考试报名接口
This commit is contained in:
parent
71197d9677
commit
7a3b651a5d
@ -9,6 +9,7 @@ import com.yf.exam.core.api.dto.BaseIdsReqDTO;
|
||||
import com.yf.exam.core.api.dto.BaseStateReqDTO;
|
||||
import com.yf.exam.core.api.dto.PagingReqDTO;
|
||||
import com.yf.exam.modules.exam.dto.ExamDTO;
|
||||
import com.yf.exam.modules.exam.dto.request.ExamSearchDTO;
|
||||
import com.yf.exam.modules.exam.dto.request.ExamSaveReqDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamOnlineRespDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamReviewRespDTO;
|
||||
@ -154,7 +155,7 @@ public class ExamController extends BaseController {
|
||||
*/
|
||||
@ApiOperation(value = "查询可考试列表")
|
||||
@RequestMapping(value = "/getExamList", method = { RequestMethod.GET})
|
||||
public ApiRest getExamList(ExamDTO reqDTO) {
|
||||
public ApiRest getExamList(ExamSearchDTO reqDTO) {
|
||||
List<ExamDTO> list = baseService.getExamList(reqDTO);
|
||||
return super.success(list);
|
||||
}
|
||||
|
||||
@ -3,10 +3,13 @@ package com.yf.exam.modules.exam.controller;
|
||||
import com.yf.exam.core.api.ApiRest;
|
||||
import com.yf.exam.core.api.controller.BaseController;
|
||||
import com.yf.exam.modules.exam.dto.ExamRegistrationDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamRegistrationVO;
|
||||
import com.yf.exam.modules.exam.service.ExamRegistrationService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@ -37,4 +40,18 @@ public class ExamRegistrationController extends BaseController {
|
||||
baseService.save(reqDTO);
|
||||
return super.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询已报名的考试列表
|
||||
* @param userId 用户主键
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "查询已报名的考试列表")
|
||||
@RequestMapping(value = "/getRegExamList/{userId}", method = { RequestMethod.GET})
|
||||
public ApiRest getExamList(@PathVariable String userId) {
|
||||
ExamRegistrationDTO examRegistrationDTO = new ExamRegistrationDTO();
|
||||
examRegistrationDTO.setUserId(userId);
|
||||
List<ExamRegistrationVO> list = baseService.getRegExamList(examRegistrationDTO);
|
||||
return super.success(list);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package com.yf.exam.modules.exam.dto.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description: 查询考试报名传输对象
|
||||
* @author: haown
|
||||
* @create: 2025-07-14 14:53
|
||||
**/
|
||||
@Data
|
||||
public class ExamRegistrationDTO {
|
||||
|
||||
@ApiModelProperty(value = "用户主键", required=true)
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty(value = "考试表主键", required=true)
|
||||
private String examId;
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.yf.exam.modules.exam.dto.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.time.LocalDate;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* @description: 可报名考试列表查询传输对象
|
||||
* @author: haown
|
||||
* @create: 2025-07-14 14:44
|
||||
**/
|
||||
@Data
|
||||
public class ExamSearchDTO {
|
||||
|
||||
@ApiModelProperty(value = "1公开2部门3定员", required=true)
|
||||
private Integer openType;
|
||||
|
||||
/**
|
||||
* 考试类型(1:模拟考试,2:正式考试)
|
||||
* */
|
||||
@ApiModelProperty(value = "考试类型(1:模拟考试,2:正式考试)", required=true)
|
||||
private Integer examType;
|
||||
|
||||
/**
|
||||
* 开始日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "开始日期", required=true)
|
||||
private LocalDate startDate;
|
||||
|
||||
/**
|
||||
* 结束日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "结束日期", required=true)
|
||||
private LocalDate endDate;
|
||||
|
||||
|
||||
/**
|
||||
* 用户主键
|
||||
* */
|
||||
@ApiModelProperty(value = "用户主键", required=true)
|
||||
private String userId;
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
package com.yf.exam.modules.exam.dto.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* @description: 用户报名返回视图类
|
||||
* @author: haown
|
||||
* @create: 2025-07-14 14:32
|
||||
**/
|
||||
@Data
|
||||
public class ExamRegistrationVO {
|
||||
|
||||
/**
|
||||
* 报名时间
|
||||
*/
|
||||
@ApiModelProperty(value = "报名时间", required=true)
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate regTime;
|
||||
|
||||
/**
|
||||
* 考试状态(0:未考试,1:已考试)
|
||||
*/
|
||||
@ApiModelProperty(value = "考试状态(0:未考试,1:已考试)", required=true)
|
||||
private Integer examState;
|
||||
|
||||
@ApiModelProperty(value = "考试名称", required=true)
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "是否限时", required=true)
|
||||
private Boolean timeLimit;
|
||||
|
||||
/**
|
||||
* 开始日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "开始日期", required=true)
|
||||
private LocalDate startDate;
|
||||
|
||||
/**
|
||||
* 结束日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "结束日期", required=true)
|
||||
private LocalDate endDate;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
|
||||
@DateTimeFormat(pattern = "HH:mm")
|
||||
@ApiModelProperty(value = "开始时间", required=true)
|
||||
private LocalTime startTime;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
|
||||
@DateTimeFormat(pattern = "HH:mm")
|
||||
@ApiModelProperty(value = "结束时间", required=true)
|
||||
private LocalTime endTime;
|
||||
|
||||
@ApiModelProperty(value = "总分数", required=true)
|
||||
private Integer totalScore;
|
||||
|
||||
@ApiModelProperty(value = "总时长(分钟)", required=true)
|
||||
private Integer totalTime;
|
||||
|
||||
@ApiModelProperty(value = "及格分数", required=true)
|
||||
private Integer qualifyScore;
|
||||
|
||||
@ApiModelProperty(value = "考试费用", required=true)
|
||||
private BigDecimal examFee;
|
||||
}
|
||||
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yf.exam.modules.exam.dto.ExamDTO;
|
||||
import com.yf.exam.modules.exam.dto.request.ExamSearchDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamOnlineRespDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamReviewRespDTO;
|
||||
import com.yf.exam.modules.exam.entity.Exam;
|
||||
@ -49,5 +50,5 @@ public interface ExamMapper extends BaseMapper<Exam> {
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<ExamDTO> getExamList(@Param("query") ExamDTO query);
|
||||
List<ExamDTO> getExamList(@Param("query") ExamSearchDTO query);
|
||||
}
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
package com.yf.exam.modules.exam.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yf.exam.modules.exam.dto.ExamRegistrationDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamRegistrationVO;
|
||||
import com.yf.exam.modules.exam.entity.ExamRegistration;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -12,4 +15,6 @@ import com.yf.exam.modules.exam.entity.ExamRegistration;
|
||||
* @since 2025-07-11 10:25
|
||||
*/
|
||||
public interface ExamRegistrationMapper extends BaseMapper<ExamRegistration> {
|
||||
|
||||
List<ExamRegistrationVO> getRegExamList(ExamRegistrationDTO examRegistrationDTO);
|
||||
}
|
||||
|
||||
@ -2,7 +2,9 @@ package com.yf.exam.modules.exam.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yf.exam.modules.exam.dto.ExamRegistrationDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamRegistrationVO;
|
||||
import com.yf.exam.modules.exam.entity.ExamRegistration;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -19,4 +21,13 @@ public interface ExamRegistrationService extends IService<ExamRegistration> {
|
||||
* @param reqDTO
|
||||
*/
|
||||
void save(ExamRegistrationDTO reqDTO);
|
||||
|
||||
/**
|
||||
* @description 查询已报名的考试列表
|
||||
* @Param userId 用户主键
|
||||
* @return null
|
||||
* @Author haown
|
||||
* @Date 2025-7-14 10:45
|
||||
*/
|
||||
List<ExamRegistrationVO> getRegExamList(ExamRegistrationDTO examRegistrationDTO);
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yf.exam.core.api.dto.PagingReqDTO;
|
||||
import com.yf.exam.modules.exam.dto.ExamDTO;
|
||||
import com.yf.exam.modules.exam.dto.request.ExamSearchDTO;
|
||||
import com.yf.exam.modules.exam.dto.request.ExamSaveReqDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamOnlineRespDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamReviewRespDTO;
|
||||
@ -68,6 +69,6 @@ public interface ExamService extends IService<Exam> {
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
List<ExamDTO> getExamList(ExamDTO reqDTO);
|
||||
List<ExamDTO> getExamList(ExamSearchDTO reqDTO);
|
||||
|
||||
}
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
package com.yf.exam.modules.exam.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yf.exam.core.exception.ServiceException;
|
||||
import com.yf.exam.modules.exam.dto.ExamRegistrationDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamRegistrationVO;
|
||||
import com.yf.exam.modules.exam.entity.ExamRegistration;
|
||||
import com.yf.exam.modules.exam.mapper.ExamRegistrationMapper;
|
||||
import com.yf.exam.modules.exam.service.ExamRegistrationService;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -20,6 +24,20 @@ public class ExamRegistrationServiceImpl extends ServiceImpl<ExamRegistrationMap
|
||||
|
||||
@Override
|
||||
public void save(ExamRegistrationDTO reqDTO) {
|
||||
if (StringUtils.isBlank(reqDTO.getUserId())) {
|
||||
throw new ServiceException("传输数据错误,请重新报名");
|
||||
}
|
||||
if (StringUtils.isBlank(reqDTO.getExamId())) {
|
||||
throw new ServiceException("请选择要报名的考试");
|
||||
}
|
||||
// 查询考生是否报名过该考试
|
||||
ExamRegistrationDTO examRegistrationDTO = new ExamRegistrationDTO();
|
||||
examRegistrationDTO.setExamId(reqDTO.getExamId());
|
||||
examRegistrationDTO.setUserId(reqDTO.getUserId());
|
||||
List<ExamRegistrationVO> list = getRegExamList(examRegistrationDTO);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
throw new ServiceException("您已报名过该考试,请勿重复报名");
|
||||
}
|
||||
// ID
|
||||
String id = reqDTO.getId();
|
||||
|
||||
@ -33,6 +51,12 @@ public class ExamRegistrationServiceImpl extends ServiceImpl<ExamRegistrationMap
|
||||
// 复制基本数据
|
||||
BeanUtils.copyProperties(reqDTO, entity);
|
||||
entity.setId(id);
|
||||
entity.setExamState(0);
|
||||
this.saveOrUpdate(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExamRegistrationVO> getRegExamList(ExamRegistrationDTO examRegistrationDTO) {
|
||||
return baseMapper.getRegExamList(examRegistrationDTO);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import com.yf.exam.core.exception.ServiceException;
|
||||
import com.yf.exam.core.utils.BeanMapper;
|
||||
import com.yf.exam.modules.exam.dto.ExamDTO;
|
||||
import com.yf.exam.modules.exam.dto.ExamRepoDTO;
|
||||
import com.yf.exam.modules.exam.dto.request.ExamSearchDTO;
|
||||
import com.yf.exam.modules.exam.dto.ext.ExamRepoExtDTO;
|
||||
import com.yf.exam.modules.exam.dto.request.ExamSaveReqDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamOnlineRespDTO;
|
||||
@ -20,14 +21,13 @@ import com.yf.exam.modules.exam.service.ExamDepartService;
|
||||
import com.yf.exam.modules.exam.service.ExamRepoService;
|
||||
import com.yf.exam.modules.exam.service.ExamService;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 考试业务实现类
|
||||
@ -98,7 +98,8 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements Ex
|
||||
public ExamSaveReqDTO findDetail(String id) {
|
||||
ExamSaveReqDTO respDTO = new ExamSaveReqDTO();
|
||||
Exam exam = this.getById(id);
|
||||
BeanMapper.copy(exam, respDTO);
|
||||
//BeanMapper.copy(exam, respDTO);
|
||||
BeanUtils.copyProperties(exam, respDTO);
|
||||
|
||||
// 考试部门
|
||||
List<String> departIds = examDepartService.listByExam(id);
|
||||
@ -159,8 +160,8 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements Ex
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
@Override public List<ExamDTO> getExamList(ExamDTO reqDTO) {
|
||||
reqDTO.setExamType(2);
|
||||
@Override
|
||||
public List<ExamDTO> getExamList(ExamSearchDTO reqDTO) {
|
||||
reqDTO.setStartDate(LocalDate.now());
|
||||
List<ExamDTO> list = baseMapper.getExamList(reqDTO);
|
||||
return list;
|
||||
|
||||
@ -51,6 +51,9 @@
|
||||
<if test="query.openType!=null">
|
||||
AND open_type = #{query.openType}
|
||||
</if>
|
||||
<if test="query.examType!=null">
|
||||
AND exam_type = #{query.examType}
|
||||
</if>
|
||||
<if test="query.startDate!=null">
|
||||
AND start_date >= #{query.startDate}
|
||||
</if>
|
||||
@ -86,10 +89,12 @@
|
||||
<if test="query.title!=null and query.title!=''">
|
||||
AND ex.title LIKE CONCAT('%',#{query.title},'%')
|
||||
</if>
|
||||
|
||||
<if test="query.openType!=null">
|
||||
AND ex.open_type=#{query.openType}
|
||||
</if>
|
||||
<if test="query.examType!=null">
|
||||
AND ex.exam_type=#{query.examType}
|
||||
</if>
|
||||
</if>
|
||||
|
||||
|
||||
@ -97,11 +102,8 @@
|
||||
|
||||
<select id="getExamList" resultMap="OnlineResultMap">
|
||||
SELECT * FROM el_exam
|
||||
where state = 0
|
||||
where state = 0 and id not in (select exam_id from el_exam_registration where user_id = #{query.userId})
|
||||
<if test="query!=null">
|
||||
<if test="query.title!=null and query.title!=''">
|
||||
AND title LIKE CONCAT('%',#{query.title},'%')
|
||||
</if>
|
||||
<if test="query.openType!=null">
|
||||
AND open_type = #{query.openType}
|
||||
</if>
|
||||
|
||||
@ -41,4 +41,18 @@
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="getRegExamList" resultType="com.yf.exam.modules.exam.dto.response.ExamRegistrationVO">
|
||||
SELECT reg.reg_time, reg.exam_state, ex.title, ex.start_date, ex.end_date, ex.start_time, ex.end_time
|
||||
,ex.total_score, ex.total_time, ex.qualify_score, ex.exam_fee
|
||||
FROM el_exam_registration reg
|
||||
left join el_exam ex on reg.exam_id = ex.id
|
||||
WHERE ex.state=0
|
||||
<if test="userId!=null">
|
||||
AND reg.user_id=#{userId}
|
||||
</if>
|
||||
<if test="examId!=null">
|
||||
AND reg.exam_id=#{examId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -51,6 +51,9 @@
|
||||
<if test="query.openType!=null">
|
||||
AND open_type = #{query.openType}
|
||||
</if>
|
||||
<if test="query.examType!=null">
|
||||
AND exam_type = #{query.examType}
|
||||
</if>
|
||||
<if test="query.startDate!=null">
|
||||
AND start_date >= #{query.startDate}
|
||||
</if>
|
||||
@ -86,10 +89,12 @@
|
||||
<if test="query.title!=null and query.title!=''">
|
||||
AND ex.title LIKE CONCAT('%',#{query.title},'%')
|
||||
</if>
|
||||
|
||||
<if test="query.openType!=null">
|
||||
AND ex.open_type=#{query.openType}
|
||||
</if>
|
||||
<if test="query.examType!=null">
|
||||
AND ex.exam_type=#{query.examType}
|
||||
</if>
|
||||
</if>
|
||||
|
||||
|
||||
@ -97,11 +102,8 @@
|
||||
|
||||
<select id="getExamList" resultMap="OnlineResultMap">
|
||||
SELECT * FROM el_exam
|
||||
where state = 0
|
||||
where state = 0 and id not in (select exam_id from el_exam_registration where user_id = #{query.userId})
|
||||
<if test="query!=null">
|
||||
<if test="query.title!=null and query.title!=''">
|
||||
AND title LIKE CONCAT('%',#{query.title},'%')
|
||||
</if>
|
||||
<if test="query.openType!=null">
|
||||
AND open_type = #{query.openType}
|
||||
</if>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user