# RevenueAdrConfigController.java

    package cloud.wconnect.rateshop.controller.revenue;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.rateshop.entity.revenue.RevenueAdrConfig;
    import cloud.wconnect.rateshop.pojo.dto.revenue.AdrConfigDTO;
    import cloud.wconnect.rateshop.service.revenue.IRevenueAdrConfigService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.*;

    import jakarta.validation.Valid;
    import java.util.Collections;
    import java.util.Map;
    import java.util.Objects;

    /**
     * <p>
     * adr 配置，导入报告时，根据当前配置规则来计算 adr 前端控制器
     * </p>
     *
     * @author yyt
     * @since 2023-10-26
     */
    @RestController
    @RequestMapping("/revenue/adr-config")
    public class RevenueAdrConfigController {

        @Autowired
        private SessionContext sessionContext;
        @Autowired
        private IRevenueAdrConfigService revenueAdrConfigService;

        /**
         * 获取 adr 配置
         *
         * @param property 资产标识
         * @return adr 配置
         * @author yyt
         * @date 2023/10/28
         */
        @ApiId(879)
        @GetMapping
        public AdrConfigDTO get(String property) {
            RevenueAdrConfig adrConfig = revenueAdrConfigService.get(sessionContext.getPropertyId(property));
            // 默认都是 false: 未勾选
            return Objects.isNull(adrConfig) ?
                    new AdrConfigDTO(false, false, false, false)
                    : new AdrConfigDTO(adrConfig.getCheckTransientDeduct(), adrConfig.getCheckTransientNonDeduct(),
                    adrConfig.getCheckGroupDeduct(), adrConfig.getCheckGroupNonDeduct());
        }

        /**
         * 修改 adr 配置
         *
         * @param property     资产标识
         * @param adrConfigDTO adr 配置
         * @return {}
         * @author yyt
         * @date 2023/10/28
         */
        @ApiId(880)
        @PostMapping
        public Map save(String property, @Valid @RequestBody AdrConfigDTO adrConfigDTO) {
            revenueAdrConfigService.save(sessionContext.getPropertyId(property), adrConfigDTO,
                    sessionContext.getLoginUserId());
            return Collections.emptyMap();
        }

    }