版本冲突解决

yun-zuoyi
wei.peng 7 years ago
parent d8915185ed
commit d3bb38283d

@ -1,6 +1,9 @@
package cn.estsh.i3plus.core.api.iservice.busi;
import cn.estsh.i3plus.pojo.platform.bean.Department;
import cn.estsh.i3plus.pojo.platform.bean.Position;
import java.util.List;
/**
* @Description :
@ -19,4 +22,26 @@ public interface ICoreTreeService {
* @param step
*/
void findDepartmentChildrenTreePack(Department parent,int step);
/**
*
* @param parentId
* @return
*/
List<Position> findPositionTreeByParentId(long parentId);
/**
*
* @param id
* @return
*/
Position getPositionTreeByParentId(long id);
/**
*
* @param parent
* @param step
*/
void findPositionChildrenTreePack(Position parent,int step);
}

@ -38,7 +38,7 @@ import java.util.Locale;
* @Modify:
**/
@RestController
@RequestMapping("/core/tree")
@RequestMapping("/demo/tree")
@Api(description="系统服务demo")
public class CoreTreeController {
private static final Logger LOGGER = LoggerFactory.getLogger(CoreTreeController.class);

@ -2,13 +2,16 @@ package cn.estsh.i3plus.core.apiservice.controller.base;
import cn.estsh.i3plus.core.api.iservice.base.ISysUserService;
import cn.estsh.i3plus.core.api.iservice.base.ISystemLoginService;
import cn.estsh.i3plus.core.api.iservice.busi.ICoreTreeService;
import cn.estsh.i3plus.core.apiservice.controller.DemoAuthController;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.Department;
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
import cn.estsh.impp.framework.boot.util.ImppRedis;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.impp.framework.boot.util.ValidatorBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
@ -18,7 +21,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
@ -47,12 +49,17 @@ public class AuthController {
public ResultBean login(HttpServletRequest request, String loginName, String loginPwd, String languageCode){
LOGGER.info("用户登陆 loginName:{} loginPwd:{} languageCode:{}",loginName,loginPwd,languageCode);
try {
ValidatorBean.checkNotNull(loginName,"用户名不能为空");
ValidatorBean.checkNotNull(loginPwd,"密码不能为空");
ValidatorBean.checkNotNull(languageCode,"语言不能为空");
SessionUser user = userService.queryUserLogin(loginName,loginPwd,languageCode);
LOGGER.info("会员登陆:{}",user);
AuthUtil.setSessionObject("languageCode",languageCode);
String sessionId = request.getSession().getId();
String token = "{accessToken:'"+sessionId+"',expiresIn:1800}";
return new ResultBean(true,"",token);
return new ResultBean(true,token,AuthUtil.getSessionUser());
} catch (ImppBusiException e) {
return new ResultBean(false,e.getErrorDetail() + ",so:" + e.getErrorSolution());
}catch (Exception e){
@ -94,4 +101,39 @@ public class AuthController {
}
/**
* @Description : demo
* @Reference :
* @Author : alwaysfrin
* @CreateDate : 2018-09-26 10:34
* @Modify:
**/
@RestController
@RequestMapping("/core/tree")
@Api(description="系统服务demo")
public static class CoreTreeController {
private static final Logger LOGGER = LoggerFactory.getLogger(CoreTreeController.class);
@Autowired
private ICoreTreeService coreTreeService;
@GetMapping(value="/department")
@ApiOperation(value="查询部门树",notes="通过部门主键获取部门树,-1为根节点")
public ResultBean listDepartmentTree(long depParentId) {
try {
Department department = coreTreeService.getDepartmentTreeByParentId(depParentId);
return ResultBean.success("查询部门树成功")
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
.setResultObject(department);
}catch(ImppBusiException busExcep){
LOGGER.error(busExcep.getErrorMsg() + "{}",busExcep.getErrorDetail(),busExcep);
return ResultBean.fail(busExcep.getErrorShow());
}catch(Exception e){
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + "{}",e.getMessage(),e);
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
}
}
}
}

@ -2,7 +2,11 @@ package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ICoreTreeService;
import cn.estsh.i3plus.pojo.platform.bean.Department;
import cn.estsh.i3plus.pojo.platform.bean.Position;
import cn.estsh.i3plus.pojo.platform.repository.DepartmentRepository;
import cn.estsh.i3plus.pojo.platform.repository.PositionRepository;
import cn.estsh.impp.framework.boot.util.ValidatorBean;
import javafx.scene.layout.VBox;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -25,31 +29,77 @@ public class CoreTreeServiceImpl implements ICoreTreeService {
@Autowired
private DepartmentRepository departmentRDao;
@Autowired
private PositionRepository positionRDao;
@Override
public Department getDepartmentTreeByParentId(long depParentId) {
Department depParent = departmentRDao.getById(depParentId);
//封装子集
findDepartmentChildrenTreePack(depParent,0);
findDepartmentChildrenTreePack(depParent, 0);
return depParent;
}
/**
*
*
* @param parent
*/
@Override
public void findDepartmentChildrenTreePack(Department parent,int step){
public void findDepartmentChildrenTreePack(Department parent, int step) {
++step;
List<Department> childDepList = departmentRDao.findByProperty("parentId",parent.getId());
List<Department> childDepList = departmentRDao.findByProperty("parentId", parent.getId());
if(childDepList.size() > 0){
if (childDepList.size() > 0) {
//说明有子集
for(Department depChild : childDepList){
findDepartmentChildrenTreePack(depChild,step);
for (Department depChild : childDepList) {
findDepartmentChildrenTreePack(depChild, step);
}
}
LOGGER.info("【{}】包含子集:{},步长:{}",parent.getDepartmentName(),childDepList.size(),step);
LOGGER.info("【{}】包含子集:{},步长:{}", parent.getName(), childDepList.size(), step);
parent.setChildList(childDepList);
}
@Override
public List<Position> findPositionTreeByParentId(long parentId) {
List<Position> result = positionRDao.findByProperty("parentId", parentId);
// 循环设置子集
if(result != null && result.size() > 0){
result.stream().forEach(position -> findPositionChildrenTreePack(position,0));
}
return result;
}
@Override
public Position getPositionTreeByParentId(long id) {
// 查找数据
Position position = positionRDao.getById(id);
// 数据是否真实存在
ValidatorBean.checkNotNull(position,"不存在的岗位信息");
// 递归查询子集
findPositionChildrenTreePack(position, 0);
return position;
}
@Override
public void findPositionChildrenTreePack(Position parent, int step) {
++step;
List<Position> childList = positionRDao.findByProperty("parentId", parent.getId());
if (childList.size() > 0) {
//说明有子集
for (Position child : childList) {
findPositionChildrenTreePack(child, step);
}
}
LOGGER.info("【{}】包含子集:{},步长:{}", parent.getName(), childList.size(), step);
parent.setChildList(childList);
}
}

@ -73,6 +73,15 @@ public class SysUserServiceImpl implements ISysUserService {
SysUser user = getSysUserByLoginName(loginName);
if(user == null){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
.setErrorCode(ImppExceptionEnum.LOGIN_USER_NAME_EXCEPTION.getCode())
.setErrorDetail("用户名不存在")
.setErrorSolution("请重新输入用户名")
.build();
}
AuthenticationToken token = null;
switch (user.getUserTypeId()) {
case 2:
@ -98,7 +107,7 @@ public class SysUserServiceImpl implements ISysUserService {
public void updateSysUserStatus(String id, int status, SessionUser user) {
LOGGER.info("平台用户 SYS_USER id:{} status:{} modifyUser:{}", id, status, user.getUserName());
SysUser sysUser = sysUserRDao.getById(Long.parseLong(id));
sysUser.setUserStatus(status);
sysUser.setUserStatusId(status);
sysUser.setModifyUser(user.getUserName());
sysUserRDao.update(sysUser);
}
@ -171,7 +180,7 @@ public class SysUserServiceImpl implements ISysUserService {
ValidatorBean.checkNotNull(dep);
// 用户部门关系保存
RefUserDepartment refUserDepartment = new RefUserDepartment(sysUser.getId(), dep.getId(), dep.getDepartmentName());
RefUserDepartment refUserDepartment = new RefUserDepartment(sysUser.getId(), dep.getId(), dep.getName());
refUserDepartmentRDao.save(refUserDepartment);
// 组织信息冗余
@ -182,7 +191,7 @@ public class SysUserServiceImpl implements ISysUserService {
}
// 冗余 部门信息
sysUser.setRedDepartmentName(dep.getDepartmentName());
sysUser.setRedDepartmentName(dep.getName());
}
}
@ -322,12 +331,17 @@ public class SysUserServiceImpl implements ISysUserService {
public static SessionUser packSessionUser(SessionUser sessionUser, SysUser user, Integer userType, String languageCode) {
sessionUser.setLanguageCode(languageCode);
sessionUser.setUserName(user.getName());
sessionUser.setUserType(CommonEnumUtil.USER_TYPE.valueOf(userType));
sessionUser.setUserTypeId(userType);
sessionUser.setUserCode(user.getUserInfo().getLanguageCode());
sessionUser.setRoleList(user.getRoleList());
sessionUser.setDepartmentList(user.getDepartmentList());
sessionUser.setPositionList(user.getPositionList());
sessionUser.setOrganize(user.getOrganize());
if(null != user.getPositionList() && user.getPositionList().size() > 0){
sessionUser.setPosition(user.getPositionList().get(0));
}
return sessionUser;
}

Loading…
Cancel
Save