From 219780c1d142cd3824726400acc05ed5652c47b8 Mon Sep 17 00:00:00 2001 From: "DESKTOP-4U0TDEF\\20371" <2037158277@qq.com> Date: Thu, 15 Jul 2021 15:22:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=BB=8A=E6=97=A5=E7=81=AB=E7=82=B9=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/TokenAuthenticationService.java | 2 +- .../xkrs/controller/FirePointController.java | 18 ++++++++++++++++++ src/main/java/com/xkrs/dao/FirePointDao.java | 11 +++++++++++ .../com/xkrs/service/FirePointService.java | 9 +++++++++ .../service/impl/FirePointServiceImpl.java | 13 +++++++++++++ 5 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java b/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java index 6b8daae..3bc2aab 100644 --- a/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java +++ b/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java @@ -80,7 +80,7 @@ public class TokenAuthenticationService { /** * 动态设置过期时间 */ - final long EXPIRATIONTIME = 60 * 60 * 24 * duration.toDays(); + final long EXPIRATIONTIME = 60 * 60 * duration.toDays() * 24_000 ; // 生成JWT String jwt = Jwts.builder() diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index 0a9a3c0..89c4b59 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -12,6 +12,7 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.List; import java.util.Locale; import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; @@ -63,4 +64,21 @@ public class FirePointController { } return outputEncapsulationObject(PromptMessageEnum.SUCCESS,sysUserEntity.getUserName(),locale); } + + /** + * 查询今天的好点信息 + * @param token + * @return + */ + @GetMapping("/selectTodayFirePoint") + @PreAuthorize("hasAnyAuthority('auth_general_user')") + public String selectTodayFirePoint(@RequestHeader(value="Authorization") String token){ + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + List firePointEntities = firePointService.selectTodayFirePoint(); + if(firePointEntities == null || firePointEntities.size() == 0){ + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale); + } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale); + } } diff --git a/src/main/java/com/xkrs/dao/FirePointDao.java b/src/main/java/com/xkrs/dao/FirePointDao.java index fe2e6f0..3c3ac1f 100644 --- a/src/main/java/com/xkrs/dao/FirePointDao.java +++ b/src/main/java/com/xkrs/dao/FirePointDao.java @@ -2,11 +2,22 @@ package com.xkrs.dao; import com.xkrs.model.entity.FirePointEntity; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Component; +import java.util.List; + /** * @author XinYi Song */ @Component public interface FirePointDao extends JpaRepository { + + /** + * 查询今天的火点信息 + * @param addTime + * @return + */ + @Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%')",nativeQuery = true) + List selectTodayFirePoint(String addTime); } diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java index e13389f..a7f1be9 100644 --- a/src/main/java/com/xkrs/service/FirePointService.java +++ b/src/main/java/com/xkrs/service/FirePointService.java @@ -4,6 +4,8 @@ import com.xkrs.dao.FirePointDao; import com.xkrs.model.entity.FirePointEntity; import com.xkrs.model.qo.FirePointQo; +import java.util.List; + /** * @author XinYi Song */ @@ -15,4 +17,11 @@ public interface FirePointService { * @return */ FirePointEntity insertFirePoint(FirePointQo firePointQo); + + /** + * 查询今天的火点信息 + * @param + * @return + */ + List selectTodayFirePoint(); } diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 632dd98..a98ecaa 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -11,7 +11,9 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.List; /** * @author XinYi Song @@ -48,4 +50,15 @@ public class FirePointServiceImpl implements FirePointService { return firePointDao.save(firePointEntity); } + + /** + * 查询今天的火点信息 + * @param + * @return + */ + @Override + public List selectTodayFirePoint() { + String addTime = DateTimeUtil.dateToString(LocalDate.now()); + return firePointDao.selectTodayFirePoint(addTime); + } }