Browse Source

阿米巴开发

anderx 3 years ago
parent
commit
5bcae45847

+ 1 - 2
src/main/java/com/goafanti/ambSystem/bo/OutAmb.java

@@ -1,9 +1,8 @@
 package com.goafanti.ambSystem.bo;
 
-import com.goafanti.common.model.AmbSystem;
 
 
-public class OutAmb extends AmbSystem{
+public class OutAmb {
     /**
      * 部门id
      */

+ 7 - 0
src/main/java/com/goafanti/ambSystem/service/Impl/AmbServiceImpl.java

@@ -5,17 +5,21 @@ import com.goafanti.ambSystem.bo.InputAmb;
 import com.goafanti.ambSystem.bo.OutAmb;
 import com.goafanti.ambSystem.service.AmbService;
 import com.goafanti.common.dao.AmbSystemMapper;
+import com.goafanti.common.error.BusinessException;
 import com.goafanti.common.model.AmbSystem;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
 
 @Service
 public class AmbServiceImpl extends BaseMybatisDao<AmbSystemMapper> implements AmbService {
+    @Value(value = "${amb.maxLvl}")
+    private Integer maxLvl=null;
     @Autowired
     private AmbSystemMapper ambSystemMapper;
 
@@ -23,6 +27,7 @@ public class AmbServiceImpl extends BaseMybatisDao<AmbSystemMapper> implements A
     public int addAmb(InputAmb in) {
         AmbSystem parentAmb = ambSystemMapper.selectByPrimaryKey(in.getParentId());
         in.setLvl(parentAmb.getLvl()+1);
+        if (in.getLvl()>maxLvl)throw new BusinessException(String.format("层级最多添加%s层,如需添加更多请联系管理员。",maxLvl));
         in.setAncestors(parentAmb.getAncestors()+","+parentAmb.getId());
         in.setAncestorsNames(getAncestorsNames(in.getAncestors()));
         in.setStatus("0");
@@ -36,6 +41,7 @@ public class AmbServiceImpl extends BaseMybatisDao<AmbSystemMapper> implements A
         if (in.getParentId()!=null){
             AmbSystem parentAmb = ambSystemMapper.selectByPrimaryKey(in.getParentId());
             in.setLvl(parentAmb.getLvl()+1);
+            if (in.getLvl()>maxLvl)throw new BusinessException(String.format("层级最多添加%s层,如需添加更多请联系管理员。",maxLvl));
             in.setAncestors(parentAmb.getAncestors()+","+parentAmb.getId());
             in.setAncestorsNames(getAncestorsNames(in.getAncestors()));
         }
@@ -49,6 +55,7 @@ public class AmbServiceImpl extends BaseMybatisDao<AmbSystemMapper> implements A
         HashMap<String, Object> param = new HashMap<>();
         param.put("name",in.getName());
         param.put("lvl",in.getLvl());
+        param.put("leader",in.getLeader());
         param.put("ancestors",in.getAncestors());
         return (Pagination<OutAmb>) findPage("selectAmbSystemList","selectAmbSystemCount",param,in.getPageNo(),in.getPageSize());
     }

+ 10 - 3
src/main/java/com/goafanti/common/mapper/AmbSystemMapper.xml

@@ -193,9 +193,9 @@
 
   <select id="getAncestorsList" resultType="com.goafanti.ambSystem.bo.AmbAll">
     select id,name,lvl,parent_id parentId
-    from amb_system
+    from amb_system where status=0
     <if test="list !=null and list.size>0 ">
-    where id in
+    and  id in
     <foreach close=")" collection="list" item="id" open="(" separator=",">
       #{id}
     </foreach>
@@ -203,7 +203,8 @@
   </select>
 
   <select id="selectAmbSystemList" resultType="com.goafanti.ambSystem.bo.OutAmb">
-    select a.id,a.name ,a.ancestors_names ancestorsNames ,b.name leaderName,c.name financeName
+    select a.id,a.name ,a.ancestors_names ancestorsNames ,
+    b.name leaderName,c.name financeName
     from amb_system a
     left join admin b on a.leader =b.id
     left join admin c on a.finance_id =c.id
@@ -211,6 +212,9 @@
     <if test="lvl !=null">
       and a.lvl= #{lvl}
     </if>
+    <if test="leader !=null">
+      and a.leader= #{leader}
+    </if>
     <if test="name !=null">
       and a.name  like concat('%',#{name},'%')
     </if>
@@ -232,6 +236,9 @@
     <if test="lvl !=null">
       and a.lvl= #{lvl}
     </if>
+    <if test="leader !=null">
+      and a.leader= #{leader}
+    </if>
     <if test="name !=null">
       and a.name  like concat('%',#{name},'%')
     </if>

+ 2 - 0
src/main/resources/props/config_local.properties

@@ -49,6 +49,8 @@ yxzj_max=800
 yxy_max=100
 yxjl_max=100
 
+amb.maxLvl=6
+
 avatar.host=//static.jishutao.com
 static.host=//static.jishutao.com/1.2.48
 #avatar.host=//172.16.0.255:3000

+ 2 - 0
src/main/resources/props/config_test.properties

@@ -47,6 +47,8 @@ yxzj_max=800
 yxy_max=100
 yxjl_max=100
 
+amb.maxLvl=6
+
 static.host=//static.jishutao.com/1.2.48
 portal.host=//static.jishutao.com/portal/2.0.6
 avatar.host=//static.jishutao.com