mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-12 04:16:51 +08:00
Merge branch 'pre-master'
# Conflicts: # servers/boe-server-all/src/main/java/com/xboe/module/course/service/impl/CourseServiceImpl.java
This commit is contained in:
@@ -8,7 +8,7 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class CourseStudyDto {
|
public class CourseStudyDto {
|
||||||
|
|
||||||
/**id,对于原系统是kid*/
|
/**id,系统中标识的学习记录id,本地就是studyId*/
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
/**es中的id*/
|
/**es中的id*/
|
||||||
@@ -45,4 +45,14 @@ public class CourseStudyDto {
|
|||||||
* 10-报名未审核 20-报名被拒绝 30-报名审核通过-字段新,应管理端需求增加
|
* 10-报名未审核 20-报名被拒绝 30-报名审核通过-字段新,应管理端需求增加
|
||||||
*/
|
*/
|
||||||
private Integer applyStatus;
|
private Integer applyStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应管理端需求,增加上课时间
|
||||||
|
*/
|
||||||
|
private Long attendCourseTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应管理端需求,增加面授地点
|
||||||
|
*/
|
||||||
|
private String courseAddress;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ public class CourseStudyElasticsearchImpl implements ICourseStudySearch{
|
|||||||
builder.field("status").startObject().field("type", "integer").endObject();
|
builder.field("status").startObject().field("type", "integer").endObject();
|
||||||
builder.field("progress").startObject().field("type", "integer").endObject();
|
builder.field("progress").startObject().field("type", "integer").endObject();
|
||||||
builder.field("applyStatus").startObject().field("type", "integer").endObject();
|
builder.field("applyStatus").startObject().field("type", "integer").endObject();
|
||||||
|
builder.field("attendCourseTime").startObject().field("type", "integer").endObject();
|
||||||
|
builder.field("courseAddress").startObject().field("type", "keyword").endObject();
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
||||||
@@ -185,7 +187,7 @@ public class CourseStudyElasticsearchImpl implements ICourseStudySearch{
|
|||||||
BoolQueryBuilder boolQuery= QueryBuilders.boolQuery();
|
BoolQueryBuilder boolQuery= QueryBuilders.boolQuery();
|
||||||
if(StringUtils.isNotBlank(dto.getCourseName())) {
|
if(StringUtils.isNotBlank(dto.getCourseName())) {
|
||||||
String words=QueryParser.escape(dto.getCourseName());
|
String words=QueryParser.escape(dto.getCourseName());
|
||||||
boolQuery.filter(QueryBuilders.wildcardQuery("courseName", "*"+words+"*"));
|
boolQuery.filter(QueryBuilders.wildcardQuery("courseName.keyword", "*"+words+"*"));
|
||||||
}
|
}
|
||||||
if(dto.getCourseType()!=null) {
|
if(dto.getCourseType()!=null) {
|
||||||
if(dto.getCourseType()==10 || dto.getCourseType()==20) {
|
if(dto.getCourseType()==10 || dto.getCourseType()==20) {
|
||||||
|
|||||||
@@ -19,4 +19,13 @@ public interface IScormStudyCallback {
|
|||||||
* @param scoId sco的id
|
* @param scoId sco的id
|
||||||
*/
|
*/
|
||||||
void finishCallback(String lmsId,String courseId,String contentId,String studentId,String studentName,String scormId,String scoId);
|
void finishCallback(String lmsId,String courseId,String contentId,String studentId,String studentName,String scormId,String scoId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 追加学习时长
|
||||||
|
* @param lmsId 初始化时传入的学习lmsId,studyId
|
||||||
|
* @param contentId 初始化时传入的课程内容id
|
||||||
|
* @param studentId 学生id
|
||||||
|
* @param duration 学习时长
|
||||||
|
*/
|
||||||
|
void appendStudyDuration(String lmsId, String contentId, String studentId,Integer duration);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,11 @@
|
|||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.xboe</groupId>
|
||||||
|
<artifactId>xboe-api</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.xboe</groupId>
|
<groupId>com.xboe</groupId>
|
||||||
<artifactId>xboe-module-scorm</artifactId>
|
<artifactId>xboe-module-scorm</artifactId>
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.xboe;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.xboe.api.IUrlSecurityFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对url的过滤处理.
|
||||||
|
* 此服务全部需要
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class UrlSecurityFilterImpl implements IUrlSecurityFilter{
|
||||||
|
|
||||||
|
|
||||||
|
private static Set<String> noLoginUrls=new HashSet<String>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
noLoginUrls.add("/inner/data");
|
||||||
|
noLoginUrls.add("/xboe/account/captcha");
|
||||||
|
noLoginUrls.add("/xboe/account/login");
|
||||||
|
noLoginUrls.add("/xboe/account/boelogin");
|
||||||
|
noLoginUrls.add("/xboe/account/mobile-login");
|
||||||
|
noLoginUrls.add("/xboe/account/logout");
|
||||||
|
noLoginUrls.add("/xboe/system/captcha");
|
||||||
|
noLoginUrls.add("/xboe/system/login");
|
||||||
|
noLoginUrls.add("/xboe/system/logout");
|
||||||
|
noLoginUrls.add("/xboe/sys/user/sync-all");
|
||||||
|
//noLoginUrls.add("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requireLogin(String url) {
|
||||||
|
for(String str : noLoginUrls) {
|
||||||
|
if(url.startsWith(str)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!url.startsWith("/xboe/") && !url.startsWith("/api/")){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -260,6 +260,11 @@ public class CourseFileApi extends ApiBaseController {
|
|||||||
file.setDecoder(m.getVideo().getDecoder());
|
file.setDecoder(m.getVideo().getDecoder());
|
||||||
file.setVideoHeight(m.getVideo().getSize().getHeight());
|
file.setVideoHeight(m.getVideo().getSize().getHeight());
|
||||||
file.setVideoWidth(m.getVideo().getSize().getWidth());
|
file.setVideoWidth(m.getVideo().getSize().getWidth());
|
||||||
|
|
||||||
|
if(StringUtils.isBlank(file.getDecoder()) || !file.getDecoder().equals("h264")) {
|
||||||
|
log.error("编码格式不是h264,不能上传");
|
||||||
|
return error("编码格式不是h264,请先转码再上传","");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("读取视频时长错误");
|
log.error("读取视频时长错误");
|
||||||
|
|||||||
@@ -234,12 +234,28 @@ public class CourseFullTextApi extends ApiBaseController{
|
|||||||
PageList<CourseFullText> coursePageList = fullTextSearch.search(ICourseFullTextSearch.DEFAULT_INDEX_NAME,pager.getStartRow(), pager.getPageSize(),paras);
|
PageList<CourseFullText> coursePageList = fullTextSearch.search(ICourseFullTextSearch.DEFAULT_INDEX_NAME,pager.getStartRow(), pager.getPageSize(),paras);
|
||||||
//提取教师信息
|
//提取教师信息
|
||||||
List<String> ids=new ArrayList<String>();
|
List<String> ids=new ArrayList<String>();
|
||||||
|
List<String> cids=new ArrayList<String>();
|
||||||
for(CourseFullText c :coursePageList.getList()) {
|
for(CourseFullText c :coursePageList.getList()) {
|
||||||
ids.add(c.getId());
|
ids.add(c.getId());
|
||||||
|
if(c.getSource()==2) {
|
||||||
|
cids.add(c.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<Course> clist=null;
|
||||||
|
if(!cids.isEmpty()) {
|
||||||
|
clist=courseService.findStudysScoreByIds(cids);
|
||||||
}
|
}
|
||||||
List<CourseTeacher> teachers = courseService.findTeachersByCourseIds(ids);
|
List<CourseTeacher> teachers = courseService.findTeachersByCourseIds(ids);
|
||||||
//注意对于多个教师的情况,这里只是设置第一个教师
|
//注意对于多个教师的情况,这里只是设置第一个教师
|
||||||
for(CourseFullText c :coursePageList.getList()) {
|
for(CourseFullText c :coursePageList.getList()) {
|
||||||
|
if(clist!=null) {
|
||||||
|
for(Course c2 : clist) {
|
||||||
|
if(c2.getId().equals(c.getId())) {
|
||||||
|
c.setScore(c2.getScore());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for(CourseTeacher ct : teachers) {
|
for(CourseTeacher ct : teachers) {
|
||||||
if(ct.getCourseId().equals(c.getId())) {
|
if(ct.getCourseId().equals(c.getId())) {
|
||||||
c.setTeacher(ct.getTeacherName());
|
c.setTeacher(ct.getTeacherName());
|
||||||
|
|||||||
@@ -50,6 +50,12 @@ public class Course extends BaseEntity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Course(String id,Integer studys,Float score) {
|
||||||
|
this.setId(id);
|
||||||
|
this.studys=studys;
|
||||||
|
this.score=score;
|
||||||
|
}
|
||||||
|
|
||||||
public Course(String id,Integer type,String name,String coverImg, Float score,Integer studys,Integer comments,Integer shares,Integer praises,Integer favorites
|
public Course(String id,Integer type,String name,String coverImg, Float score,Integer studys,Integer comments,Integer shares,Integer praises,Integer favorites
|
||||||
,String forUsers,String value,String summary,LocalDateTime publishTime,Boolean isTop) {
|
,String forUsers,String value,String summary,LocalDateTime publishTime,Boolean isTop) {
|
||||||
this.setId(id);
|
this.setId(id);
|
||||||
@@ -135,6 +141,10 @@ public class Course extends BaseEntity {
|
|||||||
@Column(name = "org_id",length = 20)
|
@Column(name = "org_id",length = 20)
|
||||||
private String orgId;
|
private String orgId;
|
||||||
|
|
||||||
|
/**复制的课程的来源id*/
|
||||||
|
@Column(name = "copy_id",length = 20)
|
||||||
|
private String copyId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 企业ID, 多企业使用
|
* 企业ID, 多企业使用
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class CourseFile extends BaseEntity {
|
|||||||
private Integer duration;
|
private Integer duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编码格式
|
* 编码格式,目前只限 h264
|
||||||
* */
|
* */
|
||||||
@Column(name = "decoder",length = 20)
|
@Column(name = "decoder",length = 20)
|
||||||
private String decoder;
|
private String decoder;
|
||||||
|
|||||||
@@ -130,6 +130,11 @@ public interface ICourseService {
|
|||||||
/**
|
/**
|
||||||
* 复制课程
|
* 复制课程
|
||||||
* @param id
|
* @param id
|
||||||
|
* @param refId
|
||||||
|
* @param refType
|
||||||
|
* @param aid
|
||||||
|
* @param aname
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
String copyCourse(String id,String refId,String refType,String aid,String aname);
|
String copyCourse(String id,String refId,String refType,String aid,String aname);
|
||||||
|
|
||||||
@@ -316,6 +321,13 @@ public interface ICourseService {
|
|||||||
* */
|
* */
|
||||||
List<Course> ids(List<String> ids);
|
List<Course> ids(List<String> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询需要的字段
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Course> findStudysScoreByIds(List<String> ids);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询出三条关联兴趣爱好的数据
|
* 查询出三条关联兴趣爱好的数据
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import java.util.stream.Collectors;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.hibernate.mapping.IdGenerator;
|
||||||
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 org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
@@ -369,10 +370,9 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
filters.add(FieldFilters.eq("enabled",true));
|
filters.add(FieldFilters.eq("enabled",true));
|
||||||
//返回的结果
|
//返回的结果
|
||||||
|
|
||||||
|
|
||||||
QueryBuilder query=QueryBuilder.from(Course.class).addFilters(filters);
|
QueryBuilder query=QueryBuilder.from(Course.class).addFilters(filters);
|
||||||
|
|
||||||
if(dto.getTopOrder()!=null) {
|
if(dto.getTopOrder()!=null){
|
||||||
if(dto.getTopOrder()){
|
if(dto.getTopOrder()){
|
||||||
query.addOrder(OrderCondition.desc("isTop"));
|
query.addOrder(OrderCondition.desc("isTop"));
|
||||||
query.addOrder(OrderCondition.desc("topTime"));
|
query.addOrder(OrderCondition.desc("topTime"));
|
||||||
@@ -1640,6 +1640,7 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
mess="长度超出范围";
|
mess="长度超出范围";
|
||||||
}
|
}
|
||||||
return mess;
|
return mess;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1653,6 +1654,12 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
courseDao.updateFieldById(id, field, value);
|
courseDao.updateFieldById(id, field, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Course> findStudysScoreByIds(List<String> ids) {
|
||||||
|
|
||||||
|
return courseDao.findListByHql("Select new Course(id,studys,score) from Course where id in(?1)",ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,10 @@ import com.xboe.account.entity.Account;
|
|||||||
import com.xboe.account.service.IAccountService;
|
import com.xboe.account.service.IAccountService;
|
||||||
import com.xboe.common.utils.StringUtil;
|
import com.xboe.common.utils.StringUtil;
|
||||||
import com.xboe.core.CurrentUser;
|
import com.xboe.core.CurrentUser;
|
||||||
import com.xboe.core.IAuthorizationToken;
|
|
||||||
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.outside.IOutSideDataService;
|
import com.xboe.data.outside.IOutSideDataService;
|
||||||
import com.xboe.module.teacher.entity.Teacher;
|
|
||||||
import com.xboe.module.teacher.service.ITeacherService;
|
import com.xboe.module.teacher.service.ITeacherService;
|
||||||
import com.xboe.system.organization.entity.Organization;
|
import com.xboe.system.organization.entity.Organization;
|
||||||
import com.xboe.system.organization.service.IOrganizationService;
|
import com.xboe.system.organization.service.IOrganizationService;
|
||||||
@@ -35,9 +33,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@RequestMapping(value = "/xboe/portal")
|
@RequestMapping(value = "/xboe/portal")
|
||||||
public class PortalConsoleApi extends ApiBaseController{
|
public class PortalConsoleApi extends ApiBaseController{
|
||||||
|
|
||||||
@Autowired
|
|
||||||
IAuthorizationToken authorizationToken;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IUserService userService;
|
IUserService userService;
|
||||||
|
|
||||||
@@ -61,7 +56,8 @@ public class PortalConsoleApi extends ApiBaseController{
|
|||||||
public JsonResponse<Map<String,Object>> init() {
|
public JsonResponse<Map<String,Object>> init() {
|
||||||
Map<String,Object> map=new HashMap<String,Object>();
|
Map<String,Object> map=new HashMap<String,Object>();
|
||||||
try {
|
try {
|
||||||
Account account = accountService.get(getCurrent().getAccountId());
|
CurrentUser cuser=getCurrent();
|
||||||
|
Account account = accountService.get(cuser.getAccountId());
|
||||||
if(account==null) {
|
if(account==null) {
|
||||||
log.error("未找到账号id【"+getCurrent().getAccountId()+"】对应的用户");
|
log.error("未找到账号id【"+getCurrent().getAccountId()+"】对应的用户");
|
||||||
return error("账号错误,无此账号");
|
return error("账号错误,无此账号");
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -14,6 +13,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.xboe.common.utils.Sha256Mac;
|
import com.xboe.common.utils.Sha256Mac;
|
||||||
import com.xboe.core.IAuthorizationToken;
|
import com.xboe.core.IAuthorizationToken;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* token 与原boe系统相同的生成解析规则
|
* token 与原boe系统相同的生成解析规则
|
||||||
*
|
*
|
||||||
@@ -37,7 +38,7 @@ public class BoeTokenImpl implements IAuthorizationToken{
|
|||||||
//long iat=System.currentTimeMillis()/1000;
|
//long iat=System.currentTimeMillis()/1000;
|
||||||
long iat=System.currentTimeMillis()/1000;
|
long iat=System.currentTimeMillis()/1000;
|
||||||
payloadMap.put("iat", iat);
|
payloadMap.put("iat", iat);
|
||||||
long exp=iat+(12*60*60);//过期时间,12个小时过期
|
long exp=iat+(2*60*60);//过期时间,2个小时过期
|
||||||
payloadMap.put("exp", exp);
|
payloadMap.put("exp", exp);
|
||||||
payloadMap.put("GivenName", "boeu");
|
payloadMap.put("GivenName", "boeu");
|
||||||
payloadMap.put("permission","");
|
payloadMap.put("permission","");
|
||||||
@@ -97,10 +98,11 @@ public class BoeTokenImpl implements IAuthorizationToken{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// public static void main(String[] args) {
|
// public static void main(String[] args) {
|
||||||
//
|
////
|
||||||
//// Map<String,String> data=new HashMap<String,String>();
|
// Map<String,String> data=new HashMap<String,String>();
|
||||||
//// data.put("userId","DFF192E1-FB7B-11EC-9DDF-005056BD9028");//原系统id
|
// data.put("userId","DFF192E1-FB7B-11EC-9DDF-005056BD9028");//原系统id
|
||||||
//// data.put("name", "测试账号0001");
|
// data.put("uId", "二期新增加的id");
|
||||||
|
// data.put("name", "测试账号0001");
|
||||||
////
|
////
|
||||||
//// try {
|
//// try {
|
||||||
////
|
////
|
||||||
@@ -110,18 +112,19 @@ public class BoeTokenImpl implements IAuthorizationToken{
|
|||||||
//// }catch(Exception e) {
|
//// }catch(Exception e) {
|
||||||
//// e.printStackTrace();
|
//// e.printStackTrace();
|
||||||
//// }
|
//// }
|
||||||
//
|
////
|
||||||
// try {
|
// try {
|
||||||
//
|
//
|
||||||
// BoeTokenImpl impl=new BoeTokenImpl();
|
// BoeTokenImpl impl=new BoeTokenImpl();
|
||||||
//// String token=impl.createToken(data);
|
// String token=impl.createToken(data);
|
||||||
//// System.out.println(token);
|
// System.out.println(token);
|
||||||
////
|
////
|
||||||
//// Map<String,String> tokenData = impl.readToken(token);
|
//// Map<String,String> tokenData = impl.readToken(token);
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// String token="eyJ0eXBlIjoidG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJ1SWQiOiI5NTI5NDg2MjY0OTc3MjQ0MTEiLCJ1c2VyTm8iOiIxMjM0NTYwMSIsImlzcyI6Imh0dHA6Ly91LmJvZS5jb20iLCJuYW1lIjoi5Luj5rW35YW0IiwiR2l2ZW5OYW1lIjoiYm9ldSIsImRlcGFydElkIjoiOTg0MTQ3NTY2NTIxNjY3NTg0IiwicGVybWlzc2lvbiI6IiIsImV4cCI6MTY3NTc4MTQwMSwiaWF0IjoxNjc1NzM4MjAxLCJhaWQiOiI5NTI5NDg2MjY0OTc3MjQ0MTEiLCJ1c2VySWQiOiIwMTU1NTNERC00NDVFLTY5RDQtMzUxRi1ERDlBMUE1NjQyMEUifQ==.d1d8d3e53ece04a8a863d5f0a3c227cea559cc4cfcbc9010a1125f7a11d6e9a0";
|
// //String token="eyJhbGciOiJIUzI1NiIsInR5cGUiOiJ0b2tlbiJ9.eyJpc3MiOiJodHRwOi8vdS5ib2UuY29tIiwiR2l2ZW5OYW1lIjoiYm9ldSIsInVJZCI6OTY1MzQxOTk5NjQzMjM0MzA0LCJ1c2VySWQiOiIwMTU1NTNERC00NDVFLTY5RDQtMzUxRi1ERDlBMUE1NjQyMEUiLCJleHAiOjE2NzkzNjcwOTc1NDF9.1758ccba02926f5e790743857e11f0fc89238cb9c30024530b5d4b3ff8387ad2";
|
||||||
// //String token = "eyJhbGciOiJIUzI1NiIsInR5cGUiOiJ0b2tlbiJ9.eyJpc3MiOiJodHRwOi8vdS5ib2UuY29tIiwiR2l2ZW5OYW1lIjoiYm9ldSIsInVJZCI6OTY1MzQyMDI3NDk3NjA3MTY4LCJ1c2VySWQiOiI2QjA0OUZBRi1DMzE0LTdDQ0YtMEQyOC0wRDIzRjRDNDI1MzEiLCJleHAiOjE2NzU3NTU4ODYzMzV9.c65d86ccc5feb1c820490d94196f5509b6bb97dce748bc590160c6d8489bde6a";
|
// //String token = "eyJhbGciOiJIUzI1NiIsInR5cGUiOiJ0b2tlbiJ9.eyJpc3MiOiJodHRwOi8vdS5ib2UuY29tIiwiR2l2ZW5OYW1lIjoiYm9ldSIsInVJZCI6OTY1MzQyMDI3NDk3NjA3MTY4LCJ1c2VySWQiOiI2QjA0OUZBRi1DMzE0LTdDQ0YtMEQyOC0wRDIzRjRDNDI1MzEiLCJleHAiOjE2NzU3NTU4ODYzMzV9.c65d86ccc5feb1c820490d94196f5509b6bb97dce748bc590160c6d8489bde6a";
|
||||||
|
// //Map<String,String> map = impl.readToken(token);
|
||||||
// String[] tokens = token.split("\\.");
|
// String[] tokens = token.split("\\.");
|
||||||
// System.out.println(tokens.length);
|
// System.out.println(tokens.length);
|
||||||
// String header = new String(Base64.decodeBase64(tokens[0]));
|
// String header = new String(Base64.decodeBase64(tokens[0]));
|
||||||
@@ -136,12 +139,13 @@ public class BoeTokenImpl implements IAuthorizationToken{
|
|||||||
// JsonNode json = om.readTree(payload);
|
// JsonNode json = om.readTree(payload);
|
||||||
// System.out.println(json);
|
// System.out.println(json);
|
||||||
// String userId=json.get("userId").asText();
|
// String userId=json.get("userId").asText();
|
||||||
|
// String uId=json.get("uId").asText();
|
||||||
// long exp=json.get("exp").asLong();
|
// long exp=json.get("exp").asLong();
|
||||||
// System.out.println("userId="+userId+",exp="+exp);
|
// System.out.println("userId="+userId+",uId="+uId+",exp="+exp);
|
||||||
// }catch(Exception e) {
|
// }catch(Exception e) {
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
//
|
////
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.xboe.school.impl;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
||||||
|
|
||||||
import com.xboe.core.CurrentUser;
|
|
||||||
import com.xboe.core.IGetCurrentUser;
|
|
||||||
import com.xboe.core.SysConstant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前用户的信息接口的实现
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class GetCurrentUserImpl implements IGetCurrentUser{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CurrentUser get() {
|
|
||||||
// 如果接口不是从action进入就会没有这些信息
|
|
||||||
if(RequestContextHolder.getRequestAttributes() == null){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
HttpServletRequest req = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
||||||
CurrentUser info=(CurrentUser)req.getAttribute(SysConstant.KEY_CURRENT_LOGIN_USER);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
package com.xboe.school.impl;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.auth0.jwt.JWT;
|
|
||||||
import com.auth0.jwt.JWTCreator.Builder;
|
|
||||||
import com.auth0.jwt.JWTVerifier;
|
|
||||||
import com.auth0.jwt.algorithms.Algorithm;
|
|
||||||
import com.auth0.jwt.interfaces.Claim;
|
|
||||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
|
||||||
import com.xboe.core.IAuthorizationToken;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 认证token的jwt实现,生成和解析jwt
|
|
||||||
*/
|
|
||||||
//@Component
|
|
||||||
public class JwtTokenImpl implements IAuthorizationToken {
|
|
||||||
|
|
||||||
|
|
||||||
private static String jwtIssuer = "xboe";
|
|
||||||
|
|
||||||
//private static String SignKey="$J#F@f3@7G!D";
|
|
||||||
private static String SignKey = "JDF_BOE";//采用与原系统保持一致
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String createToken(Map<String, String> params) throws Exception {
|
|
||||||
|
|
||||||
HashMap<String, Object> map = new HashMap<>(); //自定义header
|
|
||||||
|
|
||||||
Calendar insCalendar = Calendar.getInstance();
|
|
||||||
insCalendar.add(Calendar.SECOND, 12 * 60 * 60); //存储时间为800s// 指令令牌过期时间
|
|
||||||
Builder signBuilder = JWT.create().withHeader(map).withExpiresAt(insCalendar.getTime());
|
|
||||||
|
|
||||||
signBuilder.withIssuer(jwtIssuer).withSubject("subject");//谁创建了令牌并签署了它
|
|
||||||
|
|
||||||
for (String key : params.keySet()) {
|
|
||||||
signBuilder.withClaim(key, params.get(key));
|
|
||||||
}
|
|
||||||
String sign = signBuilder.sign(Algorithm.HMAC256(SignKey));// 签名
|
|
||||||
//System.out.println(sign);
|
|
||||||
return sign;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, String> readToken(String token) throws Exception {
|
|
||||||
//System.out.println(token);
|
|
||||||
JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(SignKey)).build();
|
|
||||||
DecodedJWT verify = jwtVerifier.verify(token);
|
|
||||||
|
|
||||||
//System.out.println("token过期时间:"+verify.getExpiresAt());
|
|
||||||
// 时间过期返回null
|
|
||||||
Calendar insCalendar = Calendar.getInstance();
|
|
||||||
if (insCalendar.getTime().before(verify.getExpiresAt())) {
|
|
||||||
Map<String, Claim> map = verify.getClaims();
|
|
||||||
Map<String, String> result = new HashMap<String, String>();
|
|
||||||
for (String key : map.keySet()) {
|
|
||||||
String value = map.get(key).asString();
|
|
||||||
result.put(key, value);
|
|
||||||
//System.out.print(key+"="+value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -245,18 +245,22 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
if(StringUtils.isBlank(sci.getContentId())){
|
if(StringUtils.isBlank(sci.getContentId())){
|
||||||
return error("参数错误:内容");
|
return error("参数错误:内容");
|
||||||
}
|
}
|
||||||
LocalDateTime now=LocalDateTime.now();
|
// LocalDateTime now=LocalDateTime.now();
|
||||||
CurrentUser cuser=getCurrent();
|
CurrentUser cuser=getCurrent();
|
||||||
|
|
||||||
StudyTime st=new StudyTime();
|
if(sci.getDuration()==null) {
|
||||||
st.setContentId(sci.getContentId());
|
sci.setDuration(1);//增加5秒的学习时长,因方法是每5秒调用一次的
|
||||||
st.setCourseId(sci.getCourseId());
|
}
|
||||||
st.setDuration(5);//增加5秒的学习时长
|
|
||||||
st.setEndTime(now);
|
// StudyTime st=new StudyTime();
|
||||||
st.setStartTime(now);
|
// st.setContentId(sci.getContentId());
|
||||||
st.setStudentId(cuser.getAccountId());
|
// st.setCourseId(sci.getCourseId());
|
||||||
st.setStudentName(cuser.getName());
|
// st.setDuration(5);//增加5秒的学习时长,因方法是每5秒调用一次的
|
||||||
st.setStudyId(sci.getStudyId());
|
// st.setEndTime(now);
|
||||||
|
// st.setStartTime(now);
|
||||||
|
// st.setStudentId(cuser.getAccountId());
|
||||||
|
// st.setStudentName(cuser.getName());
|
||||||
|
// st.setStudyId(sci.getStudyId());
|
||||||
|
|
||||||
//检查是否已存在
|
//检查是否已存在
|
||||||
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
||||||
@@ -266,7 +270,7 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),sci.getProgress());
|
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),sci.getProgress());
|
||||||
}
|
}
|
||||||
//追加学习时长
|
//追加学习时长
|
||||||
studyService.appendStudyDuration(st);
|
studyService.appendStudyDuration(sci.getStudyId(),item.getId(),sci.getContentId(),sci.getDuration());
|
||||||
return success(item.getId());
|
return success(item.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +287,7 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
|
|
||||||
studyService.saveStudyInfo(sci);
|
studyService.saveStudyInfo(sci);
|
||||||
//学习记录成功后处理
|
//学习记录成功后处理
|
||||||
studyService.appendStudyDuration(st);
|
studyService.appendStudyDuration(sci.getStudyId(),sci.getStudyItemId(),sci.getContentId(),sci.getDuration());
|
||||||
return success(sci.getStudyItemId());
|
return success(sci.getStudyItemId());
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
log.error("记录学习情况错误",e);
|
log.error("记录学习情况错误",e);
|
||||||
@@ -292,6 +296,29 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//更新时长
|
||||||
|
/**追加学习时长*/
|
||||||
|
@PostMapping("/study-append-duration")
|
||||||
|
public JsonResponse<Boolean> appendStudyDuration(String studyId,String studyItemId,String contentId,Integer duration){
|
||||||
|
if(StringUtils.isBlank(studyId)){
|
||||||
|
return error("参数错误");
|
||||||
|
}
|
||||||
|
if(StringUtils.isBlank(studyItemId) && StringUtils.isBlank(contentId)){
|
||||||
|
return error("未指定学习内容");
|
||||||
|
}
|
||||||
|
if(duration==null){
|
||||||
|
return error("无学习时长");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
studyService.appendStudyDuration(studyId, studyItemId,contentId,duration);
|
||||||
|
return success(true);
|
||||||
|
}catch(Exception e) {
|
||||||
|
log.error("追加学习时长错误",e);
|
||||||
|
return error("追加学习时长失败",e.getMessage(),false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 学习完成一项课程内容,针对于所有课程内容,不只是音视频,还有scorm及其它的内容
|
* 学习完成一项课程内容,针对于所有课程内容,不只是音视频,还有scorm及其它的内容
|
||||||
* @param sci
|
* @param sci
|
||||||
@@ -308,36 +335,23 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
}
|
}
|
||||||
// LocalDateTime now=LocalDateTime.now();
|
// LocalDateTime now=LocalDateTime.now();
|
||||||
CurrentUser cuser=getCurrent();
|
CurrentUser cuser=getCurrent();
|
||||||
|
|
||||||
//下面的学习时长应该去掉了,不需要
|
|
||||||
// StudyTime st=new StudyTime();
|
|
||||||
// st.setContentId(sci.getContentId());
|
|
||||||
// st.setCourseId(sci.getCourseId());
|
|
||||||
// st.setDuration(5);//增加5秒的学习时长
|
|
||||||
// st.setEndTime(now);
|
|
||||||
// st.setStartTime(now);
|
|
||||||
// st.setStudentId(cuser.getAccountId());
|
|
||||||
// st.setStudentName(cuser.getName());
|
|
||||||
// st.setStudyId(sci.getStudyId());
|
|
||||||
|
|
||||||
//检查是否已存在
|
//检查是否已存在
|
||||||
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
||||||
if(item!=null) {
|
if(item!=null) {
|
||||||
//如果记录存在,但是进度不到100,未完成情况,就更新进度,一期不会有这种情况
|
//如果记录存在,但是进度不到100,未完成情况,就更新进度,一期不会有这种情况
|
||||||
if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
|
if(item.getProgress()<100) {
|
||||||
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),sci.getProgress());
|
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),100);
|
||||||
}
|
}
|
||||||
//追加学习时长
|
//追加学习时长,学习时长是单独的记录,这里不再进行记录
|
||||||
//studyService.appendStudyDuration(st);
|
//studyService.appendStudyDuration(st);
|
||||||
return success(item.getId());
|
return success(item.getId());
|
||||||
}
|
}
|
||||||
|
//如果不存在,就创建,这种情况应该不存在
|
||||||
try {
|
try {
|
||||||
sci.setAid(cuser.getAccountId());
|
sci.setAid(cuser.getAccountId());
|
||||||
sci.setAname(cuser.getName());
|
sci.setAname(cuser.getName());
|
||||||
|
sci.setProgress(100);
|
||||||
studyService.saveStudyInfo(sci);
|
studyService.saveStudyInfo(sci);
|
||||||
//学习记录成功后处理
|
|
||||||
//studyService.appendStudyDuration(st);
|
|
||||||
return success(sci.getStudyItemId());
|
return success(sci.getStudyItemId());
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
log.error("记录学习课程内容完成错误",e);
|
log.error("记录学习课程内容完成错误",e);
|
||||||
@@ -437,7 +451,7 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/study-video-time")
|
@PostMapping("/study-video-time")
|
||||||
public JsonResponse<Boolean> study(String itemId,Integer videoTime){
|
public JsonResponse<Boolean> study(String studyId,String itemId,Integer videoTime){
|
||||||
|
|
||||||
if(StringUtils.isBlank(itemId)){
|
if(StringUtils.isBlank(itemId)){
|
||||||
return error("参数错误");
|
return error("参数错误");
|
||||||
@@ -485,7 +499,8 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
try {
|
try {
|
||||||
//此处需要优化处理,
|
//此处需要优化处理,
|
||||||
//不能直接记录追加学习时间。以后增加到队列中,后台服务定时从队列中读取, 更新到系统中
|
//不能直接记录追加学习时间。以后增加到队列中,后台服务定时从队列中读取, 更新到系统中
|
||||||
studyService.appendStudyDuration(studyTime);
|
//studyService.appendStudyDuration(studyTime);
|
||||||
|
studyService.appendStudyDuration(studyTime.getStudyId(),null,studyTime.getContentId(),studyTime.getDuration());
|
||||||
return success(studyTime.getId());
|
return success(studyTime.getId());
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
log.error("记录学习时长错误",e);
|
log.error("记录学习时长错误",e);
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ package com.xboe.school.study.api;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
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.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -53,6 +55,20 @@ public class StudyCourseESApi extends ApiBaseController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/list-by-ids",method = {RequestMethod.POST})
|
||||||
|
public JsonResponse<List<StudyCourse>> search(@RequestBody List<String> ids){
|
||||||
|
if(ids.isEmpty()) {
|
||||||
|
return badRequest("无需ids");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
List<StudyCourse> rs=service.findByIds(ids);
|
||||||
|
return success(rs);
|
||||||
|
}catch(Exception e) {
|
||||||
|
log.error("根据id集合查询报名学习错误",e);
|
||||||
|
return error("查询失败",e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/index-create")
|
@GetMapping("/index-create")
|
||||||
public JsonResponse<Boolean> createIndex(){
|
public JsonResponse<Boolean> createIndex(){
|
||||||
if(search==null) {
|
if(search==null) {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
* @param total
|
* @param total
|
||||||
*/
|
*/
|
||||||
public void finishCheck(String studyId,String courseId,Integer total){
|
public void finishCheck(String studyId,String courseId,Integer total){
|
||||||
|
LocalDateTime now=LocalDateTime.now();
|
||||||
//已完成的内容
|
//已完成的内容
|
||||||
int n=scItemDao.count(FieldFilters.eq("studyId",studyId),FieldFilters.eq("status",StudyCourseItem.STATUS_FINISH));
|
int n=scItemDao.count(FieldFilters.eq("studyId",studyId),FieldFilters.eq("status",StudyCourseItem.STATUS_FINISH));
|
||||||
if(total==null) {
|
if(total==null) {
|
||||||
@@ -40,7 +41,8 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
//自主报名的课程,代表学习完成
|
//自主报名的课程,代表学习完成
|
||||||
super.updateMultiFieldById(studyId,
|
super.updateMultiFieldById(studyId,
|
||||||
UpdateBuilder.create("progress",100f),
|
UpdateBuilder.create("progress",100f),
|
||||||
UpdateBuilder.create("lastTime",LocalDateTime.now()),
|
UpdateBuilder.create("lastTime",now),
|
||||||
|
UpdateBuilder.create("finishTime",now),
|
||||||
UpdateBuilder.create("status",StudyCourse.STATUS_FINISH));
|
UpdateBuilder.create("status",StudyCourse.STATUS_FINISH));
|
||||||
}else {
|
}else {
|
||||||
super.updateMultiFieldById(studyId,
|
super.updateMultiFieldById(studyId,
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ public class StudyContentDto {
|
|||||||
/**内容的总数量*/
|
/**内容的总数量*/
|
||||||
private Integer contentTotal;
|
private Integer contentTotal;
|
||||||
|
|
||||||
|
/**学习时长*/
|
||||||
|
private Integer duration;
|
||||||
|
|
||||||
private String aid;
|
private String aid;
|
||||||
|
|
||||||
private String aname;
|
private String aname;
|
||||||
|
|||||||
@@ -80,6 +80,13 @@ public interface IStudyCourseService {
|
|||||||
* */
|
* */
|
||||||
List<StudyCourse> ids(StudyCourseQuery studyCourseQuery);
|
List<StudyCourse> ids(StudyCourseQuery studyCourseQuery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配合ES中二次查询显示一些信息
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<StudyCourse> findByIds(List<String> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询课程内容学习记录
|
* 查询课程内容学习记录
|
||||||
* */
|
* */
|
||||||
|
|||||||
@@ -62,11 +62,21 @@ public interface IStudyService {
|
|||||||
void finishVideoStudyItem(String itemId,String studyId,String courseId,Integer cnum);
|
void finishVideoStudyItem(String itemId,String studyId,String courseId,Integer cnum);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 追加学习持续时长
|
* 追加学习持续时长,此处理是一期的,有追加记录,二期后追加记录在stat服务中,这里不需要再记录了,所以不建议使用此方法
|
||||||
* @param st
|
* @param st
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
void appendStudyDuration(StudyTime st);
|
void appendStudyDuration(StudyTime st);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 追加学习时长,通用,无追加记录
|
||||||
|
* @param studyId 学习id
|
||||||
|
* @param studyItemId 学习内容id
|
||||||
|
* @param courseContentId 课程的内容id
|
||||||
|
* @param duration 学习时长
|
||||||
|
*/
|
||||||
|
void appendStudyDuration(String studyId,String studyItemId,String courseContentId, int duration);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据学习id,得到章节的学习记录情况
|
* 根据学习id,得到章节的学习记录情况
|
||||||
* @param studyId
|
* @param studyId
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public class StudyAssessServiceImpl implements IStudyAssessService{
|
|||||||
sci.setCourseId(assess.getCourseId());
|
sci.setCourseId(assess.getCourseId());
|
||||||
//sci.setCsectionId(homework.getCsectionId());
|
//sci.setCsectionId(homework.getCsectionId());
|
||||||
sci.setProgress(100);//直接设置为学习完成
|
sci.setProgress(100);//直接设置为学习完成
|
||||||
|
sci.setStatus(StudyCourseItem.STATUS_FINISH);
|
||||||
sci.setStartTime(ldt);
|
sci.setStartTime(ldt);
|
||||||
sci.setAid(assess.getStudentId());
|
sci.setAid(assess.getStudentId());
|
||||||
sci.setAname(assess.getStudentName());
|
sci.setAname(assess.getStudentName());
|
||||||
|
|||||||
@@ -704,4 +704,9 @@ public class StudyCourseServiceImpl implements IStudyCourseService{
|
|||||||
return rslist;
|
return rslist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<StudyCourse> findByIds(List<String> ids) {
|
||||||
|
return studyCourseDao.findList(FieldFilters.in("id", ids));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public class StudyExamServiceImpl implements IStudyExamService{
|
|||||||
sci.setCourseId(exam.getCourseId());
|
sci.setCourseId(exam.getCourseId());
|
||||||
//sci.setCsectionId(homework.getCsectionId());
|
//sci.setCsectionId(homework.getCsectionId());
|
||||||
sci.setProgress(100);//直接设置为学习完成
|
sci.setProgress(100);//直接设置为学习完成
|
||||||
|
sci.setStatus(StudyCourseItem.STATUS_FINISH);//状态直接更新为已完成
|
||||||
sci.setStartTime(ldt);
|
sci.setStartTime(ldt);
|
||||||
sci.setAid(exam.getStudentId());
|
sci.setAid(exam.getStudentId());
|
||||||
sci.setAname(exam.getStudentName());
|
sci.setAname(exam.getStudentName());
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
|
|||||||
sci.setCourseId(homework.getCourseId());
|
sci.setCourseId(homework.getCourseId());
|
||||||
//sci.setCsectionId(homework.getCsectionId());
|
//sci.setCsectionId(homework.getCsectionId());
|
||||||
sci.setProgress(100);//直接设置为学习完成
|
sci.setProgress(100);//直接设置为学习完成
|
||||||
|
sci.setStatus(9);//状态直接更新为已完成
|
||||||
sci.setStartTime(ldt);
|
sci.setStartTime(ldt);
|
||||||
sci.setAid(homework.getStudentId());
|
sci.setAid(homework.getStudentId());
|
||||||
sci.setAname(homework.getStudentName());
|
sci.setAname(homework.getStudentName());
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
sci.setStudyId(dto.getStudyId());
|
sci.setStudyId(dto.getStudyId());
|
||||||
sci.setContentId(dto.getContentId());
|
sci.setContentId(dto.getContentId());
|
||||||
sci.setContentName(dto.getContentName());
|
sci.setContentName(dto.getContentName());
|
||||||
|
sci.setStudyDuration(0);
|
||||||
sci.setCourseId(dto.getCourseId());
|
sci.setCourseId(dto.getCourseId());
|
||||||
sci.setCsectionId(dto.getCsectionId());
|
sci.setCsectionId(dto.getCsectionId());
|
||||||
}
|
}
|
||||||
@@ -80,6 +81,7 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
sci.setProgress(1);
|
sci.setProgress(1);
|
||||||
sci.setStatus(StudyCourseItem.STATUS_STUDYING);
|
sci.setStatus(StudyCourseItem.STATUS_STUDYING);
|
||||||
}else if(dto.getProgress().intValue()==100) {
|
}else if(dto.getProgress().intValue()==100) {
|
||||||
|
sci.setFinishTime(ldt);
|
||||||
sci.setStatus(StudyCourseItem.STATUS_FINISH);
|
sci.setStatus(StudyCourseItem.STATUS_FINISH);
|
||||||
sci.setProgress(100);
|
sci.setProgress(100);
|
||||||
}else {
|
}else {
|
||||||
@@ -87,7 +89,6 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
sci.setProgress(dto.getProgress());
|
sci.setProgress(dto.getProgress());
|
||||||
}
|
}
|
||||||
//sci.setProgress(100);//直接设置为学习完成
|
//sci.setProgress(100);//直接设置为学习完成
|
||||||
sci.setFinishTime(ldt);
|
|
||||||
sci.setLastTime(ldt);
|
sci.setLastTime(ldt);
|
||||||
scItemDao.saveOrUpdate(sci);
|
scItemDao.saveOrUpdate(sci);
|
||||||
|
|
||||||
@@ -97,6 +98,41 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void appendStudyDuration(String studyId,String studyItemId,String courseContentId, int duration) {
|
||||||
|
|
||||||
|
//增加内容的学习时长
|
||||||
|
if(StringUtils.isNotBlank(studyItemId)) {
|
||||||
|
//直接根据id更新
|
||||||
|
// String hql="Update StudyCourseItem set studyDuration=studyDuration+"+duration+",status=(case when status<2 then 2 else status end) where id=?1";
|
||||||
|
// scItemDao.update(hql,studyItemId);
|
||||||
|
String sql="Update boe_study_course_item set study_duration=study_duration+"+duration+",status=(case when status<2 then 2 else status end) where id=?1";
|
||||||
|
scItemDao.sqlUpdate(sql,studyItemId);
|
||||||
|
//scItemDao.updateMultiFieldById(studyItemId, UpdateBuilder.create("studyDuration", "studyDuration+"+duration,FieldUpdateType.EXPRESSION));
|
||||||
|
|
||||||
|
}else {
|
||||||
|
//根据学习id和课程内容id更新
|
||||||
|
// scItemDao.update(UpdateBuilder.from(StudyCourseItem.class)
|
||||||
|
// .addUpdateField("studyDuration", "studyDuration+"+duration,FieldUpdateType.EXPRESSION)
|
||||||
|
// .addFilter(FieldFilters.eq("studyId", studyId))
|
||||||
|
// .addFilter(FieldFilters.eq("contentId", courseContentId))
|
||||||
|
// .builder());
|
||||||
|
//
|
||||||
|
// String hql="Update StudyCourseItem set studyDuration=studyDuration+"+duration+",status=(case when status<2 then 2 else status end) where studyId=?1 and contentId=?2";
|
||||||
|
// scItemDao.update(hql,studyId,courseContentId);
|
||||||
|
String sql="Update boe_study_course_item set study_duration=study_duration+"+duration+",status=(case when status<2 then 2 else status end) where study_id=?1 and content_id=?2";
|
||||||
|
scItemDao.sqlUpdate(sql,studyId,courseContentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//追加课程的学习时长
|
||||||
|
//scDao.updateMultiFieldById(studyId, UpdateBuilder.create("totalDuration", "totalDuration+"+duration,FieldUpdateType.EXPRESSION));
|
||||||
|
|
||||||
|
String sql="Update boe_study_course set total_duration=total_duration+"+duration+",status=(case when status<2 then 2 else status end),progress=(case when progress=0 then 1 else progress end) where id=?1";
|
||||||
|
scDao.sqlUpdate(sql,studyId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void appendStudyDuration(StudyTime st) {
|
public void appendStudyDuration(StudyTime st) {
|
||||||
@@ -158,12 +194,22 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress) {
|
public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress) {
|
||||||
int status=StudyCourseItem.STATUS_STUDYING;
|
int status=StudyCourseItem.STATUS_STUDYING;
|
||||||
|
LocalDateTime now=LocalDateTime.now();
|
||||||
if(progress.intValue()==100) {
|
if(progress.intValue()==100) {
|
||||||
status=StudyCourseItem.STATUS_FINISH;
|
status=StudyCourseItem.STATUS_FINISH;
|
||||||
}
|
scItemDao.updateMultiFieldById(studyContentId,
|
||||||
scItemDao.updateMultiFieldById(studyContentId,UpdateBuilder.create("progress",progress),UpdateBuilder.create("status",status));
|
UpdateBuilder.create("progress",progress),
|
||||||
|
UpdateBuilder.create("lastTime",now),
|
||||||
|
UpdateBuilder.create("finishTime",now),
|
||||||
|
UpdateBuilder.create("status",status));
|
||||||
//检查是否全部学习完成
|
//检查是否全部学习完成
|
||||||
scDao.finishCheck(studyId,courseId,total);
|
scDao.finishCheck(studyId,courseId,total);
|
||||||
|
}else {
|
||||||
|
scItemDao.updateMultiFieldById(studyContentId,
|
||||||
|
UpdateBuilder.create("progress",progress),
|
||||||
|
UpdateBuilder.create("lastTime",now),
|
||||||
|
UpdateBuilder.create("status",status));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +276,6 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//以下是针对于视频课件的处理
|
//以下是针对于视频课件的处理
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void saveVideoStudyItem(StudyCourseItem sci) {
|
public void saveVideoStudyItem(StudyCourseItem sci) {
|
||||||
@@ -239,6 +284,9 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
if(sci.getStatus()==null) {
|
if(sci.getStatus()==null) {
|
||||||
sci.setStatus(StudyCourseItem.STATUS_STUDYING);
|
sci.setStatus(StudyCourseItem.STATUS_STUDYING);
|
||||||
}
|
}
|
||||||
|
if(sci.getStudyDuration()==null) {
|
||||||
|
sci.setStudyDuration(0);
|
||||||
|
}
|
||||||
scItemDao.save(sci);
|
scItemDao.save(sci);
|
||||||
//更新课程学习的进度
|
//更新课程学习的进度
|
||||||
scDao.updateProgress(sci.getStudyId(),sci.getProgress().floatValue());
|
scDao.updateProgress(sci.getStudyId(),sci.getProgress().floatValue());
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ public class StudySignupServiceImpl implements IStudySignupService{
|
|||||||
sc.setCourseId(signup.getCourseId());
|
sc.setCourseId(signup.getCourseId());
|
||||||
sc.setCourseName(signup.getCourseName());
|
sc.setCourseName(signup.getCourseName());
|
||||||
sc.setCourseType(signup.getCourseType());
|
sc.setCourseType(signup.getCourseType());
|
||||||
|
sc.setStartTime(now);
|
||||||
sc.setFinishTime(null);
|
sc.setFinishTime(null);
|
||||||
sc.setLastScore(0f);
|
sc.setLastScore(0f);
|
||||||
sc.setProgress(0f);
|
sc.setProgress(0f);
|
||||||
@@ -98,6 +99,12 @@ public class StudySignupServiceImpl implements IStudySignupService{
|
|||||||
dto.setCourseType(sc.getCourseType());
|
dto.setCourseType(sc.getCourseType());
|
||||||
dto.setProgress(sc.getProgress()==null? 0:sc.getProgress().intValue());
|
dto.setProgress(sc.getProgress()==null? 0:sc.getProgress().intValue());
|
||||||
dto.setSource(2);//固定值,新系统
|
dto.setSource(2);//固定值,新系统
|
||||||
|
//下面模拟添加线下课程报名,用于本地测试
|
||||||
|
// dto.setCourseType(30);
|
||||||
|
// dto.setSource(3);//来源在线课
|
||||||
|
// dto.setApplyStatus(50);
|
||||||
|
// dto.setCourseAddress("这里是上课地址");
|
||||||
|
// dto.setAttendCourseTime(LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")));
|
||||||
//如果开始时间没有,就使用添加时间
|
//如果开始时间没有,就使用添加时间
|
||||||
if(sc.getStartTime()!=null) {
|
if(sc.getStartTime()!=null) {
|
||||||
dto.setStartTime(sc.getStartTime().toEpochSecond(ZoneOffset.of("+8")));
|
dto.setStartTime(sc.getStartTime().toEpochSecond(ZoneOffset.of("+8")));
|
||||||
|
|||||||
@@ -1,168 +0,0 @@
|
|||||||
package com.xboe.system.filter;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.xboe.core.CurrentUser;
|
|
||||||
import com.xboe.core.JsonResponse;
|
|
||||||
import com.xboe.core.api.TokenProxy;
|
|
||||||
import com.xboe.standard.BaseConstant;
|
|
||||||
import com.xboe.system.user.entity.User;
|
|
||||||
import com.xboe.system.user.service.IUserService;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.core.annotation.Order;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.filter.OncePerRequestFilter;
|
|
||||||
|
|
||||||
import javax.servlet.FilterChain;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 认证过滤器
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@Order(100)
|
|
||||||
public class AuthenticationFilter extends OncePerRequestFilter {
|
|
||||||
|
|
||||||
// private static String urls="/xboe";
|
|
||||||
|
|
||||||
// @Autowired(required = false)
|
|
||||||
// ICurrentUserStorage storage;
|
|
||||||
//
|
|
||||||
// @Autowired(required = false)
|
|
||||||
// private IApiUrlSecurityFilter urlFilters;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
IUserService userService;
|
|
||||||
|
|
||||||
// @Autowired
|
|
||||||
// IAuthorizationToken authorizationToken;
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void destroy() {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
private void error(HttpServletResponse response,int code,String message) throws IOException {
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
JsonResponse<String> rr = new JsonResponse<String>();
|
|
||||||
rr.setStatus(code);
|
|
||||||
rr.setMessage(message);
|
|
||||||
String json = mapper.writeValueAsString(rr);
|
|
||||||
response.setCharacterEncoding("UTF-8");
|
|
||||||
response.setContentType("application/json; charset=utf-8");
|
|
||||||
response.getWriter().write(json);
|
|
||||||
response.flushBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)throws ServletException, IOException {
|
|
||||||
String url = request.getServletPath();
|
|
||||||
//当前先写固定的url判断
|
|
||||||
//以下是针对于url规划的判断,这里简写
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
if(!url.startsWith("/xboe/") && !url.startsWith("/api/")){
|
|
||||||
filterChain.doFilter(request, response);
|
|
||||||
}else {
|
|
||||||
String token = TokenProxy.getToken(request);
|
|
||||||
//System.out.println("token="+token);
|
|
||||||
if(StringUtils.isBlank(token)){
|
|
||||||
error(response,401,"您还未登录,请重新登录");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//检查token的格式
|
|
||||||
|
|
||||||
Map<String, String> tokenData;
|
|
||||||
try {
|
|
||||||
//System.out.println("token");
|
|
||||||
//System.out.println(token);
|
|
||||||
tokenData = TokenProxy.instance().readToken(token);
|
|
||||||
if(tokenData==null) {
|
|
||||||
error(response,401,"您还未登录或登录已超时,请重新登录");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CurrentUser cuser=convertByMap(tokenData);
|
|
||||||
|
|
||||||
//先从tokenData中读取,如果没有再到存储中读取,如果都没有,就返回未登录的错误
|
|
||||||
//当前没有在本地做存储,所以这里不再做处理
|
|
||||||
// if(cuser==null) {
|
|
||||||
// if(storage!=null) {
|
|
||||||
// cuser=storage.read(request,token);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
if(cuser==null) {
|
|
||||||
// 判断token中获取的值是否当前系统的,不是则告诉前端来获取
|
|
||||||
if(tokenData.containsKey("uId")) {
|
|
||||||
error(response,302,"token 错误");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
error(response,401,"请重新登录");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// String levelStr=tokenData.get("alevel");
|
|
||||||
// if(levelStr!=null) {
|
|
||||||
// request.setAttribute(XaskConstant.KEY_CURRENT_API_LEVEL,Integer.valueOf(levelStr));
|
|
||||||
// }else {
|
|
||||||
// request.setAttribute(XaskConstant.KEY_CURRENT_API_LEVEL,0);
|
|
||||||
// }
|
|
||||||
request.setAttribute(BaseConstant.KEY_CURRENT_LOGIN_USER,cuser);
|
|
||||||
|
|
||||||
filterChain.doFilter(request, response);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
error(response,401,"请重新登录");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private CurrentUser convertByMap(Map<String, String> data) {
|
|
||||||
if(!data.containsKey("aid")) {
|
|
||||||
//修改为新的接口,通过uId获取
|
|
||||||
if(data.containsKey("uId")) {
|
|
||||||
User user = userService.get(data.get("uId"));
|
|
||||||
if(user != null){
|
|
||||||
CurrentUser cuser=new CurrentUser();
|
|
||||||
cuser.setAccountId(user.getId());
|
|
||||||
cuser.setName(user.getName());
|
|
||||||
cuser.setCode(user.getUserNo());
|
|
||||||
cuser.setDepartId(user.getDepartId());
|
|
||||||
return cuser;
|
|
||||||
}else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if(data.containsKey("userId")) {
|
|
||||||
// User user = userService.getBySysId(data.get("userId"));
|
|
||||||
// if(user != null){
|
|
||||||
// CurrentUser cuser=new CurrentUser();
|
|
||||||
// cuser.setAccountId(user.getId());
|
|
||||||
// cuser.setName(user.getName());
|
|
||||||
// cuser.setCode(user.getUserNo());
|
|
||||||
// cuser.setDepartId(user.getDepartId());
|
|
||||||
// return cuser;
|
|
||||||
// }else {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
//此处用于本地登录的情况,直接从token中获取,不需要再查询一次了
|
|
||||||
CurrentUser cuser=new CurrentUser();
|
|
||||||
cuser.setAccountId(data.get("aid"));
|
|
||||||
cuser.setName(data.get("name"));
|
|
||||||
cuser.setCode(data.get("userNo"));
|
|
||||||
// cuser.setOrgId(data.get("orgId"));
|
|
||||||
cuser.setDepartId(data.get("departId"));
|
|
||||||
return cuser;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -43,6 +43,7 @@ xboe.externalinterface.url.system=http://localhost:9091
|
|||||||
## 新增加的教师的内部调用接口
|
## 新增加的教师的内部调用接口
|
||||||
xboe.old.base.url=https://u-pre.boe.com
|
xboe.old.base.url=https://u-pre.boe.com
|
||||||
|
|
||||||
|
# 用户中心的接口配置
|
||||||
xboe.server.userbasic.url=https://u-pre.boe.com/userbasic
|
xboe.server.userbasic.url=https://u-pre.boe.com/userbasic
|
||||||
|
|
||||||
## 用户统计接口的api地址
|
## 用户统计接口的api地址
|
||||||
|
|||||||
Reference in New Issue
Block a user