From f138375f15c072d10335c20ecec9b35f1da78ee4 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期三, 03 七月 2024 16:17:59 +0800 Subject: [PATCH] bug修改 --- ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TIntegralRecordServiceImpl.java | 39 ++++++++++++++++++++++++++++++++++++--- 1 files changed, 36 insertions(+), 3 deletions(-) diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TIntegralRecordServiceImpl.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TIntegralRecordServiceImpl.java index e2dd428..c0dccef 100644 --- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TIntegralRecordServiceImpl.java +++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TIntegralRecordServiceImpl.java @@ -1,13 +1,17 @@ package com.ruoyi.study.service.impl; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ruoyi.study.domain.TGameRecord; +import com.ruoyi.common.security.service.TokenService; import com.ruoyi.study.domain.TIntegralRecord; -import com.ruoyi.study.mapper.TGameRecordMapper; import com.ruoyi.study.mapper.TIntegralRecordMapper; -import com.ruoyi.study.service.ITGameRecordService; import com.ruoyi.study.service.ITIntegralRecordService; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; /** * <p> @@ -20,4 +24,33 @@ @Service public class TIntegralRecordServiceImpl extends ServiceImpl<TIntegralRecordMapper, TIntegralRecord> implements ITIntegralRecordService { + @Resource + private TokenService tokenService; + + @Override + public IPage<TIntegralRecord> integralDetail(Page<TIntegralRecord> page, Integer userId, String time) { + IPage<TIntegralRecord> tIntegralRecordIPage = baseMapper.integralDetail(userId, time, page); + List<TIntegralRecord> records = tIntegralRecordIPage.getRecords(); + for (TIntegralRecord record : records) { + if (!record.getIntegral().equals("0") && (!record.getIntegral().contains("-"))){ + record.setIntegral("+" + record.getIntegral()); + } + } + tIntegralRecordIPage.setRecords(records); + return tIntegralRecordIPage; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean add(String integral, String method, Integer gameId, Integer storyId, Integer difficulty, Integer storyType) { + TIntegralRecord integralRecord = new TIntegralRecord(); + integralRecord.setIntegral(integral); + integralRecord.setMethod(method); + integralRecord.setUserId(tokenService.getLoginUserStudy().getUserid()); + integralRecord.setGameId(gameId); + integralRecord.setStoryId(storyId); + integralRecord.setGameDifficulty(difficulty); + integralRecord.setStoryType(storyType); + return this.save(integralRecord); + } } -- Gitblit v1.7.1