Commit 7693165b authored by 严俊's avatar 严俊

Merge remote-tracking branch 'origin/dev-activity-faw' into dev-activity-faw

parents bb7f8a32 7ab3a793
...@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil; ...@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.afanticar.afantiopenapi.model.BaseResponse; import com.afanticar.afantiopenapi.model.BaseResponse;
import com.afanticar.afantiopenapi.model.dto.FawActivityDTO; import com.afanticar.afantiopenapi.model.dto.FawActivityDTO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
...@@ -103,6 +104,9 @@ public class BaseController { ...@@ -103,6 +104,9 @@ public class BaseController {
if (DateUtil.between(publishDateEnd, publishDateStart, DateUnit.DAY) > dateNum) { if (DateUtil.between(publishDateEnd, publishDateStart, DateUnit.DAY) > dateNum) {
return BaseController.error("10010", "时间跨度最大为31天!"); return BaseController.error("10010", "时间跨度最大为31天!");
} }
// if (CollectionUtils.isEmpty(dto.getActivityIds()) || dto.getActivityIds().size() > 5) {
// return BaseController.error("10010", "活动ID不能为空,最大5个!");
// }
dto.setEnd(publishDateEnd); dto.setEnd(publishDateEnd);
dto.setStart(publishDateStart); dto.setStart(publishDateStart);
dto.setCurrent(dto.getCurrent() == null ? 1 : dto.getCurrent()); dto.setCurrent(dto.getCurrent() == null ? 1 : dto.getCurrent());
......
...@@ -145,7 +145,7 @@ public class FawOpenController extends BaseController { ...@@ -145,7 +145,7 @@ public class FawOpenController extends BaseController {
@ApiOperation(value = "抖音活动视频数据信息", notes = "抖音活动视频数据", produces = "application/json") @ApiOperation(value = "抖音活动视频数据信息", notes = "抖音活动视频数据", produces = "application/json")
@PostMapping("/activity/douyin/aweme/list") @PostMapping("/activity/douyin/aweme/list")
public BaseResponse<BasePageVO<HongqiActivityAwemeVO>> getDouyinActivityAwemeData(@RequestBody @Validated FawActivityDTO dto) { public BaseResponse<BasePageVO<HongqiActivityAwemeVO>> getDouyinActivityAwemeData(@RequestBody @Validated FawActivityDTO dto) {
BaseResponse check = baseService.baseLimit(dataType, limit, limitPeriod); BaseResponse check = baseService.pageApiLimit(dataType, limit, limitPeriod);
if (check != null) { if (check != null) {
return check; return check;
} }
...@@ -159,7 +159,7 @@ public class FawOpenController extends BaseController { ...@@ -159,7 +159,7 @@ public class FawOpenController extends BaseController {
@ApiOperation(value = "抖音活动直播数据信息", notes = "抖音活动直播数据", produces = "application/json") @ApiOperation(value = "抖音活动直播数据信息", notes = "抖音活动直播数据", produces = "application/json")
@PostMapping("/activity/douyin/live/list") @PostMapping("/activity/douyin/live/list")
public BaseResponse<BasePageVO<HongqiActivityLiveVO>> getDouyinActivityLiveData(@RequestBody @Validated FawActivityDTO dto) { public BaseResponse<BasePageVO<HongqiActivityLiveVO>> getDouyinActivityLiveData(@RequestBody @Validated FawActivityDTO dto) {
BaseResponse check = baseService.baseLimit(dataType, limit, limitPeriod); BaseResponse check = baseService.pageApiLimit(dataType, limit, limitPeriod);
if (check != null) { if (check != null) {
return check; return check;
} }
...@@ -173,7 +173,7 @@ public class FawOpenController extends BaseController { ...@@ -173,7 +173,7 @@ public class FawOpenController extends BaseController {
@ApiOperation(value = "快手活动视频数据信息", notes = "快手活动视频数据", produces = "application/json") @ApiOperation(value = "快手活动视频数据信息", notes = "快手活动视频数据", produces = "application/json")
@PostMapping("/activity/kuaishou/aweme/list") @PostMapping("/activity/kuaishou/aweme/list")
public BaseResponse<BasePageVO<HongqiActivityAwemeVO>> getKuaishouActivityAwemeData(@RequestBody @Validated FawActivityDTO dto) { public BaseResponse<BasePageVO<HongqiActivityAwemeVO>> getKuaishouActivityAwemeData(@RequestBody @Validated FawActivityDTO dto) {
BaseResponse check = baseService.baseLimit(dataType, limit, limitPeriod); BaseResponse check = baseService.pageApiLimit(dataType, limit, limitPeriod);
if (check != null) { if (check != null) {
return check; return check;
} }
...@@ -187,7 +187,7 @@ public class FawOpenController extends BaseController { ...@@ -187,7 +187,7 @@ public class FawOpenController extends BaseController {
@ApiOperation(value = "快手活动直播数据信息", notes = "快手活动直播数据", produces = "application/json") @ApiOperation(value = "快手活动直播数据信息", notes = "快手活动直播数据", produces = "application/json")
@PostMapping("/activity/kuaishou/live/list") @PostMapping("/activity/kuaishou/live/list")
public BaseResponse<BasePageVO<HongqiActivityLiveVO>> getKuaishouActivityLiveData(@RequestBody @Validated FawActivityDTO dto) { public BaseResponse<BasePageVO<HongqiActivityLiveVO>> getKuaishouActivityLiveData(@RequestBody @Validated FawActivityDTO dto) {
BaseResponse check = baseService.baseLimit(dataType, limit, limitPeriod); BaseResponse check = baseService.pageApiLimit(dataType, limit, limitPeriod);
if (check != null) { if (check != null) {
return check; return check;
} }
......
...@@ -64,7 +64,7 @@ public interface DwdKuaishouAuthorInfoMapper extends BaseMapper<DwdDouyinAuthorI ...@@ -64,7 +64,7 @@ public interface DwdKuaishouAuthorInfoMapper extends BaseMapper<DwdDouyinAuthorI
" </choose> " + " </choose> " +
" and is_deleted = 0 " + " and is_deleted = 0 " +
" group by aweme_id " + " group by aweme_id " +
" ) t2 on t1.aweme_id = t2.aweme_id " + " ) t2 on t1.aweme_id = t2.aweme_id or t1.other_video_id = t2.aweme_id " +
" left join dwd_douyin_author_info t3 on t1.author_id = t3.author_id " + " left join dwd_douyin_author_info t3 on t1.author_id = t3.author_id " +
"where contains(split(t3.principal_ids,','),'869752931296989184')</script>") "where contains(split(t3.principal_ids,','),'869752931296989184')</script>")
IPage<HongqiActivityAwemeVO> douyinActivityAwemes(IPage<HongqiActivityAwemeVO> page, @Param("dto") FawActivityDTO dto); IPage<HongqiActivityAwemeVO> douyinActivityAwemes(IPage<HongqiActivityAwemeVO> page, @Param("dto") FawActivityDTO dto);
...@@ -110,7 +110,7 @@ public interface DwdKuaishouAuthorInfoMapper extends BaseMapper<DwdDouyinAuthorI ...@@ -110,7 +110,7 @@ public interface DwdKuaishouAuthorInfoMapper extends BaseMapper<DwdDouyinAuthorI
" </choose> " + " </choose> " +
" and is_deleted = 0 " + " and is_deleted = 0 " +
" group by aweme_id " + " group by aweme_id " +
" ) t2 on t1.aweme_id = t2.aweme_id " + " ) t2 on t1.aweme_id = t2.aweme_id or t1.other_video_id = t2.aweme_id " +
" left join dwd_kuaishou_author_info t3 on t1.author_id = t3.author_id " + " left join dwd_kuaishou_author_info t3 on t1.author_id = t3.author_id " +
"where contains(split(t3.principal_ids,','),'869752931296989184')</script>") "where contains(split(t3.principal_ids,','),'869752931296989184')</script>")
IPage<HongqiActivityAwemeVO> kuaishouActivityAwemes(IPage<HongqiActivityAwemeVO> page, @Param("dto") FawActivityDTO dto); IPage<HongqiActivityAwemeVO> kuaishouActivityAwemes(IPage<HongqiActivityAwemeVO> page, @Param("dto") FawActivityDTO dto);
...@@ -163,7 +163,7 @@ public interface DwdKuaishouAuthorInfoMapper extends BaseMapper<DwdDouyinAuthorI ...@@ -163,7 +163,7 @@ public interface DwdKuaishouAuthorInfoMapper extends BaseMapper<DwdDouyinAuthorI
@Select("<script>select " + @Select("<script>select " +
" t1.room_id, " + " t1.room_id, " +
" t1.title, " + " t1.title, " +
" 'douyin' as platform, " + " 'kuaishou' as platform, " +
" t3.dealer_area_names area_name, " + " t3.dealer_area_names area_name, " +
" t3.dealer_store_code dealer_code, " + " t3.dealer_store_code dealer_code, " +
" t3.dealer_name , " + " t3.dealer_name , " +
......
...@@ -22,7 +22,7 @@ public class FawActivityDTO { ...@@ -22,7 +22,7 @@ public class FawActivityDTO {
@Min(value = 1, message = "当前页最小1") @Min(value = 1, message = "当前页最小1")
private Integer current; private Integer current;
@Max(value = 500, message = "分页大小最大500") @Max(value = 1000, message = "分页大小最大1000")
private Integer size; private Integer size;
private String publishDateStart; private String publishDateStart;
......
...@@ -42,11 +42,26 @@ public class BaseService { ...@@ -42,11 +42,26 @@ public class BaseService {
String header = "token"; String header = "token";
String fawKey = String.format("%s:%s:limit", dataType, 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)) {
return BaseController.error("10010", "您的请求太过频繁,请稍后再试!"); return BaseController.error("10010", "您的请求太过频繁,请稍后再试!");
} }
return null; return null;
} }
public BaseResponse pageApiLimit(String dataType, Integer limit, Integer limitPeriod) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
String header = "token";
String fawKey = String.format("%s:%s:limit", dataType, header);
RRateLimiter rateLimiter = redissonClient.getRateLimiter(fawKey);
rateLimiter.trySetRate(RateType.OVERALL, limit, limitPeriod, RateIntervalUnit.SECONDS);
if (!rateLimiter.tryAcquire(1, waiting, TimeUnit.MILLISECONDS)) {
return BaseController.error("10010", "您的请求太过频繁,请稍后再试!");
}
return null;
}
} }
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