fix-提出部分常量,优化sql
This commit is contained in:
parent
bd41c0d035
commit
612a80aadd
@ -1,14 +0,0 @@
|
|||||||
INSERT INTO `app_channel_bucket`( `app_channel_bucket_no`, `app_code`, `channel_code`, `bucket_name`, `access_control`, `remark`, `extension`, `create_at`, `update_at`, `create_by`, `update_by`, `is_delete`)
|
|
||||||
VALUES ( 'zeus:aliyun:zeus', 'zeus', 'aliyun', 'axzo_public', '', NULL, NULL, now(), now(), '', '', 0);
|
|
||||||
|
|
||||||
INSERT INTO `file_app`(`app_code`, `app_name`, `status`, `remark`, `extension`, `create_at`, `update_at`, `create_by`, `update_by`, `is_delete`)
|
|
||||||
VALUES ('zeus', 'zeus', 1, 'zeus', NULL, now(), now(), '', '', 0);
|
|
||||||
|
|
||||||
INSERT INTO `file_business_scene`(`app_channel_bucket_no`, `app_code`, `channel_code`, `bucket_name`, `business_scene`, `directory`, `create_at`, `update_at`, `create_by`, `update_by`, `is_delete`)
|
|
||||||
VALUES ('zeus:aliyun:zeus', 'zeus', 'aliyun', 'axzo_public', 'recruit_collect', 'oss-test/zeus', now(), now(), NULL, NULL, 0);
|
|
||||||
|
|
||||||
INSERT INTO `file_channel`(`channel_code`, `channel_name`, `status`, `remark`, `extension`, `priority`, `create_at`, `update_at`, `create_by`, `update_by`, `is_delete`)
|
|
||||||
VALUES ('aliyun', '阿里云', 1, NULL, NULL, 1, now(), now(), NULL, NULL, 0);
|
|
||||||
|
|
||||||
INSERT INTO `file_upload_config`(`app_channel_bucket_no`, `app_code`, `channel_code`, `bucket_name`, `directory`, `storage_unit`, `storage_size`, `file_format`, `create_at`, `update_at`, `create_by`, `update_by`, `is_delete`)
|
|
||||||
VALUES ('zeus:aliyun:zeus', 'zeus', 'aliyun', 'axzo-public', 'oss-test/zeus', 'MB', 5, 'jpg', now(), now(), NULL, NULL, 0);
|
|
||||||
14
doc/sql/dml/oss_data_init.sql
Normal file
14
doc/sql/dml/oss_data_init.sql
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
INSERT INTO `app_channel_bucket`( `app_channel_bucket_no`, `app_code`, `channel_code`, `bucket_name`)
|
||||||
|
VALUES ( 'zeus:aliyun:zeus', 'zeus', 'aliyun', 'axzo_public');
|
||||||
|
|
||||||
|
INSERT INTO `file_app`(`app_code`, `app_name`, `status`, `remark` )
|
||||||
|
VALUES ('zeus', 'zeus', 1, 'zeus');
|
||||||
|
|
||||||
|
INSERT INTO `file_business_scene`(`app_channel_bucket_no`, `app_code`, `channel_code`, `bucket_name`, `business_scene`, `directory`)
|
||||||
|
VALUES ('zeus:aliyun:zeus', 'zeus', 'aliyun', 'axzo_public', 'recruit_collect', 'oss-test/zeus');
|
||||||
|
|
||||||
|
INSERT INTO `file_channel`(`channel_code`, `channel_name`, `status`, `priority`)
|
||||||
|
VALUES ('aliyun', '阿里云', 1, 1);
|
||||||
|
|
||||||
|
INSERT INTO `file_upload_config`(`app_channel_bucket_no`, `app_code`, `channel_code`, `bucket_name`, `directory`, `storage_unit`, `storage_size`, `file_format`)
|
||||||
|
VALUES ('zeus:aliyun:zeus', 'zeus', 'aliyun', 'axzo-public', 'oss-test/zeus', 'MB', 5, 'xlsx');
|
||||||
@ -9,21 +9,6 @@ package cn.axzo.oss.common.constans;
|
|||||||
*/
|
*/
|
||||||
public abstract class CommonConstants {
|
public abstract class CommonConstants {
|
||||||
|
|
||||||
/**
|
|
||||||
* 默认 分割器
|
|
||||||
*/
|
|
||||||
public static final String SEPARATOR_CHAR = "/";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 默认 .
|
|
||||||
*/
|
|
||||||
public static final String DOT = ".";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 逗号
|
|
||||||
*/
|
|
||||||
public static final String COMMA = ",";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在指定字符串未找字符串的位置
|
* 在指定字符串未找字符串的位置
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
package cn.axzo.oss.common.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: zhangran
|
||||||
|
* @date: 20210805 21:31
|
||||||
|
* @description: 文件类符号
|
||||||
|
**/
|
||||||
|
public enum FileClassEnum {
|
||||||
|
|
||||||
|
|
||||||
|
SEPARATOR_CHAR("/", "默认 分割器"),
|
||||||
|
DOT(".", "文件命后缀 如abc.xlsx"),
|
||||||
|
COMMA(",", "逗号"),
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
FileClassEnum(String type, String desc) {
|
||||||
|
this.type = type;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public final String type;
|
||||||
|
|
||||||
|
public final String desc;
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,8 +1,7 @@
|
|||||||
package cn.axzo.oss.common.utils;
|
package cn.axzo.oss.common.utils;
|
||||||
|
|
||||||
import cn.axzo.oss.common.constans.CommonConstants;
|
import cn.axzo.oss.common.enums.FileClassEnum;
|
||||||
import cn.axzo.oss.common.enums.StorageUnitEnum;
|
import cn.axzo.oss.common.enums.StorageUnitEnum;
|
||||||
import java.io.File;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
@ -120,9 +119,9 @@ public class Utility {
|
|||||||
*/
|
*/
|
||||||
public static String generateFileKey(String directory, String fileUuid, String fileFormat){
|
public static String generateFileKey(String directory, String fileUuid, String fileFormat){
|
||||||
StringBuilder tgtFileKey = new StringBuilder(directory);
|
StringBuilder tgtFileKey = new StringBuilder(directory);
|
||||||
tgtFileKey.append(CommonConstants.SEPARATOR_CHAR);
|
tgtFileKey.append(FileClassEnum.SEPARATOR_CHAR.type);
|
||||||
tgtFileKey.append(fileUuid);
|
tgtFileKey.append(fileUuid);
|
||||||
tgtFileKey.append(CommonConstants.DOT);
|
tgtFileKey.append(FileClassEnum.DOT.type);
|
||||||
tgtFileKey.append(fileFormat);
|
tgtFileKey.append(fileFormat);
|
||||||
return tgtFileKey.toString();
|
return tgtFileKey.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import cn.axzo.oss.common.constans.CommonConstants;
|
|||||||
import cn.axzo.oss.common.constans.CommonConstants.FileStatus;
|
import cn.axzo.oss.common.constans.CommonConstants.FileStatus;
|
||||||
import cn.axzo.oss.common.constans.CommonConstants.TableDelete;
|
import cn.axzo.oss.common.constans.CommonConstants.TableDelete;
|
||||||
import cn.axzo.oss.common.enums.CodeEnum;
|
import cn.axzo.oss.common.enums.CodeEnum;
|
||||||
|
import cn.axzo.oss.common.enums.FileClassEnum;
|
||||||
import cn.axzo.oss.common.enums.FileStatusEnum;
|
import cn.axzo.oss.common.enums.FileStatusEnum;
|
||||||
import cn.axzo.oss.common.exception.BizException;
|
import cn.axzo.oss.common.exception.BizException;
|
||||||
import cn.axzo.oss.common.utils.JsonUtil;
|
import cn.axzo.oss.common.utils.JsonUtil;
|
||||||
@ -145,9 +146,9 @@ public class FileServiceImpl implements FileService {
|
|||||||
.capacityConversion(fileUploadConfig.getStorageSize(), fileUploadConfig.getStorageUnit());
|
.capacityConversion(fileUploadConfig.getStorageSize(), fileUploadConfig.getStorageUnit());
|
||||||
BizException.error(size > fileLength, CodeEnum.FILE_SIZE_EXCEEDS_LIMIT);
|
BizException.error(size > fileLength, CodeEnum.FILE_SIZE_EXCEEDS_LIMIT);
|
||||||
// 文件格式判断
|
// 文件格式判断
|
||||||
String[] formats = fileUploadConfig.getFileFormat().split(CommonConstants.COMMA);
|
String[] formats = fileUploadConfig.getFileFormat().split(FileClassEnum.COMMA.type);
|
||||||
|
|
||||||
int lastIndexOf = fileName.lastIndexOf(CommonConstants.DOT);
|
int lastIndexOf = fileName.lastIndexOf(FileClassEnum.DOT.type);
|
||||||
BizException
|
BizException
|
||||||
.error(lastIndexOf != CommonConstants.NOT_FOUND_INDEX_OF, CodeEnum.NOT_FILE_FORMAT);
|
.error(lastIndexOf != CommonConstants.NOT_FOUND_INDEX_OF, CodeEnum.NOT_FILE_FORMAT);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user