Browse Source

Merge branch 'rongrunxiang/fixbugs' of rongrunxiang/OnlineJudge into master

rongrunxiang 1 year ago
parent
commit
55182dcf30

+ 6 - 0
sql/建表语句.sql → sql/create_table.sql

@@ -1,3 +1,9 @@
+-- 创建库
+create database if not exists onlinejudge;
+
+-- 切换库
+use onlinejudge;
+
 create table question_submit
 create table question_submit
 (
 (
 	id bigint not null
 	id bigint not null

+ 3 - 8
src/main/java/com/example/onlinejudge/config/SaTokenConfigure.java

@@ -12,18 +12,13 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  */
  */
 @Configuration
 @Configuration
 public class SaTokenConfigure implements WebMvcConfigurer {
 public class SaTokenConfigure implements WebMvcConfigurer {
-    /**
-     * 添加拦截器
-     * @param registry
-     */
     @Override
     @Override
     public void addInterceptors(InterceptorRegistry registry) {
     public void addInterceptors(InterceptorRegistry registry) {
         registry.addInterceptor(new SaInterceptor( handle -> {
         registry.addInterceptor(new SaInterceptor( handle -> {
                 // 指定一条 match 规则
                 // 指定一条 match 规则
-                SaRouter
-                        .match("/**")
-                        .notMatch("/api/user/login/**")
+                SaRouter.match("/api/**")
+                        .notMatch("/api/user/**")
                         .check(r -> StpUtil.checkLogin());
                         .check(r -> StpUtil.checkLogin());
-        })).addPathPatterns("/**");
+        }));
     }
     }
 }
 }

+ 2 - 0
src/main/java/com/example/onlinejudge/controller/JudgeController.java

@@ -24,6 +24,8 @@ public class JudgeController {
 
 
         return Result.success();
         return Result.success();
     }
     }
+
+    @ApiOperation(value = "提交代码")
     @PostMapping("/submitCode")
     @PostMapping("/submitCode")
     public Result submitCode(@RequestParam("code") String code,
     public Result submitCode(@RequestParam("code") String code,
                              @RequestParam("questionId") String questionID,
                              @RequestParam("questionId") String questionID,

+ 23 - 23
src/main/java/com/example/onlinejudge/controller/UserController.java

@@ -2,50 +2,50 @@ package com.example.onlinejudge.controller;
 
 
 import cn.dev33.satoken.stp.StpUtil;
 import cn.dev33.satoken.stp.StpUtil;
 import cn.dev33.satoken.util.SaResult;
 import cn.dev33.satoken.util.SaResult;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.druid.util.StringUtils;
+import com.example.onlinejudge.model.dto.user.UserLoginRequest;
 import com.example.onlinejudge.model.entity.result.Result;
 import com.example.onlinejudge.model.entity.result.Result;
+import com.example.onlinejudge.model.entity.result.ResultCode;
 import com.example.onlinejudge.service.UserService;
 import com.example.onlinejudge.service.UserService;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
-/**
- * 用户Controller层
- */
+import javax.annotation.Resource;
+
+
 @Controller
 @Controller
 @RequestMapping("/api/user")
 @RequestMapping("/api/user")
 public class UserController {
 public class UserController {
-    @Autowired
+
+    @Resource
     private UserService userService;
     private UserService userService;
 
 
-    /**
-     * 登录
-     *
-     * @param username 用户名
-     * @param password 用户密码
-     * @return 用户bean
-     */
-    @PostMapping("/login/{username}/{password}")
+    @ApiOperation(value = "用户登录")
+    @PostMapping("/login")
     @ResponseBody
     @ResponseBody
-    public Result login(@PathVariable("username") String username,
-                        @PathVariable("password") String password) {
+    public Result login(@RequestBody UserLoginRequest userLoginRequest) {
+        if(userLoginRequest == null) {
+            return Result.error(ResultCode.PARAM_IS_INVALID.getCode(),ResultCode.PARAM_IS_INVALID.getMessage());
+        }
+        String username = userLoginRequest.getUserName();
+        String password = userLoginRequest.getPassword();
+        if(StrUtil.isBlank(username) || StrUtil.isBlank(password)) {
+            return Result.error(ResultCode.PARAM_IS_BLANK.getCode(),ResultCode.PARAM_IS_BLANK.getMessage());
+        }
         return userService.login(username, password);
         return userService.login(username, password);
     }
     }
 
 
-    /**
-     * 测试是否登录
-     *
-     * @return 字符串
-     */
+    @ApiOperation(value = "判断用户是否登录")
     @GetMapping("/isLogin")
     @GetMapping("/isLogin")
     @ResponseBody
     @ResponseBody
     public String isLogin() {
     public String isLogin() {
         return "当前会话登录了";
         return "当前会话登录了";
     }
     }
 
 
-    /**
-     * 测试注销
-     * @return LinkedHashMap
-     */
+    @ApiOperation(value = "用户登出")
     @GetMapping("/logout")
     @GetMapping("/logout")
     @ResponseBody
     @ResponseBody
     public Result logout() {
     public Result logout() {

+ 16 - 33
src/main/java/com/example/onlinejudge/model/VO/QuestionSubmitVO.java

@@ -3,6 +3,9 @@ package com.example.onlinejudge.model.VO;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.JSONUtil;
 import com.example.onlinejudge.model.dto.questionSubmit.JudgeInfo;
 import com.example.onlinejudge.model.dto.questionSubmit.JudgeInfo;
 import com.example.onlinejudge.model.entity.QuestionSubmit;
 import com.example.onlinejudge.model.entity.QuestionSubmit;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiOperation;
 import lombok.Data;
 import lombok.Data;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 
 
@@ -10,60 +13,40 @@ import java.io.Serializable;
 import java.util.Date;
 import java.util.Date;
 
 
 @Data
 @Data
+@ApiModel("提交题目信息")
 public class QuestionSubmitVO implements Serializable {
 public class QuestionSubmitVO implements Serializable {
-    /**
-     * id
-     */
+
+    @ApiModelProperty("提交题目ID")
     private Long id;
     private Long id;
 
 
-    /**
-     * 编程语言
-     */
+    @ApiModelProperty("编程语言")
     private String language;
     private String language;
 
 
-    /**
-     * 用户代码
-     */
+    @ApiModelProperty("用户代码")
     private String code;
     private String code;
 
 
-    /**
-     * 判题信息
-     */
+    @ApiModelProperty("判题信息")
     private JudgeInfo judgeInfo;
     private JudgeInfo judgeInfo;
 
 
-    /**
-     * 判题状态(0 - 待判题、1 - 判题中、2 - 成功、3 - 失败)
-     */
+    @ApiModelProperty("判题状态(0 - 待判题、1 - 判题中、2 - 成功、3 - 失败)")
     private Integer status;
     private Integer status;
 
 
-    /**
-     * 题目 id
-     */
+    @ApiModelProperty("题目 id")
     private Long questionId;
     private Long questionId;
 
 
-    /**
-     * 创建用户 id
-     */
+    @ApiModelProperty("创建用户 id")
     private Long userId;
     private Long userId;
 
 
-    /**
-     * 创建时间
-     */
+    @ApiModelProperty("创建时间")
     private Date createTime;
     private Date createTime;
 
 
-    /**
-     * 更新时间
-     */
+    @ApiModelProperty("更新时间")
     private Date updateTime;
     private Date updateTime;
 
 
-    /**
-     * 提交用户信息
-     */
+    @ApiModelProperty("提交用户信息")
     private UserVO userVO;
     private UserVO userVO;
 
 
-    /**
-     * 对应题目信息
-     */
+    @ApiModelProperty("对应题目信息")
     private QuestionVO questionVO;
     private QuestionVO questionVO;
 
 
     /**
     /**

+ 15 - 46
src/main/java/com/example/onlinejudge/model/VO/QuestionVO.java

@@ -3,80 +3,49 @@ package com.example.onlinejudge.model.VO;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.JSONUtil;
 import com.example.onlinejudge.model.dto.question.JudgeConfig;
 import com.example.onlinejudge.model.dto.question.JudgeConfig;
 import com.example.onlinejudge.model.entity.Question;
 import com.example.onlinejudge.model.entity.Question;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 
 
 import java.util.Date;
 import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
-/**
- * 题目封装类
- */
+@ApiModel("题目封装类")
 @Data
 @Data
 public class QuestionVO {
 public class QuestionVO {
-    /**
-     * id
-     */
+
+    @ApiModelProperty("题目ID")
     private Long id;
     private Long id;
 
 
-    /**
-     * 标题
-     */
+    @ApiModelProperty("题目标题")
     private String title;
     private String title;
 
 
-    /**
-     * 内容
-     */
+    @ApiModelProperty("题目内容")
     private String content;
     private String content;
 
 
-    /**
-     * 标签列表
-     */
+    @ApiModelProperty("题目标签")
     private List<String> tags;
     private List<String> tags;
 
 
-    /**
-     * 题目提交数
-     */
+    @ApiModelProperty("题目提交数")
     private Integer submitNum;
     private Integer submitNum;
 
 
-    /**
-     * 题目通过数
-     */
+    @ApiModelProperty("题目通过数")
     private Integer acceptedNum;
     private Integer acceptedNum;
 
 
-    /**
-     * 判题配置(json 对象)
-     */
+    @ApiModelProperty("判题配置")
     private JudgeConfig judgeConfig;
     private JudgeConfig judgeConfig;
 
 
-    /**
-     * 点赞数
-     */
-    private Integer thumbNum;
-
-    /**
-     * 收藏数
-     */
-    private Integer favourNum;
-
-    /**
-     * 创建用户 id
-     */
+    @ApiModelProperty("创建用户 id")
     private Long userId;
     private Long userId;
 
 
-    /**
-     * 创建时间
-     */
+    @ApiModelProperty("创建时间")
     private Date createTime;
     private Date createTime;
 
 
-    /**
-     * 更新时间
-     */
+    @ApiModelProperty("更新时间")
     private Date updateTime;
     private Date updateTime;
 
 
-    /**
-     * 创建题目人的信息
-     */
+    @ApiModelProperty("创建用户信息")
     private UserVO userVO;
     private UserVO userVO;
 
 
     /**
     /**

+ 6 - 9
src/main/java/com/example/onlinejudge/model/dto/question/JudgeCase.java

@@ -1,20 +1,17 @@
 package com.example.onlinejudge.model.dto.question;
 package com.example.onlinejudge.model.dto.question;
 
 
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 
 
-/**
- * 题目用例
- */
+
+@ApiModel("测试用例")
 @Data
 @Data
 public class JudgeCase {
 public class JudgeCase {
 
 
-        /**
-        * 输入用例
-        */
+        @ApiModelProperty("输入用例")
         private String input;
         private String input;
 
 
-        /**
-        * 输出用例
-        */
+        @ApiModelProperty("输出用例")
         private String output;
         private String output;
 }
 }

+ 6 - 12
src/main/java/com/example/onlinejudge/model/dto/question/JudgeConfig.java

@@ -1,25 +1,19 @@
 package com.example.onlinejudge.model.dto.question;
 package com.example.onlinejudge.model.dto.question;
 
 
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 
 
-/**
- * 题目配置
- */
+@ApiModel("题目配置")
 @Data
 @Data
 public class JudgeConfig {
 public class JudgeConfig {
 
 
-        /**
-        * 时间限制(ms)
-        */
+        @ApiModelProperty("时间限制(ms)")
         private Long timeLimit;
         private Long timeLimit;
 
 
-        /**
-        * 内存限制(KB)
-        */
+        @ApiModelProperty("内存限制(KB)")
         private Long memoryLimit;
         private Long memoryLimit;
 
 
-        /**
-        * 堆栈限制(KB)
-        */
+        @ApiModelProperty("堆栈限制(KB)")
         private Long stackLimit;
         private Long stackLimit;
 }
 }

+ 7 - 9
src/main/java/com/example/onlinejudge/model/dto/questionSubmit/JudgeInfo.java

@@ -1,22 +1,20 @@
 package com.example.onlinejudge.model.dto.questionSubmit;
 package com.example.onlinejudge.model.dto.questionSubmit;
 
 
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 
 
 @Data
 @Data
+@ApiModel("评测信息")
 public class JudgeInfo {
 public class JudgeInfo {
 
 
-        /**
-        * 程序执行信息
-        */
+
+        @ApiModelProperty("程序执行信息")
         private String message;
         private String message;
 
 
-        /**
-        * 消耗内存
-        */
+        @ApiModelProperty("消耗内存(KB)")
         private Long memory;
         private Long memory;
 
 
-        /**
-        * 消耗时间(KB)
-        */
+        @ApiModelProperty("消耗时间(ms)")
         private Long time;
         private Long time;
 }
 }

+ 7 - 9
src/main/java/com/example/onlinejudge/model/dto/questionSubmit/QuestionSubmitAddRequest.java

@@ -1,24 +1,22 @@
 package com.example.onlinejudge.model.dto.questionSubmit;
 package com.example.onlinejudge.model.dto.questionSubmit;
 
 
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
 
 
+@ApiModel("添加题目请求")
 @Data
 @Data
 public class QuestionSubmitAddRequest implements Serializable {
 public class QuestionSubmitAddRequest implements Serializable {
-    /**
-     * 编程语言
-     */
+
+    @ApiModelProperty("编程语言")
     private String language;
     private String language;
 
 
-    /**
-     * 用户代码
-     */
+    @ApiModelProperty("用户代码")
     private String code;
     private String code;
 
 
-    /**
-     * 题目 id
-     */
+    @ApiModelProperty("题目ID")
     private Long questionId;
     private Long questionId;
 
 
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;

+ 6 - 9
src/main/java/com/example/onlinejudge/model/dto/questionSubmit/QuestionSubmitQueryRequest.java

@@ -1,25 +1,22 @@
 package com.example.onlinejudge.model.dto.questionSubmit;
 package com.example.onlinejudge.model.dto.questionSubmit;
 
 
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
 
 
+@ApiModel("查询题目请求")
 @Data
 @Data
 public class QuestionSubmitQueryRequest implements Serializable {
 public class QuestionSubmitQueryRequest implements Serializable {
 
 
-        /**
-        * 编程语言
-        */
+        @ApiModelProperty("编程语言")
         private String language;
         private String language;
 
 
-        /**
-        * 用户代码
-        */
+        @ApiModelProperty("用户代码")
         private String code;
         private String code;
 
 
-        /**
-        * 题目 id
-        */
+        @ApiModelProperty("题目ID")
         private Long questionId;
         private Long questionId;
 
 
         private static final long serialVersionUID = 1L;
         private static final long serialVersionUID = 1L;

+ 21 - 0
src/main/java/com/example/onlinejudge/model/dto/user/UserLoginRequest.java

@@ -0,0 +1,21 @@
+package com.example.onlinejudge.model.dto.user;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@ApiModel("用户登录请求")
+@Data
+public class UserLoginRequest implements Serializable {
+
+    @ApiModelProperty("用户ID")
+    private static final long serialVersionUID = 3191241716373120793L;
+
+    @ApiModelProperty("用户名")
+    private String userName;
+
+    @ApiModelProperty("密码")
+    private String password;
+}

+ 16 - 52
src/main/java/com/example/onlinejudge/model/entity/Question.java

@@ -1,89 +1,53 @@
 package com.example.onlinejudge.model.entity;
 package com.example.onlinejudge.model.entity;
 
 
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.annotation.*;
 
 
 import java.util.Date;
 import java.util.Date;
 
 
-/**
- * 题目
- */
+@ApiModel("题目")
 @Data
 @Data
 public class Question {
 public class Question {
-    /**
-     * id
-     */
+    @ApiModelProperty("题目ID")
     @TableId(type = IdType.ASSIGN_ID)
     @TableId(type = IdType.ASSIGN_ID)
     private Long id;
     private Long id;
 
 
-    /**
-     * 标题
-     */
+    @ApiModelProperty("题目标题")
     private String title;
     private String title;
 
 
-    /**
-     * 内容
-     */
+    @ApiModelProperty("题目内容")
     private String content;
     private String content;
 
 
-    /**
-     * 标签列表(json 数组)
-     */
+    @ApiModelProperty("题目标签(json数组)")
     private String tags;
     private String tags;
 
 
-    /**
-     * 题目答案
-     */
+    @ApiModelProperty("题目答案")
     private String answer;
     private String answer;
 
 
-    /**
-     * 题目提交数
-     */
+    @ApiModelProperty("题目提交数")
     private Integer submitNum;
     private Integer submitNum;
 
 
-    /**
-     * 题目通过数
-     */
+    @ApiModelProperty("题目通过数")
     private Integer acceptedNum;
     private Integer acceptedNum;
 
 
-    /**
-     * 判题用例(json 数组)
-     */
+    @ApiModelProperty("判题用例(json 数组)")
     private String judgeCase;
     private String judgeCase;
 
 
-    /**
-     * 判题配置(json 对象)
-     */
+    @ApiModelProperty("判题配置(json 对象)")
     private String judgeConfig;
     private String judgeConfig;
 
 
-    /**
-     * 点赞数
-     */
-    private Integer thumbNum;
-
-    /**
-     * 收藏数
-     */
-    private Integer favourNum;
-
-    /**
-     * 创建用户 id
-     */
+    @ApiModelProperty("创建用户 id")
     private Long userId;
     private Long userId;
 
 
-    /**
-     * 创建时间
-     */
+    @ApiModelProperty("创建时间")
     private Date createTime;
     private Date createTime;
 
 
-    /**
-     * 更新时间
-     */
+    @ApiModelProperty("更新时间")
     private Date updateTime;
     private Date updateTime;
 
 
-    /**
-     * 是否删除
-     */
+    @ApiModelProperty("是否删除")
     @TableLogic
     @TableLogic
     private Integer isDelete;
     private Integer isDelete;
 
 

+ 19 - 42
src/main/java/com/example/onlinejudge/model/entity/QuestionSubmit.java

@@ -2,83 +2,60 @@ package com.example.onlinejudge.model.entity;
 
 
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.annotation.*;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.NoArgsConstructor;
 
 
 import java.util.Date;
 import java.util.Date;
 
 
-/**
- * 题目提交
- */
+
+@ApiModel("题目提交")
 @TableName(value ="question_submit")
 @TableName(value ="question_submit")
 @Data
 @Data
 @AllArgsConstructor
 @AllArgsConstructor
 @NoArgsConstructor
 @NoArgsConstructor
 public class QuestionSubmit {
 public class QuestionSubmit {
-    /**
-     * id
-     */
+
+    @ApiModelProperty("提交ID")
     @TableId(type = IdType.ASSIGN_ID)
     @TableId(type = IdType.ASSIGN_ID)
     private Long id;
     private Long id;
 
 
-    /**
-     * 编程语言
-     */
+    @ApiModelProperty("编程语言")
     private String language;
     private String language;
 
 
-    /**
-     * 用户代码
-     */
+    @ApiModelProperty("用户代码")
     private String code;
     private String code;
 
 
-    /**
-     * 判题信息(json 对象)
-     */
+    @ApiModelProperty("判题信息(json 对象)")
     private String judgeInfo;
     private String judgeInfo;
 
 
-    /**
-     * 判题状态(0 - 待判题、1 - 判题中、2 - 成功、3 - 失败)
-     */
+    @ApiModelProperty("判题状态(0 - 待判题、1 - 判题中、2 - 成功、3 - 失败)")
     private Integer status;
     private Integer status;
 
 
-    /**
-     * 题目 id
-     */
+    @ApiModelProperty("题目 id")
     private Long questionId;
     private Long questionId;
 
 
-    /**
-     * 创建用户 id
-     */
+    @ApiModelProperty("创建用户 id")
     private Long userId;
     private Long userId;
 
 
-    /**
-     * 创建时间
-     */
+    @ApiModelProperty("创建时间")
     private Date createTime;
     private Date createTime;
 
 
-    /**
-     * 更新时间
-     */
+    @ApiModelProperty("更新时间")
     private Date updateTime;
     private Date updateTime;
 
 
-    /**
-     * 用户自测用例
-     */
+    @ApiModelProperty("用户自测用例")
     private String userCases;
     private String userCases;
 
 
-    /**
-     * 用户自测用例的输出
-     */
+    @ApiModelProperty("用户自测用例的输出")
     private String output;
     private String output;
-    /**
-     * 判断模式 (0 - 系统用例判别 1 - 用户自测用例判别)
-     */
+
+    @ApiModelProperty("判断模式 (0 - 系统用例判别 1 - 用户自测用例判别)")
     private Integer judgeMode;
     private Integer judgeMode;
 
 
-    /**
-     * 是否删除
-     */
+    @ApiModelProperty("是否删除")
     @TableLogic
     @TableLogic
     private Integer isDelete;
     private Integer isDelete;
 
 

+ 8 - 3
src/main/java/com/example/onlinejudge/model/entity/User.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.NoArgsConstructor;
@@ -11,16 +13,19 @@ import lombok.NoArgsConstructor;
 import java.sql.Timestamp;
 import java.sql.Timestamp;
 import java.util.List;
 import java.util.List;
 
 
-/**
- * 用户bean
- */
+@ApiModel("用户")
 @TableName("user")
 @TableName("user")
 @Data
 @Data
 @AllArgsConstructor
 @AllArgsConstructor
 @NoArgsConstructor
 @NoArgsConstructor
 public class User {
 public class User {
+    @ApiModelProperty("用户ID")
     @TableId(type = IdType.AUTO)
     @TableId(type = IdType.AUTO)
     private Long id;
     private Long id;
+
+    @ApiModelProperty("用户名")
     private String username;
     private String username;
+
+    @ApiModelProperty("密码")
     private String password;
     private String password;
 }
 }

+ 0 - 2
src/main/java/com/example/onlinejudge/service/impl/UserServiceImpl.java

@@ -33,8 +33,6 @@ public class UserServiceImpl implements UserService {
      */
      */
     @Override
     @Override
     public Result login(String username, String password) {
     public Result login(String username, String password) {
-        if (StrUtil.isBlank(username) || StrUtil.isBlank(password))
-            return Result.error(ResultCode.PARAM_IS_BLANK.getCode(), "用户名或密码不能为空");
         QueryWrapper<User> queryWrapper = new QueryWrapper<>();
         QueryWrapper<User> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("username", username).eq("password", password);
         queryWrapper.eq("username", username).eq("password", password);
         User user = userMapper.selectOne(queryWrapper);
         User user = userMapper.selectOne(queryWrapper);