Skip to content

Commit

Permalink
update detail
Browse files Browse the repository at this point in the history
  • Loading branch information
Smith-Cruise committed Mar 5, 2018
1 parent 206a14a commit 520b3ff
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
**/
@Repository
public interface LeaderboardMapper {
List<Map<String, Object>> listOIRankByCid(int cid);
List<Map<String, Object>> listOIRankByCid(@Param("cid") int cid, @Param("except") int exceptUser);

List<Map<String, Object>> listACMRankByCid(@Param("cid") int cid, @Param("penalty") int penalty);
List<Map<String, Object>> listACMRankByCid(@Param("cid") int cid, @Param("penalty") int penalty, @Param("except") int exceptUser);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface UserMapper {

int count();

List<UserEntity> listUserRank();
List<UserEntity> listUserRank(@Param("admin") int admin, @Param("root") int root);

UserEntity getByUid(int uid);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.eagleoj.web.dao.LeaderboardMapper;
import com.eagleoj.web.dao.UserMapper;
import com.eagleoj.web.data.status.ContestTypeStatus;
import com.eagleoj.web.data.status.RoleStatus;
import com.eagleoj.web.entity.ContestEntity;
import com.eagleoj.web.entity.UserEntity;
import com.eagleoj.web.service.ContestProblemUserService;
Expand Down Expand Up @@ -56,10 +57,10 @@ public List<Map<String, Object>> getContestLeaderboard(int cid) {
if (type == ContestTypeStatus.OI_CONTEST_NORMAL_TIME.getNumber()
|| type == ContestTypeStatus.OI_CONTEST_LIMIT_TIME.getNumber()) {
// OI比赛
list = leaderboardMapper.listOIRankByCid(cid);
list = leaderboardMapper.listOIRankByCid(cid, contestEntity.getOwner());
} else {
// ACM
list = leaderboardMapper.listACMRankByCid(cid, DefaultConfig.ACM_PENALTY_TIME);
list = leaderboardMapper.listACMRankByCid(cid, DefaultConfig.ACM_PENALTY_TIME, contestEntity.getOwner());
isACM = true;
}
// 存放本次生成的基本信息
Expand Down Expand Up @@ -101,7 +102,7 @@ public Map<String, Object> getUserMetaInContest(int uid, int cid) {

@Override
public List<UserEntity> getLeaderboard() {
return userMapper.listUserRank();
return userMapper.listUserRank(RoleStatus.ADMIN.getNumber(), RoleStatus.ROOT.getNumber());
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions eagle-oj-web/src/main/resources/mapping/LeaderboardMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
avatar
FROM contest_user
LEFT JOIN user ON contest_user.uid = user.uid
WHERE cid = #{cid}
WHERE cid = #{cid} AND contest_user.uid != #{except}
ORDER BY total_score DESC , total_used_time ASC
</select>

Expand All @@ -37,7 +37,7 @@
LEFT JOIN
user ON contest_user.uid = user.uid
WHERE
contest_user.cid = #{cid}
contest_user.cid = #{cid} AND contest_user.uid != #{except}
ORDER BY total_score DESC , (total_used_time + penalty_time) ASC
</select>
</mapper>
4 changes: 3 additions & 1 deletion eagle-oj-web/src/main/resources/mapping/UserMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
</select>

<select id="listUserRank" resultMap="userEntityResultMap">
SELECT uid, nickname, avatar, ac_times, finished_problems, submit_times FROM user ORDER BY finished_problems DESC, ac_times DESC, submit_times DESC
SELECT uid, nickname, avatar, ac_times, finished_problems, submit_times FROM user
WHERE user.role NOT IN (#{admin}, #{root})
ORDER BY finished_problems DESC, ac_times DESC, submit_times DESC
</select>

<select id="getByUid" resultMap="userEntityResultMap">
Expand Down

0 comments on commit 520b3ff

Please sign in to comment.