upd sing method
parent
b458abf461
commit
a1959f22f3
|
@ -25,6 +25,13 @@ public class SysSignController {
|
|||
private SysSignService sysSignService;
|
||||
|
||||
|
||||
/**
|
||||
* @description: 查询当前登录人的签到记录
|
||||
* @param:
|
||||
* @return: Result
|
||||
* @author 冯凯
|
||||
* @date: 2023/11/5 14:03
|
||||
*/
|
||||
@GetMapping("/search/sign")
|
||||
public Result searchSignByUserId(){
|
||||
//获取当前登录人userId
|
||||
|
@ -36,6 +43,14 @@ public class SysSignController {
|
|||
return Result.success(sign);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 当前登录人进行签字
|
||||
* @param:
|
||||
* @return: Result
|
||||
* @author 冯凯
|
||||
* @date: 2023/11/5 14:04
|
||||
*/
|
||||
@PostMapping("/sign/byUserId")
|
||||
public Result signByUserId(){
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
|
|
|
@ -39,7 +39,7 @@ public class SysSignServiceImpl implements SysSignService {
|
|||
if (redisService.hasKey("sign:" + userId)) {
|
||||
Sign redisSign = redisService.getCacheObject("sign:" + userId);
|
||||
Date signTime = redisSign.getSignTime();
|
||||
LocalDate redisDate = signTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
LocalDate redisDate = signTime.toInstant().atZone(ZoneId.of("GMT+8")).toLocalDate();
|
||||
|
||||
// 如果 Redis 缓存中的日期与当前日期相等,则认为客户当天已经签到过
|
||||
if (redisDate.isEqual(today)) {
|
||||
|
@ -51,7 +51,7 @@ public class SysSignServiceImpl implements SysSignService {
|
|||
// 从数据库中获取最近一次签到记录
|
||||
Sign sign = sysSignMapper.searchSignByUserId(userId);
|
||||
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);
|
||||
|
||||
// 判断是否已经断签
|
||||
|
@ -72,9 +72,9 @@ public class SysSignServiceImpl implements SysSignService {
|
|||
// 断签了,需要将签到次数清零,并更新数据库中的签到次数
|
||||
System.out.println("断签了!!!!");
|
||||
sign.setSignAmount(0);
|
||||
System.out.println(sign);
|
||||
sysSignMapper.updateSingAmountByUserId(sign);
|
||||
}
|
||||
|
||||
return sign;
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,7 @@ public class SysSignServiceImpl implements SysSignService {
|
|||
return expireTime;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void signByUserId(Long userId) {
|
||||
Sign sign = sysSignMapper.searchSignByUserId(userId);
|
||||
|
|
Loading…
Reference in New Issue