修复backend的bug(事务失效、数据上传问题)和judgeserver对java编译的修正
This commit is contained in:
parent
aba96809cb
commit
72bd0d886f
|
@ -423,7 +423,7 @@ contest_register表 比赛报名表
|
|||
| id | long | 主键 | auto_increment |
|
||||
| cid | long | 外键 | 比赛id |
|
||||
| uid | String | 外键 | 用户id |
|
||||
| Status | int | | 默认为0表示正常,1为失效。 |
|
||||
| status | int | | 默认为0表示正常,1为失效。 |
|
||||
| gmt_create | datetime | | 创建时间 |
|
||||
| gmt_modified | datetime | | 修改时间 |
|
||||
|
||||
|
@ -455,10 +455,12 @@ contest_record表 比赛记录表
|
|||
| submit_id | int | 外键 | 提交id,用于可重判 |
|
||||
| display_id | String | | 比赛展示的id |
|
||||
| username | String | | 用户名 |
|
||||
| realname | String | | 真实姓名 |
|
||||
| realname | String | | 真实姓名(废弃) |
|
||||
| status | int | | 提交结果,0表示未AC通过不罚时,1表示AC通过,-1为未AC通过算罚时 |
|
||||
| submit_time | datetime | | 具体提交时间 |
|
||||
| time | int | | 提交时间,为提交时间减去比赛时间,时间戳 |
|
||||
| score | int | | OI比赛得分 |
|
||||
| use_time | int | | 提交的程序运行耗时 |
|
||||
| first_blood | Boolean | | 是否为一血AC(废弃) |
|
||||
| checked | Boolean | | AC是否已校验 |
|
||||
| gmt_create | datetime | | 创建时间 |
|
||||
|
@ -494,8 +496,6 @@ announcement表
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
contest_announcement表 比赛时的通知表
|
||||
|
||||
| 列名 | 实体属性类型 | 键 | 备注 |
|
||||
|
@ -521,6 +521,88 @@ contest_explanation表 赛后题解表**(未使用)**
|
|||
|
||||
|
||||
|
||||
##训练(题单)模块
|
||||
|
||||
题单训练表 training
|
||||
|
||||
| 列名 | 实体属性类型 | 键 | 备注 |
|
||||
| ------------ | ------------ | ---- | --------------------------------- |
|
||||
| id | long | 主键 | |
|
||||
| title | string | | 训练题单名称 |
|
||||
| description | string | | 训练题单简介 |
|
||||
| author | string | 外键 | 训练题单创建者用户名 |
|
||||
| auth | string | | 训练题单权限类型:Public、Private |
|
||||
| private_pwd | string | | 训练题单权限为Private时的密码 |
|
||||
| rank | int | | 编号,升序 |
|
||||
| status | boolean | | 是否可用 |
|
||||
| gmt_create | datetime | | 创建时间 |
|
||||
| gmt_modified | datetime | | 修改时间 |
|
||||
|
||||
|
||||
|
||||
训练注册表 training_register
|
||||
|
||||
| 列名 | 实体属性类型 | 键 | 备注 |
|
||||
| ------------ | ------------ | ---- | -------- |
|
||||
| id | long | 主键 | |
|
||||
| tid | long | 外键 | 训练id |
|
||||
| uid | long | 外键 | 用户id |
|
||||
| status | boolean | | 是否可用 |
|
||||
| gmt_create | datetime | | 创建时间 |
|
||||
| gmt_modified | datetime | | 修改时间 |
|
||||
|
||||
|
||||
|
||||
训练与题目关联表 training_problem
|
||||
|
||||
| 列名 | 实体属性类型 | 键 | 备注 |
|
||||
| ------------ | ------------ | ---- | ------------- |
|
||||
| id | long | 主键 | |
|
||||
| tid | long | 外键 | 训练id |
|
||||
| pid | long | 外键 | 题目id |
|
||||
| display_id | string | | 排序用 展示id |
|
||||
| gmt_create | datetime | | 创建时间 |
|
||||
| gmt_modified | datetime | | 修改时间 |
|
||||
|
||||
|
||||
|
||||
训练记录表 training_record
|
||||
|
||||
| 列名 | 实体属性类型 | 键 | 备注 |
|
||||
| ------------ | ------------ | ---- | ---------- |
|
||||
| id | long | 主键 | |
|
||||
| tid | long | 外键 | 训练id |
|
||||
| tpid | long | 外键 | 训练题目id |
|
||||
| pid | long | 外键 | 题目id |
|
||||
| uid | string | 外键 | 用户id |
|
||||
| submit_id | long | 外键 | 提交id |
|
||||
| gmt_create | datetime | | 创建时间 |
|
||||
| gmt_modified | datetime | | 修改时间 |
|
||||
|
||||
|
||||
|
||||
训练分类表 training_category
|
||||
|
||||
| 列名 | 实体属性类型 | 键 | 备注 |
|
||||
| ------------ | ------------ | ---- | ------------ |
|
||||
| id | long | 主键 | |
|
||||
| name | string | | 分类名称 |
|
||||
| color | string | | 分类背景颜色 |
|
||||
| gmt_create | datetime | | 创建时间 |
|
||||
| gmt_modified | datetime | | 修改时间 |
|
||||
|
||||
|
||||
|
||||
训练分类关联表 mapping_training_category
|
||||
|
||||
| 列名 | 实体属性类型 | 键 | 备注 |
|
||||
| ------------ | ------------ | ---- | ------------------------------- |
|
||||
| id | long | 主键 | |
|
||||
| tid | long | 外键 | 训练id |
|
||||
| cid | long | 外键 | 训练分类id(training_category) |
|
||||
| gmt_create | datetime | | 创建时间 |
|
||||
| gmt_modified | datetime | | 修改时间 |
|
||||
|
||||
|
||||
|
||||
## 讨论模块
|
||||
|
@ -710,21 +792,22 @@ file表
|
|||
|
||||
judge_server表
|
||||
|
||||
| 列名 | 实体属性类型 | 键 | 备注 |
|
||||
| --------------- | ------------ | ---- | ------------------------- |
|
||||
| id | int | 主键 | auto_increment |
|
||||
| name | String | | 判题服务名字 |
|
||||
| ip | String | | 判题机ip |
|
||||
| port | int | | 判题机端口号 |
|
||||
| url | String | | ip:port |
|
||||
| cpu_core | int | | 判题机所在服务器cpu核心数 |
|
||||
| task_number | int | | 当前判题数 |
|
||||
| max_task_number | int | | 判题并发最大数 |
|
||||
| status | int | | 0可用,1不可用 |
|
||||
| version | long | | 版本控制 |
|
||||
| is_remote | boolean | | 是否为远程判题vj |
|
||||
| gmt_create | datetime | | 创建时间 |
|
||||
| gmt_modified | datetime | | 修改时间 |
|
||||
| 列名 | 实体属性类型 | 键 | 备注 |
|
||||
| --------------- | ------------ | ---- | ------------------------------------------------ |
|
||||
| id | int | 主键 | auto_increment |
|
||||
| name | String | | 判题服务名字 |
|
||||
| ip | String | | 判题机ip |
|
||||
| port | int | | 判题机端口号 |
|
||||
| url | String | | ip:port |
|
||||
| cpu_core | int | | 判题机所在服务器cpu核心数 |
|
||||
| task_number | int | | 当前判题数 |
|
||||
| max_task_number | int | | 判题并发最大数 |
|
||||
| status | int | | 0可用,1不可用 |
|
||||
| version | long | | 版本控制 |
|
||||
| is_remote | boolean | | 是否为远程判题vj |
|
||||
| cf_submittable | boolean | | 当前机器是否可提交cf,控制机器一次只能一账号交题 |
|
||||
| gmt_create | datetime | | 创建时间 |
|
||||
| gmt_modified | datetime | | 修改时间 |
|
||||
|
||||
remote_judge_account表
|
||||
|
||||
|
|
|
@ -7,14 +7,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
import top.hcode.hoj.pojo.entity.RemoteJudgeAccount;
|
||||
import top.hcode.hoj.pojo.entity.judge.RemoteJudgeAccount;
|
||||
import top.hcode.hoj.pojo.vo.ConfigVo;
|
||||
import top.hcode.hoj.service.impl.ConfigServiceImpl;
|
||||
import top.hcode.hoj.service.impl.RemoteJudgeAccountServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
import top.hcode.hoj.service.common.impl.ConfigServiceImpl;
|
||||
import top.hcode.hoj.service.judge.impl.RemoteJudgeAccountServiceImpl;
|
||||
import top.hcode.hoj.utils.RedisUtils;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
|
|
@ -13,9 +13,9 @@ import org.springframework.web.bind.annotation.*;
|
|||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.dao.*;
|
||||
import top.hcode.hoj.pojo.dto.LoginDto;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.pojo.entity.user.Session;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.impl.SessionServiceImpl;
|
||||
import top.hcode.hoj.service.user.impl.SessionServiceImpl;
|
||||
import top.hcode.hoj.utils.IpUtils;
|
||||
import top.hcode.hoj.utils.JwtUtils;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import cn.hutool.core.map.MapUtil;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
|
@ -18,10 +17,17 @@ import top.hcode.hoj.common.result.CommonResult;
|
|||
import top.hcode.hoj.crawler.problem.ProblemStrategy;
|
||||
import top.hcode.hoj.pojo.dto.AnnouncementDto;
|
||||
import top.hcode.hoj.pojo.dto.ProblemDto;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.pojo.entity.contest.Contest;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestAnnouncement;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestProblem;
|
||||
import top.hcode.hoj.pojo.entity.problem.Problem;
|
||||
import top.hcode.hoj.pojo.vo.AnnouncementVo;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.impl.*;
|
||||
import top.hcode.hoj.service.common.impl.AnnouncementServiceImpl;
|
||||
import top.hcode.hoj.service.contest.impl.ContestAnnouncementServiceImpl;
|
||||
import top.hcode.hoj.service.contest.impl.ContestProblemServiceImpl;
|
||||
import top.hcode.hoj.service.contest.impl.ContestServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.ProblemServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -89,10 +95,13 @@ public class AdminContestController {
|
|||
@GetMapping("")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
|
||||
public CommonResult getContest(@Valid @RequestParam("cid") Long cid, HttpServletRequest request) {
|
||||
public CommonResult getContest(@RequestParam("cid") Long cid, HttpServletRequest request) {
|
||||
|
||||
// 获取本场比赛的状态
|
||||
Contest contest = contestService.getById(cid);
|
||||
if (contest == null) { // 查询不存在
|
||||
return CommonResult.errorResponse("查询失败:该比赛不存在,请检查参数cid是否准确!");
|
||||
}
|
||||
// 获取当前登录的用户
|
||||
HttpSession session = request.getSession();
|
||||
UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
|
||||
|
@ -103,18 +112,14 @@ public class AdminContestController {
|
|||
if (!isRoot && !userRolesVo.getUid().equals(contest.getUid())) {
|
||||
return CommonResult.errorResponse("对不起,你无权限操作!", CommonResult.STATUS_FORBIDDEN);
|
||||
}
|
||||
return CommonResult.successResponse(contest, "查询成功!");
|
||||
|
||||
if (contest != null) { // 查询成功
|
||||
return CommonResult.successResponse(contest, "查询成功!");
|
||||
} else {
|
||||
return CommonResult.errorResponse("查询失败!", CommonResult.STATUS_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = "root") // 只有超级管理员能删除比赛
|
||||
public CommonResult deleteContest(@Valid @RequestParam("cid") Long cid) {
|
||||
public CommonResult deleteContest(@RequestParam("cid") Long cid) {
|
||||
boolean result = contestService.removeById(cid);
|
||||
/*
|
||||
contest的id为其他表的外键的表中的对应数据都会被一起删除!
|
||||
|
@ -154,7 +159,7 @@ public class AdminContestController {
|
|||
}
|
||||
|
||||
boolean result = contestService.saveOrUpdate(contest);
|
||||
if (result) { // 添加成功
|
||||
if (result) {
|
||||
return CommonResult.successResponse(null, "修改成功!");
|
||||
} else {
|
||||
return CommonResult.errorResponse("修改失败", CommonResult.STATUS_FAIL);
|
||||
|
@ -194,7 +199,7 @@ public class AdminContestController {
|
|||
@GetMapping("/get-problem-list")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult getProblemList(@RequestParam(value = "limit", required = false) Integer limit,
|
||||
@RequestParam(value = "currentPage", required = false) Integer currentPage,
|
||||
@RequestParam(value = "keyword", required = false) String keyword,
|
||||
|
@ -313,7 +318,7 @@ public class AdminContestController {
|
|||
@PostMapping("/problem")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult addProblem(@RequestBody ProblemDto problemDto) {
|
||||
|
||||
QueryWrapper<Problem> queryWrapper = new QueryWrapper<>();
|
||||
|
@ -337,7 +342,7 @@ public class AdminContestController {
|
|||
@PutMapping("/problem")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult updateProblem(@RequestBody ProblemDto problemDto, HttpServletRequest request) {
|
||||
|
||||
QueryWrapper<Problem> queryWrapper = new QueryWrapper<>();
|
||||
|
@ -455,7 +460,7 @@ public class AdminContestController {
|
|||
@GetMapping("/import-remote-oj-problem")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult importContestRemoteOJProblem(@RequestParam("name") String name,
|
||||
@RequestParam("problemId") String problemId,
|
||||
@RequestParam("cid") Long cid,
|
||||
|
@ -549,7 +554,7 @@ public class AdminContestController {
|
|||
@PostMapping("/announcement")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult addAnnouncement(@RequestBody AnnouncementDto announcementDto) {
|
||||
boolean result1 = announcementService.save(announcementDto.getAnnouncement());
|
||||
boolean result2 = contestAnnouncementService.saveOrUpdate(new ContestAnnouncement().setAid(announcementDto.getAnnouncement().getId())
|
||||
|
|
|
@ -9,10 +9,10 @@ import org.apache.shiro.authz.annotation.RequiresRoles;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.Discussion;
|
||||
import top.hcode.hoj.pojo.entity.DiscussionReport;
|
||||
import top.hcode.hoj.service.impl.DiscussionReportServiceImpl;
|
||||
import top.hcode.hoj.service.impl.DiscussionServiceImpl;
|
||||
import top.hcode.hoj.pojo.entity.discussion.Discussion;
|
||||
import top.hcode.hoj.pojo.entity.discussion.DiscussionReport;
|
||||
import top.hcode.hoj.service.discussion.impl.DiscussionReportServiceImpl;
|
||||
import top.hcode.hoj.service.discussion.impl.DiscussionServiceImpl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package top.hcode.hoj.controller.admin;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
|
@ -18,14 +17,21 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.judge.remote.RemoteJudgeDispatcher;
|
||||
import top.hcode.hoj.judge.self.JudgeDispatcher;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.service.impl.*;
|
||||
import top.hcode.hoj.pojo.entity.judge.Judge;
|
||||
import top.hcode.hoj.pojo.entity.judge.JudgeCase;
|
||||
import top.hcode.hoj.pojo.entity.user.UserAcproblem;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestRecord;
|
||||
import top.hcode.hoj.pojo.entity.problem.Problem;
|
||||
import top.hcode.hoj.service.contest.impl.ContestRecordServiceImpl;
|
||||
import top.hcode.hoj.service.judge.impl.JudgeCaseServiceImpl;
|
||||
import top.hcode.hoj.service.judge.impl.JudgeServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.ProblemServiceImpl;
|
||||
import top.hcode.hoj.service.user.impl.UserAcproblemServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
|
@ -129,7 +135,7 @@ public class AdminJudgeController {
|
|||
@RequiresAuthentication
|
||||
@RequiresRoles("root") // 只有超级管理员能操作
|
||||
@RequiresPermissions("rejudge")
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult rejudgeContestProblem(@RequestParam("cid") Long cid, @RequestParam("pid") Long pid) {
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import cn.hutool.core.io.FileUtil;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
|
@ -18,9 +17,12 @@ import top.hcode.hoj.common.result.CommonResult;
|
|||
import top.hcode.hoj.crawler.problem.ProblemStrategy;
|
||||
import top.hcode.hoj.judge.Dispatcher;
|
||||
import top.hcode.hoj.pojo.dto.ProblemDto;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.pojo.entity.judge.CompileSpj;
|
||||
import top.hcode.hoj.pojo.entity.problem.Problem;
|
||||
import top.hcode.hoj.pojo.entity.problem.ProblemCase;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.impl.*;
|
||||
import top.hcode.hoj.service.problem.impl.ProblemCaseServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.ProblemServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
|
||||
|
@ -153,7 +155,7 @@ public class AdminProblemController {
|
|||
@PutMapping("")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult updateProblem(@RequestBody ProblemDto problemDto, HttpServletRequest request) {
|
||||
|
||||
QueryWrapper<Problem> queryWrapper = new QueryWrapper<>();
|
||||
|
@ -213,7 +215,7 @@ public class AdminProblemController {
|
|||
@GetMapping("/import-remote-oj-problem")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult importRemoteOJProblem(@RequestParam("name") String name,
|
||||
@RequestParam("problemId") String problemId,
|
||||
HttpServletRequest request) {
|
||||
|
|
|
@ -6,8 +6,8 @@ import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
|||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.Tag;
|
||||
import top.hcode.hoj.service.impl.TagServiceImpl;
|
||||
import top.hcode.hoj.pojo.entity.problem.Tag;
|
||||
import top.hcode.hoj.service.problem.impl.TagServiceImpl;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
package top.hcode.hoj.controller.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.dto.TrainingDto;
|
||||
import top.hcode.hoj.pojo.entity.contest.Contest;
|
||||
import top.hcode.hoj.pojo.entity.training.Training;
|
||||
import top.hcode.hoj.pojo.vo.TrainingVo;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.training.impl.TrainingServiceImpl;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
* @Date: 2021/11/22 20:57
|
||||
* @Description:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/admin/training")
|
||||
public class AdminTrainingController {
|
||||
|
||||
@Resource
|
||||
private TrainingServiceImpl trainingService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
|
||||
public CommonResult getTrainingList(@RequestParam(value = "limit", required = false) Integer limit,
|
||||
@RequestParam(value = "currentPage", required = false) Integer currentPage,
|
||||
@RequestParam(value = "keyword", required = false) String keyword) {
|
||||
|
||||
if (currentPage == null || currentPage < 1) currentPage = 1;
|
||||
if (limit == null || limit < 1) limit = 10;
|
||||
IPage<Training> iPage = new Page<>(currentPage, limit);
|
||||
QueryWrapper<Training> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
if (!StringUtils.isEmpty(keyword)) {
|
||||
keyword = keyword.trim();
|
||||
queryWrapper
|
||||
.like("title", keyword).or()
|
||||
.like("id", keyword);
|
||||
}
|
||||
|
||||
queryWrapper.orderByAsc("rank");
|
||||
|
||||
IPage<Training> TrainingPager = trainingService.page(iPage, queryWrapper);
|
||||
if (TrainingPager.getTotal() == 0) { // 未查询到一条数据
|
||||
return CommonResult.successResponse(TrainingPager, "暂无数据");
|
||||
} else {
|
||||
return CommonResult.successResponse(TrainingPager, "获取成功");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
|
||||
public CommonResult getTraining(@RequestParam("tid") Long tid, HttpServletRequest request) {
|
||||
|
||||
// 获取本场训练的信息
|
||||
Training training = trainingService.getById(tid);
|
||||
if (training == null) { // 查询不存在
|
||||
return CommonResult.errorResponse("查询失败:该训练不存在,请检查参数tid是否准确!");
|
||||
}
|
||||
|
||||
// 获取当前登录的用户
|
||||
HttpSession session = request.getSession();
|
||||
UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
|
||||
// 是否为超级管理员
|
||||
boolean isRoot = SecurityUtils.getSubject().hasRole("root");
|
||||
// 只有超级管理员和训练拥有者才能操作
|
||||
if (!isRoot && !userRolesVo.getUsername().equals(training.getAuthor())) {
|
||||
return CommonResult.errorResponse("对不起,你无权限操作!", CommonResult.STATUS_FORBIDDEN);
|
||||
}
|
||||
return CommonResult.successResponse(training, "查询成功!");
|
||||
}
|
||||
|
||||
@DeleteMapping("")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = "root") // 只有超级管理员能删除训练
|
||||
public CommonResult deleteTraining(@RequestParam("cid") Long cid) {
|
||||
boolean result = trainingService.removeById(cid);
|
||||
/*
|
||||
Training的id为其他表的外键的表中的对应数据都会被一起删除!
|
||||
*/
|
||||
if (result) { // 删除成功
|
||||
return CommonResult.successResponse(null, "删除成功!");
|
||||
} else {
|
||||
return CommonResult.errorResponse("删除失败!", CommonResult.STATUS_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
|
||||
public CommonResult addTraining(@RequestBody TrainingDto trainingDto) {
|
||||
|
||||
boolean result = trainingService.addTraining(trainingDto);
|
||||
if (result) { // 添加成功
|
||||
return CommonResult.successResponse(null, "添加成功!");
|
||||
} else {
|
||||
return CommonResult.errorResponse("添加失败", CommonResult.STATUS_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("")
|
||||
@RequiresAuthentication
|
||||
@RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
|
||||
public CommonResult updateTraining(@RequestBody TrainingDto trainingDto, HttpServletRequest request) {
|
||||
|
||||
// 获取当前登录的用户
|
||||
HttpSession session = request.getSession();
|
||||
UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
|
||||
// 是否为超级管理员
|
||||
boolean isRoot = SecurityUtils.getSubject().hasRole("root");
|
||||
// 只有超级管理员和比赛拥有者才能操作
|
||||
if (!isRoot && !userRolesVo.getUsername().equals(trainingDto.getTraining().getAuthor())) {
|
||||
return CommonResult.errorResponse("对不起,你无权限操作!", CommonResult.STATUS_FORBIDDEN);
|
||||
}
|
||||
|
||||
boolean result = trainingService.updateTraining(trainingDto);
|
||||
if (result) {
|
||||
return CommonResult.successResponse(null, "修改成功!");
|
||||
} else {
|
||||
return CommonResult.errorResponse("修改失败", CommonResult.STATUS_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -14,16 +14,15 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.UserInfo;
|
||||
import top.hcode.hoj.pojo.entity.UserRecord;
|
||||
import top.hcode.hoj.pojo.entity.UserRole;
|
||||
import top.hcode.hoj.pojo.entity.user.UserInfo;
|
||||
import top.hcode.hoj.pojo.entity.user.UserRecord;
|
||||
import top.hcode.hoj.pojo.entity.user.UserRole;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.AdminSysNoticeService;
|
||||
import top.hcode.hoj.service.UserInfoService;
|
||||
import top.hcode.hoj.service.UserRecordService;
|
||||
import top.hcode.hoj.service.impl.UserRoleServiceImpl;
|
||||
import top.hcode.hoj.service.msg.AdminSysNoticeService;
|
||||
import top.hcode.hoj.service.user.UserInfoService;
|
||||
import top.hcode.hoj.service.user.UserRecordService;
|
||||
import top.hcode.hoj.service.user.impl.UserRoleServiceImpl;
|
||||
import top.hcode.hoj.utils.RedisUtils;
|
||||
import top.hcode.hoj.utils.ShiroUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -31,8 +30,6 @@ import javax.servlet.http.HttpSession;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static oshi.util.GlobalConfig.set;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
* @Date: 2020/12/6 15:18
|
||||
|
@ -82,7 +79,7 @@ public class AdminUserController {
|
|||
@PutMapping("/edit-user")
|
||||
@RequiresPermissions("user_admin")
|
||||
@RequiresAuthentication
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult editUser(@RequestBody Map<String, Object> params,
|
||||
HttpServletRequest request) {
|
||||
String username = (String) params.get("username");
|
||||
|
@ -148,7 +145,7 @@ public class AdminUserController {
|
|||
@PostMapping("/insert-batch-user")
|
||||
@RequiresPermissions("user_admin")
|
||||
@RequiresAuthentication
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult insertBatchUser(@RequestBody Map<String, Object> params) {
|
||||
List<List<String>> users = (List<List<String>>) params.get("users");
|
||||
List<UserInfo> userInfoList = new LinkedList<>();
|
||||
|
@ -218,7 +215,7 @@ public class AdminUserController {
|
|||
@PostMapping("/generate-user")
|
||||
@RequiresPermissions("user_admin")
|
||||
@RequiresAuthentication
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult generateUser(@RequestBody Map<String, Object> params) {
|
||||
String prefix = (String) params.getOrDefault("prefix", "");
|
||||
String suffix = (String) params.getOrDefault("suffix", "");
|
||||
|
|
|
@ -7,12 +7,11 @@ import org.apache.shiro.authz.annotation.RequiresRoles;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.Announcement;
|
||||
import top.hcode.hoj.pojo.entity.common.Announcement;
|
||||
import top.hcode.hoj.pojo.vo.AnnouncementVo;
|
||||
import top.hcode.hoj.service.impl.AnnouncementServiceImpl;
|
||||
import top.hcode.hoj.service.common.impl.AnnouncementServiceImpl;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
|
|
|
@ -4,27 +4,20 @@ import cn.hutool.core.io.FileUtil;
|
|||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.UnicodeUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.File;
|
||||
import top.hcode.hoj.pojo.entity.common.File;
|
||||
import top.hcode.hoj.pojo.vo.ConfigVo;
|
||||
import top.hcode.hoj.service.impl.ConfigServiceImpl;
|
||||
import top.hcode.hoj.service.impl.EmailServiceImpl;
|
||||
import top.hcode.hoj.service.impl.FileServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
import top.hcode.hoj.service.common.impl.ConfigServiceImpl;
|
||||
import top.hcode.hoj.service.common.impl.EmailServiceImpl;
|
||||
import top.hcode.hoj.service.common.impl.FileServiceImpl;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
|
|
|
@ -14,9 +14,9 @@ import top.hcode.hoj.common.result.CommonResult;
|
|||
import top.hcode.hoj.dao.ContestMapper;
|
||||
import top.hcode.hoj.dao.JudgeMapper;
|
||||
import top.hcode.hoj.dao.SessionMapper;
|
||||
import top.hcode.hoj.pojo.entity.Session;
|
||||
import top.hcode.hoj.pojo.entity.user.Session;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.UserInfoService;
|
||||
import top.hcode.hoj.service.user.UserInfoService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
|
|
@ -20,12 +20,20 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.pojo.entity.contest.Contest;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestPrint;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestProblem;
|
||||
import top.hcode.hoj.pojo.entity.judge.Judge;
|
||||
import top.hcode.hoj.pojo.vo.ACMContestRankVo;
|
||||
import top.hcode.hoj.pojo.vo.ContestRecordVo;
|
||||
import top.hcode.hoj.pojo.vo.OIContestRankVo;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.impl.*;
|
||||
import top.hcode.hoj.service.common.impl.FileServiceImpl;
|
||||
import top.hcode.hoj.service.contest.impl.ContestPrintServiceImpl;
|
||||
import top.hcode.hoj.service.contest.impl.ContestProblemServiceImpl;
|
||||
import top.hcode.hoj.service.contest.impl.ContestRecordServiceImpl;
|
||||
import top.hcode.hoj.service.contest.impl.ContestServiceImpl;
|
||||
import top.hcode.hoj.service.judge.impl.JudgeServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
@ -16,11 +16,11 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.Role;
|
||||
import top.hcode.hoj.pojo.entity.UserInfo;
|
||||
import top.hcode.hoj.pojo.entity.user.Role;
|
||||
import top.hcode.hoj.pojo.entity.user.UserInfo;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.impl.FileServiceImpl;
|
||||
import top.hcode.hoj.service.impl.UserInfoServiceImpl;
|
||||
import top.hcode.hoj.service.common.impl.FileServiceImpl;
|
||||
import top.hcode.hoj.service.user.impl.UserInfoServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -46,7 +46,7 @@ public class ImageController {
|
|||
@RequestMapping(value = "/upload-avatar", method = RequestMethod.POST)
|
||||
@RequiresAuthentication
|
||||
@ResponseBody
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult uploadAvatar(@RequestParam("image") MultipartFile image, HttpServletRequest request) {
|
||||
if (image == null) {
|
||||
return CommonResult.errorResponse("上传的头像图片文件不能为空!");
|
||||
|
@ -86,7 +86,7 @@ public class ImageController {
|
|||
userInfoService.update(userInfoUpdateWrapper);
|
||||
|
||||
// 插入file表记录
|
||||
top.hcode.hoj.pojo.entity.File imgFile = new top.hcode.hoj.pojo.entity.File();
|
||||
top.hcode.hoj.pojo.entity.common.File imgFile = new top.hcode.hoj.pojo.entity.common.File();
|
||||
imgFile.setName(filename).setFolderPath(Constants.File.USER_AVATAR_FOLDER.getPath())
|
||||
.setFilePath(Constants.File.USER_AVATAR_FOLDER.getPath() + File.separator + filename)
|
||||
.setSuffix(suffix)
|
||||
|
@ -119,7 +119,7 @@ public class ImageController {
|
|||
@RequestMapping(value = "/upload-carouse-img", method = RequestMethod.POST)
|
||||
@RequiresAuthentication
|
||||
@ResponseBody
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiresRoles("root")
|
||||
public CommonResult uploadCarouselImg(@RequestParam("file") MultipartFile image, HttpServletRequest request) {
|
||||
|
||||
|
@ -150,7 +150,7 @@ public class ImageController {
|
|||
|
||||
|
||||
// 插入file表记录
|
||||
top.hcode.hoj.pojo.entity.File imgFile = new top.hcode.hoj.pojo.entity.File();
|
||||
top.hcode.hoj.pojo.entity.common.File imgFile = new top.hcode.hoj.pojo.entity.common.File();
|
||||
imgFile.setName(filename).setFolderPath(Constants.File.HOME_CAROUSEL_FOLDER.getPath())
|
||||
.setFilePath(Constants.File.HOME_CAROUSEL_FOLDER.getPath() + File.separator + filename)
|
||||
.setSuffix(suffix)
|
||||
|
|
|
@ -20,13 +20,13 @@ import org.springframework.web.bind.annotation.*;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.dto.ProblemDto;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.pojo.entity.problem.*;
|
||||
import top.hcode.hoj.pojo.vo.ImportProblemVo;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.impl.LanguageServiceImpl;
|
||||
import top.hcode.hoj.service.impl.ProblemCaseServiceImpl;
|
||||
import top.hcode.hoj.service.impl.ProblemServiceImpl;
|
||||
import top.hcode.hoj.service.impl.TagServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.LanguageServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.ProblemCaseServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.ProblemServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.TagServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -70,7 +70,7 @@ public class ImportAndExportProblemController {
|
|||
@RequiresRoles("root")
|
||||
@RequiresAuthentication
|
||||
@ResponseBody
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@PostMapping("/import-problem")
|
||||
public CommonResult importProblem(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
|
||||
|
|
|
@ -20,10 +20,13 @@ import org.w3c.dom.Document;
|
|||
import org.w3c.dom.Element;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.dto.ProblemDto;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.pojo.entity.problem.CodeTemplate;
|
||||
import top.hcode.hoj.pojo.entity.problem.Language;
|
||||
import top.hcode.hoj.pojo.entity.problem.Problem;
|
||||
import top.hcode.hoj.pojo.entity.problem.ProblemCase;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.impl.LanguageServiceImpl;
|
||||
import top.hcode.hoj.service.impl.ProblemServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.LanguageServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.ProblemServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -74,7 +77,7 @@ public class ImportFpsController {
|
|||
@RequiresRoles("root")
|
||||
@RequiresAuthentication
|
||||
@ResponseBody
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@PostMapping("/import-fps-problem")
|
||||
public CommonResult importFPSProblem(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws IOException {
|
||||
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
|
||||
|
|
|
@ -23,14 +23,14 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.dto.ProblemDto;
|
||||
import top.hcode.hoj.pojo.dto.QDOJProblemDto;
|
||||
import top.hcode.hoj.pojo.entity.Language;
|
||||
import top.hcode.hoj.pojo.entity.Problem;
|
||||
import top.hcode.hoj.pojo.entity.ProblemCase;
|
||||
import top.hcode.hoj.pojo.entity.Tag;
|
||||
import top.hcode.hoj.pojo.entity.problem.Language;
|
||||
import top.hcode.hoj.pojo.entity.problem.Problem;
|
||||
import top.hcode.hoj.pojo.entity.problem.ProblemCase;
|
||||
import top.hcode.hoj.pojo.entity.problem.Tag;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.impl.LanguageServiceImpl;
|
||||
import top.hcode.hoj.service.impl.ProblemServiceImpl;
|
||||
import top.hcode.hoj.service.impl.TagServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.LanguageServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.ProblemServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.TagServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -73,7 +73,7 @@ public class ImportQDUOJController {
|
|||
@RequiresRoles("root")
|
||||
@RequiresAuthentication
|
||||
@ResponseBody
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@PostMapping("/import-qdoj-problem")
|
||||
public CommonResult importQDOJProblem(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ import org.springframework.util.Assert;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.ProblemCase;
|
||||
import top.hcode.hoj.service.impl.ProblemCaseServiceImpl;
|
||||
import top.hcode.hoj.pojo.entity.problem.ProblemCase;
|
||||
import top.hcode.hoj.service.problem.impl.ProblemCaseServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
|
@ -4,13 +4,10 @@ import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
|||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.AdminSysNotice;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.impl.AdminSysNoticeServiceImpl;
|
||||
import top.hcode.hoj.pojo.entity.msg.AdminSysNotice;
|
||||
import top.hcode.hoj.service.msg.impl.AdminSysNoticeServiceImpl;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.pojo.vo.UserUnreadMsgCountVo;
|
||||
import top.hcode.hoj.service.impl.MsgRemindServiceImpl;
|
||||
import top.hcode.hoj.service.msg.impl.MsgRemindServiceImpl;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.impl.UserSysNoticeServiceImpl;
|
||||
import top.hcode.hoj.service.msg.impl.UserSysNoticeServiceImpl;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
@ -3,7 +3,6 @@ package top.hcode.hoj.controller.oj;
|
|||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
@ -11,7 +10,6 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
@ -22,12 +20,17 @@ import top.hcode.hoj.pojo.bo.EmailRuleBo;
|
|||
import top.hcode.hoj.pojo.dto.LoginDto;
|
||||
import top.hcode.hoj.pojo.dto.RegisterDto;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.pojo.entity.user.*;
|
||||
import top.hcode.hoj.pojo.entity.problem.Problem;
|
||||
import top.hcode.hoj.pojo.vo.ConfigVo;
|
||||
import top.hcode.hoj.pojo.vo.UserHomeVo;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.UserInfoService;
|
||||
import top.hcode.hoj.service.impl.*;
|
||||
import top.hcode.hoj.service.common.impl.EmailServiceImpl;
|
||||
import top.hcode.hoj.service.msg.impl.AdminSysNoticeServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.ProblemServiceImpl;
|
||||
import top.hcode.hoj.service.user.impl.SessionServiceImpl;
|
||||
import top.hcode.hoj.service.user.impl.UserAcproblemServiceImpl;
|
||||
import top.hcode.hoj.service.user.impl.UserInfoServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
import top.hcode.hoj.utils.IpUtils;
|
||||
import top.hcode.hoj.utils.JwtUtils;
|
||||
|
@ -253,7 +256,7 @@ public class AccountController {
|
|||
* @Since 2020/10/24
|
||||
*/
|
||||
@PostMapping("/register")
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult register(@Validated @RequestBody RegisterDto registerDto) {
|
||||
|
||||
if (!configVo.getRegister()) { // 需要判断一下网站是否开启注册
|
||||
|
@ -379,19 +382,25 @@ public class AccountController {
|
|||
*/
|
||||
@GetMapping("/get-user-home-info")
|
||||
public CommonResult getUserHomeInfo(@RequestParam(value = "uid", required = false) String uid,
|
||||
@RequestParam(value = "username", required = false) String username,
|
||||
HttpServletRequest request) {
|
||||
HttpSession session = request.getSession();
|
||||
UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
|
||||
// 如果没有uid,默认查询当前登录用户的
|
||||
if (uid == null) {
|
||||
if (uid == null && userRolesVo != null) {
|
||||
uid = userRolesVo.getUid();
|
||||
}
|
||||
UserHomeVo userHomeInfo = userRecordDao.getUserHomeInfo(uid);
|
||||
|
||||
if (StringUtils.isEmpty(uid) && StringUtils.isEmpty(username)) {
|
||||
return CommonResult.errorResponse("请求参数错误:uid和username不能都为空!");
|
||||
}
|
||||
|
||||
UserHomeVo userHomeInfo = userRecordDao.getUserHomeInfo(uid, username);
|
||||
if (userHomeInfo == null) {
|
||||
return CommonResult.errorResponse("用户不存在");
|
||||
}
|
||||
QueryWrapper<UserAcproblem> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("uid", uid).select("distinct pid");
|
||||
queryWrapper.eq("uid", userHomeInfo.getUid()).select("distinct pid");
|
||||
List<Long> pidList = new LinkedList<>();
|
||||
List<UserAcproblem> acProblemList = userAcproblemService.list(queryWrapper);
|
||||
acProblemList.forEach(acProblem -> {
|
||||
|
@ -411,7 +420,9 @@ public class AccountController {
|
|||
|
||||
userHomeInfo.setSolvedList(disPlayIdList);
|
||||
QueryWrapper<Session> sessionQueryWrapper = new QueryWrapper<>();
|
||||
sessionQueryWrapper.eq("uid", uid).orderByDesc("gmt_create").last("limit 1");
|
||||
sessionQueryWrapper.eq("uid", userHomeInfo.getUid())
|
||||
.orderByDesc("gmt_create")
|
||||
.last("limit 1");
|
||||
|
||||
Session recentSession = sessionService.getOne(sessionQueryWrapper, false);
|
||||
if (recentSession != null) {
|
||||
|
|
|
@ -13,10 +13,18 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.dto.ReplyDto;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.pojo.entity.user.UserAcproblem;
|
||||
import top.hcode.hoj.pojo.entity.discussion.Comment;
|
||||
import top.hcode.hoj.pojo.entity.discussion.CommentLike;
|
||||
import top.hcode.hoj.pojo.entity.discussion.Discussion;
|
||||
import top.hcode.hoj.pojo.entity.discussion.Reply;
|
||||
import top.hcode.hoj.pojo.vo.CommentsVo;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.impl.*;
|
||||
import top.hcode.hoj.service.discussion.impl.CommentLikeServiceImpl;
|
||||
import top.hcode.hoj.service.discussion.impl.CommentServiceImpl;
|
||||
import top.hcode.hoj.service.discussion.impl.DiscussionServiceImpl;
|
||||
import top.hcode.hoj.service.discussion.impl.ReplyServiceImpl;
|
||||
import top.hcode.hoj.service.user.impl.UserAcproblemServiceImpl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
|
|
@ -11,8 +11,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.service.impl.*;
|
||||
import top.hcode.hoj.pojo.entity.problem.*;
|
||||
import top.hcode.hoj.pojo.entity.training.TrainingCategory;
|
||||
import top.hcode.hoj.service.problem.impl.*;
|
||||
import top.hcode.hoj.service.training.TrainingCategoryService;
|
||||
import top.hcode.hoj.utils.RedisUtils;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
@ -51,6 +53,9 @@ public class CommonController {
|
|||
@Autowired
|
||||
private CodeTemplateServiceImpl codeTemplateService;
|
||||
|
||||
@Autowired
|
||||
private TrainingCategoryService trainingCategoryService;
|
||||
|
||||
|
||||
@GetMapping("/captcha")
|
||||
public CommonResult getCaptcha() {
|
||||
|
@ -65,6 +70,18 @@ public class CommonController {
|
|||
.put("captchaKey", key).map(), "获取成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* @MethodName getTrainingCategory
|
||||
* @Params null
|
||||
* @Description 获取训练的分类列表
|
||||
* @Return
|
||||
* @Since 2021/11/22
|
||||
*/
|
||||
@GetMapping("/get-training-category")
|
||||
public CommonResult getTrainingCategory() {
|
||||
List<TrainingCategory> categoryList = trainingCategoryService.list();
|
||||
return CommonResult.successResponse(categoryList, "success");
|
||||
}
|
||||
|
||||
@GetMapping("/get-all-problem-tags")
|
||||
public CommonResult getAllProblemTagsList(@RequestParam(value = "oj", defaultValue = "ME") String oj) {
|
||||
|
|
|
@ -9,13 +9,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.dto.CheckACDto;
|
||||
import top.hcode.hoj.pojo.entity.Contest;
|
||||
import top.hcode.hoj.pojo.entity.ContestPrint;
|
||||
import top.hcode.hoj.pojo.entity.ContestRecord;
|
||||
import top.hcode.hoj.pojo.entity.contest.Contest;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestPrint;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestRecord;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.ContestRecordService;
|
||||
import top.hcode.hoj.service.impl.ContestPrintServiceImpl;
|
||||
import top.hcode.hoj.service.impl.ContestServiceImpl;
|
||||
import top.hcode.hoj.service.contest.ContestRecordService;
|
||||
import top.hcode.hoj.service.contest.impl.ContestPrintServiceImpl;
|
||||
import top.hcode.hoj.service.contest.impl.ContestServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package top.hcode.hoj.controller.oj;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -9,16 +7,20 @@ import org.apache.shiro.SecurityUtils;
|
|||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.dto.CheckACDto;
|
||||
import top.hcode.hoj.pojo.dto.ContestPrintDto;
|
||||
import top.hcode.hoj.pojo.dto.UserReadContestAnnouncementDto;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.pojo.entity.common.Announcement;
|
||||
import top.hcode.hoj.pojo.entity.problem.*;
|
||||
import top.hcode.hoj.pojo.entity.user.UserInfo;
|
||||
import top.hcode.hoj.pojo.entity.contest.*;
|
||||
import top.hcode.hoj.pojo.vo.*;
|
||||
import top.hcode.hoj.service.ContestRecordService;
|
||||
import top.hcode.hoj.service.impl.*;
|
||||
import top.hcode.hoj.service.common.impl.AnnouncementServiceImpl;
|
||||
import top.hcode.hoj.service.contest.ContestRecordService;
|
||||
import top.hcode.hoj.service.contest.impl.*;
|
||||
import top.hcode.hoj.service.judge.impl.JudgeServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.*;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -147,15 +149,15 @@ public class ContestController {
|
|||
// 获取当前登录的用户
|
||||
HttpSession session = request.getSession();
|
||||
UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
|
||||
|
||||
Contest contest = contestService.getById(Long.valueOf(cidStr));
|
||||
Long cid = Long.valueOf(cidStr);
|
||||
Contest contest = contestService.getById(cid);
|
||||
|
||||
if (contest == null || !contest.getVisible()) {
|
||||
return CommonResult.errorResponse("对不起,该比赛不存在!");
|
||||
}
|
||||
|
||||
if (!contest.getPwd().equals(password)) { // 密码不对
|
||||
return CommonResult.errorResponse("比赛密码错误!");
|
||||
return CommonResult.errorResponse("比赛密码错误,请重新输入!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,14 +172,14 @@ public class ContestController {
|
|||
}
|
||||
|
||||
|
||||
QueryWrapper<ContestRegister> wrapper = new QueryWrapper<ContestRegister>().eq("cid", Long.valueOf(cidStr))
|
||||
QueryWrapper<ContestRegister> wrapper = new QueryWrapper<ContestRegister>().eq("cid", cid)
|
||||
.eq("uid", userRolesVo.getUid());
|
||||
if (contestRegisterService.getOne(wrapper) != null) {
|
||||
if (contestRegisterService.getOne(wrapper,false) != null) {
|
||||
return CommonResult.errorResponse("您已注册过该比赛,请勿重复注册!");
|
||||
}
|
||||
|
||||
boolean result = contestRegisterService.saveOrUpdate(new ContestRegister()
|
||||
.setCid(Long.valueOf(cidStr))
|
||||
.setCid(cid)
|
||||
.setUid(userRolesVo.getUid()));
|
||||
|
||||
if (!result) {
|
||||
|
@ -203,7 +205,7 @@ public class ContestController {
|
|||
|
||||
QueryWrapper<ContestRegister> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("cid", cid).eq("uid", userRolesVo.getUid());
|
||||
ContestRegister contestRegister = contestRegisterService.getOne(queryWrapper);
|
||||
ContestRegister contestRegister = contestRegisterService.getOne(queryWrapper,false);
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
result.put("access", contestRegister != null);
|
||||
return CommonResult.successResponse(result);
|
||||
|
|
|
@ -12,16 +12,23 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.pojo.entity.problem.Category;
|
||||
import top.hcode.hoj.pojo.entity.user.UserAcproblem;
|
||||
import top.hcode.hoj.pojo.entity.discussion.Discussion;
|
||||
import top.hcode.hoj.pojo.entity.discussion.DiscussionLike;
|
||||
import top.hcode.hoj.pojo.entity.discussion.DiscussionReport;
|
||||
import top.hcode.hoj.pojo.vo.DiscussionVo;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.impl.*;
|
||||
import top.hcode.hoj.service.discussion.impl.DiscussionLikeServiceImpl;
|
||||
import top.hcode.hoj.service.discussion.impl.DiscussionReportServiceImpl;
|
||||
import top.hcode.hoj.service.discussion.impl.DiscussionServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.CategoryServiceImpl;
|
||||
import top.hcode.hoj.service.user.impl.UserAcproblemServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
import top.hcode.hoj.utils.RedisUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -232,7 +239,7 @@ public class DiscussionController {
|
|||
}
|
||||
|
||||
@GetMapping("/discussion-like")
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiresAuthentication
|
||||
public CommonResult addDiscussionLike(@RequestParam("did") Integer did,
|
||||
@RequestParam("toLike") Boolean toLike,
|
||||
|
|
|
@ -2,7 +2,6 @@ package top.hcode.hoj.controller.oj;
|
|||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.UnicodeUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -11,19 +10,18 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.dao.ContestMapper;
|
||||
import top.hcode.hoj.pojo.entity.File;
|
||||
import top.hcode.hoj.pojo.entity.common.File;
|
||||
import top.hcode.hoj.pojo.vo.ACMRankVo;
|
||||
import top.hcode.hoj.pojo.vo.AnnouncementVo;
|
||||
import top.hcode.hoj.pojo.vo.ConfigVo;
|
||||
import top.hcode.hoj.pojo.vo.ContestVo;
|
||||
import top.hcode.hoj.service.impl.AnnouncementServiceImpl;
|
||||
import top.hcode.hoj.service.impl.FileServiceImpl;
|
||||
import top.hcode.hoj.service.impl.UserRecordServiceImpl;
|
||||
import top.hcode.hoj.service.common.impl.AnnouncementServiceImpl;
|
||||
import top.hcode.hoj.service.common.impl.FileServiceImpl;
|
||||
import top.hcode.hoj.service.user.impl.UserRecordServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
import top.hcode.hoj.utils.RedisUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
|
@ -2,7 +2,6 @@ package top.hcode.hoj.controller.oj;
|
|||
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
@ -12,9 +11,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.dao.JudgeMapper;
|
||||
|
@ -22,19 +19,29 @@ import top.hcode.hoj.judge.remote.RemoteJudgeDispatcher;
|
|||
import top.hcode.hoj.judge.self.JudgeDispatcher;
|
||||
import top.hcode.hoj.pojo.dto.SubmitIdListDto;
|
||||
import top.hcode.hoj.pojo.dto.ToJudgeDto;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.pojo.entity.judge.Judge;
|
||||
import top.hcode.hoj.pojo.entity.judge.JudgeCase;
|
||||
import top.hcode.hoj.pojo.entity.user.UserAcproblem;
|
||||
import top.hcode.hoj.pojo.entity.contest.Contest;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestProblem;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestRecord;
|
||||
import top.hcode.hoj.pojo.entity.problem.Problem;
|
||||
import top.hcode.hoj.pojo.vo.JudgeVo;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
|
||||
import top.hcode.hoj.service.ProblemService;
|
||||
import top.hcode.hoj.service.impl.*;
|
||||
import top.hcode.hoj.service.contest.impl.ContestProblemServiceImpl;
|
||||
import top.hcode.hoj.service.contest.impl.ContestRecordServiceImpl;
|
||||
import top.hcode.hoj.service.contest.impl.ContestServiceImpl;
|
||||
import top.hcode.hoj.service.judge.impl.JudgeCaseServiceImpl;
|
||||
import top.hcode.hoj.service.judge.impl.JudgeServiceImpl;
|
||||
import top.hcode.hoj.service.problem.ProblemService;
|
||||
import top.hcode.hoj.service.user.impl.UserAcproblemServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
import top.hcode.hoj.utils.IpUtils;
|
||||
import top.hcode.hoj.utils.RedisUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -248,7 +255,7 @@ public class JudgeController {
|
|||
*/
|
||||
@RequiresAuthentication
|
||||
@GetMapping(value = "/resubmit")
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult resubmit(@RequestParam("submitId") Long submitId,
|
||||
HttpServletRequest request) {
|
||||
|
||||
|
|
|
@ -10,12 +10,16 @@ import org.springframework.validation.annotation.Validated;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.dto.PidListDto;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.pojo.entity.contest.Contest;
|
||||
import top.hcode.hoj.pojo.entity.judge.Judge;
|
||||
import top.hcode.hoj.pojo.entity.problem.*;
|
||||
import top.hcode.hoj.pojo.vo.ProblemCountVo;
|
||||
import top.hcode.hoj.pojo.vo.ProblemInfoVo;
|
||||
import top.hcode.hoj.pojo.vo.ProblemVo;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.impl.*;
|
||||
import top.hcode.hoj.service.contest.impl.ContestServiceImpl;
|
||||
import top.hcode.hoj.service.judge.impl.JudgeServiceImpl;
|
||||
import top.hcode.hoj.service.problem.impl.*;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
package top.hcode.hoj.controller.oj;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.vo.ACMRankVo;
|
||||
import top.hcode.hoj.service.impl.UserRecordServiceImpl;
|
||||
import top.hcode.hoj.service.user.impl.UserRecordServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,211 @@
|
|||
package top.hcode.hoj.controller.oj;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.training.Training;
|
||||
import top.hcode.hoj.pojo.entity.training.TrainingCategory;
|
||||
import top.hcode.hoj.pojo.entity.training.TrainingRegister;
|
||||
import top.hcode.hoj.pojo.vo.ProblemVo;
|
||||
import top.hcode.hoj.pojo.vo.TrainingRankVo;
|
||||
import top.hcode.hoj.pojo.vo.TrainingVo;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
import top.hcode.hoj.service.training.impl.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
* @Date: 2021/11/19 21:42
|
||||
* @Description: 处理训练题单的请求
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
public class TrainingController {
|
||||
|
||||
@Resource
|
||||
private TrainingServiceImpl trainingService;
|
||||
|
||||
@Resource
|
||||
private TrainingRegisterServiceImpl trainingRegisterService;
|
||||
|
||||
@Resource
|
||||
private TrainingCategoryServiceImpl trainingCategoryService;
|
||||
|
||||
@Resource
|
||||
private TrainingProblemServiceImpl trainingProblemService;
|
||||
|
||||
@Resource
|
||||
private TrainingRecordServiceImpl trainingRecordService;
|
||||
|
||||
/**
|
||||
* @param limit
|
||||
* @param currentPage
|
||||
* @param keyword
|
||||
* @param categoryId
|
||||
* @param auth
|
||||
* @MethodName getTrainingList
|
||||
* @Description 获取训练题单列表,可根据关键词、类别、权限、类型过滤
|
||||
* @Return
|
||||
* @Since 2021/11/20
|
||||
*/
|
||||
@GetMapping("/get-training-list")
|
||||
public CommonResult getTrainingList(@RequestParam(value = "limit", required = false) Integer limit,
|
||||
@RequestParam(value = "currentPage", required = false) Integer currentPage,
|
||||
@RequestParam(value = "keyword", required = false) String keyword,
|
||||
@RequestParam(value = "categoryId", required = false) Long categoryId,
|
||||
@RequestParam(value = "auth", required = false) String auth) {
|
||||
|
||||
// 页数,每页题数若为空,设置默认值
|
||||
if (currentPage == null || currentPage < 1) currentPage = 1;
|
||||
if (limit == null || limit < 1) limit = 30;
|
||||
IPage<TrainingVo> trainingList = trainingService.getTrainingList(limit, currentPage, categoryId, auth, keyword);
|
||||
return CommonResult.successResponse(trainingList, "success");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param tid
|
||||
* @param request
|
||||
* @MethodName getTraining
|
||||
* @Description 根据tid获取指定训练详情
|
||||
* @Return
|
||||
* @Since 2021/11/20
|
||||
*/
|
||||
@GetMapping("/get-training-detail")
|
||||
public CommonResult getTraining(@RequestParam(value = "tid") Long tid, HttpServletRequest request) {
|
||||
|
||||
Training training = trainingService.getById(tid);
|
||||
if (training == null || !training.getStatus()) {
|
||||
return CommonResult.errorResponse("该训练不存在或不允许显示!");
|
||||
}
|
||||
|
||||
CommonResult result = trainingRegisterService.checkTrainingAuth(training, request);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
TrainingVo trainingVo = BeanUtil.copyProperties(training, TrainingVo.class);
|
||||
TrainingCategory trainingCategory = trainingCategoryService.getTrainingCategoryByTrainingId(training.getId());
|
||||
trainingVo.setCategoryName(trainingCategory.getName());
|
||||
trainingVo.setCategoryColor(trainingCategory.getColor());
|
||||
trainingVo.setProblemCount(trainingProblemService.getTrainingProblemCount(training.getId()));
|
||||
|
||||
return CommonResult.successResponse(trainingVo, "success");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tid
|
||||
* @param request
|
||||
* @MethodName getTrainingProblemList
|
||||
* @Description 根据tid获取指定训练的题单题目列表
|
||||
* @Return
|
||||
* @Since 2021/11/20
|
||||
*/
|
||||
@GetMapping("/get-training-problem-list")
|
||||
public CommonResult getTrainingProblemList(@RequestParam(value = "tid") Long tid, HttpServletRequest request) {
|
||||
|
||||
Training training = trainingService.getById(tid);
|
||||
if (training == null || !training.getStatus()) {
|
||||
return CommonResult.errorResponse("该训练不存在或不允许显示!");
|
||||
}
|
||||
|
||||
CommonResult result = trainingRegisterService.checkTrainingAuth(training, request);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
List<ProblemVo> trainingProblemList = trainingProblemService.getTrainingProblemList(tid);
|
||||
return CommonResult.successResponse(trainingProblemList, "success");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param params
|
||||
* @param request
|
||||
* @MethodName toRegisterTraining
|
||||
* @Description 注册校验私有权限的训练
|
||||
* @Return
|
||||
* @Since 2021/11/20
|
||||
*/
|
||||
@PostMapping("/register-training")
|
||||
@RequiresAuthentication
|
||||
public CommonResult toRegisterTraining(@RequestBody HashMap<String, Object> params, HttpServletRequest request) {
|
||||
String tidStr = (String) params.get("tid");
|
||||
String password = (String) params.get("password");
|
||||
if (StringUtils.isEmpty(tidStr) || StringUtils.isEmpty(password)) {
|
||||
return CommonResult.errorResponse("请求参数不能为空!");
|
||||
}
|
||||
Long tid = Long.valueOf(tidStr);
|
||||
|
||||
return trainingRegisterService.toRegisterTraining(tid, password, request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param tid
|
||||
* @param request
|
||||
* @MethodName getTrainingAccess
|
||||
* @Description 私有权限的训练需要获取当前用户是否有进入训练的权限
|
||||
* @Return
|
||||
* @Since 2021/11/20
|
||||
*/
|
||||
@RequiresAuthentication
|
||||
@GetMapping("/get-training-access")
|
||||
public CommonResult getTrainingAccess(@RequestParam(value = "tid") Long tid, HttpServletRequest request) {
|
||||
|
||||
// 获取当前登录的用户
|
||||
HttpSession session = request.getSession();
|
||||
UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
|
||||
|
||||
QueryWrapper<TrainingRegister> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("tid", tid).eq("uid", userRolesVo.getUid());
|
||||
TrainingRegister trainingRegister = trainingRegisterService.getOne(queryWrapper, false);
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
result.put("access", trainingRegister != null);
|
||||
return CommonResult.successResponse(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @MethodName getTrainingRank
|
||||
* @param tid
|
||||
* @param limit
|
||||
* @param currentPage
|
||||
* @param request
|
||||
* @Description 获取训练的排行榜分页
|
||||
* @Return
|
||||
* @Since 2021/11/22
|
||||
*/
|
||||
@GetMapping("/get-training-rank")
|
||||
@RequiresAuthentication
|
||||
public CommonResult getTrainingRank(@RequestParam(value = "tid", required = true) Long tid,
|
||||
@RequestParam(value = "limit", required = false) Integer limit,
|
||||
@RequestParam(value = "currentPage", required = false) Integer currentPage,
|
||||
HttpServletRequest request) {
|
||||
|
||||
Training training = trainingService.getById(tid);
|
||||
if (training == null || !training.getStatus()) {
|
||||
return CommonResult.errorResponse("该训练不存在或不允许显示!");
|
||||
}
|
||||
|
||||
CommonResult result = trainingRegisterService.checkTrainingAuth(training, request);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 页数,每页数若为空,设置默认值
|
||||
if (currentPage == null || currentPage < 1) currentPage = 1;
|
||||
if (limit == null || limit < 1) limit = 30;
|
||||
IPage<TrainingRankVo> trainingRankPager = trainingRecordService.getTrainingRank(tid, currentPage, limit);
|
||||
return CommonResult.successResponse(trainingRankPager, "success");
|
||||
}
|
||||
|
||||
}
|
|
@ -5,8 +5,8 @@ import cn.hutool.core.util.ReUtil;
|
|||
import cn.hutool.http.HttpUtil;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
import top.hcode.hoj.pojo.entity.Problem;
|
||||
import top.hcode.hoj.pojo.entity.Tag;
|
||||
import top.hcode.hoj.pojo.entity.problem.Problem;
|
||||
import top.hcode.hoj.pojo.entity.problem.Tag;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.crawler.problem;
|
|||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import top.hcode.hoj.pojo.entity.Problem;
|
||||
import top.hcode.hoj.pojo.entity.problem.Problem;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
@ -2,10 +2,9 @@ package top.hcode.hoj.crawler.problem;
|
|||
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import org.jsoup.Connection;
|
||||
import org.jsoup.helper.Validate;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.springframework.util.Assert;
|
||||
import top.hcode.hoj.pojo.entity.Problem;
|
||||
import top.hcode.hoj.pojo.entity.problem.Problem;
|
||||
import top.hcode.hoj.utils.JsoupUtils;
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@ import cn.hutool.core.util.ReUtil;
|
|||
import org.jsoup.Connection;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.springframework.util.Assert;
|
||||
import top.hcode.hoj.pojo.entity.Problem;
|
||||
import top.hcode.hoj.pojo.entity.problem.Problem;
|
||||
import top.hcode.hoj.utils.JsoupUtils;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package top.hcode.hoj.crawler.problem;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import top.hcode.hoj.pojo.entity.Problem;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
|
|
|
@ -2,8 +2,8 @@ package top.hcode.hoj.crawler.problem;
|
|||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import top.hcode.hoj.pojo.entity.Problem;
|
||||
import top.hcode.hoj.pojo.entity.Tag;
|
||||
import top.hcode.hoj.pojo.entity.problem.Problem;
|
||||
import top.hcode.hoj.pojo.entity.problem.Tag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.AdminSysNotice;
|
||||
import top.hcode.hoj.pojo.entity.msg.AdminSysNotice;
|
||||
import top.hcode.hoj.pojo.vo.AdminSysNoticeVo;
|
||||
|
||||
@Mapper
|
||||
|
|
|
@ -5,12 +5,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.Announcement;
|
||||
import top.hcode.hoj.pojo.entity.common.Announcement;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import top.hcode.hoj.pojo.vo.AnnouncementVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package top.hcode.hoj.dao;
|
||||
|
||||
import top.hcode.hoj.pojo.entity.Auth;
|
||||
import top.hcode.hoj.pojo.entity.user.Auth;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.Category;
|
||||
import top.hcode.hoj.pojo.entity.problem.Category;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.CodeTemplate;
|
||||
import top.hcode.hoj.pojo.entity.problem.CodeTemplate;
|
||||
|
||||
|
||||
@Mapper
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.CommentLike;
|
||||
import top.hcode.hoj.pojo.entity.discussion.CommentLike;
|
||||
|
||||
|
||||
@Mapper
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.Comment;
|
||||
import top.hcode.hoj.pojo.entity.discussion.Comment;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import top.hcode.hoj.pojo.vo.CommentsVo;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.ContestAnnouncement;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestAnnouncement;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package top.hcode.hoj.dao;
|
||||
|
||||
import top.hcode.hoj.pojo.entity.ContestExplanation;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestExplanation;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.vo.ContestVo;
|
||||
import top.hcode.hoj.pojo.entity.Contest;
|
||||
import top.hcode.hoj.pojo.entity.contest.Contest;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.ContestPrint;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestPrint;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.ContestProblem;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestProblem;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import top.hcode.hoj.pojo.vo.ContestProblemVo;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.ContestRecord;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestRecord;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import top.hcode.hoj.pojo.vo.ContestRecordVo;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package top.hcode.hoj.dao;
|
|||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.ContestRegister;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestRegister;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package top.hcode.hoj.dao;
|
||||
|
||||
import top.hcode.hoj.pojo.entity.ContestScore;
|
||||
import top.hcode.hoj.pojo.entity.contest.ContestScore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.DiscussionLike;
|
||||
import top.hcode.hoj.pojo.entity.discussion.DiscussionLike;
|
||||
|
||||
|
||||
@Mapper
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.Discussion;
|
||||
import top.hcode.hoj.pojo.entity.discussion.Discussion;
|
||||
import top.hcode.hoj.pojo.vo.DiscussionVo;
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.DiscussionReport;
|
||||
import top.hcode.hoj.pojo.entity.discussion.DiscussionReport;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.Param;
|
|||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.File;
|
||||
import top.hcode.hoj.pojo.entity.common.File;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package top.hcode.hoj.dao;
|
|||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.JudgeCase;
|
||||
import top.hcode.hoj.pojo.entity.judge.JudgeCase;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.Judge;
|
||||
import top.hcode.hoj.pojo.entity.judge.Judge;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import top.hcode.hoj.pojo.vo.JudgeVo;
|
||||
import top.hcode.hoj.pojo.vo.ProblemCountVo;
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.JudgeServer;
|
||||
import top.hcode.hoj.pojo.entity.judge.JudgeServer;
|
||||
|
||||
|
||||
@Mapper
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.Language;
|
||||
import top.hcode.hoj.pojo.entity.problem.Language;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package top.hcode.hoj.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.training.MappingTrainingCategory;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface MappingTrainingCategoryMapper extends BaseMapper<MappingTrainingCategory> {
|
||||
}
|
|
@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.MsgRemind;
|
||||
import top.hcode.hoj.pojo.entity.msg.MsgRemind;
|
||||
import top.hcode.hoj.pojo.vo.UserMsgVo;
|
||||
import top.hcode.hoj.pojo.vo.UserUnreadMsgCountVo;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.ProblemCase;
|
||||
import top.hcode.hoj.pojo.entity.problem.ProblemCase;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.ProblemCount;
|
||||
import top.hcode.hoj.pojo.entity.problem.ProblemCount;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.ProblemLanguage;
|
||||
import top.hcode.hoj.pojo.entity.problem.ProblemLanguage;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package top.hcode.hoj.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.vo.ProblemVo;
|
||||
import top.hcode.hoj.pojo.entity.Problem;
|
||||
import top.hcode.hoj.pojo.entity.problem.Problem;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.ProblemTag;
|
||||
import top.hcode.hoj.pojo.entity.problem.ProblemTag;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.Param;
|
|||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.RemoteJudgeAccount;
|
||||
import top.hcode.hoj.pojo.entity.judge.RemoteJudgeAccount;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.Reply;
|
||||
import top.hcode.hoj.pojo.entity.discussion.Reply;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.RoleAuth;
|
||||
import top.hcode.hoj.pojo.entity.user.RoleAuth;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import top.hcode.hoj.pojo.vo.RoleAuthsVo;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package top.hcode.hoj.dao;
|
|||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.Role;
|
||||
import top.hcode.hoj.pojo.entity.user.Role;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.Session;
|
||||
import top.hcode.hoj.pojo.entity.user.Session;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
|
|
|
@ -2,7 +2,7 @@ package top.hcode.hoj.dao;
|
|||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.Tag;
|
||||
import top.hcode.hoj.pojo.entity.problem.Tag;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package top.hcode.hoj.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.training.TrainingCategory;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface TrainingCategoryMapper extends BaseMapper<TrainingCategory> {
|
||||
|
||||
public TrainingCategory getTrainingCategoryByTrainingId(@Param("tid") Long tid);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package top.hcode.hoj.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.training.Training;
|
||||
import top.hcode.hoj.pojo.vo.TrainingVo;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
* @Date: 2021/11/19 22:03
|
||||
* @Description:
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface TrainingMapper extends BaseMapper<Training> {
|
||||
|
||||
IPage<TrainingVo> getTrainingList(Page<TrainingVo> page,
|
||||
@Param("categoryId") Long categoryId,
|
||||
@Param("auth") String auth,
|
||||
@Param("keyword") String keyword);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package top.hcode.hoj.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.training.TrainingProblem;
|
||||
import top.hcode.hoj.pojo.vo.ProblemVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface TrainingProblemMapper extends BaseMapper<TrainingProblem> {
|
||||
|
||||
public Integer getTrainingProblemCount(@Param("tid") Long tid);
|
||||
|
||||
public List<ProblemVo> getTrainingProblemList(@Param("tid") Long tid);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package top.hcode.hoj.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.training.TrainingRecord;
|
||||
import top.hcode.hoj.pojo.vo.TrainingRecordVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
* @Date: 2021/11/21 14:27
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface TrainingRecordMapper extends BaseMapper<TrainingRecord> {
|
||||
|
||||
public List<TrainingRecordVo> getTrainingRecord(@Param("tid") Long tid);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package top.hcode.hoj.dao;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.training.TrainingRegister;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface TrainingRegisterMapper extends BaseMapper<TrainingRegister> {
|
||||
}
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.UserAcproblem;
|
||||
import top.hcode.hoj.pojo.entity.user.UserAcproblem;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,7 @@ package top.hcode.hoj.dao;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.dto.RegisterDto;
|
||||
import top.hcode.hoj.pojo.entity.UserInfo;
|
||||
import top.hcode.hoj.pojo.entity.user.UserInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -6,9 +6,8 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.vo.ACMRankVo;
|
||||
import top.hcode.hoj.pojo.entity.UserRecord;
|
||||
import top.hcode.hoj.pojo.entity.user.UserRecord;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import top.hcode.hoj.pojo.vo.JudgeVo;
|
||||
import top.hcode.hoj.pojo.vo.OIRankVo;
|
||||
import top.hcode.hoj.pojo.vo.UserHomeVo;
|
||||
|
||||
|
@ -28,6 +27,6 @@ public interface UserRecordMapper extends BaseMapper<UserRecord> {
|
|||
IPage<ACMRankVo> getACMRankList(Page<ACMRankVo> page);
|
||||
List<ACMRankVo> getRecent7ACRank();
|
||||
IPage<OIRankVo> getOIRankList(Page<OIRankVo> page);
|
||||
UserHomeVo getUserHomeInfo(@Param("uid") String uid);
|
||||
UserHomeVo getUserHomeInfo(@Param("uid") String uid,@Param("username")String username);
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.Role;
|
||||
import top.hcode.hoj.pojo.entity.UserRole;
|
||||
import top.hcode.hoj.pojo.entity.user.Role;
|
||||
import top.hcode.hoj.pojo.entity.user.UserRole;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import top.hcode.hoj.pojo.vo.UserRolesVo;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import top.hcode.hoj.pojo.entity.UserSysNotice;
|
||||
import top.hcode.hoj.pojo.entity.msg.UserSysNotice;
|
||||
import top.hcode.hoj.pojo.vo.SysMsgVo;
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<result column="like_num" property="likeNum"></result>
|
||||
<result column="total_reply_num" property="totalReplyNum"></result>
|
||||
<result column="gmt_create" property="gmtCreate"></result>
|
||||
<collection property="replyList" ofType="top.hcode.hoj.pojo.entity.Reply" select="getCommentListReply" column="id">
|
||||
<collection property="replyList" ofType="top.hcode.hoj.pojo.entity.discussion.Reply" select="getCommentListReply" column="id">
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
|||
</select>
|
||||
|
||||
<!-- 子查询 -->
|
||||
<select id="getCommentListReply" resultType="top.hcode.hoj.pojo.entity.Reply">
|
||||
<select id="getCommentListReply" resultType="top.hcode.hoj.pojo.entity.discussion.Reply">
|
||||
select r.* from reply r where r.comment_id=#{id} and r.status=0 order by r.gmt_create desc LIMIT 3
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="top.hcode.hoj.dao.ContestRecordMapper">
|
||||
|
||||
<select id="getACInfo" resultType="top.hcode.hoj.pojo.entity.ContestRecord">
|
||||
<select id="getACInfo" resultType="top.hcode.hoj.pojo.entity.contest.ContestRecord">
|
||||
SELECT c.id,c.uid,c.username,c.display_id,c.cid,u.realname,c.pid,c.time,c.status,c.checked,c.submit_id,
|
||||
c.submit_time FROM contest_record c,user_info u,
|
||||
(SELECT status,uid,pid,cpid,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?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="top.hcode.hoj.dao.ProblemCountMapper">
|
||||
<select id="getContestProblemCount" resultType="top.hcode.hoj.pojo.entity.ProblemCount">
|
||||
<select id="getContestProblemCount" resultType="top.hcode.hoj.pojo.entity.problem.ProblemCount">
|
||||
SELECT COUNT(IF(status=-3,status,NULL)) AS pe,
|
||||
COUNT(IF(status=-2,status,NULL)) AS ce,
|
||||
COUNT(IF(status=-1,status,NULL)) AS wa,
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<result column="wa" property="wa"></result>
|
||||
<result column="se" property="se"></result>
|
||||
<result column="pa" property="pa"></result>
|
||||
<collection property="tags" ofType="top.hcode.hoj.pojo.entity.Tag" select="getProblemTag" column="pid">
|
||||
<collection property="tags" ofType="top.hcode.hoj.pojo.entity.problem.Tag" select="getProblemTag" column="pid">
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
|||
</select>
|
||||
|
||||
<!-- 子查询 :为了防止分页总数据数出错-->
|
||||
<select id="getProblemTag" resultType="top.hcode.hoj.pojo.entity.Tag">
|
||||
<select id="getProblemTag" resultType="top.hcode.hoj.pojo.entity.problem.Tag">
|
||||
select t.* from tag t,problem_tag pt where t.id = pt.tid and pt.pid = #{pid}
|
||||
</select>
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<result column="status" property="status"></result>
|
||||
<result column="gmt_create" property="gmtCreate"></result>
|
||||
<result column="gmt_modified" property="gmtModified"></result>
|
||||
<collection property="auths" ofType="top.hcode.hoj.pojo.entity.Auth">
|
||||
<collection property="auths" ofType="top.hcode.hoj.pojo.entity.user.Auth">
|
||||
<id column="auth_id" property="id"></id>
|
||||
<result column="name" property="name"></result>
|
||||
<result column="permission" property="permission"></result>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?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="top.hcode.hoj.dao.TrainingCategoryMapper">
|
||||
<select id="getTrainingCategoryByTrainingId" resultType="top.hcode.hoj.pojo.entity.training.TrainingCategory">
|
||||
select tc.* from mapping_training_category mtc, training_category tc
|
||||
where tc.id = mtc.cid and mtc.tid = #{tid}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,41 @@
|
|||
<?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="top.hcode.hoj.dao.TrainingMapper">
|
||||
|
||||
<resultMap id="map_TrainingList" type="top.hcode.hoj.pojo.vo.TrainingVo">
|
||||
<id column="id" property="id"></id>
|
||||
<result column="title" property="title"></result>
|
||||
<result column="description" property="description"></result>
|
||||
<result column="author" property="author"></result>
|
||||
<result column="auth" property="auth"></result>
|
||||
<result column="rank" property="rank"></result>
|
||||
<result column="category_name" property="categoryName"></result>
|
||||
<result column="category_color" property="categoryColor"></result>
|
||||
<result column="problem_count" property="problemCount"></result>
|
||||
</resultMap>
|
||||
|
||||
<select id="getTrainingList" resultMap="map_TrainingList">
|
||||
select t.*,tc.name as category_name,tc.color as category_color
|
||||
(
|
||||
select count(*) from training_problem tp,problem p
|
||||
where tp.tid = t.id and tp.pid = p.id and p.auth = 1
|
||||
)
|
||||
as problem_count
|
||||
from training t,mapping_training_category mtc,training_category tc
|
||||
<where>
|
||||
t.status = true and t.id = mtc.tid and mtc.cid = tc.id
|
||||
<if test="categoryId != null">
|
||||
and tc.id = #{categoryId}
|
||||
</if>
|
||||
<if test="auth != null">
|
||||
and t.auth = #{auth}
|
||||
</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
and (
|
||||
t.title like concat('%',#{keyword},'%') or t.author like concat('%',#{keyword},'%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
order by t.rank asc
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,49 @@
|
|||
<?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="top.hcode.hoj.dao.TrainingProblemMapper">
|
||||
|
||||
|
||||
<select id="getTrainingProblemCount" resultType="java.lang.Integer">
|
||||
select count(*) from training_problem tp,problem p
|
||||
where tp.tid = #{tid} and tp.pid = p.id and p.auth = 1
|
||||
</select>
|
||||
|
||||
|
||||
<resultMap id="map_TrainingProblemList" type="top.hcode.hoj.pojo.vo.ProblemVo">
|
||||
<id column="pid" property="pid"></id>
|
||||
<result column="display_id" property="problemId"></result>
|
||||
<result column="title" property="title"></result>
|
||||
<result column="difficulty" property="difficulty"></result>
|
||||
<result column="type" property="type"></result>
|
||||
<result column="total" property="total"></result>
|
||||
<result column="ac" property="ac"></result>
|
||||
<collection property="tags" ofType="top.hcode.hoj.pojo.entity.problem.Tag" select="getProblemTag" column="pid">
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="getTrainingProblemList" resultMap="map_TrainingProblemList">
|
||||
SELECT DISTINCT p.id AS pid, tp.display_id, p.title, p.difficulty, p.type
|
||||
, COALESCE(j.ac, 0) AS ac
|
||||
, COALESCE(j.total, 0) AS total
|
||||
FROM problem p,
|
||||
(
|
||||
SELECT j.pid AS pid
|
||||
, COUNT(IF(j.status = 0, STATUS, NULL)) AS ac
|
||||
, COUNT(*) AS total
|
||||
FROM judge j
|
||||
WHERE j.cid = 0
|
||||
GROUP BY j.pid
|
||||
) j,
|
||||
training_problem tp
|
||||
where p.id = tp.pid
|
||||
and j.pid = p.id
|
||||
and p.auth = 1
|
||||
and tp.tid = #{tid}
|
||||
order by tp.display_id asc
|
||||
</select>
|
||||
|
||||
<!-- 子查询 :为了防止分页总数据数出错-->
|
||||
<select id="getProblemTag" resultType="top.hcode.hoj.pojo.entity.problem.Tag">
|
||||
select t.* from tag t,problem_tag pt where t.id = pt.tid and pt.pid = #{pid}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,14 @@
|
|||
<?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="top.hcode.hoj.dao.TrainingRecordMapper">
|
||||
<select id="getTrainingRecord" resultType="top.hcode.hoj.pojo.vo.TrainingRecordVo">
|
||||
SELECT tr.tid,tr.uid,tr.pid,tr.tpid,tr.submit_id,j.status,j.score,j.use_time,
|
||||
u.gender,u.realname as realname,u.username,u.avatar,u.school,u.nickname
|
||||
FROM training_record tr,user_info u,judge j
|
||||
WHERE tr.uid = u.uuid
|
||||
AND tr.submit_id = j.submit_id
|
||||
AND tr.tid = #{tid}
|
||||
AND j.status IN (-3,-2,-1,0,1,2,3,8)
|
||||
ORDER BY j.gmt_create ASC
|
||||
</select>
|
||||
</mapper>
|
|
@ -6,7 +6,7 @@
|
|||
#{uuid}, #{username},#{password},#{email}
|
||||
)
|
||||
</insert>
|
||||
<select id="getSuperAdminList" resultType="top.hcode.hoj.pojo.entity.UserInfo" useCache="true">
|
||||
<select id="getSuperAdminList" resultType="top.hcode.hoj.pojo.entity.user.UserInfo" useCache="true">
|
||||
select * from user_info u,user_role ur where u.uuid = ur.uid and ur.role_id = 1000
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -69,7 +69,16 @@
|
|||
<select id="getUserHomeInfo" resultMap="map_UserHomeVo">
|
||||
SELECT u.uuid as uid,u.username,u.nickname,u.gender,u.signature,u.school,u.github,u.blog,u.avatar,ur.rating,
|
||||
(SELECT COUNT(uid) FROM judge WHERE uid=u.uuid AND cid=0) AS total
|
||||
FROM user_info u,user_record ur WHERE u.uuid = ur.uid AND u.status = 0 AND u.uuid = #{uid}
|
||||
FROM user_info u,user_record ur
|
||||
<where>
|
||||
u.uuid = ur.uid AND u.status = 0
|
||||
<if test="uid!=null">
|
||||
AND u.uuid = #{uid}
|
||||
</if>
|
||||
<if test="username!=null">
|
||||
AND u.username = #{username}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 子查询-->
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<result column="avatar" property="avatar"></result>
|
||||
<result column="gmt_create" property="gmtCreate"></result>
|
||||
<result column="gmt_modified" property="gmtModified"></result>
|
||||
<collection property="roles" ofType="top.hcode.hoj.pojo.entity.Role">
|
||||
<collection property="roles" ofType="top.hcode.hoj.pojo.entity.user.Role">
|
||||
<id column="role_id" property="id"></id>
|
||||
<result column="role" property="role"></result>
|
||||
<result column="description" property="description"></result>
|
||||
|
@ -47,7 +47,7 @@
|
|||
|
||||
</select>
|
||||
|
||||
<select id="getRolesByUid" resultType="top.hcode.hoj.pojo.entity.Role">
|
||||
<select id="getRolesByUid" resultType="top.hcode.hoj.pojo.entity.user.Role">
|
||||
select r.* from role r,user_role ur where r.id=ur.role_id and ur.uid = #{uid}
|
||||
</select>
|
||||
|
||||
|
@ -70,7 +70,7 @@
|
|||
<result column="avatar" property="avatar"></result>
|
||||
<result column="gmt_create" property="gmtCreate"></result>
|
||||
<result column="gmt_modified" property="gmtModified"></result>
|
||||
<collection property="roles" ofType="top.hcode.hoj.pojo.entity.Role" select="getUserListRoles"
|
||||
<collection property="roles" ofType="top.hcode.hoj.pojo.entity.user.Role" select="getUserListRoles"
|
||||
column="uuid=uuid">
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
@ -90,7 +90,7 @@
|
|||
</select>
|
||||
|
||||
<!-- 子查询 -->
|
||||
<select id="getUserListRoles" resultType="top.hcode.hoj.pojo.entity.Role">
|
||||
<select id="getUserListRoles" resultType="top.hcode.hoj.pojo.entity.user.Role">
|
||||
select r.* from role r,user_role ur where ur.uid=#{uuid} and ur.role_id = r.id
|
||||
</select>
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import top.hcode.hoj.dao.RemoteJudgeAccountMapper;
|
||||
import top.hcode.hoj.pojo.entity.JudgeServer;
|
||||
import top.hcode.hoj.pojo.entity.RemoteJudgeAccount;
|
||||
import top.hcode.hoj.service.impl.JudgeServerServiceImpl;
|
||||
import top.hcode.hoj.pojo.entity.judge.JudgeServer;
|
||||
import top.hcode.hoj.pojo.entity.judge.RemoteJudgeAccount;
|
||||
import top.hcode.hoj.service.judge.impl.JudgeServerServiceImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -7,10 +7,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import top.hcode.hoj.common.result.CommonResult;
|
||||
import top.hcode.hoj.pojo.entity.*;
|
||||
import top.hcode.hoj.service.impl.JudgeServerServiceImpl;
|
||||
import top.hcode.hoj.service.impl.JudgeServiceImpl;
|
||||
import top.hcode.hoj.service.impl.RemoteJudgeAccountServiceImpl;
|
||||
import top.hcode.hoj.pojo.entity.judge.*;
|
||||
import top.hcode.hoj.service.judge.impl.JudgeServerServiceImpl;
|
||||
import top.hcode.hoj.service.judge.impl.JudgeServiceImpl;
|
||||
import top.hcode.hoj.service.judge.impl.RemoteJudgeAccountServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import cn.hutool.json.JSONUtil;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import top.hcode.hoj.pojo.entity.Judge;
|
||||
import top.hcode.hoj.service.impl.JudgeServiceImpl;
|
||||
import top.hcode.hoj.pojo.entity.judge.Judge;
|
||||
import top.hcode.hoj.service.judge.impl.JudgeServiceImpl;
|
||||
import top.hcode.hoj.utils.Constants;
|
||||
import top.hcode.hoj.utils.RedisUtils;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue