package com.jeeplus.psimanage.serialNumTpl.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.core.query.QueryWrapperGenerator;
import com.jeeplus.psimanage.serialNumTpl.domain.PsiSysSerialnumTpl;
import com.jeeplus.psimanage.serialNumTpl.service.PsiSerialnumTplService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags ="template")
@RestController
@RequestMapping(value = "/psi/template")
public class PsiSerialnumTplController {

    @Resource
    private PsiSerialnumTplService psiSerialnumTplService;

    /**
     * 编号模板列表
     */
    @ApiOperation(value = "编号模板列表")
    @GetMapping(value = "/list")
    public ResponseEntity<IPage<PsiSysSerialnumTpl>> list(Page<PsiSysSerialnumTpl> page, PsiSysSerialnumTpl psiSysSerialnumTpl) throws Exception{
        QueryWrapper<PsiSysSerialnumTpl> sysSerialnumTplQueryWrapper = QueryWrapperGenerator.buildQueryCondition(psiSysSerialnumTpl, PsiSysSerialnumTpl.class);
        IPage<PsiSysSerialnumTpl> list = psiSerialnumTplService.list(page, sysSerialnumTplQueryWrapper);
        return ResponseEntity.ok (list);
    }

    /**
     * 编号模板删除
     */
    @ApiOperation(value = "编号模板列表")
    @GetMapping(value = "/remove")
    public String remove(@RequestParam String id){
        return psiSerialnumTplService.remove(id);
    }

    /**
     * 编号模板查询
     */
    @ApiOperation(value = "编号模板列表")
    @GetMapping(value = "/findById")
    public PsiSysSerialnumTpl findById(@RequestParam String id){
        return psiSerialnumTplService.findById(id);
    }

    /**
     * 编号模板保存、修改
     */
    @ApiOperation(value = "编号模板保存、修改")
    @PostMapping(value = "/save")
    public String save(@RequestBody PsiSysSerialnumTpl psiSysSerialnumTpl){
        return psiSerialnumTplService.save(psiSysSerialnumTpl);
    }
}
