New file |
| | |
| | | package com.ycl.jxkg.controller.admin; |
| | | |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.form.ExamTemplateForm; |
| | | import com.ycl.jxkg.domain.query.ExamTemplateQuery; |
| | | import com.ycl.jxkg.group.Add; |
| | | import com.ycl.jxkg.group.Update; |
| | | import com.ycl.jxkg.service.ExamTemplateService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 随机试卷模板 前端控制器 |
| | | * |
| | | * @author 开发人员名字 |
| | | * @since 2024-06-03 |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @Api(value = "随机试卷模板", tags = "随机试卷模板管理") |
| | | @RestController |
| | | @RequestMapping("/exam-template") |
| | | public class ExamTemplateController { |
| | | |
| | | private final ExamTemplateService examTemplateService; |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加", notes = "添加") |
| | | @PreAuthorize("hasAuthority('examTemplate:add')") |
| | | public Result add(@RequestBody @Validated(Add.class) ExamTemplateForm form) { |
| | | return examTemplateService.add(form); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "修改", notes = "修改") |
| | | @PreAuthorize("hasAuthority('examTemplate:edit')") |
| | | public Result update(@RequestBody @Validated(Update.class) ExamTemplateForm form) { |
| | | return examTemplateService.update(form); |
| | | } |
| | | |
| | | @DeleteMapping("/{id}") |
| | | @ApiOperation(value = "ID删除", notes = "ID删除") |
| | | @PreAuthorize("hasAuthority('examTemplate:del')") |
| | | public Result removeById(@PathVariable("id") String id) { |
| | | return examTemplateService.removeById(id); |
| | | } |
| | | |
| | | @DeleteMapping("/batch") |
| | | @ApiOperation(value = "批量删除", notes = "批量删除") |
| | | @PreAuthorize("hasAuthority('examTemplate:del:batch')") |
| | | public Result remove(@RequestBody @NotEmpty(message = "请选择数据") List<String> ids) { |
| | | return examTemplateService.remove(ids); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @ApiOperation(value = "分页", notes = "分页") |
| | | @PreAuthorize("hasAuthority('examTemplate:page')") |
| | | public Result page(ExamTemplateQuery query) { |
| | | return examTemplateService.page(query); |
| | | } |
| | | |
| | | @GetMapping("/{id}") |
| | | @ApiOperation(value = "详情", notes = "详情") |
| | | @PreAuthorize("hasAuthority('examTemplate:detail')") |
| | | public Result detail(@PathVariable("id") Integer id) { |
| | | return examTemplateService.detail(id); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | @PreAuthorize("hasAuthority('examTemplate:list')") |
| | | @ApiOperation(value = "列表", notes = "列表") |
| | | public Result list() { |
| | | return examTemplateService.all(); |
| | | } |
| | | } |
| | |
| | | PaperFilter timeLimitPaperFilter = new PaperFilter(); |
| | | timeLimitPaperFilter.setDateTime(new Date()); |
| | | timeLimitPaperFilter.setGradeLevel(user.getUserLevel()); |
| | | timeLimitPaperFilter.setExamPaperType(ExamPaperTypeEnum.TimeLimit.getCode()); |
| | | timeLimitPaperFilter.setExamPaperType(ExamPaperTypeEnum.Random.getCode()); |
| | | |
| | | List<PaperInfo> limitPaper = examPaperService.indexPaper(timeLimitPaperFilter); |
| | | List<PaperInfoVO> paperInfoVOS = limitPaper.stream().map(d -> { |
| | |
| | | PaperFilter timeLimitPaperFilter = new PaperFilter(); |
| | | timeLimitPaperFilter.setDateTime(new Date()); |
| | | timeLimitPaperFilter.setGradeLevel(user.getUserLevel()); |
| | | timeLimitPaperFilter.setExamPaperType(ExamPaperTypeEnum.TimeLimit.getCode()); |
| | | timeLimitPaperFilter.setExamPaperType(ExamPaperTypeEnum.Random.getCode()); |
| | | |
| | | List<PaperInfo> limitPaper = examPaperService.indexPaper(timeLimitPaperFilter); |
| | | List<PaperInfoVO> paperInfoVOS = limitPaper.stream().map(d -> { |
| | |
| | | private Integer questionCount; |
| | | |
| | | /** |
| | | * 题目分数 |
| | | */ |
| | | @TableField("question_score") |
| | | private Integer questionScore; |
| | | |
| | | /** |
| | | * 建议时长(分钟) |
| | | */ |
| | | @TableField("suggest_time") |
| | |
| | | /** |
| | | * 可见性,公开/私有 |
| | | * */ |
| | | @TableField("visibility") |
| | | private String visibility; |
| | | |
| | | /** |
| | | * 扣分类型 |
| | | * */ |
| | | @TableField("deduct_type") |
| | | private String deductType; |
| | | } |
| | |
| | | @TableName("t_exam_paper_answer") |
| | | public class ExamPaperAnswer extends AbsEntity { |
| | | |
| | | |
| | | @TableField("exam_paper_id") |
| | | private Integer examPaperId; |
| | | |
New file |
| | |
| | | package com.ycl.jxkg.domain.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.ycl.jxkg.domain.base.AbsEntity; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | /** |
| | | * 随机试卷模板表 |
| | | * */ |
| | | @Data |
| | | @TableName("t_exam_template") |
| | | public class ExamTemplate extends AbsEntity { |
| | | /** |
| | | * 模板名 |
| | | * */ |
| | | @TableField("name") |
| | | private String name; |
| | | |
| | | /** |
| | | * 学科 |
| | | * */ |
| | | @TableField("subject_id") |
| | | private Integer subjectId; |
| | | |
| | | /** |
| | | * 建议考试时长 |
| | | * */ |
| | | @TableField("suggest_time") |
| | | private Integer suggestTime; |
| | | |
| | | /** |
| | | * 单选题数量 |
| | | * */ |
| | | @TableField("single_choice") |
| | | private Integer singleChoice; |
| | | |
| | | /** |
| | | * 多选题数量 |
| | | * */ |
| | | @TableField("multiple_choice") |
| | | private Integer multipleChoice; |
| | | |
| | | /** |
| | | * 填空题数量 |
| | | * */ |
| | | @TableField("gap_filling") |
| | | private Integer gapFilling; |
| | | |
| | | /** |
| | | * 判断题数量 |
| | | * */ |
| | | @TableField("true_false") |
| | | private Integer trueFalse; |
| | | |
| | | /** |
| | | * 简答题数量 |
| | | * */ |
| | | @TableField("short_answer") |
| | | private Integer shortAnswer; |
| | | |
| | | /** |
| | | * 计算题数量 |
| | | * */ |
| | | @TableField("calculation") |
| | | private Integer calculation; |
| | | |
| | | /** |
| | | * 总分 |
| | | * */ |
| | | @TableField("score") |
| | | private Integer score; |
| | | |
| | | /** |
| | | * 多选扣分类型 |
| | | * */ |
| | | @TableField("deduct_type") |
| | | private String deductType; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | * */ |
| | | @TableField("create_time") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 创建人 |
| | | * */ |
| | | @TableField("create_user") |
| | | private Integer createUser; |
| | | } |
| | |
| | | package com.ycl.jxkg.domain.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.ycl.jxkg.domain.base.AbsEntity; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | @Data |
New file |
| | |
| | | package com.ycl.jxkg.domain.enums; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public enum DeductTypeEnum { |
| | | |
| | | AllCorrect(1, "答错不得分"), |
| | | PartCorrect(2, "漏选得固定分值,包含错误选项不得分"), |
| | | EachCorrect(3, "每对一题得相应分值,包含错误选项不得分"); |
| | | |
| | | int code; |
| | | String name; |
| | | |
| | | DeductTypeEnum(int code, String name) { |
| | | this.code = code; |
| | | this.name = name; |
| | | } |
| | | |
| | | |
| | | private static final Map<Integer, DeductTypeEnum> keyMap = new HashMap<>(); |
| | | |
| | | static { |
| | | for (DeductTypeEnum item : DeductTypeEnum.values()) { |
| | | keyMap.put(item.getCode(), item); |
| | | } |
| | | } |
| | | |
| | | public static DeductTypeEnum fromCode(Integer code) { |
| | | return keyMap.get(code); |
| | | } |
| | | |
| | | |
| | | public int getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(int code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | public enum ExamPaperTypeEnum { |
| | | |
| | | Fixed(1, "固定试卷"), |
| | | TimeLimit(4, "时段试卷"), |
| | | Task(6, "任务试卷"); |
| | | Random(2, "随机试卷"), |
| | | RandomOrder(3, "随序试卷"); |
| | | |
| | | private final Integer code; |
| | | private final String name; |
New file |
| | |
| | | package com.ycl.jxkg.domain.enums; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public enum VisibilityEnum { |
| | | Private("私有", "只有老师自己能看"), |
| | | Public("公开", "所有人能看"); |
| | | |
| | | String name; |
| | | String description; |
| | | |
| | | VisibilityEnum(String name, String description) { |
| | | this.name = name; |
| | | this.description = description; |
| | | } |
| | | |
| | | public String getDescription() { |
| | | return description; |
| | | } |
| | | |
| | | public void setDescription(String description) { |
| | | this.description = description; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | |
| | | private static final Map<String, VisibilityEnum> keyMap = new HashMap<>(); |
| | | |
| | | static { |
| | | for (VisibilityEnum item : VisibilityEnum.values()) { |
| | | keyMap.put(item.getName(), item); |
| | | } |
| | | } |
| | | |
| | | public static VisibilityEnum fromCode(String name) { |
| | | return keyMap.get(name); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.domain.form; |
| | | |
| | | import com.ycl.jxkg.domain.base.AbsForm; |
| | | import com.ycl.jxkg.domain.entity.ExamTemplate; |
| | | import com.ycl.jxkg.group.Add; |
| | | import com.ycl.jxkg.group.Update; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.lang.NonNull; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * 随机试卷模板表单 |
| | | * |
| | | * @author 开发人员名字 |
| | | * @since 2024-06-03 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "ExamTemplate表单", description = "随机试卷模板表单") |
| | | public class ExamTemplateForm extends AbsForm { |
| | | |
| | | @NotBlank(message = "模板名称不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("模板名称") |
| | | private String name; |
| | | |
| | | @NotNull(message = "试卷科目不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("试卷科目") |
| | | private Integer subjectId; |
| | | |
| | | @NotNull(message = "考试时长(分钟)不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("考试时长(分钟)") |
| | | private Integer suggestTime; |
| | | |
| | | @NotNull(message = "单选题数量不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("单选题数量") |
| | | private Integer singleChoice; |
| | | |
| | | @NotNull(message = "多选题数量不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("多选题数量") |
| | | private Integer multipleChoice; |
| | | |
| | | @NotNull(message = "填空题数量不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("填空题数量") |
| | | private Integer gapFilling; |
| | | |
| | | @NotNull(message = "判断数量不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("判断数量") |
| | | private Integer trueFalse; |
| | | |
| | | @NotNull(message = "简答题数量不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("简答题数量") |
| | | private Integer shortAnswer; |
| | | |
| | | @NotNull(message = "计算题数量不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("计算题数量") |
| | | private Integer calculation; |
| | | |
| | | @NotNull(message = "试卷总分不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("试卷总分") |
| | | private Integer score; |
| | | |
| | | @NotBlank(message = "多选题扣分方式不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("多选题扣分方式") |
| | | private String deductType; |
| | | |
| | | @NotNull(message = "创建人不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("创建人") |
| | | private Integer createUser; |
| | | |
| | | @NotNull(message = "创建时间不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("创建时间") |
| | | private LocalDateTime createTime; |
| | | |
| | | @NotNull(message = "不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("") |
| | | private BigDecimal singleScore; |
| | | |
| | | @NotNull(message = "不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("") |
| | | private BigDecimal multipleScore; |
| | | |
| | | @NotNull(message = "不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("") |
| | | private BigDecimal gapScore; |
| | | |
| | | @NotNull(message = "不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("") |
| | | private BigDecimal trueFalseScore; |
| | | |
| | | @NotNull(message = "不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("") |
| | | private BigDecimal shortAnswerScore; |
| | | |
| | | @NotNull(message = "不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("") |
| | | private BigDecimal calculationScore; |
| | | |
| | | public static ExamTemplate getEntityByForm(@NonNull ExamTemplateForm form, ExamTemplate entity) { |
| | | if(entity == null) { |
| | | entity = new ExamTemplate(); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | return entity; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.domain.query; |
| | | |
| | | import com.ycl.jxkg.domain.base.AbsQuery; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 随机试卷模板查询 |
| | | * |
| | | * @author 开发人员名字 |
| | | * @since 2024-06-03 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "ExamTemplate查询", description = "随机试卷模板查询") |
| | | public class ExamTemplateQuery extends AbsQuery { |
| | | } |
| | | |
New file |
| | |
| | | package com.ycl.jxkg.domain.vo.admin.exam; |
| | | |
| | | import com.ycl.jxkg.domain.base.AbsVo; |
| | | import com.ycl.jxkg.domain.entity.ExamTemplate; |
| | | import lombok.Data; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.lang.NonNull; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 随机试卷模板展示 |
| | | * |
| | | * @author 开发人员名字 |
| | | * @since 2024-06-03 |
| | | */ |
| | | @Data |
| | | public class ExamTemplateVO extends AbsVo { |
| | | |
| | | /** 模板名称 */ |
| | | private String name; |
| | | |
| | | /** 试卷科目 */ |
| | | private Integer subjectId; |
| | | |
| | | /** 考试时长(分钟) */ |
| | | private Integer suggestTime; |
| | | |
| | | /** 单选题数量 */ |
| | | private Integer singleChoice; |
| | | |
| | | /** 多选题数量 */ |
| | | private Integer multipleChoice; |
| | | |
| | | /** 填空题数量 */ |
| | | private Integer gapFilling; |
| | | |
| | | /** 判断数量 */ |
| | | private Integer trueFalse; |
| | | |
| | | /** 简答题数量 */ |
| | | private Integer shortAnswer; |
| | | |
| | | /** 计算题数量 */ |
| | | private Integer calculation; |
| | | |
| | | /** 试卷总分 */ |
| | | private Integer score; |
| | | |
| | | /** 多选题扣分方式 */ |
| | | private String deductType; |
| | | |
| | | /** 创建人 */ |
| | | private Integer createUser; |
| | | |
| | | /** 创建时间 */ |
| | | private Date createTime; |
| | | |
| | | /** */ |
| | | private BigDecimal singleScore; |
| | | |
| | | /** */ |
| | | private BigDecimal multipleScore; |
| | | |
| | | /** */ |
| | | private BigDecimal gapScore; |
| | | |
| | | /** */ |
| | | private BigDecimal trueFalseScore; |
| | | |
| | | /** */ |
| | | private BigDecimal shortAnswerScore; |
| | | |
| | | /** */ |
| | | private BigDecimal calculationScore; |
| | | |
| | | public static ExamTemplateVO getVoByEntity(@NonNull ExamTemplate entity, ExamTemplateVO vo) { |
| | | if(vo == null) { |
| | | vo = new ExamTemplateVO(); |
| | | } |
| | | BeanUtils.copyProperties(entity, vo); |
| | | return vo; |
| | | } |
| | | |
| | | } |
| | |
| | | examPaperQuestionCustomerAnswerService.insertList(examPaperQuestionCustomerAnswers); |
| | | |
| | | switch (ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) { |
| | | case Task: { |
| | | case RandomOrder: { |
| | | examCustomerAnswerService.insertOrUpdate(examPaper, examPaperAnswer, now); |
| | | break; |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ycl.jxkg.domain.entity.ExamTemplate; |
| | | import com.ycl.jxkg.domain.query.ExamTemplateQuery; |
| | | import com.ycl.jxkg.domain.vo.admin.exam.ExamTemplateVO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 随机试卷模板 Mapper 接口 |
| | | * |
| | | * @author 开发人员名字 |
| | | * @since 2024-06-03 |
| | | */ |
| | | @Mapper |
| | | public interface ExamTemplateMapper extends BaseMapper<ExamTemplate> { |
| | | |
| | | /** |
| | | * id查找随机试卷模板 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | ExamTemplateVO getById(Integer id); |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | IPage getPage(IPage page, @Param("query") ExamTemplateQuery query); |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.entity.ExamTemplate; |
| | | import com.ycl.jxkg.domain.form.ExamTemplateForm; |
| | | import com.ycl.jxkg.domain.query.ExamTemplateQuery; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 随机试卷模板 服务类 |
| | | * |
| | | * @author 开发人员名字 |
| | | * @since 2024-06-03 |
| | | */ |
| | | public interface ExamTemplateService extends IService<ExamTemplate> { |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result add(ExamTemplateForm form); |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result update(ExamTemplateForm form); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | Result remove(List<String> ids); |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result removeById(String id); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Result page(ExamTemplateQuery query); |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result detail(Integer id); |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | Result all(); |
| | | } |
| | |
| | | ExamPaper examPaper = examPaperMapper.selectById(examPaperSubmitVO.getId()); |
| | | ExamPaperTypeEnum paperTypeEnum = ExamPaperTypeEnum.fromCode(examPaper.getPaperType()); |
| | | //任务试卷只能做一次 |
| | | if (paperTypeEnum == ExamPaperTypeEnum.Task) { |
| | | if (paperTypeEnum == ExamPaperTypeEnum.RandomOrder) { |
| | | ExamPaperAnswer examPaperAnswer = examPaperAnswerMapper.getByPidUid(examPaperSubmitVO.getId(), user.getId()); |
| | | if (null != examPaperAnswer) |
| | | return null; |
| | |
| | | |
| | | ExamPaperTypeEnum examPaperTypeEnum = ExamPaperTypeEnum.fromCode(examPaperAnswer.getPaperType()); |
| | | switch (examPaperTypeEnum) { |
| | | case Task: |
| | | case RandomOrder: |
| | | //任务试卷批改完成后,需要更新任务的状态 |
| | | ExamPaper examPaper = examPaperMapper.selectById(examPaperAnswer.getExamPaperId()); |
| | | Integer taskId = examPaper.getTaskExamId(); |
| | |
| | | }).collect(Collectors.toList()); |
| | | vo.setTitleItems(examPaperTitleItemVOS); |
| | | vo.setScore(ExamUtil.scoreToVM(examPaper.getScore())); |
| | | if (ExamPaperTypeEnum.TimeLimit == ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) { |
| | | if (ExamPaperTypeEnum.Random == ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) { |
| | | List<String> limitDateTime = Arrays.asList(DateTimeUtil.dateFormat(examPaper.getLimitStartTime()), DateTimeUtil.dateFormat(examPaper.getLimitEndTime())); |
| | | vo.setLimitDateTime(limitDateTime); |
| | | } |
| | |
| | | examPaper.setScore(score); |
| | | examPaper.setGradeLevel(gradeLevel); |
| | | List<String> dateTimes = examPaperEditRequestVO.getLimitDateTime(); |
| | | if (ExamPaperTypeEnum.TimeLimit == ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) { |
| | | if (ExamPaperTypeEnum.Random == ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) { |
| | | examPaper.setLimitStartTime(DateTimeUtil.parse(dateTimes.get(0), DateTimeUtil.STANDER_FORMAT)); |
| | | examPaper.setLimitEndTime(DateTimeUtil.parse(dateTimes.get(1), DateTimeUtil.STANDER_FORMAT)); |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Assert; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.entity.ExamTemplate; |
| | | import com.ycl.jxkg.domain.form.ExamTemplateForm; |
| | | import com.ycl.jxkg.domain.query.ExamTemplateQuery; |
| | | import com.ycl.jxkg.domain.vo.admin.exam.ExamTemplateVO; |
| | | import com.ycl.jxkg.mapper.ExamTemplateMapper; |
| | | import com.ycl.jxkg.service.ExamTemplateService; |
| | | import com.ycl.jxkg.utils.PageUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 随机试卷模板 服务实现类 |
| | | * |
| | | * @author 开发人员名字 |
| | | * @since 2024-06-03 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class ExamTemplateServiceImpl extends ServiceImpl<ExamTemplateMapper, ExamTemplate> implements ExamTemplateService { |
| | | |
| | | private final ExamTemplateMapper examTemplateMapper; |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result add(ExamTemplateForm form) { |
| | | ExamTemplate entity = ExamTemplateForm.getEntityByForm(form, null); |
| | | baseMapper.insert(entity); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result update(ExamTemplateForm form) { |
| | | ExamTemplate entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result remove(List<String> ids) { |
| | | baseMapper.deleteBatchIds(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result removeById(String id) { |
| | | baseMapper.deleteById(id); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result page(ExamTemplateQuery query) { |
| | | IPage<ExamTemplateVO> page = PageUtil.getPage(query, ExamTemplateVO.class); |
| | | baseMapper.getPage(page, query); |
| | | PageInfo<ExamTemplateVO> pageInfo = new PageInfo<>(); |
| | | pageInfo.setList(page.getRecords()); |
| | | pageInfo.setTotal(page.getTotal()); |
| | | return Result.ok(pageInfo); |
| | | } |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result detail(Integer id) { |
| | | ExamTemplateVO vo = baseMapper.getById(id); |
| | | Assert.notNull(vo, "记录不存在"); |
| | | return Result.ok(vo); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result all() { |
| | | List<ExamTemplate> entities = baseMapper.selectList(null); |
| | | List<ExamTemplateVO> vos = entities.stream() |
| | | .map(entity -> ExamTemplateVO.getVoByEntity(entity, null)) |
| | | .collect(Collectors.toList()); |
| | | return Result.ok(vos); |
| | | } |
| | | } |
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.monkeylessey.mapper.ExamTemplateMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.vo.admin.exam.ExamTemplateVO"> |
| | | <result column="name" property="name" /> |
| | | <result column="subject_id" property="subjectId" /> |
| | | <result column="suggest_time" property="suggestTime" /> |
| | | <result column="single_choice" property="singleChoice" /> |
| | | <result column="multiple_choice" property="multipleChoice" /> |
| | | <result column="gap_filling" property="gapFilling" /> |
| | | <result column="true_false" property="trueFalse" /> |
| | | <result column="short_answer" property="shortAnswer" /> |
| | | <result column="calculation" property="calculation" /> |
| | | <result column="score" property="score" /> |
| | | <result column="deduct_type" property="deductType" /> |
| | | <result column="create_user" property="createUser" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="single_score" property="singleScore" /> |
| | | <result column="multiple_score" property="multipleScore" /> |
| | | <result column="gap_score" property="gapScore" /> |
| | | <result column="true_false_score" property="trueFalseScore" /> |
| | | <result column="short_answer_score" property="shortAnswerScore" /> |
| | | <result column="calculation__score" property="calculationScore" /> |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <select id="getById" resultMap="BaseResultMap"> |
| | | SELECT |
| | | TET.name, |
| | | TET.subject_id, |
| | | TET.suggest_time, |
| | | TET.single_choice, |
| | | TET.multiple_choice, |
| | | TET.gap_filling, |
| | | TET.true_false, |
| | | TET.short_answer, |
| | | TET.calculation, |
| | | TET.score, |
| | | TET.deduct_type, |
| | | TET.create_user, |
| | | TET.create_time, |
| | | TET.single_score, |
| | | TET.multiple_score, |
| | | TET.gap_score, |
| | | TET.true_false_score, |
| | | TET.short_answer_score, |
| | | TET.calculation__score, |
| | | TET.id |
| | | FROM |
| | | t_exam_template TET |
| | | WHERE |
| | | TET.id = #{id} AND TET.deleted = 0 |
| | | </select> |
| | | |
| | | |
| | | <select id="getPage" resultMap="BaseResultMap"> |
| | | SELECT |
| | | TET.name, |
| | | TET.subject_id, |
| | | TET.suggest_time, |
| | | TET.single_choice, |
| | | TET.multiple_choice, |
| | | TET.gap_filling, |
| | | TET.true_false, |
| | | TET.short_answer, |
| | | TET.calculation, |
| | | TET.score, |
| | | TET.deduct_type, |
| | | TET.create_user, |
| | | TET.create_time, |
| | | TET.single_score, |
| | | TET.multiple_score, |
| | | TET.gap_score, |
| | | TET.true_false_score, |
| | | TET.short_answer_score, |
| | | TET.calculation__score, |
| | | TET.id |
| | | FROM |
| | | t_exam_template TET |
| | | WHERE |
| | | TET.deleted = 0 |
| | | </select> |
| | | |
| | | </mapper> |