New file |
| | |
| | | package com.ycl.jxkg.controller.student; |
| | | |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.vo.admin.education.EducationResourceVO; |
| | | import com.ycl.jxkg.service.EducationResourceService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author:xp |
| | | * @date:2024/5/16 10:58 |
| | | */ |
| | | @RestController("StudentEducationResourceController") |
| | | @RequiredArgsConstructor |
| | | @RequestMapping(value = "/api/student/education/resource") |
| | | public class EducationResourceController { |
| | | |
| | | private final EducationResourceService service; |
| | | |
| | | @GetMapping("/page") |
| | | public Result page(EducationResourceVO query) { |
| | | return service.studentPage(query); |
| | | } |
| | | } |
| | |
| | | /** 所属学科 */ |
| | | private Integer subjectId; |
| | | |
| | | /** 班级 */ |
| | | private Integer classId; |
| | | |
| | | /** 主题简介 */ |
| | | private String introduction; |
| | | |
| | | /** 附件 */ |
| | | private String attachment; |
| | | |
| | | private Integer createUser; |
| | | |
| | | private Date createTime; |
| | | |
| | | private Date updateTime; |
| | |
| | | package com.ycl.jxkg.domain.vo.admin.education; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | |
| | | @NotNull(message = "请选择学科") |
| | | private Integer subjectId; |
| | | |
| | | /** 学科名 */ |
| | | private String typeName; |
| | | |
| | | /** 班级 */ |
| | | @NotNull(message = "请选择班级") |
| | | private Integer classId; |
| | | /** 学生端分页查询条件 */ |
| | | private List<Integer> classIds; |
| | | /** 班级名 */ |
| | | private String className; |
| | | |
| | | /** 主题 */ |
| | | @NotBlank(message = "请输入主题简介") |
| | |
| | | private List<UploadFile> attachment; |
| | | private String attachmentString; |
| | | |
| | | private Integer createUser; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | |
| | | |
| | | List<EducationResourceVO> page(@Param("query") EducationResourceVO query); |
| | | |
| | | List<EducationResourceVO> byType(@Param("query") StudentOnlineVO query); |
| | | List<EducationResourceVO> studentPage(@Param("query") EducationResourceVO query); |
| | | } |
| | |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Result byType(StudentOnlineVO query); |
| | | Result studentPage(EducationResourceVO query); |
| | | |
| | | /** |
| | | * 学习类型list |
| | |
| | | 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)); |
| | |
| | | |
| | | @Override |
| | | public Result updateExamPaper(ExamPaperForm form) { |
| | | //TODO:验证是否是试卷创建人 |
| | | ExamPaper examPaper = ExamPaperForm.getEntityByForm(form, null); |
| | | examPaper.setScore(new BigDecimal(form.getScore())); |
| | | //随机试卷 |
| | |
| | | |
| | | @Override |
| | | public PageInfo<ExamResponseVO> page(ExamPaperPageRequestVO requestVM) { |
| | | //TODO: 数据权限 |
| | | PageInfo<ExamPaper> page = PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() -> |
| | | examPaperMapper.page(requestVM)); |
| | | PageInfo<ExamResponseVO> pageVO = PageInfoHelper.copyMap(page, e -> { |
| | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | |
| | | // 现在只需要保存到一张临时表 |
| | | // 该接口是主动提交,所以状态都设置为完成,以便后续老师阅卷 |
| | | saveTempExam(submitData, ExamSubmitTempStatusEnum.finish); |
| | | |
| | | //TODO:考试状态设定为结束 |
| | | |
| | | return Result.ok(); |
| | | } |
| | | |
| | |
| | | examPaperScoreMapper.updateById(examPaperScore); |
| | | } else { |
| | | examPaperScoreMapper.insert(examPaperScore); |
| | | //修改考试里试卷状态为已阅卷 |
| | | ExamSubmitTemp userExam = new LambdaQueryChainWrapper<>(examSubmitTempMapper) |
| | | .eq(ExamSubmitTemp::getExamId, examPaperMark.getExamId()) |
| | | .eq(ExamSubmitTemp::getUserId, examPaperMark.getUserId()) |
| | | .one(); |
| | | userExam.setMarkPaperStatus(ExamSubmitTempStatusEnum.finish); |
| | | examSubmitTempMapper.updateById(userExam); |
| | | } |
| | | return Result.ok(); |
| | | } |
| | |
| | | ter.create_time, |
| | | ter.update_time, |
| | | ter.attachment as attachmentString, |
| | | ts.name as typeName |
| | | ts.name as typeName, |
| | | ter.class_id, |
| | | tc.class_name |
| | | FROM |
| | | t_education_resource ter |
| | | INNER JOIN t_subject ts ON ts.id = ter.subject_id |
| | | INNER JOIN t_classes tc ON tc.id = ter.class_id |
| | | <where> |
| | | AND ter.deleted = 0 |
| | | <if test="query.introduction != null and query.introduction != ''"> |
| | | AND ter.introduction like concat('%', #{query.subject}, '%') |
| | | AND ter.introduction like concat('%', #{query.introduction}, '%') |
| | | </if> |
| | | <if test="query.subjectId != null"> |
| | | AND ts.id = #{query.subjectId} |
| | | AND ter.subject_id = #{query.subjectId} |
| | | </if> |
| | | <if test="query.classId != null"> |
| | | AND ter.class_id = #{query.classId} |
| | | </if> |
| | | </where> |
| | | ORDER BY |
| | | ter.create_time DESC |
| | | </select> |
| | | |
| | | <select id="byType" resultType="com.ycl.jxkg.domain.vo.admin.education.EducationResourceVO"> |
| | | <select id="studentPage" resultType="com.ycl.jxkg.domain.vo.admin.education.EducationResourceVO"> |
| | | SELECT |
| | | ter.id, |
| | | ter.content_type, |
| | | ter.content_url as contentUrlString, |
| | | ter.subject_id, |
| | | ter.introduction, |
| | | ter.create_time, |
| | | ter.update_time, |
| | | ter.attachment as attachmentString |
| | | ter.id, |
| | | ter.content_type, |
| | | ter.content_url as contentUrlString, |
| | | ter.subject_id, |
| | | ter.introduction, |
| | | ter.create_time, |
| | | ter.update_time, |
| | | ter.attachment as attachmentString, |
| | | ts.name as typeName, |
| | | ter.class_id, |
| | | tc.class_name |
| | | FROM |
| | | t_education_resource ter |
| | | INNER JOIN t_subject ts ON ts.id = ter.subject_id |
| | | t_education_resource ter |
| | | INNER JOIN t_subject ts ON ts.id = ter.subject_id |
| | | INNER JOIN t_classes tc ON tc.id = ter.class_id |
| | | <where> |
| | | AND ter.deleted = 0 |
| | | AND ter.deleted = 0 and ter.class_id in |
| | | <foreach collection="query.classIds" item="classId" separator="," open="(" close=")"> |
| | | #{classId} |
| | | </foreach> |
| | | <if test="query.introduction != null and query.introduction != ''"> |
| | | AND ter.introduction like concat('%', #{query.subject}, '%') |
| | | AND ter.introduction like concat('%', #{query.introduction}, '%') |
| | | </if> |
| | | <if test="query.subjectId != null"> |
| | | AND ts.id = #{query.subjectId} |
| | | AND ter.subject_id = #{query.subjectId} |
| | | </if> |
| | | </where> |
| | | ORDER BY |
| | |
| | | |
| | | <insert id="add" keyColumn="id" useGeneratedKeys="true"> |
| | | INSERT INTO t_education_resource(content_type, content_url, subject_id, introduction, create_time, update_time, |
| | | attachment) |
| | | value (#{form.contentType}, #{form.contentUrl}, #{form.subjectId}, #{form.introduction}, #{form.createTime}, #{form.updateTime}, #{form.attachment}) |
| | | attachment,create_user,class_id) |
| | | value (#{form.contentType}, #{form.contentUrl}, #{form.subjectId}, #{form.introduction}, #{form.createTime}, #{form.updateTime}, #{form.attachment},#{form.createUser},#{form.classId}) |
| | | </insert> |
| | | |
| | | <update id="update"> |
| | |
| | | <if test="form.contentType != null and form.contentType != ''">content_type = #{form.contentType},</if> |
| | | <if test="form.contentUrl != null and form.contentUrl != ''">content_url = #{form.contentUrl},</if> |
| | | <if test="form.subjectId != null">subject_id = #{form.subjectId},</if> |
| | | <if test="form.classId != null">class_id = #{form.classId},</if> |
| | | <if test="form.introduction != null and form.introduction != ''">introduction = #{form.introduction},</if> |
| | | <if test="form.updateTime != null">update_time = #{form.updateTime},</if> |
| | | attachment = #{form.attachment} |