|
|
@@ -25,25 +25,25 @@ public class AmbServiceImpl extends BaseMybatisDao<AmbSystemMapper> implements A
|
|
|
|
|
|
@Override
|
|
|
public int addAmb(InputAmb in) {
|
|
|
+ getParentParam(in);
|
|
|
+ in.setStatus("0");
|
|
|
+ in.setCreateBy(TokenManager.getAdminId());
|
|
|
+ in.setCreateTime(new Date());
|
|
|
+ return ambSystemMapper.insertSelective(in);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getParentParam(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");
|
|
|
- in.setCreateBy(TokenManager.getAdminId());
|
|
|
- in.setCreateTime(new Date());
|
|
|
- return ambSystemMapper.insertSelective(in);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int updateAmb(InputAmb in) {
|
|
|
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()));
|
|
|
+ getParentParam(in);
|
|
|
}
|
|
|
in.setUpdateBy(TokenManager.getAdminId());
|
|
|
in.setUpdateTime(new Date());
|