mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 19:06:49 +08:00
Merge branch 'preview' of codeup.aliyun.com:6265f483e4166464dc2f9c14/boeu/baseservers into release
This commit is contained in:
@@ -27,6 +27,10 @@ public class AccountDao extends BaseDao<Account> {
|
||||
public Account findByLoginName(String loginName) {
|
||||
return this.findOne(FieldFilters.eq("loginName", loginName), FieldFilters.eq("deleted", false));
|
||||
}
|
||||
|
||||
public Account findLoginBySysId(String sysId) {
|
||||
return this.findOne(FieldFilters.eq("sysId", sysId),FieldFilters.eq("deleted", false));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查账号是否存在
|
||||
|
||||
@@ -26,6 +26,13 @@ public interface IAccountService {
|
||||
* @return
|
||||
*/
|
||||
Account getBySysId(String id);
|
||||
|
||||
/**
|
||||
* 为登录获取用户账号
|
||||
* @param sysId
|
||||
* @return
|
||||
*/
|
||||
Account findLoginBySysId(String sysId);
|
||||
|
||||
/**
|
||||
* 按登录名查询账号
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xboe.account.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -17,7 +18,6 @@ import com.xboe.account.service.IAccountService;
|
||||
import com.xboe.common.utils.MD5Util;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.constants.CacheName;
|
||||
import com.xboe.core.exception.DaoException;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.UpdateBuilder;
|
||||
@@ -140,4 +140,30 @@ public class AccountServiceImpl implements IAccountService {
|
||||
public void delete(Account account) {
|
||||
dao.setDeleted(account.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Account findLoginBySysId(String sysId) {
|
||||
|
||||
//重复用户的问题
|
||||
List<Account> list=dao.findList(FieldFilters.eq("sysId", sysId));
|
||||
if(list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Account account=null;
|
||||
for(Account a:list) {
|
||||
if(!a.getDeleted() && a.getStatus()<Account.STATUS_DEAD) {
|
||||
account=a;
|
||||
}
|
||||
}
|
||||
if(account!=null) {
|
||||
Account result = new Account();
|
||||
BeanUtils.copyProperties(account,result,"passKey","passValue");
|
||||
return result;
|
||||
}else{
|
||||
account=list.get(0);
|
||||
Account result = new Account();
|
||||
BeanUtils.copyProperties(account,result,"passKey","passValue");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,11 @@ public class PortalConsoleApi extends ApiBaseController{
|
||||
Map<String,Object> map=new HashMap<String,Object>();
|
||||
try {
|
||||
Account account = accountService.get(getCurrent().getAccountId());
|
||||
if(account==null) {
|
||||
log.error("未找到账号id【"+getCurrent().getAccountId()+"】对应的用户");
|
||||
return error("账号错误,无此账号");
|
||||
}
|
||||
|
||||
User user = userService.get(getCurrent().getAccountId());
|
||||
Organization org = null;
|
||||
String departName = "";
|
||||
|
||||
@@ -209,18 +209,27 @@ public class PortalLoginApi extends ApiBaseController {
|
||||
//检查系统用户是否存在
|
||||
account = accountService.get(tokenInfo.get("aid"));
|
||||
}else{
|
||||
log.error("查询用户kid【"+tokenInfo.get("userId")+"】");
|
||||
// 没有aid则判断是否已同步的用户,不是则同步
|
||||
if(StringUtil.isNotBlank(tokenInfo.get("userId"))){
|
||||
account = accountService.getBySysId(tokenInfo.get("userId"));
|
||||
account = accountService.findLoginBySysId(tokenInfo.get("userId"));
|
||||
if(account == null){ //系统中无此用户,需要同步用户
|
||||
log.error("未找到【"+tokenInfo.get("userId")+"】的用户");
|
||||
UserVo fwUser = fwUserService.getById(tokenInfo.get("userId"));
|
||||
if(fwUser != null) {
|
||||
try {
|
||||
account = userService.syncUser(fwUser);
|
||||
} catch (Exception e) {
|
||||
log.error("boelogin同步用户错误:" + e.getMessage());
|
||||
return error("登录失败,未同步用户");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(account.getDeleted()!=null && account.getDeleted()) {
|
||||
return error("登录失败,用户已删除,请与管理员联系");
|
||||
}else if(account.getStatus()!=null && account.getStatus()==Account.STATUS_DEAD) {
|
||||
return error("登录失败,用户已停用,请与管理员联系");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return error("token不合法");
|
||||
|
||||
@@ -89,14 +89,37 @@ public class MainDbSyncServiceImpl implements IMainDbSyncService {
|
||||
//System.out.println("dto.name="+dto.getName());
|
||||
Integer employeeStatus=dto.getEmployeeStatus();
|
||||
//同一个用户工号对应 多个kid的情况,所以直接根据kid查询是不对的,同步过来的,使用sysId查询
|
||||
MainAccount a=null;
|
||||
MainUser user = userDao.get(dto.getId());
|
||||
if(user!=null) {
|
||||
//更新用户信息,更新账号信息
|
||||
user.setSysId(dto.getKid());
|
||||
//hasUser.setBirthday(null);
|
||||
user.setName(dto.getName());
|
||||
user.setDepartId(dto.getDepartId());
|
||||
user.setDescription(dto.getDescription());
|
||||
user.setDomainId(dto.getDomainId());
|
||||
user.setDuty(dto.getDuty());
|
||||
user.setSysId(dto.getKid());
|
||||
user.setLearningDuration(dto.getLearningDuration());
|
||||
user.setName(dto.getName());
|
||||
user.setRank(dto.getRank());
|
||||
user.setSassId(dto.getSassId());
|
||||
user.setTelephoneNo(dto.getTelephoneNo());
|
||||
user.setUserNo(dto.getUserNo());
|
||||
user.setGender(dto.toGenderInteger()==3? 1:dto.toGenderInteger());
|
||||
user.setGraduatedFrom(dto.getGraduatedFrom());
|
||||
user.setGraduatedMajor(dto.getGraduatedMajor());
|
||||
user.setHighestEducation(dto.getHighestEducation());
|
||||
user.setHomePhoneNo(dto.getHomePhoneNo());
|
||||
user.setIdNumber(dto.getIdNumber());
|
||||
user.setMobileNo(dto.getMobile());
|
||||
user.setNationality(dto.getNationality());
|
||||
userDao.saveAndFlush(user);
|
||||
//账号没有修改的字段,所以不进行更新操作了
|
||||
//a=accountDao.getById(dto.getId());
|
||||
}else {
|
||||
//账号信息
|
||||
MainAccount a=new MainAccount();
|
||||
a=new MainAccount();
|
||||
//同步过程中一样,可以不一样。因为此系统当前是一致的,所以统一使用一个
|
||||
a.setId(dto.getId());
|
||||
a.setAvatar(dto.getAvatar());
|
||||
|
||||
Reference in New Issue
Block a user