upd sing method

master
冯凯 2023-11-05 14:18:42 +08:00
parent b458abf461
commit a1959f22f3
2 changed files with 19 additions and 3 deletions

View File

@ -25,6 +25,13 @@ public class SysSignController {
private SysSignService sysSignService; private SysSignService sysSignService;
/**
* @description:
* @param:
* @return: Result
* @author
* @date: 2023/11/5 14:03
*/
@GetMapping("/search/sign") @GetMapping("/search/sign")
public Result searchSignByUserId(){ public Result searchSignByUserId(){
//获取当前登录人userId //获取当前登录人userId
@ -36,6 +43,14 @@ public class SysSignController {
return Result.success(sign); return Result.success(sign);
} }
/**
* @description:
* @param:
* @return: Result
* @author
* @date: 2023/11/5 14:04
*/
@PostMapping("/sign/byUserId") @PostMapping("/sign/byUserId")
public Result signByUserId(){ public Result signByUserId(){
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();

View File

@ -39,7 +39,7 @@ public class SysSignServiceImpl implements SysSignService {
if (redisService.hasKey("sign:" + userId)) { if (redisService.hasKey("sign:" + userId)) {
Sign redisSign = redisService.getCacheObject("sign:" + userId); Sign redisSign = redisService.getCacheObject("sign:" + userId);
Date signTime = redisSign.getSignTime(); Date signTime = redisSign.getSignTime();
LocalDate redisDate = signTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); LocalDate redisDate = signTime.toInstant().atZone(ZoneId.of("GMT+8")).toLocalDate();
// 如果 Redis 缓存中的日期与当前日期相等,则认为客户当天已经签到过 // 如果 Redis 缓存中的日期与当前日期相等,则认为客户当天已经签到过
if (redisDate.isEqual(today)) { if (redisDate.isEqual(today)) {
@ -51,7 +51,7 @@ public class SysSignServiceImpl implements SysSignService {
// 从数据库中获取最近一次签到记录 // 从数据库中获取最近一次签到记录
Sign sign = sysSignMapper.searchSignByUserId(userId); Sign sign = sysSignMapper.searchSignByUserId(userId);
Date recentTime = sign.getSignTime(); Date recentTime = sign.getSignTime();
LocalDate recentDate = recentTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); LocalDate recentDate = recentTime.toInstant().atZone(ZoneId.of("GMT+8")).toLocalDate();
System.out.println("最近签到是:" + recentDate); System.out.println("最近签到是:" + recentDate);
// 判断是否已经断签 // 判断是否已经断签
@ -72,9 +72,9 @@ public class SysSignServiceImpl implements SysSignService {
// 断签了,需要将签到次数清零,并更新数据库中的签到次数 // 断签了,需要将签到次数清零,并更新数据库中的签到次数
System.out.println("断签了!!!!"); System.out.println("断签了!!!!");
sign.setSignAmount(0); sign.setSignAmount(0);
System.out.println(sign);
sysSignMapper.updateSingAmountByUserId(sign); sysSignMapper.updateSingAmountByUserId(sign);
} }
return sign; return sign;
} }
@ -88,6 +88,7 @@ public class SysSignServiceImpl implements SysSignService {
return expireTime; return expireTime;
} }
@Override @Override
public void signByUserId(Long userId) { public void signByUserId(Long userId) {
Sign sign = sysSignMapper.searchSignByUserId(userId); Sign sign = sysSignMapper.searchSignByUserId(userId);