mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 10:56:50 +08:00
提交代码修改
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
package com.xboe.data.api;
|
package com.xboe.data.api;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@@ -9,15 +7,12 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.xboe.account.entity.Account;
|
|
||||||
import com.xboe.account.service.IAccountService;
|
import com.xboe.account.service.IAccountService;
|
||||||
import com.xboe.core.JsonResponse;
|
import com.xboe.core.JsonResponse;
|
||||||
import com.xboe.core.api.ApiBaseController;
|
import com.xboe.core.api.ApiBaseController;
|
||||||
import com.xboe.data.dto.UserData;
|
import com.xboe.data.dto.UserData;
|
||||||
import com.xboe.data.service.IDataUserSyncService;
|
import com.xboe.data.service.IDataUserSyncService;
|
||||||
import com.xboe.system.organization.entity.Organization;
|
|
||||||
import com.xboe.system.organization.service.IOrganizationService;
|
import com.xboe.system.organization.service.IOrganizationService;
|
||||||
import com.xboe.system.user.entity.User;
|
|
||||||
import com.xboe.system.user.service.IUserService;
|
import com.xboe.system.user.service.IUserService;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -52,71 +47,7 @@ public class UserDataSyncApi extends ApiBaseController {
|
|||||||
//清除缓存需要loginName
|
//清除缓存需要loginName
|
||||||
try {
|
try {
|
||||||
//先查询是否存在
|
//先查询是否存在
|
||||||
Account a=accountService.get(user.getId());
|
service.syncUserFull(user);
|
||||||
User u=userService.get(user.getId());
|
|
||||||
Organization org=null;
|
|
||||||
if(a!=null) {
|
|
||||||
//账户只是修改状态
|
|
||||||
a.setDeleted(user.getDeleted());
|
|
||||||
}else {
|
|
||||||
//新账户
|
|
||||||
a=new Account();
|
|
||||||
a.setDeleted(user.getDeleted());
|
|
||||||
a.setSysId(user.getKid());
|
|
||||||
a.setLoginName(user.getCode());
|
|
||||||
a.setAvatar(user.getAvatar());
|
|
||||||
a.setId(user.getId());
|
|
||||||
a.setRegTime(LocalDateTime.now());
|
|
||||||
a.setSysId(user.getKid());
|
|
||||||
a.setStatus(1);
|
|
||||||
}
|
|
||||||
if(u!=null) {
|
|
||||||
//更新部分用户字段
|
|
||||||
u.setDepartId(user.getDepartId());
|
|
||||||
u.setDepartName(user.getDepartName());
|
|
||||||
u.setName(user.getName());
|
|
||||||
u.setUserType(user.getUserType());
|
|
||||||
if(user.getLearningDuration()>0) { //不大于0才会更新
|
|
||||||
u.setLearningDuration(user.getLearningDuration());
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
//新建用户
|
|
||||||
u=new User();
|
|
||||||
u.setId(user.getId());
|
|
||||||
u.setDepartId(user.getDepartId());
|
|
||||||
u.setDepartName(user.getDepartName());
|
|
||||||
u.setDynamic(0);
|
|
||||||
u.setGender(user.getGender());
|
|
||||||
u.setName(user.getName());
|
|
||||||
u.setSign("");
|
|
||||||
u.setUserNo(user.getCode());
|
|
||||||
u.setUserType(user.getUserType());
|
|
||||||
u.setSysId(user.getKid());
|
|
||||||
u.setStudyTotal(0);
|
|
||||||
u.setLearningDuration(user.getLearningDuration());
|
|
||||||
if(user.getBandLevel()!=null && user.getBandLevel()>15) {
|
|
||||||
u.setShowHome(false);//band16及以上
|
|
||||||
}else {
|
|
||||||
u.setShowHome(true);//band16以下,及其它无bandLevel的信息
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
//对机构的判断,不为空时才会处理,为空时不处理
|
|
||||||
if(StringUtils.isNotBlank(user.getDepartId())) {
|
|
||||||
org=orgService.get(user.getDepartId());
|
|
||||||
if(org==null) {
|
|
||||||
org=new Organization();
|
|
||||||
org.setCode("");
|
|
||||||
org.setId(user.getDepartId());
|
|
||||||
org.setName(user.getDepartName());
|
|
||||||
org.setDeleted(false);
|
|
||||||
org.setStatus(1);
|
|
||||||
}
|
|
||||||
org.setNamePath(user.getOrgNamePath());
|
|
||||||
|
|
||||||
}
|
|
||||||
service.syncUserFull(a, u, org);
|
|
||||||
|
|
||||||
return success(true);
|
return success(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("同步处理用户错误", e);
|
log.error("同步处理用户错误", e);
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.xboe.data.service;
|
package com.xboe.data.service;
|
||||||
|
|
||||||
import com.xboe.account.entity.Account;
|
import com.xboe.data.dto.UserData;
|
||||||
import com.xboe.system.organization.entity.Organization;
|
|
||||||
import com.xboe.system.user.entity.User;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户数据的更橷
|
* 用户数据的更橷
|
||||||
@@ -17,5 +15,5 @@ public interface IDataUserSyncService {
|
|||||||
* @param org
|
* @param org
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void syncUserFull(Account a,User u,Organization org);
|
void syncUserFull(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
package com.xboe.data.service.impl;
|
package com.xboe.data.service.impl;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
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.xboe.account.dao.AccountDao;
|
import com.xboe.account.dao.AccountDao;
|
||||||
import com.xboe.account.entity.Account;
|
import com.xboe.account.entity.Account;
|
||||||
|
import com.xboe.data.dto.UserData;
|
||||||
import com.xboe.data.service.IDataUserSyncService;
|
import com.xboe.data.service.IDataUserSyncService;
|
||||||
import com.xboe.module.teacher.dao.TeacherDao;
|
import com.xboe.module.teacher.dao.TeacherDao;
|
||||||
import com.xboe.module.teacher.entity.Teacher;
|
import com.xboe.module.teacher.entity.Teacher;
|
||||||
@@ -29,10 +33,80 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService{
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
TeacherDao teacherDao;
|
TeacherDao teacherDao;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void syncUserFull(Account a, User u, Organization org) {
|
public void syncUserFull(UserData user) {
|
||||||
|
|
||||||
|
//先查询是否存在
|
||||||
|
Account a=accountDao.get(user.getId());
|
||||||
|
User u=userDao.get(user.getId());
|
||||||
|
Organization org=null;
|
||||||
|
if(a!=null) {
|
||||||
|
//账户只是修改状态
|
||||||
|
if(user.getDeleted()!=null) {
|
||||||
|
a.setDeleted(user.getDeleted());
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
//新账户
|
||||||
|
a=new Account();
|
||||||
|
a.setDeleted(user.getDeleted());
|
||||||
|
a.setSysId(user.getKid());
|
||||||
|
a.setLoginName(user.getCode());
|
||||||
|
a.setAvatar(user.getAvatar());
|
||||||
|
a.setId(user.getId());
|
||||||
|
a.setRegTime(LocalDateTime.now());
|
||||||
|
a.setSysId(user.getKid());
|
||||||
|
a.setStatus(1);
|
||||||
|
}
|
||||||
|
if(u!=null) {
|
||||||
|
//更新部分用户字段
|
||||||
|
u.setDepartId(user.getDepartId());
|
||||||
|
u.setDepartName(user.getDepartName());
|
||||||
|
u.setName(user.getName());
|
||||||
|
u.setUserType(user.getUserType());
|
||||||
|
if(user.getLearningDuration()>0) { //不大于0才会更新
|
||||||
|
u.setLearningDuration(user.getLearningDuration());
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
//新建用户
|
||||||
|
u=new User();
|
||||||
|
u.setId(user.getId());
|
||||||
|
u.setDepartId(user.getDepartId());
|
||||||
|
u.setDepartName(user.getDepartName());
|
||||||
|
u.setDynamic(0);
|
||||||
|
u.setGender(user.getGender());
|
||||||
|
u.setName(user.getName());
|
||||||
|
u.setSign("");
|
||||||
|
u.setUserNo(user.getCode());
|
||||||
|
u.setUserType(user.getUserType());
|
||||||
|
u.setSysId(user.getKid());
|
||||||
|
u.setStudyTotal(0);
|
||||||
|
u.setLearningDuration(user.getLearningDuration());
|
||||||
|
if(user.getBandLevel()!=null && user.getBandLevel()>15) {
|
||||||
|
u.setShowHome(false);//band16及以上
|
||||||
|
}else {
|
||||||
|
u.setShowHome(true);//band16以下,及其它无bandLevel的信息
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//对机构的判断,不为空时才会处理,为空时不处理
|
||||||
|
if(StringUtils.isNotBlank(user.getDepartId())) {
|
||||||
|
org=orgDao.get(user.getDepartId());
|
||||||
|
if(org==null) {
|
||||||
|
org=new Organization();
|
||||||
|
org.setCode("");
|
||||||
|
org.setId(user.getDepartId());
|
||||||
|
org.setName(user.getDepartName());
|
||||||
|
org.setDeleted(false);
|
||||||
|
org.setStatus(1);
|
||||||
|
}
|
||||||
|
org.setNamePath(user.getOrgNamePath());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
accountDao.saveOrUpdate(a);
|
accountDao.saveOrUpdate(a);
|
||||||
userDao.saveOrUpdate(u);
|
userDao.saveOrUpdate(u);
|
||||||
if(org!=null) {
|
if(org!=null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user