Commit 496c245c authored by 陈炎's avatar 陈炎

🎨 红旗数据api-优化3

parent 0c2e288d
...@@ -17,7 +17,10 @@ public class MybatisPlusConfig { ...@@ -17,7 +17,10 @@ public class MybatisPlusConfig {
@Bean @Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() { public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
paginationInnerInterceptor.setOverflow(true);
paginationInnerInterceptor.setMaxLimit(500L);
interceptor.addInnerInterceptor(paginationInnerInterceptor);
return interceptor; return interceptor;
} }
......
...@@ -67,6 +67,10 @@ public class CommonDataController extends BaseController { ...@@ -67,6 +67,10 @@ public class CommonDataController extends BaseController {
@ApiOperation(value = "获取token", notes = "token数据", produces = "application/json") @ApiOperation(value = "获取token", notes = "token数据", produces = "application/json")
@PostMapping("/token") @PostMapping("/token")
public BaseResponse<TokenVO> getToken(@RequestBody @Valid TokenDTO dto) { public BaseResponse<TokenVO> getToken(@RequestBody @Valid TokenDTO dto) {
BaseResponse check = baseService.baseLimit(null, dateType, limit, limitPeriod);
if (check != null) {
return check;
}
TokenVO vo = commonDataService.token(dto); TokenVO vo = commonDataService.token(dto);
if (vo == null) { if (vo == null) {
return error(); return error();
......
...@@ -39,7 +39,11 @@ public class BaseService { ...@@ -39,7 +39,11 @@ public class BaseService {
} }
public BaseResponse baseLimit(HttpServletRequest request, String dataType, Integer limit, Integer limitPeriod) { public BaseResponse baseLimit(HttpServletRequest request, String dataType, Integer limit, Integer limitPeriod) {
String fawKey = String.format("%s:%s:limit", dataType, request.getAttribute(BaseController.header)); String header = "token";
if (request != null) {
header = (String) request.getAttribute(BaseController.header);
}
String fawKey = String.format("%s:%s:limit", dataType, header);
RRateLimiter rateLimiter = redissonClient.getRateLimiter(fawKey); RRateLimiter rateLimiter = redissonClient.getRateLimiter(fawKey);
rateLimiter.trySetRate(RateType.OVERALL, limit,limitPeriod, RateIntervalUnit.SECONDS); rateLimiter.trySetRate(RateType.OVERALL, limit,limitPeriod, RateIntervalUnit.SECONDS);
if (!rateLimiter.tryAcquire(1, waiting, TimeUnit.MILLISECONDS)) { if (!rateLimiter.tryAcquire(1, waiting, TimeUnit.MILLISECONDS)) {
......
...@@ -45,7 +45,7 @@ public class CommonDataService { ...@@ -45,7 +45,7 @@ public class CommonDataService {
IPage<ActivityInfo> activityPage = activityInfoMapper.selectPage(page, queryWrapper); IPage<ActivityInfo> activityPage = activityInfoMapper.selectPage(page, queryWrapper);
ActivityInfoStructMapper mapper = Mappers.getMapper(ActivityInfoStructMapper.class); ActivityInfoStructMapper mapper = Mappers.getMapper(ActivityInfoStructMapper.class);
List<ActivityInfoVO> vos = mapper.listActivityInfoToVO(activityPage.getRecords()); List<ActivityInfoVO> vos = mapper.listActivityInfoToVO(activityPage.getRecords());
return BasePageVO.restPage(pageNum, pageSize, (int) activityPage.getTotal(), (int) activityPage.getPages(), vos); return BasePageVO.restPage(pageNum, (int) activityPage.getSize(), (int) activityPage.getTotal(), (int) activityPage.getPages(), vos);
} }
public TokenVO token(TokenDTO dto) { public TokenVO token(TokenDTO dto) {
......
...@@ -57,7 +57,7 @@ public class FawOpenService { ...@@ -57,7 +57,7 @@ public class FawOpenService {
IPage<HongqiAwemeIncentiveMonthly> awemePage = hongqiAwemeIncentiveMonthlyMapper.selectPage(page, queryWrapper); IPage<HongqiAwemeIncentiveMonthly> awemePage = hongqiAwemeIncentiveMonthlyMapper.selectPage(page, queryWrapper);
HongqiAwemeIncentiveStructMapper mapper = Mappers.getMapper(HongqiAwemeIncentiveStructMapper.class); HongqiAwemeIncentiveStructMapper mapper = Mappers.getMapper(HongqiAwemeIncentiveStructMapper.class);
List<HongqiAwemeIncentiveVO> vos = mapper.listLiveMonthlyToVO(awemePage.getRecords()); List<HongqiAwemeIncentiveVO> vos = mapper.listLiveMonthlyToVO(awemePage.getRecords());
return BasePageVO.restPage(pageNum, pageSize, (int) awemePage.getTotal(), (int) awemePage.getPages(), vos); return BasePageVO.restPage(pageNum, (int) awemePage.getSize(), (int) awemePage.getTotal(), (int) awemePage.getPages(), vos);
} else if (quarter.equals(type)) { } else if (quarter.equals(type)) {
IPage<HongqiAwemeIncentiveQuarter> page = new Page<>(pageNum, pageSize); IPage<HongqiAwemeIncentiveQuarter> page = new Page<>(pageNum, pageSize);
QueryWrapper<HongqiAwemeIncentiveQuarter> queryWrapper = new QueryWrapper<>(); QueryWrapper<HongqiAwemeIncentiveQuarter> queryWrapper = new QueryWrapper<>();
...@@ -65,7 +65,7 @@ public class FawOpenService { ...@@ -65,7 +65,7 @@ public class FawOpenService {
IPage<HongqiAwemeIncentiveQuarter> awemePage = hongqiAwemeIncentiveQuarterMapper.selectPage(page, queryWrapper); IPage<HongqiAwemeIncentiveQuarter> awemePage = hongqiAwemeIncentiveQuarterMapper.selectPage(page, queryWrapper);
HongqiAwemeIncentiveStructMapper mapper = Mappers.getMapper(HongqiAwemeIncentiveStructMapper.class); HongqiAwemeIncentiveStructMapper mapper = Mappers.getMapper(HongqiAwemeIncentiveStructMapper.class);
List<HongqiAwemeIncentiveVO> vos = mapper.listLiveQuarterToVO(awemePage.getRecords()); List<HongqiAwemeIncentiveVO> vos = mapper.listLiveQuarterToVO(awemePage.getRecords());
return BasePageVO.restPage(pageNum, pageSize, (int) awemePage.getTotal(), (int) awemePage.getPages(), vos); return BasePageVO.restPage(pageNum, (int) awemePage.getSize(), (int) awemePage.getTotal(), (int) awemePage.getPages(), vos);
} else { } else {
return new BasePageVO<>(); return new BasePageVO<>();
} }
...@@ -80,7 +80,7 @@ public class FawOpenService { ...@@ -80,7 +80,7 @@ public class FawOpenService {
IPage<HongqiLiveIncentiveMonthly> awemePage = hongqiLiveIncentiveMonthlyMapper.selectPage(page, queryWrapper); IPage<HongqiLiveIncentiveMonthly> awemePage = hongqiLiveIncentiveMonthlyMapper.selectPage(page, queryWrapper);
HongqiLiveIncentiveStructMapper mapper = Mappers.getMapper(HongqiLiveIncentiveStructMapper.class); HongqiLiveIncentiveStructMapper mapper = Mappers.getMapper(HongqiLiveIncentiveStructMapper.class);
List<HongqiLiveIncentiveVO> vos = mapper.listLiveMonthlyToVO(awemePage.getRecords()); List<HongqiLiveIncentiveVO> vos = mapper.listLiveMonthlyToVO(awemePage.getRecords());
return BasePageVO.restPage(pageNum, pageSize, (int) awemePage.getTotal(), (int) awemePage.getPages(), vos); return BasePageVO.restPage(pageNum, (int) awemePage.getSize(), (int) awemePage.getTotal(), (int) awemePage.getPages(), vos);
} else if (quarter.equals(type)) { } else if (quarter.equals(type)) {
IPage<HongqiLiveIncentiveQuarter> page = new Page<>(pageNum, pageSize); IPage<HongqiLiveIncentiveQuarter> page = new Page<>(pageNum, pageSize);
QueryWrapper<HongqiLiveIncentiveQuarter> queryWrapper = new QueryWrapper<>(); QueryWrapper<HongqiLiveIncentiveQuarter> queryWrapper = new QueryWrapper<>();
...@@ -88,7 +88,7 @@ public class FawOpenService { ...@@ -88,7 +88,7 @@ public class FawOpenService {
IPage<HongqiLiveIncentiveQuarter> awemePage = hongqiLiveIncentiveQuarterMapper.selectPage(page, queryWrapper); IPage<HongqiLiveIncentiveQuarter> awemePage = hongqiLiveIncentiveQuarterMapper.selectPage(page, queryWrapper);
HongqiLiveIncentiveStructMapper mapper = Mappers.getMapper(HongqiLiveIncentiveStructMapper.class); HongqiLiveIncentiveStructMapper mapper = Mappers.getMapper(HongqiLiveIncentiveStructMapper.class);
List<HongqiLiveIncentiveVO> vos = mapper.listLiveQuarterToVO(awemePage.getRecords()); List<HongqiLiveIncentiveVO> vos = mapper.listLiveQuarterToVO(awemePage.getRecords());
return BasePageVO.restPage(pageNum, pageSize, (int) awemePage.getTotal(), (int) awemePage.getPages(), vos); return BasePageVO.restPage(pageNum, (int) awemePage.getSize(), (int) awemePage.getTotal(), (int) awemePage.getPages(), vos);
} else { } else {
return new BasePageVO<>(); return new BasePageVO<>();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment