Browse Source

修改设置设置巴主自动设置权限

anderx 3 years ago
parent
commit
51022adeda

+ 30 - 8
src/main/java/com/goafanti/ambSystem/service/Impl/AmbServiceImpl.java

@@ -8,6 +8,7 @@ import com.goafanti.common.dao.*;
 import com.goafanti.common.error.BusinessException;
 import com.goafanti.common.model.Admin;
 import com.goafanti.common.model.AmbSystem;
+import com.goafanti.common.model.UserRole;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
@@ -27,11 +28,9 @@ public class AmbServiceImpl extends BaseMybatisDao<AmbSystemMapper> implements A
     @Autowired
     private AdminMapper adminMapper;
     @Autowired
-    private AmbInvestLogMapper ambInvestLogMapper;
+    private UserRoleMapper userRoleMapper;
     @Autowired
-    private AmbInvestMapper ambInvestMapper;
-    @Autowired
-    private RoleMapper roleMapper;
+    private RoleMapper  roleMapper;
 
 
     @Override
@@ -95,11 +94,34 @@ public class AmbServiceImpl extends BaseMybatisDao<AmbSystemMapper> implements A
         StringBuffer str=new StringBuffer();
         List<AmbSystem> list=selectByLeader(leader);
         Admin a =new Admin();
-        for (AmbSystem ambSystem : list) {
-            if (ambSystem.getLvl()==5||ambSystem.getLvl()==6){
-                a.setAmbManage(1);
+        if (!list.isEmpty()){
+            //不为空就是巴主,如果不是巴主则设置成巴主
+            List<UserRole> al = userRoleMapper.selectAdminRole("巴主");
+            String roleId = roleMapper.selectIdByName("巴主");
+            boolean flag=false;
+            if (al.isEmpty()){
+                flag=true;
+            }else {
+                flag=true;
+                for (UserRole userRole : al) {
+                    if (userRole.getUid().equals(leader)){
+                        flag=false;
+                    }
+                }
+            }
+            if (flag){
+                UserRole userRole=new UserRole();
+                userRole.setUid(leader);
+                userRole.setRid(roleId);
+                userRoleMapper.insert(userRole);
+            }
+            for (AmbSystem ambSystem : list) {
+                if (ambSystem.getLvl()==5||ambSystem.getLvl()==6){
+                    a.setAmbManage(1);
+                }
+                str.append(ambSystem.getLvl()).append(",");
+
             }
-            str.append(ambSystem.getLvl()).append(",");
 
         }
         a.setId(leader);

+ 6 - 1
src/main/java/com/goafanti/common/dao/UserRoleMapper.java

@@ -24,7 +24,12 @@ public interface UserRoleMapper {
 
 	List<String> listAuditor();
 
+	/**
+	 * 获取角色对应管理员编号
+	 * @param roleName
+	 * @return
+	 */
 	List<UserRole> selectAdminRole(String roleName);
 
     Role selectById(String roleId);
-}
+}

+ 8 - 2
src/main/java/com/goafanti/common/mapper/AmbInvestMapper.xml

@@ -149,10 +149,10 @@
     <if test="startTime!=null and endTime !=null">
       and a.create_time between #{startTime} and #{endTime}
     </if>
-    <if test="type==2 ">
+    <if test="roleType==2 ">
       and a.initiate_amb_id= #{ambId}
     </if>
-    <if test="type==3">
+    <if test="roleType==3">
       and a.accept_amb_id = #{ambId}
     </if>
     order by a.create_time desc
@@ -174,6 +174,12 @@
     <if test="startTime!=null and endTime !=null">
       and a.create_time between #{startTime} and #{endTime}
     </if>
+    <if test="roleType==2 ">
+      and a.initiate_amb_id= #{ambId}
+    </if>
+    <if test="roleType==3">
+      and a.accept_amb_id = #{ambId}
+    </if>
   </select>
   <select id="selectCountAmountById" resultType="java.lang.Integer">
     select sum(amount)amount