fuliqi
2024-07-03 3303fef314b45020d8ea62a908d887060d695b3f
教学资源增加班级
8个文件已修改
1个文件已添加
132 ■■■■ 已修改文件
src/main/java/com/ycl/jxkg/controller/student/EducationResourceController.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/domain/entity/EducationResource.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/domain/vo/admin/education/EducationResourceVO.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/mapper/EducationResourceMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/service/EducationResourceService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/service/impl/EducationResourceServiceImpl.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/EducationResourceMapper.xml 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/controller/student/EducationResourceController.java
New file
@@ -0,0 +1,28 @@
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);
    }
}
src/main/java/com/ycl/jxkg/domain/entity/EducationResource.java
@@ -23,12 +23,17 @@
    /** 所属学科 */
    private Integer subjectId;
    /** 班级 */
    private Integer classId;
    /** 主题简介 */
    private String introduction;
    /** 附件 */
    private String attachment;
    private Integer createUser;
    private Date createTime;
    private Date updateTime;
src/main/java/com/ycl/jxkg/domain/vo/admin/education/EducationResourceVO.java
@@ -1,6 +1,7 @@
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;
@@ -34,7 +35,16 @@
    @NotNull(message = "请选择学科")
    private Integer subjectId;
    /** 学科名 */
    private String typeName;
    /** 班级 */
    @NotNull(message = "请选择班级")
    private Integer classId;
    /** 学生端分页查询条件 */
    private List<Integer> classIds;
    /** 班级名 */
    private String className;
    /** 主题 */
    @NotBlank(message = "请输入主题简介")
@@ -44,6 +54,8 @@
    private List<UploadFile> attachment;
    private String attachmentString;
    private Integer createUser;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
src/main/java/com/ycl/jxkg/mapper/EducationResourceMapper.java
@@ -23,5 +23,5 @@
    List<EducationResourceVO> page(@Param("query") EducationResourceVO query);
    List<EducationResourceVO> byType(@Param("query") StudentOnlineVO query);
    List<EducationResourceVO> studentPage(@Param("query") EducationResourceVO query);
}
src/main/java/com/ycl/jxkg/service/EducationResourceService.java
@@ -29,7 +29,7 @@
     * @param query
     * @return
     */
    Result byType(StudentOnlineVO query);
    Result studentPage(EducationResourceVO query);
    /**
     * 学习类型list
src/main/java/com/ycl/jxkg/service/impl/EducationResourceServiceImpl.java
@@ -4,10 +4,12 @@
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;
@@ -16,6 +18,7 @@
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;
@@ -30,6 +33,8 @@
    private final EducationResourceMapper mapper;
    private final SubjectMapper subjectMapper;
    private final WebContext webContext;
    private final ClassesUserMapper classesUserMapper;
    @Override
    public Result add(EducationResourceVO form) {
@@ -41,6 +46,7 @@
        }
        educationResource.setCreateTime(new Date());
        educationResource.setUpdateTime(new Date());
        educationResource.setCreateUser(webContext.getCurrentUser().getId());
        mapper.add(educationResource);
        return Result.ok("添加成功");
    }
@@ -80,9 +86,17 @@
    }
    @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));
src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java
@@ -176,6 +176,7 @@
    @Override
    public Result updateExamPaper(ExamPaperForm form) {
        //TODO:验证是否是试卷创建人
        ExamPaper examPaper = ExamPaperForm.getEntityByForm(form, null);
        examPaper.setScore(new BigDecimal(form.getScore()));
        //随机试卷
@@ -198,6 +199,7 @@
    @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 -> {
src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
@@ -2,6 +2,7 @@
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;
@@ -470,9 +471,6 @@
        // 现在只需要保存到一张临时表
        // 该接口是主动提交,所以状态都设置为完成,以便后续老师阅卷
        saveTempExam(submitData, ExamSubmitTempStatusEnum.finish);
        //TODO:考试状态设定为结束
        return Result.ok();
    }
@@ -845,6 +843,13 @@
            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();
    }
src/main/resources/mapper/EducationResourceMapper.xml
@@ -14,43 +14,56 @@
            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
@@ -59,8 +72,8 @@
    <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">
@@ -70,6 +83,7 @@
            <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}