|
@@ -1,6 +1,7 @@
|
|
|
package com.fs.course.service.impl;
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
@@ -10,24 +11,21 @@ import com.fs.company.domain.CompanyTag;
|
|
|
import com.fs.company.domain.CompanyTagUser;
|
|
|
import com.fs.company.mapper.CompanyTagMapper;
|
|
|
import com.fs.company.mapper.CompanyTagUserMapper;
|
|
|
-import com.fs.course.domain.FsUserCourse;
|
|
|
-import com.fs.course.domain.FsUserCourseStudy;
|
|
|
-import com.fs.course.domain.FsUserCourseStudyLog;
|
|
|
-import com.fs.course.domain.FsUserCourseVideo;
|
|
|
+import com.fs.company.mapper.CompanyUserMapper;
|
|
|
+import com.fs.course.config.CourseConfig;
|
|
|
+import com.fs.course.domain.*;
|
|
|
import com.fs.course.mapper.*;
|
|
|
-import com.fs.course.param.FsUserCourseAddStudyCourseParam;
|
|
|
-import com.fs.course.param.FsUserCourseGetIntegralParam;
|
|
|
-import com.fs.course.param.FsUserCourseListUParam;
|
|
|
-import com.fs.course.param.FsUserCourseParam;
|
|
|
+import com.fs.course.param.*;
|
|
|
import com.fs.course.param.newfs.FsUserCourseListParam;
|
|
|
import com.fs.course.service.IFsUserCourseService;
|
|
|
import com.fs.course.vo.*;
|
|
|
import com.fs.course.vo.newfs.FsUserCourseListVO;
|
|
|
import com.fs.his.vo.OptionsVO;
|
|
|
+import com.fs.system.service.ISysConfigService;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -53,6 +51,15 @@ public class FsUserCourseServiceImpl implements IFsUserCourseService
|
|
|
private FsUserCourseStudyLogMapper fsUserCourseStudyLogMapper;
|
|
|
@Autowired
|
|
|
private CompanyTagMapper companyTagMapper;
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService configService;
|
|
|
+ @Autowired
|
|
|
+ private FsCourseLinkMapper fsCourseLinkMapper;
|
|
|
+ @Autowired
|
|
|
+ private CompanyUserMapper companyUserMapper;
|
|
|
+
|
|
|
+ // todo 链接url需要调整
|
|
|
+ private static final String realLink = "/courseh5/pages/course/learning?course=";
|
|
|
|
|
|
/**
|
|
|
* 查询课程
|
|
@@ -390,4 +397,67 @@ public class FsUserCourseServiceImpl implements IFsUserCourseService
|
|
|
});
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R createCourseSortLink(FsCourseLinkCreateParam param) {
|
|
|
+ String json = configService.selectConfigByKey("course.config");
|
|
|
+ CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
+
|
|
|
+ //新增链接表信息
|
|
|
+ FsCourseLink link = new FsCourseLink();
|
|
|
+ BeanUtils.copyProperties(param, link);
|
|
|
+ link.setLinkType(0);
|
|
|
+ link.setIsRoom(0);
|
|
|
+
|
|
|
+ FsCourseRealLink courseMap = new FsCourseRealLink();
|
|
|
+ BeanUtils.copyProperties(link, courseMap);
|
|
|
+ String courseJson = JSON.toJSONString(courseMap);
|
|
|
+
|
|
|
+ link.setRealLink(realLink + courseJson);
|
|
|
+ link.setLink(generateRandomString());
|
|
|
+ link.setCreateTime(new Date());
|
|
|
+
|
|
|
+ //获取过期时间
|
|
|
+ Calendar calendar = getExpireDay(param, config, link.getCreateTime());
|
|
|
+ link.setUpdateTime(calendar.getTime());
|
|
|
+ int i = fsCourseLinkMapper.insertFsCourseLink(link);
|
|
|
+ if (i > 0){
|
|
|
+ String domainName = getDomainName(param.getCompanyUserId(), config);
|
|
|
+ String sortLink = domainName + "/s/" + link.getLink();
|
|
|
+ return R.ok().put("url", sortLink);
|
|
|
+ }
|
|
|
+ return R.error("生成链接失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ private static Calendar getExpireDay(FsCourseLinkCreateParam param, CourseConfig config, Date createTime) {
|
|
|
+ Integer expireDays;
|
|
|
+ if (param.getDays() == null || param.getDays() == 0){
|
|
|
+ expireDays = config.getVideoLinkExpireDate();
|
|
|
+ }else {
|
|
|
+ expireDays = param.getDays();
|
|
|
+ }
|
|
|
+ // 设置过期时间
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(createTime);
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH, expireDays);
|
|
|
+ return calendar;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成随机的八位数字字母大小写的字符串(改为生成随机不重复的雪花id)
|
|
|
+ */
|
|
|
+ public static String generateRandomString() {
|
|
|
+ return FsCourseLinkServiceImpl.generateRandomString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getDomainName(Long companyUserId, CourseConfig config){
|
|
|
+ String domainName = companyUserMapper.selectDomainByUserId(companyUserId);
|
|
|
+ if (StringUtils.isEmpty(domainName)){
|
|
|
+ domainName = config.getRealLinkDomainName();
|
|
|
+ }
|
|
|
+ return domainName;
|
|
|
+ }
|
|
|
}
|