Commit 4ff3ab1e authored by 许润龙's avatar 许润龙

Merge branch 'dev-activity-faw' into 'master'

Dev activity faw

See merge request !64
parents 83cbdfb6 83a4423d
......@@ -16,6 +16,56 @@
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- 活动服务API -->
<dependency>
<groupId>com.afanticar</groupId>
<artifactId>afanti-activity-api</artifactId>
<version>1.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
</exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
</exclusion>
<exclusion>
<groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId>
</exclusion>
<exclusion>
<groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId>
</exclusion>
<exclusion>
<groupId>cn.hutool</groupId>
<artifactId>hutool-extra</artifactId>
</exclusion>
<exclusion>
<groupId>com.afanticar</groupId>
<artifactId>afanticar-swagger2-starter</artifactId>
</exclusion>
<exclusion>
<groupId>com.afanticar</groupId>
<artifactId>afanticar-rocketmq-starter</artifactId>
</exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
</exclusion>
<exclusion>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
......@@ -219,6 +269,36 @@
</exclusions>
</dependency>
<!--<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.10.5</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.10.5</version>
<exclusions>
<exclusion>
<artifactId>mapstruct</artifactId>
<groupId>org.mapstruct</groupId>
</exclusion>
</exclusions>
</dependency>
&lt;!&ndash;解决Swagger 2.9.2版本NumberFormatException&ndash;&gt;
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.0</version>
</dependency>-->
</dependencies>
<repositories>
......
......@@ -5,17 +5,17 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableScheduling;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
*
* @author Chin
*
*/
@EnableSwagger2
//@EnableSwagger2
@SpringBootApplication
@EnableScheduling
@EnableFeignClients
@EnableFeignClients(basePackages = {"com.afanticar"})
@MapperScan(basePackages = {"com.afanticar.afantiopenapi.mapper"})
public class AfantiOpenApiApplication {
......
package com.afanticar.afantiopenapi.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.util.Set;
@Data
@Configuration
@ConfigurationProperties(prefix = "ignored")
public class IgnoredUri {
private Set<String> uris;
}
package com.afanticar.afantiopenapi.config;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.afanticar.afantiopenapi.constant.Constant;
import com.afanticar.afantiopenapi.controller.BaseController;
import com.afanticar.afantiopenapi.feign.AfantiCasFeign;
import com.afanticar.afantiopenapi.model.BaseResponse;
import com.afanticar.afantiopenapi.model.vo.TokenCheckVO;
import com.afanticar.afantiopenapi.utils.JWTUtils;
import com.alibaba.fastjson.JSONObject;
import feign.FeignException;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RBucket;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
* @author chin
......@@ -20,31 +32,81 @@ import java.util.Set;
* @since 2023/4/26/026
*/
@Slf4j
@Setter
@Component
@ConfigurationProperties(prefix = "ignored")
public class TokenInterceptor implements HandlerInterceptor {
public class TokenInterceptor extends HandlerInterceptorAdapter {
private Set<String> uris;
@Autowired
private AfantiCasFeign casFeign;
@Autowired
private RedissonClient redissonClient;
@Autowired
private IgnoredUri ignoredUri;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String requestUri = request.getRequestURI();
log.info("请求uri" + requestUri);
if (uris.contains(requestUri)) {
if (ignoredUri.getUris().contains(requestUri)) {
return true;
}
String token = request.getHeader("authorization");
if (StrUtil.isNotBlank(token)) {
request.setAttribute("clientId", JWTUtils.getClientId(token));
// 红旗旧接口不进行验证
if(Constant.EXCLUDE_PATH.contains(requestUri)){
return true;
}
try{
String clientId = JWTUtils.getClientId(token);
request.setAttribute("clientId", clientId);
TokenCheckVO tokenCheckVO = this.getCasToken(clientId,token);
if(tokenCheckVO == null || DateUtil.currentSeconds() > Long.valueOf(tokenCheckVO.getExp()).longValue()){
this.writeResponse(response,"token已过期");
return false;
}
}catch (FeignException e){
if(e.status()==HttpServletResponse.SC_UNAUTHORIZED){
this.writeResponse(response,"Unauthorized");
return false;
}
}catch (Exception e){
this.writeResponse(response,"认证失败,无效的token");
return false;
}
} else {
this.writeResponse(response,"认证失败,无效的token");
return false;
}
return true;
}
private void writeResponse(HttpServletResponse response, String msg) throws Exception {
response.setCharacterEncoding("UTF-8");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setContentType("application/json");
response.getWriter().append(JSONObject.toJSONString(BaseController.error("401", "认证失败")));
return false;
response.getWriter().append(JSONObject.toJSONString(BaseController.error("401", msg)));
}
return true;
private TokenCheckVO getCasToken(String clientId,String token) {
// RBucket<TokenCheckVO> rBucket = redissonClient.getBucket(Constant.TOKEN_REDIS_KEY+clientId);
// if(!rBucket.isExists()){
// RLock lock = redissonClient.getLock(Constant.TOKEN_REDIS_LOCK+clientId);
// lock.lock(5,TimeUnit.SECONDS);
// try{
TokenCheckVO checkVO = casFeign.checkToken(token);
// rBucket.set(checkVO,24, TimeUnit.HOURS);
return checkVO;
// }catch (Exception e){
// throw e;
// }finally {
// if(lock.isLocked()){
// lock.unlock();
// }
// }
// }else{
// return rBucket.get();
// }
}
}
package com.afanticar.afantiopenapi.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
......@@ -14,12 +15,17 @@ import javax.annotation.Resource;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Resource
TokenInterceptor tokenInterceptor;
// @Resource
// TokenInterceptor tokenInterceptor;
@Bean
public TokenInterceptor getLoginInterceptor(){
return new TokenInterceptor();
}
@Override
public void addInterceptors(InterceptorRegistry register) {
register.addInterceptor(tokenInterceptor);
register.addInterceptor(getLoginInterceptor());
}
}
\ No newline at end of file
package com.afanticar.afantiopenapi.constant;
import java.util.HashMap;
import java.util.Map;
/**
* @author chin
* @contact chenyan@afanticar.com
......@@ -9,4 +12,39 @@ public class Constant {
public static final String SUCCESS_CODE = "200";
public static final String TOKEN_REDIS_KEY = "TOKEN_";
public static final String TOKEN_REDIS_LOCK = "TOKEN_LOCK_";
public static final String EXCLUDE_PATH = "/faw/live,/faw/aweme";
// key=车系name,value=车系code
public static Map<String, String> seriesMap = new HashMap();
static {
seriesMap.put("E-001", "E-001");
seriesMap.put("EH7", "EH7");
seriesMap.put("E-HS3", "E-HS3");
seriesMap.put("EHS7", "EHS7");
seriesMap.put("E-HS9", "E-HS9");
seriesMap.put("E-QM5", "E-QM5");
seriesMap.put("H5", "H5");
seriesMap.put("H5-2", "H5-2");
seriesMap.put("H6", "H6");
seriesMap.put("H7", "H7");
seriesMap.put("H9", "H9");
seriesMap.put("H9+", "H9+");
seriesMap.put("HQ9", "HQ9");
seriesMap.put("HS3", "HS3");
seriesMap.put("HS5", "HS5");
seriesMap.put("HS7", "HS7");
seriesMap.put("HS7-2", "HS7-2");
seriesMap.put("L1", "L1");
seriesMap.put("L5", "L5");
seriesMap.put("红旗国礼", "红旗国礼");
seriesMap.put("红旗国雅", "红旗国雅");
seriesMap.put("红旗国耀", "红旗国耀");
seriesMap.put("红旗国悦", "红旗国悦");
seriesMap.put("盛世", "盛世");
}
}
package com.afanticar.afantiopenapi.controller;
import cn.hutool.core.date.DateException;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.afanticar.afantiopenapi.model.BaseResponse;
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.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
......@@ -76,4 +83,35 @@ public class BaseController {
}
return params;
}
public static Date parseDate(String publishDateStr) {
Date publishDate = null;
try {
publishDate = DateUtil.parse(publishDateStr, "yyyy-MM-dd");
} catch (DateException ignore) {
}
return publishDate;
}
int dateNum = 31;
public BaseResponse activityRequestDTO(FawActivityDTO dto) {
Date publishDateEnd = StrUtil.isNotBlank(dto.getPublishDateEnd()) ? DateUtil.endOfDay(parseDate(dto.getPublishDateEnd())) : DateUtil.endOfDay(DateUtil.yesterday()),
publishDateStart = StrUtil.isNotBlank(dto.getPublishDateStart()) ? parseDate(dto.getPublishDateStart()) : DateUtil.beginOfDay(DateUtil.offsetDay(publishDateEnd, -dateNum));
if (publishDateEnd.after(DateUtil.date())) {
return BaseController.error("10010", "时间右端点日期最大为昨日!");
}
if (DateUtil.between(publishDateEnd, publishDateStart, DateUnit.DAY) > dateNum) {
return BaseController.error("10010", "时间跨度最大为31天!");
}
// if (CollectionUtils.isEmpty(dto.getActivityIds()) || dto.getActivityIds().size() > 5) {
// return BaseController.error("10010", "活动ID不能为空,最大5个!");
// }
dto.setEnd(publishDateEnd);
dto.setStart(publishDateStart);
dto.setCurrent(dto.getCurrent() == null ? 1 : dto.getCurrent());
dto.setSize(dto.getSize() == null ? 500 : dto.getSize());
return null;
}
}
package com.afanticar.afantiopenapi.controller;
import cn.hutool.core.date.DateException;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.afanticar.activity.client.IActivityManagerApiClient;
import com.afanticar.activity.domain.param.*;
import com.afanticar.activity.domain.vo.ApiActivityInfoVO;
import com.afanticar.afantiopenapi.constant.Constant;
import com.afanticar.afantiopenapi.model.BaseResponse;
import com.afanticar.afantiopenapi.model.vo.BasePageVO;
import com.afanticar.afantiopenapi.model.vo.HongqiAwemeIncentiveVO;
import com.afanticar.afantiopenapi.model.vo.HongqiLiveIncentiveVO;
import com.afanticar.afantiopenapi.model.dto.FawActivityDTO;
import com.afanticar.afantiopenapi.model.vo.*;
import com.afanticar.afantiopenapi.service.BaseService;
import com.afanticar.afantiopenapi.service.FawOpenService;
import com.afanticar.common.base.domain.BasePage;
import com.afanticar.common.core.api.CommonResult;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -16,10 +22,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.Max;
......@@ -41,6 +44,9 @@ public class FawOpenController extends BaseController {
@Autowired
FawOpenService fawOpenService;
@Autowired
private IActivityManagerApiClient activityManagerApiClient;
@Autowired
BaseService baseService;
......@@ -50,9 +56,33 @@ public class FawOpenController extends BaseController {
@Value("${faw.limit.period:60}")
Integer limitPeriod;
@Value("${faw.limit.threshold:3}")
@Value("${faw.limit.threshold:5}")
Integer limit;
/**
* 活动创建, 1天不能超过100个 -uat环境
*/
@Value("${faw.activity.create.limit.period:86400}")
Integer activityCreateLimitPeriod;
@Value("${faw.activity.create.limit.threshold:100}")
Integer activityCreateLimit;
/**
* 活动查询修改、删除60秒内不能超过120次
*/
@Value("${faw.activity.query.limit.period:60}")
Integer activityCurdLimitPeriod;
@Value("${faw.activity.query.limit.threshold:120}")
Integer activityCurdLimit;
/**
* 红旗主体id
*/
@Value("${faw.principalId:869752931296989184}")
String fawPrincipalId;
static String dataType = "faw";
static String monthly = "monthly", quarter = "quarter";
......@@ -108,17 +138,180 @@ public class FawOpenController extends BaseController {
return success(fawOpenService.lives(publishDateStart, publishDateEnd, type, pageNum, pageSize));
}
private static Date parseDate(String publishDateStr) {
Date publishDate = null;
try {
publishDate = DateUtil.parse(publishDateStr, "yyyy-MM-dd");
} catch (DateException ignore) {
private Date endTime(Date endDate) {
return DateUtil.endOfDay(endDate);
}
@ApiOperation(value = "抖音活动视频数据信息", notes = "抖音活动视频数据", produces = "application/json")
@PostMapping("/activity/douyin/aweme/list")
public BaseResponse<BasePageVO<HongqiActivityAwemeVO>> getDouyinActivityAwemeData(@RequestBody @Validated FawActivityDTO dto) {
BaseResponse check = baseService.pageApiLimit(dataType, limit, limitPeriod);
if (check != null) {
return check;
}
return publishDate;
check = activityRequestDTO(dto);
if (check != null) {
return check;
}
return success(fawOpenService.douyinActivityAwemes(dto));
}
private Date endTime(Date endDate) {
return DateUtil.endOfDay(endDate);
@ApiOperation(value = "抖音活动直播数据信息", notes = "抖音活动直播数据", produces = "application/json")
@PostMapping("/activity/douyin/live/list")
public BaseResponse<BasePageVO<HongqiActivityLiveVO>> getDouyinActivityLiveData(@RequestBody @Validated FawActivityDTO dto) {
BaseResponse check = baseService.pageApiLimit(dataType, limit, limitPeriod);
if (check != null) {
return check;
}
check = activityRequestDTO(dto);
if (check != null) {
return check;
}
return success(fawOpenService.douyinActivityLives(dto));
}
@ApiOperation(value = "快手活动视频数据信息", notes = "快手活动视频数据", produces = "application/json")
@PostMapping("/activity/kuaishou/aweme/list")
public BaseResponse<BasePageVO<HongqiActivityAwemeVO>> getKuaishouActivityAwemeData(@RequestBody @Validated FawActivityDTO dto) {
BaseResponse check = baseService.pageApiLimit(dataType, limit, limitPeriod);
if (check != null) {
return check;
}
check = activityRequestDTO(dto);
if (check != null) {
return check;
}
return success(fawOpenService.kuaishouActivityAwemes(dto));
}
@ApiOperation(value = "快手活动直播数据信息", notes = "快手活动直播数据", produces = "application/json")
@PostMapping("/activity/kuaishou/live/list")
public BaseResponse<BasePageVO<HongqiActivityLiveVO>> getKuaishouActivityLiveData(@RequestBody @Validated FawActivityDTO dto) {
BaseResponse check = baseService.pageApiLimit(dataType, limit, limitPeriod);
if (check != null) {
return check;
}
check = activityRequestDTO(dto);
if (check != null) {
return check;
}
return success(fawOpenService.kuaishouActivityLives(dto));
}
@ApiOperation(value = "创建活动", notes = "创建活动", produces = "application/json")
@PostMapping("/activity/create")
public BaseResponse<String> activityCreate(@RequestBody ApiActivityCreateParam param) {
log.info("红旗活动-活动创建req={}", JSONObject.toJSONString(param));
BaseResponse check = baseService.baseLimit(dataType+":activity_create", activityCreateLimit, activityCreateLimitPeriod);
if (check != null) {
return check;
}
if(StrUtil.isEmpty(param.getActor())){
param.setActor("external-system");
}
param.setPrincipalId(fawPrincipalId);
CommonResult<String> res = activityManagerApiClient.activityCreate(param);
if(Constant.SUCCESS_CODE.equals(res.getCode().toString())){
return success(res.getData());
}else{
return error(res.getCode().toString(),res.getMessage());
}
}
@ApiOperation(value = "活动更新", notes = "活动更新", produces = "application/json")
@PostMapping("/activity/update")
public BaseResponse<String> activityUpdate(@RequestBody ApiActivityUpdateParam param) {
log.info("红旗活动-活动更新req={}", JSONObject.toJSONString(param));
BaseResponse check = baseService.baseLimit(dataType+":activity_curd", activityCurdLimit, activityCurdLimitPeriod);
if (check != null) {
return check;
}
if(StrUtil.isEmpty(param.getActor())){
param.setActor("external-system");
}
param.setPrincipalId(fawPrincipalId);
CommonResult<String> res = activityManagerApiClient.activityUpdate(param);
if(Constant.SUCCESS_CODE.equals(res.getCode().toString())){
return success(res.getData());
}else{
return error(res.getCode().toString(),res.getMessage());
}
}
@ApiOperation(value = "删除活动", notes = "删除活动", produces = "application/json")
@PostMapping("/activity/delete")
public BaseResponse<String> activityDelete(@RequestBody ApiActivityDeletedParam param) {
log.info("红旗活动-删除活动req={}", JSONObject.toJSONString(param));
BaseResponse check = baseService.baseLimit(dataType+":activity_curd", activityCurdLimit, activityCurdLimitPeriod);
if (check != null) {
return check;
}
if(StrUtil.isEmpty(param.getActor())){
param.setActor("external-system");
}
param.setPrincipalId(fawPrincipalId);
CommonResult<String> res = activityManagerApiClient.activityDeleted(param);
if(Constant.SUCCESS_CODE.equals(res.getCode().toString())){
return success();
}else{
return error(res.getCode().toString(),res.getMessage());
}
}
@ApiOperation(value = "活动列表", notes = "活动列表", produces = "application/json")
@PostMapping("/activity/list")
public BaseResponse<BasePageVO<ApiActivityInfoVO>> activityList(@RequestBody ApiActivityListParam param) {
log.info("红旗活动-活动列表req={}", JSONObject.toJSONString(param));
BaseResponse check = baseService.baseLimit(dataType+":activity_curd", activityCurdLimit, activityCurdLimitPeriod);
if (check != null) {
return check;
}
if(StrUtil.isEmpty(param.getActor())){
param.setActor("external-system");
}
param.setPrincipalId(fawPrincipalId);
CommonResult<BasePage<ApiActivityInfoVO>> res = activityManagerApiClient.activityList(param);
if(Constant.SUCCESS_CODE.equals(res.getCode().toString())){
BasePageVO basePageVO = new BasePageVO();
basePageVO.setPages(res.getData().getTotalPage().intValue());
basePageVO.setTotal(res.getData().getTotal().intValue());
basePageVO.setCurrent(res.getData().getPage().intValue());
basePageVO.setRecords(res.getData().getList());
basePageVO.setSize(res.getData().getSize().intValue());
return success(basePageVO);
}else{
return error(res.getCode().toString(),res.getMessage());
}
}
@ApiOperation(value = "活动详情", notes = "活动详情")
@GetMapping("/activity/info")
public BaseResponse<ApiActivityInfoVO> activityList(@RequestBody(required = false) ApiActivityInfoParam param,
@RequestParam(value = "activity_id",required = false) String activityId,
@RequestParam(value = "actor",required = false) String actor) {
log.info("红旗活动-活动详情req={},activityId={},actor={}", JSONObject.toJSONString(param),activityId,actor);
BaseResponse check = baseService.baseLimit(dataType+":activity_curd", activityCurdLimit, activityCurdLimitPeriod);
if (check != null) {
return check;
}
boolean paramIsEmpty = param == null || StrUtil.isEmpty(param.getActivityId());
if(paramIsEmpty && StrUtil.isEmpty(activityId)){
return error("400","活动id不能为空");
}
if(param == null){
param = new ApiActivityInfoParam();
param.setActivityId(activityId);
param.setActor(actor);
}
if(StrUtil.isEmpty(param.getActor())){
param.setActor("external-system");
}
param.setPrincipalId(fawPrincipalId);
CommonResult<ApiActivityInfoVO> res = activityManagerApiClient.activityInfo(param);
if(Constant.SUCCESS_CODE.equals(res.getCode().toString())){
return success(res.getData());
}else{
return error(res.getCode().toString(),res.getMessage());
}
}
}
package com.afanticar.afantiopenapi.feign;
import com.afanticar.afantiopenapi.model.BaseResponse;
import com.afanticar.afantiopenapi.model.vo.TokenCheckVO;
import com.afanticar.afantiopenapi.model.vo.TokenVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -15,11 +17,19 @@ import java.util.Map;
public interface AfantiCasFeign {
/**
* 分类标签
* 获取token
* @param request 参数
* @return JSONObject结果
*/
@PostMapping(value = "/oauth/token")
BaseResponse<TokenVO> predict(@RequestParam Map<String, Object> request);
/**
* 分类标签
* @param token 参数
* @return JSONObject结果
*/
@GetMapping(value = "/oauth/check_token")
TokenCheckVO checkToken(@RequestParam("token") String token);
}
package com.afanticar.afantiopenapi.mapper;
import com.afanticar.afantiopenapi.model.dto.FawActivityDTO;
import com.afanticar.afantiopenapi.model.entity.DwdDouyinAuthorInfo;
import com.afanticar.afantiopenapi.model.vo.HongqiActivityAwemeVO;
import com.afanticar.afantiopenapi.model.vo.HongqiActivityLiveVO;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* <p>
* 抖音主播信息 Mapper 接口
* </p>
*
* @author Wsr
* @since 2023-02-09
*/
@Mapper
@DS("afanti-bi-app")
public interface DwdKuaishouAuthorInfoMapper extends BaseMapper<DwdDouyinAuthorInfo> {
@Select("<script>select " +
" t1.aweme_id, " +
" t1.author_id , " +
" t1.aweme_title , " +
" 'douyin' as platform, " +
" t3.dealer_area_names area_name, " +
" t3.dealer_store_code dealer_code, " +
" t3.dealer_name , " +
" t3.nickname , " +
" t1.publish_time , " +
" t1.play_volume , " +
" nvl(t1.digg_count,0) + nvl(t1.comment_count,0) + nvl(t1.share_count,0) as polling_count, " +
" t1.digg_count , " +
" t1.comment_count , " +
" t1.share_count , " +
" t1.share_url , " +
" t1.data_update_time , " +
" t2.activity_info " +
"from ( " +
" select * from dwd_douyin_aweme_info " +
" where publish_time &gt;= #{dto.start} and publish_time &lt;= #{dto.end} " +
") t1 left join ( " +
" select aweme_id,collect_set(json_object('activity_id',activity_id,'match_keywords',match_keywords)) as activity_info " +
" from dwd_fhl_activity_douyin_aweme_info " +
" where " +
" publish_time &gt;= #{dto.start} " +
" and publish_time &lt;= #{dto.end} " +
" and " +
" <choose>" +
" <when test=\"dto.activityIds != null\">" +
" activity_id in " +
" <foreach collection='dto.activityIds' item='item' open='(' separator=',' close=')'>" +
" #{item} " +
" </foreach> " +
" </when> " +
" <otherwise> " +
" activity_id != '' " +
" </otherwise> " +
" </choose> " +
" and is_deleted = 0 " +
" group by 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 " +
"where contains(split(t3.principal_ids,','),'869752931296989184')</script>")
IPage<HongqiActivityAwemeVO> douyinActivityAwemes(IPage<HongqiActivityAwemeVO> page, @Param("dto") FawActivityDTO dto);
@Select("<script>select " +
" t1.aweme_id, " +
" t1.author_id, " +
" t1.aweme_title , " +
" 'kuaishou' as platform, " +
" t3.dealer_area_names area_name, " +
" t3.dealer_store_code dealer_code, " +
" t3.dealer_name , " +
" t3.nickname , " +
" t1.publish_time , " +
" t1.play_volume , " +
" nvl(t1.digg_count,0) + nvl(t1.comment_count,0) + nvl(t1.share_count,0) as polling_count, " +
" t1.digg_count , " +
" t1.comment_count , " +
" t1.share_count , " +
" t1.share_url , " +
" t1.data_update_time , " +
" t2.activity_info " +
"from ( " +
" select * from dwd_kuaishou_aweme_info " +
" where publish_time &gt;= #{dto.start} and publish_time &lt;= #{dto.end} " +
") t1 left join ( " +
" select aweme_id,collect_set(json_object('activity_id',activity_id,'match_keywords',match_keywords)) as activity_info " +
" from dwd_fhl_activity_kuaishou_aweme_info " +
" where " +
" publish_time &gt;= #{dto.start} " +
" and publish_time &lt;= #{dto.end} " +
" and " +
" <choose>" +
" <when test=\"dto.activityIds != null\">" +
" activity_id in " +
" <foreach collection='dto.activityIds' item='item' open='(' separator=',' close=')'>" +
" #{item} " +
" </foreach> " +
" </when> " +
" <otherwise> " +
" activity_id != '' " +
" </otherwise> " +
" </choose> " +
" and is_deleted = 0 " +
" group by 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 " +
"where contains(split(t3.principal_ids,','),'869752931296989184')</script>")
IPage<HongqiActivityAwemeVO> kuaishouActivityAwemes(IPage<HongqiActivityAwemeVO> page, @Param("dto") FawActivityDTO dto);
@Select("<script>select " +
" t1.room_id, " +
" t3.author_id , " +
" t1.title, " +
" 'douyin' as platform, " +
" t3.dealer_area_names area_name, " +
" t3.dealer_store_code dealer_code, " +
" t3.dealer_name , " +
" t3.nickname , " +
" t1.publish_time , " +
" t1.statistics_total_watch_user_count , " +
" round(t1.statistics_live_time/60, 2) statistics_live_time, " +
" t1.statistics_total_polling_count as polling_cnt, " +
" t1.statistics_total_like_count like_cnt, " +
" t1.statistics_total_comment_count comment_cnt, " +
" t1.statistics_total_gift_count gift_cnt, " +
" t1.statistics_fans_add , " +
" t1.data_update_time , " +
" t2.activity_info " +
"from ( " +
" select * from dwd_douyin_live_info " +
" where publish_time &gt;= #{dto.start} and publish_time &lt;= #{dto.end} " +
") t1 left join ( " +
" select room_id,collect_set(json_object('activity_id',activity_id,'match_keywords',match_keywords)) as activity_info " +
" from dwd_fhl_activity_douyin_live_info " +
" where publish_time &gt;= #{dto.start} and publish_time &lt;= #{dto.end} " +
" and " +
" <choose>" +
" <when test=\"dto.activityIds != null\">" +
" activity_id in " +
" <foreach collection='dto.activityIds' item='item' open='(' separator=',' close=')'>" +
" #{item} " +
" </foreach> " +
" </when> " +
" <otherwise> " +
" activity_id != '' " +
" </otherwise> " +
" </choose> " +
" and is_deleted = 0 " +
" group by room_id " +
" ) t2 on t1.room_id = t2.room_id " +
" left join dwd_douyin_author_info t3 on t1.author_id = t3.author_id " +
"where contains(split(t3.principal_ids,','),'869752931296989184')</script>")
IPage<HongqiActivityLiveVO> douyinActivityLives(IPage<HongqiActivityLiveVO> page, @Param("dto") FawActivityDTO dto);
@Select("<script>select " +
" t1.room_id, " +
" t1.title, " +
" 'kuaishou' as platform, " +
" t3.dealer_area_names area_name, " +
" t3.dealer_store_code dealer_code, " +
" t3.dealer_name , " +
" t3.nickname , " +
" t3.author_id , " +
" t1.publish_time , " +
" t1.statistics_total_watch_user_count , " +
" round(t1.statistics_live_time/60, 2) statistics_live_time, " +
" t1.statistics_total_polling_count as polling_cnt, " +
" t1.statistics_total_like_count like_cnt, " +
" t1.statistics_total_comment_count comment_cnt, " +
" t1.statistics_total_gift_count gift_cnt, " +
" t1.statistics_fans_add , " +
" t1.data_update_time , " +
" t2.activity_info " +
"from ( " +
" select * from dwd_kuaishou_live_info " +
" where publish_time &gt;= #{dto.start} and publish_time &lt;= #{dto.end} " +
") t1 left join ( " +
" select room_id,collect_set(json_object('activity_id',activity_id,'match_keywords',match_keywords)) as activity_info " +
" from dwd_fhl_activity_kuaishou_live_info " +
" where publish_time &gt;= #{dto.start} and publish_time &lt;= #{dto.end} " +
" and " +
" <choose>" +
" <when test=\"dto.activityIds != null\">" +
" activity_id in " +
" <foreach collection='dto.activityIds' item='item' open='(' separator=',' close=')'>" +
" #{item} " +
" </foreach> " +
" </when> " +
" <otherwise> " +
" activity_id != '' " +
" </otherwise> " +
" </choose> " +
" and is_deleted = 0 " +
" group by room_id " +
" ) t2 on t1.room_id = t2.room_id " +
" left join dwd_kuaishou_author_info t3 on t1.author_id = t3.author_id " +
"where contains(split(t3.principal_ids,','),'869752931296989184')</script>")
IPage<HongqiActivityLiveVO> kuaishouActivityLives(IPage<HongqiActivityLiveVO> page, @Param("dto") FawActivityDTO dto);
}
......@@ -25,4 +25,5 @@ public class BaseResponse<T> {
@ApiModelProperty(value = "是否成功", example = "true")
private Boolean success;
}
package com.afanticar.afantiopenapi.model.dto;
import com.alibaba.fastjson.annotation.JSONType;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.util.Date;
import java.util.List;
/**
* @author chin
* @contact chenyan@afanticar.com
* @since 2024/9/13/013
*/
@Data
@JsonNaming(value = com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy.class)
@JSONType(naming = com.alibaba.fastjson.PropertyNamingStrategy.SnakeCase)
public class FawActivityDTO {
@Min(value = 1, message = "当前页最小1")
private Integer current;
@Max(value = 1000, message = "分页大小最大1000")
private Integer size;
private String publishDateStart;
private Date start;
private String publishDateEnd;
private Date end;
private List<String> activityIds;
}
package com.afanticar.afantiopenapi.model.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* <p>
* 抖音主播信息
* </p>
*
* @author Wsr
* @since 2023-02-09
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("dwd_douyin_author_info")
@ApiModel(value = "DwdDouyinAuthorInfo对象", description = "抖音主播信息")
public class DwdDouyinAuthorInfo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主播ID")
@TableId("author_id")
private String authorId;
@ApiModelProperty("主播抖音号")
@TableField("code")
private String code;
@ApiModelProperty("主播性别")
@TableField("gender")
private Integer gender;
@ApiModelProperty("主播签名")
@TableField("signature")
private String signature;
@ApiModelProperty("主播生日")
@TableField("birthday")
private String birthday;
@ApiModelProperty("主播认证名称")
@TableField("verify_name")
private String verifyName;
@ApiModelProperty("主播昵称")
@TableField("nickname")
private String nickname;
@ApiModelProperty("抖音主播认证类型")
@TableField("verification_type")
private String verificationType;
@ApiModelProperty("抖音主播认证名称")
@TableField("verification_name")
private String verificationName;
@ApiModelProperty("主播头像")
@TableField("avatar")
private String avatar;
@ApiModelProperty("主播爬虫字段,一般使用该字段发送爬取该主播信息指令")
@TableField("sec_author_id")
private String secAuthorId;
@ApiModelProperty("主播所在城市code")
@TableField("author_city_code")
private String authorCityCode;
@ApiModelProperty("主播所在城市名称")
@TableField("author_city_name")
private String authorCityName;
@ApiModelProperty("主播所在省code")
@TableField("author_province_code")
private String authorProvinceCode;
@ApiModelProperty("主播所在省名称")
@TableField("author_province_name")
private String authorProvinceName;
@ApiModelProperty("经销商id")
@TableField("dealer_id")
private String dealerId;
@ApiModelProperty("经销商名称")
@TableField("dealer_name")
private String dealerName;
@ApiModelProperty("经销商城市code")
@TableField("dealer_city_code")
private Long dealerCityCode;
@ApiModelProperty("经销商城市名称")
@TableField("dealer_city_name")
private String dealerCityName;
@ApiModelProperty("经销商地区code")
@TableField("dealer_county_code")
private Long dealerCountyCode;
@ApiModelProperty("经销商地区名称")
@TableField("dealer_county_name")
private String dealerCountyName;
@ApiModelProperty("经销商省份code")
@TableField("dealer_province_code")
private Long dealerProvinceCode;
@ApiModelProperty("经销商省份名称")
@TableField("dealer_province_name")
private String dealerProvinceName;
@ApiModelProperty("主机厂ids")
@TableField("manufactor_ids")
private String manufactorIds;
@ApiModelProperty("主机厂名称")
@TableField("manufactor_names")
private String manufactorNames;
@ApiModelProperty("品牌ids")
@TableField("brand_ids")
private String brandIds;
@ApiModelProperty("主体ids")
@TableField("principal_ids")
private String principalIds;
@ApiModelProperty("主体名称")
@TableField("principal_names")
private String principalNames;
@ApiModelProperty("主播总点赞数")
@TableField("like_count_total")
private Integer likeCountTotal;
@ApiModelProperty("主播总视频数")
@TableField("aweme_count_total")
private Integer awemeCountTotal;
@ApiModelProperty("主播总粉丝数")
@TableField("fans_count_total")
private Integer fansCountTotal;
@ApiModelProperty("主播抖音粉丝数")
@TableField("fans_dy_count")
private Integer fansDyCount;
@ApiModelProperty("主播头条粉丝数")
@TableField("fans_tt_count")
private Integer fansTtCount;
@ApiModelProperty("主播火山粉丝数")
@TableField("fans_hs_count")
private Integer fansHsCount;
@ApiModelProperty("主播总动态数")
@TableField("dongtai_count_total")
private Integer dongtaiCountTotal;
@ApiModelProperty("更新时间")
@TableField(value = "mtime", fill = FieldFill.INSERT_UPDATE)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date mtime;
@ApiModelProperty("经销商大区id,多列值")
@TableField("dealer_area_ids")
private String dealerAreaIds;
@ApiModelProperty("经销商大区名称,多列值")
@TableField("dealer_area_names")
private String dealerAreaNames;
@TableField("dealer_company_name")
private String dealerCompanyName;
@TableField("dealer_store_code")
private String dealerStoreCode;
@ApiModelProperty("账号类型:10经销商未分类,11经销商官号,12经销商个人号,13经销商营销号;20主机厂号未分类;21主机厂官号,22主机厂营销号;41汽车KOL,14:经销商售后,15:经销商二手车,30:经销商大区号 ; NULL 既不是品牌主播号,也不是经销商主播号,又不是汽车分类主播号的主播号")
@TableField("account_type")
private Integer accountType;
@ApiModelProperty("主播状态, 0正常;1删除")
@TableField("author_status")
private Integer authorStatus;
@ApiModelProperty("数据同步更新的时间点")
@TableField("data_update_time")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date dataUpdateTime;
@ApiModelProperty("团队编号")
@TableField("team_id")
private String teamId;
@ApiModelProperty("账号收录时间")
@TableField("included_time")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date includedTime;
@ApiModelProperty("主播主页背景图链接")
@TableField("cover_url")
private String coverUrl;
@ApiModelProperty("排序权重")
@TableField("sort_weight")
private String sortWeight;
@ApiModelProperty("懂车帝主播id")
@TableField("dongchedi_author_id")
private String dongchediAuthorId;
@ApiModelProperty("创建时间")
@TableField(value = "ctime", fill = FieldFill.INSERT)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date ctime;
@ApiModelProperty("运营主体:1:品牌,2:主机厂,3:主体大区,4:经销商,5:KOIP,6:二手车商")
@TableField("operate_type")
private String operateType;
@ApiModelProperty("阿凡提总后台定义主播是否继续采集(是否删除,0正常;1删除)")
@TableField("is_deleted")
private Integer isDeleted;
@ApiModelProperty("品牌名称")
@TableField("brand_names")
private String brandNames;
@ApiModelProperty("抖音返回的主播状态,0正常、1注销、2封禁")
@TableField("platform_author_status")
private Integer platformAuthorStatus;
@ApiModelProperty("门店原始编码")
@TableField("origin_store_code")
private String originStoreCode;
@ApiModelProperty("成员ids")
private List<String> matrixMemberIds;
}
package com.afanticar.afantiopenapi.model.vo;
import com.alibaba.fastjson.annotation.JSONType;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;
/**
* @author chin
* @contact chenyan@afanticar.com
* @since 2024/9/23/023
*/
@Data
@JsonNaming(value = com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy.class)
@JSONType(naming = com.alibaba.fastjson.PropertyNamingStrategy.SnakeCase)
public class ActivityVO {
private String activityId;
private String matchKeywords;
private String seriesCode;
}
package com.afanticar.afantiopenapi.model.vo;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONType;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author chin
* @contact chenyan@afanticar.com
* @since 2024/9/13/013
*/
@Data
@JsonNaming(value = com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy.class)
@JSONType(naming = com.alibaba.fastjson.PropertyNamingStrategy.SnakeCase)
public class HongqiActivityAwemeVO extends HongqiActivityBaseVO {
private String awemeId;
private String authorId;
private String awemeTitle;
private String platform;
private String areaName;
private String dealerCode;
private String dealerName;
private String nickname;
private Date publishTime;
private Integer playVolume;
private Integer pollingCount;
private Integer diggCount;
private Integer commentCount;
private Integer shareCount;
private String shareUrl;
private Date dataUpdateTime;
}
package com.afanticar.afantiopenapi.model.vo;
import com.alibaba.fastjson.annotation.JSONType;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;
import java.util.List;
@Data
@JsonNaming(value = com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy.class)
@JSONType(naming = com.alibaba.fastjson.PropertyNamingStrategy.SnakeCase)
public class HongqiActivityBaseVO {
private List<ActivityVO> activityList;
@JsonIgnore
private String activityInfo;
}
package com.afanticar.afantiopenapi.model.vo;
import com.alibaba.fastjson.annotation.JSONType;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author chin
* @contact chenyan@afanticar.com
* @since 2024/9/13/013
*/
@Data
@JsonNaming(value = com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy.class)
@JSONType(naming = com.alibaba.fastjson.PropertyNamingStrategy.SnakeCase)
public class HongqiActivityLiveVO extends HongqiActivityBaseVO {
private String roomId;
private String authorId;
private String title;
private String platform;
private String areaName;
private String dealerCode;
private String dealerName;
private String nickname;
private Date publishTime;
private Integer statisticsTotalWatchUserCount;
private Double statisticsLiveTime;
private Integer pollingCnt;
private Integer likeCnt;
private Integer commentCnt;
private Integer giftCnt;
private Integer statisticsFansAdd;
}
package com.afanticar.afantiopenapi.model.vo;
import com.alibaba.fastjson.annotation.JSONType;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author chin
* @contact chenyan@afanticar.com
* @since 2023/4/27/027
*/
@Data
@JsonNaming(value = com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy.class)
@JSONType(naming = com.alibaba.fastjson.PropertyNamingStrategy.SnakeCase)
public class TokenCheckVO {
@ApiModelProperty(value = "", example = "wastehh")
private Boolean active;
@ApiModelProperty(value = "过期时间-秒")
private String exp;
private String jti;
@ApiModelProperty(value = "客服端id")
private String clientId;
}
......@@ -42,11 +42,26 @@ public class BaseService {
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);
rateLimiter.trySetRate(RateType.OVERALL, limit, limitPeriod, RateIntervalUnit.SECONDS);
if (!rateLimiter.tryAcquire(1, waiting, TimeUnit.MILLISECONDS)) {
return BaseController.error("10010", "您的请求太过频繁,请稍后再试!");
}
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;
}
}
package com.afanticar.afantiopenapi.service;
import com.afanticar.afantiopenapi.mapper.HongqiAwemeIncentiveMonthlyMapper;
import com.afanticar.afantiopenapi.mapper.HongqiAwemeIncentiveQuarterMapper;
import com.afanticar.afantiopenapi.mapper.HongqiLiveIncentiveMonthlyMapper;
import com.afanticar.afantiopenapi.mapper.HongqiLiveIncentiveQuarterMapper;
import com.afanticar.afantiopenapi.mapper.*;
import com.afanticar.afantiopenapi.mapper.struct.HongqiAwemeIncentiveStructMapper;
import com.afanticar.afantiopenapi.mapper.struct.HongqiLiveIncentiveStructMapper;
import com.afanticar.afantiopenapi.model.dto.FawActivityDTO;
import com.afanticar.afantiopenapi.model.entity.HongqiAwemeIncentiveMonthly;
import com.afanticar.afantiopenapi.model.entity.HongqiAwemeIncentiveQuarter;
import com.afanticar.afantiopenapi.model.entity.HongqiLiveIncentiveMonthly;
import com.afanticar.afantiopenapi.model.entity.HongqiLiveIncentiveQuarter;
import com.afanticar.afantiopenapi.model.vo.BasePageVO;
import com.afanticar.afantiopenapi.model.vo.HongqiAwemeIncentiveVO;
import com.afanticar.afantiopenapi.model.vo.HongqiLiveIncentiveVO;
import com.afanticar.afantiopenapi.model.vo.*;
import com.afanticar.afantiopenapi.utils.BaseUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -45,6 +42,9 @@ public class FawOpenService {
@Resource
HongqiLiveIncentiveQuarterMapper hongqiLiveIncentiveQuarterMapper;
@Resource
DwdKuaishouAuthorInfoMapper dwdKuaishouAuthorInfoMapper;
static String monthly = "monthly";
static String quarter = "quarter";
......@@ -102,4 +102,38 @@ public class FawOpenService {
return new BasePageVO<>();
}
}
public BasePageVO<HongqiActivityAwemeVO> douyinActivityAwemes(FawActivityDTO dto) {
PageHelper.orderBy(" publish_time DESC ");
IPage<HongqiActivityAwemeVO> page = new Page<>(dto.getCurrent(), dto.getSize());
IPage<HongqiActivityAwemeVO> awemePage = dwdKuaishouAuthorInfoMapper.douyinActivityAwemes(page, dto);
BaseUtils.parseSeries(awemePage.getRecords());
return BasePageVO.restPage(dto.getCurrent(), (int) awemePage.getSize(), (int) awemePage.getTotal(), (int) awemePage.getPages(), awemePage.getRecords());
}
public BasePageVO<HongqiActivityLiveVO> douyinActivityLives(FawActivityDTO dto) {
PageHelper.orderBy(" publish_time DESC ");
IPage<HongqiActivityLiveVO> page = new Page<>(dto.getCurrent(), dto.getSize());
IPage<HongqiActivityLiveVO> livePage = dwdKuaishouAuthorInfoMapper.douyinActivityLives(page, dto);
BaseUtils.parseSeries(livePage.getRecords());
return BasePageVO.restPage(dto.getCurrent(), (int) livePage.getSize(), (int) livePage.getTotal(), (int) livePage.getPages(), livePage.getRecords());
}
public BasePageVO<HongqiActivityAwemeVO> kuaishouActivityAwemes(FawActivityDTO dto) {
PageHelper.orderBy(" publish_time DESC ");
IPage<HongqiActivityAwemeVO> page = new Page<>(dto.getCurrent(), dto.getSize());
IPage<HongqiActivityAwemeVO> awemePage = dwdKuaishouAuthorInfoMapper.kuaishouActivityAwemes(page, dto);
BaseUtils.parseSeries(awemePage.getRecords());
return BasePageVO.restPage(dto.getCurrent(), (int) awemePage.getSize(), (int) awemePage.getTotal(), (int) awemePage.getPages(), awemePage.getRecords());
}
public BasePageVO<HongqiActivityLiveVO> kuaishouActivityLives(FawActivityDTO dto) {
PageHelper.orderBy(" publish_time DESC ");
IPage<HongqiActivityLiveVO> page = new Page<>(dto.getCurrent(), dto.getSize());
IPage<HongqiActivityLiveVO> livePage = dwdKuaishouAuthorInfoMapper.kuaishouActivityLives(page, dto);
BaseUtils.parseSeries(livePage.getRecords());
return BasePageVO.restPage(dto.getCurrent(), (int) livePage.getSize(), (int) livePage.getTotal(), (int) livePage.getPages(), livePage.getRecords());
}
}
package com.afanticar.afantiopenapi.utils;
import com.afanticar.afantiopenapi.constant.Constant;
import com.afanticar.afantiopenapi.model.vo.ActivityVO;
import com.afanticar.afantiopenapi.model.vo.HongqiActivityAwemeVO;
import com.afanticar.afantiopenapi.model.vo.HongqiActivityBaseVO;
import com.alibaba.fastjson.JSONObject;
import com.auth0.jwt.JWT;
import com.auth0.jwt.interfaces.DecodedJWT;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
public class BaseUtils {
public static <T extends HongqiActivityBaseVO> void parseSeries(List<T> list) {
for (HongqiActivityBaseVO awemeVO: list) {
if (StringUtils.isEmpty(awemeVO.getActivityInfo())) {
continue;
}
List<ActivityVO> activityVOList = new ArrayList<>();
List<String> objects = JSONObject.parseArray(awemeVO.getActivityInfo(), String.class);
for (String object : objects) {
ActivityVO activityVO = JSONObject.parseObject(object, ActivityVO.class);
activityVOList.add(activityVO);
if (StringUtils.isEmpty(activityVO.getMatchKeywords())) {
continue;
}
StringBuffer seriesCode = new StringBuffer();
String[] names = activityVO.getMatchKeywords().split(",");
for (String name : names) {
String code = Constant.seriesMap.get(name);
if (StringUtils.isEmpty(code)) {
continue;
}
seriesCode.append(code).append(",");
}
if (seriesCode.length() > 0) {
activityVO.setSeriesCode(seriesCode.substring(0, seriesCode.length() - 1));
}
}
awemeVO.setActivityList(activityVOList);
}
}
}
......@@ -12,6 +12,7 @@ spring:
maxRetry: 3
namespace: 09c8e0f2-6c67-4cd4-b167-5883a98a7a4f #local
ext-config:
- data-id: dynamic-db-afanti-bi-app-vault.yml
- data-id: dynamic-db-afanti-vault.yml
- data-id: dynamic-db-afanti-tmp-vault.yml
- data-id: common-redis.yml
......@@ -35,7 +36,7 @@ spring:
secret-key-property: spring.rocket-mq.secretKey
# adb链接
kv:
enabled: false
enabled: true
backend: ${spring.profiles.active}
default-context: etladb
databases:
......
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