package cn.com.tenlion.configtable.controller.api.configtableoperation;

import cn.com.tenlion.configtable.pojo.dtos.configtablefield.ConfigTableFieldDTO;
import cn.com.tenlion.configtable.pojo.dtos.configtableoperation.ConfigTableOperationDTO;
import cn.com.tenlion.configtable.pojo.vos.configtablefield.ConfigTableFieldVO;
import cn.com.tenlion.configtable.service.configtablefield.IConfigTableFieldService;
import cn.com.tenlion.configtable.service.configtableoperation.IConfigTableOperationService;
import cn.com.tenlion.configtable.service.configtableoperation.IConfigTableOperationSubService;
import com.alibaba.fastjson.JSONArray;
import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultData;
import ink.wgink.pojo.result.SuccessResultList;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: ConfigTableOperationController
 * @Description: 
 * @Author: CodeFactory
 * @Date: 2021-06-24 11:06:57
 * @Version: 3.0
 **/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "接口")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/configtableoperation")
public class ConfigTableOperationController extends DefaultBaseController {

    @Autowired
    private IConfigTableOperationSubService configTableOperationSubService;

    @ApiOperation(value = "获得动态表单列名集合", notes = "列表接口")
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("list/{configTableCode}")
    public List<ConfigTableOperationDTO> list(@PathVariable("configTableCode") String configTableCode) {
        return configTableOperationSubService.getTableFieldConfig(configTableCode);
    }

    @ApiOperation(value = "分页列表", notes = "分页列表接口")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
        @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
        @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
        @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
        @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("listpage")
    public SuccessResultList<List<Map<String, Object>>> listPage(ListPage page) {
        Map<String, Object> params = requestParams();
        page.setParams(params);
        SuccessResultList<List<Map<String, Object>>> result = configTableOperationSubService.listPage(page);
        return result;
    }

}