mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-12 04:16:51 +08:00
Merge branch 'third'
This commit is contained in:
@@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.xboe.module.scorm.cam.load.SCORMPackageManager;
|
import com.xboe.module.scorm.cam.load.SCORMPackageManager;
|
||||||
|
import com.xboe.module.scorm.cam.load.ZipUtils;
|
||||||
import com.xboe.module.scorm.cam.model.ContentPackage;
|
import com.xboe.module.scorm.cam.model.ContentPackage;
|
||||||
import com.xboe.module.scorm.cam.model.Item;
|
import com.xboe.module.scorm.cam.model.Item;
|
||||||
import com.xboe.module.scorm.cam.model.Manifest;
|
import com.xboe.module.scorm.cam.model.Manifest;
|
||||||
@@ -23,7 +24,13 @@ public class SCORMParser {
|
|||||||
|
|
||||||
public String parserToJson(String path) throws Exception {
|
public String parserToJson(String path) throws Exception {
|
||||||
// System.out.println("test");
|
// System.out.println("test");
|
||||||
ContentPackage cp=SCORMPackageManager.getInstance().loadSCORMContentPackageFromZipFile("1", path);
|
ContentPackage cp=null;
|
||||||
|
if(ZipUtils.isEndWithZip(path)) {
|
||||||
|
cp=SCORMPackageManager.getInstance().loadSCORMContentPackageFromZipFile("1", path);
|
||||||
|
}else {
|
||||||
|
cp=SCORMPackageManager.getInstance().readSCORMContentPackage("1", path);
|
||||||
|
}
|
||||||
|
//ContentPackage cp=SCORMPackageManager.getInstance().readSCORMContentPackage("1", path);
|
||||||
Manifest manifest= cp.getManifest();
|
Manifest manifest= cp.getManifest();
|
||||||
// System.out.println(cp.getManifest().getIdentifier());
|
// System.out.println(cp.getManifest().getIdentifier());
|
||||||
// System.out.println(cp.getContent());
|
// System.out.println(cp.getContent());
|
||||||
@@ -81,8 +88,14 @@ public class SCORMParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//scorm的版本
|
//scorm的版本
|
||||||
|
if(manifest.getMetadata()==null) {
|
||||||
|
data.setSchema("ADL SCORM");
|
||||||
|
data.setVersion("1.2");
|
||||||
|
}else {
|
||||||
data.setSchema(manifest.getMetadata().getSchema());
|
data.setSchema(manifest.getMetadata().getSchema());
|
||||||
data.setVersion(manifest.getMetadata().getSchemaVersion());
|
data.setVersion(manifest.getMetadata().getSchemaVersion());
|
||||||
|
}
|
||||||
|
|
||||||
data.setScoItems(scoItems);//sco共有多少个
|
data.setScoItems(scoItems);//sco共有多少个
|
||||||
if(scoItems.size()>0 && scoItems.get(0).getScoUrl()!=null) {
|
if(scoItems.size()>0 && scoItems.get(0).getScoUrl()!=null) {
|
||||||
data.setIndex(scoItems.get(0).getScoUrl());//打开播放时进入的第一个sco
|
data.setIndex(scoItems.get(0).getScoUrl());//打开播放时进入的第一个sco
|
||||||
@@ -108,7 +121,7 @@ public class SCORMParser {
|
|||||||
// public static void main(String[] args) {
|
// public static void main(String[] args) {
|
||||||
// SCORMParser parser=new SCORMParser();
|
// SCORMParser parser=new SCORMParser();
|
||||||
// //String path1="E:/Projects/BOEU/scorm/file/ContentPackagingOneFilePerSCO_SCORM12.zip";
|
// //String path1="E:/Projects/BOEU/scorm/file/ContentPackagingOneFilePerSCO_SCORM12.zip";
|
||||||
// String path1="E:/Projects/BOEU/scorm/file/7a462dbee222ba62810191d2f512576e.zip";
|
// String path1="E:/Projects/BOEU/scorm/file/7a462dbee222ba62810191d2f512576e";
|
||||||
// try {
|
// try {
|
||||||
// String json= parser.parserToJson(path1);
|
// String json= parser.parserToJson(path1);
|
||||||
// System.out.println(json);
|
// System.out.println(json);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.xboe.module.scorm.cam.model.Resource;
|
|||||||
import com.xboe.module.scorm.common.LMSPersistDriverManager;
|
import com.xboe.module.scorm.common.LMSPersistDriverManager;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -113,6 +114,50 @@ public class SCORMPackageManager {
|
|||||||
return contentPackage;
|
return contentPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ContentPackage readSCORMContentPackage(String lmsContentPackageID, String packagePath) {
|
||||||
|
if (StringUtils.isBlank(packagePath)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// step 1: uncompress
|
||||||
|
File f=new File(packagePath);
|
||||||
|
if(!f.exists()) {
|
||||||
|
log.error( packagePath+ " is not exists");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if(!f.isDirectory()) {
|
||||||
|
log.error( packagePath+ " is not directory");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String saveDir=packagePath;
|
||||||
|
// step 2: validate all xml file in saveDir
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
|
if (!XmlSchemaValidator.validateAllXmlFileWithSchemaFileInPath(saveDir)) {
|
||||||
|
log.error("validate xml schema error.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// step 3: 读取imsmanifest.xml,生成ContentPackage
|
||||||
|
ContentPackage contentPackage = new ContentPackageGenerator().generateContentPackageFromFile(saveDir);
|
||||||
|
if (contentPackage == null) {
|
||||||
|
log.error("generate content package error.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// step 4: 验证ContentPackage
|
||||||
|
// ContentPackageValidator validator = new ContentPackageValidator(false);
|
||||||
|
// boolean validateResult = validator.validate(contentPackage, saveDir);
|
||||||
|
// if (!validateResult) {
|
||||||
|
// log.error("validate content package error: " + validator.getErrors());
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
contentPackageMap.put(lmsContentPackageID, contentPackage);
|
||||||
|
|
||||||
|
return contentPackage;
|
||||||
|
}
|
||||||
|
|
||||||
public int contentPackageCount() {
|
public int contentPackageCount() {
|
||||||
return contentPackageMap.size();
|
return contentPackageMap.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.xboe.data.dto;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserOrgIds {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是超级管理员
|
||||||
|
*/
|
||||||
|
public static final String IsSystemAdminKey="isSystemAdmin";
|
||||||
|
|
||||||
|
private Map<String,Boolean> permissions=new HashMap<String,Boolean>();
|
||||||
|
|
||||||
|
private List<String> ids;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.xboe.data.dto.AudienceUser;
|
import com.xboe.data.dto.AudienceUser;
|
||||||
import com.xboe.data.dto.UserData;
|
import com.xboe.data.dto.UserData;
|
||||||
|
import com.xboe.data.dto.UserOrgIds;
|
||||||
|
|
||||||
public interface IOutSideDataService {
|
public interface IOutSideDataService {
|
||||||
|
|
||||||
@@ -22,6 +23,6 @@ public interface IOutSideDataService {
|
|||||||
/**
|
/**
|
||||||
* 获取用户有权限的机构id
|
* 获取用户有权限的机构id
|
||||||
* */
|
* */
|
||||||
List<String> getOrgIds();
|
UserOrgIds getOrgIds();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.xboe.core.api.TokenProxy;
|
|||||||
import com.xboe.core.utils.OkHttpUtil;
|
import com.xboe.core.utils.OkHttpUtil;
|
||||||
import com.xboe.data.dto.AudienceUser;
|
import com.xboe.data.dto.AudienceUser;
|
||||||
import com.xboe.data.dto.UserData;
|
import com.xboe.data.dto.UserData;
|
||||||
|
import com.xboe.data.dto.UserOrgIds;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@@ -162,8 +163,10 @@ public class OutSideDataServiceImpl implements IOutSideDataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getOrgIds() {
|
public UserOrgIds getOrgIds() {
|
||||||
|
UserOrgIds uids=new UserOrgIds();
|
||||||
List<String> orgIds = new ArrayList<>();
|
List<String> orgIds = new ArrayList<>();
|
||||||
|
uids.setIds(orgIds);
|
||||||
String token = TokenProxy.getToken(request);
|
String token = TokenProxy.getToken(request);
|
||||||
String type="application/json";
|
String type="application/json";
|
||||||
String[] headers=new String[] {"token",token,"Content-Type",type};
|
String[] headers=new String[] {"token",token,"Content-Type",type};
|
||||||
@@ -178,6 +181,13 @@ public class OutSideDataServiceImpl implements IOutSideDataService {
|
|||||||
log.error("获取当前用户拥有权限机构id错误:"+responseStr);
|
log.error("获取当前用户拥有权限机构id错误:"+responseStr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
//对权限进行检查
|
||||||
|
if(rootNode.has("permissions")) {
|
||||||
|
JsonNode isAdminNode = rootNode.get("permissions").get("isSystemAdmin");
|
||||||
|
if(isAdminNode!=null) {
|
||||||
|
uids.getPermissions().put(UserOrgIds.IsSystemAdminKey, isAdminNode.asBoolean());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(rootNode.get("result")!=null & rootNode.get("result").isArray()) {
|
if(rootNode.get("result")!=null & rootNode.get("result").isArray()) {
|
||||||
JsonNode result = rootNode.get("result");
|
JsonNode result = rootNode.get("result");
|
||||||
@@ -189,7 +199,7 @@ public class OutSideDataServiceImpl implements IOutSideDataService {
|
|||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("获取当前用户有权限的机构id错误",e);
|
log.error("获取当前用户有权限的机构id错误",e);
|
||||||
}
|
}
|
||||||
return orgIds;
|
return uids;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,9 +51,7 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService{
|
|||||||
if(user.getDeleted()!=null) {
|
if(user.getDeleted()!=null) {
|
||||||
a.setDeleted(user.getDeleted());
|
a.setDeleted(user.getDeleted());
|
||||||
}
|
}
|
||||||
|
|
||||||
a.setLoginName(user.getCode());
|
a.setLoginName(user.getCode());
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
//新账户
|
//新账户
|
||||||
a=new Account();
|
a=new Account();
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.xboe.core.orm.FieldFilters;
|
|||||||
import com.xboe.core.orm.IFieldFilter;
|
import com.xboe.core.orm.IFieldFilter;
|
||||||
import com.xboe.core.orm.LikeMatchMode;
|
import com.xboe.core.orm.LikeMatchMode;
|
||||||
import com.xboe.core.upload.XFileUploader;
|
import com.xboe.core.upload.XFileUploader;
|
||||||
|
import com.xboe.data.dto.UserOrgIds;
|
||||||
import com.xboe.data.outside.IOutSideDataService;
|
import com.xboe.data.outside.IOutSideDataService;
|
||||||
import com.xboe.module.course.entity.CourseFile;
|
import com.xboe.module.course.entity.CourseFile;
|
||||||
import com.xboe.module.course.service.ICourseFileService;
|
import com.xboe.module.course.service.ICourseFileService;
|
||||||
@@ -106,8 +107,15 @@ public class CourseFileApi extends ApiBaseController {
|
|||||||
}
|
}
|
||||||
//增加权限的过滤,只要看到自己或有权限的机构的
|
//增加权限的过滤,只要看到自己或有权限的机构的
|
||||||
if(TempFilterConfig.Manager_CourseFile_ByOrgIds) {
|
if(TempFilterConfig.Manager_CourseFile_ByOrgIds) {
|
||||||
List<String> orgIds = outSideDataService.getOrgIds();
|
UserOrgIds userOrgIds=outSideDataService.getOrgIds();
|
||||||
|
List<String> orgIds = userOrgIds.getIds();
|
||||||
String aid=getCurrent().getAccountId();
|
String aid=getCurrent().getAccountId();
|
||||||
|
//如果是超级管理员,就不按机构过滤了
|
||||||
|
boolean isSystemAdmin=false;
|
||||||
|
if(userOrgIds.getPermissions().containsKey(UserOrgIds.IsSystemAdminKey)) {
|
||||||
|
isSystemAdmin=userOrgIds.getPermissions().get(UserOrgIds.IsSystemAdminKey);
|
||||||
|
}
|
||||||
|
if(!isSystemAdmin) {
|
||||||
if(!orgIds.isEmpty()){
|
if(!orgIds.isEmpty()){
|
||||||
//filters.add(FieldFilters.in("orgId", orgIds));
|
//filters.add(FieldFilters.in("orgId", orgIds));
|
||||||
filters.add(FieldFilters.or(FieldFilters.eq("sysCreateAid", aid),FieldFilters.in("orgId", orgIds)));
|
filters.add(FieldFilters.or(FieldFilters.eq("sysCreateAid", aid),FieldFilters.in("orgId", orgIds)));
|
||||||
@@ -116,6 +124,8 @@ public class CourseFileApi extends ApiBaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//默认是查询自己的课件。
|
//默认是查询自己的课件。
|
||||||
//
|
//
|
||||||
PageList<CourseFile> courseFilePageList = courseFileService.queryPage(pager.getPageIndex(), pager.getPageSize(), OrderCondition.desc("id"), filters);
|
PageList<CourseFile> courseFilePageList = courseFileService.queryPage(pager.getPageIndex(), pager.getPageSize(), OrderCondition.desc("id"), filters);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.xboe.core.CurrentUser;
|
|||||||
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.core.log.AutoLog;
|
import com.xboe.core.log.AutoLog;
|
||||||
|
import com.xboe.data.dto.UserOrgIds;
|
||||||
import com.xboe.data.outside.IOutSideDataService;
|
import com.xboe.data.outside.IOutSideDataService;
|
||||||
import com.xboe.externalinterface.system.service.IFwUserService;
|
import com.xboe.externalinterface.system.service.IFwUserService;
|
||||||
import com.xboe.module.assistance.service.IEmailService;
|
import com.xboe.module.assistance.service.IEmailService;
|
||||||
@@ -112,9 +113,20 @@ public class CourseManageApi extends ApiBaseController{
|
|||||||
public JsonResponse<PageList<Course>> findPage(Pagination pager,CourseQueryDto dto){
|
public JsonResponse<PageList<Course>> findPage(Pagination pager,CourseQueryDto dto){
|
||||||
|
|
||||||
//增加权限的过滤,只要看到自己或有权限的机构的
|
//增加权限的过滤,只要看到自己或有权限的机构的
|
||||||
|
//getCurrent().get
|
||||||
try {
|
try {
|
||||||
List<String> orgIds = outSideDataService.getOrgIds();
|
UserOrgIds userOrgIds=outSideDataService.getOrgIds();
|
||||||
String ids= StringUtils.join(orgIds,",");
|
List<String> orgIds = userOrgIds.getIds();
|
||||||
|
if(userOrgIds.getPermissions().containsKey(UserOrgIds.IsSystemAdminKey)) {
|
||||||
|
dto.setIsSystemAdmin(userOrgIds.getPermissions().get(UserOrgIds.IsSystemAdminKey));
|
||||||
|
}else {
|
||||||
|
dto.setIsSystemAdmin(false);
|
||||||
|
}
|
||||||
|
String ids="";
|
||||||
|
if(userOrgIds.getIds()!=null && !userOrgIds.getIds().isEmpty())
|
||||||
|
{
|
||||||
|
ids= StringUtils.join(orgIds,",");
|
||||||
|
}
|
||||||
//log.info("获取到的用户的组织机构权限ids",ids);
|
//log.info("获取到的用户的组织机构权限ids",ids);
|
||||||
String aid=getCurrent().getAccountId();
|
String aid=getCurrent().getAccountId();
|
||||||
//如果前端查询当前人的,这里去掉
|
//如果前端查询当前人的,这里去掉
|
||||||
|
|||||||
@@ -104,4 +104,9 @@ public class CourseQueryDto {
|
|||||||
|
|
||||||
/**用户权限的查询*/
|
/**用户权限的查询*/
|
||||||
private String orgAid;
|
private String orgAid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是超级管理员
|
||||||
|
*/
|
||||||
|
private Boolean isSystemAdmin;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import javax.servlet.http.Cookie;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -38,7 +37,6 @@ import com.xboe.system.logs.entity.SysLogLogin;
|
|||||||
import com.xboe.system.logs.service.ISysLogLoginService;
|
import com.xboe.system.logs.service.ISysLogLoginService;
|
||||||
import com.xboe.system.user.entity.User;
|
import com.xboe.system.user.entity.User;
|
||||||
import com.xboe.system.user.service.IUserService;
|
import com.xboe.system.user.service.IUserService;
|
||||||
import com.xboe.system.user.vo.UserVo;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@@ -207,6 +205,7 @@ public class PortalLoginApi extends ApiBaseController {
|
|||||||
if (StringUtil.isBlank(token)) {
|
if (StringUtil.isBlank(token)) {
|
||||||
return wrap(JsonResponseStatus.TOKEN_NOPASS, "token error");
|
return wrap(JsonResponseStatus.TOKEN_NOPASS, "token error");
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> tokenInfo = authorizationToken.readToken(token);
|
Map<String, String> tokenInfo = authorizationToken.readToken(token);
|
||||||
if (tokenInfo == null) {
|
if (tokenInfo == null) {
|
||||||
return wrap(JsonResponseStatus.TOKEN_NOPASS, "token error");
|
return wrap(JsonResponseStatus.TOKEN_NOPASS, "token error");
|
||||||
|
|||||||
@@ -306,19 +306,19 @@ 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();
|
// StudyTime st=new StudyTime();
|
||||||
st.setContentId(sci.getContentId());
|
// st.setContentId(sci.getContentId());
|
||||||
st.setCourseId(sci.getCourseId());
|
// st.setCourseId(sci.getCourseId());
|
||||||
st.setDuration(5);//增加5秒的学习时长
|
// st.setDuration(5);//增加5秒的学习时长
|
||||||
st.setEndTime(now);
|
// st.setEndTime(now);
|
||||||
st.setStartTime(now);
|
// st.setStartTime(now);
|
||||||
st.setStudentId(cuser.getAccountId());
|
// st.setStudentId(cuser.getAccountId());
|
||||||
st.setStudentName(cuser.getName());
|
// st.setStudentName(cuser.getName());
|
||||||
st.setStudyId(sci.getStudyId());
|
// st.setStudyId(sci.getStudyId());
|
||||||
|
|
||||||
//检查是否已存在
|
//检查是否已存在
|
||||||
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
||||||
@@ -328,7 +328,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(st);
|
||||||
return success(item.getId());
|
return success(item.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +337,7 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
sci.setAname(cuser.getName());
|
sci.setAname(cuser.getName());
|
||||||
studyService.saveStudyInfo(sci);
|
studyService.saveStudyInfo(sci);
|
||||||
//学习记录成功后处理
|
//学习记录成功后处理
|
||||||
studyService.appendStudyDuration(st);
|
//studyService.appendStudyDuration(st);
|
||||||
return success(sci.getStudyItemId());
|
return success(sci.getStudyItemId());
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
log.error("记录学习课程内容完成错误",e);
|
log.error("记录学习课程内容完成错误",e);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.xboe.core.orm.FieldFilters;
|
|||||||
import com.xboe.core.orm.UpdateBuilder;
|
import com.xboe.core.orm.UpdateBuilder;
|
||||||
import com.xboe.module.course.dao.CourseContentDao;
|
import com.xboe.module.course.dao.CourseContentDao;
|
||||||
import com.xboe.school.study.entity.StudyCourse;
|
import com.xboe.school.study.entity.StudyCourse;
|
||||||
|
import com.xboe.school.study.entity.StudyCourseItem;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class StudyCourseDao extends BaseDao<StudyCourse> {
|
public class StudyCourseDao extends BaseDao<StudyCourse> {
|
||||||
@@ -27,7 +28,8 @@ 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){
|
||||||
int n=scItemDao.count(FieldFilters.eq("studyId",studyId));
|
//已完成的内容
|
||||||
|
int n=scItemDao.count(FieldFilters.eq("studyId",studyId),FieldFilters.eq("status",StudyCourseItem.STATUS_FINISH));
|
||||||
if(total==null) {
|
if(total==null) {
|
||||||
total=courseContentDao.count(FieldFilters.eq("courseId", courseId),FieldFilters.eq("deleted",false));
|
total=courseContentDao.count(FieldFilters.eq("courseId", courseId),FieldFilters.eq("deleted",false));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public interface IStudyService {
|
|||||||
* @param studyContentId
|
* @param studyContentId
|
||||||
* @param progress
|
* @param progress
|
||||||
*/
|
*/
|
||||||
void updateProcess(String studyContentId,String studyId, String courseId,int total,Integer progress);
|
void updateProcess(String studyContentId,String studyId, String courseId,Integer total,Integer progress);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新最后的学习时间,及学习时间点
|
* 更新最后的学习时间,及学习时间点
|
||||||
|
|||||||
@@ -61,24 +61,36 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void saveStudyInfo(StudyContentDto dto) {
|
public void saveStudyInfo(StudyContentDto dto) {
|
||||||
//记录课程学习信息
|
StudyCourseItem sci = scItemDao.findOne(FieldFilters.eq("studyId", dto.getStudyId()),FieldFilters.eq("contentId", dto.getContentId()),FieldFilters.eq("aid", dto.getAid()));
|
||||||
StudyCourseItem sci=new StudyCourseItem();
|
|
||||||
LocalDateTime ldt=LocalDateTime.now();
|
LocalDateTime ldt=LocalDateTime.now();
|
||||||
|
if(sci==null) {
|
||||||
|
sci=new StudyCourseItem();
|
||||||
|
sci.setStartTime(ldt);
|
||||||
|
sci.setAid(dto.getAid());
|
||||||
|
sci.setAname(dto.getAname());
|
||||||
|
sci.setLastStudyTime(0);//此项用户记录视频内容当前学习的时间点
|
||||||
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.setCourseId(dto.getCourseId());
|
sci.setCourseId(dto.getCourseId());
|
||||||
|
|
||||||
sci.setCsectionId(dto.getCsectionId());
|
sci.setCsectionId(dto.getCsectionId());
|
||||||
sci.setProgress(100);//直接设置为学习完成
|
}
|
||||||
sci.setStartTime(ldt);
|
//进度状态
|
||||||
sci.setAid(dto.getAid());
|
if(dto.getProgress()==null) {
|
||||||
sci.setAname(dto.getAname());
|
sci.setProgress(1);
|
||||||
sci.setFinishTime(LocalDateTime.now());
|
sci.setStatus(StudyCourseItem.STATUS_STUDYING);
|
||||||
sci.setLastStudyTime(0);//此项用户记录视频内容当前学习的时间点
|
}else if(dto.getProgress().intValue()==100) {
|
||||||
sci.setLastTime(ldt);
|
|
||||||
sci.setStatus(StudyCourseItem.STATUS_FINISH);
|
sci.setStatus(StudyCourseItem.STATUS_FINISH);
|
||||||
scItemDao.save(sci);
|
sci.setProgress(100);
|
||||||
|
}else {
|
||||||
|
sci.setStatus(StudyCourseItem.STATUS_STUDYING);
|
||||||
|
sci.setProgress(dto.getProgress());
|
||||||
|
}
|
||||||
|
//sci.setProgress(100);//直接设置为学习完成
|
||||||
|
sci.setFinishTime(ldt);
|
||||||
|
sci.setLastTime(ldt);
|
||||||
|
scItemDao.saveOrUpdate(sci);
|
||||||
|
|
||||||
dto.setStudyItemId(sci.getId());
|
dto.setStudyItemId(sci.getId());
|
||||||
//检查是否全部学习完成
|
//检查是否全部学习完成
|
||||||
scDao.finishCheck(dto.getStudyId(),dto.getCourseId(),dto.getContentTotal());
|
scDao.finishCheck(dto.getStudyId(),dto.getCourseId(),dto.getContentTotal());
|
||||||
@@ -144,8 +156,12 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void updateProcess(String studyContentId,String studyId, String courseId,int total, Integer progress) {
|
public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress) {
|
||||||
scItemDao.updateMultiFieldById(studyContentId, UpdateBuilder.create("progress",progress));
|
int status=StudyCourseItem.STATUS_STUDYING;
|
||||||
|
if(progress.intValue()==100) {
|
||||||
|
status=StudyCourseItem.STATUS_FINISH;
|
||||||
|
}
|
||||||
|
scItemDao.updateMultiFieldById(studyContentId,UpdateBuilder.create("progress",progress),UpdateBuilder.create("status",status));
|
||||||
//检查是否全部学习完成
|
//检查是否全部学习完成
|
||||||
scDao.finishCheck(studyId,courseId,total);
|
scDao.finishCheck(studyId,courseId,total);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user