Skip to content

Commit

Permalink
解决用户无法注册的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jishenghua committed Dec 29, 2019
1 parent b1a48f8 commit e692ae7
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/main/java/com/jsh/erp/service/user/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,23 @@ public List<UserEx> getUserList(Map<String, Object> parameterMap) throws Excepti
}
return list;
}

/**
* 根据用户名查询id
* @param loginName
* @return
*/
public Long getIdByLoginName(String loginName) {
Long userId = 0L;
UserExample example = new UserExample();
example.createCriteria().andLoginameEqualTo(loginName);
List<User> list = userMapper.selectByExample(example);
if(list!=null) {
userId = list.get(0).getId();
}
return userId;
}

@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void addUserAndOrgUserRel(UserEx ue) throws Exception{
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginame())) {
Expand Down Expand Up @@ -335,13 +352,8 @@ public void addUserAndOrgUserRel(UserEx ue) throws Exception{
//机构id
oul.setOrgaId(ue.getOrgaId());
//用户id,根据用户名查询id
UserExample example = new UserExample();
example.createCriteria().andLoginameEqualTo(ue.getLoginame());
List<User> list = userMapper.selectByExample(example);
if(list!=null) {
Long userId = list.get(0).getId();
oul.setUserId(userId);
}
Long userId = getIdByLoginName(ue.getLoginame());
oul.setUserId(userId);
//用户在机构中的排序
oul.setUserBlngOrgaDsplSeq(ue.getUserBlngOrgaDsplSeq());

Expand Down Expand Up @@ -403,6 +415,8 @@ public UserEx registerUser(UserEx ue, Integer manageRoleId, HttpServletRequest r
int result=0;
try{
result= userMapper.insertSelective(ue);
Long userId = getIdByLoginName(ue.getLoginame());
ue.setId(userId);
}catch(Exception e){
JshException.writeFail(logger, e);
}
Expand Down

0 comments on commit e692ae7

Please sign in to comment.