package com.ningdatech.carapi.sys.controller;


import com.ningdatech.carapi.sys.entity.req.ReqCodingRulePO;
import com.ningdatech.carapi.sys.entity.vo.ResCodingRuleVO;
import com.ningdatech.carapi.sys.manage.CodingRuleManage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
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 Liuxinxin
 * @since 2022-10-20
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/coding-rule")
@Api(tags = "赋码规则")
@RequiredArgsConstructor
public class CodingRuleController {

    private final CodingRuleManage codingRuleManage;

    @ApiOperation(value = "获取赋码规则")
    @PostMapping("/get")
    public ResCodingRuleVO getCodingRule() {
        return codingRuleManage.getCodingRule();
    }

    @ApiOperation(value = "保存赋码规则")
    @PostMapping("/save")
    public void saveCodingRule(@Valid @RequestBody ReqCodingRulePO request) {
        codingRuleManage.saveCodingRule(request);
    }
}
