mirror of
https://github.com/Geniusay/ChopperBot.git
synced 2026-06-03 05:12:19 +08:00
热门模块接口重构
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
package org.example.api;
|
||||
|
||||
import org.example.config.BarrageScoreConfig;
|
||||
import org.example.pojo.Anchor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Author welsir
|
||||
* @Date 2023/8/2 22:51
|
||||
*/
|
||||
public class BarrageModuleApi {
|
||||
|
||||
// public static void updateAnchorBarrageScore(String roomId, String plathForm, List<Anchor> anchorList){
|
||||
// BarrageScoreConfig.setAnchorConfig(roomId,plathForm,anchorList);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -17,20 +17,20 @@ import java.util.Map;
|
||||
* @date 2023/10/13 17:52
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/barrage")
|
||||
public class BarrageController {
|
||||
@RequestMapping("/barrage/barrageScoreCurve")
|
||||
@CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN})
|
||||
public class BarrageScoreCurveController {
|
||||
|
||||
@Resource
|
||||
BarrageService barrageService;
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN})
|
||||
@GetMapping("/barrageScoreCurve/curveList")
|
||||
|
||||
@GetMapping("/curveList")
|
||||
public Result curveVOList(){
|
||||
return Result.success(Map.of("list",barrageService.barrageScoreCurvePluginApi().curveVOList()));
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN})
|
||||
@GetMapping("/barrageScoreCurve/generate")
|
||||
@GetMapping("/generate")
|
||||
public Result generateCurve(@RequestParam(required = false) String filePath,@RequestParam(required = false) String liver){
|
||||
if(!StringUtils.hasText(filePath)){
|
||||
filePath = "E:\\Project\\ChopperBot\\config\\Barrage\\online\\huya\\Uzi_2023-10-18 21_22_57.json";
|
||||
@@ -43,36 +43,30 @@ public class BarrageController {
|
||||
return Result.success(Map.of("curve",barrageCurveVO));
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN})
|
||||
@GetMapping("/barrageScoreCurve/keywords")
|
||||
@GetMapping("/keywords")
|
||||
public Result getKeyWords(@RequestParam(required = false) String liver) {
|
||||
return Result.success(Map.of("list", barrageService.barrageScoreCurvePluginApi().getKeyWords(liver)));
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN})
|
||||
@GetMapping("/barrageScoreCurve/delete")
|
||||
@GetMapping("/delete")
|
||||
public Result deleteKeyWords(@RequestParam String liver,@RequestParam String keyWord) {
|
||||
return Result.success(Map.of("success",
|
||||
barrageService.barrageScoreCurvePluginApi().deleteKeyWord(liver,keyWord)));
|
||||
}
|
||||
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN})
|
||||
@PostMapping("/barrageScoreCurve/add")
|
||||
@PostMapping("/add")
|
||||
public Result addKeyWords(@RequestBody LiverKeyword keyword) {
|
||||
return Result.success(Map.of("success",
|
||||
barrageService.barrageScoreCurvePluginApi().addKeyWord(keyword)));
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN})
|
||||
@PostMapping("/barrageScoreCurve/update")
|
||||
@PostMapping("/update")
|
||||
public Result updateKeyWords(@RequestBody LiverKeyword keyword) {
|
||||
return Result.success(Map.of("success",
|
||||
barrageService.barrageScoreCurvePluginApi().updateKeyWord(keyword)));
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.BARRAGE_SCORE_CURVE_PLUGIN})
|
||||
@GetMapping("/barrageScoreCurve/setting")
|
||||
@GetMapping("/setting")
|
||||
public Result getSetting(){
|
||||
return Result.success(Map.of("curve",barrageService.barrageScoreCurvePluginApi().getSetting()));
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import java.lang.annotation.Target;
|
||||
* api需要哪些插件的注解
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Target({ElementType.METHOD,ElementType.TYPE})
|
||||
public @interface CheckPlugin {
|
||||
|
||||
String[] needPlugin() default {};
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.example.config;
|
||||
|
||||
import org.example.interceptor.ApiPrefixInterceptor;
|
||||
import org.example.interceptor.PluginCheckInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
@@ -15,10 +17,14 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(apiPrefixInterceptor());
|
||||
registry.addInterceptor(checkInterceptor());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ApiPrefixInterceptor apiPrefixInterceptor() {
|
||||
return new ApiPrefixInterceptor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PluginCheckInterceptor checkInterceptor() {return new PluginCheckInterceptor();}
|
||||
}
|
||||
|
||||
@@ -1,192 +0,0 @@
|
||||
package org.example.controller;
|
||||
|
||||
import com.genius.assistant.common.Result;
|
||||
import org.example.api.HotModuleApi;
|
||||
import org.example.bean.*;
|
||||
import org.example.bean.hotmodule.HotModuleList;
|
||||
import org.example.constpool.ConstPool;
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.core.HotModuleDataCenter;
|
||||
import org.example.core.guard.Guard;
|
||||
import org.example.plugin.annotation.CheckPlugin;
|
||||
import org.example.service.FocusLiverService;
|
||||
import org.example.service.HotModuleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
* @date 2023/07/21 17:13
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/hot")
|
||||
public class HotController {
|
||||
|
||||
@Autowired
|
||||
HotModuleService hotModuleService;
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_GUARD_PLUGIN})
|
||||
@GetMapping("/hotLive/live")
|
||||
public Result getAllHotLive(@RequestParam(defaultValue = "0") int latest,@RequestParam String platform){
|
||||
List<? extends Live> lives = hotModuleService.hotModuleApi().getHotLiveList(platform);
|
||||
if(lives==null){
|
||||
return Result.error("403","暂无该数据");
|
||||
}
|
||||
return Result.success(Map.of("list",lives));
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_GUARD_PLUGIN})
|
||||
@GetMapping("/hotLive/module")
|
||||
public Result getAllHotModule(@RequestParam(defaultValue = "0") int latest,@RequestParam String platform){
|
||||
HotModuleList hotModuleList = hotModuleService.hotModuleApi().getAllHotModule(platform);
|
||||
if(hotModuleList==null||hotModuleList.getHotModuleList()==null){
|
||||
return Result.error("403","暂无该数据");
|
||||
}
|
||||
return Result.success(Map.of("list",hotModuleList.getHotModuleList()));
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_GUARD_PLUGIN})
|
||||
@GetMapping("/hotLive/modelLive")
|
||||
public Result getHotModuleLives(@RequestParam String moduleId,@RequestParam String platform){
|
||||
HotModule moduleHotLives = hotModuleService.hotModuleApi().getModuleList(platform, moduleId);
|
||||
if(moduleHotLives==null||moduleHotLives.getHotLives()==null){
|
||||
return Result.error("403","暂无该数据");
|
||||
}
|
||||
return Result.success(Map.of("list",moduleHotLives.getHotLives()));
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_GUARD_PLUGIN})
|
||||
@GetMapping("/hotGuard/setting")
|
||||
public Result getHotGuardSetting(){
|
||||
List<HotModuleSetting> allSettings = hotModuleService.hotModuleGuardApi().getAllSettings();
|
||||
return Result.success(
|
||||
Map.of("list",allSettings)
|
||||
);
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_GUARD_PLUGIN})
|
||||
@PostMapping("/hotGuard/update")
|
||||
public Result updateHotGuardSetting(@RequestBody HotModuleSetting setting){
|
||||
boolean b = hotModuleService.hotModuleGuardApi().changeSetting(setting);
|
||||
return Result.success(
|
||||
Map.of("success",b)
|
||||
);
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_GUARD_PLUGIN})
|
||||
@GetMapping("/hotGuard/guard")
|
||||
public Result hotGuards(){
|
||||
List<GuardVO> guards = hotModuleService.hotModuleGuardApi().getGuards();
|
||||
return Result.success(
|
||||
Map.of("list",guards)
|
||||
);
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_LIVER_FOLLOWER})
|
||||
@GetMapping("/liveFollow/list")
|
||||
public Result followList(){
|
||||
List<FocusLiver> focusLivers = hotModuleService.liverFollowApi().allFocusLivers();
|
||||
return Result.success(
|
||||
Map.of("list",focusLivers)
|
||||
);
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_LIVER_FOLLOWER})
|
||||
@PostMapping("/liveFollow/add")
|
||||
public Result addFocus(@RequestBody FocusLiver focusLiver){
|
||||
boolean follow = hotModuleService.liverFollowApi().follow(focusLiver);
|
||||
return Result.success(
|
||||
Map.of("success",follow)
|
||||
);
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_LIVER_FOLLOWER})
|
||||
@GetMapping("/liveFollow/delete")
|
||||
public Result deleteFocus(@RequestParam String platform,@RequestParam String liver){
|
||||
boolean delete = hotModuleService.liverFollowApi().unFollow(platform,liver);
|
||||
return Result.success(
|
||||
Map.of("success",delete)
|
||||
);
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_LIVER_FOLLOWER})
|
||||
@GetMapping("/liveFollow/changeSetting")
|
||||
public Result changeLiverFollowSetting(@RequestParam(required = false) Integer focusLive,
|
||||
@RequestParam(required = false) Integer focusBarrage,
|
||||
@RequestParam(required = false) Long checkTime){
|
||||
hotModuleService.liverFollowApi().changeSetting(
|
||||
Map.of("focusLive",focusLive,
|
||||
"focusBarrage",focusBarrage,
|
||||
"checkTime",checkTime
|
||||
)
|
||||
);
|
||||
return Result.success(
|
||||
Map.of("success",true)
|
||||
);
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_LIVER_FOLLOWER})
|
||||
@GetMapping("/liveFollow/setting")
|
||||
public Result changeLiverFollowSetting(){
|
||||
return Result.success(
|
||||
Map.of("setting",hotModuleService.liverFollowApi().getSetting())
|
||||
);
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_RECOMMENDATION_PLUGIN})
|
||||
@GetMapping("/hotRecommendation/list")
|
||||
public Result getFollowDogs(){
|
||||
return Result.success(
|
||||
Map.of(
|
||||
"list",hotModuleService.heatRecommendApi().getFollowDog()
|
||||
)
|
||||
);
|
||||
}
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_RECOMMENDATION_PLUGIN})
|
||||
@PostMapping("/hotRecommendation/add")
|
||||
public Result addFollowDogs(@RequestBody FollowDog dog){
|
||||
dog.setId(null);
|
||||
|
||||
boolean success = hotModuleService.heatRecommendApi().addFollowDog(dog);
|
||||
if(success){
|
||||
return Result.success(
|
||||
Map.of("add",dog)
|
||||
);
|
||||
}else{
|
||||
return Result.error("403","添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_RECOMMENDATION_PLUGIN})
|
||||
@PostMapping("/hotRecommendation/update")
|
||||
public Result updateFollowDogs(@RequestBody FollowDog dog){
|
||||
boolean success = hotModuleService.heatRecommendApi().updateFollowDog(dog);
|
||||
return Result.success(
|
||||
Map.of("success",success)
|
||||
);
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_RECOMMENDATION_PLUGIN})
|
||||
@GetMapping("/hotRecommendation/delete")
|
||||
public Result addFollowDogs(@RequestParam String dogId,@RequestParam String platform){
|
||||
boolean success = hotModuleService.heatRecommendApi().deleteFollowDog(dogId,platform);
|
||||
return Result.success(
|
||||
Map.of("success",success)
|
||||
);
|
||||
}
|
||||
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_RECOMMENDATION_PLUGIN})
|
||||
@GetMapping("/hotRecommendation/open")
|
||||
public Result openFollowDogs(@RequestParam String platform,@RequestParam Boolean isOpen){
|
||||
boolean success = hotModuleService.heatRecommendApi().openPlatformFollowDog(platform,isOpen);
|
||||
return Result.success(
|
||||
Map.of("success",success)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.example.config;
|
||||
package org.example.interceptor;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.example.interceptor;
|
||||
|
||||
import org.example.exception.plugin.PluginNotRegisterException;
|
||||
import org.example.init.InitPluginRegister;
|
||||
import org.example.plugin.annotation.CheckPlugin;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@Component
|
||||
public class PluginCheckInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
if (handler instanceof HandlerMethod) {
|
||||
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
||||
CheckPlugin checkPlugin = handlerMethod.getBeanType().getAnnotation(CheckPlugin.class);
|
||||
|
||||
if (checkPlugin != null) {
|
||||
for (String plugin: checkPlugin.needPlugin()) {
|
||||
if(!InitPluginRegister.isRegister(plugin)){
|
||||
throw new PluginNotRegisterException(checkPlugin.needPlugin());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.example.controller;
|
||||
|
||||
import com.genius.assistant.common.Result;
|
||||
import org.example.api.HotModuleGuardApi;
|
||||
import org.example.bean.GuardVO;
|
||||
import org.example.bean.HotModuleSetting;
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.plugin.annotation.CheckPlugin;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 热门守卫插件接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/hot/hotGuard")
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_GUARD_PLUGIN})
|
||||
public class HotGuardController {
|
||||
|
||||
@Resource
|
||||
private HotModuleGuardApi hotModuleGuardApi;
|
||||
|
||||
@GetMapping("/setting")
|
||||
public Result getHotGuardSetting(){
|
||||
List<HotModuleSetting> allSettings = hotModuleGuardApi.getAllSettings();
|
||||
return Result.success(
|
||||
Map.of("list",allSettings)
|
||||
);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public Result updateHotGuardSetting(@RequestBody HotModuleSetting setting){
|
||||
boolean b = hotModuleGuardApi.changeSetting(setting);
|
||||
return Result.success(
|
||||
Map.of("success",b)
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("/guard")
|
||||
public Result hotGuards(){
|
||||
List<GuardVO> guards = hotModuleGuardApi.getGuards();
|
||||
return Result.success(
|
||||
Map.of("list",guards)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package org.example.controller;
|
||||
|
||||
import com.genius.assistant.common.Result;
|
||||
import org.example.api.HotModuleApi;
|
||||
import org.example.bean.HotModule;
|
||||
import org.example.bean.Live;
|
||||
import org.example.bean.hotmodule.HotModuleList;
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.plugin.annotation.CheckPlugin;
|
||||
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 javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 热门模块插件接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/hot/hotLive")
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_GUARD_PLUGIN})
|
||||
public class HotModuleController {
|
||||
|
||||
@Resource
|
||||
HotModuleApi hotModuleApi;
|
||||
|
||||
@GetMapping("/live")
|
||||
public Result getAllHotLive(@RequestParam(defaultValue = "0") int latest, @RequestParam String platform){
|
||||
List<? extends Live> lives = hotModuleApi.getHotLiveList(platform);
|
||||
if(lives==null){
|
||||
return Result.error("403","暂无该数据");
|
||||
}
|
||||
return Result.success(Map.of("list",lives));
|
||||
}
|
||||
|
||||
@GetMapping("/module")
|
||||
public Result getAllHotModule(@RequestParam(defaultValue = "0") int latest,@RequestParam String platform){
|
||||
HotModuleList hotModuleList = hotModuleApi.getAllHotModule(platform);
|
||||
if(hotModuleList==null||hotModuleList.getHotModuleList()==null){
|
||||
return Result.error("403","暂无该数据");
|
||||
}
|
||||
return Result.success(Map.of("list",hotModuleList.getHotModuleList()));
|
||||
}
|
||||
|
||||
@GetMapping("/modelLive")
|
||||
public Result getHotModuleLives(@RequestParam String moduleId,@RequestParam String platform){
|
||||
HotModule moduleHotLives = hotModuleApi.getModuleList(platform, moduleId);
|
||||
if(moduleHotLives==null||moduleHotLives.getHotLives()==null){
|
||||
return Result.error("403","暂无该数据");
|
||||
}
|
||||
return Result.success(Map.of("list",moduleHotLives.getHotLives()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package org.example.controller;
|
||||
|
||||
import com.genius.assistant.common.Result;
|
||||
import org.example.api.HeatRecommendApi;
|
||||
import org.example.bean.FollowDog;
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.plugin.annotation.CheckPlugin;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/hot/hotRecommendation")
|
||||
@CheckPlugin(needPlugin =PluginName.HOT_RECOMMENDATION_PLUGIN)
|
||||
public class HotRecommendationController {
|
||||
|
||||
@Resource
|
||||
private HeatRecommendApi heatRecommendApi;
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result getFollowDogs(){
|
||||
return Result.success(
|
||||
Map.of(
|
||||
"list",heatRecommendApi.getFollowDog()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public Result addFollowDogs(@RequestBody FollowDog dog){
|
||||
dog.setId(null);
|
||||
|
||||
boolean success = heatRecommendApi.addFollowDog(dog);
|
||||
if(success){
|
||||
return Result.success(
|
||||
Map.of("add",dog)
|
||||
);
|
||||
}else{
|
||||
return Result.error("403","添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public Result updateFollowDogs(@RequestBody FollowDog dog){
|
||||
boolean success = heatRecommendApi.updateFollowDog(dog);
|
||||
return Result.success(
|
||||
Map.of("success",success)
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("/delete")
|
||||
public Result addFollowDogs(@RequestParam String dogId, @RequestParam String platform){
|
||||
boolean success = heatRecommendApi.deleteFollowDog(dogId,platform);
|
||||
return Result.success(
|
||||
Map.of("success",success)
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("/open")
|
||||
public Result openFollowDogs(@RequestParam String platform,@RequestParam Boolean isOpen){
|
||||
boolean success = heatRecommendApi.openPlatformFollowDog(platform,isOpen);
|
||||
return Result.success(
|
||||
Map.of("success",success)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.example.controller;
|
||||
|
||||
|
||||
import com.genius.assistant.common.Result;
|
||||
import org.example.api.LiverFollowApi;
|
||||
import org.example.bean.FocusLiver;
|
||||
import org.example.constpool.PluginName;
|
||||
import org.example.plugin.annotation.CheckPlugin;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/hot/liveFollow")
|
||||
@CheckPlugin(needPlugin = {PluginName.HOT_LIVER_FOLLOWER})
|
||||
public class LiveFollowController {
|
||||
|
||||
@Resource
|
||||
private LiverFollowApi liverFollowApi;
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result followList(){
|
||||
List<FocusLiver> focusLivers = liverFollowApi.allFocusLivers();
|
||||
return Result.success(
|
||||
Map.of("list",focusLivers)
|
||||
);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public Result addFocus(@RequestBody FocusLiver focusLiver){
|
||||
boolean follow = liverFollowApi.follow(focusLiver);
|
||||
return Result.success(
|
||||
Map.of("success",follow)
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("/delete")
|
||||
public Result deleteFocus(@RequestParam String platform,@RequestParam String liver){
|
||||
boolean delete = liverFollowApi.unFollow(platform,liver);
|
||||
return Result.success(
|
||||
Map.of("success",delete)
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("/changeSetting")
|
||||
public Result changeLiverFollowSetting(@RequestParam(required = false) Integer focusLive,
|
||||
@RequestParam(required = false) Integer focusBarrage,
|
||||
@RequestParam(required = false) Long checkTime){
|
||||
liverFollowApi.changeSetting(
|
||||
Map.of("focusLive",focusLive,
|
||||
"focusBarrage",focusBarrage,
|
||||
"checkTime",checkTime
|
||||
)
|
||||
);
|
||||
return Result.success(
|
||||
Map.of("success",true)
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("/setting")
|
||||
public Result changeLiverFollowSetting(){
|
||||
return Result.success(
|
||||
Map.of("setting",liverFollowApi.getSetting())
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user