diff --git a/ad-distribute-common/common-core/pom.xml b/ad-distribute-common/common-core/pom.xml index 1b9156f..77fe084 100644 --- a/ad-distribute-common/common-core/pom.xml +++ b/ad-distribute-common/common-core/pom.xml @@ -73,7 +73,10 @@ 2.3.2.RELEASE - + + net.lingala.zip4j + zip4j + diff --git a/ad-distribute-common/common-core/src/main/java/com/baiye/constant/FileConstant.java b/ad-distribute-common/common-core/src/main/java/com/baiye/constant/FileConstant.java new file mode 100644 index 0000000..72261a7 --- /dev/null +++ b/ad-distribute-common/common-core/src/main/java/com/baiye/constant/FileConstant.java @@ -0,0 +1,112 @@ +package com.baiye.constant; + +/** + * @author + * 文件相关 常量类 + */ +public class FileConstant { + + /** + * 0,(自定义模板) + */ + public static final int ZERO_NUMBER = 0; + + /** + * 1,(UC) + */ + public static final int ONE_NUMBER = 1; + + /** + * 2,(快手) + */ + public static final int TWO_NUMBER = 2; + + /** + * 3,(抖音) + */ + public static final int THREE_NUMBER = 3; + + /** + * 4,(百度) + */ + public static final int FOUR_NUMBER = 4; + + /** + * 5,(动态任务自定义模板) + */ + public static final int FIVE_NUMBER = 5; + + /** + * 6,(拓客动态任务) + */ + public static final int SIX_NUMBER = 6; + + /** + * 1000 + */ + public static final int ONE_THOUSAND_NUMBER = 1000; + + /** + * 1000000 + */ + public static final int ONE_MILLION_NUMBER = 1000000; + + /** + * BY + */ + public static final String BY = "BY"; + + /** + * MM + */ + public static final String MM = "MM"; + + /** + * uc + */ + public static final String UC = "uc"; + + /** + * 快手 + */ + public static final String KS = "ks"; + + /** + * 抖音 + */ + public static final String DY = "dy"; + + /** + * 其它 + */ + public static final String QT = "qt"; + + + /** + * 以 xlsx 结尾的文件 + */ + public static final String XLSX_FILE_SUB_NAME = "xlsx"; + + /** + * 以 xls 结尾的文件 + */ + public static final String XLS_FILE_SUB_NAME = "xls"; + + /** + * 以 txt 结尾的文件 + */ + public static final String TXT_FILE_SUB_NAME = "txt"; + + /** + * 以 csv 结尾的文件 + */ + public static final String CSV_FILE_SUB_NAME = "csv"; + + + /** + * 以 zip 结尾的文件 + */ + public static final String ZIP_FILE_SUB_NAME = ".zip"; + + +} diff --git a/ad-distribute-common/common-core/src/main/java/com/baiye/util/CompressUtil.java b/ad-distribute-common/common-core/src/main/java/com/baiye/util/CompressUtil.java new file mode 100644 index 0000000..ddaa1fc --- /dev/null +++ b/ad-distribute-common/common-core/src/main/java/com/baiye/util/CompressUtil.java @@ -0,0 +1,85 @@ +package com.baiye.util; + +import cn.hutool.core.text.StrPool; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.IdUtil; +import net.lingala.zip4j.core.ZipFile; +import net.lingala.zip4j.exception.ZipException; +import net.lingala.zip4j.model.ZipParameters; +import net.lingala.zip4j.util.Zip4jConstants; +import org.apache.commons.lang3.StringUtils; + +import java.io.File; +import java.util.ArrayList; + +/** + * @author Enzo + * @date : 2022/10/24 + */ +public class CompressUtil { + private CompressUtil() { + } + + /** + * @param zipPath 压缩文件路径 + * @param filepath 文件路径 + * @param password 压缩密码 + */ + public static void decryptionCompression(String zipPath, String filepath, String password) { + try { + //创建压缩文件 + ZipFile zipFile = new ZipFile(zipPath); + ArrayList files = new ArrayList<>(); + files.add(new File(filepath)); + + //设置压缩文件参数 + ZipParameters parameters = new ZipParameters(); + //设置压缩方法 + parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); + + //设置压缩级别 + //DEFLATE_LEVEL_FASTEST - Lowest compression level but higher speed of compression + //DEFLATE_LEVEL_FAST - Low compression level but higher speed of compression + //DEFLATE_LEVEL_NORMAL - Optimal balance between compression level/speed + //DEFLATE_LEVEL_MAXIMUM - High compression level with a compromise of speed + //DEFLATE_LEVEL_ULTRA - Highest compression level but low speed + parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); + + + //设置加密方法 + parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_AES); + + //设置aes加密强度 + parameters.setAesKeyStrength(Zip4jConstants.AES_STRENGTH_256); + + if (StringUtils.isNotBlank(password)) { + //设置压缩文件加密 + parameters.setEncryptFiles(Boolean.TRUE); + //设置密码 + parameters.setPassword(password); + } + + //添加文件到压缩文件 + zipFile.addFiles(files, parameters); + } catch (ZipException e) { + e.printStackTrace(); + } + } + + public static String unzipFiles(String fileUrl, String zipPath, String password) throws ZipException { + File file = new File(zipPath); + ZipFile zipFile = new ZipFile(file); + //设置文件编码,根据实际场景 + zipFile.setFileNameCharset(CharsetUtil.GBK); + if (zipFile.isEncrypted()) { + zipFile.setPassword(password); + } + String uuid = IdUtil.randomUUID(); + String filePath + = fileUrl.concat(StrPool.SLASH).concat(uuid); + zipFile.extractAll(filePath); + return filePath; + } + + +} diff --git a/ad-distribute-extends/ad-distribute-extend-mybatis-plus/src/main/java/com/baiye/extend/mybatis/plus/converter/ListIntToListLongTypeHandler.java b/ad-distribute-extends/ad-distribute-extend-mybatis-plus/src/main/java/com/baiye/extend/mybatis/plus/converter/ListIntToListLongTypeHandler.java new file mode 100644 index 0000000..11f1650 --- /dev/null +++ b/ad-distribute-extends/ad-distribute-extend-mybatis-plus/src/main/java/com/baiye/extend/mybatis/plus/converter/ListIntToListLongTypeHandler.java @@ -0,0 +1,74 @@ +package com.baiye.extend.mybatis.plus.converter; + +import cn.hutool.json.JSONUtil; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.CollectionType; +import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.type.BaseTypeHandler; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedJdbcTypes; +import org.apache.ibatis.type.MappedTypes; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Enzo + * @date : 2024/3/14 + */ +@MappedJdbcTypes(JdbcType.VARCHAR) // 数据库中该字段存储的类型 +@MappedTypes(List.class) // 需要转换的对象 +public class ListIntToListLongTypeHandler extends BaseTypeHandler> { + + private static ObjectMapper mObjectMapper = new ObjectMapper(); + + @Override + public void setNonNullParameter(PreparedStatement preparedStatement, int i, List longs, JdbcType jdbcType) throws SQLException { + String json = JSONUtil.toJsonStr(longs); + preparedStatement.setObject(i, json); + } + + @Override + public List getNullableResult(ResultSet resultSet, String columnName) throws SQLException { + String value = resultSet.getString(columnName); + return getLongs(value); + } + + + @Override + public List getNullableResult(ResultSet resultSet, int i) throws SQLException { + String value = resultSet.getString(i); + + return getLongs(value); + } + + @Override + public List getNullableResult(CallableStatement callableStatement, int i) throws SQLException { + String value = callableStatement.getString(i); + + return getLongs(value); + } + + private List getLongs(String value) { + if (StringUtils.isNotBlank(value)) { + try { + + CollectionType type = mObjectMapper.getTypeFactory().constructCollectionType(ArrayList.class, Long.class); + List longs = mObjectMapper.readValue(value , type); + + //List longs = JsonUtil.parseArray(value, Long.class); + return longs; + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + } + + return null; + } +} diff --git a/ad-distribute-system/system-biz/src/main/java/com/baiye/system/properties/FileProperties.java b/ad-distribute-system/system-biz/src/main/java/com/baiye/system/properties/FileProperties.java index e87ac93..088a701 100644 --- a/ad-distribute-system/system-biz/src/main/java/com/baiye/system/properties/FileProperties.java +++ b/ad-distribute-system/system-biz/src/main/java/com/baiye/system/properties/FileProperties.java @@ -25,6 +25,8 @@ public class FileProperties { private ElPath windows; + private String downUrl; + public ElPath getPath() { String os = System.getProperty("os.name"); if (os.toLowerCase().startsWith("win")) { diff --git a/ad-distribute-system/system-biz/src/main/resources/mapper/SysUserMapper.xml b/ad-distribute-system/system-biz/src/main/resources/mapper/SysUserMapper.xml index 354010c..f69926d 100644 --- a/ad-distribute-system/system-biz/src/main/resources/mapper/SysUserMapper.xml +++ b/ad-distribute-system/system-biz/src/main/resources/mapper/SysUserMapper.xml @@ -60,15 +60,17 @@ + SELECT + + FROM + tb_file_contrast_task fl + ${ew.customSqlSegment} + + diff --git a/pom.xml b/pom.xml index d2dbf75..a4c289a 100644 --- a/pom.xml +++ b/pom.xml @@ -52,6 +52,7 @@ 3.5.3.1 3.5.10 4.1.2 + 1.3.2 2.2.0 2.20.70 0.4.2 @@ -402,6 +403,14 @@ easy-captcha ${captcha.version} + + + net.lingala.zip4j + zip4j + ${zip4j.version} + + +