package com.jeeplus.test.mould.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.sys.domain.User;
import com.jeeplus.sys.service.dto.UserDTO;
import com.jeeplus.sys.utils.UserUtils;
import com.jeeplus.test.mould.domain.SysSerialnumTpl;
import com.jeeplus.test.mould.service.SerialnumTplService;
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 = "/sys/template")
public class SerialnumTplController {

    @Resource
    private SerialnumTplService serialnumTplService;

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

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

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

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