Add .gitignore file and remove ignored files from git
This commit is contained in:
@@ -1,100 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.controller.admin;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
import pc.exam.pp.module.judgement.controller.admin.vo.JudgementPageReqVO;
|
||||
import pc.exam.pp.module.judgement.dal.dataobject.JudgementDO;
|
||||
import pc.exam.pp.module.judgement.service.JudgementService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static pc.exam.pp.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 管理后台 - 判题信息
|
||||
*
|
||||
* @author pengchen
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/judgement")
|
||||
public class JudgementController {
|
||||
|
||||
@Resource
|
||||
private JudgementService judgementService;
|
||||
|
||||
/**
|
||||
* 创建判题
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 判题编号
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
public CommonResult<Long> createJudgement(@Valid @RequestBody JudgementDO createReqVO) {
|
||||
return success(judgementService.createJudgement(createReqVO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新判题
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
* @return 成功状态
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public CommonResult<Boolean> updateJudgement(@Valid @RequestBody JudgementDO updateReqVO) {
|
||||
judgementService.updateJudgement(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除判题
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 成功状态
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
public CommonResult<Boolean> deleteJudgement(@RequestParam("id") Long id) {
|
||||
judgementService.deleteJudgement(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得判题
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 判题
|
||||
*/
|
||||
@GetMapping("/get")
|
||||
public CommonResult<JudgementDO> getJudgement(@RequestParam("id") Long id) {
|
||||
return success(judgementService.getJudgement(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得判题分页
|
||||
*
|
||||
* @param pageVO 分页查询
|
||||
* @return 判题分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public CommonResult<PageResult<JudgementDO>> getJudgementPage(@Valid JudgementPageReqVO pageVO) {
|
||||
return success(judgementService.getJudgementPage(pageVO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户在某次考试的所有判题结果
|
||||
*
|
||||
* @param examId 考试ID
|
||||
* @param userId 用户ID
|
||||
* @return 判题列表
|
||||
*/
|
||||
@GetMapping("/list-by-exam-and-user")
|
||||
public CommonResult<List<JudgementDO>> getJudgementListByExamAndUser(
|
||||
@RequestParam("examId") Long examId,
|
||||
@RequestParam("userId") Long userId) {
|
||||
return success(judgementService.getJudgementListByExamAndUser(examId, userId));
|
||||
}
|
||||
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.controller.admin.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import pc.exam.pp.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static pc.exam.pp.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 判题分页查询 Request VO
|
||||
*
|
||||
* @author pengchen
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class JudgementPageReqVO extends PageParam {
|
||||
|
||||
/**
|
||||
* 考试ID
|
||||
*/
|
||||
private Long examId;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 题目ID
|
||||
*/
|
||||
private Long questionId;
|
||||
|
||||
/**
|
||||
* 判题结果
|
||||
*/
|
||||
private Integer result;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.dal.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import pc.exam.pp.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 判题信息 DO
|
||||
*
|
||||
* @author pengchen
|
||||
*/
|
||||
@TableName("judgement")
|
||||
@KeySequence("judgement_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class JudgementDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 考试ID
|
||||
*/
|
||||
private Long examId;
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 题目ID
|
||||
*/
|
||||
private Long questionId;
|
||||
/**
|
||||
* 用户答案
|
||||
*/
|
||||
private String userAnswer;
|
||||
/**
|
||||
* 判题结果
|
||||
*
|
||||
* 枚举 {@link JudgementResultEnum}
|
||||
*/
|
||||
private Integer result;
|
||||
/**
|
||||
* 得分
|
||||
*/
|
||||
private Integer score;
|
||||
/**
|
||||
* 判题时间
|
||||
*/
|
||||
private LocalDateTime judgementTime;
|
||||
/**
|
||||
* 判题详情
|
||||
*/
|
||||
private String detail;
|
||||
/**
|
||||
* 判题类型
|
||||
*/
|
||||
private Integer type;
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.dal.dataobject;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 判题结果枚举
|
||||
*
|
||||
* @author pengchen
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum JudgementResultEnum {
|
||||
|
||||
PENDING(0, "待判题"),
|
||||
CORRECT(1, "正确"),
|
||||
PARTIALLY_CORRECT(2, "部分正确"),
|
||||
INCORRECT(3, "错误"),
|
||||
ERROR(4, "判题出错");
|
||||
|
||||
/**
|
||||
* 结果值
|
||||
*/
|
||||
private final Integer result;
|
||||
/**
|
||||
* 结果名
|
||||
*/
|
||||
private final String name;
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.dal.mysql;
|
||||
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import pc.exam.pp.module.judgement.controller.admin.vo.JudgementPageReqVO;
|
||||
import pc.exam.pp.module.judgement.dal.dataobject.JudgementDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 判题信息 Mapper
|
||||
*
|
||||
* @author pengchen
|
||||
*/
|
||||
@Mapper
|
||||
public interface JudgementMapper extends BaseMapperX<JudgementDO> {
|
||||
|
||||
default PageResult<JudgementDO> selectPage(JudgementPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<JudgementDO>()
|
||||
.eqIfPresent(JudgementDO::getExamId, reqVO.getExamId())
|
||||
.eqIfPresent(JudgementDO::getUserId, reqVO.getUserId())
|
||||
.eqIfPresent(JudgementDO::getQuestionId, reqVO.getQuestionId())
|
||||
.eqIfPresent(JudgementDO::getResult, reqVO.getResult())
|
||||
.betweenIfPresent(JudgementDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(JudgementDO::getId));
|
||||
}
|
||||
|
||||
default List<JudgementDO> selectListByExamIdAndUserId(Long examId, Long userId) {
|
||||
return selectList(new LambdaQueryWrapperX<JudgementDO>()
|
||||
.eq(JudgementDO::getExamId, examId)
|
||||
.eq(JudgementDO::getUserId, userId));
|
||||
}
|
||||
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.service;
|
||||
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
import pc.exam.pp.module.judgement.controller.admin.vo.JudgementPageReqVO;
|
||||
import pc.exam.pp.module.judgement.dal.dataobject.JudgementDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 判题信息 Service 接口
|
||||
*
|
||||
* @author pengchen
|
||||
*/
|
||||
public interface JudgementService {
|
||||
|
||||
/**
|
||||
* 创建判题
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createJudgement(@Valid JudgementDO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新判题
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateJudgement(@Valid JudgementDO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除判题
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteJudgement(Long id);
|
||||
|
||||
/**
|
||||
* 获得判题
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 判题
|
||||
*/
|
||||
JudgementDO getJudgement(Long id);
|
||||
|
||||
/**
|
||||
* 获得判题列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 判题列表
|
||||
*/
|
||||
List<JudgementDO> getJudgementList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得判题分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 判题分页
|
||||
*/
|
||||
PageResult<JudgementDO> getJudgementPage(JudgementPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获取用户在某次考试的所有判题结果
|
||||
*
|
||||
* @param examId 考试ID
|
||||
* @param userId 用户ID
|
||||
* @return 判题列表
|
||||
*/
|
||||
List<JudgementDO> getJudgementListByExamAndUser(Long examId, Long userId);
|
||||
|
||||
}
|
@@ -1,77 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import pc.exam.pp.framework.common.pojo.PageResult;
|
||||
import pc.exam.pp.module.judgement.controller.admin.vo.JudgementPageReqVO;
|
||||
import pc.exam.pp.module.judgement.dal.dataobject.JudgementDO;
|
||||
import pc.exam.pp.module.judgement.dal.mysql.JudgementMapper;
|
||||
import pc.exam.pp.module.judgement.service.JudgementService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 判题信息 Service 实现类
|
||||
*
|
||||
* @author pengchen
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class JudgementServiceImpl implements JudgementService {
|
||||
|
||||
@Resource
|
||||
private JudgementMapper judgementMapper;
|
||||
|
||||
@Override
|
||||
public Long createJudgement(JudgementDO createReqVO) {
|
||||
// 插入
|
||||
judgementMapper.insert(createReqVO);
|
||||
// 返回
|
||||
return createReqVO.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateJudgement(JudgementDO updateReqVO) {
|
||||
// 校验存在
|
||||
validateJudgementExists(updateReqVO.getId());
|
||||
// 更新
|
||||
judgementMapper.updateById(updateReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteJudgement(Long id) {
|
||||
// 校验存在
|
||||
validateJudgementExists(id);
|
||||
// 删除
|
||||
judgementMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateJudgementExists(Long id) {
|
||||
if (judgementMapper.selectById(id) == null) {
|
||||
throw new RuntimeException("判题不存在");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JudgementDO getJudgement(Long id) {
|
||||
return judgementMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JudgementDO> getJudgementList(Collection<Long> ids) {
|
||||
return judgementMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<JudgementDO> getJudgementPage(JudgementPageReqVO pageReqVO) {
|
||||
return judgementMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JudgementDO> getJudgementListByExamAndUser(Long examId, Long userId) {
|
||||
return judgementMapper.selectListByExamIdAndUserId(examId, userId);
|
||||
}
|
||||
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
<?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="pc.exam.pp.module.judgement.dal.mysql.JudgementMapper">
|
||||
|
||||
<resultMap id="judgementResultMap" type="pc.exam.pp.module.judgement.dal.dataobject.JudgementDO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="examId" column="exam_id"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="questionId" column="question_id"/>
|
||||
<result property="userAnswer" column="user_answer"/>
|
||||
<result property="result" column="result"/>
|
||||
<result property="score" column="score"/>
|
||||
<result property="judgementTime" column="judgement_time"/>
|
||||
<result property="detail" column="detail"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="creator" column="creator"/>
|
||||
<result property="updater" column="updater"/>
|
||||
<result property="deleted" column="deleted"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user