package com.njcn.gather.tool.adddata.controller;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.gather.tool.adddata.pojo.enums.AddDataStorageTypeEnum;
import com.njcn.gather.tool.adddata.pojo.vo.AddDataStorageTypeVO;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * add-data 入库类型接口。
 */
@Api(tags = "数据补录入库类型")
@RestController
@RequestMapping("/addData/storage-type")
public class AddDataStorageTypeController extends BaseController {

    /**
     * 查询当前支持的入库类型。
     *
     * @return 入库类型列表
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("查询数据补录入库类型")
    @GetMapping("/list")
    public HttpResult<List<AddDataStorageTypeVO>> list() {
        String methodDescribe = getMethodDescribe("list");
        List<AddDataStorageTypeVO> result = new ArrayList<AddDataStorageTypeVO>();
        for (AddDataStorageTypeEnum storageType : AddDataStorageTypeEnum.values()) {
            AddDataStorageTypeVO vo = new AddDataStorageTypeVO();
            vo.setCode(storageType.getCode());
            vo.setName(storageType.getName());
            result.add(vo);
        }
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }
}
