账号模块修改命名规则

This commit is contained in:
welsir
2024-05-27 23:09:09 +08:00
parent 2e3c53da5a
commit 4b7b53dd64
7 changed files with 21 additions and 17 deletions

View File

@@ -14,7 +14,7 @@ import javax.annotation.Resource;
* @Date 2023/9/5 22:36
*/
@RestController
@RequestMapping("")
@RequestMapping("/video")
public class VideoPushApi {
@Resource

View File

@@ -44,7 +44,7 @@ public class Exchange {
//切片推送
public void work(){
System.out.println("执行视频发布推送工作..........");
log.info("执行视频发布推送工作..........");
Map<String, List<Account>> channelAccount = channel.getChannelAccount();
channels.forEach((k,v)->{
if(channels.get(k)==null||channelAccount.get(k)==null){
@@ -54,6 +54,7 @@ public class Exchange {
List<PacketSectionVideo> packageSections = channels.get(k);
for (Account account : accountList) {
for (PackageSection packageSection : packageSections) {
//换成builder
VideoToPublish video = new VideoToPublish();
video.setCookies(account.getCookies());
video.setTitle(packageSection.getTitle());

View File

@@ -27,10 +27,6 @@ import java.util.concurrent.TimeUnit;
@Component
public class PostWorkerManager extends SpringBootPlugin {
int coreSize = 15;
int maxSize = 20;
ThreadPoolExecutor executor;
HashMap<String,PacketSectionVideo> temporaryPool = new HashMap<>();
@Resource
Exchange exchange;
@@ -40,7 +36,6 @@ public class PostWorkerManager extends SpringBootPlugin {
VideoTemporaryMapper mapper;
@Override
public boolean init() {
executor = new ThreadPoolExecutor(coreSize,maxSize,0, TimeUnit.SECONDS,new LinkedBlockingQueue<>(),new ThreadPoolExecutor.AbortPolicy());
startProcess();
return super.init();
}
@@ -60,15 +55,17 @@ public class PostWorkerManager extends SpringBootPlugin {
for (PacketSectionVideo video : videoList) {
String route = String.join(".", video.getLabels());
//是否自动推送
if(video.isRelay()){
if(!video.isAuto()){
temporaryPool.put(video.getId(),video);
continue;
}
exchange.pushToQueue(route,video);
video.setFinish(true);
videoStorehouse.setCount();
videoStorehouse.decrementCount();
}
}
//如何保证数据一定会被消费且不会重复消费
exchange.work();
saveToLocal();
}

View File

@@ -18,9 +18,8 @@ public class DefaultVideoPushStrategy extends StrategyFactory {
private List<String> priorityImportWord = new ArrayList<>();
@Override
public PacketSectionVideo rule(PackageSection obj) {
public PacketSectionVideo wrapperSectionVideo(PackageSection obj) {
if(obj != null){
return wrapPacketSection(obj);
}

View File

@@ -7,7 +7,7 @@ package org.example.core.factory.videoPushFactory;
*/
public abstract class StrategyFactory implements VideoPushStrategy {
public static StrategyFactory connect(int x){
public static StrategyFactory selectStrategy(int x){
switch (x) {
case 0:
return new DefaultVideoPushStrategy();

View File

@@ -12,7 +12,7 @@ import java.util.List;
*/
public interface VideoPushStrategy {
PacketSectionVideo rule(PackageSection obj);
PacketSectionVideo wrapperSectionVideo(PackageSection obj);
List<String> queryPriority();

View File

@@ -5,8 +5,10 @@ import org.example.bean.section.PackageSection;
import org.example.core.factory.videoPushFactory.StrategyFactory;
import org.example.plugin.SpringGuardPlugin;
import org.example.pojo.PacketSectionVideo;
import org.example.sql.SQLInitHelper;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
@@ -29,9 +31,12 @@ public class VideoPushChannelGuard extends SpringGuardPlugin {
private int val = 0;
private AtomicInteger count = new AtomicInteger(0);
@Resource
SQLInitHelper sqlInitHelper;
@Override
public boolean init() {
factory = StrategyFactory.connect(val);
factory = StrategyFactory.selectStrategy(val);
sqlInitHelper.initTable("videoTemp","");
return true;
}
@@ -41,7 +46,8 @@ public class VideoPushChannelGuard extends SpringGuardPlugin {
if(p==null){
return;
}
PacketSectionVideo packedVideo = factory.rule(p);
//数据库持久化保存
PacketSectionVideo packedVideo = factory.wrapperSectionVideo(p);
videosCollection.put(packedVideo.getId(),packedVideo);
count.incrementAndGet();
}
@@ -51,10 +57,10 @@ public class VideoPushChannelGuard extends SpringGuardPlugin {
}
public boolean pushNotify(){
return count.get()!=0;
return count.get()!=0;
}
public void setCount(){
public void decrementCount(){
count.decrementAndGet();
}
public List<String> priority(){
@@ -72,4 +78,5 @@ public class VideoPushChannelGuard extends SpringGuardPlugin {
.forEach(list::add);
return list;
}
}