package com.xjrsoft.module.print.controller;

import com.xjrsoft.common.constant.GlobalConstant;
import com.xjrsoft.common.model.result.R;
import com.xjrsoft.module.print.dto.PrintConfigInfoDto;
import com.xjrsoft.module.print.dto.PrintSetConfigDto;
import com.xjrsoft.module.print.service.IPrintConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tzx
 * @since 2023-05-23
 */
@RestController
@RequestMapping(GlobalConstant.PRINT_MODULE_PREFIX + "/config")
@Api(value = GlobalConstant.PRINT_MODULE_PREFIX + "/config", tags = "打印配置模块")
@AllArgsConstructor
public class PrintConfigController {

    private final IPrintConfigService printConfigService;

    @PostMapping
    @ApiOperation(value = "设置打印按钮配置")
    public R set(@Valid @RequestBody PrintSetConfigDto dto){
        return R.ok(printConfigService.setConfig(dto));
    }

    @GetMapping("/info")
    @ApiOperation(value = "获取打印按钮配置")
    public R info(@Valid PrintConfigInfoDto dto){
        return R.ok(printConfigService.getInfo(dto));
    }

}
