package com.dk.mdm.controller.mst;

import com.dk.common.infrastructure.constant.Constant;
import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultVO;
import com.dk.mdm.model.pojo.mst.PrintLayout;
import com.dk.common.service.BaseService;
import com.dk.mdm.service.common.CommonService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import com.dk.mdm.service.mst.PrintLayoutService;

import java.util.Map;

@Api(tags = "打印模版API接口")
@RestController
@RequestMapping("/mst/printLayout")
public class PrintLayoutController{

    public BaseService<PrintLayout> getService() {
        return printLayoutService;
    }

    @Autowired
    private PrintLayoutService printLayoutService;

    /**
     * @desc   : 条件查询
     * @author : 张潇木
     * @date   : 2024/4/9 9:02
     */
    @ApiOperation( value = "分页、关联、条件查询", notes = "分页、关联、条件查询" )
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<PrintLayout>> selectByCond(@RequestBody PrintLayout printLayout) {
        return printLayoutService.selectByCond(printLayout);
    }

    /**
     * @desc : 新建
     * @author : 张潇木
     * @date   : 2024/4/9 9:02
     */
    @ApiOperation( value = "新建", notes = "新建" )
    @PostMapping({"insert"})
    public ResponseResultVO<?> insert(@RequestBody PrintLayout printLayout) {
        return printLayoutService.insert(printLayout);
    }

    /**
     * @desc : 编辑
     * @author : 张潇木
     * @date   : 2024/4/9 9:02
     */
    @ApiOperation( value = "编辑", notes = "编辑" )
    @PostMapping({"update"})
    public ResponseResultVO<?> update(@RequestBody PrintLayout printLayout) {
        return printLayoutService.update(printLayout);
    }

    /**
     * @desc   : 明细查询
     * @author : 张潇木
     * @date   : 2024/4/9 9:02
     */
    @PostMapping({"/{id}"})
    public ResponseResultVO<?> selectById(@PathVariable String id) {
        return this.getService().selectById(id);
    }


    /**
     * @desc    : 停用
     * @author : 张潇木
     * @date   : 2024/4/9 9:02
     */
    @PostMapping("disable/{id}")
    public ResponseResultVO<Boolean> disable(@PathVariable String id) {
        return this.getService().disable(id);
    }

    /**
     * @desc    : 启用
     * @author : 张潇木
     * @date   : 2024/4/9 9:02
     */
    @PostMapping("enable/{id}")
    public ResponseResultVO<Boolean> enable(@PathVariable String id) {
        return this.getService().enable(id);
    }

    /**
     * @desc : 查询打印数据
     * @author : 周兴
     * @date : 2024/4/22 15:28
     */
    @PostMapping("get_print_data")
    public ResponseResultVO<?> getPrintData(@RequestBody Map<String, Object> param) {
        return printLayoutService.getPrintData(param);
    }
}
