From a7a8a50f48c1bff5ddc52b3bad1782328f8043d8 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期五, 12 四月 2024 18:50:20 +0800
Subject: [PATCH] 基础数据配置接口修改

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbDataScreenConfigServiceImpl.java |   70 ++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 1 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbDataScreenConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbDataScreenConfigServiceImpl.java
index 87624d8..cec2e79 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbDataScreenConfigServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbDataScreenConfigServiceImpl.java
@@ -1,10 +1,20 @@
 package com.ruoyi.system.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.enums.DataScreenConfigEnum;
+import com.ruoyi.common.utils.BeanUtils;
 import com.ruoyi.system.domain.TbDataScreenConfig;
+import com.ruoyi.system.dto.update.DataIndicatorsUpdDTO;
+import com.ruoyi.system.dto.update.FormalIndicatorsUpdDTO;
+import com.ruoyi.system.dto.update.RiskLevelUpdDTO;
 import com.ruoyi.system.mapper.TbDataScreenConfigMapper;
+import com.ruoyi.system.query.DataScreenConfigQuery;
 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;
 
 /**
  * <p>
@@ -15,6 +25,64 @@
  * @since 2024-03-13
  */
 @Service
-public class TbDataScreenConfigServiceImpl extends ServiceImpl<TbDataScreenConfigMapper, TbDataScreenConfig> implements TbDataScreenConfigService {
+public class TbDataScreenConfigServiceImpl extends
+        ServiceImpl<TbDataScreenConfigMapper, TbDataScreenConfig> implements
+        TbDataScreenConfigService {
 
+    @Override
+    public DataScreenConfigVO getRiskLevel() {
+        TbDataScreenConfig tbDataScreenConfig = this.lambdaQuery()
+                .eq(TbDataScreenConfig::getType, DataScreenConfigEnum.RISK_LEVEL)
+                .one();
+        return Objects.nonNull(tbDataScreenConfig) ? BeanUtils.copyBean(tbDataScreenConfig,
+                DataScreenConfigVO.class) : new DataScreenConfigVO();
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public DataScreenConfigVO editRiskLevel(RiskLevelUpdDTO dto) {
+        //查询是否有该指标配置
+        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);
+    }
+
+    @Override
+    public List<DataScreenConfigVO> getIndicatorsConfig(DataScreenConfigQuery query) {
+        List<TbDataScreenConfig> list = this.lambdaQuery()
+                .eq(TbDataScreenConfig::getType, query.getType()).list();
+        return BeanUtils.copyList(list, DataScreenConfigVO.class);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public DataScreenConfigVO editDataIndicatorsConfig(DataIndicatorsUpdDTO dto) {
+        //查询是否有该指标配置
+        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);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public DataScreenConfigVO editFormalIndicatorsConfig(FormalIndicatorsUpdDTO dto) {
+        //查询是否有该指标配置
+        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);
+    }
 }

--
Gitblit v1.7.1