|
@@ -19,9 +19,7 @@ import com.ynfy.buss.practice.userpractice.mapper.UserPracticeMapper;
|
|
|
import com.ynfy.buss.practice.userpractice.service.IUserPracticeService;
|
|
|
import com.ynfy.buss.practice.userpracticequestion.entity.UserPracticeQuestion;
|
|
|
import com.ynfy.buss.practice.userpracticequestion.service.IUserPracticeQuestionService;
|
|
|
-import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
-import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -51,13 +49,10 @@ public class UserPracticeServiceImpl extends ServiceImpl<UserPracticeMapper, Use
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<UserPractice> getRecentPractice(String repositoryId) {
|
|
|
- LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
-
|
|
|
+ public List<UserPractice> getRecentPractice(String repositoryId, String userId) {
|
|
|
Page<UserPractice> page = new Page<UserPractice>(1, 5);
|
|
|
-
|
|
|
LambdaQueryWrapper<UserPractice> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(UserPractice::getUserId, user.getId()).eq(UserPractice::getRepositoryId, repositoryId)
|
|
|
+ wrapper.eq(UserPractice::getUserId, userId).eq(UserPractice::getRepositoryId, repositoryId)
|
|
|
.orderByDesc(UserPractice::getCommitTime);
|
|
|
IPage<UserPractice> pageList = page(page, wrapper);
|
|
|
return pageList.getRecords();
|
|
@@ -157,4 +152,20 @@ public class UserPracticeServiceImpl extends ServiceImpl<UserPracticeMapper, Use
|
|
|
public IPage<UserPractice> selectPageList(IPage<UserPractice> page, UserPractice userPractice) {
|
|
|
return userPracticeMapper.selectPageList(page, userPractice);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 最近练习
|
|
|
+ *
|
|
|
+ * @param limit
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<UserPractice> listLatestPractice(Integer limit, String userId) {
|
|
|
+ LambdaQueryWrapper<UserPractice> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(UserPractice::getUserId, userId).last("LIMIT " + limit)
|
|
|
+ .orderByDesc(UserPractice::getCommitTime);
|
|
|
+ return list(wrapper);
|
|
|
+ }
|
|
|
}
|