# RevenueMepsGroupConfigController.java

    package cloud.wconnect.rateshop.controller.revenue;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.commonlib.cons.BaseConstant;
    import cloud.wconnect.commonlib.pojo.dto.ListPagedDTO;
    import cloud.wconnect.rateshop.entity.revenue.RevenueMepsGroupConfig;
    import cloud.wconnect.rateshop.pojo.dto.revenue.MepsGroupConfigDTO;
    import cloud.wconnect.rateshop.pojo.dto.revenue.SaveMepsGroupConfigDTO;
    import cloud.wconnect.rateshop.pojo.query.revenue.MepsGroupConfigQuery;
    import cloud.wconnect.rateshop.service.revenue.IRevenueMepsGroupConfigService;
    import jakarta.validation.Valid;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.*;

    import java.util.Collections;
    import java.util.Map;

    /**
     * <p>
     * MEPS Group 显示规则 前端控制器
     * </p>
     *
     * @author yyt
     * @since 2025-06-10
     */
    @RestController
    @RequestMapping("/revenue/meps-group")
    public class RevenueMepsGroupConfigController {

        @Autowired
        private IRevenueMepsGroupConfigService revenueMepsGroupConfigService;
        @Autowired
        private SessionContext sessionContext;

        /**
         * 1524 - 查询配置列表
         *
         * @param property 资产标识
         * @param query    查询条件
         * @return 配置列表
         * @author yyt
         * @date 2025/6/10
         **/
        @ApiId(1524)
        @GetMapping
        public ListPagedDTO<MepsGroupConfigDTO> listPage(String property, @Valid MepsGroupConfigQuery query) {
            Integer propertyId = sessionContext.getPropertyId(property);
            return revenueMepsGroupConfigService.listPage(propertyId, query);
        }

        /**
         * 1525 - 保存配置
         *
         * @param property           资产标识
         * @param id                 配置id
         * @param mepsGroupConfigDTO 配置信息
         * @return {}
         * @author yyt
         * @date 2025/6/10
         **/
        @ApiId(1525)
        @PostMapping("/{id:\\d+}")
        public Map<String, Object> save(String property, @PathVariable Integer id, @Valid @RequestBody SaveMepsGroupConfigDTO mepsGroupConfigDTO) {
            Integer propertyId = sessionContext.getPropertyId(property);

            if (id == BaseConstant.ZERO) {
                // 验重
                revenueMepsGroupConfigService.checkRepeat(propertyId, Integer.parseInt(mepsGroupConfigDTO.getDate()), null);
                // 保存
                revenueMepsGroupConfigService.save(propertyId, mepsGroupConfigDTO, sessionContext.getLoginUserId());
            } else {
                // 检查配置存在
                RevenueMepsGroupConfig config = revenueMepsGroupConfigService.checkExist(id);
                // 检查资产所属
                revenueMepsGroupConfigService.checkBelong(config, propertyId);
                // 验重
                revenueMepsGroupConfigService.checkRepeat(propertyId, Integer.parseInt(mepsGroupConfigDTO.getDate()), id);
                // 更新
                revenueMepsGroupConfigService.update(config, mepsGroupConfigDTO, sessionContext.getLoginUserId());
            }

            return Collections.emptyMap();
        }

        /**
         * 1526 - 删除配置
         *
         * @param property 资产标识
         * @param id       配置id
         * @return {}
         * @author yyt
         * @date 2025/6/11
         **/
        @ApiId(1526)
        @DeleteMapping("/{id:\\d+}")
        public Map<String, Object> delete(String property, @PathVariable Integer id) {
            Integer propertyId = sessionContext.getPropertyId(property);
            // 检查配置存在
            RevenueMepsGroupConfig config = revenueMepsGroupConfigService.checkExist(id);
            // 检查资产所属
            revenueMepsGroupConfigService.checkBelong(config, propertyId);
            // 删除
            revenueMepsGroupConfigService.delete(id);

            return Collections.emptyMap();
        }

    }