自定义 Claim HandlerMethodArgumentResolver

This commit is contained in:
Shikong 2023-05-09 01:30:41 +08:00
parent 90782da7c4
commit f125c1d114
2 changed files with 3 additions and 2 deletions

View File

@ -54,8 +54,7 @@ public class LocationRecordController {
@PostJson("/page") @PostJson("/page")
@Operation(summary = "分页查询记录") @Operation(summary = "分页查询记录")
public JsonResponse<PageWrapper<LocationRecordVo>> getPageLocationRecord(@RequestBody PageLocationRecordParams params, @RequestHeader("token") String token){ public JsonResponse<PageWrapper<LocationRecordVo>> getPageLocationRecord(@Claim Claims claims, @RequestBody PageLocationRecordParams params){
Claims claims = jwtService.parseToken(token);
PageInfo<LocationRecordVo> pageInfo = PageInfo<LocationRecordVo> pageInfo =
LocationRecordConvertor.INSTANCE.daoToVo(locationRecordService.getPageLocationRecord(params, claims.getUserId()).getResult()); LocationRecordConvertor.INSTANCE.daoToVo(locationRecordService.getPageLocationRecord(params, claims.getUserId()).getResult());

View File

@ -12,9 +12,11 @@ import java.util.Date;
public class LocationRecordParams { public class LocationRecordParams {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(example = "2023-05-08 00:00:00")
private Date startTime; private Date startTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(example = "2023-05-08 23:59:59")
private Date endTime; private Date endTime;
} }