package com.cm.common.plugin.controller.routes.dynamic.config.form;

import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
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.servlet.ModelAndView;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: DynamicConfigSubRouteController
 * @Description: 动态配置-表单
 * @Author: WangGeng
 * @Date: 2019/12/7 5:23 下午
 * @Version: 1.0
 **/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "动态配置-表单接口")
@Controller
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/dynamicconfigtable/dynamicconfigform")
public class DynamicConfigFormRouteController extends AbstractController {

    @ApiOperation(value = "新增页面", notes = "新增页面接口")
    @GetMapping("save/{tableName}")
    public ModelAndView save(@PathVariable("tableName") String tableName) {
        ModelAndView mv = new ModelAndView("dynamic/config/form/save");
        mv.addObject("tableName", tableName);
        return mv;
    }

    @ApiOperation(value = "编辑页面", notes = "编辑页面接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", paramType = "path")
    })
    @GetMapping("update/{id}")
    public ModelAndView update(@PathVariable("id") String id) {
        ModelAndView mv = new ModelAndView("dynamic/config/form/update");
        mv.addObject("id", id);
        return mv;
    }

    @ApiOperation(value = "列表页面", notes = "列表页面接口")
    @GetMapping("list/{tableName}")
    public ModelAndView list(@PathVariable("tableName") String tableName) {
        ModelAndView mv = new ModelAndView("dynamic/config/form/list");
        mv.addObject("tableName", tableName);
        return mv;
    }

}
