Compare commits
2 Commits
2c08552986
...
9df2b7994b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9df2b7994b | ||
|
|
e1afc3a6c5 |
@ -7,15 +7,15 @@ import com.pengrad.telegrambot.model.Chat;
|
|||||||
import com.pengrad.telegrambot.model.Message;
|
import com.pengrad.telegrambot.model.Message;
|
||||||
import com.pengrad.telegrambot.model.MessageEntity;
|
import com.pengrad.telegrambot.model.MessageEntity;
|
||||||
import com.pengrad.telegrambot.response.SendResponse;
|
import com.pengrad.telegrambot.response.SendResponse;
|
||||||
import com.sun.tools.javac.Main;
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
import org.springframework.aot.hint.annotation.RegisterReflectionForBinding;
|
import org.springframework.aot.hint.annotation.RegisterReflectionForBinding;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import com.pengrad.telegrambot.model.User;
|
import com.pengrad.telegrambot.model.User;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@RegisterReflectionForBinding(classes = {CRC32Cache.class, CustomConfiguration.class,
|
@RegisterReflectionForBinding(classes = {CustomConfiguration.class,
|
||||||
GalleryForQuery.class, Gallery.class, GalleryTask.class, MaskDomain.class,
|
GalleryForQuery.class, Gallery.class, GalleryTask.class, HikariConfig.class,
|
||||||
PageNameCache.class, ShareFile.class, Tag.class, TagMark.class, User.class,
|
PageNameCache.class, ShareFile.class, Tag.class, TagMark.class, User.class,
|
||||||
SendResponse.class, Message.class, com.pengrad.telegrambot.model.User.class,
|
SendResponse.class, Message.class, com.pengrad.telegrambot.model.User.class,
|
||||||
Chat.class, MessageEntity.class,
|
Chat.class, MessageEntity.class,
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
package com.lion.lionwebsite.Configuration;
|
package com.lion.lionwebsite.Configuration;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Domain.MaskDomain;
|
|
||||||
import com.lion.lionwebsite.Interceptor.HumanInterceptor;
|
import com.lion.lionwebsite.Interceptor.HumanInterceptor;
|
||||||
import com.lion.lionwebsite.Interceptor.PersonalInterceptor;
|
import com.lion.lionwebsite.Interceptor.PersonalInterceptor;
|
||||||
import com.lion.lionwebsite.Interceptor.TaskHandlerInterceptor;
|
import com.lion.lionwebsite.Interceptor.TaskHandlerInterceptor;
|
||||||
import com.lion.lionwebsite.Util.CustomUtil;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
@ -36,14 +33,4 @@ public class InterceptorConfiguration implements WebMvcConfigurer {
|
|||||||
public HandlerInterceptor getHumanInterceptor(){
|
public HandlerInterceptor getHumanInterceptor(){
|
||||||
return new HumanInterceptor();
|
return new HumanInterceptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CustomUtil getParameterUtil(){
|
|
||||||
CustomUtil customUtil = new CustomUtil();
|
|
||||||
MaskDomain[] maskDomains = new MaskDomain[2];
|
|
||||||
maskDomains[0] = new MaskDomain("exhentai.org", "element-plus.org");
|
|
||||||
maskDomains[1] = new MaskDomain("e-hentai.org", "element.org");
|
|
||||||
customUtil.setMaskDomains(maskDomains);
|
|
||||||
return customUtil;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,51 @@
|
|||||||
|
package com.lion.lionwebsite.Configuration;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
|
import org.mybatis.spring.SqlSessionTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SqlConfiguration {
|
||||||
|
@Bean(name = "datasource-main")
|
||||||
|
@ConfigurationProperties(prefix = "spring.datasource-main")
|
||||||
|
public DataSource dataSourceMain() {
|
||||||
|
return DataSourceBuilder.create().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "datasource-cache")
|
||||||
|
@ConfigurationProperties(prefix = "spring.datasource-cache")
|
||||||
|
public DataSource dataSourceCache() {
|
||||||
|
return DataSourceBuilder.create().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "sqlSessionFactory-main")
|
||||||
|
public SqlSessionFactory sqlSessionFactoryMain(@Qualifier("datasource-main") DataSource dataSource) throws Exception {
|
||||||
|
SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
|
||||||
|
sessionFactoryBean.setDataSource(dataSource);
|
||||||
|
return sessionFactoryBean.getObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "sqlSessionFactory-cache")
|
||||||
|
public SqlSessionFactory sqlSessionFactoryCache(@Qualifier("datasource-cache") DataSource dataSource) throws Exception {
|
||||||
|
SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
|
||||||
|
sessionFactoryBean.setDataSource(dataSource);
|
||||||
|
return sessionFactoryBean.getObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "sqlSessionTemplate-main")
|
||||||
|
public SqlSessionTemplate sqlSessionTemplateMain(@Qualifier("sqlSessionFactory-main") SqlSessionFactory sqlSessionFactory) {
|
||||||
|
return new SqlSessionTemplate(sqlSessionFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "sqlSessionTemplate-cache")
|
||||||
|
public SqlSessionTemplate sqlSessionTemplateCache(@Qualifier("sqlSessionFactory-cache") SqlSessionFactory sqlSessionFactory) {
|
||||||
|
return new SqlSessionTemplate(sqlSessionFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,15 +3,12 @@ package com.lion.lionwebsite.Controller;
|
|||||||
import com.lion.lionwebsite.Service.CollectService;
|
import com.lion.lionwebsite.Service.CollectService;
|
||||||
import com.lion.lionwebsite.Service.GalleryManageService;
|
import com.lion.lionwebsite.Service.GalleryManageService;
|
||||||
import com.lion.lionwebsite.Service.UserServiceImpl;
|
import com.lion.lionwebsite.Service.UserServiceImpl;
|
||||||
import com.lion.lionwebsite.Util.CustomUtil;
|
|
||||||
import com.lion.lionwebsite.Util.Response;
|
import com.lion.lionwebsite.Util.Response;
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@ -22,14 +19,11 @@ public class GalleryManageController {
|
|||||||
|
|
||||||
CollectService collectService;
|
CollectService collectService;
|
||||||
|
|
||||||
CustomUtil customUtil;
|
|
||||||
|
|
||||||
UserServiceImpl userService;
|
UserServiceImpl userService;
|
||||||
|
|
||||||
public GalleryManageController(GalleryManageService galleryManageService, CollectService collectService, CustomUtil customUtil, UserServiceImpl userService) {
|
public GalleryManageController(GalleryManageService galleryManageService, CollectService collectService, UserServiceImpl userService) {
|
||||||
this.galleryManageService = galleryManageService;
|
this.galleryManageService = galleryManageService;
|
||||||
this.collectService = collectService;
|
this.collectService = collectService;
|
||||||
this.customUtil = customUtil;
|
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,9 +33,6 @@ public class GalleryManageController {
|
|||||||
@RequestParam(value = "mode", defaultValue = "3", required = false)String mode){
|
@RequestParam(value = "mode", defaultValue = "3", required = false)String mode){
|
||||||
if(link == null || targetResolution == null)
|
if(link == null || targetResolution == null)
|
||||||
return Response._failure("参数不全");
|
return Response._failure("参数不全");
|
||||||
link = customUtil.restoreUrl(link);
|
|
||||||
if(link == null)
|
|
||||||
return Response._failure("链接错误");
|
|
||||||
return galleryManageService.createTask(link, targetResolution, AuthCode, tags, Byte.parseByte(mode));
|
return galleryManageService.createTask(link, targetResolution, AuthCode, tags, Byte.parseByte(mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,9 +49,6 @@ public class GalleryManageController {
|
|||||||
return Response._failure("参数不全");
|
return Response._failure("参数不全");
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "link" -> {
|
case "link" -> {
|
||||||
param = customUtil.restoreUrl(param);
|
|
||||||
if (param == null)
|
|
||||||
return Response._failure("链接错误");
|
|
||||||
return galleryManageService.selectTaskByLink(param);
|
return galleryManageService.selectTaskByLink(param);
|
||||||
}
|
}
|
||||||
case "gid" -> {
|
case "gid" -> {
|
||||||
@ -79,17 +67,17 @@ public class GalleryManageController {
|
|||||||
return galleryManageService.selectGalleryByDownloader(AuthCode);
|
return galleryManageService.selectGalleryByDownloader(AuthCode);
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
return Response._default();
|
return Response._failure("参数错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("")
|
@DeleteMapping("")
|
||||||
public String deleteTask(Integer gid, String AuthCode, @RequestParam(value = "mode", defaultValue = "3", required = false)String mode){
|
public String deleteTask(Integer gid, String AuthCode){
|
||||||
if(gid == null)
|
if(gid == null)
|
||||||
return Response._failure("参数不全");
|
return Response._failure("参数不全");
|
||||||
|
|
||||||
return galleryManageService.deleteGalleryByGid(gid, AuthCode, Byte.parseByte(mode));
|
return galleryManageService.deleteGalleryByGid(gid, AuthCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,26 +0,0 @@
|
|||||||
package com.lion.lionwebsite.Dao;
|
|
||||||
|
|
||||||
import com.lion.lionwebsite.Domain.CRC32Cache;
|
|
||||||
import org.apache.ibatis.annotations.Delete;
|
|
||||||
import org.apache.ibatis.annotations.Insert;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface CRC32CacheMapper {
|
|
||||||
@Insert("insert into CRC32Cache (path, lastModifyTime, crc32) values (#{path}, #{lastModifyTime}, #{crc32})")
|
|
||||||
void insertCache(CRC32Cache crc32Cache);
|
|
||||||
|
|
||||||
@Select("select * from CRC32Cache where path=#{path}")
|
|
||||||
CRC32Cache selectCache(String path);
|
|
||||||
|
|
||||||
@Select("select * from CRC32Cache where path like '%' || #{name} || '%'")
|
|
||||||
CRC32Cache selectCacheByName(String name);
|
|
||||||
|
|
||||||
// @Update("update CRC32Cache set lastModifyTime=#{lastModifyTime}, crc32=#{crc32} where path=#{path}")
|
|
||||||
// void updateCache(CRC32Cache crc32Cache);
|
|
||||||
|
|
||||||
@Delete("delete from CRC32Cache where path=#{path}")
|
|
||||||
void deleteCacheByPath(String path);
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.lion.lionwebsite.Dao;
|
package com.lion.lionwebsite.Dao.cache;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Domain.PageNameCache;
|
import com.lion.lionwebsite.Domain.PageNameCache;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
@ -17,6 +17,6 @@ public interface PageNameCacheMapper {
|
|||||||
@Delete("delete from pageName where gid=#{gid}")
|
@Delete("delete from pageName where gid=#{gid}")
|
||||||
void deletePageNameByGid(int gid);
|
void deletePageNameByGid(int gid);
|
||||||
|
|
||||||
@Delete("delete from pageName where gid=#{gid} and page=#{page}")
|
// @Delete("delete from pageName where gid=#{gid} and page=#{page}")
|
||||||
void deletePageName(PageNameCache pageNameCache);
|
// void deletePageName(PageNameCache pageNameCache);
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.lion.lionwebsite.Dao;
|
package com.lion.lionwebsite.Dao.normal;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.lion.lionwebsite.Dao;
|
package com.lion.lionwebsite.Dao.normal;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Domain.CustomConfiguration;
|
import com.lion.lionwebsite.Domain.CustomConfiguration;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.lion.lionwebsite.Dao;
|
package com.lion.lionwebsite.Dao.normal;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Domain.Gallery;
|
import com.lion.lionwebsite.Domain.Gallery;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
@ -9,8 +9,8 @@ public interface GalleryMapper {
|
|||||||
|
|
||||||
|
|
||||||
@Insert("insert into gallery" +
|
@Insert("insert into gallery" +
|
||||||
" (gid, name, link, language, pages, status, fileSize, createTime, proceeding, resolution, displayFileSize, downloader, mode)\n" +
|
" (gid, name, link, language, pages, status, fileSize, createTime, proceeding, resolution, displayFileSize, downloader, mode, thumb_link)\n" +
|
||||||
" values (#{gid}, #{name}, #{link}, #{language}, #{pages}, #{status}, #{fileSize}, #{createTime}, #{proceeding}, #{resolution}, #{displayFileSize}, #{downloader}, #{mode})")
|
" values (#{gid}, #{name}, #{link}, #{language}, #{pages}, #{status}, #{fileSize}, #{createTime}, #{proceeding}, #{resolution}, #{displayFileSize}, #{downloader}, #{mode}, #{thumb_link})")
|
||||||
void insertGallery(Gallery gallery);
|
void insertGallery(Gallery gallery);
|
||||||
|
|
||||||
@Select("select * from gallery where link=#{link}")
|
@Select("select * from gallery where link=#{link}")
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.lion.lionwebsite.Dao;
|
package com.lion.lionwebsite.Dao.normal;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Domain.ShareFile;
|
import com.lion.lionwebsite.Domain.ShareFile;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.lion.lionwebsite.Dao;
|
package com.lion.lionwebsite.Dao.normal;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Domain.SubBind;
|
import com.lion.lionwebsite.Domain.SubBind;
|
||||||
import com.lion.lionwebsite.Domain.SubUpdateRecord;
|
import com.lion.lionwebsite.Domain.SubUpdateRecord;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.lion.lionwebsite.Dao;
|
package com.lion.lionwebsite.Dao.normal;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Domain.Tag;
|
import com.lion.lionwebsite.Domain.Tag;
|
||||||
import com.lion.lionwebsite.Domain.TagMark;
|
import com.lion.lionwebsite.Domain.TagMark;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.lion.lionwebsite.Dao;
|
package com.lion.lionwebsite.Dao.normal;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Domain.User;
|
import com.lion.lionwebsite.Domain.User;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
@ -1,14 +0,0 @@
|
|||||||
package com.lion.lionwebsite.Domain;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class CRC32Cache {
|
|
||||||
String path;
|
|
||||||
long lastModifyTime;
|
|
||||||
String crc32;
|
|
||||||
}
|
|
||||||
@ -12,6 +12,11 @@ import java.util.Map;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class Gallery {
|
public class Gallery {
|
||||||
|
public static byte VIEW = 0;
|
||||||
|
public static byte SOURCE = 1;
|
||||||
|
public static byte PREVIEW = 2;
|
||||||
|
public static byte ALL = 3;
|
||||||
|
|
||||||
@JsonProperty("name")
|
@JsonProperty("name")
|
||||||
private String name; //本子名字
|
private String name; //本子名字
|
||||||
|
|
||||||
@ -66,5 +71,9 @@ public class Gallery {
|
|||||||
|
|
||||||
@JsonProperty("mode")
|
@JsonProperty("mode")
|
||||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
private byte mode; //rd 可读可下载 r可读 d可下载
|
private byte mode; //0 仅查看 1 仅下载源文件 2 仅存储预览图 3 全部
|
||||||
|
|
||||||
|
@JsonProperty("thumb_link")
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
|
private String thumb_link;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
package com.lion.lionwebsite.Domain;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class MaskDomain {
|
|
||||||
String raw;
|
|
||||||
String mask;
|
|
||||||
}
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package com.lion.lionwebsite.Filter;
|
package com.lion.lionwebsite.Filter;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Dao.UserMapper;
|
import com.lion.lionwebsite.Dao.normal.UserMapper;
|
||||||
import com.lion.lionwebsite.Util.CustomUtil;
|
import com.lion.lionwebsite.Util.CustomUtil;
|
||||||
import jakarta.servlet.*;
|
import jakarta.servlet.*;
|
||||||
import jakarta.servlet.annotation.WebFilter;
|
import jakarta.servlet.annotation.WebFilter;
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
package com.lion.lionwebsite.Interceptor;
|
package com.lion.lionwebsite.Interceptor;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Dao.UserMapper;
|
import com.lion.lionwebsite.Dao.normal.UserMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ public class TaskHandlerInterceptor implements HandlerInterceptor {
|
|||||||
@Resource
|
@Resource
|
||||||
UserMapper userMapper;
|
UserMapper userMapper;
|
||||||
|
|
||||||
String[] AuthCodes = null;
|
String[] AuthCodes;
|
||||||
|
|
||||||
public TaskHandlerInterceptor(UserMapper userMapper) {
|
public TaskHandlerInterceptor(UserMapper userMapper) {
|
||||||
this.userMapper = userMapper;
|
this.userMapper = userMapper;
|
||||||
@ -22,7 +23,7 @@ public class TaskHandlerInterceptor implements HandlerInterceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler){
|
public boolean preHandle(HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler){
|
||||||
String auth = request.getParameter("AuthCode");
|
String auth = request.getParameter("AuthCode");
|
||||||
|
|
||||||
if(auth != null)
|
if(auth != null)
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package com.lion.lionwebsite;
|
package com.lion.lionwebsite;
|
||||||
|
|
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.mybatis.spring.annotation.MapperScans;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||||
@ -9,6 +11,10 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@ServletComponentScan(value = "com.lion.lionwebsite.Filter")
|
@ServletComponentScan(value = "com.lion.lionwebsite.Filter")
|
||||||
|
@MapperScans({
|
||||||
|
@MapperScan(basePackages = "com.lion.lionwebsite.Dao.normal", sqlSessionTemplateRef = "sqlSessionTemplate-main", sqlSessionFactoryRef = "sqlSessionFactory-main"),
|
||||||
|
@MapperScan(basePackages = "com.lion.lionwebsite.Dao.cache", sqlSessionTemplateRef = "sqlSessionTemplate-cache", sqlSessionFactoryRef = "sqlSessionFactory-cache")
|
||||||
|
})
|
||||||
public class LionWebsiteApplication {
|
public class LionWebsiteApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@ -7,14 +7,5 @@ public class DeleteGalleryMessage extends AbstractMessage{
|
|||||||
{
|
{
|
||||||
messageType = DELETE_GALLERY_MESSAGE;
|
messageType = DELETE_GALLERY_MESSAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final byte DELETE_ALL = 3;
|
|
||||||
public static final byte DELETE_PREVIEW = 2;
|
|
||||||
public static final byte DELETE_SOURCE = 1;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
byte deleteType;
|
|
||||||
|
|
||||||
String galleryName;
|
String galleryName;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package com.lion.lionwebsite.Service;
|
package com.lion.lionwebsite.Service;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Dao.CollectMapper;
|
import com.lion.lionwebsite.Dao.normal.CollectMapper;
|
||||||
import com.lion.lionwebsite.Util.Response;
|
import com.lion.lionwebsite.Util.Response;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@ -2,7 +2,8 @@ package com.lion.lionwebsite.Service;
|
|||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import com.lion.lionwebsite.Dao.*;
|
import com.lion.lionwebsite.Dao.cache.PageNameCacheMapper;
|
||||||
|
import com.lion.lionwebsite.Dao.normal.*;
|
||||||
import com.lion.lionwebsite.Domain.*;
|
import com.lion.lionwebsite.Domain.*;
|
||||||
import com.lion.lionwebsite.Exception.ResolutionNotMatchException;
|
import com.lion.lionwebsite.Exception.ResolutionNotMatchException;
|
||||||
import com.lion.lionwebsite.Error.ErrorCode;
|
import com.lion.lionwebsite.Error.ErrorCode;
|
||||||
@ -58,7 +59,7 @@ public class GalleryManageService {
|
|||||||
PushService pushService;
|
PushService pushService;
|
||||||
|
|
||||||
public GalleryManageService(GalleryMapper galleryMapper, CollectMapper collectMapper, CustomConfigurationMapper configurationMapper, UserMapper userMapper, ShareFileMapper shareFileMapper,
|
public GalleryManageService(GalleryMapper galleryMapper, CollectMapper collectMapper, CustomConfigurationMapper configurationMapper, UserMapper userMapper, ShareFileMapper shareFileMapper,
|
||||||
TagMapper tagMapper, PageNameCacheMapper pageNameCacheMapper, RemoteService remoteService, PushService pushService){
|
TagMapper tagMapper, PageNameCacheMapper pageNameCacheMapper, RemoteService remoteService, PushService pushService) {
|
||||||
this.galleryMapper = galleryMapper;
|
this.galleryMapper = galleryMapper;
|
||||||
this.collectMapper = collectMapper;
|
this.collectMapper = collectMapper;
|
||||||
this.configurationMapper = configurationMapper;
|
this.configurationMapper = configurationMapper;
|
||||||
@ -72,17 +73,17 @@ public class GalleryManageService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建任务
|
* 创建任务
|
||||||
* @param link 任务链接
|
* @param link 任务链接
|
||||||
* @param targetResolution 目标分辨率
|
* @param targetResolution 目标分辨率
|
||||||
* @param AuthCode 授权码(用于记录是谁下载的)
|
* @param AuthCode 授权码(用于记录是谁下载的)
|
||||||
* @return 提交结果
|
* @return 提交结果
|
||||||
*/
|
*/
|
||||||
public String createTask(String link, String targetResolution, String AuthCode, List<Integer> tidS, byte mode){
|
public String createTask(String link, String targetResolution, String AuthCode, List<Integer> tidS, byte mode) {
|
||||||
Response response = Response.generateResponse();
|
Response response = Response.generateResponse();
|
||||||
User user = userMapper.selectUserByAuthCode(AuthCode);
|
User user = userMapper.selectUserByAuthCode(AuthCode);
|
||||||
// return Response._failure("调试中,请勿提交任务");
|
// return Response._failure("调试中,请勿提交任务");
|
||||||
|
|
||||||
if(remoteService.isDead()) {
|
if (remoteService.isDead()) {
|
||||||
response.failure("节点挂了,找狮子处理");
|
response.failure("节点挂了,找狮子处理");
|
||||||
pushService.taskCreateReport(user.getUsername(), link, response);
|
pushService.taskCreateReport(user.getUsername(), link, response);
|
||||||
return response.toJSONString();
|
return response.toJSONString();
|
||||||
@ -90,7 +91,7 @@ public class GalleryManageService {
|
|||||||
int gid;
|
int gid;
|
||||||
try {
|
try {
|
||||||
gid = Integer.parseInt(link.split("/")[4]);
|
gid = Integer.parseInt(link.split("/")[4]);
|
||||||
}catch (NumberFormatException e){
|
} catch (NumberFormatException e) {
|
||||||
response.failure("链接错误");
|
response.failure("链接错误");
|
||||||
pushService.taskCreateReport(user.getUsername(), link, response);
|
pushService.taskCreateReport(user.getUsername(), link, response);
|
||||||
return response.toJSONString();
|
return response.toJSONString();
|
||||||
@ -98,7 +99,7 @@ public class GalleryManageService {
|
|||||||
Gallery gallery;
|
Gallery gallery;
|
||||||
|
|
||||||
//判断数据库中是否有这个任务,有则返回状态
|
//判断数据库中是否有这个任务,有则返回状态
|
||||||
if((gallery = galleryMapper.selectGalleryByGid(gid)) != null){
|
if ((gallery = galleryMapper.selectGalleryByGid(gid)) != null) {
|
||||||
response.failure("任务队列已有此任务,任务状态: " + gallery.getStatus() + " 请点击查找任务");
|
response.failure("任务队列已有此任务,任务状态: " + gallery.getStatus() + " 请点击查找任务");
|
||||||
pushService.taskCreateReport(user.getUsername(), link, response);
|
pushService.taskCreateReport(user.getUsername(), link, response);
|
||||||
return response.toJSONString();
|
return response.toJSONString();
|
||||||
@ -107,26 +108,26 @@ public class GalleryManageService {
|
|||||||
//尝试下载本子,返回结果
|
//尝试下载本子,返回结果
|
||||||
try {
|
try {
|
||||||
gallery = GalleryUtil.parse(link, true, targetResolution);
|
gallery = GalleryUtil.parse(link, true, targetResolution);
|
||||||
if(gallery == null){
|
if (gallery == null) {
|
||||||
log.error("创建任务: {},解析失败", link);
|
log.error("创建任务: {},解析失败", link);
|
||||||
response.failure("任务解析失败,未知原因,请检查链接是否正常");
|
response.failure("任务解析失败,未知原因,请检查链接是否正常");
|
||||||
pushService.taskCreateReport(user.getUsername(), link, response);
|
pushService.taskCreateReport(user.getUsername(), link, response);
|
||||||
return response.toJSONString();
|
return response.toJSONString();
|
||||||
}else{
|
} else {
|
||||||
log.info("创建任务: {} 目标分辨率:{}", link, targetResolution);
|
log.info("创建任务: {} 目标分辨率:{}", link, targetResolution);
|
||||||
if(remoteService.addGalleryToQueue(gallery, mode) != 0){
|
if (remoteService.addGalleryToQueue(gallery, mode) != 0) {
|
||||||
log.error("传送任务{}失败, 未知原因", gallery.getName());
|
log.error("传送任务{}失败, 未知原因", gallery.getName());
|
||||||
response.failure("任务传送失败,未知原因");
|
response.failure("任务传送失败,未知原因");
|
||||||
pushService.taskCreateReport(user.getUsername(), link, response);
|
pushService.taskCreateReport(user.getUsername(), link, response);
|
||||||
return response.toJSONString();
|
return response.toJSONString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (ResolutionNotMatchException e){
|
} catch (ResolutionNotMatchException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
response.failure("提交失败,分辨率不存在");
|
response.failure("提交失败,分辨率不存在");
|
||||||
pushService.taskCreateReport(user.getUsername(), link, response);
|
pushService.taskCreateReport(user.getUsername(), link, response);
|
||||||
return response.toJSONString();
|
return response.toJSONString();
|
||||||
}catch (IOException e){
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
response.failure("IO错误,可能是网络波动");
|
response.failure("IO错误,可能是网络波动");
|
||||||
pushService.taskCreateReport(user.getUsername(), link, response);
|
pushService.taskCreateReport(user.getUsername(), link, response);
|
||||||
@ -134,7 +135,7 @@ public class GalleryManageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//处理下载结果,将任务插入数据库并且更新每周用量
|
//处理下载结果,将任务插入数据库并且更新每周用量
|
||||||
if(gallery.getStatus().equals("已提交")) {
|
if (gallery.getStatus().equals("已提交")) {
|
||||||
response.success(gallery.toString());
|
response.success(gallery.toString());
|
||||||
gallery.setDownloader(user.getId());
|
gallery.setDownloader(user.getId());
|
||||||
gallery.setMode(mode);
|
gallery.setMode(mode);
|
||||||
@ -143,12 +144,11 @@ public class GalleryManageService {
|
|||||||
long usedAmount = Long.parseLong(configurationMapper.selectConfiguration(CustomConfiguration.WEEK_USED_AMOUNT).getValue());
|
long usedAmount = Long.parseLong(configurationMapper.selectConfiguration(CustomConfiguration.WEEK_USED_AMOUNT).getValue());
|
||||||
usedAmount += gallery.getFileSize();
|
usedAmount += gallery.getFileSize();
|
||||||
configurationMapper.updateConfiguration(CustomConfiguration.WEEK_USED_AMOUNT, String.valueOf(usedAmount));
|
configurationMapper.updateConfiguration(CustomConfiguration.WEEK_USED_AMOUNT, String.valueOf(usedAmount));
|
||||||
if(tidS != null)
|
if (tidS != null)
|
||||||
for (Integer tid : tidS)
|
for (Integer tid : tidS)
|
||||||
if(tagMapper.selectTagExistById(tid) > 0)
|
if (tagMapper.selectTagExistById(tid) > 0)
|
||||||
tagMapper.markTag(gallery.getGid(), tid);
|
tagMapper.markTag(gallery.getGid(), tid);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
response.failure("提交失败,未知原因");
|
response.failure("提交失败,未知原因");
|
||||||
galleryMapper.deleteGalleryByGid(gallery.getGid());
|
galleryMapper.deleteGalleryByGid(gallery.getGid());
|
||||||
}
|
}
|
||||||
@ -159,15 +159,15 @@ public class GalleryManageService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据链接查询本子
|
* 根据链接查询本子
|
||||||
* @param link 链接
|
* @param link 链接
|
||||||
* @return 查询结果
|
* @return 查询结果
|
||||||
*/
|
*/
|
||||||
public String selectTaskByLink(String link) {
|
public String selectTaskByLink(String link) {
|
||||||
Response response = Response.generateResponse();
|
Response response = Response.generateResponse();
|
||||||
Integer gid = parseGid(link);
|
Integer gid = parseGid(link);
|
||||||
Gallery gallery;
|
Gallery gallery;
|
||||||
if(gid != null)
|
if (gid != null)
|
||||||
gallery = galleryMapper.selectGalleryByGid(gid);
|
gallery = galleryMapper.selectGalleryByGid(gid);
|
||||||
else {
|
else {
|
||||||
response.failure("链接错误");
|
response.failure("链接错误");
|
||||||
return response.toJSONString();
|
return response.toJSONString();
|
||||||
@ -175,15 +175,15 @@ public class GalleryManageService {
|
|||||||
log.info("查询{}", link);
|
log.info("查询{}", link);
|
||||||
|
|
||||||
//判断数据库中是否有这个任务,如果有则返回,如果没有则直接查询
|
//判断数据库中是否有这个任务,如果有则返回,如果没有则直接查询
|
||||||
if(gallery == null)
|
if (gallery == null)
|
||||||
try{
|
try {
|
||||||
gallery = GalleryUtil.parse(link, false, null);
|
gallery = GalleryUtil.parse(link, false, null);
|
||||||
if(gallery != null)
|
if (gallery != null)
|
||||||
response.success(new ObjectMapper().valueToTree(gallery).toString());
|
response.success(new ObjectMapper().valueToTree(gallery).toString());
|
||||||
else
|
else
|
||||||
response.failure("查询失败");
|
response.failure("查询失败");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.info(e.getMessage());
|
||||||
response.failure("查询失败");
|
response.failure("查询失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,14 +195,15 @@ public class GalleryManageService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过gid查询本子
|
* 通过gid查询本子
|
||||||
|
*
|
||||||
* @param gid gid
|
* @param gid gid
|
||||||
* @return 查询结果
|
* @return 查询结果
|
||||||
*/
|
*/
|
||||||
public String selectTaskByGid(int gid){
|
public String selectTaskByGid(int gid) {
|
||||||
Response response = Response.generateResponse();
|
Response response = Response.generateResponse();
|
||||||
Gallery gallery = galleryMapper.selectGalleryByGid(gid);
|
Gallery gallery = galleryMapper.selectGalleryByGid(gid);
|
||||||
|
|
||||||
if(gallery == null)
|
if (gallery == null)
|
||||||
response.failure("未找到该本子,请使用链接");
|
response.failure("未找到该本子,请使用链接");
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -213,13 +214,14 @@ public class GalleryManageService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有本子
|
* 查询所有本子
|
||||||
|
*
|
||||||
* @return 查询结果
|
* @return 查询结果
|
||||||
*/
|
*/
|
||||||
public String selectAllGallery(int userId) {
|
public String selectAllGallery(int userId) {
|
||||||
Response response = Response.generateResponse();
|
Response response = Response.generateResponse();
|
||||||
Gallery[] galleries = galleryMapper.selectAllGallery();
|
Gallery[] galleries = galleryMapper.selectAllGallery();
|
||||||
|
|
||||||
if(galleries == null){
|
if (galleries == null) {
|
||||||
response.failure("没有找到本子");
|
response.failure("没有找到本子");
|
||||||
return response.toJSONString();
|
return response.toJSONString();
|
||||||
}
|
}
|
||||||
@ -227,16 +229,16 @@ public class GalleryManageService {
|
|||||||
ArrayList<Integer> galleryIds = collectMapper.selectGidByCollector(userId);
|
ArrayList<Integer> galleryIds = collectMapper.selectGidByCollector(userId);
|
||||||
Iterator<Integer> idIterator;
|
Iterator<Integer> idIterator;
|
||||||
|
|
||||||
if(!galleryIds.isEmpty()) //如果该用户收藏了本子
|
if (!galleryIds.isEmpty()) //如果该用户收藏了本子
|
||||||
galleryLoop: for (Gallery gallery : galleries) { //遍历本子
|
galleryLoop:for (Gallery gallery : galleries) { //遍历本子
|
||||||
idIterator = galleryIds.iterator();
|
idIterator = galleryIds.iterator();
|
||||||
while (idIterator.hasNext()){ //遍历收藏的gid
|
while (idIterator.hasNext()) { //遍历收藏的gid
|
||||||
Integer id = idIterator.next();
|
Integer id = idIterator.next();
|
||||||
if(id.equals(gallery.getGid())){ //如果找到对应的gid,修改对应本子的属性,删除当前gid,判断是否需要跳出或者结束循环
|
if (id.equals(gallery.getGid())) { //如果找到对应的gid,修改对应本子的属性,删除当前gid,判断是否需要跳出或者结束循环
|
||||||
gallery.setCollect(true);
|
gallery.setCollect(true);
|
||||||
idIterator.remove();
|
idIterator.remove();
|
||||||
|
|
||||||
if(galleryIds.isEmpty())
|
if (galleryIds.isEmpty())
|
||||||
break galleryLoop;
|
break galleryLoop;
|
||||||
else
|
else
|
||||||
continue galleryLoop;
|
continue galleryLoop;
|
||||||
@ -255,7 +257,7 @@ public class GalleryManageService {
|
|||||||
|
|
||||||
ArrayList<Integer> temp;
|
ArrayList<Integer> temp;
|
||||||
for (Gallery gallery : galleries) {
|
for (Gallery gallery : galleries) {
|
||||||
if((temp = tagsMap.get(gallery.getGid())) != null) {
|
if ((temp = tagsMap.get(gallery.getGid())) != null) {
|
||||||
gallery.setTags(new ArrayList<>());
|
gallery.setTags(new ArrayList<>());
|
||||||
gallery.getTags().addAll(temp);
|
gallery.getTags().addAll(temp);
|
||||||
}
|
}
|
||||||
@ -267,13 +269,14 @@ public class GalleryManageService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询未完成的本子
|
* 查询未完成的本子
|
||||||
|
*
|
||||||
* @return 查询结果
|
* @return 查询结果
|
||||||
*/
|
*/
|
||||||
public String selectUnDoneGallery() {
|
public String selectUnDoneGallery() {
|
||||||
Response response = Response.generateResponse();
|
Response response = Response.generateResponse();
|
||||||
Gallery[] galleries = galleryMapper.selectUnDoneGalleries();
|
Gallery[] galleries = galleryMapper.selectUnDoneGalleries();
|
||||||
|
|
||||||
if(galleries.length > 0)
|
if (galleries.length > 0)
|
||||||
response.success(new ObjectMapper().valueToTree(galleries).toString());
|
response.success(new ObjectMapper().valueToTree(galleries).toString());
|
||||||
else
|
else
|
||||||
response.failure();
|
response.failure();
|
||||||
@ -283,6 +286,7 @@ public class GalleryManageService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过本子名查询本子
|
* 通过本子名查询本子
|
||||||
|
*
|
||||||
* @param name 名字
|
* @param name 名字
|
||||||
* @return 查询结果
|
* @return 查询结果
|
||||||
*/
|
*/
|
||||||
@ -290,7 +294,7 @@ public class GalleryManageService {
|
|||||||
Response response = Response.generateResponse();
|
Response response = Response.generateResponse();
|
||||||
Gallery gallery = galleryMapper.selectGalleryByName("%" + name + "%");
|
Gallery gallery = galleryMapper.selectGalleryByName("%" + name + "%");
|
||||||
|
|
||||||
if(gallery != null)
|
if (gallery != null)
|
||||||
response.success(new ObjectMapper().valueToTree(gallery).toString());
|
response.success(new ObjectMapper().valueToTree(gallery).toString());
|
||||||
else
|
else
|
||||||
response.failure("没有找到该名字的本子");
|
response.failure("没有找到该名字的本子");
|
||||||
@ -300,14 +304,15 @@ public class GalleryManageService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户下载的本子
|
* 查询用户下载的本子
|
||||||
* @param AuthCode 授权码(用于查询用户名)
|
*
|
||||||
* @return 查询结果
|
* @param AuthCode 授权码(用于查询用户名)
|
||||||
|
* @return 查询结果
|
||||||
*/
|
*/
|
||||||
public String selectGalleryByDownloader(String AuthCode){
|
public String selectGalleryByDownloader(String AuthCode) {
|
||||||
Response response = Response.generateResponse();
|
Response response = Response.generateResponse();
|
||||||
|
|
||||||
Gallery[] galleries = galleryMapper.selectGalleryByDownloader(userMapper.selectUserByAuthCode(AuthCode).getId());
|
Gallery[] galleries = galleryMapper.selectGalleryByDownloader(userMapper.selectUserByAuthCode(AuthCode).getId());
|
||||||
if(galleries.length > 0)
|
if (galleries.length > 0)
|
||||||
response.success(new ObjectMapper().valueToTree(galleries).toString());
|
response.success(new ObjectMapper().valueToTree(galleries).toString());
|
||||||
else
|
else
|
||||||
response.failure("您未下载本子");
|
response.failure("您未下载本子");
|
||||||
@ -365,67 +370,45 @@ public class GalleryManageService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除本子以及对应的文件(如果存在的话)
|
* 删除本子以及对应的文件(如果存在的话)
|
||||||
|
*
|
||||||
* @param gid gid
|
* @param gid gid
|
||||||
* @return 删除结果
|
* @return 删除结果
|
||||||
*/
|
*/
|
||||||
public String deleteGalleryByGid(Integer gid, String AuthCode, byte mode) {
|
public String deleteGalleryByGid(Integer gid, String AuthCode) {
|
||||||
Response response = Response.generateResponse();
|
Response response = Response.generateResponse();
|
||||||
String deleteType;
|
|
||||||
|
|
||||||
Gallery gallery = galleryMapper.selectGalleryByGid(gid);
|
Gallery gallery = galleryMapper.selectGalleryByGid(gid);
|
||||||
User user = userMapper.selectUserByAuthCode(AuthCode);
|
User user = userMapper.selectUserByAuthCode(AuthCode);
|
||||||
if(gallery == null){
|
if (gallery == null) {
|
||||||
response.failure("删除失败,该本子不存在");
|
response.failure("删除失败,该本子不存在");
|
||||||
return response.toJSONString();
|
return response.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Integer> collector = collectMapper.selectCollectorByGid(gallery.getGid());
|
ArrayList<Integer> collector = collectMapper.selectCollectorByGid(gallery.getGid());
|
||||||
if(!(collector.isEmpty() || collector.size() == 1 && collector.get(0).equals(user.getId()) //判断收藏
|
if (!(collector.isEmpty() || collector.size() == 1 && collector.get(0).equals(user.getId()) //判断收藏
|
||||||
&& gallery.getDownloader() == user.getId())) //判断下载
|
&& gallery.getDownloader() == user.getId())) //判断下载
|
||||||
response.failure("删除失败,该本子已被别人收藏或你不是下载人");
|
response.failure("删除失败,该本子已被别人收藏或你不是下载人");
|
||||||
|
else {
|
||||||
|
log.info("删除本子{}", gallery.getName());
|
||||||
|
galleryMapper.deleteGalleryByGid(gallery.getGid()); //删除本子记录
|
||||||
|
ArrayList<Integer> tidS = tagMapper.selectTagByGid(gallery.getGid());
|
||||||
|
for (Integer tid : tidS)
|
||||||
|
tagMapper.decrTagUsage(tid);
|
||||||
|
|
||||||
else{
|
tagMapper.disMarkTagByGid(gallery.getGid()); //删除本子标记
|
||||||
if((gallery.getMode() & mode) == 0) { //不能删除对应的,因为对应的没有
|
gid2name_cache.remove(gallery.getGid()); //删除本子缓存
|
||||||
if (mode == 1)
|
page2pageNameCache.remove(gallery.getName()); //移除页数缓存
|
||||||
response.failure("无法删除该本子的源文件,不存在");
|
pageNameCacheMapper.deletePageNameByGid(gid);
|
||||||
else if (mode == 2)
|
|
||||||
response.failure("无法删除该本子的预览图,不存在");
|
|
||||||
} else {
|
|
||||||
log.info("删除本子{}, mode:{}, delete_mode:{}", gallery.getName(), gallery.getMode(), mode);
|
|
||||||
gallery.setMode((byte) (gallery.getMode() ^ mode));
|
|
||||||
if(gallery.getMode() == 0) { //删整个本子
|
|
||||||
galleryMapper.deleteGalleryByGid(gallery.getGid()); //删除本子记录
|
|
||||||
ArrayList<Integer> tidS = tagMapper.selectTagByGid(gallery.getGid());
|
|
||||||
for (Integer tid : tidS)
|
|
||||||
tagMapper.decrTagUsage(tid);
|
|
||||||
|
|
||||||
tagMapper.disMarkTagByGid(gallery.getGid()); //删除本子标记
|
if (new File(TargetPath + "/" + gallery.getName()).isDirectory()) //删除本地缓存
|
||||||
gid2name_cache.remove(gallery.getGid()); //删除本子缓存
|
FileUtil.del(TargetPath + "/" + gallery.getName());
|
||||||
page2pageNameCache.remove(gallery.getName()); //移除页数缓存
|
|
||||||
pageNameCacheMapper.deletePageNameByGid(gid);
|
|
||||||
|
|
||||||
if(new File(TargetPath + "/" + gallery.getName()).isDirectory()) //删除本地缓存
|
|
||||||
FileUtil.del(TargetPath + "/" + gallery.getName());
|
|
||||||
deleteType = "全部";
|
|
||||||
}else{
|
|
||||||
if(mode == 2 && new File(TargetPath + "/" + gallery.getName()).isDirectory()) { //删除预览缓存
|
|
||||||
FileUtil.del(TargetPath + "/" + gallery.getName());
|
|
||||||
gid2name_cache.remove(gallery.getGid()); //删除本子缓存
|
|
||||||
page2pageNameCache.remove(gallery.getName()); //移除页数缓存
|
|
||||||
}
|
|
||||||
|
|
||||||
galleryMapper.updateGallery(gallery);
|
|
||||||
deleteType = (mode == 1? "源文件": "预览图"); //用于提示
|
|
||||||
}
|
|
||||||
switch (remoteService.deleteGallery(gallery, mode)){
|
|
||||||
case ErrorCode.IO_ERROR -> response.failure("本子:" + gallery.getName() + deleteType + "删除失败,IO错误");
|
|
||||||
case ErrorCode.FILE_NOT_FOUND -> response.failure("本子:" + gallery.getName() + deleteType + "删除失败,文件不存在");
|
|
||||||
case 0 -> response.success();
|
|
||||||
}
|
|
||||||
if(response.get("result").equals("failure"))
|
|
||||||
log.info(response.getResult());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
switch (remoteService.deleteGallery(gallery)) {
|
||||||
|
case ErrorCode.IO_ERROR -> response.failure("本子:" + gallery.getName() + "删除失败,IO错误");
|
||||||
|
case ErrorCode.FILE_NOT_FOUND -> response.failure("本子:" + gallery.getName() + "删除失败,文件不存在");
|
||||||
|
case 0 -> response.success();
|
||||||
|
}
|
||||||
|
if (response.get("result").equals("failure"))
|
||||||
|
log.info(response.getResult());
|
||||||
return response.toJSONString();
|
return response.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package com.lion.lionwebsite.Service;
|
package com.lion.lionwebsite.Service;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Dao.CustomConfigurationMapper;
|
import com.lion.lionwebsite.Dao.normal.CustomConfigurationMapper;
|
||||||
import com.lion.lionwebsite.Dao.GalleryMapper;
|
import com.lion.lionwebsite.Dao.normal.GalleryMapper;
|
||||||
import com.lion.lionwebsite.Dao.ShareFileMapper;
|
import com.lion.lionwebsite.Dao.normal.ShareFileMapper;
|
||||||
import com.lion.lionwebsite.Domain.CustomConfiguration;
|
import com.lion.lionwebsite.Domain.CustomConfiguration;
|
||||||
import com.lion.lionwebsite.Domain.ShareFile;
|
import com.lion.lionwebsite.Domain.ShareFile;
|
||||||
import com.lion.lionwebsite.Util.CustomUtil;
|
import com.lion.lionwebsite.Util.CustomUtil;
|
||||||
@ -29,8 +29,6 @@ import static java.nio.file.FileVisitResult.CONTINUE;
|
|||||||
@Service
|
@Service
|
||||||
@Data
|
@Data
|
||||||
public class LocalServiceImpl{
|
public class LocalServiceImpl{
|
||||||
String fires = "https://api.dler.io/sub?target=clash&new_name=true&url=https%3A%2F%2Ffast.losadhwselfff2332dasd.xyz%2Flink%2Fz0pfwyTvC5naXkbb%3Fclash%3D1&insert=false&config=https%3A%2F%2Fraw.githubusercontent.com%2FACL4SSR%2FACL4SSR%2Fmaster%2FClash%2Fconfig%2FACL4SSR_Online.ini";
|
|
||||||
|
|
||||||
String DouNaiClash = "https://aaaa.gay/link/X7zEqkIx5gtIGugO?client=clashmeta";
|
String DouNaiClash = "https://aaaa.gay/link/X7zEqkIx5gtIGugO?client=clashmeta";
|
||||||
|
|
||||||
String DouNaiV2ray = "https://aaaa.gay/link/X7zEqkIx5gtIGugO?client=v2";
|
String DouNaiV2ray = "https://aaaa.gay/link/X7zEqkIx5gtIGugO?client=v2";
|
||||||
@ -81,8 +79,6 @@ public class LocalServiceImpl{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
File mixin = new File("sub/sub.txt");
|
|
||||||
File firesFile = new File("sub/fires.txt");
|
|
||||||
File DouNaiClashFile = new File("sub/DouNaiClash.txt");
|
File DouNaiClashFile = new File("sub/DouNaiClash.txt");
|
||||||
File DouNaiV2rayFile = new File("sub/DouNaiV2ray.txt");
|
File DouNaiV2rayFile = new File("sub/DouNaiV2ray.txt");
|
||||||
File directory = new File("sub");
|
File directory = new File("sub");
|
||||||
@ -90,31 +86,17 @@ public class LocalServiceImpl{
|
|||||||
if(!directory.isDirectory())
|
if(!directory.isDirectory())
|
||||||
Files.createDirectory(Paths.get("sub"));
|
Files.createDirectory(Paths.get("sub"));
|
||||||
|
|
||||||
List<String> fires_profile = null;
|
List<String> DouNaiClash_profile;
|
||||||
List<String> DouNaiClash_profile = null;
|
|
||||||
OutputStream outputStream;
|
|
||||||
|
|
||||||
//下载薯条订阅
|
|
||||||
try(FileWriter writer = new FileWriter(firesFile)) {
|
|
||||||
fires_profile = Get(fires);
|
|
||||||
for (String i : fires_profile)
|
|
||||||
writer.write(i + "\n");
|
|
||||||
|
|
||||||
System.out.println("load fires complete");
|
|
||||||
}catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
System.out.println("load fires failure");
|
|
||||||
}
|
|
||||||
|
|
||||||
//下载豆奶v2ray订阅
|
//下载豆奶v2ray订阅
|
||||||
try(FileWriter writer = new FileWriter(DouNaiV2rayFile)) {
|
try(FileWriter writer = new FileWriter(DouNaiV2rayFile)) {
|
||||||
String DouNaiV2rayRaw = Get(DouNaiV2ray).get(0);
|
String DouNaiV2rayRaw = Get(DouNaiV2ray).getFirst();
|
||||||
String[] v2rayPlain = new String(Base64.getDecoder().decode(DouNaiV2rayRaw)).split("\n");
|
String[] v2rayPlain = new String(Base64.getDecoder().decode(DouNaiV2rayRaw)).split("\n");
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
//过滤高倍率节点
|
//过滤高倍率节点
|
||||||
for(String node: v2rayPlain){
|
for(String node: v2rayPlain){
|
||||||
String name = URLDecoder.decode(node.split("#")[1], StandardCharsets.UTF_8);
|
String name = URLDecoder.decode(node.split("#")[1], StandardCharsets.UTF_8);
|
||||||
if(name.startsWith("①") && name.contains("流量")){
|
if(name.startsWith("⛅") && name.contains("流量")){
|
||||||
float ratio = Float.parseFloat(name.substring(name.indexOf("(") + 1, name.indexOf(")")).replace("倍流量", ""));
|
float ratio = Float.parseFloat(name.substring(name.indexOf("(") + 1, name.indexOf(")")).replace("倍流量", ""));
|
||||||
if(ratio <= 1)
|
if(ratio <= 1)
|
||||||
stringBuilder.append(node).append("\n");
|
stringBuilder.append(node).append("\n");
|
||||||
@ -163,44 +145,6 @@ public class LocalServiceImpl{
|
|||||||
System.out.println("load DouNai clash failure");
|
System.out.println("load DouNai clash failure");
|
||||||
}
|
}
|
||||||
|
|
||||||
//处理合并
|
|
||||||
assert DouNaiClash_profile != null;
|
|
||||||
int side_start = DouNaiClash_profile.indexOf("proxies:");
|
|
||||||
int side_end = DouNaiClash_profile.indexOf("proxy-groups:");
|
|
||||||
|
|
||||||
List<String> side_proxy = new ArrayList<>();
|
|
||||||
List<String> side_name = new ArrayList<>();
|
|
||||||
for (int i = side_start + 1; i < side_end; i++) {
|
|
||||||
side_proxy.add(DouNaiClash_profile.get(i));
|
|
||||||
if (DouNaiClash_profile.get(i).contains("name"))
|
|
||||||
side_name.add(DouNaiClash_profile.get(i).replace("name:", ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> final_profile = new ArrayList<>();
|
|
||||||
assert fires_profile != null;
|
|
||||||
for (String i : fires_profile) {
|
|
||||||
if (i.equals("proxy-groups:"))
|
|
||||||
final_profile.addAll(side_proxy);
|
|
||||||
|
|
||||||
final_profile.add(i);
|
|
||||||
if (i.equals("proxy-groups:")) {
|
|
||||||
final_profile.add(" -");
|
|
||||||
final_profile.add(" name: e站流量");
|
|
||||||
final_profile.add(" type: select");
|
|
||||||
final_profile.add(" proxies:");
|
|
||||||
for (String x : side_name)
|
|
||||||
final_profile.add(" " + x);
|
|
||||||
|
|
||||||
}
|
|
||||||
if (i.equals("rules:"))
|
|
||||||
final_profile.add(" - DOMAIN-KEYWORD,hentai,e站流量");
|
|
||||||
}
|
|
||||||
|
|
||||||
outputStream = Files.newOutputStream(mixin.toPath());
|
|
||||||
for(String i: final_profile)
|
|
||||||
outputStream.write((i + "\n").getBytes(StandardCharsets.UTF_8));
|
|
||||||
outputStream.close();
|
|
||||||
|
|
||||||
configurationMapper.updateConfiguration(CustomConfiguration.LAST_UPDATE_SUB_TIME, dateTimeFormatter.format(LocalDateTime.now()));
|
configurationMapper.updateConfiguration(CustomConfiguration.LAST_UPDATE_SUB_TIME, dateTimeFormatter.format(LocalDateTime.now()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,9 +3,9 @@ package com.lion.lionwebsite.Service;
|
|||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import com.lion.lionwebsite.Dao.CustomConfigurationMapper;
|
import com.lion.lionwebsite.Dao.normal.CustomConfigurationMapper;
|
||||||
import com.lion.lionwebsite.Dao.ShareFileMapper;
|
import com.lion.lionwebsite.Dao.normal.ShareFileMapper;
|
||||||
import com.lion.lionwebsite.Dao.UserMapper;
|
import com.lion.lionwebsite.Dao.normal.UserMapper;
|
||||||
import com.lion.lionwebsite.Domain.CustomConfiguration;
|
import com.lion.lionwebsite.Domain.CustomConfiguration;
|
||||||
import com.lion.lionwebsite.Domain.ShareFile;
|
import com.lion.lionwebsite.Domain.ShareFile;
|
||||||
import com.lion.lionwebsite.Interceptor.TaskHandlerInterceptor;
|
import com.lion.lionwebsite.Interceptor.TaskHandlerInterceptor;
|
||||||
@ -22,7 +22,6 @@ import org.apache.commons.compress.archivers.ArchiveEntry;
|
|||||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||||
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
package com.lion.lionwebsite.Service;
|
package com.lion.lionwebsite.Service;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Dao.CustomConfigurationMapper;
|
import com.lion.lionwebsite.Dao.normal.CustomConfigurationMapper;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Dao.ShareFileMapper;
|
import com.lion.lionwebsite.Dao.normal.ShareFileMapper;
|
||||||
import com.lion.lionwebsite.Dao.UserMapper;
|
import com.lion.lionwebsite.Dao.normal.UserMapper;
|
||||||
import com.lion.lionwebsite.Domain.CustomConfiguration;
|
import com.lion.lionwebsite.Domain.CustomConfiguration;
|
||||||
import com.lion.lionwebsite.Domain.ShareFile;
|
import com.lion.lionwebsite.Domain.ShareFile;
|
||||||
import com.lion.lionwebsite.Domain.User;
|
import com.lion.lionwebsite.Domain.User;
|
||||||
@ -23,6 +23,8 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@ -129,7 +131,7 @@ public class PublicServiceImpl {
|
|||||||
ServletOutputStream outputStream = response.getOutputStream();
|
ServletOutputStream outputStream = response.getOutputStream();
|
||||||
outputStream.write(imageBytes);
|
outputStream.write(imageBytes);
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
}catch (IOException e){
|
}catch (IOException | URISyntaxException e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
try {
|
try {
|
||||||
response.sendError(503);
|
response.sendError(503);
|
||||||
@ -139,8 +141,8 @@ public class PublicServiceImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] getImageBytesFromUrl(String imageUrl) throws IOException {
|
public static byte[] getImageBytesFromUrl(String imageUrl) throws IOException, URISyntaxException {
|
||||||
URL url = new URL(imageUrl);
|
URL url = new URI(imageUrl).toURL();
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|||||||
@ -109,6 +109,8 @@ public class QueryService {
|
|||||||
else{ // transfer image and save it as cache
|
else{ // transfer image and save it as cache
|
||||||
log.info("miss cache:{}", imageName);
|
log.info("miss cache:{}", imageName);
|
||||||
try {
|
try {
|
||||||
|
if(!path.startsWith("/t"))
|
||||||
|
path = "/t" + path;
|
||||||
requests("https://s.exhentai.org" + path, true, response, new FileOutputStream(image));
|
requests("https://s.exhentai.org" + path, true, response, new FileOutputStream(image));
|
||||||
}catch (IOException e){
|
}catch (IOException e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -119,8 +121,8 @@ public class QueryService {
|
|||||||
public String requests(String url, boolean isDirect, HttpServletResponse response, OutputStream local) throws IOException {
|
public String requests(String url, boolean isDirect, HttpServletResponse response, OutputStream local) throws IOException {
|
||||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
CloseableHttpResponse httpResponse;
|
CloseableHttpResponse httpResponse;
|
||||||
HashMap<String, String> headers = new HashMap<>();
|
|
||||||
|
|
||||||
|
HashMap<String, String> headers = new HashMap<>();
|
||||||
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36");
|
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36");
|
||||||
headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
|
headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
|
||||||
headers.put("Upgrade-Insecure-Requests", "1");
|
headers.put("Upgrade-Insecure-Requests", "1");
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package com.lion.lionwebsite.Service;
|
package com.lion.lionwebsite.Service;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Dao.GalleryMapper;
|
import com.lion.lionwebsite.Dao.normal.GalleryMapper;
|
||||||
import com.lion.lionwebsite.Domain.Gallery;
|
import com.lion.lionwebsite.Domain.Gallery;
|
||||||
import com.lion.lionwebsite.Domain.GalleryTask;
|
import com.lion.lionwebsite.Domain.GalleryTask;
|
||||||
import com.lion.lionwebsite.Message.*;
|
import com.lion.lionwebsite.Message.*;
|
||||||
@ -130,10 +130,9 @@ public class RemoteService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte deleteGallery(Gallery gallery, byte type){
|
public byte deleteGallery(Gallery gallery){
|
||||||
DeleteGalleryMessage dgm = new DeleteGalleryMessage();
|
DeleteGalleryMessage dgm = new DeleteGalleryMessage();
|
||||||
dgm.setGalleryName(gallery.getName());
|
dgm.setGalleryName(gallery.getName());
|
||||||
dgm.setDeleteType(type);
|
|
||||||
dgm.messageId = atomicInteger.getAndIncrement();
|
dgm.messageId = atomicInteger.getAndIncrement();
|
||||||
|
|
||||||
channel.writeAndFlush(dgm);
|
channel.writeAndFlush(dgm);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package com.lion.lionwebsite.Service;
|
package com.lion.lionwebsite.Service;
|
||||||
|
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import com.lion.lionwebsite.Dao.SubMapper;
|
import com.lion.lionwebsite.Dao.normal.SubMapper;
|
||||||
import com.lion.lionwebsite.Domain.SubBind;
|
import com.lion.lionwebsite.Domain.SubBind;
|
||||||
import com.lion.lionwebsite.Domain.SubUpdateRecord;
|
import com.lion.lionwebsite.Domain.SubUpdateRecord;
|
||||||
import com.lion.lionwebsite.Util.CustomUtil;
|
import com.lion.lionwebsite.Util.CustomUtil;
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
package com.lion.lionwebsite.Service;
|
package com.lion.lionwebsite.Service;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Dao.GalleryMapper;
|
import com.lion.lionwebsite.Dao.normal.GalleryMapper;
|
||||||
import com.lion.lionwebsite.Dao.TagMapper;
|
import com.lion.lionwebsite.Dao.normal.TagMapper;
|
||||||
import com.lion.lionwebsite.Domain.Gallery;
|
import com.lion.lionwebsite.Domain.Gallery;
|
||||||
import com.lion.lionwebsite.Domain.Tag;
|
import com.lion.lionwebsite.Domain.Tag;
|
||||||
import com.lion.lionwebsite.Util.Response;
|
import com.lion.lionwebsite.Util.Response;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package com.lion.lionwebsite.Service;
|
package com.lion.lionwebsite.Service;
|
||||||
|
|
||||||
import com.lion.lionwebsite.Dao.CollectMapper;
|
import com.lion.lionwebsite.Dao.normal.CollectMapper;
|
||||||
import com.lion.lionwebsite.Dao.GalleryMapper;
|
import com.lion.lionwebsite.Dao.normal.GalleryMapper;
|
||||||
import com.lion.lionwebsite.Dao.UserMapper;
|
import com.lion.lionwebsite.Dao.normal.UserMapper;
|
||||||
import com.lion.lionwebsite.Domain.User;
|
import com.lion.lionwebsite.Domain.User;
|
||||||
import com.lion.lionwebsite.Interceptor.TaskHandlerInterceptor;
|
import com.lion.lionwebsite.Interceptor.TaskHandlerInterceptor;
|
||||||
import com.lion.lionwebsite.Util.CustomUtil;
|
import com.lion.lionwebsite.Util.CustomUtil;
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
package com.lion.lionwebsite.Util;
|
package com.lion.lionwebsite.Util;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.lion.lionwebsite.Domain.MaskDomain;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.URL;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -28,27 +25,6 @@ public class CustomUtil {
|
|||||||
|
|
||||||
public static ObjectMapper objectMapper = new ObjectMapper();
|
public static ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
private MaskDomain[] maskDomains;
|
|
||||||
public String restoreUrl(String link){
|
|
||||||
URL url;
|
|
||||||
|
|
||||||
try {
|
|
||||||
url = new URL(link);
|
|
||||||
}catch (MalformedURLException e){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(MaskDomain maskDomain: maskDomains){
|
|
||||||
if(url.getHost().equals(maskDomain.getMask())){
|
|
||||||
return link.replace(maskDomain.getMask(), maskDomain.getRaw());
|
|
||||||
}
|
|
||||||
else if(url.getHost().equals(maskDomain.getRaw())){
|
|
||||||
return link;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String fileSizeToString(long fileSize){
|
public static String fileSizeToString(long fileSize){
|
||||||
if (fileSize < ONE_KB) {
|
if (fileSize < ONE_KB) {
|
||||||
return fileSize + "B";
|
return fileSize + "B";
|
||||||
|
|||||||
@ -3,10 +3,11 @@ package com.lion.lionwebsite.Util;
|
|||||||
import com.lion.lionwebsite.Domain.Gallery;
|
import com.lion.lionwebsite.Domain.Gallery;
|
||||||
import com.lion.lionwebsite.Exception.ResolutionNotMatchException;
|
import com.lion.lionwebsite.Exception.ResolutionNotMatchException;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
|
import org.apache.http.client.entity.EntityBuilder;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
import org.apache.http.entity.ContentType;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
@ -21,9 +22,6 @@ import java.util.*;
|
|||||||
|
|
||||||
public class GalleryUtil {
|
public class GalleryUtil {
|
||||||
|
|
||||||
static String EX_HENTAI = "https://exhentai.org";
|
|
||||||
static String E_HENTAI = "https://e-hentai.org";
|
|
||||||
|
|
||||||
static String POST = "post";
|
static String POST = "post";
|
||||||
static String GET = "get";
|
static String GET = "get";
|
||||||
|
|
||||||
@ -58,7 +56,7 @@ public class GalleryUtil {
|
|||||||
gallery.setProceeding(0);
|
gallery.setProceeding(0);
|
||||||
|
|
||||||
//访问本子页面
|
//访问本子页面
|
||||||
String galleryPage = requests(url, null, GET, null);
|
String galleryPage = requests(url, GET, null, null);
|
||||||
Document galleryDoc = Jsoup.parse(galleryPage);
|
Document galleryDoc = Jsoup.parse(galleryPage);
|
||||||
|
|
||||||
//收集本子基本信息
|
//收集本子基本信息
|
||||||
@ -76,7 +74,7 @@ public class GalleryUtil {
|
|||||||
|
|
||||||
|
|
||||||
//访问下载页面,获取分辨率
|
//访问下载页面,获取分辨率
|
||||||
String downloadPage = requests(download_link, extraProperties, GET, null);
|
String downloadPage = requests(download_link, GET, extraProperties, null);
|
||||||
Document downloadDoc = Jsoup.parse(downloadPage);
|
Document downloadDoc = Jsoup.parse(downloadPage);
|
||||||
Elements resolutions = downloadDoc.select("#db > div > table > tbody > tr > td");
|
Elements resolutions = downloadDoc.select("#db > div > table > tbody > tr > td");
|
||||||
download_link = downloadDoc.select("#hathdl_form").attr("action");
|
download_link = downloadDoc.select("#hathdl_form").attr("action");
|
||||||
@ -121,9 +119,11 @@ public class GalleryUtil {
|
|||||||
gallery.setResolution(targetResolution);
|
gallery.setResolution(targetResolution);
|
||||||
gallery.setFileSize(CustomUtil.stringToFileSize(availableResolution.get(targetResolution).replace(" ", "")));
|
gallery.setFileSize(CustomUtil.stringToFileSize(availableResolution.get(targetResolution).replace(" ", "")));
|
||||||
gallery.setDisplayFileSize(CustomUtil.fileSizeToString(gallery.getFileSize()));
|
gallery.setDisplayFileSize(CustomUtil.fileSizeToString(gallery.getFileSize()));
|
||||||
|
|
||||||
//提交下载请求
|
//提交下载请求
|
||||||
downloadPage = requests(download_link, extraProperties, POST, targetResolution);
|
HashMap<String, String> body = new HashMap<>();
|
||||||
|
body.put("hathdl_xres", targetResolution.replace("x", "").replace("Original", "org"));
|
||||||
|
downloadPage = requests(download_link, POST, extraProperties, body);
|
||||||
downloadDoc = Jsoup.parse(downloadPage);
|
downloadDoc = Jsoup.parse(downloadPage);
|
||||||
|
|
||||||
//判断下载请求是否提交成功
|
//判断下载请求是否提交成功
|
||||||
@ -139,12 +139,12 @@ public class GalleryUtil {
|
|||||||
|
|
||||||
|
|
||||||
public static String queryUpdateLink(String link) throws IOException{
|
public static String queryUpdateLink(String link) throws IOException{
|
||||||
String page = requests(link, null, GET, null);
|
String page = requests(link, GET, null, null);
|
||||||
Document document = Jsoup.parse(page);
|
Document document = Jsoup.parse(page);
|
||||||
|
|
||||||
Elements select = document.select("#gnd");
|
Elements select = document.select("#gnd");
|
||||||
if(select.size() > 0)
|
if(!select.isEmpty())
|
||||||
return select.select("a").get(0).attributes().get("href");
|
return select.select("a").getFirst().attributes().get("href");
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -161,40 +161,30 @@ public class GalleryUtil {
|
|||||||
if(url.length() < 40)
|
if(url.length() < 40)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if(!url.contains("/g/") || !url.contains("hentai"))
|
if(!url.contains("/g/") || !url.contains("exhentai"))
|
||||||
return null;
|
return null;
|
||||||
else if (url.contains(EX_HENTAI))
|
return "";
|
||||||
return EX_HENTAI;
|
|
||||||
else if (url.contains(E_HENTAI))
|
|
||||||
return E_HENTAI;
|
|
||||||
else{
|
|
||||||
System.out.println(url);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自用request
|
* 自用request
|
||||||
* @param url 链接
|
* @param url 链接
|
||||||
* @param extraProperties 额外参数
|
* @param headers 额外参数
|
||||||
* @param method 请求方法
|
* @param method 请求方法
|
||||||
* @param targetResolution 目标分辨率
|
|
||||||
* @return 请求页面
|
* @return 请求页面
|
||||||
* @throws IOException 可能会抛出IO错误
|
* @throws IOException 可能会抛出IO错误
|
||||||
*/
|
*/
|
||||||
public static String requests(String url, HashMap<String, String> extraProperties, String method, String targetResolution) throws IOException {
|
public static String requests(String url, String method, HashMap<String, String> headers, HashMap<String, String> body) throws IOException {
|
||||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
CloseableHttpResponse httpResponse;
|
CloseableHttpResponse httpResponse;
|
||||||
HashMap<String, String> headers = new HashMap<>();
|
if(headers == null)
|
||||||
|
headers = new HashMap<>();
|
||||||
|
|
||||||
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36");
|
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0");
|
||||||
headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
|
headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
|
||||||
headers.put("Upgrade-Insecure-Requests", "1");
|
headers.put("Upgrade-Insecure-Requests", "1");
|
||||||
headers.put("Cookie", "ipb_member_id=5774855; ipb_pass_hash=4b061c3abe25289568b5a8e0123fb3b9; igneous=cea2e08fb; sk=oye107wk02gtomb56x65dmv4qzbn; nw=1");
|
headers.put("Cookie", "ipb_member_id=5774855; ipb_pass_hash=4b061c3abe25289568b5a8e0123fb3b9; igneous=cea2e08fb; sk=oye107wk02gtomb56x65dmv4qzbn; nw=1");
|
||||||
|
|
||||||
if(extraProperties != null)
|
|
||||||
headers.putAll(extraProperties);
|
|
||||||
|
|
||||||
if(method.equals(GET)){
|
if(method.equals(GET)){
|
||||||
HttpGet httpGet = new HttpGet(url);
|
HttpGet httpGet = new HttpGet(url);
|
||||||
for (Map.Entry<String, String> header: headers.entrySet()){
|
for (Map.Entry<String, String> header: headers.entrySet()){
|
||||||
@ -208,11 +198,12 @@ public class GalleryUtil {
|
|||||||
httpPost.addHeader(header.getKey(), header.getValue());
|
httpPost.addHeader(header.getKey(), header.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
|
if(body != null) {
|
||||||
multipartEntityBuilder.addTextBody("hathdl_xres",
|
EntityBuilder entityBuilder = EntityBuilder.create();
|
||||||
targetResolution.replace("x", "").replace("Original", "org"));
|
entityBuilder.setContentType(ContentType.APPLICATION_JSON);
|
||||||
|
entityBuilder.setText(CustomUtil.objectMapper.writeValueAsString(body));
|
||||||
httpPost.setEntity(multipartEntityBuilder.build());
|
httpPost.setEntity(entityBuilder.build());
|
||||||
|
}
|
||||||
httpResponse = httpClient.execute(httpPost);
|
httpResponse = httpClient.execute(httpPost);
|
||||||
}
|
}
|
||||||
HttpEntity responseEntity = httpResponse.getEntity();
|
HttpEntity responseEntity = httpResponse.getEntity();
|
||||||
|
|||||||
@ -50,9 +50,10 @@ public class Response {
|
|||||||
setResult("failure");
|
setResult("failure");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void failure(String result){
|
public Response failure(String result){
|
||||||
failure();
|
failure();
|
||||||
setData(result);
|
setData(result);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResult(){
|
public String getResult(){
|
||||||
@ -82,13 +83,6 @@ public class Response {
|
|||||||
return response.toJSONString();
|
return response.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String _default(){
|
|
||||||
Response response = Response.generateResponse();
|
|
||||||
response.failure("参数错误");
|
|
||||||
|
|
||||||
return response.toJSONString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toJSONString(){
|
public String toJSONString(){
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@ -6,9 +6,12 @@ server:
|
|||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
datasource:
|
datasource-main:
|
||||||
driver-class-name: org.sqlite.JDBC
|
driver-class-name: org.sqlite.JDBC
|
||||||
url: jdbc:sqlite:/root/LionWebsite/LionWebsite.db
|
jdbc-url: jdbc:sqlite:/root/LionWebsite/LionWebsite.db
|
||||||
|
datasource-cache:
|
||||||
|
driver-class-name: org.sqlite.JDBC
|
||||||
|
jdbc-url: jdbc:sqlite:/root/LionWebsite/cache.db
|
||||||
mvc:
|
mvc:
|
||||||
view:
|
view:
|
||||||
prefix: /resources/templates/
|
prefix: /resources/templates/
|
||||||
@ -21,8 +24,6 @@ spring:
|
|||||||
max-request-size: 10000MB
|
max-request-size: 10000MB
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
mybatis:
|
|
||||||
type-aliases-package: com.lion.lionwebsite.Dao
|
|
||||||
|
|
||||||
personal-service:
|
personal-service:
|
||||||
StoragePath: /storage/
|
StoragePath: /storage/
|
||||||
@ -35,7 +36,6 @@ remote-service:
|
|||||||
ip: 5.255.110.45
|
ip: 5.255.110.45
|
||||||
|
|
||||||
local-service:
|
local-service:
|
||||||
fires: https://api.dler.io/sub?target=clash&new_name=true&url=https%3A%2F%2Ffast.losadhwselfff2332dasd.xyz%2Flink%2Fz0pfwyTvC5naXkbb%3Fclash%3D1&insert=false&config=https%3A%2F%2Fraw.githubusercontent.com%2FACL4SSR%2FACL4SSR%2Fmaster%2FClash%2Fconfig%2FACL4SSR_Online.ini
|
|
||||||
DouNaiClash: https://aaaa.gay/link/X7zEqkIx5gtIGugO?client=clashmeta
|
DouNaiClash: https://aaaa.gay/link/X7zEqkIx5gtIGugO?client=clashmeta
|
||||||
DouNaiV2ray: https://aaaa.gay/link/X7zEqkIx5gtIGugO?client=v2
|
DouNaiV2ray: https://aaaa.gay/link/X7zEqkIx5gtIGugO?client=v2
|
||||||
|
|
||||||
|
|||||||
BIN
src/main/resources/cache.db
Normal file
BIN
src/main/resources/cache.db
Normal file
Binary file not shown.
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
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user