Browse Source

最近练习

yangfeng 1 year ago
parent
commit
470611afb2

+ 2 - 2
web/src/main/java/com/ynfy/buss/practice/userpractice/controller/UserPracticeController.java

@@ -166,8 +166,8 @@ public class UserPracticeController extends JeecgController<UserPractice, IUserP
      */
     @ApiOperation(value = "获取用户最近的练习", notes = "获取用户最近的练习")
     @GetMapping(value = "/getRecentPractice")
-    public Result<?> getRecentPractice() {
-        return Result.OK(userPracticeService.getRecentPractice());
+    public Result<?> getRecentPractice(@RequestParam String repositoryId) {
+        return Result.OK(userPracticeService.getRecentPractice(repositoryId));
     }
 
 

+ 1 - 1
web/src/main/java/com/ynfy/buss/practice/userpractice/service/IUserPracticeService.java

@@ -21,7 +21,7 @@ public interface IUserPracticeService extends IService<UserPractice> {
      *
      * @return
      */
-    List<UserPractice> getRecentPractice();
+    List<UserPractice> getRecentPractice(String repositoryId);
 
     String submitPractice(UserPracticeDTO dto);
 

+ 3 - 2
web/src/main/java/com/ynfy/buss/practice/userpractice/service/impl/UserPracticeServiceImpl.java

@@ -48,13 +48,14 @@ public class UserPracticeServiceImpl extends ServiceImpl<UserPracticeMapper, Use
      * @return
      */
     @Override
-    public List<UserPractice> getRecentPractice() {
+    public List<UserPractice> getRecentPractice(String repositoryId) {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 
         Page<UserPractice> page = new Page<UserPractice>(1, 5);
 
         LambdaQueryWrapper<UserPractice> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(UserPractice::getUserId, user.getId()).orderByDesc(UserPractice::getCommitTime);
+        wrapper.eq(UserPractice::getUserId, user.getId()).eq(UserPractice::getRepositoryId, repositoryId)
+                .orderByDesc(UserPractice::getCommitTime);
         IPage<UserPractice> pageList = page(page, wrapper);
         return pageList.getRecords();
     }