package com.steerinfo.ems.tcmcodeinfo.controller;
import com.steerinfo.ems.tcmcodeinfo.model.TCmCodeInfo;
import com.steerinfo.ems.tcmcodeinfo.service.TCmCodeInfoService;
import com.steerinfo.framework.controller.BaseRESTfulController;
import com.steerinfo.framework.controller.RESTfulResult;
import com.steerinfo.framework.service.pagehelper.PageList;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * @author 李日量
 * @Date 2019/9/27 9:30
 * @Copyright 湖南视拓信息技术股份有限公司
 */
@RestController
@RequestMapping("/${api.version}/tcmcodeinfo")
public class TCmCodeInfoController extends BaseRESTfulController {

    @Autowired
    private TCmCodeInfoService tCmCodeInfoService;

    @ApiOperation(value="获取列表", notes="分页模糊查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
    })
    //@RequiresPermissions("trmenergytype:view")
    @GetMapping(value = "/All")
    public RESTfulResult listLike(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize){
        PageList<TCmCodeInfo> list = tCmCodeInfoService.queryLikeForPage(parmas, pageNum, pageSize);
        return success(list);
    }


    @ApiOperation(value="创建", notes="根据TCmCodeInfo对象创建")
    @ApiImplicitParam(name = "tCmCodeInfo", value = "详细实体tCmCodeInfo", required = true, dataType = "TCmCodeInfo")
    @PostMapping(value = "/save")
    public RESTfulResult add(@RequestBody TCmCodeInfo model){
        TCmCodeInfo tCmCodeInfo = tCmCodeInfoService.add(model);
        return success(tCmCodeInfo);
    }

}
