From f136ed8ce4691725786e02ce048c831e4d373bab Mon Sep 17 00:00:00 2001 From: DengMin <16679070171@qq.com> Date: Thu, 23 Dec 2021 11:38:30 +0800 Subject: [PATCH] 签到数据存储到Redis --- src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java index 2ff5291..a5052ce 100644 --- a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java @@ -11,6 +11,7 @@ import com.subsidy.model.*; import com.subsidy.service.SignInRecordService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.subsidy.util.ConstantUtils; +import com.subsidy.util.DateFormatUtil; import com.subsidy.util.MathUtil; import com.subsidy.util.RedisUtil; import com.subsidy.vo.member.GetMemberSignInfoVO; @@ -21,6 +22,7 @@ import org.springframework.stereotype.Service; import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.Date; import java.util.List; import java.util.Set; @@ -69,19 +71,21 @@ public class SignInRecordServiceImpl extends ServiceImpl classDictDOS = classMemberMappingMapper.getMemberClass(signInRecordDO.getMemberId()); - this.baseMapper.delete(new QueryWrapper() + /*this.baseMapper.delete(new QueryWrapper() .lambda() .eq(SignInRecordDO::getMemberId, signInRecordDO.getMemberId()) - .gt(SignInRecordDO::getSignInDate, LocalDate.now())); + .gt(SignInRecordDO::getSignInDate, LocalDate.now()));*/ for (ClassDictDO classDictDO : classDictDOS) { + /* SignInRecordDO signInRecordDO1 = new SignInRecordDO(); signInRecordDO1.setClassId(classDictDO.getId()); signInRecordDO1.setMemberId(signInRecordDO.getMemberId()); signInRecordDO1.setSignInDate(LocalDateTime.now()); + */ - //redisUtil.set("signInStatus"+signInRecordDO.getMemberId()+classDictDO.getId(),LocalDateTime.now()); - this.baseMapper.insert(signInRecordDO1); + redisUtil.set("subsidySignInfo_"+signInRecordDO.getMemberId()+"_"+classDictDO.getId()+"_"+DateFormatUtil.format(new Date(), "yyyyMMdd")+"_"+System.currentTimeMillis(), null); + // this.baseMapper.insert(signInRecordDO1); } return ConstantUtils.ADD_SUCCESS; @@ -179,13 +183,13 @@ public class SignInRecordServiceImpl extends ServiceImpl classDictDOS = classMemberMappingMapper.getMemberClass(signInRecordDO.getMemberId()); for (ClassDictDO classDictDO : classDictDOS) { - Integer count = this.baseMapper.selectCount(new QueryWrapper() + /*Integer count = this.baseMapper.selectCount(new QueryWrapper() .lambda() .eq(SignInRecordDO::getClassId, classDictDO.getId()) .eq(SignInRecordDO::getMemberId, signInRecordDO.getMemberId()) - .gt(SignInRecordDO::getSignInDate, LocalDate.now())); + .gt(SignInRecordDO::getSignInDate, LocalDate.now()));*/ - //String count = redisUtil.get("signInStatus:"+signInRecordDO.getMemberId()+":"+classDictDO.getId()).toString(); + long count = redisUtil.keys("*subsidySignInfo_"+signInRecordDO.getMemberId()+"_"+classDictDO.getId()+"_"+DateFormatUtil.format(new Date(), "yyyyMMdd")+"*").stream().count(); if (count == 0) { flag = false; //没有签到 -- libgit2 0.25.0