|
@@ -1,19 +1,28 @@
|
|
|
package com.ynfy.app.api.v1.controller;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.ynfy.app.api.v1.annoation.IgnoreAuth;
|
|
|
+import com.ynfy.app.api.v1.util.TokenUtil;
|
|
|
import com.ynfy.buss.banner.service.IBannerService;
|
|
|
import com.ynfy.buss.course.course.service.ICourseService;
|
|
|
+import com.ynfy.buss.exam.exam.entity.Exam;
|
|
|
+import com.ynfy.buss.exam.exam.service.IExamService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.modules.system.entity.SysAnnouncement;
|
|
|
import org.jeecg.modules.system.service.ISysAnnouncementService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/api/v1/index")
|
|
@@ -28,6 +37,11 @@ public class ApiIndexController extends ApiBaseController {
|
|
|
@Autowired
|
|
|
private ICourseService courseService;
|
|
|
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IExamService examService;
|
|
|
+
|
|
|
+ @IgnoreAuth
|
|
|
@PostMapping("/banner/list")
|
|
|
public Result<?> list() {
|
|
|
return Result.OK(bannerService.list());
|
|
@@ -38,6 +52,7 @@ public class ApiIndexController extends ApiBaseController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
+ @IgnoreAuth
|
|
|
@PostMapping("/announcement/list")
|
|
|
public Result<?> announcementList() {
|
|
|
LambdaQueryWrapper<SysAnnouncement> query = new LambdaQueryWrapper<>();
|
|
@@ -50,9 +65,10 @@ public class ApiIndexController extends ApiBaseController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
+ @IgnoreAuth
|
|
|
@GetMapping("/listHotCourse")
|
|
|
- public Result<?> listHotCourse() {
|
|
|
- return Result.OK(courseService.listHotCourse(5));
|
|
|
+ public Result<?> listHotCourse(Integer limit) {
|
|
|
+ return Result.OK(courseService.listHotCourse(limit));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -60,9 +76,15 @@ public class ApiIndexController extends ApiBaseController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
+ @IgnoreAuth
|
|
|
@GetMapping("/listLatestExam")
|
|
|
- public Result<?> listLatestExam() {
|
|
|
- return Result.OK();
|
|
|
+ public Result<?> listLatestExam(Integer limit) {
|
|
|
+ List<Exam> examList = examService.listLatestExam(limit, TokenUtil.getUserId(TokenUtil.getToken(request)));
|
|
|
+ if (!CollectionUtils.isEmpty(examList)) {
|
|
|
+ examList.forEach(item -> item.setAppShowTime(DateUtil.parseDate(DateUtil.formatDate(!Objects.isNull(item.getUpdateTime())
|
|
|
+ ? item.getUpdateTime() : item.getCreateTime()))));
|
|
|
+ }
|
|
|
+ return Result.OK(examList);
|
|
|
}
|
|
|
|
|
|
}
|