添加了查询今日火点的接口

This commit is contained in:
DESKTOP-4U0TDEF\20371 2021-07-15 15:22:23 +08:00
parent c1adf0e28a
commit 219780c1d1
5 changed files with 52 additions and 1 deletions

View File

@ -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()

View File

@ -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<FirePointEntity> firePointEntities = firePointService.selectTodayFirePoint();
if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
}
}

View File

@ -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<FirePointEntity,Long> {
/**
* 查询今天的火点信息
* @param addTime
* @return
*/
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%')",nativeQuery = true)
List<FirePointEntity> selectTodayFirePoint(String addTime);
}

View File

@ -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<FirePointEntity> selectTodayFirePoint();
}

View File

@ -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<FirePointEntity> selectTodayFirePoint() {
String addTime = DateTimeUtil.dateToString(LocalDate.now());
return firePointDao.selectTodayFirePoint(addTime);
}
}