New file |
| | |
| | | package com.ycl.jxkg.controller.admin; |
| | | |
| | | 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 |
| | | @RequiredArgsConstructor |
| | | @RequestMapping(value = "/api/admin/education/resource") |
| | | public class EducationResourceController { |
| | | |
| | | private final EducationResourceService service; |
| | | |
| | | @PostMapping |
| | | public Result add(@RequestBody @Validated EducationResourceVO form) { |
| | | return service.add(form); |
| | | } |
| | | |
| | | @PostMapping("/edit") |
| | | public Result edit(@RequestBody @Validated EducationResourceVO form) { |
| | | return service.update(form); |
| | | } |
| | | |
| | | @PostMapping("/remove") |
| | | public Result remove(@RequestBody @NotEmpty(message = "请选择要删除的数据") List<Integer> ids) { |
| | | return service.remove(ids); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | public Result page(EducationResourceVO query) { |
| | | return service.page(query); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.domain.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 教育资源 |
| | | * @author:flq |
| | | * @date:2024/6/18 10:53 |
| | | */ |
| | | @Data |
| | | public class EducationResource { |
| | | |
| | | private Integer id; |
| | | |
| | | /** 文件类型 */ |
| | | private String contentType; |
| | | |
| | | /** 文件地址 */ |
| | | private String contentUrl; |
| | | |
| | | /** 所属分类 */ |
| | | private Integer belongType; |
| | | |
| | | /** 主题简介 */ |
| | | private String introduction; |
| | | |
| | | /** 附件 */ |
| | | private String attachment; |
| | | |
| | | private Date createTime; |
| | | |
| | | private Date updateTime; |
| | | |
| | | private Integer deleted; |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.domain.vo.admin.education; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author:flq |
| | | * @date:2024/6/18 10:53 |
| | | */ |
| | | @Data |
| | | public class EducationResourceVO { |
| | | |
| | | private Integer pageSize = 10; |
| | | |
| | | private Integer pageNum = 1; |
| | | |
| | | private Integer id; |
| | | |
| | | /** 文件类型 */ |
| | | @NotBlank(message = "请选择文件类型") |
| | | private String contentType; |
| | | |
| | | /** 文件地址 */ |
| | | @NotNull(message = "请上传文件") |
| | | private UploadFile contentUrl; |
| | | private String contentUrlString; |
| | | |
| | | /** 所属分类 */ |
| | | @NotNull(message = "请选择分类") |
| | | private Integer belongType; |
| | | |
| | | private String typeName; |
| | | |
| | | /** 主题 */ |
| | | @NotBlank(message = "请输入主题简介") |
| | | private String introduction; |
| | | |
| | | /** 附件 */ |
| | | private List<UploadFile> attachment; |
| | | private String attachmentString; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | @Data |
| | | public static class UploadFile { |
| | | |
| | | /** 地址 */ |
| | | private String url; |
| | | |
| | | |
| | | /** 文件原始名 */ |
| | | private String name; |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.domain.vo.student.education; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author:xp |
| | | * @date:2024/5/16 17:54 |
| | | */ |
| | | @Data |
| | | public class StudentOnlineVO { |
| | | |
| | | /** 类别 */ |
| | | private Integer belongType; |
| | | |
| | | /** 主题 */ |
| | | private String subject; |
| | | |
| | | private Integer pageNum = 1; |
| | | |
| | | private Integer pageSize = 10; |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.mapper; |
| | | |
| | | import com.ycl.jxkg.domain.entity.EducationResource; |
| | | import com.ycl.jxkg.domain.vo.admin.education.EducationResourceVO; |
| | | import com.ycl.jxkg.domain.vo.student.education.StudentOnlineVO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author:flq |
| | | * @date:2024/6/18 10:53 |
| | | */ |
| | | @Mapper |
| | | public interface EducationResourceMapper { |
| | | |
| | | void add(@Param("form") EducationResource form); |
| | | |
| | | void update(@Param("form") EducationResource form); |
| | | |
| | | void remove(@Param("ids") List<Integer> ids); |
| | | |
| | | List<EducationResourceVO> page(@Param("query") EducationResourceVO query); |
| | | |
| | | List<EducationResourceVO> byType(@Param("query") StudentOnlineVO query); |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.service; |
| | | |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.vo.admin.education.EducationResourceVO; |
| | | import com.ycl.jxkg.domain.vo.student.education.StudentOnlineVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author:flq |
| | | * @date:2024/6/18 10:53 |
| | | */ |
| | | public interface EducationResourceService { |
| | | |
| | | Result add(EducationResourceVO form); |
| | | |
| | | |
| | | Result update(EducationResourceVO form); |
| | | |
| | | |
| | | Result remove(List<Integer> ids); |
| | | |
| | | |
| | | Result page(EducationResourceVO query); |
| | | |
| | | /** |
| | | * 学生端分页查询 |
| | | * |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Result byType(StudentOnlineVO query); |
| | | |
| | | /** |
| | | * 学习类型list |
| | | * |
| | | * @return |
| | | */ |
| | | Result typeList(); |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.base.Result; |
| | | 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.EducationResourceMapper; |
| | | import com.ycl.jxkg.mapper.SubjectMapper; |
| | | import com.ycl.jxkg.service.EducationResourceService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @author:flq |
| | | * @date:2024/6/18 10:53 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class EducationResourceServiceImpl implements EducationResourceService { |
| | | |
| | | private final EducationResourceMapper mapper; |
| | | private final SubjectMapper subjectMapper; |
| | | |
| | | @Override |
| | | public Result add(EducationResourceVO form) { |
| | | EducationResource educationResource = new EducationResource(); |
| | | BeanUtils.copyProperties(form, educationResource); |
| | | educationResource.setContentUrl(JSON.toJSONString(form.getContentUrl())); |
| | | if (!CollectionUtils.isEmpty(form.getAttachment())) { |
| | | educationResource.setAttachment(JSON.toJSONString(form.getAttachment())); |
| | | } |
| | | educationResource.setCreateTime(new Date()); |
| | | educationResource.setUpdateTime(new Date()); |
| | | mapper.add(educationResource); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result update(EducationResourceVO form) { |
| | | if (Objects.isNull(form.getId())) { |
| | | throw new RuntimeException("请选择要修改的数据"); |
| | | } |
| | | EducationResource educationResource = new EducationResource(); |
| | | BeanUtils.copyProperties(form, educationResource); |
| | | educationResource.setContentUrl(JSON.toJSONString(form.getContentUrl())); |
| | | if (!CollectionUtils.isEmpty(form.getAttachment())) { |
| | | educationResource.setAttachment(JSON.toJSONString(form.getAttachment())); |
| | | } else { |
| | | educationResource.setAttachment(""); |
| | | } |
| | | mapper.update(educationResource); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result remove(List<Integer> ids) { |
| | | mapper.remove(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result page(EducationResourceVO query) { |
| | | PageInfo<EducationResourceVO> page = PageHelper.startPage(query.getPageNum(), query.getPageSize()).doSelectPageInfo(() -> |
| | | mapper.page(query)); |
| | | page.getList().stream().forEach(item -> { |
| | | item.setContentUrl(JSON.parseObject(item.getContentUrlString(), EducationResourceVO.UploadFile.class)); |
| | | item.setAttachment(JSON.parseArray(item.getAttachmentString(), EducationResourceVO.UploadFile.class)); |
| | | }); |
| | | return Result.ok(page.getList()).put("total", page.getTotal()); |
| | | } |
| | | |
| | | @Override |
| | | public Result byType(StudentOnlineVO query) { |
| | | PageInfo<EducationResourceVO> page = PageHelper.startPage(query.getPageNum(), query.getPageSize()).doSelectPageInfo(() -> |
| | | mapper.byType(query)); |
| | | page.getList().stream().forEach(item -> { |
| | | item.setContentUrl(JSON.parseObject(item.getContentUrlString(), EducationResourceVO.UploadFile.class)); |
| | | item.setAttachment(JSON.parseArray(item.getAttachmentString(), EducationResourceVO.UploadFile.class)); |
| | | }); |
| | | return Result.ok(page.getList()).put("total", page.getTotal()); |
| | | } |
| | | |
| | | @Override |
| | | public Result typeList() { |
| | | List<Subject> subjects = subjectMapper.allSubject(); |
| | | return Result.ok(subjects); |
| | | } |
| | | } |
| | |
| | | for (Integer questionType : map.keySet()) { |
| | | //数据库里的这个类型的题目 |
| | | List<Integer> questionIdList = map.get(questionType); |
| | | Result InnerError1 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.SingleChoice.getCode()); |
| | | if (InnerError1 != null) return InnerError1; |
| | | Result InnerError2 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.MultipleChoice.getCode()); |
| | | if (InnerError2 != null) return InnerError2; |
| | | Result InnerError3 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.TrueFalse.getCode()); |
| | | if (InnerError3 != null) return InnerError3; |
| | | Result InnerError4 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.GapFilling.getCode()); |
| | | if (InnerError4 != null) return InnerError4; |
| | | Result InnerError5 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.ShortAnswer.getCode()); |
| | | if (InnerError5 != null) return InnerError5; |
| | | Result InnerError6 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.Audio.getCode()); |
| | | if (InnerError6 != null) return InnerError6; |
| | | Result InnerError7 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.Calculate.getCode()); |
| | | if (InnerError7 != null) return InnerError7; |
| | | Result InnerError8 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.Analysis.getCode()); |
| | | if (InnerError8 != null) return InnerError8; |
| | | Result result = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.fromCode(questionType).getCode()); |
| | | if (result != null) return result; |
| | | } |
| | | examPaper.setContent(JSON.toJSONString(questionTitleList)); |
| | | baseMapper.insert(examPaper); |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ycl.jxkg.mapper.EducationResourceMapper"> |
| | | |
| | | <select id="page" resultType="com.ycl.jxkg.domain.vo.admin.education.EducationResourceVO"> |
| | | SELECT |
| | | ter.id, |
| | | ter.content_type, |
| | | ter.content_url as contentUrlString, |
| | | ter.belong_type, |
| | | ter.introduction, |
| | | ter.create_time, |
| | | ter.update_time, |
| | | ter.attachment as attachmentString, |
| | | ts.name as typeName |
| | | FROM |
| | | t_education_resource ter |
| | | INNER JOIN t_subject ts ON ts.id = ter.belong_type |
| | | <where> |
| | | AND ter.deleted = 0 |
| | | <if test="query.introduction != null and query.introduction != ''"> |
| | | AND ter.introduction like concat('%', #{query.subject}, '%') |
| | | </if> |
| | | <if test="query.belongType != null"> |
| | | AND ts.id = #{query.belongType} |
| | | </if> |
| | | </where> |
| | | ORDER BY |
| | | ter.create_time DESC |
| | | </select> |
| | | |
| | | <select id="byType" resultType="com.ycl.jxkg.domain.vo.admin.education.EducationResourceVO"> |
| | | SELECT |
| | | ter.id, |
| | | ter.content_type, |
| | | ter.content_url as contentUrlString, |
| | | ter.belong_type, |
| | | ter.introduction, |
| | | ter.create_time, |
| | | ter.update_time, |
| | | ter.attachment as attachmentString |
| | | FROM |
| | | t_education_resource ter |
| | | INNER JOIN t_subject ts ON ts.id = tos.belong_type |
| | | <where> |
| | | AND ter.deleted = 0 |
| | | <if test="query.introduction != null and query.introduction != ''"> |
| | | AND ter.introduction like concat('%', #{query.subject}, '%') |
| | | </if> |
| | | <if test="query.belongType != null"> |
| | | AND ts.id = #{query.belongType} |
| | | </if> |
| | | </where> |
| | | ORDER BY |
| | | ter.create_time DESC |
| | | </select> |
| | | |
| | | <insert id="add" keyColumn="id" useGeneratedKeys="true"> |
| | | INSERT INTO t_education_resource(content_type, content_url, belong_type, introduction, create_time, update_time, |
| | | attachment) |
| | | value (#{form.contentType}, #{form.contentUrl}, #{form.belongType}, #{form.introduction}, #{form.createTime}, #{form.updateTime}, #{form.attachment}) |
| | | </insert> |
| | | |
| | | <update id="update"> |
| | | UPDATE |
| | | t_education_resource |
| | | <set> |
| | | <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.belongType != null">belong_type = #{form.belongType},</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} |
| | | </set> |
| | | WHERE |
| | | id = #{form.id} |
| | | </update> |
| | | |
| | | <update id="remove"> |
| | | UPDATE t_education_resource SET deleted = 1 WHERE id IN |
| | | <foreach collection="ids" open="(" separator="," close=")" item="id">#{id}</foreach> |
| | | </update> |
| | | |
| | | |
| | | </mapper> |