From f2a015dc1accb18f33f003ab4cbad4ed0d47aecc Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Fri, 2 Feb 2024 18:05:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=A6=E8=AF=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/controller/UserBookClockInController.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/peanut/modules/book/controller/UserBookClockInController.java b/src/main/java/com/peanut/modules/book/controller/UserBookClockInController.java index 8145f3b7..3619a9cc 100644 --- a/src/main/java/com/peanut/modules/book/controller/UserBookClockInController.java +++ b/src/main/java/com/peanut/modules/book/controller/UserBookClockInController.java @@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; /** @@ -120,12 +122,21 @@ public class UserBookClockInController { @RequestMapping(value = "/correctClockIn", method = RequestMethod.GET) public R correctClockIn(@RequestParam("bookId") Integer bookId, @RequestParam("userId") Integer userId, - @RequestParam("day") Integer day) { + @RequestParam("day") Integer day) throws ParseException { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("book_id", bookId); queryWrapper.eq("user_id", userId); UserBookClockEntity userBookClock = userBookClockService.getOne(queryWrapper); String clocksStr = userBookClock.getClocks(); + + long time = userBookClock.getBeginDate().getTime(); + Date date = new Date(); + long time1 = date.getTime(); + int c = (int)(time1-time); + int c_day = c/86400000; + if(day<(c_day-7)){ + return R.error("不可补卡超过7天"); + } List clockInDaysList = JSON.parseObject(clocksStr, new TypeReference>() { }); clockInDaysList.add(day);