# OverBalanceConfigController.java

    package cloud.wconnect.frontoffice.controller.guestledgercheck;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.frontoffice.pojo.dto.guestledgercheck.OverBalanceConfigDTO;
    import cloud.wconnect.frontoffice.service.guestledgercheck.IGstLedgOverBalanceConfigService;
    import com.google.common.collect.ImmutableMap;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.*;

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

    /**
     * <p>
     * 前端控制器
     * </p>
     *
     * @author zc
     * @since 2023-12-14
     */
    @RestController
    @RequestMapping("/guest-ledger-check/ov-balance/config")
    public class OverBalanceConfigController {

        @Autowired
        private IGstLedgOverBalanceConfigService overBalanceConfigService;

        @Autowired
        private SessionContext sessionContext;

        /**
         * 获取余额下限配置
         *
         * @param property 资产标识
         * @return 余额下限
         * @author zc
         * @date 2023/12/14
         */
        @ApiId(1004)
        @GetMapping
        public Map<String, BigDecimal> get(@RequestParam String property) {
            int propertyId = sessionContext.getPropertyId(property);
            return ImmutableMap.of("overBalance", overBalanceConfigService.get(propertyId));
        }

        /**
         * 保存余额下限配置
         *
         * @param property             资产标识
         * @param overBalanceConfigDTO 余额下限
         * @return empty map
         * @author zc
         * @date 2023/12/14
         */
        @ApiId(1005)
        @PostMapping
        public Map<Objects, Objects> save(@RequestParam String property,
                                          @RequestBody @Valid OverBalanceConfigDTO overBalanceConfigDTO) {
            int propertyId = sessionContext.getPropertyId(property);
            overBalanceConfigService.save(propertyId, sessionContext.getLoginUserId(), overBalanceConfigDTO);

            return Collections.emptyMap();
        }
    }