|
@@ -3,6 +3,7 @@ package com.example.onlinejudge.service.impl;
|
|
|
import cn.dev33.satoken.stp.SaTokenInfo;
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.dev33.satoken.util.SaResult;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.example.onlinejudge.model.entity.User;
|
|
|
import com.example.onlinejudge.mapper.UserMapper;
|
|
@@ -11,6 +12,7 @@ import com.example.onlinejudge.model.entity.result.ResultCode;
|
|
|
import com.example.onlinejudge.service.UserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import sun.security.krb5.internal.PAData;
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
@@ -31,16 +33,8 @@ public class UserServiceImpl implements UserService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Result login(String username, String password) {
|
|
|
- if (username == null || password == null) {
|
|
|
- return Result.error(ResultCode.PARAM_IS_BLANK);
|
|
|
- }
|
|
|
- username = username.trim();
|
|
|
- if (username.length() == 0) {
|
|
|
- return Result.error(ResultCode.PARAM_IS_BLANK.getCode(), "用户名长度不能为0");
|
|
|
- }
|
|
|
- if (password.length() == 0) {
|
|
|
- return Result.error(ResultCode.PARAM_IS_BLANK.getCode(), "密码长度不能为0");
|
|
|
- }
|
|
|
+ if (StrUtil.isBlank(username) || StrUtil.isBlank(password))
|
|
|
+ return Result.error(ResultCode.PARAM_IS_BLANK.getCode(), "用户名或密码不能为空");
|
|
|
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("username", username).eq("password", password);
|
|
|
User user = userMapper.selectOne(queryWrapper);
|