Ver Fonte

字典项权限判断

wujiefeng há 1 ano atrás
pai
commit
53df34dd04

+ 2 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/init/DictionaryInit.java

@@ -83,6 +83,7 @@ public class DictionaryInit implements ApplicationRunner {
             dictionary.setProjectId(projectId);
             dictionary.setType(DictionaryType.Standard);
             dictionary.setDisabled(false);
+            dictionary.setPermission(dict.getPermission());
             dictionaryDao.save(dictionary);
         }
         return dictionary;
@@ -104,6 +105,7 @@ public class DictionaryInit implements ApplicationRunner {
             item.setIdString(id);
             item.setCreateTime(System.currentTimeMillis());
             item.setDisable(false);
+            item.setPermission(dict.getPermission());
             dictionaryItemDao.save(item);
         }
 

+ 20 - 3
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/dictionary/DictionaryService.java

@@ -6,6 +6,7 @@ import com.github.microservice.components.data.base.util.PageEntityUtil;
 import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.model.dictionary.*;
+import com.zhongshu.card.client.type.DictionaryPermission;
 import com.zhongshu.card.client.type.DictionaryType;
 import com.zhongshu.card.client.type.DictionaryUpdateStatus;
 import com.zhongshu.card.server.core.dao.dictionary.DictionaryDao;
@@ -109,7 +110,9 @@ public class DictionaryService extends SuperService {
             return ResultContent.buildFail("数据不存在");
         }
         if (DictionaryType.Standard.equals(dictionary.getType())){
-            return ResultContent.buildFail("标准字典不允许删除");
+            if (dictionary.getPermission() == null || !dictionary.getPermission().contains(DictionaryPermission.delete)){
+                return ResultContent.buildFail("标准字典不允许删除");
+            }
         }
         dictionaryDao.deleteById(id);
         //TODO 删除字典下的字典项
@@ -152,7 +155,19 @@ public class DictionaryService extends SuperService {
         }
 
         if (dictionary.getType().equals(DictionaryType.Standard)){
-            return ResultContent.buildFail("标准字典不允许添加项");
+            List<DictionaryPermission> permission = dictionary.getPermission();
+            if (permission==null || !permission.contains(DictionaryPermission.add)){
+                return ResultContent.buildFail("该字典不允许添加项");
+            }
+        }
+
+        if (param.getParentId()!=null){
+            DictionaryItem parentItem = dictionaryItemDao.findTopById(param.getParentId());
+            if (parentItem != null && parentItem.getType().equals(DictionaryType.Standard)){
+                if (parentItem.getPermission() == null || !parentItem.getPermission().contains(DictionaryPermission.add)){
+                    return ResultContent.buildFail("该项不允许添加下级");
+                }
+            }
         }
 
         DictionaryItem updateItem = dictionaryItemDao.findTopByDictionary_IdAndKey(param.getDictionaryId(), param.getKey());
@@ -213,7 +228,9 @@ public class DictionaryService extends SuperService {
             return ResultContent.buildFail("数据不存在");
         }
         if (DictionaryType.Standard.equals(dictionaryItem.getType())){
-            return ResultContent.buildFail("标准字典的项不允许删除");
+            if (dictionaryItem.getPermission() == null || dictionaryItem.getPermission().contains(DictionaryPermission.delete)){
+                return ResultContent.buildFail("标准字典的项不允许删除");
+            }
         }
         dictionaryItemDao.deleteById(id);
         return ResultContent.buildSuccess();

+ 5 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/pay/PayAccountService.java

@@ -162,7 +162,11 @@ public class PayAccountService {
         payAccount.setUserId(userId);
         payAccount.setPaymentChannelType(channelType);
         payAccount.setLevel(PayAccountLevel.UserChildren);
-        String ledgerId = createLedger(new String[]{projectOid, userId}, "用户子账-" + channelType.getRemark(), parent.getLedgerId(), Map.of("projectOid", projectOid, "paymentChannelType", channelType, "userId", userId) , 999999999L, 0L);
+        Long rangeMin = -9999999999999L;
+        if (channelType.equals(PaymentChannelType.BalancePayment)){
+            rangeMin = 0L;
+        }
+        String ledgerId = createLedger(new String[]{projectOid, userId}, "用户子账-" + channelType.getRemark(), parent.getLedgerId(), Map.of("projectOid", projectOid, "paymentChannelType", channelType, "userId", userId) , 999999999L, rangeMin);
         if (StringUtils.isBlank(ledgerId)){
             throw new Exception("支付中心创建用户子账失败");
         }