|
@@ -4,9 +4,12 @@ import cn.rankin.apiweb.assist.resolver.NeedUser;
|
|
|
import cn.rankin.apiweb.code.ApiWebCode;
|
|
|
import cn.rankin.apiweb.service.download.DownloadInfoService;
|
|
|
import cn.rankin.apiweb.service.event.EventService;
|
|
|
+import cn.rankin.apiweb.service.product.ProductService;
|
|
|
import cn.rankin.common.utils.api.model.APICode;
|
|
|
import cn.rankin.common.utils.api.model.APIResult;
|
|
|
import cn.rankin.data.api.app.vo.DeviceUserVo;
|
|
|
+import cn.rankin.data.api.product.entity.Course;
|
|
|
+import cn.rankin.data.api.product.entity.Lesson;
|
|
|
import cn.rankin.data.api.user.dto.DownloadInfoDTO;
|
|
|
import cn.rankin.data.api.user.dto.EventLogDTO;
|
|
|
import cn.rankin.data.api.user.entity.DownloadInfo;
|
|
@@ -34,6 +37,9 @@ public class CallbackController {
|
|
|
@Autowired
|
|
|
private DownloadInfoService downloadInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProductService productService;
|
|
|
+
|
|
|
@RequestMapping(value = "/event", method = RequestMethod.POST)
|
|
|
public APIResult<Boolean> addEvent(@NeedUser DeviceUserVo user, @RequestBody EventLogDTO eventLog) {
|
|
|
if (eventLog.getEventType() == null ) {
|
|
@@ -48,7 +54,10 @@ public class CallbackController {
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/download/add", method = RequestMethod.POST)
|
|
|
- public APIResult<Boolean> addDownloadInfo(HttpServletRequest request, @NeedUser DeviceUserVo user,@RequestParam("lessonId") String lessonId , @RequestParam("data") String data) {
|
|
|
+ public APIResult<Boolean> addDownloadInfo(HttpServletRequest request, @NeedUser DeviceUserVo user ,
|
|
|
+ @RequestParam("courseId") String courseId,
|
|
|
+ @RequestParam("lessonId") String lessonId,
|
|
|
+ @RequestParam("data") String data) {
|
|
|
|
|
|
|
|
|
|
|
@@ -68,23 +77,46 @@ public class CallbackController {
|
|
|
String localName = request.getLocalName();//获取WEB服务器的主机名
|
|
|
String device = request.getHeader("User-Agent");
|
|
|
|
|
|
-
|
|
|
+ log.info("device={}",device);
|
|
|
|
|
|
DownloadInfoDTO dto = new DownloadInfoDTO();
|
|
|
|
|
|
if(StringUtils.isBlank(lessonId)){
|
|
|
return APIResult.error(ApiWebCode.PARAMETER_ERROR);
|
|
|
+ }else{
|
|
|
+ Lesson lesson = productService.getLesson(lessonId, courseId).getData();
|
|
|
+ if(null == lesson){
|
|
|
+ log.info("not found lesson by id ,lessonId={}",lessonId);
|
|
|
+ return APIResult.error(ApiWebCode.PARAMETER_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ dto.setLessonId(lessonId);
|
|
|
+ dto.setLessonName(lesson.getTitle());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(courseId)){
|
|
|
+ return APIResult.error(ApiWebCode.PARAMETER_ERROR);
|
|
|
+ }else{
|
|
|
+ Course course = productService.getCourse(courseId);
|
|
|
+ if(null == course){
|
|
|
+ log.info("not found course by id ,courseId={}",courseId);
|
|
|
+ return APIResult.error(ApiWebCode.PARAMETER_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ dto.setCourseId(courseId);
|
|
|
+ dto.setCourseName(course.getTitle());
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(data)){
|
|
|
dto.setData(data);
|
|
|
}
|
|
|
|
|
|
- dto.setLessonId(lessonId);
|
|
|
dto.setMerchantId(user.getMerchantId());
|
|
|
dto.setUserId(user.getUid());
|
|
|
dto.setDeviceType(device);
|
|
|
|
|
|
-
|
|
|
DownloadInfo downloadInfo = downloadInfoService.add(dto);
|
|
|
if(downloadInfo != null){
|
|
|
return APIResult.ok();
|