|
@@ -1,11 +1,14 @@
|
|
package com.yonge.cooleshow.admin.controller;
|
|
package com.yonge.cooleshow.admin.controller;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.HomeworkAdminSearch;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.HomeworkAdminSearch;
|
|
import com.yonge.cooleshow.biz.dal.entity.StudentCourseHomework;
|
|
import com.yonge.cooleshow.biz.dal.entity.StudentCourseHomework;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.SysUser;
|
|
import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
|
|
import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
|
|
import com.yonge.cooleshow.biz.dal.service.CourseHomeworkService;
|
|
import com.yonge.cooleshow.biz.dal.service.CourseHomeworkService;
|
|
import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
|
|
import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
|
|
import com.yonge.cooleshow.biz.dal.service.StudentCourseHomeworkService;
|
|
import com.yonge.cooleshow.biz.dal.service.StudentCourseHomeworkService;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.service.SysUserService;
|
|
import com.yonge.cooleshow.biz.dal.vo.CourseHomeworkDetailVo;
|
|
import com.yonge.cooleshow.biz.dal.vo.CourseHomeworkDetailVo;
|
|
import com.yonge.cooleshow.biz.dal.vo.CourseHomeworkVo;
|
|
import com.yonge.cooleshow.biz.dal.vo.CourseHomeworkVo;
|
|
import com.yonge.cooleshow.biz.dal.wrapper.HomeworkWrapper;
|
|
import com.yonge.cooleshow.biz.dal.wrapper.HomeworkWrapper;
|
|
@@ -17,6 +20,7 @@ import com.yonge.toolset.mybatis.support.PageUtil;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -24,6 +28,8 @@ import javax.annotation.Resource;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("${app-config.url.admin:}/homework")
|
|
@RequestMapping("${app-config.url.admin:}/homework")
|
|
@@ -38,6 +44,8 @@ public class CourseHomeworkController extends BaseController {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private StudentCourseHomeworkService studentCourseHomeworkService;
|
|
private StudentCourseHomeworkService studentCourseHomeworkService;
|
|
|
|
+ @Resource
|
|
|
|
+ private SysUserService sysUserService;
|
|
|
|
|
|
@ApiOperation(value = "课后作业-列表", httpMethod = "POST", consumes = "application/json", produces = "application/json")
|
|
@ApiOperation(value = "课后作业-列表", httpMethod = "POST", consumes = "application/json", produces = "application/json")
|
|
@PostMapping(value = "/list", consumes = "application/json", produces = "application/json")
|
|
@PostMapping(value = "/list", consumes = "application/json", produces = "application/json")
|
|
@@ -85,7 +93,16 @@ public class CourseHomeworkController extends BaseController {
|
|
@ApiOperation(value = "根据作业编号,获取学员作业列表")
|
|
@ApiOperation(value = "根据作业编号,获取学员作业列表")
|
|
@GetMapping(value = "/studentList")
|
|
@GetMapping(value = "/studentList")
|
|
@PreAuthorize("@pcs.hasPermissions('homework/studentList')")
|
|
@PreAuthorize("@pcs.hasPermissions('homework/studentList')")
|
|
- public HttpResponseResult<List<StudentCourseHomework>> studentList(Long homeworkId) {
|
|
|
|
- return succeed(studentCourseHomeworkService.lambdaQuery().eq(StudentCourseHomework::getCourseHomeworkId, homeworkId).list());
|
|
|
|
|
|
+ public HttpResponseResult<List<HomeworkWrapper.StudentCourseHomeworkDto>> studentList(Long homeworkId) {
|
|
|
|
+ List<StudentCourseHomework> list = studentCourseHomeworkService.lambdaQuery().eq(StudentCourseHomework::getCourseHomeworkId, homeworkId).list();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
|
+ List<HomeworkWrapper.StudentCourseHomeworkDto> dtos = JSON.parseArray(JSON.toJSONString(list), HomeworkWrapper.StudentCourseHomeworkDto.class);
|
|
|
|
+ List<Long> studentIds = dtos.stream().map(StudentCourseHomework::getStudentId).collect(Collectors.toList());
|
|
|
|
+ List<SysUser> sysUsers = sysUserService.getDao().selectBatchIds(studentIds);
|
|
|
|
+ Map<Long, String> nameMap = sysUsers.stream().collect(Collectors.toMap(SysUser::getId, SysUser::getUsername));
|
|
|
|
+ dtos.forEach(e -> e.setUsername(nameMap.get(e.getStudentId())));
|
|
|
|
+ return succeed(dtos);
|
|
|
|
+ }
|
|
|
|
+ return succeed(new ArrayList<>());
|
|
}
|
|
}
|
|
}
|
|
}
|