|
|
@@ -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());
|
|
|
}
|