8 changed files with 94 additions and 96 deletions
@ -0,0 +1,16 @@
|
||||
package com.biutag.lan; |
||||
|
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import java.time.Duration; |
||||
import java.time.LocalDateTime; |
||||
|
||||
public class DateTest { |
||||
|
||||
@Test |
||||
public void test() { |
||||
long l = 345600 - Duration.between(LocalDateTime.of(2024, 3, 19, 13, 0, 0), LocalDateTime.now()).getSeconds(); |
||||
System.out.println(l / 60 / 60); |
||||
} |
||||
|
||||
} |
||||
@ -1,40 +0,0 @@
|
||||
package com.biutag.outer.controller; |
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.biutag.exception.AuthException; |
||||
import com.biutag.outer.domain.Mail; |
||||
import com.biutag.outer.service.MailService; |
||||
import jakarta.servlet.http.HttpServletRequest; |
||||
import lombok.RequiredArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.time.LocalDateTime; |
||||
|
||||
@Slf4j |
||||
@RequiredArgsConstructor |
||||
@RequestMapping("api") |
||||
@RestController |
||||
public class ApiController { |
||||
|
||||
private final MailService mailService; |
||||
|
||||
@GetMapping("mail") |
||||
public Page<Mail> list(Page<Mail> page, |
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam LocalDateTime beginTime, |
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam LocalDateTime endTime, |
||||
HttpServletRequest request) { |
||||
log.info("开始时间:{} 结束时间:{}", beginTime, endTime); |
||||
// 校验token
|
||||
String authorization = request.getHeader("Authorization"); |
||||
if (!"chuangke".equals(authorization)) { |
||||
throw new AuthException(); |
||||
} |
||||
return mailService.pageByCreateTime(page, beginTime, endTime); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue