1、全网热搜Controller接口实现
This commit is contained in:
parent
a7d2e4dff2
commit
0e3bf22548
|
|
@ -14,7 +14,7 @@ import java.lang.annotation.*;
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
// 表示通过aop框架暴露该代理对象,AopContext能够访问
|
||||
// 表示通过aop框架暴露该代理对象,AopContext能够访问(AOP开启)
|
||||
@EnableAspectJAutoProxy(exposeProxy = true)
|
||||
// 指定要扫描的Mapper类的包的路径
|
||||
@MapperScan({"com.ruoyi.**.mapper","com.xjs.**.mapper"})
|
||||
|
|
|
|||
|
|
@ -1,11 +1,22 @@
|
|||
package com.xjs.topsearch.controller;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.security.annotation.RequiresLogin;
|
||||
import com.xjs.topsearch.domain.ApiTopsearchAllnetwork;
|
||||
import com.xjs.topsearch.factory.TopserachFactory;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 热搜榜控制器
|
||||
* @author xiejs
|
||||
* @since 2022-01-10
|
||||
*/
|
||||
|
|
@ -15,6 +26,27 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@Log4j2
|
||||
public class ApiTopSearchController {
|
||||
|
||||
@Autowired
|
||||
private TopserachFactory<ApiTopsearchAllnetwork> tianXingTopsearchAllnetworkFactory;
|
||||
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("热搜榜接口")
|
||||
@Log(title = "获取热搜榜")
|
||||
@RequiresLogin
|
||||
public AjaxResult topSearch() {
|
||||
//获取全网热搜
|
||||
List<ApiTopsearchAllnetwork> allnetworkList = tianXingTopsearchAllnetworkFactory.topSearchApi();
|
||||
//获取微博热搜
|
||||
|
||||
//获取抖音热搜
|
||||
|
||||
//获取微信热搜
|
||||
|
||||
//获取百度热搜
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import lombok.extern.log4j.Log4j2;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -52,10 +53,12 @@ public class TianXingTopsearchAllnetworkFactory implements TopserachFactory<ApiT
|
|||
log.info("全网热搜批量插入成功了嘛---" + apiTopsearchAllnetworkService.saveBatch(collect));
|
||||
return collect;
|
||||
} else {
|
||||
throw new ApiException("天行全网热搜服务调用成功,但返回异常");
|
||||
log.error("天行全网热搜服务调用成功,但返回异常");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
} else {
|
||||
throw new ApiException("天行全网热搜服务调用失败,被降级!!");
|
||||
log.error("天行全网热搜服务调用失败,被降级!!");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue