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:
@@ -56,12 +56,12 @@ public class UserData {
|
||||
/**
|
||||
* 表系统管理员 是为1
|
||||
* */
|
||||
private Boolean SysAdmin;
|
||||
private Boolean sysAdmin;
|
||||
|
||||
/**
|
||||
* 表学习管理员 是为1
|
||||
* 管理员类型,1表默认管理员,2表非默认管理员,0表不是管理员
|
||||
* */
|
||||
private Boolean StudyAdmin;
|
||||
private Integer adminType;
|
||||
|
||||
/**
|
||||
* 是否删除的,如果是删除的,上面所有的字段可以不提供,只提供id就可以了
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface IOutSideDataService {
|
||||
List<AudienceUser> getUsersByAudienceId(String audienceId);
|
||||
|
||||
/**
|
||||
* 通过统一用户id获取用户的信息
|
||||
* 通过统一用户id获取用户的信息,如果是空,就是当前登录的用户
|
||||
*/
|
||||
UserData getUserInfoByUserId(String userId);
|
||||
|
||||
|
||||
@@ -73,19 +73,28 @@ public class OutSideDataServiceImpl implements IOutSideDataService {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// OutSideDataServiceImpl impl=new OutSideDataServiceImpl();
|
||||
// impl.getUserInfoByUserId(null);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public UserData getUserInfoByUserId(String userId) {
|
||||
|
||||
String token = TokenProxy.getToken(request);
|
||||
//String token="eyJ0eXBlIjoidG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC91LmJvZS5jb20iLCJpYXQiOjE2NzIxMTI3NTUsImV4cCI6MTY3MjExOTk1NSwiR2l2ZW5OYW1lIjoiYm9ldSIsInVzZXJJZCI6IjZCMDQ5RkFGLUMzMTQtN0NDRi0wRDI4LTBEMjNGNEM0MjUzMSIsInVJZCI6Ijk2NTM0MjAyNzQ5NzYwNzE2OCIsInBlcm1pc3Npb24iOiIifQ==.1348e0cfbb064d6d348d3976db3618974c1b1e8d2f6c6f45ae8294f09223f9b1";
|
||||
String type="application/json";
|
||||
String[] headers=new String[] {"token",token,"Content-Type",type};
|
||||
String url= getBaseUrl("/user/info");
|
||||
//String url="https://u-pre.boe.com/userbasic/user/info";
|
||||
ObjectMapper mapper=new ObjectMapper();
|
||||
try {
|
||||
//OkHttpUtil http=new OkHttpUtil();
|
||||
String responseStr = okHttpUtil.doPostJson(url,"{}", headers);
|
||||
//System.out.println(responseStr);
|
||||
JsonNode rootNode= mapper.readTree(responseStr);
|
||||
int code = rootNode.get("code").asInt();
|
||||
int code = rootNode.get("status").asInt();
|
||||
if(code!=200) {
|
||||
log.error("获取当前用户信息返回结果错误:"+responseStr);
|
||||
return null;
|
||||
@@ -104,26 +113,32 @@ public class OutSideDataServiceImpl implements IOutSideDataService {
|
||||
}
|
||||
user.setAvatar("");
|
||||
user.setCode(getNodeText(result.get("userNo")));
|
||||
user.setDeleted(result.get("deleted").asBoolean());
|
||||
//user.setDeleted(result.get("deleted").asBoolean());//无此字段
|
||||
user.setDeleted(false);
|
||||
user.setDepartId(getNodeText(result.get("departId")));
|
||||
user.setDepartName("");//无此字段
|
||||
user.setGender(1);//少此字段
|
||||
user.setKid(getNodeText(result.get("kid")));
|
||||
user.setLearningDuration(result.get("learningDuration").asInt());
|
||||
user.setName(result.get("realName").asText());
|
||||
user.setOrgNamePath(result.get("orgNamePath").asText());
|
||||
user.setOrgNamePath(result.get("orgName").asText());
|
||||
user.setUserType(1);//直接设置为学员
|
||||
if(result.get("roleList")!=null){
|
||||
JsonNode result1 = rootNode.get("result");
|
||||
for(JsonNode jsonNode :result1) {
|
||||
if(getNodeText(jsonNode.get("code")).equals("system-admin")){
|
||||
user.setSysAdmin(true);
|
||||
user.setTeacher(false);
|
||||
user.setAdminType(0);
|
||||
JsonNode roleList = result.get("roleList");
|
||||
if(roleList!=null){
|
||||
for(JsonNode jsonNode :roleList) {
|
||||
String roleCode=getNodeText(jsonNode.get("code"));
|
||||
if(roleCode.equals("system-admin")){
|
||||
user.setSysAdmin(true);//系统管理员
|
||||
}
|
||||
if(getNodeText(jsonNode.get("code")).equals("learning-admin")){
|
||||
user.setStudyAdmin(true);
|
||||
if(roleCode.equals("learning-admin")){
|
||||
user.setAdminType(1);//默认管理员
|
||||
}else if(roleCode.equals("non-default-admin")) {
|
||||
user.setAdminType(1);//非默认管理员
|
||||
}
|
||||
if(getNodeText(jsonNode.get("code")).equals("teacher")){
|
||||
user.setTeacher(true);
|
||||
if(roleCode.equals("teacher")){
|
||||
user.setTeacher(true);//是老师
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,6 +148,8 @@ public class OutSideDataServiceImpl implements IOutSideDataService {
|
||||
}
|
||||
|
||||
}
|
||||
System.out.println("用户管理员:"+user.getAdminType());
|
||||
System.out.println("老师:"+user.getTeacher());
|
||||
return user;
|
||||
} catch (Exception e) {
|
||||
log.error("获取当前用户信息错误",e);
|
||||
@@ -152,7 +169,7 @@ public class OutSideDataServiceImpl implements IOutSideDataService {
|
||||
try{
|
||||
responseStr = okHttpUtil.doPostJson(url,"{}", headers);
|
||||
JsonNode rootNode= mapper.readTree(responseStr);
|
||||
int code = rootNode.get("code").asInt();
|
||||
int code = rootNode.get("status").asInt();
|
||||
if(code!=200) {
|
||||
log.error("获取当前用户拥有权限机构id错误:"+responseStr);
|
||||
return null;
|
||||
|
||||
@@ -231,6 +231,7 @@ public class Cases extends BaseEntity {
|
||||
* 设置时间
|
||||
* */
|
||||
@Column(name = "excellent_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime excellentTime;
|
||||
|
||||
@Transient
|
||||
|
||||
@@ -63,6 +63,7 @@ public class CasesServiceImpl implements ICasesService {
|
||||
likes.add(FieldFilters.like("keyword4", LikeMatchMode.ANYWHERE, caseVo.getKeyWord()));
|
||||
likes.add(FieldFilters.like("keyword5", LikeMatchMode.ANYWHERE, caseVo.getKeyWord()));
|
||||
|
||||
|
||||
if(StringUtil.isNotBlank(caseVo.getKeyWord())) {
|
||||
filters.add(FieldFilters.or(likes));
|
||||
}
|
||||
@@ -82,6 +83,9 @@ public class CasesServiceImpl implements ICasesService {
|
||||
filters.add(FieldFilters.eq("excellent",caseVo.getExcellent()));
|
||||
}
|
||||
|
||||
//增加只是查询有附件的
|
||||
filters.add(FieldFilters.isNotNull("filePath"));
|
||||
filters.add(FieldFilters.ne("filePath",""));
|
||||
|
||||
// if(StringUtil.isNotBlank(caseVo.getMajorType())){
|
||||
// filters.add(FieldFilters.eq("majorType",caseVo.getMajorType()));
|
||||
|
||||
@@ -15,6 +15,8 @@ import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.IAuthorizationToken;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.data.dto.UserData;
|
||||
import com.xboe.data.outside.IOutSideDataService;
|
||||
import com.xboe.module.teacher.entity.Teacher;
|
||||
import com.xboe.module.teacher.service.ITeacherService;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
@@ -47,6 +49,9 @@ public class PortalConsoleApi extends ApiBaseController{
|
||||
|
||||
@Autowired
|
||||
ITeacherService teacherService;
|
||||
|
||||
@Autowired
|
||||
IOutSideDataService outsideDataService;
|
||||
|
||||
/**
|
||||
* 信息初始化
|
||||
@@ -62,6 +67,8 @@ public class PortalConsoleApi extends ApiBaseController{
|
||||
return error("账号错误,无此账号");
|
||||
}
|
||||
|
||||
UserData userData = outsideDataService.getUserInfoByUserId(null);
|
||||
|
||||
User user = userService.get(getCurrent().getAccountId());
|
||||
Organization org = null;
|
||||
String departName = "";
|
||||
@@ -78,9 +85,11 @@ public class PortalConsoleApi extends ApiBaseController{
|
||||
//检查是否是教师,并计算用户的类型,修改于220507
|
||||
Teacher t = teacherService.get(account.getId());
|
||||
int utype=1,ttype=0;
|
||||
//本地判断是否是管理员
|
||||
if(user.getUserType()!=null && user.getUserType()==3) {
|
||||
utype=3;
|
||||
}
|
||||
//判断是否是老师
|
||||
if(t!=null && (t.getDeleted()==null || !t.getDeleted())) {
|
||||
ttype=2;
|
||||
}
|
||||
@@ -94,8 +103,23 @@ public class PortalConsoleApi extends ApiBaseController{
|
||||
}
|
||||
}
|
||||
|
||||
// int utype=1;//仅仅是学员
|
||||
// if(userData.getTeacher()) {
|
||||
// utype=2;
|
||||
// }
|
||||
// if(userData.getAdminType()>0) {
|
||||
// if(utype==2) {
|
||||
// utype=5;//是管理员,又是教师
|
||||
// }else {
|
||||
// utype=3;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
map.put("aid",account.getId());
|
||||
map.put("sysId",user.getSysId());
|
||||
map.put("adminType",userData.getAdminType());//管理员类型,1表默认管理员,2表非默认管理员,0表不是管理员
|
||||
map.put("companyId",user.getCompanyId());
|
||||
map.put("name",user.getName());
|
||||
map.put("sex",user.getGender());
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -29,6 +30,8 @@ import com.xboe.core.IAuthorizationToken;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.JsonResponseStatus;
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.data.dto.UserData;
|
||||
import com.xboe.data.outside.IOutSideDataService;
|
||||
import com.xboe.externalinterface.system.service.IFwUserService;
|
||||
import com.xboe.system.logs.entity.SysLogLogin;
|
||||
import com.xboe.system.logs.service.ISysLogLoginService;
|
||||
@@ -63,6 +66,9 @@ public class PortalLoginApi extends ApiBaseController {
|
||||
|
||||
@Autowired
|
||||
StringRedisTemplate redisTemplate;
|
||||
|
||||
@Autowired
|
||||
IOutSideDataService outsideService;
|
||||
|
||||
@GetMapping("/captcha")
|
||||
public JsonResponse<Map<String, String>> captcha() {
|
||||
@@ -201,51 +207,31 @@ public class PortalLoginApi extends ApiBaseController {
|
||||
if (tokenInfo == null) {
|
||||
return wrap(JsonResponseStatus.TOKEN_NOPASS, "token error");
|
||||
}
|
||||
Account account = null;
|
||||
if(StringUtil.isNotBlank(tokenInfo.get("aid"))){
|
||||
//检查系统用户是否存在
|
||||
account = accountService.get(tokenInfo.get("aid"));
|
||||
}else{
|
||||
//log.error("查询用户kid【"+tokenInfo.get("userId")+"】");
|
||||
// 没有aid则判断是否已同步的用户,不是则同步
|
||||
if(StringUtil.isNotBlank(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不合法");
|
||||
}
|
||||
}
|
||||
if (account == null) {
|
||||
log.error("未找到用户的id:"+tokenInfo.get("userId"));
|
||||
return error("未找到的用户信息");
|
||||
}
|
||||
|
||||
//在这种情况下情况下,应该重置 一下缓存,以便对用户进行缓存更新
|
||||
//String cacheKey=CacheName.NAME_USER+ CacheName.KEY_USER_SYSID +account.getId();
|
||||
|
||||
|
||||
// if (account.getStatus() == Constants.ACCOUNT_STATUS_DEACTIVATE) {
|
||||
// return error("账号已停用");
|
||||
// }
|
||||
UserData udata=outsideService.getUserInfoByUserId(null);
|
||||
if(udata==null) {
|
||||
log.error("未获取当前登录人的用户信息");
|
||||
return wrap(JsonResponseStatus.TOKEN_NOPASS, "用户信息查询失败");
|
||||
}
|
||||
|
||||
//检查本地是否存在,如果存在就更新,不存在就添加
|
||||
|
||||
Map<String, String> data = new HashMap<String, String>();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
//模拟数据
|
||||
data.put("aid",udata.getId());
|
||||
data.put("uId", udata.getId());//匹配新的token中的 uId
|
||||
data.put("name", udata.getName());
|
||||
data.put("userNo", udata.getCode());
|
||||
data.put("departId", udata.getDepartId());
|
||||
data.put("userId",udata.getKid());
|
||||
|
||||
Map<String, Object> map = this.createToken(account);
|
||||
//此处以后用于服务端记录,因为当前不再转化token,直接使用老系统生成的token
|
||||
String newtoken = authorizationToken.createToken(data);
|
||||
map.put("expires_in", IAuthorizationToken.TOKEN_TIMEOUT);
|
||||
map.put("scope", "boe");
|
||||
map.put("access_token", newtoken);
|
||||
//
|
||||
return success(map);
|
||||
} catch (Exception e) {
|
||||
log.error("boe登录 错误", e);
|
||||
|
||||
@@ -37,6 +37,7 @@ xboe.old.base.url=https://u.boe.com
|
||||
|
||||
## 用户统计接口的api地址
|
||||
xboe.stat.base.url=http://127.0.0.1:9080
|
||||
xboe.server.userbasic.url=https://u.boe.com/userbasic
|
||||
|
||||
#加密盐
|
||||
#jasypt.encryptor.password=jasypt
|
||||
|
||||
@@ -74,6 +74,7 @@ xboe.old.base.url=https://u.boe.com
|
||||
|
||||
## 用户统计接口的api地址
|
||||
xboe.stat.base.url=http://127.0.0.1:9080
|
||||
xboe.server.userbasic.url=https://u.boe.com/userbasic
|
||||
|
||||
#加密盐
|
||||
#jasypt.encryptor.password=jasypt
|
||||
|
||||
@@ -49,6 +49,7 @@ xboe.old.base.url=https://u-pre.boe.com
|
||||
|
||||
## 用户统计接口的api地址
|
||||
xboe.stat.base.url=http://127.0.0.1:9080
|
||||
xboe.server.userbasic.url=https://u-pre.boe.com/userbasic
|
||||
|
||||
#加密盐
|
||||
#jasypt.encryptor.password=jasypt
|
||||
|
||||
Reference in New Issue
Block a user