| | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.context.WebContext; |
| | | import com.ycl.jxkg.domain.entity.EducationResource; |
| | | import com.ycl.jxkg.domain.entity.Subject; |
| | | import com.ycl.jxkg.domain.vo.admin.education.EducationResourceVO; |
| | | import com.ycl.jxkg.domain.vo.student.education.StudentOnlineVO; |
| | | import com.ycl.jxkg.mapper.ClassesUserMapper; |
| | | import com.ycl.jxkg.mapper.EducationResourceMapper; |
| | | import com.ycl.jxkg.mapper.SubjectMapper; |
| | | import com.ycl.jxkg.service.EducationResourceService; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | |
| | | private final EducationResourceMapper mapper; |
| | | private final SubjectMapper subjectMapper; |
| | | private final WebContext webContext; |
| | | private final ClassesUserMapper classesUserMapper; |
| | | |
| | | @Override |
| | | public Result add(EducationResourceVO form) { |
| | |
| | | } |
| | | educationResource.setCreateTime(new Date()); |
| | | educationResource.setUpdateTime(new Date()); |
| | | educationResource.setCreateUser(webContext.getCurrentUser().getId()); |
| | | mapper.add(educationResource); |
| | | return Result.ok("添加成功"); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result byType(StudentOnlineVO query) { |
| | | public Result studentPage(EducationResourceVO query) { |
| | | Integer id = webContext.getCurrentUser().getId(); |
| | | List<Integer> classes = classesUserMapper.getClassesByUserId(id); |
| | | if (CollectionUtils.isEmpty(classes)) { |
| | | //学生没有班级 |
| | | List<EducationResourceVO> list = new ArrayList<>(); |
| | | return Result.ok(list).put("total", 0); |
| | | } |
| | | query.setClassIds(classes); |
| | | PageInfo<EducationResourceVO> page = PageHelper.startPage(query.getPageNum(), query.getPageSize()).doSelectPageInfo(() -> |
| | | mapper.byType(query)); |
| | | mapper.studentPage(query)); |
| | | page.getList().stream().forEach(item -> { |
| | | item.setContentUrl(JSON.parseObject(item.getContentUrlString(), EducationResourceVO.UploadFile.class)); |
| | | item.setAttachment(JSON.parseArray(item.getAttachmentString(), EducationResourceVO.UploadFile.class)); |