| | |
| | | package com.ruoyi.study.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.study.domain.TGame; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.study.domain.TUserStudy; |
| | | import com.ruoyi.study.mapper.TGameMapper; |
| | | import com.ruoyi.study.mapper.TUserStudyMapper; |
| | | import com.ruoyi.study.service.ITGameService; |
| | | import com.ruoyi.study.service.ITUserStudyService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class TUserStudyServiceImpl extends ServiceImpl<TUserStudyMapper, TUserStudy> implements ITUserStudyService { |
| | | |
| | | @Override |
| | | public TUserStudy studySchedule(String userId, Integer week, Integer day) { |
| | | return lambdaQuery().eq(TUserStudy::getUserId, userId) |
| | | .eq(TUserStudy::getDay, day).eq(TUserStudy::getWeek, week) |
| | | .eq(TUserStudy::getDisabled, 0).one(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void resettingStudyRecord(String time) { |
| | | List<TUserStudy> list = lambdaQuery().eq(TUserStudy::getDisabled, 0).list(); |
| | | switch (time) { |
| | | case Constants.DAY: |
| | | list.forEach(data -> data.setTodayStudy(0)); |
| | | break; |
| | | case Constants.WEEK: |
| | | list.forEach(data -> data.setWeekStudy(0)); |
| | | break; |
| | | case Constants.MONTH: |
| | | list.forEach(data -> data.setMonthStudy(0)); |
| | | break; |
| | | default: |
| | | } |
| | | int number = 0; |
| | | boolean update = this.updateBatchById(list); |
| | | while (!update) { |
| | | if (number >= 3) { |
| | | break; |
| | | } |
| | | update = this.updateBatchById(list); |
| | | number++; |
| | | } |
| | | } |
| | | } |