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);