package com.hzs.system.base.provider;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hzs.common.core.domain.R;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.domain.AjaxResult;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.common.domain.system.config.BdAwardsRegionConfig;
import com.hzs.common.domain.system.config.ext.BdAwardsRegionConfigExt;
import com.hzs.system.base.IBdAwardsRegionConfigServiceApi;
import com.hzs.system.base.service.IBdAwardsRegionConfigService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 奖衔区域配置 前端控制器
 * </p>
 *
 * @author bd
 * @since 2025-07-23
 */
@DubboService
public class BdAwardsRegionConfigServiceProvider implements IBdAwardsRegionConfigServiceApi {

    @Autowired
    private IBdAwardsRegionConfigService iBdAwardsRegionConfigService;

    @Override
    public R<List<BdAwardsRegionConfig>> getMatchList(Integer value) {
        LambdaQueryWrapper<BdAwardsRegionConfig> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.le(BdAwardsRegionConfig::getAwardsValue, value);
        return R.ok(iBdAwardsRegionConfigService.list(queryWrapper));
    }

    @Override
    public R<Map<Integer, BdAwardsRegionConfigExt>> getAwardsRegionConfig() {
        Map<Integer, BdAwardsRegionConfigExt> resultMap = new HashMap<>();
        List<BdAwardsRegionConfigExt> configList = iBdAwardsRegionConfigService.listConfigAndAssess();
        for (BdAwardsRegionConfigExt bdAwardsRegionConfig : configList) {
            resultMap.put(bdAwardsRegionConfig.getAreaType(), bdAwardsRegionConfig);
        }
        return R.ok(resultMap);
    }

}
