Jelajahi Sumber

APP角色新增角色等级校验

wjj 1 Minggu lalu
induk
melakukan
8baf32bb33

+ 9 - 0
fs-service/src/main/java/com/fs/app/service/impl/FsAppRoleServiceImpl.java

@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.app.vo.FsAppRoleVO;
+import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fs.common.utils.StringUtils;
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Service;
 import com.fs.app.mapper.FsAppRoleMapper;
 import com.fs.app.domain.FsAppRole;
 import com.fs.app.service.IFsAppRoleService;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 /**
@@ -102,9 +104,16 @@ public class FsAppRoleServiceImpl extends ServiceImpl<FsAppRoleMapper, FsAppRole
      * @param param APP角色
      * @return 结果
      */
+    @Transactional
     @Override
     public int insertFsAppRole(FsAppRoleVO param)
     {
+        FsAppRole query = new FsAppRole();
+        query.setRoleLevel(param.getRoleLevel());
+        List<FsAppRole> fsAppRoles = fsAppRoleMapper.selectFsAppRoleList(query);
+        if (!CollectionUtils.isEmpty(fsAppRoles)) {
+            throw new CustomException("角色的等级:"+param.getRoleLevel()+"已存在");
+        }
         FsAppRole fsAppRole = new FsAppRole();
         BeanUtils.copyProperties(param, fsAppRole);
         fsAppRole.setCreateTime(DateUtils.getNowDate());