mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-18 23:36:52 +08:00
Merge branch 'master' of codeup.aliyun.com:6265f483e4166464dc2f9c14/boeu/baseservers
# Conflicts: # servers/boe-server-case/src/main/resources/application-pre.properties # servers/boe-server-case/src/main/resources/application-pro.properties
This commit is contained in:
@@ -8,6 +8,9 @@ public interface CacheName {
|
||||
*/
|
||||
String NAME_AUTH= "auth";
|
||||
|
||||
|
||||
String NAME_USER_LOGIN_ERROR_NUM= "user:login:error:aid:";
|
||||
|
||||
/**
|
||||
* 验证码key前缀
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.xboe.data.api;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.account.service.IAccountService;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.data.dto.UserData;
|
||||
import com.xboe.data.service.IDataUserSyncService;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import com.xboe.system.organization.service.IOrganizationService;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import com.xboe.system.user.service.IUserService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 用户数据同步的处理
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping(value = "/inner/data")
|
||||
public class UserDataSyncApi extends ApiBaseController {
|
||||
|
||||
@Autowired
|
||||
IAccountService accountService;
|
||||
|
||||
@Autowired
|
||||
IUserService userService;
|
||||
|
||||
@Autowired
|
||||
IOrganizationService orgService;
|
||||
|
||||
@Autowired
|
||||
IDataUserSyncService service;
|
||||
|
||||
@PostMapping("/user")
|
||||
public JsonResponse<Boolean> syncUser( @RequestBody UserData user) {
|
||||
|
||||
if (StringUtils.isBlank(user.getId())) {
|
||||
return error("无用户的id");
|
||||
}
|
||||
//清除缓存需要loginName
|
||||
try {
|
||||
//先查询是否存在
|
||||
Account a=accountService.get(user.getId());
|
||||
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(u.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);
|
||||
} catch (Exception e) {
|
||||
log.error("同步处理用户错误", e);
|
||||
return error("同步处理用户失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xboe.data.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 受众人员
|
||||
* @author seastar
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class AudienceUser {
|
||||
|
||||
/**
|
||||
* 用户的统一id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 用户的姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 用户的代码
|
||||
*/
|
||||
private String code;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.xboe.data.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用于同步的用户数据
|
||||
* @author seastar
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class UserData {
|
||||
|
||||
/**用户的id*/
|
||||
private String id;
|
||||
|
||||
/**主要是为了兼容之前的使用,新用户可以为空*/
|
||||
private String kid;
|
||||
|
||||
/**用户工号*/
|
||||
private String code;
|
||||
|
||||
/**band的级别*/
|
||||
private Integer bandLevel;
|
||||
|
||||
/**姓名*/
|
||||
private String name;
|
||||
|
||||
/**用户的头像*/
|
||||
private String avatar;
|
||||
|
||||
/**性别 1:男 2:女*/
|
||||
private Integer gender;
|
||||
|
||||
/**学习时长,秒*/
|
||||
private Integer learningDuration;
|
||||
|
||||
/**部门id*/
|
||||
private String departId;
|
||||
|
||||
/**部门名称*/
|
||||
private String departName;
|
||||
|
||||
/**此字段主要是为了人员的显示*/
|
||||
private String orgNamePath;
|
||||
|
||||
/**
|
||||
* 用户类型,1表学员,2表教师,3表管理员
|
||||
*/
|
||||
private Integer userType;
|
||||
|
||||
/**
|
||||
* 是否删除的,如果是删除的,上面所有的字段可以不提供,只提供id就可以了
|
||||
*/
|
||||
private Boolean deleted;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xboe.data.outside;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.xboe.data.dto.AudienceUser;
|
||||
import com.xboe.data.dto.UserData;
|
||||
|
||||
public interface IOutSideDataService {
|
||||
|
||||
/**
|
||||
* 获取受众的所有用户
|
||||
* @param task
|
||||
*/
|
||||
List<AudienceUser> getUsersByAudienceId(String audienceId);
|
||||
|
||||
/**
|
||||
* 通过统一用户id获取用户的信息
|
||||
*/
|
||||
UserData getUserInfoByUserId(String userId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.xboe.data.outside;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.api.TokenProxy;
|
||||
import com.xboe.core.utils.OkHttpUtil;
|
||||
import com.xboe.data.dto.AudienceUser;
|
||||
import com.xboe.data.dto.UserData;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class OutSideDataServiceImpl implements IOutSideDataService {
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private OkHttpUtil okHttpUtil;
|
||||
|
||||
|
||||
private String getNodeText(JsonNode jn) {
|
||||
if(jn!=null) {
|
||||
return jn.asText();
|
||||
}else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AudienceUser> getUsersByAudienceId(String audienceId){
|
||||
|
||||
String token = TokenProxy.getToken(request);
|
||||
String type="application/json";
|
||||
String[] headers=new String[] {"token",token,"Content-Type",type};
|
||||
String url= getBaseUrl("/audience/memberList");
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("audienceId", audienceId);
|
||||
String json = null;
|
||||
List<AudienceUser> list=new ArrayList<AudienceUser>();
|
||||
ObjectMapper mapper=new ObjectMapper();
|
||||
try {
|
||||
|
||||
json = mapper.writeValueAsString(params);
|
||||
String responseStr = okHttpUtil.doPostJson(url, json, headers);
|
||||
JsonNode rootNode= mapper.readTree(responseStr);
|
||||
|
||||
JsonNode result = rootNode.get("result")!=null ?( rootNode.get("result").get("data") !=null ? rootNode.get("result").get("data"):null):null;
|
||||
if(rootNode.get("result")!=null & rootNode.get("result").isArray()) {
|
||||
//这里应该是单独的线程去处理
|
||||
for(JsonNode JsonNode :result) {
|
||||
AudienceUser au=new AudienceUser();
|
||||
au.setId(JsonNode.get("id").asText());
|
||||
au.setName(getNodeText(JsonNode.get("userName")));
|
||||
au.setCode(getNodeText(JsonNode.get("userNo")));
|
||||
list.add(au);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取受众用户列表错误",e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserData getUserInfoByUserId(String userId) {
|
||||
|
||||
String token = TokenProxy.getToken(request);
|
||||
String type="application/json";
|
||||
String[] headers=new String[] {"token",token,"Content-Type",type};
|
||||
String url= getBaseUrl("/user/info");
|
||||
ObjectMapper mapper=new ObjectMapper();
|
||||
try {
|
||||
String responseStr = okHttpUtil.doPostJson(url,"{}", headers);
|
||||
JsonNode rootNode= mapper.readTree(responseStr);
|
||||
int code = rootNode.get("code").asInt();
|
||||
if(code!=200) {
|
||||
log.error("获取当前用户信息返回结果错误:"+responseStr);
|
||||
return null;
|
||||
}
|
||||
UserData user=new UserData();
|
||||
JsonNode result = rootNode.get("result");
|
||||
if(rootNode.get("result")!=null & rootNode.get("result").isObject()) {
|
||||
//这里应该是单独的线程去处理
|
||||
user.setId(getNodeText(result.get("id")));
|
||||
String band=getNodeText(result.get("bandCode"));
|
||||
if(StringUtils.isNotBlank(band) && band.length()>4) {
|
||||
String bandNum=band.substring(4);
|
||||
user.setBandLevel(Integer.valueOf(bandNum));
|
||||
}else {
|
||||
user.setBandLevel(0);
|
||||
}
|
||||
user.setAvatar("");
|
||||
user.setCode(getNodeText(result.get("userNo")));
|
||||
user.setDeleted(result.get("deleted").asBoolean());
|
||||
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.setUserType(1);//直接设置为学员
|
||||
if(StringUtils.isBlank(user.getCode())) {
|
||||
log.error("通过接口获取当前用户信息【"+user.getId()+"】"+user.getName()+",工号为空,不能使用");
|
||||
throw new RuntimeException("通过接口获取当前用户信息,工号为空,不能使用");
|
||||
}
|
||||
|
||||
}
|
||||
return user;
|
||||
} catch (Exception e) {
|
||||
log.error("获取当前用户信息错误",e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getBaseUrl(String url) {
|
||||
String baseUrl=SysConstant.getConfigValue("xboe.server.userbasic.url");
|
||||
if(StringUtils.isBlank(baseUrl)) {
|
||||
log.error("调用用户接口错误,未配置用户服务的地址【xboe.server.userbasic.url】");
|
||||
throw new RuntimeException("获取用户信息错误,未配置用户服务的地址");
|
||||
}
|
||||
String reqUrl= baseUrl+"/user/info";
|
||||
return reqUrl;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xboe.data.service;
|
||||
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import com.xboe.system.user.entity.User;
|
||||
|
||||
/**
|
||||
* 用户数据的更橷
|
||||
*
|
||||
*/
|
||||
public interface IDataUserSyncService {
|
||||
|
||||
/**
|
||||
* 同步用户,账号,机构等信息
|
||||
* @param a
|
||||
* @param u
|
||||
* @param org
|
||||
* @return
|
||||
*/
|
||||
void syncUserFull(Account a,User u,Organization org);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.xboe.data.service.impl;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.xboe.account.dao.AccountDao;
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.data.service.IDataUserSyncService;
|
||||
import com.xboe.module.teacher.dao.TeacherDao;
|
||||
import com.xboe.module.teacher.entity.Teacher;
|
||||
import com.xboe.system.organization.dao.OrganizationDao;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import com.xboe.system.user.dao.UserDao;
|
||||
import com.xboe.system.user.entity.User;
|
||||
|
||||
@Service
|
||||
public class DataUserSyncServiceImpl implements IDataUserSyncService{
|
||||
|
||||
@Autowired
|
||||
AccountDao accountDao;
|
||||
|
||||
@Autowired
|
||||
UserDao userDao;
|
||||
|
||||
@Autowired
|
||||
OrganizationDao orgDao;
|
||||
|
||||
@Autowired
|
||||
TeacherDao teacherDao;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void syncUserFull(Account a, User u, Organization org) {
|
||||
accountDao.saveOrUpdate(a);
|
||||
userDao.saveOrUpdate(u);
|
||||
if(org!=null) {
|
||||
orgDao.saveOrUpdate(org);
|
||||
}
|
||||
//老师信息
|
||||
if(u.getUserType()!=null && u.getUserType()==2) {
|
||||
Teacher t = teacherDao.get(u.getId());
|
||||
if(t==null) {
|
||||
t=new Teacher();
|
||||
t.setId(u.getId());
|
||||
t.setDepartId(u.getDepartId());
|
||||
t.setDeleted(false);
|
||||
t.setGender(u.getGender());
|
||||
t.setName(u.getName());
|
||||
t.setStatus(1);
|
||||
t.setWaitStatus(0);
|
||||
t.setUser(u);
|
||||
teacherDao.save(t);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -223,6 +223,8 @@ public class Cases extends BaseEntity {
|
||||
@Column(name = "case_value")
|
||||
private String caseValue;
|
||||
|
||||
|
||||
|
||||
@Transient
|
||||
private List<String> majorIds;
|
||||
|
||||
|
||||
@@ -472,12 +472,6 @@ public class CourseServiceImpl implements ICourseService {
|
||||
//同时添加发布事件,这里的创建人需要修改为教师
|
||||
Course c=courseDao.get(id);
|
||||
//删除分两种情况,一个是管理员删除,一个是自己删除 ,所以这里的处理移到前端了
|
||||
// if(eventSender!=null) {
|
||||
// eventSender.send("删除课程","DeleteCourse", "删除课程【"+c.getName()+"】", c.getId(), "1", c.getName(), c.getSysCreateAid(), c.getSysCreateBy(),"");
|
||||
// }else {
|
||||
// log.error("未配置事件消息发送的实现");
|
||||
// }
|
||||
//删除
|
||||
if(c.getFullTextId()!=null) {
|
||||
try {
|
||||
fullTextSearch.remove(ICourseFullTextSearch.DEFAULT_INDEX_NAME,c.getFullTextId());
|
||||
@@ -485,6 +479,26 @@ public class CourseServiceImpl implements ICourseService {
|
||||
log.error("删除课程时删除全文索引错误",e);
|
||||
}
|
||||
}
|
||||
//只有速有全文检索返回标识的,才算是发布过再删除的,删除消息
|
||||
if(StringUtils.isNotBlank(c.getFullTextId())){
|
||||
if(eventSender!=null) {
|
||||
List<CourseTeacher> teachers = courseTeacherDao.findList(FieldFilters.eq("courseId", id));
|
||||
if(teachers.size()>0) {
|
||||
String authorIds="";
|
||||
for(CourseTeacher cteacher:teachers) {
|
||||
if(authorIds.equals("")) {
|
||||
authorIds+=cteacher.getTeacherId();
|
||||
}else {
|
||||
authorIds+="|"+cteacher.getTeacherId();
|
||||
}
|
||||
}
|
||||
String txt="管理删除课程";
|
||||
eventSender.send(txt,"CourseDelete", "管理删除课程", c.getId(), "1", c.getName(), aid, name,"authors:"+authorIds);
|
||||
}
|
||||
}else {
|
||||
log.error("未配置事件消息发送的实现");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//彻底删除,课件设置为无课程状态
|
||||
courseDao.setDeleted(id);
|
||||
@@ -834,12 +848,23 @@ public class CourseServiceImpl implements ICourseService {
|
||||
//发布到全文检索中
|
||||
Course c=courseDao.get(courseId);
|
||||
if(fullTextSearch!=null) {
|
||||
|
||||
this.fullTextPublish(c);
|
||||
}
|
||||
//同时添加发布事件,这里的创建人需要修改为教师
|
||||
if(eventSender!=null) {
|
||||
eventSender.send("发布课程","PublishCourse", "发布课程【"+c.getName()+"】", c.getId(), "1", c.getName(), c.getSysCreateAid(), c.getSysCreateBy(),"");
|
||||
List<CourseTeacher> teachers = courseTeacherDao.findList(FieldFilters.eq("courseId", courseId));
|
||||
if(teachers.size()>0) {
|
||||
String authorIds="";
|
||||
for(CourseTeacher cteacher:teachers) {
|
||||
if(authorIds.equals("")) {
|
||||
authorIds+=cteacher.getTeacherId();
|
||||
}else {
|
||||
authorIds+="|"+cteacher.getTeacherId();
|
||||
}
|
||||
}
|
||||
eventSender.send("发布课程","PublishCourse", "发布课程【"+c.getName()+"】", c.getId(), "1", c.getName(), aid,name,"authors:"+authorIds);
|
||||
}
|
||||
|
||||
}else {
|
||||
log.error("未配置事件消息发送的实现");
|
||||
}
|
||||
@@ -943,7 +968,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
@Override
|
||||
public List<CourseTeacher> findTeachersByCourseId(String courseId) {
|
||||
|
||||
return courseTeacherDao.findList(FieldFilters.eq("courseId", courseId));
|
||||
return courseTeacherDao.findList(OrderCondition.desc("teacherId"),FieldFilters.eq("courseId", courseId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -961,7 +986,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
@Override
|
||||
public List<CourseTeacher> findTeachersByCourseIds(List<String> ids) {
|
||||
|
||||
return courseTeacherDao.findList(FieldFilters.in("courseId",ids));
|
||||
return courseTeacherDao.findList(OrderCondition.desc("teacherId"),FieldFilters.in("courseId",ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.QueryBuilder;
|
||||
import com.xboe.module.course.dao.CourseTeacherDao;
|
||||
@@ -39,7 +40,7 @@ public class CourseTeacherServiceImpl implements ICourseTeacherService {
|
||||
public CourseTeacherDto getTeacherByCourseId(String courseId) {
|
||||
CourseTeacherDto dto = null;
|
||||
|
||||
List<CourseTeacher> list = dao.findList(FieldFilters.eq("courseId",courseId));
|
||||
List<CourseTeacher> list = dao.findList(OrderCondition.desc("teacherId"),FieldFilters.eq("courseId",courseId));
|
||||
if(list != null && !list.isEmpty()){
|
||||
dto=new CourseTeacherDto();
|
||||
dto.setCourseId(courseId);
|
||||
@@ -60,7 +61,7 @@ public class CourseTeacherServiceImpl implements ICourseTeacherService {
|
||||
public List<CourseTeacherDto> queryTeacher(Collection<String> ids) {
|
||||
List<CourseTeacherDto> teacherDtos = null;
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
List<CourseTeacher> list = dao.findList(FieldFilters.in("courseId",ids));
|
||||
List<CourseTeacher> list = dao.findList(OrderCondition.desc("teacherId"),FieldFilters.in("courseId",ids));
|
||||
if(list != null && !list.isEmpty()) {
|
||||
teacherDtos = new ArrayList<>();
|
||||
for (String s : ids) {
|
||||
|
||||
@@ -78,6 +78,7 @@ public class ExamPaper extends BaseEntity {
|
||||
@Column(name = "counts")
|
||||
private Integer counts;
|
||||
|
||||
|
||||
public ExamPaper(String testName, String paperType, Integer paperMode, String resOwner1,
|
||||
String resOwner2, String resOwner3,String sysCreateBy,LocalDateTime sysUpdateTime,String id,Integer counts) {
|
||||
this.testName = testName;
|
||||
|
||||
@@ -156,6 +156,7 @@ public class ExamTest extends BaseEntity {
|
||||
@Column(name = "deadline_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime deadlineTime;
|
||||
|
||||
|
||||
@Transient
|
||||
private String paperName;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ExamUserTask extends IdBaseEntity{
|
||||
/**
|
||||
* 群组,受众id
|
||||
*/
|
||||
@Column(name = "group_id",nullable=false,length=20)
|
||||
@Column(name = "group_id",nullable=false,length=36)
|
||||
private String groupId;
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,13 +10,14 @@ import javax.transaction.Transactional;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.data.dto.AudienceUser;
|
||||
import com.xboe.data.outside.IOutSideDataService;
|
||||
import com.xboe.module.exam.dao.AloneExamAnswerDao;
|
||||
import com.xboe.module.exam.dao.AloneExamDao;
|
||||
import com.xboe.module.exam.dao.ExamUserTaskDao;
|
||||
import com.xboe.module.exam.dto.ExamTestDto;
|
||||
import com.xboe.module.exam.entity.AloneExam;
|
||||
import com.xboe.module.exam.entity.AloneExamAnswer;
|
||||
import com.xboe.module.exam.entity.ExamPaper;
|
||||
import com.xboe.module.exam.entity.ExamTest;
|
||||
import com.xboe.module.exam.entity.ExamUserTask;
|
||||
import com.xboe.module.exam.service.IExamUserTaskService;
|
||||
@@ -41,6 +42,9 @@ public class ExamUserTaskServiceImpl implements IExamUserTaskService{
|
||||
|
||||
@Resource
|
||||
AloneExamDao aloneExamDao;
|
||||
|
||||
@Resource
|
||||
IOutSideDataService outSideService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -54,13 +58,13 @@ public class ExamUserTaskServiceImpl implements IExamUserTaskService{
|
||||
examUserTask.setTaskTime(LocalDateTime.now());
|
||||
examUserTask.setStatus(ExamUserTask.STATUS_FINISH);
|
||||
dao.save(examUserTask);
|
||||
// 下面的代码应该调用rePushTask
|
||||
//执行推送,当前因为是固定人,所以这里直接添加处理,按受众添加到每个人中
|
||||
//查询受众的信息
|
||||
List<UserGroupItem> items = ugroupDao.findList("groupId", task.getGroupId());
|
||||
if(items.size()>0) {
|
||||
//防止加入两条的问题,应该是先查询,再添加
|
||||
Map<String,Object> amap= aloneExamDao.findMap("aid", "name",FieldFilters.eq("testId", task.getTestId()));
|
||||
|
||||
//这里应该是单独的线程去处理
|
||||
for(UserGroupItem item :items) {
|
||||
if(amap.containsKey(item.getAid())) {
|
||||
@@ -90,7 +94,7 @@ public class ExamUserTaskServiceImpl implements IExamUserTaskService{
|
||||
@Transactional
|
||||
public void rePushTask(ExamTestDto task) {
|
||||
//执行推送,当前因为是固定人,所以这里直接添加处理,按受众添加到每个人中
|
||||
//查询受众的信息
|
||||
//查询受众的信息,2022、11、30 这个的返回需要从接口获取人员信息,然后推送
|
||||
List<UserGroupItem> items = ugroupDao.findList("groupId", task.getGroupId());
|
||||
if(items.size()>0) {
|
||||
//防止加入两条的问题,应该是先查询,再添加
|
||||
@@ -115,6 +119,33 @@ public class ExamUserTaskServiceImpl implements IExamUserTaskService{
|
||||
aloneExamDao.save(aloneExam);
|
||||
}
|
||||
}
|
||||
|
||||
//调用用户服务的接口,在启用下面的代码前,需要
|
||||
// List<AudienceUser> sudienceUsers=outSideService.getUsersByAudienceId(task.getGroupId());
|
||||
// if(sudienceUsers.size()>0) {
|
||||
// //防止加入两条的问题,应该是先查询,再添加
|
||||
// Map<String,Object> amap= aloneExamDao.findMap("aid", "name",FieldFilters.eq("testId", task.getTestId()));
|
||||
// //这里应该是单独的线程去处理
|
||||
// for(AudienceUser item :sudienceUsers) {
|
||||
// if(amap.containsKey(item.getId())) {
|
||||
// continue;
|
||||
// }
|
||||
// //检查是否存在
|
||||
// AloneExam aloneExam = new AloneExam();
|
||||
// aloneExam.setAid(item.getId());
|
||||
// aloneExam.setTestId(task.getTestId());
|
||||
// aloneExam.setTestName(task.getTestName());
|
||||
// aloneExam.setName(item.getName());
|
||||
// aloneExam.setUcode(item.getCode());
|
||||
// aloneExam.setTestDuration(task.getDuration());
|
||||
// aloneExam.setTaskTime(LocalDateTime.now());
|
||||
// aloneExam.setStartTime(task.getStartTime());
|
||||
// aloneExam.setStatus(AloneExamAnswer.STATUS_NONE);//未考试过
|
||||
// aloneExam.setScore(0f);
|
||||
// aloneExamDao.save(aloneExam);
|
||||
// }
|
||||
// }
|
||||
|
||||
//examUserTask.setStatus(ExamUserTask.STATUS_FINISH);
|
||||
//dao.update(examUserTask);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xboe.module.interaction.api;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -15,6 +16,8 @@ import com.xboe.module.interaction.service.ICourseGradeService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping(value = "/xboe/m/grade")
|
||||
@@ -50,5 +53,23 @@ public class CourseGradeApi extends ApiBaseController {
|
||||
return success(has);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前用户评分的课程 分数
|
||||
* */
|
||||
@PostMapping("/score")
|
||||
public JsonResponse<CourseGrade> score(String courseId,String aid){
|
||||
if(StringUtils.isBlank(courseId)){
|
||||
return badRequest("参数异常");
|
||||
}
|
||||
if(StringUtils.isBlank(aid)){
|
||||
aid=this.getCurrent().getAccountId();
|
||||
}
|
||||
CourseGrade score = service.score(courseId, aid);
|
||||
if(score==null) {
|
||||
return notfound();
|
||||
}
|
||||
return success(score);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.xboe.common.PageList;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.interaction.entity.CourseGrade;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ICourseGradeService {
|
||||
|
||||
|
||||
@@ -20,4 +22,9 @@ public interface ICourseGradeService {
|
||||
* 查询当前用户是否评分
|
||||
* */
|
||||
Boolean has(String courseId,String aid);
|
||||
|
||||
/**
|
||||
* 查询当前用户评分的课程
|
||||
* */
|
||||
CourseGrade score(String courseId,String aid);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.xboe.module.interaction.service.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -77,6 +80,13 @@ public class CourseGradeServiceImpl implements ICourseGradeService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CourseGrade score(String courseId, String aid) {
|
||||
|
||||
CourseGrade cg = courseGradeDao.findOne(FieldFilters.eq("courseId", courseId), FieldFilters.eq("sysCreateAid", aid));
|
||||
|
||||
return cg;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class UserGroupItem extends IdEntity {
|
||||
/**
|
||||
* 受众ID
|
||||
*/
|
||||
@Column(name = "group_Id", nullable = false, length = 20)
|
||||
@Column(name = "group_Id", nullable = false, length = 36)
|
||||
private String groupId;
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,7 @@ public class EventDataSender implements IEventDataSender{
|
||||
|
||||
@Override
|
||||
public void send(String title, String eventKey, String content, String objId, String objType, String objInfo,
|
||||
String aid, String aname,String author) {
|
||||
String aid, String aname,String parameters) {
|
||||
String statBaseUrl=SysConstant.getConfigValue("xboe.stat.base.url");
|
||||
if(StringUtils.isBlank(statBaseUrl)) {
|
||||
log.error("发送事件失败:未配置【xboe.stat.base.url】的值");
|
||||
@@ -58,7 +58,7 @@ public class EventDataSender implements IEventDataSender{
|
||||
params.put("objInfo", objInfo);
|
||||
params.put("aid", aid);
|
||||
params.put("aname", aname);
|
||||
params.put("parameters","");
|
||||
params.put("parameters",parameters);
|
||||
String token = TokenProxy.getToken(request);
|
||||
//最后采用异常发送,不影响当前进程
|
||||
|
||||
|
||||
@@ -81,24 +81,6 @@ public class SysLoginApi extends ApiBaseController {
|
||||
return success(map);
|
||||
}
|
||||
|
||||
@GetMapping("/login/send")
|
||||
public JsonResponse<Map<String, String>> sendMessage() {
|
||||
Map<String, String> rs=new HashMap<String, String>();
|
||||
|
||||
if(eventSender!=null) {
|
||||
try {
|
||||
eventSender.send("测试消息","keykey", "all测试消息","1231231", "1", "aaaa", "asdqadqw","wqwrqre","");
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
return error("发送失败"+e.getMessage());
|
||||
}
|
||||
}else {
|
||||
//log.error();
|
||||
return error("未配置事件消息发送的实现");
|
||||
}
|
||||
return success(rs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户名和密码登录
|
||||
*
|
||||
@@ -117,6 +99,9 @@ public class SysLoginApi extends ApiBaseController {
|
||||
if (!code.toLowerCase().equals(verCode)) {
|
||||
return error("验证码错误");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 检查系统用户是否存在
|
||||
Account account = accountService.check(loginName,null);
|
||||
String passStr = "";
|
||||
@@ -124,8 +109,27 @@ public class SysLoginApi extends ApiBaseController {
|
||||
passStr = MD5Util.MD5Encode(password + account.getPassKey());
|
||||
}
|
||||
|
||||
// 从redis缓存中获取5分钟内登陆错误的次数
|
||||
String loginErrorNum = redisTemplate.opsForValue().get(CacheName.NAME_USER_LOGIN_ERROR_NUM+account);
|
||||
Integer loginErrorCount = 0;
|
||||
if(loginErrorNum != null){
|
||||
loginErrorCount = Integer.parseInt(loginErrorNum);
|
||||
}
|
||||
|
||||
if (account == null || StringUtil.isBlank(passStr) || !passStr.equals(account.getPassValue())) {
|
||||
return error("用户名或密码错误");
|
||||
if(loginErrorCount >=5){
|
||||
redisTemplate.opsForValue().set(CacheName.NAME_USER_LOGIN_ERROR_NUM+account, "5", 5, TimeUnit.MINUTES);
|
||||
return error("由于您登录失败次数过多,账号已被锁定!");
|
||||
}else{
|
||||
loginErrorCount = loginErrorCount + 1;
|
||||
redisTemplate.opsForValue().set(CacheName.NAME_USER_LOGIN_ERROR_NUM+account, loginErrorCount+"", 5, TimeUnit.MINUTES);
|
||||
int next = (6-loginErrorCount);
|
||||
if(next == 0){
|
||||
return error("账号已被锁定");
|
||||
}
|
||||
return error("用户名或密码错误,您还有"+(6-loginErrorCount)+"次登录机会");
|
||||
}
|
||||
// return error("用户名或密码错误");
|
||||
}
|
||||
|
||||
if (account.getStatus().equals(Constants.ACCOUNT_STATUS_DEACTIVATE)) {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
||||
String url = request.getServletPath();
|
||||
//当前先写固定的url判断
|
||||
//以下是针对于url规划的判断,这里简写
|
||||
if(url.startsWith("/xboe/account/captcha") || url.startsWith("/xboe/account/login") || url.startsWith("/xboe/account/boelogin") || url.startsWith("/xboe/account/mobile-login") || url.startsWith("/xboe/account/logout") || url.startsWith("/xboe/system/captcha") || url.startsWith("/xboe/system/logout") || url.startsWith("/xboe/system/login") || url.startsWith("/xboe/sys/user/sync-all")){
|
||||
if(url.startsWith("/inner/data") || url.startsWith("/xboe/account/captcha") || url.startsWith("/xboe/account/login") || url.startsWith("/xboe/account/boelogin") || url.startsWith("/xboe/account/mobile-login") || url.startsWith("/xboe/account/logout") || url.startsWith("/xboe/system/captcha") || url.startsWith("/xboe/system/logout") || url.startsWith("/xboe/system/login") || url.startsWith("/xboe/sys/user/sync-all")){
|
||||
filterChain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Organization extends BaseEntity {
|
||||
/**
|
||||
* 组织部门代码
|
||||
*/
|
||||
@Column(name = "code", nullable = false, length = 50)
|
||||
@Column(name = "code", nullable = true, length = 50)
|
||||
private String code;
|
||||
|
||||
/**
|
||||
|
||||
@@ -287,6 +287,7 @@ public class UserServiceImpl implements IUserService {
|
||||
return user.getAccount();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void syncUpdateUser(UserVo uv)throws XaskException{
|
||||
|
||||
@@ -43,6 +43,8 @@ xboe.externalinterface.url.system=http://localhost:9091
|
||||
## 新增加的教师的内部调用接口
|
||||
xboe.old.base.url=https://u-pre.boe.com
|
||||
|
||||
xboe.server.userbasic.url=https://u-pre.boe.com/userbasic
|
||||
|
||||
## 用户统计接口的api地址
|
||||
xboe.stat.base.url=http://127.0.0.1:9080
|
||||
|
||||
|
||||
Reference in New Issue
Block a user