Skip to content

Commit cc57794

Browse files
authored
Merge pull request #95 from Boyuan-IT-Club/Red_Moon
让查询简历支持形如"1,2,3"的状态查询
2 parents d02f944 + de9ad29 commit cc57794

File tree

5 files changed

+49
-19
lines changed

5 files changed

+49
-19
lines changed

src/main/java/club/boyuan/official/controller/ResumeController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ public ResponseEntity<ResponseMessage<?>> queryResumes(
813813
@RequestParam(required = false) String name,
814814
@RequestParam(required = false) String major,
815815
@RequestParam(required = false) Integer cycleId,
816-
@RequestParam(required = false) Integer status,
816+
@RequestParam(required = false) String status,
817817
@RequestParam(required = false, defaultValue = "0") Integer page,
818818
@RequestParam(required = false, defaultValue = "10") Integer size,
819819
HttpServletRequest request) {

src/main/java/club/boyuan/official/mapper/ResumeMapper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,30 @@ public interface ResumeMapper {
7171
* @param name 姓名(可选)
7272
* @param major 专业(可选)
7373
* @param cycleId 年份ID(可选)
74-
* @param status 简历状态(可选)
74+
* @param status 简历状态(可选),支持多个状态,用逗号分隔,如"2,3,4,5"
7575
* @return 简历列表
7676
*/
77-
List<Resume> queryResumes(@Param("name") String name, @Param("major") String major, @Param("cycleId") Integer cycleId, @Param("status") Integer status);
77+
List<Resume> queryResumes(@Param("name") String name, @Param("major") String major, @Param("cycleId") Integer cycleId, @Param("status") String status);
7878

7979
/**
8080
* 多条件查询简历列表(分页)
8181
* @param name 姓名(可选)
8282
* @param major 专业(可选)
8383
* @param cycleId 年份ID(可选)
84-
* @param status 简历状态(可选)
84+
* @param status 简历状态(可选),支持多个状态,用逗号分隔,如"2,3,4,5"
8585
* @param offset 偏移量
8686
* @param limit 限制数量
8787
* @return 简历列表
8888
*/
89-
List<Resume> queryResumesWithPagination(@Param("name") String name, @Param("major") String major, @Param("cycleId") Integer cycleId, @Param("status") Integer status, @Param("offset") int offset, @Param("limit") int limit);
89+
List<Resume> queryResumesWithPagination(@Param("name") String name, @Param("major") String major, @Param("cycleId") Integer cycleId, @Param("status") String status, @Param("offset") int offset, @Param("limit") int limit);
9090

9191
/**
9292
* 统计多条件查询简历数量
9393
* @param name 姓名(可选)
9494
* @param major 专业(可选)
9595
* @param cycleId 年份ID(可选)
96-
* @param status 简历状态(可选)
96+
* @param status 简历状态(可选),支持多个状态,用逗号分隔,如"2,3,4,5"
9797
* @return 简历数量
9898
*/
99-
int countResumes(@Param("name") String name, @Param("major") String major, @Param("cycleId") Integer cycleId, @Param("status") Integer status);
99+
int countResumes(@Param("name") String name, @Param("major") String major, @Param("cycleId") Integer cycleId, @Param("status") String status);
100100
}

src/main/java/club/boyuan/official/service/IResumeService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,22 @@ public interface IResumeService {
103103
* @param name 姓名(可选)
104104
* @param major 专业(可选)
105105
* @param cycleId 年份ID(可选)
106-
* @param status 简历状态(可选)
106+
* @param status 简历状态(可选),支持多个状态,用逗号分隔,如"2,3,4,5"
107107
* @return 简历DTO列表
108108
*/
109-
List<ResumeDTO> queryResumes(String name, String major, Integer cycleId, Integer status);
109+
List<ResumeDTO> queryResumes(String name, String major, Integer cycleId, String status);
110110

111111
/**
112112
* 条件查询简历列表(分页)
113113
* @param name 姓名(可选)
114114
* @param major 专业(可选)
115115
* @param cycleId 年份ID(可选)
116-
* @param status 简历状态(可选)
116+
* @param status 简历状态(可选),支持多个状态,用逗号分隔,如"2,3,4,5"
117117
* @param page 页码(从0开始)
118118
* @param size 每页大小
119119
* @return 分页结果DTO
120120
*/
121-
PageResultDTO<ResumeDTO> queryResumesWithPagination(String name, String major, Integer cycleId, Integer status, int page, int size);
121+
PageResultDTO<ResumeDTO> queryResumesWithPagination(String name, String major, Integer cycleId, String status, int page, int size);
122122

123123
/**
124124
* 根据cycleId获取所有简历

src/main/java/club/boyuan/official/service/impl/ResumeServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public List<ResumeFieldValueDTO> getFieldValuesWithDefinitionsByResumeId(Integer
244244
}
245245

246246
@Override
247-
public List<ResumeDTO> queryResumes(String name, String major, Integer cycleId, Integer status) {
247+
public List<ResumeDTO> queryResumes(String name, String major, Integer cycleId, String status) {
248248
logger.info("条件查询简历:name={}, major={}, cycleId={}, status={}", name, major, cycleId, status);
249249
// 构建缓存键
250250
String cacheKey = QUERY_RESUME_CACHE_PREFIX + "name:" + (name != null ? name : "")
@@ -290,7 +290,7 @@ public List<ResumeDTO> queryResumes(String name, String major, Integer cycleId,
290290
}
291291

292292
@Override
293-
public PageResultDTO<ResumeDTO> queryResumesWithPagination(String name, String major, Integer cycleId, Integer status, int page, int size) {
293+
public PageResultDTO<ResumeDTO> queryResumesWithPagination(String name, String major, Integer cycleId, String status, int page, int size) {
294294
logger.info("分页条件查询简历:name={}, major={}, cycleId={}, status={}, page={}, size={}", name, major, cycleId, status, page, size);
295295

296296
try {

src/main/resources/mapper/ResumeMapper.xml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,18 @@
4646
<if test="cycleId != null">
4747
AND r.cycle_id = #{cycleId}
4848
</if>
49-
<if test="status != null">
50-
AND r.status = #{status}
49+
<if test="status != null and status != ''">
50+
<choose>
51+
<when test="status.indexOf(',') > -1">
52+
AND r.status IN
53+
<foreach collection="status.split(',')" item="statusValue" open="(" separator="," close=")">
54+
#{statusValue}
55+
</foreach>
56+
</when>
57+
<otherwise>
58+
AND r.status = #{status}
59+
</otherwise>
60+
</choose>
5161
</if>
5262
</where>
5363
ORDER BY r.created_at DESC
@@ -67,8 +77,18 @@
6777
<if test="cycleId != null">
6878
AND r.cycle_id = #{cycleId}
6979
</if>
70-
<if test="status != null">
71-
AND r.status = #{status}
80+
<if test="status != null and status != ''">
81+
<choose>
82+
<when test="status.indexOf(',') > -1">
83+
AND r.status IN
84+
<foreach collection="status.split(',')" item="statusValue" open="(" separator="," close=")">
85+
#{statusValue}
86+
</foreach>
87+
</when>
88+
<otherwise>
89+
AND r.status = #{status}
90+
</otherwise>
91+
</choose>
7292
</if>
7393
</where>
7494
ORDER BY r.created_at DESC
@@ -89,8 +109,18 @@
89109
<if test="cycleId != null">
90110
AND r.cycle_id = #{cycleId}
91111
</if>
92-
<if test="status != null">
93-
AND r.status = #{status}
112+
<if test="status != null and status != ''">
113+
<choose>
114+
<when test="status.indexOf(',') > -1">
115+
AND r.status IN
116+
<foreach collection="status.split(',')" item="statusValue" open="(" separator="," close=")">
117+
#{statusValue}
118+
</foreach>
119+
</when>
120+
<otherwise>
121+
AND r.status = #{status}
122+
</otherwise>
123+
</choose>
94124
</if>
95125
</where>
96126
</select>

0 commit comments

Comments
 (0)