Commit 968924f9 by zhengxj

finish 解决组织新增超过四层问题 on 20190312 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@18436 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent efdd040e
...@@ -58,26 +58,26 @@ public class OrganizationController extends BaseController{ ...@@ -58,26 +58,26 @@ public class OrganizationController extends BaseController{
private ISysOrganizationService organizationService; private ISysOrganizationService organizationService;
@RequestMapping(value = "/getByParams", method = { RequestMethod.GET, RequestMethod.POST }) @RequestMapping(value = "/getByParams", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject getByParams( SysOrganization sysOrganization ) { public ResultObject getByParams(SysOrganization sysOrganization) {
Integer id=sysOrganization.getId(); Integer id = sysOrganization.getId();
String name=sysOrganization.getName(); String name = sysOrganization.getName();
Byte orgStatus=sysOrganization.getOrgStatus(); Byte orgStatus = sysOrganization.getOrgStatus();
logger.info("接收到的id参数值为:"+id); logger.info("接收到的id参数值为:" + id);
if (!StringUtils.isNull(name)) { if (!StringUtils.isNull(name)) {
name = name.replaceAll(" ", ""); name = name.replaceAll(" ", "");
} }
Map map = new HashMap(); Map<String, Object> map = new HashMap<>();
if (StringUtils.isNull(name) && orgStatus == null && id == null) { if (StringUtils.isNull(name) && orgStatus == null && id == null) {
// 菜单状态:1,正常、0.停用、2.注销 // 菜单状态:1,正常、0.停用、2.注销
// 只查询一级菜单 // 只查询一级菜单
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.selectByExample(null, null)); organizationService.selectByExample(null, null));
} else { } else {
if (StringUtils.isNull(name) && (orgStatus != null || id != null)) { if (StringUtils.isNull(name) && (orgStatus != null || id != null)) {
if (orgStatus == null) { if (orgStatus == null) {
// 根据id递归查询子菜单 // 根据id递归查询子菜单
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
organizationService.findOrgById(id)); organizationService.findOrgById(id));
} else if (id != null) { } else if (id != null) {
...@@ -102,11 +102,8 @@ public class OrganizationController extends BaseController{ ...@@ -102,11 +102,8 @@ public class OrganizationController extends BaseController{
sysOrganization.setCreateBy(ShiroUtil.getUsername()); sysOrganization.setCreateBy(ShiroUtil.getUsername());
if(sysOrganization.getOrgType()==null){ if(sysOrganization.getOrgType()==null){
sysOrganization.setOrgType((byte)1); sysOrganization.setOrgType((byte)1);
} }
int i = organizationService.insertSelective(sysOrganization); return organizationService.insertSelective(sysOrganization);
String msg = i == 0 ? ResultCodeEnum.FAIL.getMsg() : ResultCodeEnum.SUCCESS.getMsg();
int code = i == 0 ? ResultCodeEnum.FAIL.getCode() : ResultCodeEnum.SUCCESS.getCode();
return new ResultObject(code, msg);
} }
@Log(menuName="系统管理-组织管理", operateType = Constants.SYS_LOG_OPERATE_TYPE_DELETE) @Log(menuName="系统管理-组织管理", operateType = Constants.SYS_LOG_OPERATE_TYPE_DELETE)
......
...@@ -6,6 +6,7 @@ package com.glsx.usercenter.service; ...@@ -6,6 +6,7 @@ package com.glsx.usercenter.service;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.glsx.common.constants.ResultObject;
import com.glsx.usercenter.pojo.menu.SysOrganization; import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.menu.SysOrganizationExample; import com.glsx.usercenter.pojo.menu.SysOrganizationExample;
...@@ -21,7 +22,7 @@ public interface ISysOrganizationService { ...@@ -21,7 +22,7 @@ public interface ISysOrganizationService {
int deleteByPrimaryKey(Integer id); int deleteByPrimaryKey(Integer id);
int insertSelective(SysOrganization record); ResultObject insertSelective(SysOrganization record);
List<SysOrganization> selectByExample(String orgName,Byte orgStatus); List<SysOrganization> selectByExample(String orgName,Byte orgStatus);
......
...@@ -13,8 +13,9 @@ import org.springframework.beans.BeanUtils; ...@@ -13,8 +13,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.glsx.common.constants.ResultCodeEnum;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.StringUtils; import com.glsx.common.utils.StringUtils;
import com.glsx.usercenter.constants.Constants;
import com.glsx.usercenter.mapper.SysOrganizationMapper; import com.glsx.usercenter.mapper.SysOrganizationMapper;
import com.glsx.usercenter.pojo.menu.SysOrganization; import com.glsx.usercenter.pojo.menu.SysOrganization;
import com.glsx.usercenter.pojo.menu.SysOrganizationExample; import com.glsx.usercenter.pojo.menu.SysOrganizationExample;
...@@ -62,8 +63,12 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{ ...@@ -62,8 +63,12 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{
* *
*/ */
@Override @Override
public int insertSelective(SysOrganization record) { public ResultObject insertSelective(SysOrganization record) {
int i = 0;
boolean isExceedLevel = isExceedLevel(record.getParentId());
if (isExceedLevel) {
return new ResultObject(ResultCodeEnum.FAIL.getCode(), "当前组织层级已达到4级!");
}
SysOrganizationExample example = new SysOrganizationExample(); SysOrganizationExample example = new SysOrganizationExample();
Criteria criteria = example.createCriteria(); Criteria criteria = example.createCriteria();
List<SysOrganization> list = null; List<SysOrganization> list = null;
...@@ -74,20 +79,36 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{ ...@@ -74,20 +79,36 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{
list = orgDao.selectByExample(example); list = orgDao.selectByExample(example);
if (list == null || list.size() == 0) { if (list == null || list.size() == 0) {
record.setCreateTime(new Date()); record.setCreateTime(new Date());
} }
}
byte label=(byte)1;
// 设置有无下级菜单
if(Constants.BUTTON==record.getOrgType() ){
label=(byte)0;
} }
// record.setLabel(label); // byte label=(byte)1;
} // 设置有无下级菜单
// if(Constants.BUTTON==record.getOrgType() ){
// label=(byte)0;
// }
// record.setLabel(label);
}
orgDao.insertSelective(record);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
static int level=1;
public Boolean isExceedLevel(Integer id) {
SysOrganization sysOrganization = orgDao.selectByPrimaryKey(id);
if (sysOrganization != null) {
level++;
isExceedLevel(sysOrganization.getParentId());
boolean isExceed = level > 3 ? true : false;
if(isExceed){
return isExceed;
}
}
return false;
i = orgDao.insertSelective(record);
return i;
} }
/** /**
...@@ -97,6 +118,8 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{ ...@@ -97,6 +118,8 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{
public List<SysOrganization> selectByExample(String orgName,Byte orgStatus) { public List<SysOrganization> selectByExample(String orgName,Byte orgStatus) {
SysOrganizationExample example = new SysOrganizationExample(); SysOrganizationExample example = new SysOrganizationExample();
Criteria criteria =example.createCriteria(); Criteria criteria =example.createCriteria();
// TODO 查询当前用户的
List<SysOrganization> resultList = orgDao.selectByExample(example); List<SysOrganization> resultList = orgDao.selectByExample(example);
// 仅查询一级菜单 // 仅查询一级菜单
...@@ -104,6 +127,7 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{ ...@@ -104,6 +127,7 @@ public class SysOrganizationServiceImpl implements ISysOrganizationService{
example.setOrderByClause("create_time desc"); example.setOrderByClause("create_time desc");
criteria.andOrgStatusBetween((byte) 0, (byte) 1); criteria.andOrgStatusBetween((byte) 0, (byte) 1);
criteria.andParentIdEqualTo(0); criteria.andParentIdEqualTo(0);
// TODO 查询当前用户的
return orgDao.selectByExample(example); return orgDao.selectByExample(example);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!