组织树 数据权限修复

yun-zuoyi
曾贞一 6 years ago
parent aaf76a00dc
commit 39c1e511a9

@ -1,7 +1,6 @@
package cn.estsh.i3plus.core.api.iservice.busi; package cn.estsh.i3plus.core.api.iservice.busi;
import cn.estsh.i3plus.pojo.platform.bean.SysPosition; import cn.estsh.i3plus.pojo.platform.bean.*;
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserPosition;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
@ -59,4 +58,25 @@ public interface ICoreMemTreeService {
@ApiOperation(value = "查询岗位子节点",notes = "查询字节点岗位ID") @ApiOperation(value = "查询岗位子节点",notes = "查询字节点岗位ID")
List<Long> findChildSysPosition(SysPosition position); List<Long> findChildSysPosition(SysPosition position);
/********************************************* Start SysOrganize Tree *********************************************/
@ApiOperation(value = "分装组织树",notes = "分装组织树")
List<SysOrganize> packTreeSysOrganize(List<SysOrganize> list,Long parentId);
@ApiOperation(value = "分装组织树",notes = "根据用户组织关系分装组织树")
List<SysOrganize> packTreeSysOrganizeBySysRefUserOrganize(List<SysOrganize> list, List<SysRefUserDepartment> refList);
@ApiOperation(value = "分装组织树",notes = "根据用户组织关系分装组织树")
List<SysOrganize> packTreeSysOrganizeBySysRefUserInfoOrganize(List<SysOrganize> list, List<SysRefUserInfoDepartment> refList);
@ApiOperation(value = "分装组织树",notes = "根据制定IDS分装组织树")
List<SysOrganize> packTreeSysOrganizeByIds(List<SysOrganize> list, List<Long> ids);
@ApiOperation(value = "分装组织树",notes = "根据制定ID分装组织树")
SysOrganize packTreeSysOrganizeById(List<SysOrganize> list, Long id);
@ApiOperation(value = "查询组织子节点",notes = "查询字节点组织ID")
List<Long> findChildSysOrganize(SysOrganize organize);
/********************************************* End SysOrganize Tree *********************************************/
} }

@ -82,7 +82,7 @@ public interface IPersonnelService {
List<SysRefUserRole> findSysRefUserRoleById(Long userId); List<SysRefUserRole> findSysRefUserRoleById(Long userId);
@ApiOperation(value = "查询账号部门关系") @ApiOperation(value = "查询账号部门关系")
List<SysRefUserDepartment> findSysRefUserDepartmentById(Long userId); List<SysRefUserDepartment> findSysRefUserDepartmentByUserId(Long userId);
@ApiOperation(value = "查询账号部门关系") @ApiOperation(value = "查询账号部门关系")
List<SysRefUserDepartment> querySysRefUserDepartmentByUserDetailModel(UserDetailModel model); List<SysRefUserDepartment> querySysRefUserDepartmentByUserDetailModel(UserDetailModel model);
@ -102,6 +102,8 @@ public interface IPersonnelService {
@ApiOperation(value = "查询账户组织关系") @ApiOperation(value = "查询账户组织关系")
List<SysOrganize> findSysUserOrganize(Long infoId); List<SysOrganize> findSysUserOrganize(Long infoId);
List<SysOrganize> findSysOrganizeList();
@ApiOperation(value = "查询用户岗位关系") @ApiOperation(value = "查询用户岗位关系")
List<SysRefUserPosition> findSysRefUserPositionById(Long infoId); List<SysRefUserPosition> findSysRefUserPositionById(Long infoId);

@ -4,6 +4,7 @@ import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.platform.bean.SessionUser; import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
import cn.estsh.i3plus.pojo.platform.bean.SysOrganize; import cn.estsh.i3plus.pojo.platform.bean.SysOrganize;
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserDepartment;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
@ -71,6 +72,8 @@ public interface ISysOrganizeService {
@ApiOperation(value = "查询组织信息",notes = "查询 组织信息(分页、组合)") @ApiOperation(value = "查询组织信息",notes = "查询 组织信息(分页、组合)")
ListPager<SysOrganize> querySysOrganize(SysOrganize organize, Pager pager); ListPager<SysOrganize> querySysOrganize(SysOrganize organize, Pager pager);
ListPager<SysOrganize> querySysOrganize(SysOrganize organize,List<Long> idList, Pager pager);
/** /**
* id * id
* @param id * @param id
@ -85,4 +88,12 @@ public interface ISysOrganizeService {
*/ */
@ApiOperation(value = "查询组织个数") @ApiOperation(value = "查询组织个数")
long getSysOrganizeCount(); long getSysOrganizeCount();
/**
* ID
* @return
*/
@ApiOperation(value = "查询当前用户所有组织数据",notes = "查询当前用户所有组织数据")
List<SysOrganize> findOrganizeIdByRefUsers(List<SysRefUserDepartment> sysRefUserDepartments);
} }

@ -297,7 +297,7 @@ public class PersonnelController extends CoreBaseController {
List<SysRefUserInfoDepartment> refUserInfoDepartmentList = personnelService.findSysRefUserInfoDepartmentById(info.getId()); List<SysRefUserInfoDepartment> refUserInfoDepartmentList = personnelService.findSysRefUserInfoDepartmentById(info.getId());
List<SysRefUserPosition> refUserPositionList = personnelService.findSysRefUserPositionById(info.getId()); List<SysRefUserPosition> refUserPositionList = personnelService.findSysRefUserPositionById(info.getId());
List<SysRefUserDepartment> refUserDepartmentList = personnelService.findSysRefUserDepartmentById(user.getId()); List<SysRefUserDepartment> refUserDepartmentList = personnelService.findSysRefUserDepartmentByUserId(user.getId());
List<SysRefUserRole> refUserRoleList = personnelService.findSysRefUserRoleById(user.getId()); List<SysRefUserRole> refUserRoleList = personnelService.findSysRefUserRoleById(user.getId());
SysFile image = info.getUserImageId() != null ? fileService.getSysFileById(info.getUserImageId()) : null; SysFile image = info.getUserImageId() != null ? fileService.getSysFileById(info.getUserImageId()) : null;
@ -331,7 +331,7 @@ public class PersonnelController extends CoreBaseController {
SysUser user = personnelService.getSysUserById(Long.parseLong(id)); SysUser user = personnelService.getSysUserById(Long.parseLong(id));
List<SysRefUserDepartment> refUserInfoDepartmentList = personnelService.findSysRefUserDepartmentById(user.getId()); List<SysRefUserDepartment> refUserInfoDepartmentList = personnelService.findSysRefUserDepartmentByUserId(user.getId());
List<SysRefUserRole> refUserRoleList = personnelService.findSysRefUserRoleById(user.getId()); List<SysRefUserRole> refUserRoleList = personnelService.findSysRefUserRoleById(user.getId());
resultMap.put("refUserDepartmentList", refUserInfoDepartmentList); resultMap.put("refUserDepartmentList", refUserInfoDepartmentList);

@ -6,7 +6,9 @@ import cn.estsh.i3plus.core.api.iservice.busi.ISysPositionService;
import cn.estsh.i3plus.platform.common.util.PlatformConstWords; import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.SysOrganize;
import cn.estsh.i3plus.pojo.platform.bean.SysPosition; import cn.estsh.i3plus.pojo.platform.bean.SysPosition;
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserDepartment;
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserPosition; import cn.estsh.i3plus.pojo.platform.bean.SysRefUserPosition;
import cn.estsh.i3plus.pojo.platform.repository.SysRefUserPositionRepository; import cn.estsh.i3plus.pojo.platform.repository.SysRefUserPositionRepository;
import cn.estsh.impp.framework.base.controller.CoreBaseController; import cn.estsh.impp.framework.base.controller.CoreBaseController;
@ -156,4 +158,24 @@ public class SysMemTreeController extends CoreBaseController {
} }
} }
/**
* ID
* @return
*/
@GetMapping(value="/organize/user")
@ApiOperation(value="查询岗位树",notes="通过部门主键获取岗位树,-1为根节点")
public ResultBean findSysOrganizeByUser() {
try {
List<SysOrganize> list = personnelService.findSysOrganizeList();
List listTree = memTreeService.packTreeSysOrganize(list, CommonEnumUtil.PARENT.DEFAULT.getValue());
List<SysRefUserDepartment> refList = personnelService.findSysRefUserDepartmentByUserId(getSessionUser().getUserInfo().getId());
List userTreeList = memTreeService.packTreeSysOrganizeBySysRefUserOrganize(listTree, refList);
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(userTreeList);
}catch(ImppBusiException busExcep){
return ResultBean.fail(busExcep);
}catch(Exception e){
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
} }

@ -1,5 +1,7 @@
package cn.estsh.i3plus.core.apiservice.controller.busi; package cn.estsh.i3plus.core.apiservice.controller.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ICoreMemTreeService;
import cn.estsh.i3plus.core.api.iservice.busi.IPersonnelService;
import cn.estsh.i3plus.core.api.iservice.busi.ISysOrganizeService; import cn.estsh.i3plus.core.api.iservice.busi.ISysOrganizeService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean; import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.StringTool; import cn.estsh.i3plus.platform.common.tool.StringTool;
@ -9,6 +11,7 @@ import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.SysOrganize; import cn.estsh.i3plus.pojo.platform.bean.SysOrganize;
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserDepartment;
import cn.estsh.impp.framework.base.controller.CoreBaseController; import cn.estsh.impp.framework.base.controller.CoreBaseController;
import cn.estsh.impp.framework.boot.auth.AuthUtil; import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException; import cn.estsh.impp.framework.boot.exception.ImppBusiException;
@ -21,9 +24,13 @@ import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* @Description : * @Description :
@ -42,6 +49,12 @@ public class SysOrganizeController extends CoreBaseController{
@Autowired @Autowired
private ISysOrganizeService organizeService; private ISysOrganizeService organizeService;
@Autowired
private IPersonnelService personnelService;
@Autowired
private ICoreMemTreeService coreMemTreeService;
/** /**
* *
* @param organize * @param organize
@ -133,8 +146,9 @@ public class SysOrganizeController extends CoreBaseController{
@ApiOperation(value = "查询所有组织", notes = "查询所有组织") @ApiOperation(value = "查询所有组织", notes = "查询所有组织")
public ResultBean findSysOrganizeAll() { public ResultBean findSysOrganizeAll() {
try { try {
List<SysOrganize> list = organizeService.listSysOrganize(); List<SysRefUserDepartment> refList = personnelService.findSysRefUserDepartmentByUserId(getSessionUser().getUser().getId());
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(list); List<SysOrganize> result = organizeService.findOrganizeIdByRefUsers(refList);
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(result);
} catch (ImppBusiException busExcep) { } catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep); return ResultBean.fail(busExcep);
} catch (Exception e) { } catch (Exception e) {
@ -152,8 +166,15 @@ public class SysOrganizeController extends CoreBaseController{
@ApiOperation(value="查询组织",notes="组合查询组织外加分页") @ApiOperation(value="查询组织",notes="组合查询组织外加分页")
public ResultBean queryPosition(SysOrganize organize, Pager pager){ public ResultBean queryPosition(SysOrganize organize, Pager pager){
try{ try{
ListPager<SysOrganize> listPager = organizeService.querySysOrganize(organize, pager); List<SysRefUserDepartment> refList = personnelService.findSysRefUserDepartmentByUserId(getSessionUser().getUser().getId());
return ResultBean.success("操作成功").setListPager(listPager).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()); if(refList != null && refList.size() > 0){
List<Long> idList = new ArrayList<>(refList.size());
refList.forEach(ref ->idList.add(ref.getOrganizeId()));
return ResultBean.success("操作成功").setListPager(organizeService.querySysOrganize(organize, idList, pager))
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){ }catch(ImppBusiException busExcep){
return ResultBean.fail(busExcep); return ResultBean.fail(busExcep);
}catch(Exception e){ }catch(Exception e){

@ -3,8 +3,8 @@ package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ICoreMemTreeService; import cn.estsh.i3plus.core.api.iservice.busi.ICoreMemTreeService;
import cn.estsh.i3plus.platform.common.util.CommonConstWords; import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.SysPosition; import cn.estsh.i3plus.pojo.platform.bean.*;
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserPosition; import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
@ -100,4 +100,101 @@ public class CoreMemTreeService implements ICoreMemTreeService {
return result; return result;
} }
/********************************************* Start SysOrganize Tree *********************************************/
@Override
public List<SysOrganize> packTreeSysOrganize(List<SysOrganize> list, Long parentId) {
List<SysOrganize> result = new ArrayList<>();
List<SysOrganize> copyList = new ArrayList<>(list);
if(list != null && list.size() > 0){
list.forEach(organize -> {
if(organize.getParentId() != null && organize.getParentId().equals(parentId)){
result.add(organize);
copyList.remove(organize);
organize.setChildList(packTreeSysOrganize(copyList, organize.getId()));
}
});
}
return result;
}
@Override
public List<SysOrganize> packTreeSysOrganizeBySysRefUserOrganize(List<SysOrganize> list, List<SysRefUserDepartment> refList) {
List<Long> ids = new ArrayList<>(refList.size());
if(refList != null && refList.size() > 0){
refList.forEach(ref ->{
ids.add(ref.getOrganizeId());
});
}
return packTreeSysOrganizeByIds(list, ids);
}
@Override
public List<SysOrganize> packTreeSysOrganizeBySysRefUserInfoOrganize(List<SysOrganize> list, List<SysRefUserInfoDepartment> refList) {
List<Long> ids = new ArrayList<>(refList.size());
if(refList != null && refList.size() > 0){
refList.forEach(ref ->{
ids.add(ref.getOrganizeId());
});
}
return packTreeSysOrganizeByIds(list, ids);
}
@Override
public List<SysOrganize> packTreeSysOrganizeByIds(List<SysOrganize> list, List<Long> ids) {
List<SysOrganize> result = new ArrayList<>();
if(list != null && list.size() > 0){
list.forEach(organize -> {
if(organize.getChildList() == null || organize.getChildList().size() <= 0){
if(ids.contains(organize.getId())){
result.add(organize);
}
}else{
List<SysOrganize> childList = packTreeSysOrganizeByIds(organize.getChildList(), ids);
if(ids.contains(organize.getId()) || childList != null && childList.size() > 0){
organize.setChildList(childList);
result.add(organize);
}
}
});
}
return result;
}
@Override
public SysOrganize packTreeSysOrganizeById(List<SysOrganize> list, Long id) {
if(list != null && list.size() > 0){
for (SysOrganize organize : list) {
if(organize.getId().equals(id)){
organize.setChildList(packTreeSysOrganize(list, organize.getId()));
return organize;
}
}
}
return null;
}
@Override
public List<Long> findChildSysOrganize(SysOrganize organize) {
List<Long> result = new ArrayList<>();
if(organize != null && organize.getChildList() != null && organize.getChildList().size() > 0){
for (SysOrganize so : organize.getChildList()) {
result.add(so.getId());
result.addAll(findChildSysOrganize(so));
}
}
return result;
}
/********************************************* End SysOrganize Tree *********************************************/
} }

@ -17,7 +17,6 @@ import cn.estsh.i3plus.pojo.model.platform.UserDetailModel;
import cn.estsh.i3plus.pojo.platform.bean.*; import cn.estsh.i3plus.pojo.platform.bean.*;
import cn.estsh.i3plus.pojo.platform.repository.*; import cn.estsh.i3plus.pojo.platform.repository.*;
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack; import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
import cn.estsh.i3plus.pojo.wms.sqlpack.WmsHqlPack;
import cn.estsh.impp.framework.boot.auth.AuthUtil; import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum; import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
@ -97,13 +96,13 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public SysUser saveSysUser(SysUser user) { public SysUser saveSysUser(SysUser user) {
LOGGER.debug("平台账号 SysUser user:{}", user); LOGGER.info("平台账号 SysUser user:{}", user);
return userRDao.save(user); return userRDao.save(user);
} }
@Override @Override
public SysUserInfo saveSysUserInfo(SysUserInfo info) { public SysUserInfo saveSysUserInfo(SysUserInfo info) {
LOGGER.debug("平台用户 SysUserInfo info:{}", info); LOGGER.info("平台用户 SysUserInfo info:{}", info);
return userInfoRDao.save(info); return userInfoRDao.save(info);
} }
@ -114,7 +113,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public void updateSysUserOrganize(Long userId, Long organizeId) { public void updateSysUserOrganize(Long userId, Long organizeId) {
LOGGER.debug("平台账号 SysUser userId:{} organizeId",userId, organizeId); LOGGER.info("平台账号 SysUser userId:{} organizeId",userId, organizeId);
SysUser user = userRDao.getById(userId); SysUser user = userRDao.getById(userId);
if(user != null){ if(user != null){
user.setOrganizeId(organizeId); user.setOrganizeId(organizeId);
@ -125,7 +124,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
@ApiOperation(value = "删除账号信息") @ApiOperation(value = "删除账号信息")
public void deleteSysUser(Long[] userIdList,String userName) { public void deleteSysUser(Long[] userIdList,String userName) {
LOGGER.debug("平台账号 SysUser userIdList:{}", userIdList); LOGGER.info("平台账号 SysUser userIdList:{}", userIdList);
// 删除账号信息 // 删除账号信息
userRDao.updateValidStatusByPropertyIn("id", userIdList,CommonEnumUtil.IS_VAILD.INVAILD.getValue(), userName); userRDao.updateValidStatusByPropertyIn("id", userIdList,CommonEnumUtil.IS_VAILD.INVAILD.getValue(), userName);
@ -137,7 +136,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
@ApiOperation(value = "删除用户信息") @ApiOperation(value = "删除用户信息")
public void deleteSysUserInfo(Long[] infoIdList,String userName) { public void deleteSysUserInfo(Long[] infoIdList,String userName) {
LOGGER.debug("平台用户 SysUserInfo infoIdList:{}", infoIdList); LOGGER.info("平台用户 SysUserInfo infoIdList:{}", infoIdList);
// 删除用户信息 // 删除用户信息
userInfoRDao.updateValidStatusByPropertyIn("id", infoIdList,CommonEnumUtil.IS_VAILD.INVAILD.getValue(), userName); userInfoRDao.updateValidStatusByPropertyIn("id", infoIdList,CommonEnumUtil.IS_VAILD.INVAILD.getValue(), userName);
@ -153,7 +152,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public List<SysUser> findSysUserByIds(Long[] ids) { public List<SysUser> findSysUserByIds(Long[] ids) {
LOGGER.debug("平台用户 SysUserInfo ids:{}", ids); LOGGER.info("平台用户 SysUserInfo ids:{}", ids);
String infoWhere = CoreHqlPack.packHqlIds("id", ids); String infoWhere = CoreHqlPack.packHqlIds("id", ids);
return userRDao.findByHqlWhere(infoWhere); return userRDao.findByHqlWhere(infoWhere);
@ -161,7 +160,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public List<SysUser> querySysUserByUserDetailModelOrIds(UserDetailModel model, List<Long> ids) { public List<SysUser> querySysUserByUserDetailModelOrIds(UserDetailModel model, List<Long> ids) {
LOGGER.debug("平台用户 SysUser model:{} ids:{}", model, ids); LOGGER.info("平台用户 SysUser model:{} ids:{}", model, ids);
String modeWhere = HqlModelPack.packHqlSysUserByModelOrIds(model, ids); String modeWhere = HqlModelPack.packHqlSysUserByModelOrIds(model, ids);
return userRDao.findByHqlWhere(modeWhere); return userRDao.findByHqlWhere(modeWhere);
@ -170,7 +169,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
@ApiOperation(value = "查询账号信息") @ApiOperation(value = "查询账号信息")
public ListPager<SysUser> querySysUserPagerByUserDetailModelOrIds(UserDetailModel model,Pager pager, List<Long> ids) { public ListPager<SysUser> querySysUserPagerByUserDetailModelOrIds(UserDetailModel model,Pager pager, List<Long> ids) {
LOGGER.debug("平台用户 SysUser model:{} ids:{}", model, ids); LOGGER.info("平台用户 SysUser model:{} ids:{}", model, ids);
String modeWhere = HqlModelPack.packHqlSysUserByModelOrIds(model, ids); String modeWhere = HqlModelPack.packHqlSysUserByModelOrIds(model, ids);
pager = PagerHelper.getPager(pager, userRDao.findByHqlWhereCount(modeWhere)); pager = PagerHelper.getPager(pager, userRDao.findByHqlWhereCount(modeWhere));
@ -199,7 +198,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public SessionUser queryUserLogin(String userName, String password, String languageCode) { public SessionUser queryUserLogin(String userName, String password, String languageCode) {
LOGGER.debug("平台用户 SYS_USER loginName:{} \t password:{} \t languageCode:{}", userName, password, languageCode); LOGGER.info("平台用户 SYS_USER loginName:{} \t password:{} \t languageCode:{}", userName, password, languageCode);
UserToken token = new UserToken(userName,password,languageCode); UserToken token = new UserToken(userName,password,languageCode);
SessionUser sessionUser = AuthUtil.login(token); SessionUser sessionUser = AuthUtil.login(token);
AuthUtil.setSessionUser(sessionUser); AuthUtil.setSessionUser(sessionUser);
@ -214,7 +213,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public List<SysUserInfo> findSysUserInfoByIds(Long[] ids) { public List<SysUserInfo> findSysUserInfoByIds(Long[] ids) {
LOGGER.debug("平台用户 SysUserInfo ids:{}", ids); LOGGER.info("平台用户 SysUserInfo ids:{}", ids);
String infoWhere = CoreHqlPack.packHqlIds("id", ids); String infoWhere = CoreHqlPack.packHqlIds("id", ids);
return userInfoRDao.findByHqlWhere(infoWhere); return userInfoRDao.findByHqlWhere(infoWhere);
@ -222,13 +221,13 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public List<SysRefUserRole> findSysRefUserRoleById(Long userId) { public List<SysRefUserRole> findSysRefUserRoleById(Long userId) {
LOGGER.debug("平台账号角色 SysRefUserRole userId:{}", userId); LOGGER.info("平台账号角色 SysRefUserRole userId:{}", userId);
return refUserRoleRDao.findByProperty("userId",userId); return refUserRoleRDao.findByProperty("userId",userId);
} }
@Override @Override
public List<SysRefUserDepartment> findSysRefUserDepartmentById(Long userId) { public List<SysRefUserDepartment> findSysRefUserDepartmentByUserId(Long userId) {
LOGGER.debug("平台账号部门 SysRefUserDepartment userId:{}", userId); LOGGER.info("平台账号部门 SysRefUserDepartment userId:{}", userId);
return refUserDepartmentRDao.findByProperty("userId",userId); return refUserDepartmentRDao.findByProperty("userId",userId);
} }
@ -252,14 +251,14 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public List<SysRefUserInfoDepartment> findSysRefUserInfoDepartmentById(Long infoId) { public List<SysRefUserInfoDepartment> findSysRefUserInfoDepartmentById(Long infoId) {
LOGGER.debug("平台用户部门关系 SysRefUserInfoDepartment infoId:{}", infoId); LOGGER.info("平台用户部门关系 SysRefUserInfoDepartment infoId:{}", infoId);
return refUserInfoDepartmentRDao.findByProperty("userId",infoId); return refUserInfoDepartmentRDao.findByProperty("userId",infoId);
} }
@Override @Override
@ApiOperation(value = "查询用户部门关系") @ApiOperation(value = "查询用户部门关系")
public List<SysDepartment> findSysUserInfoDepartmentByInfoId(Long infoId) { public List<SysDepartment> findSysUserInfoDepartmentByInfoId(Long infoId) {
LOGGER.debug("平台用户部门 SysDepartment infoId:{}", infoId); LOGGER.info("平台用户部门 SysDepartment infoId:{}", infoId);
List<SysDepartment> result = new ArrayList<>(); List<SysDepartment> result = new ArrayList<>();
List<SysRefUserInfoDepartment> refs = findSysRefUserInfoDepartmentById(infoId); List<SysRefUserInfoDepartment> refs = findSysRefUserInfoDepartmentById(infoId);
@ -277,10 +276,10 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
@ApiOperation(value = "查询账号部门关系") @ApiOperation(value = "查询账号部门关系")
public List<SysDepartment> findSysUserDepartmentByInfoId(Long infoId) { public List<SysDepartment> findSysUserDepartmentByInfoId(Long infoId) {
LOGGER.debug("平台用户部门 SysDepartment infoId:{}", infoId); LOGGER.info("平台用户部门 SysDepartment infoId:{}", infoId);
List<SysDepartment> result = new ArrayList<>(); List<SysDepartment> result = new ArrayList<>();
List<SysRefUserDepartment> refs = findSysRefUserDepartmentById(infoId); List<SysRefUserDepartment> refs = findSysRefUserDepartmentByUserId(infoId);
if(refs != null && refs.size() > 0){ if(refs != null && refs.size() > 0){
Long[] ids = new Long[refs.size()]; Long[] ids = new Long[refs.size()];
for (int i = 0; i < refs.size(); i++) { for (int i = 0; i < refs.size(); i++) {
@ -294,7 +293,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public List<SysOrganize> findSysUserInfoOrganize(Long infoId) { public List<SysOrganize> findSysUserInfoOrganize(Long infoId) {
LOGGER.debug("平台用户部门 SysDepartment infoId:{}", infoId); LOGGER.info("平台用户部门 SysDepartment infoId:{}", infoId);
List<SysOrganize> result = new ArrayList<>(); List<SysOrganize> result = new ArrayList<>();
List<SysRefUserInfoDepartment> refs = findSysRefUserInfoDepartmentById(infoId); List<SysRefUserInfoDepartment> refs = findSysRefUserInfoDepartmentById(infoId);
@ -311,10 +310,10 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public List<SysOrganize> findSysUserOrganize(Long infoId) { public List<SysOrganize> findSysUserOrganize(Long infoId) {
LOGGER.debug("平台用户部门 SysDepartment infoId:{}", infoId); LOGGER.info("平台用户部门 SysOrganize infoId:{}", infoId);
List<SysOrganize> result = new ArrayList<>(); List<SysOrganize> result = new ArrayList<>();
List<SysRefUserDepartment> refs = findSysRefUserDepartmentById(infoId); List<SysRefUserDepartment> refs = findSysRefUserDepartmentByUserId(infoId);
if(refs != null && refs.size() > 0){ if(refs != null && refs.size() > 0){
List<Long> ids = new ArrayList<>(); List<Long> ids = new ArrayList<>();
refs.forEach(ref -> { refs.forEach(ref -> {
@ -329,8 +328,16 @@ public class PersonnelServiceService implements IPersonnelService {
} }
@Override @Override
public List<SysOrganize> findSysOrganizeList() {
LOGGER.info("平台用户部门 SysOrganize Find All");
return organizeRDao.findByProperty(
new String[]{"isDeleted","isValid"},
new Object[]{CommonEnumUtil.IS_DEAL.NO.getValue(),CommonEnumUtil.IS_VAILD.VAILD.getValue()});
}
@Override
public List<SysRefUserPosition> findSysRefUserPositionById(Long infoId) { public List<SysRefUserPosition> findSysRefUserPositionById(Long infoId) {
LOGGER.debug("平台用户岗位 SysRefUserPosition infoId:{}", infoId); LOGGER.info("平台用户岗位 SysRefUserPosition infoId:{}", infoId);
return refUserPositionRDao.findByProperty("userId",infoId); return refUserPositionRDao.findByProperty("userId",infoId);
} }
@ -387,7 +394,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
@ApiOperation(value = "重置密码检查") @ApiOperation(value = "重置密码检查")
public Integer checkSysUserResetPassword(SysUser user) { public Integer checkSysUserResetPassword(SysUser user) {
LOGGER.debug("平台用户岗位 SysUser user:{}", user); LOGGER.info("平台用户岗位 SysUser user:{}", user);
Integer num = 0; Integer num = 0;
if(user != null){ if(user != null){
String day = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.format(new Date()); String day = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.format(new Date());
@ -410,7 +417,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public void checkSysPositionRef(Long positionId) { public void checkSysPositionRef(Long positionId) {
LOGGER.debug("平台岗位 SysPosition positionId:{}", positionId); LOGGER.info("平台岗位 SysPosition positionId:{}", positionId);
if(positionId != null){ if(positionId != null){
List<SysPosition> positionList = positionRDao.findByProperty("parentId", positionId); List<SysPosition> positionList = positionRDao.findByProperty("parentId", positionId);
@ -445,7 +452,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public void checkSysDepartmentRef(Long departmentId) { public void checkSysDepartmentRef(Long departmentId) {
LOGGER.debug("平台部门 SysDepartment departmentId:{}", departmentId); LOGGER.info("平台部门 SysDepartment departmentId:{}", departmentId);
if(departmentId != null){ if(departmentId != null){
List<SysDepartment> departmentList = departmentRDao.findByProperty("parentId", departmentId); List<SysDepartment> departmentList = departmentRDao.findByProperty("parentId", departmentId);
@ -490,7 +497,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public void checkSysOrganizeRef(Long organizeId) { public void checkSysOrganizeRef(Long organizeId) {
LOGGER.debug("平台部门 SysOrganize organizeId:{}", organizeId); LOGGER.info("平台部门 SysOrganize organizeId:{}", organizeId);
if(organizeId != null){ if(organizeId != null){
List<SysOrganize> organizeList = organizeRDao.findByProperty("parentId", organizeId); List<SysOrganize> organizeList = organizeRDao.findByProperty("parentId", organizeId);
@ -547,7 +554,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public void checkSysUserPassword(String password) { public void checkSysUserPassword(String password) {
LOGGER.debug("平台用户 SysUser password:{}", password); LOGGER.info("平台用户 SysUser password:{}", password);
if(StringUtils.isNotBlank(password)){ if(StringUtils.isNotBlank(password)){
// 密码长度校验 // 密码长度校验
@ -763,7 +770,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public void refreshRefSysUserRole(Long userId, Long[] roleIds) { public void refreshRefSysUserRole(Long userId, Long[] roleIds) {
LOGGER.debug("账号角色关系信息 RefSysUserRole userId:{} roleIds:{} ", userId,roleIds); LOGGER.info("账号角色关系信息 RefSysUserRole userId:{} roleIds:{} ", userId,roleIds);
SysUser user = userRDao.getById(userId); SysUser user = userRDao.getById(userId);
if(user != null){ if(user != null){
// 根据IDS 查询所有的角色信息 // 根据IDS 查询所有的角色信息
@ -801,7 +808,7 @@ public class PersonnelServiceService implements IPersonnelService {
@Override @Override
public void refreshUpdateSysRoleRdd(Long roleId) { public void refreshUpdateSysRoleRdd(Long roleId) {
LOGGER.debug("角色信息 RefSysUserRole roleId:{}", roleId); LOGGER.info("角色信息 RefSysUserRole roleId:{}", roleId);
if(roleId != null){ if(roleId != null){
SysRole role = roleRDao.getById(roleId); SysRole role = roleRDao.getById(roleId);
if(role != null){ if(role != null){

@ -2,12 +2,15 @@ package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.IPersonnelService; import cn.estsh.i3plus.core.api.iservice.busi.IPersonnelService;
import cn.estsh.i3plus.core.api.iservice.busi.ISysOrganizeService; import cn.estsh.i3plus.core.api.iservice.busi.ISysOrganizeService;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager; import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper; import cn.estsh.i3plus.pojo.base.common.PagerHelper;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.platform.bean.SessionUser; import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
import cn.estsh.i3plus.pojo.platform.bean.SysOrganize; import cn.estsh.i3plus.pojo.platform.bean.SysOrganize;
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserDepartment;
import cn.estsh.i3plus.pojo.platform.repository.SysOrganizeRepository; import cn.estsh.i3plus.pojo.platform.repository.SysOrganizeRepository;
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack; import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
@ -18,8 +21,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
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 org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @Description : * @Description :
@ -42,9 +48,6 @@ public class SysOrganizeService implements ISysOrganizeService {
@Autowired @Autowired
private IPersonnelService personnelService; private IPersonnelService personnelService;
@Override @Override
@ApiOperation(value = "更新组织", notes = "传入持久化组织对象,进行更新") @ApiOperation(value = "更新组织", notes = "传入持久化组织对象,进行更新")
public void updateSysOrganize(SysOrganize organize) { public void updateSysOrganize(SysOrganize organize) {
@ -170,24 +173,14 @@ public class SysOrganizeService implements ISysOrganizeService {
@ApiOperation(value = "查询组织信息", notes = "查询 组织信息(分页、组合)") @ApiOperation(value = "查询组织信息", notes = "查询 组织信息(分页、组合)")
public ListPager<SysOrganize> querySysOrganize(SysOrganize organize, Pager pager) { public ListPager<SysOrganize> querySysOrganize(SysOrganize organize, Pager pager) {
LOGGER.info("组织信息 SysOrganize find SysOrganize page"); LOGGER.info("组织信息 SysOrganize find SysOrganize page");
return querySysOrganize(organize, null, pager);
}
if (organize == null) { @Override
//不传入实体对象,查询所有 public ListPager<SysOrganize> querySysOrganize(SysOrganize organize, List<Long> idList, Pager pager) {
int count = organizeRDao.listCount(); DdlPackBean packBean = CoreHqlPack.packHqlSysOrganize(organize, idList);
pager = PagerHelper.getPager(pager, count); pager = PagerHelper.getPager(pager, organizeRDao.findByHqlWhereCount(packBean));
return new ListPager(organizeRDao.listPager(pager), pager); return new ListPager(organizeRDao.findByHqlWherePage(packBean, pager), pager);
} else {
if (organize.getParentId() != null) {
SysOrganize parent = coreTreeService.getSysOrganizeTreeById(organize.getParentId());
List<Long> childIds = coreTreeService.findSysOrganizeChildIds(parent);
organize.setChildIdList(childIds);
}
//生成hql查询语句
String hqlPack = CoreHqlPack.packHqlSysOrganize(organize);
pager = PagerHelper.getPager(pager, organizeRDao.findByHqlWhereCount(hqlPack));
return new ListPager(organizeRDao.findByHqlWherePage(hqlPack + organize.orderBy(), pager), pager);
}
} }
@Override @Override
@ -201,4 +194,15 @@ public class SysOrganizeService implements ISysOrganizeService {
public long getSysOrganizeCount() { public long getSysOrganizeCount() {
return organizeRDao.listCount(); return organizeRDao.listCount();
} }
@Override
@ApiOperation(value = "查询当前用户所有组织数据", notes = "查询当前用户所有组织数据")
public List<SysOrganize> findOrganizeIdByRefUsers(List<SysRefUserDepartment> sysRefUserDepartments) {
if (CollectionUtils.isEmpty(sysRefUserDepartments)) {
return null;
} else {
DdlPackBean packBean = CoreHqlPack.packHqlSysOrganize(sysRefUserDepartments);
return organizeRDao.findByHqlWhere(packBean);
}
}
} }

Loading…
Cancel
Save