Browse Source

修复user

westt 1 year ago
parent
commit
050b62401f

+ 1 - 1
src/main/java/com/example/onlinejudge/controller/QuestionSubmitController.java

@@ -53,7 +53,7 @@ public class QuestionSubmitController {
             return new Result(ResultCode.PARAM_IS_INVALID.getCode(),ResultCode.PARAM_IS_INVALID.getMessage());
         }
         // 登录才能点赞
-//        final User loginUser = userService.getLoginUser(request);
+        final User loginUser = userService.getLoginUser(request);
         long questionSubmitId = questionSubmitService.doQuestionSubmit(questionSubmitAddRequest, loginUser);
         return Result.success(questionSubmitId);
     }

+ 0 - 3
src/main/java/com/example/onlinejudge/mapper/UserMapper.java

@@ -6,7 +6,4 @@ import org.apache.ibatis.annotations.Mapper;
 
 @Mapper
 public interface UserMapper extends BaseMapper<User> {
-    User selectUserById(Integer id);
-    User selectUserByUsernameAndPassword(String username, String password);
-    boolean insertUser(String username, String password);
 }

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

@@ -10,12 +10,12 @@ import java.io.Serializable;
 @Data
 public class UserLoginRequest implements Serializable {
 
-    @ApiModelProperty("用户ID")
-    private static final long serialVersionUID = 3191241716373120793L;
 
     @ApiModelProperty("用户名")
     private String userName;
 
     @ApiModelProperty("密码")
     private String password;
+
+    private static final long serialVersionUID = 3191241716373120793L;
 }

+ 4 - 1
src/main/java/com/example/onlinejudge/service/UserService.java

@@ -1,10 +1,13 @@
 package com.example.onlinejudge.service;
 
 import cn.dev33.satoken.util.SaResult;
+import com.example.onlinejudge.model.entity.User;
 import com.example.onlinejudge.model.entity.result.Result;
 
+import javax.servlet.http.HttpServletRequest;
+
 public interface UserService {
     Result login(String username, String password);
 
-    String getLoginUser();
+    User getLoginUser(HttpServletRequest request);
 }

+ 82 - 1
src/main/java/com/example/onlinejudge/service/impl/QuestionSubmitServiceImpl.java

@@ -1,4 +1,85 @@
 package com.example.onlinejudge.service.impl;
 
-public class QuestionSubmitServiceImpl {
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.example.onlinejudge.model.VO.QuestionSubmitVO;
+import com.example.onlinejudge.model.dto.questionSubmit.QuestionSubmitAddRequest;
+import com.example.onlinejudge.model.dto.questionSubmit.QuestionSubmitQueryRequest;
+import com.example.onlinejudge.model.entity.QuestionSubmit;
+import com.example.onlinejudge.model.entity.User;
+import com.example.onlinejudge.service.QuestionSubmitService;
+import org.springframework.stereotype.Service;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.function.Function;
+
+@Service
+public class QuestionSubmitServiceImpl implements QuestionSubmitService {
+    @Override
+    public long doQuestionSubmit(QuestionSubmitAddRequest questionSubmitAddRequest, User loginUser) {
+        return 0;
+    }
+
+    @Override
+    public QueryWrapper<QuestionSubmit> getQueryWrapper(QuestionSubmitQueryRequest questionSubmitQueryRequest) {
+        return null;
+    }
+
+    @Override
+    public QuestionSubmitVO getQuestionSubmitVO(QuestionSubmit questionSubmit, User loginUser) {
+        return null;
+    }
+
+    @Override
+    public Page<QuestionSubmitVO> getQuestionSubmitVOPage(Page<QuestionSubmit> questionSubmitPage, User loginUser) {
+        return null;
+    }
+
+    @Override
+    public boolean saveBatch(Collection<QuestionSubmit> entityList, int batchSize) {
+        return false;
+    }
+
+    @Override
+    public boolean saveOrUpdateBatch(Collection<QuestionSubmit> entityList, int batchSize) {
+        return false;
+    }
+
+    @Override
+    public boolean updateBatchById(Collection<QuestionSubmit> entityList, int batchSize) {
+        return false;
+    }
+
+    @Override
+    public boolean saveOrUpdate(QuestionSubmit entity) {
+        return false;
+    }
+
+    @Override
+    public QuestionSubmit getOne(Wrapper<QuestionSubmit> queryWrapper, boolean throwEx) {
+        return null;
+    }
+
+    @Override
+    public Map<String, Object> getMap(Wrapper<QuestionSubmit> queryWrapper) {
+        return null;
+    }
+
+    @Override
+    public <V> V getObj(Wrapper<QuestionSubmit> queryWrapper, Function<? super Object, V> mapper) {
+        return null;
+    }
+
+    @Override
+    public BaseMapper<QuestionSubmit> getBaseMapper() {
+        return null;
+    }
+
+    @Override
+    public Class<QuestionSubmit> getEntityClass() {
+        return null;
+    }
 }

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

@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import sun.security.krb5.internal.PAData;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.LinkedHashMap;
 
 /**
@@ -44,8 +45,8 @@ public class UserServiceImpl implements UserService {
     }
 
     @Override
-    public String getLoginUser() {
-        return StpUtil.getLoginId().toString();
+    public User getLoginUser(HttpServletRequest request) {
+        return userMapper.selectById(StpUtil.getLoginIdAsLong());
     }
 
 }