mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-11 03:46:50 +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:
@@ -17,6 +17,11 @@
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.xboe</groupId>
|
||||
<artifactId>xboe-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xboe</groupId>
|
||||
<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.setVideoHeight(m.getVideo().getSize().getHeight());
|
||||
file.setVideoWidth(m.getVideo().getSize().getWidth());
|
||||
|
||||
if(StringUtils.isBlank(file.getDecoder()) || !file.getDecoder().equals("h264")) {
|
||||
log.error("编码格式不是h264,不能上传");
|
||||
return error("编码格式不是h264,请先转码再上传","");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
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);
|
||||
//提取教师信息
|
||||
List<String> ids=new ArrayList<String>();
|
||||
List<String> cids=new ArrayList<String>();
|
||||
for(CourseFullText c :coursePageList.getList()) {
|
||||
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);
|
||||
//注意对于多个教师的情况,这里只是设置第一个教师
|
||||
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) {
|
||||
if(ct.getCourseId().equals(c.getId())) {
|
||||
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
|
||||
,String forUsers,String value,String summary,LocalDateTime publishTime,Boolean isTop) {
|
||||
this.setId(id);
|
||||
@@ -135,6 +141,10 @@ public class Course extends BaseEntity {
|
||||
@Column(name = "org_id",length = 20)
|
||||
private String orgId;
|
||||
|
||||
/**复制的课程的来源id*/
|
||||
@Column(name = "copy_id",length = 20)
|
||||
private String copyId;
|
||||
|
||||
/**
|
||||
* 企业ID, 多企业使用
|
||||
*/
|
||||
|
||||
@@ -91,7 +91,7 @@ public class CourseFile extends BaseEntity {
|
||||
private Integer duration;
|
||||
|
||||
/**
|
||||
* 编码格式
|
||||
* 编码格式,目前只限 h264
|
||||
* */
|
||||
@Column(name = "decoder",length = 20)
|
||||
private String decoder;
|
||||
|
||||
@@ -130,6 +130,11 @@ public interface ICourseService {
|
||||
/**
|
||||
* 复制课程
|
||||
* @param id
|
||||
* @param refId
|
||||
* @param refType
|
||||
* @param aid
|
||||
* @param aname
|
||||
* @return
|
||||
*/
|
||||
String copyCourse(String id,String refId,String refType,String aid,String aname);
|
||||
|
||||
@@ -315,6 +320,13 @@ public interface ICourseService {
|
||||
* 页面二次查询
|
||||
* */
|
||||
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 org.apache.commons.lang3.StringUtils;
|
||||
import org.hibernate.mapping.IdGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
@@ -368,11 +369,10 @@ public class CourseServiceImpl implements ICourseService {
|
||||
filters.add(FieldFilters.eq("deleted",false));
|
||||
filters.add(FieldFilters.eq("enabled",true));
|
||||
//返回的结果
|
||||
|
||||
|
||||
QueryBuilder query=QueryBuilder.from(Course.class).addFilters(filters);
|
||||
|
||||
if(dto.getTopOrder()!=null) {
|
||||
if(dto.getTopOrder()!=null){
|
||||
if(dto.getTopOrder()){
|
||||
query.addOrder(OrderCondition.desc("isTop"));
|
||||
query.addOrder(OrderCondition.desc("topTime"));
|
||||
@@ -1498,58 +1498,107 @@ public class CourseServiceImpl implements ICourseService {
|
||||
@Override
|
||||
public String copyCourse(String id,String refId,String refType,String aid,String aname) {
|
||||
//复制课程,boe_course,boe_course_content,boe_course_homework,boe_course_section,boe_course_teacher,boe_course_exam
|
||||
// insert info select
|
||||
List<CourseSection> sectionList = courseSectionDao.findList("courseId", id);
|
||||
if(refId==null) {
|
||||
refId="";
|
||||
}
|
||||
if(refType==null) {
|
||||
refType="";
|
||||
}
|
||||
// insert info select
|
||||
List<CourseSection> sectionList = courseSectionDao.findList("courseId", id);
|
||||
if(refId==null) {
|
||||
refId="";
|
||||
}
|
||||
if(refType==null) {
|
||||
refType="";
|
||||
}
|
||||
|
||||
boolean visible=true;
|
||||
if(StringUtils.isNotBlank(refId)) {
|
||||
visible=false;
|
||||
}
|
||||
|
||||
String newId = IDGenerator.generate();
|
||||
String courseName = this.courseName(id);
|
||||
LocalDateTime time = LocalDateTime.now();
|
||||
String mess=null;
|
||||
if(courseName.length()<96) {
|
||||
|
||||
boolean visible=true;
|
||||
if(StringUtils.isNotBlank(refId)) {
|
||||
visible=false;
|
||||
}
|
||||
String sql = "insert into boe_course(id,org_id,copy_id,ref_id,ref_type,visible,sys_create_aid,sys_create_by,sys_create_time,deleted,sys_update_by," +
|
||||
"sys_update_time,sys_version,comments,cover_img,dead_time,device,enable_remark,enabled," +
|
||||
"erasable,favorites,for_scene,for_users,is_top,keywords,name,open_object," +
|
||||
"overview,pass_formula,praises,publish_time,published,res_owner1,res_owner2," +
|
||||
"res_owner3,score,score_formula,shares,source,study_time,studys,summary," +
|
||||
"sys_type1,sys_type2,sys_type3,tags,top_time,trample_count,type,value,views," +
|
||||
"order_study,status)" +
|
||||
"select '" + newId + "',org_id,'"+id+"','"+refId+"','"+refType+"',"+visible+",'"+aid+"','"+aname+"','" + time + "',0,'"+aname+"'," +
|
||||
"'" + time + "',1,comments,cover_img,dead_time,device,enable_remark,enabled," +
|
||||
"erasable,0,for_scene,for_users,0,keywords,'" + courseName + "(1)" + "',open_object," +
|
||||
"overview,pass_formula,0,publish_time,0,res_owner1,res_owner2," +
|
||||
"res_owner3,score,score_formula,0,source,study_time,0,summary," +
|
||||
"sys_type1,sys_type2,sys_type3,tags,top_time,trample_count,type,value,0," +
|
||||
"order_study,1 from boe_course where id=?1";
|
||||
courseDao.sqlUpdate(sql, id);
|
||||
|
||||
String newId = IDGenerator.generate();
|
||||
String courseName = this.courseName(id);
|
||||
LocalDateTime time = LocalDateTime.now();
|
||||
String mess=null;
|
||||
if(courseName.length()<96) {
|
||||
|
||||
String sql = "insert into boe_course(id,org_id,copy_id,ref_id,ref_type,visible,sys_create_aid,sys_create_by,sys_create_time,deleted,sys_update_by," +
|
||||
"sys_update_time,sys_version,comments,cover_img,dead_time,device,enable_remark,enabled," +
|
||||
"erasable,favorites,for_scene,for_users,is_top,keywords,name,open_object," +
|
||||
"overview,pass_formula,praises,publish_time,published,res_owner1,res_owner2," +
|
||||
"res_owner3,score,score_formula,shares,source,study_time,studys,summary," +
|
||||
"sys_type1,sys_type2,sys_type3,tags,top_time,trample_count,type,value,views," +
|
||||
"order_study,status)" +
|
||||
"select '" + newId + "',org_id,'"+id+"','"+refId+"','"+refType+"',"+visible+",'"+aid+"','"+aname+"','" + time + "',0,'"+aname+"'," +
|
||||
"'" + time + "',1,comments,cover_img,dead_time,device,enable_remark,enabled," +
|
||||
"erasable,0,for_scene,for_users,0,keywords,'" + courseName + "(1)" + "',open_object," +
|
||||
"overview,pass_formula,0,publish_time,0,res_owner1,res_owner2," +
|
||||
"res_owner3,score,score_formula,0,source,study_time,0,summary," +
|
||||
"sys_type1,sys_type2,sys_type3,tags,top_time,trample_count,type,value,0," +
|
||||
"order_study,1 from boe_course where id=?1";
|
||||
courseDao.sqlUpdate(sql, id);
|
||||
|
||||
//课程章节复制,因为微课是没有章的,所以这里要判断
|
||||
|
||||
if(sectionList.isEmpty()) {
|
||||
//查出所有的内容,然后再一个一个复制(因为要复制关联的内容)
|
||||
List<?> contentIds= courseContentDao.findListField("id",FieldFilters.eq("courseId", id),FieldFilters.eq("deleted", false));
|
||||
for(Object obj :contentIds) {
|
||||
String oldId=(String)obj;
|
||||
//课程章节复制,因为微课是没有章的,所以这里要判断
|
||||
|
||||
if(sectionList.isEmpty()) {
|
||||
//查出所有的内容,然后再一个一个复制(因为要复制关联的内容)
|
||||
List<?> contentIds= courseContentDao.findListField("id",FieldFilters.eq("courseId", id),FieldFilters.eq("deleted", false));
|
||||
for(Object obj :contentIds) {
|
||||
String oldId=(String)obj;
|
||||
String newContentId=IDGenerator.generate();
|
||||
String sqlContent = "insert into boe_course_content(id,sys_create_aid,sys_create_by,sys_create_time," +
|
||||
"deleted,sys_update_by,sys_update_time,sys_version,content,content_name,content_refid," +
|
||||
"content_type,course_id,csection_id,duration,sort_index)" +
|
||||
"select '"+newContentId+"','"+aid+"','"+aname+"','" + time + "'," +
|
||||
"deleted,'"+aname+"','" + time + "',1,content," +
|
||||
"content_name,content_refid,content_type,'" + newId + "','',duration,sort_index " +
|
||||
"from boe_course_content where id=?1";
|
||||
courseContentDao.sqlUpdate(sqlContent, oldId);
|
||||
|
||||
//课程作业复制
|
||||
String sqlCourseHomeWork = "insert into boe_course_homework(id,sys_create_aid,sys_create_by," +
|
||||
"sys_create_time,deleted,sys_update_by,sys_update_time,sys_version,content,content_id,course_id,dead_time," +
|
||||
"file,name,submit_mode)" +
|
||||
"SELECT UUID_SHORT(),'"+aid+"','"+aname+"','" + time + "'," +
|
||||
"deleted,'"+aname+"','" + time + "',sys_version,content,'"+newContentId+"','" + newId + "',dead_time," +
|
||||
"file,name,submit_mode from boe_course_homework where content_id=?1";
|
||||
courseHomeWorkDao.sqlUpdate(sqlCourseHomeWork, oldId);
|
||||
|
||||
//课程考试信息复制
|
||||
String sqlExam = "insert into boe_course_exam(id,sys_create_aid,sys_create_by," +
|
||||
"sys_create_time,deleted,sys_update_by,sys_update_time,sys_version,arrange,content_id," +
|
||||
"course_id,info,paper_content,paper_id,paper_type,pass_line,percent_score,qnum,random_mode," +
|
||||
"scoring_type,show_analysis,show_answer,test_duration," +
|
||||
"test_name,times)" +
|
||||
"select UUID_SHORT(),'"+aid+"','"+aname+"'," +
|
||||
"'" + time + "',deleted,'"+aname+"','" + time + "'," +
|
||||
"1,arrange,'"+newContentId+"'," +
|
||||
"'" + newId + "',info,paper_content,paper_id,paper_type,pass_line,percent_score,qnum," +
|
||||
"random_mode,scoring_type,show_analysis,show_answer,test_duration," +
|
||||
"test_name,times from boe_course_exam where content_id=?1";
|
||||
courseExamDao.sqlUpdate(sqlExam, oldId);
|
||||
}
|
||||
}else {
|
||||
List<KeyValue> contentIdSectionIds= courseContentDao.findKeyValueList("id","csectionId", FieldFilters.eq("courseId", id),FieldFilters.eq("deleted", false));
|
||||
for(CourseSection csection : sectionList) {
|
||||
//生成新的章的id
|
||||
String newSectionId = IDGenerator.generate();
|
||||
String sqlSection = "" +
|
||||
"insert into boe_course_section(id,course_id,description,name,order_index,parent_id)" +
|
||||
"SELECT '"+newSectionId+"','" + newId + "',description,name,order_index,parent_id " +
|
||||
"from boe_course_section where id=?1";
|
||||
courseSectionDao.sqlUpdate(sqlSection, csection.getId());
|
||||
|
||||
//课程内容复制
|
||||
for(KeyValue kv : contentIdSectionIds) {
|
||||
if(!kv.getValue().equals(csection.getId())) {
|
||||
continue;
|
||||
}
|
||||
String newContentId=IDGenerator.generate();
|
||||
String sqlContent = "insert into boe_course_content(id,sys_create_aid,sys_create_by,sys_create_time," +
|
||||
"deleted,sys_update_by,sys_update_time,sys_version,content,content_name,content_refid," +
|
||||
"content_type,course_id,csection_id,duration,sort_index)" +
|
||||
"select '"+newContentId+"','"+aid+"','"+aname+"','" + time + "'," +
|
||||
"deleted,'"+aname+"','" + time + "',1,content," +
|
||||
"content_name,content_refid,content_type,'" + newId + "','',duration,sort_index " +
|
||||
"deleted,'"+aname+"','" + time + "',sys_version,content," +
|
||||
"content_name,content_refid,content_type,'" + newId + "','"+newSectionId+"',duration,sort_index " +
|
||||
"from boe_course_content where id=?1";
|
||||
courseContentDao.sqlUpdate(sqlContent, oldId);
|
||||
courseContentDao.sqlUpdate(sqlContent,kv.getKey());
|
||||
|
||||
//课程作业复制
|
||||
String sqlCourseHomeWork = "insert into boe_course_homework(id,sys_create_aid,sys_create_by," +
|
||||
@@ -1557,8 +1606,8 @@ public class CourseServiceImpl implements ICourseService {
|
||||
"file,name,submit_mode)" +
|
||||
"SELECT UUID_SHORT(),'"+aid+"','"+aname+"','" + time + "'," +
|
||||
"deleted,'"+aname+"','" + time + "',sys_version,content,'"+newContentId+"','" + newId + "',dead_time," +
|
||||
"file,name,submit_mode from boe_course_homework where content_id=?1";
|
||||
courseHomeWorkDao.sqlUpdate(sqlCourseHomeWork, oldId);
|
||||
"file,name,submit_mode from boe_course_homework where content_id=?1 and course_id=?2";
|
||||
courseHomeWorkDao.sqlUpdate(sqlCourseHomeWork,kv.getKey(),id);
|
||||
|
||||
//课程考试信息复制
|
||||
String sqlExam = "insert into boe_course_exam(id,sys_create_aid,sys_create_by," +
|
||||
@@ -1571,75 +1620,27 @@ public class CourseServiceImpl implements ICourseService {
|
||||
"1,arrange,'"+newContentId+"'," +
|
||||
"'" + newId + "',info,paper_content,paper_id,paper_type,pass_line,percent_score,qnum," +
|
||||
"random_mode,scoring_type,show_analysis,show_answer,test_duration," +
|
||||
"test_name,times from boe_course_exam where content_id=?1";
|
||||
courseExamDao.sqlUpdate(sqlExam, oldId);
|
||||
}
|
||||
}else {
|
||||
List<KeyValue> contentIdSectionIds= courseContentDao.findKeyValueList("id","csectionId", FieldFilters.eq("courseId", id),FieldFilters.eq("deleted", false));
|
||||
for(CourseSection csection : sectionList) {
|
||||
//生成新的章的id
|
||||
String newSectionId = IDGenerator.generate();
|
||||
String sqlSection = "" +
|
||||
"insert into boe_course_section(id,course_id,description,name,order_index,parent_id)" +
|
||||
"SELECT '"+newSectionId+"','" + newId + "',description,name,order_index,parent_id " +
|
||||
"from boe_course_section where id=?1";
|
||||
courseSectionDao.sqlUpdate(sqlSection, csection.getId());
|
||||
|
||||
//课程内容复制
|
||||
for(KeyValue kv : contentIdSectionIds) {
|
||||
if(!kv.getValue().equals(csection.getId())) {
|
||||
continue;
|
||||
}
|
||||
String newContentId=IDGenerator.generate();
|
||||
String sqlContent = "insert into boe_course_content(id,sys_create_aid,sys_create_by,sys_create_time," +
|
||||
"deleted,sys_update_by,sys_update_time,sys_version,content,content_name,content_refid," +
|
||||
"content_type,course_id,csection_id,duration,sort_index)" +
|
||||
"select '"+newContentId+"','"+aid+"','"+aname+"','" + time + "'," +
|
||||
"deleted,'"+aname+"','" + time + "',sys_version,content," +
|
||||
"content_name,content_refid,content_type,'" + newId + "','"+newSectionId+"',duration,sort_index " +
|
||||
"from boe_course_content where id=?1";
|
||||
courseContentDao.sqlUpdate(sqlContent,kv.getKey());
|
||||
|
||||
//课程作业复制
|
||||
String sqlCourseHomeWork = "insert into boe_course_homework(id,sys_create_aid,sys_create_by," +
|
||||
"sys_create_time,deleted,sys_update_by,sys_update_time,sys_version,content,content_id,course_id,dead_time," +
|
||||
"file,name,submit_mode)" +
|
||||
"SELECT UUID_SHORT(),'"+aid+"','"+aname+"','" + time + "'," +
|
||||
"deleted,'"+aname+"','" + time + "',sys_version,content,'"+newContentId+"','" + newId + "',dead_time," +
|
||||
"file,name,submit_mode from boe_course_homework where content_id=?1 and course_id=?2";
|
||||
courseHomeWorkDao.sqlUpdate(sqlCourseHomeWork,kv.getKey(),id);
|
||||
|
||||
//课程考试信息复制
|
||||
String sqlExam = "insert into boe_course_exam(id,sys_create_aid,sys_create_by," +
|
||||
"sys_create_time,deleted,sys_update_by,sys_update_time,sys_version,arrange,content_id," +
|
||||
"course_id,info,paper_content,paper_id,paper_type,pass_line,percent_score,qnum,random_mode," +
|
||||
"scoring_type,show_analysis,show_answer,test_duration," +
|
||||
"test_name,times)" +
|
||||
"select UUID_SHORT(),'"+aid+"','"+aname+"'," +
|
||||
"'" + time + "',deleted,'"+aname+"','" + time + "'," +
|
||||
"1,arrange,'"+newContentId+"'," +
|
||||
"'" + newId + "',info,paper_content,paper_id,paper_type,pass_line,percent_score,qnum," +
|
||||
"random_mode,scoring_type,show_analysis,show_answer,test_duration," +
|
||||
"test_name,times from boe_course_exam where content_id=?1 and course_id=?2";
|
||||
courseExamDao.sqlUpdate(sqlExam,kv.getKey(),id);
|
||||
}
|
||||
|
||||
"test_name,times from boe_course_exam where content_id=?1 and course_id=?2";
|
||||
courseExamDao.sqlUpdate(sqlExam,kv.getKey(),id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//课程任课教师复制
|
||||
String sqlTeacher = "insert into boe_course_teacher(id,sys_create_aid,sys_create_by,sys_create_time," +
|
||||
"course_id,teacher_id,teacher_name)" +
|
||||
"SELECT UUID_SHORT(),'"+aid+"','"+aname+"'," +
|
||||
"'" + time + "','" + newId + "',teacher_id," +
|
||||
"teacher_name from boe_course_teacher where course_id=?1";
|
||||
courseTeacherDao.sqlUpdate(sqlTeacher, id);
|
||||
}
|
||||
|
||||
//课程任课教师复制
|
||||
String sqlTeacher = "insert into boe_course_teacher(id,sys_create_aid,sys_create_by,sys_create_time," +
|
||||
"course_id,teacher_id,teacher_name)" +
|
||||
"SELECT UUID_SHORT(),'"+aid+"','"+aname+"'," +
|
||||
"'" + time + "','" + newId + "',teacher_id," +
|
||||
"teacher_name from boe_course_teacher where course_id=?1";
|
||||
courseTeacherDao.sqlUpdate(sqlTeacher, id);
|
||||
|
||||
}
|
||||
else{
|
||||
mess="长度超出范围";
|
||||
}
|
||||
return mess;
|
||||
|
||||
}
|
||||
else{
|
||||
mess="长度超出范围";
|
||||
}
|
||||
return mess;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1653,6 +1654,12 @@ public class CourseServiceImpl implements ICourseService {
|
||||
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.common.utils.StringUtil;
|
||||
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;
|
||||
import com.xboe.system.organization.service.IOrganizationService;
|
||||
@@ -35,9 +33,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@RequestMapping(value = "/xboe/portal")
|
||||
public class PortalConsoleApi extends ApiBaseController{
|
||||
|
||||
@Autowired
|
||||
IAuthorizationToken authorizationToken;
|
||||
|
||||
@Autowired
|
||||
IUserService userService;
|
||||
|
||||
@@ -61,7 +56,8 @@ public class PortalConsoleApi extends ApiBaseController{
|
||||
public JsonResponse<Map<String,Object>> init() {
|
||||
Map<String,Object> map=new HashMap<String,Object>();
|
||||
try {
|
||||
Account account = accountService.get(getCurrent().getAccountId());
|
||||
CurrentUser cuser=getCurrent();
|
||||
Account account = accountService.get(cuser.getAccountId());
|
||||
if(account==null) {
|
||||
log.error("未找到账号id【"+getCurrent().getAccountId()+"】对应的用户");
|
||||
return error("账号错误,无此账号");
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -14,6 +13,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xboe.common.utils.Sha256Mac;
|
||||
import com.xboe.core.IAuthorizationToken;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* token 与原boe系统相同的生成解析规则
|
||||
*
|
||||
@@ -37,7 +38,7 @@ public class BoeTokenImpl implements IAuthorizationToken{
|
||||
//long iat=System.currentTimeMillis()/1000;
|
||||
long iat=System.currentTimeMillis()/1000;
|
||||
payloadMap.put("iat", iat);
|
||||
long exp=iat+(12*60*60);//过期时间,12个小时过期
|
||||
long exp=iat+(2*60*60);//过期时间,2个小时过期
|
||||
payloadMap.put("exp", exp);
|
||||
payloadMap.put("GivenName", "boeu");
|
||||
payloadMap.put("permission","");
|
||||
@@ -97,10 +98,11 @@ public class BoeTokenImpl implements IAuthorizationToken{
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
//
|
||||
//// Map<String,String> data=new HashMap<String,String>();
|
||||
//// data.put("userId","DFF192E1-FB7B-11EC-9DDF-005056BD9028");//原系统id
|
||||
//// data.put("name", "测试账号0001");
|
||||
////
|
||||
// Map<String,String> data=new HashMap<String,String>();
|
||||
// data.put("userId","DFF192E1-FB7B-11EC-9DDF-005056BD9028");//原系统id
|
||||
// data.put("uId", "二期新增加的id");
|
||||
// data.put("name", "测试账号0001");
|
||||
////
|
||||
//// try {
|
||||
////
|
||||
@@ -110,18 +112,19 @@ public class BoeTokenImpl implements IAuthorizationToken{
|
||||
//// }catch(Exception e) {
|
||||
//// e.printStackTrace();
|
||||
//// }
|
||||
//
|
||||
////
|
||||
// try {
|
||||
//
|
||||
// BoeTokenImpl impl=new BoeTokenImpl();
|
||||
//// String token=impl.createToken(data);
|
||||
//// System.out.println(token);
|
||||
// String token=impl.createToken(data);
|
||||
// System.out.println(token);
|
||||
////
|
||||
//// Map<String,String> tokenData = impl.readToken(token);
|
||||
//
|
||||
//
|
||||
// String token="eyJ0eXBlIjoidG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJ1SWQiOiI5NTI5NDg2MjY0OTc3MjQ0MTEiLCJ1c2VyTm8iOiIxMjM0NTYwMSIsImlzcyI6Imh0dHA6Ly91LmJvZS5jb20iLCJuYW1lIjoi5Luj5rW35YW0IiwiR2l2ZW5OYW1lIjoiYm9ldSIsImRlcGFydElkIjoiOTg0MTQ3NTY2NTIxNjY3NTg0IiwicGVybWlzc2lvbiI6IiIsImV4cCI6MTY3NTc4MTQwMSwiaWF0IjoxNjc1NzM4MjAxLCJhaWQiOiI5NTI5NDg2MjY0OTc3MjQ0MTEiLCJ1c2VySWQiOiIwMTU1NTNERC00NDVFLTY5RDQtMzUxRi1ERDlBMUE1NjQyMEUifQ==.d1d8d3e53ece04a8a863d5f0a3c227cea559cc4cfcbc9010a1125f7a11d6e9a0";
|
||||
// //String token="eyJhbGciOiJIUzI1NiIsInR5cGUiOiJ0b2tlbiJ9.eyJpc3MiOiJodHRwOi8vdS5ib2UuY29tIiwiR2l2ZW5OYW1lIjoiYm9ldSIsInVJZCI6OTY1MzQxOTk5NjQzMjM0MzA0LCJ1c2VySWQiOiIwMTU1NTNERC00NDVFLTY5RDQtMzUxRi1ERDlBMUE1NjQyMEUiLCJleHAiOjE2NzkzNjcwOTc1NDF9.1758ccba02926f5e790743857e11f0fc89238cb9c30024530b5d4b3ff8387ad2";
|
||||
// //String token = "eyJhbGciOiJIUzI1NiIsInR5cGUiOiJ0b2tlbiJ9.eyJpc3MiOiJodHRwOi8vdS5ib2UuY29tIiwiR2l2ZW5OYW1lIjoiYm9ldSIsInVJZCI6OTY1MzQyMDI3NDk3NjA3MTY4LCJ1c2VySWQiOiI2QjA0OUZBRi1DMzE0LTdDQ0YtMEQyOC0wRDIzRjRDNDI1MzEiLCJleHAiOjE2NzU3NTU4ODYzMzV9.c65d86ccc5feb1c820490d94196f5509b6bb97dce748bc590160c6d8489bde6a";
|
||||
// //Map<String,String> map = impl.readToken(token);
|
||||
// String[] tokens = token.split("\\.");
|
||||
// System.out.println(tokens.length);
|
||||
// String header = new String(Base64.decodeBase64(tokens[0]));
|
||||
@@ -136,12 +139,13 @@ public class BoeTokenImpl implements IAuthorizationToken{
|
||||
// JsonNode json = om.readTree(payload);
|
||||
// System.out.println(json);
|
||||
// String userId=json.get("userId").asText();
|
||||
// String uId=json.get("uId").asText();
|
||||
// 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) {
|
||||
// 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())){
|
||||
return error("参数错误:内容");
|
||||
}
|
||||
LocalDateTime now=LocalDateTime.now();
|
||||
// LocalDateTime now=LocalDateTime.now();
|
||||
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());
|
||||
if(sci.getDuration()==null) {
|
||||
sci.setDuration(1);//增加5秒的学习时长,因方法是每5秒调用一次的
|
||||
}
|
||||
|
||||
// StudyTime st=new StudyTime();
|
||||
// st.setContentId(sci.getContentId());
|
||||
// st.setCourseId(sci.getCourseId());
|
||||
// st.setDuration(5);//增加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());
|
||||
@@ -266,7 +270,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -283,7 +287,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
|
||||
studyService.saveStudyInfo(sci);
|
||||
//学习记录成功后处理
|
||||
studyService.appendStudyDuration(st);
|
||||
studyService.appendStudyDuration(sci.getStudyId(),sci.getStudyItemId(),sci.getContentId(),sci.getDuration());
|
||||
return success(sci.getStudyItemId());
|
||||
}catch(Exception 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及其它的内容
|
||||
* @param sci
|
||||
@@ -308,36 +335,23 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
}
|
||||
// LocalDateTime now=LocalDateTime.now();
|
||||
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());
|
||||
if(item!=null) {
|
||||
//如果记录存在,但是进度不到100,未完成情况,就更新进度,一期不会有这种情况
|
||||
if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
|
||||
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),sci.getProgress());
|
||||
if(item.getProgress()<100) {
|
||||
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),100);
|
||||
}
|
||||
//追加学习时长
|
||||
//追加学习时长,学习时长是单独的记录,这里不再进行记录
|
||||
//studyService.appendStudyDuration(st);
|
||||
return success(item.getId());
|
||||
}
|
||||
|
||||
//如果不存在,就创建,这种情况应该不存在
|
||||
try {
|
||||
sci.setAid(cuser.getAccountId());
|
||||
sci.setAname(cuser.getName());
|
||||
sci.setProgress(100);
|
||||
studyService.saveStudyInfo(sci);
|
||||
//学习记录成功后处理
|
||||
//studyService.appendStudyDuration(st);
|
||||
return success(sci.getStudyItemId());
|
||||
}catch(Exception e) {
|
||||
log.error("记录学习课程内容完成错误",e);
|
||||
@@ -437,7 +451,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
* @return
|
||||
*/
|
||||
@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)){
|
||||
return error("参数错误");
|
||||
@@ -485,7 +499,8 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
try {
|
||||
//此处需要优化处理,
|
||||
//不能直接记录追加学习时间。以后增加到队列中,后台服务定时从队列中读取, 更新到系统中
|
||||
studyService.appendStudyDuration(studyTime);
|
||||
//studyService.appendStudyDuration(studyTime);
|
||||
studyService.appendStudyDuration(studyTime.getStudyId(),null,studyTime.getContentId(),studyTime.getDuration());
|
||||
return success(studyTime.getId());
|
||||
}catch(Exception e) {
|
||||
log.error("记录学习时长错误",e);
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.xboe.school.study.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.RequestMethod;
|
||||
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")
|
||||
public JsonResponse<Boolean> createIndex(){
|
||||
if(search==null) {
|
||||
|
||||
@@ -28,6 +28,7 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
||||
* @param 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));
|
||||
if(total==null) {
|
||||
@@ -40,7 +41,8 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
||||
//自主报名的课程,代表学习完成
|
||||
super.updateMultiFieldById(studyId,
|
||||
UpdateBuilder.create("progress",100f),
|
||||
UpdateBuilder.create("lastTime",LocalDateTime.now()),
|
||||
UpdateBuilder.create("lastTime",now),
|
||||
UpdateBuilder.create("finishTime",now),
|
||||
UpdateBuilder.create("status",StudyCourse.STATUS_FINISH));
|
||||
}else {
|
||||
super.updateMultiFieldById(studyId,
|
||||
|
||||
@@ -33,6 +33,9 @@ public class StudyContentDto {
|
||||
/**内容的总数量*/
|
||||
private Integer contentTotal;
|
||||
|
||||
/**学习时长*/
|
||||
private Integer duration;
|
||||
|
||||
private String aid;
|
||||
|
||||
private String aname;
|
||||
|
||||
@@ -79,6 +79,13 @@ public interface IStudyCourseService {
|
||||
* 二次查询 个人/他人
|
||||
* */
|
||||
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);
|
||||
|
||||
/**
|
||||
* 追加学习持续时长
|
||||
* 追加学习持续时长,此处理是一期的,有追加记录,二期后追加记录在stat服务中,这里不需要再记录了,所以不建议使用此方法
|
||||
* @param st
|
||||
*/
|
||||
@Deprecated
|
||||
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,得到章节的学习记录情况
|
||||
* @param studyId
|
||||
|
||||
@@ -48,6 +48,7 @@ public class StudyAssessServiceImpl implements IStudyAssessService{
|
||||
sci.setCourseId(assess.getCourseId());
|
||||
//sci.setCsectionId(homework.getCsectionId());
|
||||
sci.setProgress(100);//直接设置为学习完成
|
||||
sci.setStatus(StudyCourseItem.STATUS_FINISH);
|
||||
sci.setStartTime(ldt);
|
||||
sci.setAid(assess.getStudentId());
|
||||
sci.setAname(assess.getStudentName());
|
||||
|
||||
@@ -704,4 +704,9 @@ public class StudyCourseServiceImpl implements IStudyCourseService{
|
||||
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.setCsectionId(homework.getCsectionId());
|
||||
sci.setProgress(100);//直接设置为学习完成
|
||||
sci.setStatus(StudyCourseItem.STATUS_FINISH);//状态直接更新为已完成
|
||||
sci.setStartTime(ldt);
|
||||
sci.setAid(exam.getStudentId());
|
||||
sci.setAname(exam.getStudentName());
|
||||
|
||||
@@ -50,6 +50,7 @@ public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
|
||||
sci.setCourseId(homework.getCourseId());
|
||||
//sci.setCsectionId(homework.getCsectionId());
|
||||
sci.setProgress(100);//直接设置为学习完成
|
||||
sci.setStatus(9);//状态直接更新为已完成
|
||||
sci.setStartTime(ldt);
|
||||
sci.setAid(homework.getStudentId());
|
||||
sci.setAname(homework.getStudentName());
|
||||
|
||||
@@ -72,6 +72,7 @@ public class StudyServiceImpl implements IStudyService{
|
||||
sci.setStudyId(dto.getStudyId());
|
||||
sci.setContentId(dto.getContentId());
|
||||
sci.setContentName(dto.getContentName());
|
||||
sci.setStudyDuration(0);
|
||||
sci.setCourseId(dto.getCourseId());
|
||||
sci.setCsectionId(dto.getCsectionId());
|
||||
}
|
||||
@@ -80,6 +81,7 @@ public class StudyServiceImpl implements IStudyService{
|
||||
sci.setProgress(1);
|
||||
sci.setStatus(StudyCourseItem.STATUS_STUDYING);
|
||||
}else if(dto.getProgress().intValue()==100) {
|
||||
sci.setFinishTime(ldt);
|
||||
sci.setStatus(StudyCourseItem.STATUS_FINISH);
|
||||
sci.setProgress(100);
|
||||
}else {
|
||||
@@ -87,7 +89,6 @@ public class StudyServiceImpl implements IStudyService{
|
||||
sci.setProgress(dto.getProgress());
|
||||
}
|
||||
//sci.setProgress(100);//直接设置为学习完成
|
||||
sci.setFinishTime(ldt);
|
||||
sci.setLastTime(ldt);
|
||||
scItemDao.saveOrUpdate(sci);
|
||||
|
||||
@@ -96,6 +97,41 @@ public class StudyServiceImpl implements IStudyService{
|
||||
scDao.finishCheck(dto.getStudyId(),dto.getCourseId(),dto.getContentTotal());
|
||||
|
||||
}
|
||||
|
||||
@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
|
||||
@Transactional
|
||||
@@ -158,12 +194,22 @@ public class StudyServiceImpl implements IStudyService{
|
||||
@Transactional
|
||||
public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress) {
|
||||
int status=StudyCourseItem.STATUS_STUDYING;
|
||||
LocalDateTime now=LocalDateTime.now();
|
||||
if(progress.intValue()==100) {
|
||||
status=StudyCourseItem.STATUS_FINISH;
|
||||
scItemDao.updateMultiFieldById(studyContentId,
|
||||
UpdateBuilder.create("progress",progress),
|
||||
UpdateBuilder.create("lastTime",now),
|
||||
UpdateBuilder.create("finishTime",now),
|
||||
UpdateBuilder.create("status",status));
|
||||
//检查是否全部学习完成
|
||||
scDao.finishCheck(studyId,courseId,total);
|
||||
}else {
|
||||
scItemDao.updateMultiFieldById(studyContentId,
|
||||
UpdateBuilder.create("progress",progress),
|
||||
UpdateBuilder.create("lastTime",now),
|
||||
UpdateBuilder.create("status",status));
|
||||
}
|
||||
scItemDao.updateMultiFieldById(studyContentId,UpdateBuilder.create("progress",progress),UpdateBuilder.create("status",status));
|
||||
//检查是否全部学习完成
|
||||
scDao.finishCheck(studyId,courseId,total);
|
||||
|
||||
}
|
||||
|
||||
@@ -230,7 +276,6 @@ public class StudyServiceImpl implements IStudyService{
|
||||
}
|
||||
|
||||
//以下是针对于视频课件的处理
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveVideoStudyItem(StudyCourseItem sci) {
|
||||
@@ -239,6 +284,9 @@ public class StudyServiceImpl implements IStudyService{
|
||||
if(sci.getStatus()==null) {
|
||||
sci.setStatus(StudyCourseItem.STATUS_STUDYING);
|
||||
}
|
||||
if(sci.getStudyDuration()==null) {
|
||||
sci.setStudyDuration(0);
|
||||
}
|
||||
scItemDao.save(sci);
|
||||
//更新课程学习的进度
|
||||
scDao.updateProgress(sci.getStudyId(),sci.getProgress().floatValue());
|
||||
|
||||
@@ -77,6 +77,7 @@ public class StudySignupServiceImpl implements IStudySignupService{
|
||||
sc.setCourseId(signup.getCourseId());
|
||||
sc.setCourseName(signup.getCourseName());
|
||||
sc.setCourseType(signup.getCourseType());
|
||||
sc.setStartTime(now);
|
||||
sc.setFinishTime(null);
|
||||
sc.setLastScore(0f);
|
||||
sc.setProgress(0f);
|
||||
@@ -98,6 +99,12 @@ public class StudySignupServiceImpl implements IStudySignupService{
|
||||
dto.setCourseType(sc.getCourseType());
|
||||
dto.setProgress(sc.getProgress()==null? 0:sc.getProgress().intValue());
|
||||
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) {
|
||||
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.server.userbasic.url=https://u-pre.boe.com/userbasic
|
||||
|
||||
## 用户统计接口的api地址
|
||||
|
||||
Reference in New Issue
Block a user