package com.steerinfo.ems.tcm0313.controller;

import com.steerinfo.ems.tcm0312.model.TCm0312;
import com.steerinfo.ems.tcm0313.model.TCm0313;
import com.steerinfo.ems.tcm0313.service.ITCm0313Service;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * TCm0313 RESTful接口：
 * @author 王金涛
 * @version 1.0-SNAPSHORT 2019-10-16 08:38
 * 类描述
 * 修订历史：
 * 日期：2019-10-16
 * 作者：王金涛
 * 参考：
 * 描述：TCm0313 RESTful接口
 * @see null
 * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
 */
@RestController
@RequestMapping("/${api.version}/tcm0313s")
public class TCm0313Controller extends BaseRESTfulController {

    @Autowired
    ITCm0313Service tCm0313Service;

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

    @ApiOperation(value = "更新详细信息", notes = "根据url的id来指定更新对象，并根据传过来的tCm0313信息来更新详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String"),
            @ApiImplicitParam(name = "tCm0313", value = "详细实体tCm0313", required = true, dataType = "TCm0313")
    })
    //@RequiresPermissions("tcm0313:update")
    @PutMapping(value = "/{id}")
    public RESTfulResult updatelimit(@PathVariable String id, @RequestBody TCm0313 model) {
        model.setRecordid(id);
        TCm0313 tCm0313 = tCm0313Service.updatelimit(model);
        return success(tCm0313);
    }

    /**
     @ApiOperation(value="创建", notes="根据TCm0313数组集创建")
     @ApiImplicitParam(name="model", value="TCm0313数组集", required=true,allowMultiple=true, dataType = "TCm0313")
     //@RequiresPermissions("tcm0313:create")
     @PostMapping(value = "/")
     public RESTfulResult add(List<TCm0313> model){
     tCm0313Service.batchAdd(model);
     return success();
     }

     @ApiOperation(value="创建", notes="根据TCm0313对象创建")
     @ApiImplicitParam(name = "tCm0313", value = "详细实体tCm0313", required = true, dataType = "TCm0313")
     //@RequiresPermissions("tcm0313:create")
     @PostMapping(value = "/")
     public RESTfulResult add(@RequestBody TCm0313 model){
     if(tCm0313Service.getById(model.getRecordid()) != null){
     return failed(null, "id已存在，不能新增");
     }
     else {
     TCm0313 tCm0313 = tCm0313Service.add(model);
     return success(tCm0313);
     }
     }

     @ApiOperation(value="获取详细信息", notes="根据url的id来获取详细信息")
     @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String")
     //@RequiresPermissions("tcm0313:view")
     @GetMapping(value = "/{id}")
     public RESTfulResult get(@PathVariable String id){
     TCm0313 tCm0313 = tCm0313Service.getById(id);
     return success(tCm0313);
     }
     @ApiOperation(value="删除", notes="根据用户id数组集获得用户集合信息")
     @ApiImplicitParam(name="Ids", value="用户ID数组集", required=true, paramType="query" ,allowMultiple=true, dataType = "Long")
     @DeleteMapping(value = "/")
     public RESTfulResult delete(@RequestBody List<String> Ids){
     if (Ids.size() == 1) {
     tCm0313Service.delete(Ids.get(0));
     } else {
     tCm0313Service.delete(Ids);
     }
     return success();
     }

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