Skip to content

Commit

Permalink
完善比赛添加题目功能
Browse files Browse the repository at this point in the history
  • Loading branch information
Smith-Cruise committed Mar 8, 2018
1 parent 420a6d2 commit 4a0470e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ public ResponseEntity getProblems(@RequestParam(name = "tag", defaultValue = "nu
@RequiresAuthentication
@GetMapping("/contest")
public ResponseEntity listContestProblemsForAdding(@RequestParam("page") int page,
@RequestParam("page_size") int pageSize) {
@RequestParam("page_size") int pageSize,
@RequestParam(name = "query", required = false, defaultValue = "null") String query) {
int uid = SessionHelper.get().getUid();
Page pager = PageHelper.startPage(page, pageSize);
return new ResponseEntity(WebUtil.generatePageData(pager, problemService.listProblemsForContest(uid)));
query = query.equals("null")? null: query;
return new ResponseEntity(WebUtil.generatePageData(pager, problemService.listProblemsForContest(uid, query)));
}

@ApiOperation("获取所有题目")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ List<Map<String, Object>> listShared(@Param("uid") Integer uid,
@Param("tag") String tag,
@Param("query") String query);

List<ProblemEntity> listProblemsForContest(int uid);
List<ProblemEntity> listProblemsForContest(@Param("uid") int uid, @Param("query") String query);

List<ProblemEntity> listAuditing();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int save(JSONArray tags, int owner, String title, JSONObject description, JSONOb

List<Map<String, Object>> listSharedProblems(String tag, Integer difficult, Integer uid, String query);

List<ProblemEntity> listProblemsForContest(int uid);
List<ProblemEntity> listProblemsForContest(int uid, String query);

List<ProblemEntity> listAllProblems();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ public List<Map<String, Object>> listSharedProblems(String tag, Integer difficul
}

@Override
public List<ProblemEntity> listProblemsForContest(int uid) {
return problemMapper.listProblemsForContest(uid);
public List<ProblemEntity> listProblemsForContest(int uid, String query) {
return problemMapper.listProblemsForContest(uid, query);
}

@Override
Expand Down
10 changes: 9 additions & 1 deletion eagle-oj-web/src/main/resources/mapping/ProblemMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@
</select>

<select id="listProblemsForContest" resultType="HashMap">
SELECT * FROM problem WHERE status=2 OR owner=#{uid}
SELECT * FROM problem WHERE
status=2
<if test="query != null">
AND title LIKE '%${query}%'
</if>
OR owner=#{uid}
<if test="query != null">
AND title LIKE '%${query}%'
</if>
</select>

<select id="listAuditing" resultMap="problemResultMap">
Expand Down

0 comments on commit 4a0470e

Please sign in to comment.