mitao
2024-04-12 a7a8a50f48c1bff5ddc52b3bad1782328f8043d8
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbDataScreenConfigServiceImpl.java
@@ -12,6 +12,7 @@
import com.ruoyi.system.service.TbDataScreenConfigService;
import com.ruoyi.system.vo.DataScreenConfigVO;
import java.util.List;
import java.util.Objects;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -33,14 +34,18 @@
        TbDataScreenConfig tbDataScreenConfig = this.lambdaQuery()
                .eq(TbDataScreenConfig::getType, DataScreenConfigEnum.RISK_LEVEL)
                .one();
        return BeanUtils.copyBean(tbDataScreenConfig, DataScreenConfigVO.class);
        return Objects.nonNull(tbDataScreenConfig) ? BeanUtils.copyBean(tbDataScreenConfig,
                DataScreenConfigVO.class) : new DataScreenConfigVO();
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public DataScreenConfigVO editRiskLevel(RiskLevelUpdDTO dto) {
        TbDataScreenConfig tbDataScreenConfig = BeanUtils.copyBean(dto,
                TbDataScreenConfig.class);
        //查询是否有该指标配置
        TbDataScreenConfig tbDataScreenConfig = this.lambdaQuery()
                .eq(TbDataScreenConfig::getType, DataScreenConfigEnum.RISK_LEVEL)
                .oneOpt().orElseGet(() -> BeanUtils.copyBean(dto,
                        TbDataScreenConfig.class));
        tbDataScreenConfig.setType(DataScreenConfigEnum.RISK_LEVEL);
        this.saveOrUpdate(tbDataScreenConfig);
        return BeanUtils.copyBean(tbDataScreenConfig, DataScreenConfigVO.class);
@@ -56,8 +61,12 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public DataScreenConfigVO editDataIndicatorsConfig(DataIndicatorsUpdDTO dto) {
        TbDataScreenConfig tbDataScreenConfig = BeanUtils.copyBean(dto,
                TbDataScreenConfig.class);
        //查询是否有该指标配置
        TbDataScreenConfig tbDataScreenConfig = this.lambdaQuery()
                .eq(TbDataScreenConfig::getType, DataScreenConfigEnum.DATA_INDICATORS)
                .eq(TbDataScreenConfig::getSubType,
                        dto.getSubType()).oneOpt().orElseGet(() -> BeanUtils.copyBean(dto,
                        TbDataScreenConfig.class));
        tbDataScreenConfig.setType(DataScreenConfigEnum.DATA_INDICATORS);
        this.saveOrUpdate(tbDataScreenConfig);
        return BeanUtils.copyBean(tbDataScreenConfig, DataScreenConfigVO.class);
@@ -66,8 +75,12 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public DataScreenConfigVO editFormalIndicatorsConfig(FormalIndicatorsUpdDTO dto) {
        TbDataScreenConfig tbDataScreenConfig = BeanUtils.copyBean(dto,
                TbDataScreenConfig.class);
        //查询是否有该指标配置
        TbDataScreenConfig tbDataScreenConfig = this.lambdaQuery()
                .eq(TbDataScreenConfig::getType, DataScreenConfigEnum.FORMAL_INDICATORS)
                .eq(TbDataScreenConfig::getSubType,
                        dto.getSubType()).oneOpt().orElseGet(() -> BeanUtils.copyBean(dto,
                        TbDataScreenConfig.class));
        tbDataScreenConfig.setType(DataScreenConfigEnum.FORMAL_INDICATORS);
        this.saveOrUpdate(tbDataScreenConfig);
        return BeanUtils.copyBean(tbDataScreenConfig, DataScreenConfigVO.class);