package com.cm.common.plugin.controller.apis.dynamic;

import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormFormShowFieldDTO;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormListShowFieldDTO;
import com.cm.common.plugin.service.dynamic.IDynamicFormService;
import com.cm.common.result.ErrorResult;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: DynamicFormController
 * @Description: 动态表单
 * @Author: WangGeng
 * @Date: 2019/12/2 3:54 下午
 * @Version: 1.0
 **/
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/dynamicform")
public class DynamicFormController extends AbstractController {

    @Autowired
    private IDynamicFormService dynamicFormService;

    @ApiOperation(value = "列表显示的字段", notes = "列表显示的字段接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tableName", value = "表名", paramType = "path"),
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("listlistshowfieldofpage/{tableName}")
    public List<DynamicFormListShowFieldDTO> listListShowFieldOfPage(@PathVariable("tableName") String tableName) {
        return dynamicFormService.listListShowFieldOfPage(tableName);
    }

    @ApiOperation(value = "表单显示的字段", notes = "表单显示的字段接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tableName", value = "表名", paramType = "path"),
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("listformshowfieldofpage/{tableName}")
    public List<DynamicFormFormShowFieldDTO> listFormShowFieldOfPage(@PathVariable("tableName") String tableName) {
        return dynamicFormService.listFormShowFieldOfPage(tableName);
    }

}
