去除本子更新;去除获取本子首页缩略图接口,改为获取页数为0的在线图片;
This commit is contained in:
parent
9df2b7994b
commit
f451aaaf9c
@ -20,7 +20,7 @@ import com.pengrad.telegrambot.model.User;
|
||||
SendResponse.class, Message.class, com.pengrad.telegrambot.model.User.class,
|
||||
Chat.class, MessageEntity.class,
|
||||
AbstractMethodError.class, DeleteGalleryMessage.class, DownloadPostMessage.class, DownloadStatusMessage.class,
|
||||
GalleryPageQueryMessage.class, GalleryRequestMessage.class, IdentityMessage.class, MaintainMessage.class, ResponseMessage.class, UpdateGalleryMessage.class})
|
||||
GalleryPageQueryMessage.class, GalleryRequestMessage.class, IdentityMessage.class, MaintainMessage.class, ResponseMessage.class})
|
||||
public class CustomBean {
|
||||
|
||||
@Bean
|
||||
|
||||
@ -36,11 +36,6 @@ public class GalleryManageController {
|
||||
return galleryManageService.createTask(link, targetResolution, AuthCode, tags, Byte.parseByte(mode));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public String updateGallery(String link){
|
||||
return galleryManageService.updateGallery(link);
|
||||
}
|
||||
|
||||
@GetMapping("")
|
||||
public String selectGallery(String param, String type, String AuthCode) {
|
||||
int userId = userService.getUserId(AuthCode); //能调到这里的授权码对应用户不可能为空
|
||||
@ -96,11 +91,6 @@ public class GalleryManageController {
|
||||
return galleryManageService.getWeekUsedAmount();
|
||||
}
|
||||
|
||||
@GetMapping("/thumbnail/{name}")
|
||||
public void getThumbnail(HttpServletRequest request, HttpServletResponse response, @PathVariable("name") String name){
|
||||
galleryManageService.getThumbnail(request, response, name.replace(".webp", ""));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/onlineImage/{page}")
|
||||
public void getOnlineImage(Integer gid, @PathVariable("page") Short page, HttpServletRequest request, HttpServletResponse response){
|
||||
|
||||
@ -13,8 +13,6 @@ public class AbstractMessage {
|
||||
|
||||
public static final byte RESPONSE_MESSAGE = 0;
|
||||
|
||||
public static final byte UPDATE_GALLERY_MESSAGE = 4;
|
||||
|
||||
public static final byte GALLERY_PAGE_QUERY_MESSAGE = 5;
|
||||
|
||||
public static final byte IDENTITY_MESSAGE = 6;
|
||||
|
||||
@ -41,7 +41,6 @@ public class MessageCodec extends ByteToMessageCodec<AbstractMessage> {
|
||||
case AbstractMessage.DOWNLOAD_STATUS_MESSAGE -> objectMapper.readValue(metadata, DownloadStatusMessage.class);
|
||||
case AbstractMessage.GALLERY_REQUEST_MESSAGE -> objectMapper.readValue(metadata, GalleryRequestMessage.class);
|
||||
case AbstractMessage.RESPONSE_MESSAGE -> objectMapper.readValue(metadata, ResponseMessage.class);
|
||||
case AbstractMessage.UPDATE_GALLERY_MESSAGE -> objectMapper.readValue(metadata, UpdateGalleryMessage.class);
|
||||
case AbstractMessage.DELETE_GALLERY_MESSAGE -> objectMapper.readValue(metadata, DeleteGalleryMessage.class);
|
||||
case AbstractMessage.GALLERY_PAGE_QUERY_MESSAGE -> objectMapper.readValue(metadata, GalleryPageQueryMessage.class);
|
||||
case AbstractMessage.IDENTITY_MESSAGE -> objectMapper.readValue(metadata, IdentityMessage.class);
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
package com.lion.lionwebsite.Message;
|
||||
|
||||
import com.lion.lionwebsite.Domain.GalleryTask;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateGalleryMessage extends AbstractMessage{
|
||||
{
|
||||
messageType = UPDATE_GALLERY_MESSAGE;
|
||||
}
|
||||
|
||||
GalleryTask galleryTask;
|
||||
|
||||
|
||||
}
|
||||
@ -412,57 +412,6 @@ public class GalleryManageService {
|
||||
return response.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新本子
|
||||
* @param link 目标链接
|
||||
* @return 更新结果
|
||||
*/
|
||||
public String updateGallery(String link){
|
||||
Response response = Response.generateResponse();
|
||||
|
||||
Integer gid = parseGid(link);
|
||||
if(gid == null) {
|
||||
response.failure("链接格式出错");
|
||||
return response.toJSONString();
|
||||
}
|
||||
|
||||
Gallery oldGallery = galleryMapper.selectGalleryByGid(gid);
|
||||
if(oldGallery == null) {
|
||||
response.failure("数据库不存在该本子,请提交下载");
|
||||
return response.toJSONString();
|
||||
}
|
||||
|
||||
try {
|
||||
String newLink = GalleryUtil.queryUpdateLink(oldGallery.getLink());
|
||||
if(newLink == null)
|
||||
response.failure("本子没有更新");
|
||||
|
||||
else{
|
||||
Gallery newGallery = GalleryUtil.parse(newLink, true, oldGallery.getResolution());
|
||||
if(newGallery != null) {
|
||||
galleryMapper.deleteGalleryByGid(oldGallery.getGid());
|
||||
remoteService.updateGallery(newGallery, oldGallery.getMode());
|
||||
newGallery.setDownloader(oldGallery.getDownloader());
|
||||
newGallery.setCollector(oldGallery.getCollector());
|
||||
|
||||
long usedAmount = Long.parseLong(configurationMapper.selectConfiguration(CustomConfiguration.WEEK_USED_AMOUNT).getValue());
|
||||
usedAmount += newGallery.getFileSize();
|
||||
configurationMapper.updateConfiguration(CustomConfiguration.WEEK_USED_AMOUNT, String.valueOf(usedAmount));
|
||||
|
||||
galleryMapper.insertGallery(newGallery);
|
||||
response.success("提交更新成功,更新页数:" + newGallery.getPages());
|
||||
}
|
||||
else {
|
||||
response.failure("存在更新,但更新失败");
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
response.failure("获取更新失败");
|
||||
}
|
||||
|
||||
return response.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取每周额度以及上次重置时间
|
||||
* @return 查询结果
|
||||
@ -480,25 +429,6 @@ public class GalleryManageService {
|
||||
return response.toJSONString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取缩略图 (直接按照名字路径获取,后期可能会加入缓存)
|
||||
* @param request 请求对象
|
||||
* @param response 响应对象
|
||||
* @param name 本子名字
|
||||
*/
|
||||
public void getThumbnail(HttpServletRequest request, HttpServletResponse response, String name){
|
||||
File thumbnail = new File(TargetPath + name, "thumbnail.webp");
|
||||
|
||||
if(!thumbnail.exists())
|
||||
if(remoteService.cachePreview(name, (short) 0, thumbnail) != 0){
|
||||
fourZeroFour(response);
|
||||
return;
|
||||
}
|
||||
|
||||
FileDownload.export(request, response, thumbnail.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取在线图片
|
||||
* @param gid gid
|
||||
|
||||
@ -240,31 +240,6 @@ public class RemoteService {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateGallery(Gallery gallery, byte type){
|
||||
GalleryTask galleryTask = new GalleryTask();
|
||||
galleryTask.setGid(gallery.getGid());
|
||||
galleryTask.setType(type);
|
||||
galleryTask.setPages(gallery.getPages());
|
||||
|
||||
UpdateGalleryMessage ugm = new UpdateGalleryMessage();
|
||||
ugm.messageId = atomicInteger.getAndIncrement();
|
||||
ugm.setGalleryTask(galleryTask);
|
||||
channel.writeAndFlush(ugm);
|
||||
|
||||
DefaultPromise<AbstractMessage> promise = new DefaultPromise<>(eventLoopGroup);
|
||||
promiseHashMap.put(ugm.messageId, promise);
|
||||
try {
|
||||
boolean result = promise.await(10, TimeUnit.SECONDS);
|
||||
if(result){
|
||||
ResponseMessage rsm = (ResponseMessage)promise.getNow();
|
||||
if(rsm.getResult() != 0)
|
||||
log.error("更新本子" + gallery.getName() + "出错" + rsm.getResult());
|
||||
}
|
||||
}catch (InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void monitorFunc(){
|
||||
System.out.println("监听端口: " + (port + 1) + " 等待节点上线");
|
||||
try(ServerSocket socket = new ServerSocket(port + 1)) {
|
||||
|
||||
@ -8,6 +8,7 @@ import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.jsoup.Jsoup;
|
||||
@ -199,10 +200,12 @@ public class GalleryUtil {
|
||||
}
|
||||
|
||||
if(body != null) {
|
||||
EntityBuilder entityBuilder = EntityBuilder.create();
|
||||
entityBuilder.setContentType(ContentType.APPLICATION_JSON);
|
||||
entityBuilder.setText(CustomUtil.objectMapper.writeValueAsString(body));
|
||||
httpPost.setEntity(entityBuilder.build());
|
||||
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
|
||||
body.forEach(multipartEntityBuilder::addTextBody);
|
||||
// EntityBuilder entityBuilder = EntityBuilder.create();
|
||||
// entityBuilder.setContentType(ContentType.APPLICATION_JSON);
|
||||
// entityBuilder.setText(CustomUtil.objectMapper.writeValueAsString(body));
|
||||
httpPost.setEntity(multipartEntityBuilder.build());
|
||||
}
|
||||
httpResponse = httpClient.execute(httpPost);
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user