"fix__修复不符合阿里代码规范的相关代码"
This commit is contained in:
parent
5164a5ed64
commit
4500ae3dac
|
|
@ -132,4 +132,9 @@ public class Constants
|
|||
*/
|
||||
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
||||
"org.springframework", "org.apache", "com.bonus.common.core.utils.file" };
|
||||
|
||||
/**
|
||||
* 指定集合的大小
|
||||
*/
|
||||
public static final int COMMON_COLLECTION_SIZE = 16;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@ public class Base64Utils {
|
|||
|
||||
@SuppressWarnings("MagicNumber")
|
||||
public static String getFileNameFromUrl(String url) {
|
||||
if (url.toLowerCase().startsWith("file:")) {
|
||||
final String fileProtocol = "file:";
|
||||
if (url.toLowerCase().startsWith(fileProtocol)) {
|
||||
try {
|
||||
URL urlObj = new URL(url);
|
||||
url = urlObj.getPath().substring(1);
|
||||
|
|
|
|||
|
|
@ -220,20 +220,24 @@ public class ServletUtils
|
|||
|
||||
public static boolean isAjaxRequest(HttpServletRequest request)
|
||||
{
|
||||
final String jsonMimeType = "application/json";
|
||||
final String xhrHeader = "XMLHttpRequest";
|
||||
final String jsonSuffix = ".json";
|
||||
final String xmlSuffix = ".xml";
|
||||
String accept = request.getHeader("accept");
|
||||
if (accept != null && accept.contains("application/json"))
|
||||
if (accept != null && accept.contains(jsonMimeType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
String xRequestedWith = request.getHeader("X-Requested-With");
|
||||
if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest"))
|
||||
if (xRequestedWith != null && xRequestedWith.contains(xhrHeader))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
String uri = request.getRequestURI();
|
||||
if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml"))
|
||||
if (StringUtils.inStringIgnoreCase(uri, jsonSuffix, xmlSuffix))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -446,6 +446,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
|
||||
public static String convertToCamelCase(String name)
|
||||
{
|
||||
final String underscoreChar = "_";
|
||||
StringBuilder result = new StringBuilder();
|
||||
// 快速检查
|
||||
if (name == null || name.isEmpty())
|
||||
|
|
@ -453,7 +454,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||
// 没必要转换
|
||||
return "";
|
||||
}
|
||||
else if (!name.contains("_"))
|
||||
else if (!name.contains(underscoreChar))
|
||||
{
|
||||
// 不含下划线,仅将首字母大写
|
||||
return name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||
|
|
|
|||
|
|
@ -71,13 +71,12 @@ public class FileTypeUtils
|
|||
* @param photoByte 文件字节码
|
||||
* @return 后缀(不含".")
|
||||
*/
|
||||
|
||||
|
||||
public static String getFileExtendName(byte[] photoByte)
|
||||
{
|
||||
String strFileExtendName = "JPG";
|
||||
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
|
||||
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97))
|
||||
Boolean flag = (photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
|
||||
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97);
|
||||
if (flag)
|
||||
{
|
||||
strFileExtendName = "GIF";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,13 @@ public class FileUtils {
|
|||
|
||||
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
|
||||
|
||||
private static final String PARENT_DIRECTORY_INDICATOR = "..";
|
||||
private static final String MSIE_IDENTIFIER = "MSIE";
|
||||
private static final String FIREFOX_IDENTIFIER = "Firefox";
|
||||
private static final String CHROME_IDENTIFIER = "Chrome";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 输出指定文件的byte数组
|
||||
*
|
||||
|
|
@ -112,7 +119,7 @@ public class FileUtils {
|
|||
*/
|
||||
public static boolean checkAllowDownload(String resource) {
|
||||
// 禁止目录上跳级别
|
||||
if (StringUtils.contains(resource, "..")) {
|
||||
if (StringUtils.contains(resource, PARENT_DIRECTORY_INDICATOR)) {
|
||||
return false;
|
||||
}
|
||||
// 判断是否在允许下载的文件规则内
|
||||
|
|
@ -129,14 +136,14 @@ public class FileUtils {
|
|||
public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException {
|
||||
final String agent = request.getHeader("USER-AGENT");
|
||||
String filename = fileName;
|
||||
if (agent.contains("MSIE")) {
|
||||
if (agent.contains(MSIE_IDENTIFIER)) {
|
||||
// IE浏览器
|
||||
filename = URLEncoder.encode(filename, "utf-8");
|
||||
filename = filename.replace("+", " ");
|
||||
} else if (agent.contains("Firefox")) {
|
||||
} else if (agent.contains(FIREFOX_IDENTIFIER)) {
|
||||
// 火狐浏览器
|
||||
filename = new String(fileName.getBytes(), "ISO8859-1");
|
||||
} else if (agent.contains("Chrome")) {
|
||||
} else if (agent.contains(CHROME_IDENTIFIER)) {
|
||||
// google浏览器
|
||||
filename = URLEncoder.encode(filename, "utf-8");
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@ public class EscapeUtil
|
|||
public static final String RE_HTML_MARK = "(<[^<]*?>)|(<[\\s]*?/[^<]*?>)|(<[^<]*?/[\\s]*?>)";
|
||||
|
||||
private static final char[][] TEXT = new char[64][];
|
||||
private static final int TEXT_ARRAY_LENGTH = 64;
|
||||
|
||||
static
|
||||
{
|
||||
for (int i = 0; i < 64; i++)
|
||||
for (int i = 0; i < TEXT_ARRAY_LENGTH; i++)
|
||||
{
|
||||
TEXT[i] = new char[] { (char) i };
|
||||
}
|
||||
|
|
@ -64,7 +65,7 @@ public class EscapeUtil
|
|||
*/
|
||||
public static String clean(String content)
|
||||
{
|
||||
return new HTMLFilter().filter(content);
|
||||
return new HtmlFilter().filter(content);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
//@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
|
||||
|
||||
public final class HTMLFilter
|
||||
public final class HtmlFilter
|
||||
{
|
||||
/**
|
||||
* regex flag union representing /si modifiers in php
|
||||
|
|
@ -46,6 +46,7 @@ public final class HTMLFilter
|
|||
private static final Pattern P_LEFT_ARROW = Pattern.compile("<");
|
||||
private static final Pattern P_RIGHT_ARROW = Pattern.compile(">");
|
||||
private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>");
|
||||
private static final String LOCAL_ANCHOR_PREFIX = "#//";
|
||||
|
||||
/**
|
||||
* @xxx could grow large... maybe use sesat's ReferenceMap
|
||||
|
|
@ -104,7 +105,7 @@ public final class HTMLFilter
|
|||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public HTMLFilter()
|
||||
public HtmlFilter()
|
||||
{
|
||||
vAllowed = new HashMap<>();
|
||||
|
||||
|
|
@ -145,7 +146,7 @@ public final class HTMLFilter
|
|||
* @param conf map containing configuration. keys match field names.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public HTMLFilter(final Map<String, Object> conf)
|
||||
public HtmlFilter(final Map<String, Object> conf)
|
||||
{
|
||||
|
||||
assert conf.containsKey("vAllowed") : "configuration requires vAllowed";
|
||||
|
|
@ -455,7 +456,7 @@ public final class HTMLFilter
|
|||
{
|
||||
// bad protocol, turn into local anchor link instead
|
||||
s = "#" + s.substring(protocol.length() + 1);
|
||||
if (s.startsWith("#//"))
|
||||
if (s.startsWith(LOCAL_ANCHOR_PREFIX))
|
||||
{
|
||||
s = "#" + s.substring(3);
|
||||
}
|
||||
|
|
@ -25,6 +25,11 @@ public class IpUtils
|
|||
*/
|
||||
public final static String REGX_IP_SEG = "(" + REGX_IP + "\\-" + REGX_IP + ")";
|
||||
|
||||
private final static String IP_UNKNOWN = "unknown";
|
||||
|
||||
private final static int ELEMWNT_COUNT_4 = 4;
|
||||
|
||||
|
||||
/**
|
||||
* 获取客户端IP
|
||||
*
|
||||
|
|
@ -45,27 +50,27 @@ public class IpUtils
|
|||
{
|
||||
if (request == null)
|
||||
{
|
||||
return "unknown";
|
||||
return IP_UNKNOWN;
|
||||
}
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||
if (ip == null || ip.length() == 0 || IP_UNKNOWN.equalsIgnoreCase(ip))
|
||||
{
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||
if (ip == null || ip.length() == 0 || IP_UNKNOWN.equalsIgnoreCase(ip))
|
||||
{
|
||||
ip = request.getHeader("X-Forwarded-For");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||
if (ip == null || ip.length() == 0 || IP_UNKNOWN.equalsIgnoreCase(ip))
|
||||
{
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||
if (ip == null || ip.length() == 0 || IP_UNKNOWN.equalsIgnoreCase(ip))
|
||||
{
|
||||
ip = request.getHeader("X-Real-IP");
|
||||
}
|
||||
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||
if (ip == null || ip.length() == 0 || IP_UNKNOWN.equalsIgnoreCase(ip))
|
||||
{
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
|
|
@ -94,7 +99,8 @@ public class IpUtils
|
|||
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
|
||||
private static boolean internalIp(byte[] addr)
|
||||
{
|
||||
if (StringUtils.isNull(addr) || addr.length < 2)
|
||||
final int addrLength = 2;
|
||||
if (StringUtils.isNull(addr) || addr.length < addrLength)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -145,6 +151,11 @@ public class IpUtils
|
|||
*/
|
||||
public static byte[] textToNumericFormatV4(String text)
|
||||
{
|
||||
final long maxUnsignedIntValue = 4294967295L;
|
||||
final long maxUnsignedByteValue = 255L;
|
||||
final long max24BitColorValue = 16777215L;
|
||||
final int numElementsToProcess2 = 2;
|
||||
final long maxUnsignedShortValue = 65535L;
|
||||
if (text.length() == 0)
|
||||
{
|
||||
return null;
|
||||
|
|
@ -160,7 +171,7 @@ public class IpUtils
|
|||
{
|
||||
case 1:
|
||||
l = Long.parseLong(elements[0]);
|
||||
if ((l < 0L) || (l > 4294967295L))
|
||||
if ((l < 0L) || (l > maxUnsignedIntValue))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
@ -171,13 +182,13 @@ public class IpUtils
|
|||
break;
|
||||
case 2:
|
||||
l = Integer.parseInt(elements[0]);
|
||||
if ((l < 0L) || (l > 255L))
|
||||
if ((l < 0L) || (l > maxUnsignedByteValue))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
bytes[0] = (byte) (int) (l & 0xFF);
|
||||
l = Integer.parseInt(elements[1]);
|
||||
if ((l < 0L) || (l > 16777215L))
|
||||
if ((l < 0L) || (l > max24BitColorValue))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
@ -186,7 +197,7 @@ public class IpUtils
|
|||
bytes[3] = (byte) (int) (l & 0xFF);
|
||||
break;
|
||||
case 3:
|
||||
for (i = 0; i < 2; ++i)
|
||||
for (i = 0; i < numElementsToProcess2; ++i)
|
||||
{
|
||||
l = Integer.parseInt(elements[i]);
|
||||
if ((l < 0L) || (l > 255L))
|
||||
|
|
@ -196,7 +207,7 @@ public class IpUtils
|
|||
bytes[i] = (byte) (int) (l & 0xFF);
|
||||
}
|
||||
l = Integer.parseInt(elements[2]);
|
||||
if ((l < 0L) || (l > 65535L))
|
||||
if ((l < 0L) || (l > maxUnsignedShortValue))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
@ -204,7 +215,7 @@ public class IpUtils
|
|||
bytes[3] = (byte) (int) (l & 0xFF);
|
||||
break;
|
||||
case 4:
|
||||
for (i = 0; i < 4; ++i)
|
||||
for (i = 0; i < ELEMWNT_COUNT_4; ++i)
|
||||
{
|
||||
l = Integer.parseInt(elements[i]);
|
||||
if ((l < 0L) || (l > 255L))
|
||||
|
|
@ -267,8 +278,9 @@ public class IpUtils
|
|||
*/
|
||||
public static String getMultistageReverseProxyIp(String ip)
|
||||
{
|
||||
final String commaDelimiter = ",";
|
||||
// 多级反向代理检测
|
||||
if (ip != null && ip.indexOf(",") > 0)
|
||||
if (ip != null && ip.indexOf(commaDelimiter) > 0)
|
||||
{
|
||||
final String[] ips = ip.trim().split(",");
|
||||
for (String subIp : ips)
|
||||
|
|
@ -316,10 +328,11 @@ public class IpUtils
|
|||
*/
|
||||
public static boolean ipIsInWildCardNoCheck(String ipWildCard, String ip)
|
||||
{
|
||||
final String wildcardSymbol = "*";
|
||||
String[] s1 = ipWildCard.split("\\.");
|
||||
String[] s2 = ip.split("\\.");
|
||||
boolean isMatchedSeg = true;
|
||||
for (int i = 0; i < s1.length && !"*".equals(s1[i]); i++)
|
||||
for (int i = 0; i < s1.length && !wildcardSymbol.equals(s1[i]); i++)
|
||||
{
|
||||
if (!s1[i].equals(s2[i]))
|
||||
{
|
||||
|
|
@ -349,7 +362,7 @@ public class IpUtils
|
|||
String[] sipe = iparea.substring(idx + 1).split("\\.");
|
||||
String[] sipt = ip.split("\\.");
|
||||
long ips = 0L, ipe = 0L, ipt = 0L;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
for (int i = 0; i < ELEMWNT_COUNT_4; ++i)
|
||||
{
|
||||
ips = ips << 8 | Integer.parseInt(sips[i]);
|
||||
ipe = ipe << 8 | Integer.parseInt(sipe[i]);
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ import com.bonus.common.core.utils.StringUtils;
|
|||
import com.bonus.common.core.utils.file.FileTypeUtils;
|
||||
import com.bonus.common.core.utils.file.ImageUtils;
|
||||
import com.bonus.common.core.utils.reflect.ReflectUtils;
|
||||
import com.bonus.common.core.constant.Constants;
|
||||
|
||||
/**
|
||||
* Excel相关处理
|
||||
|
|
@ -72,6 +73,12 @@ import com.bonus.common.core.utils.reflect.ReflectUtils;
|
|||
|
||||
public class ExcelUtil<T>
|
||||
{
|
||||
private static final String EXTENSION_JPG = "JPG";
|
||||
private static final String EXTENSION_PNG = "PNG";
|
||||
private static final String NOTE_PREFIX = "注:";
|
||||
private static final int MAX_COMBO_LENGTH = 15;
|
||||
private static final int MAX_COMBO_STRING_LENGTH = 255;
|
||||
private static final String TARGET_WITH_SEPARATOR = ".";
|
||||
private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
|
||||
|
||||
public static final String FORMULA_REGEX_STR = "=|-|\\+|@";
|
||||
|
|
@ -318,7 +325,7 @@ public class ExcelUtil<T>
|
|||
if (rows > 0)
|
||||
{
|
||||
// 定义一个map用于存放excel列的序号和field.
|
||||
Map<String, Integer> cellMap = new HashMap<String, Integer>();
|
||||
Map<String, Integer> cellMap = new HashMap<String, Integer>(Constants.COMMON_COLLECTION_SIZE);
|
||||
// 获取表头
|
||||
Row heard = sheet.getRow(titleNum);
|
||||
for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++)
|
||||
|
|
@ -336,7 +343,7 @@ public class ExcelUtil<T>
|
|||
}
|
||||
// 有数据时才处理 得到类的所有field.
|
||||
List<Object[]> fields = this.getFields();
|
||||
Map<Integer, Object[]> fieldsMap = new HashMap<Integer, Object[]>();
|
||||
Map<Integer, Object[]> fieldsMap = new HashMap<Integer, Object[]>(Constants.COMMON_COLLECTION_SIZE);
|
||||
for (Object[] objects : fields)
|
||||
{
|
||||
Excel attr = (Excel) objects[1];
|
||||
|
|
@ -367,6 +374,9 @@ public class ExcelUtil<T>
|
|||
Excel attr = (Excel) entry.getValue()[1];
|
||||
// 取得类型,并根据对象类型设置值.
|
||||
Class<?> fieldType = field.getType();
|
||||
boolean isIntegerAndNumeric = (Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val));
|
||||
boolean isLongAndNumeric = (Long.TYPE == fieldType || Long.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val));
|
||||
|
||||
if (String.class == fieldType)
|
||||
{
|
||||
String s = Convert.toStr(val);
|
||||
|
|
@ -387,11 +397,12 @@ public class ExcelUtil<T>
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val)))
|
||||
|
||||
else if (isIntegerAndNumeric)
|
||||
{
|
||||
val = Convert.toInt(val);
|
||||
}
|
||||
else if ((Long.TYPE == fieldType || Long.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val)))
|
||||
else if (isLongAndNumeric)
|
||||
{
|
||||
val = Convert.toLong(val);
|
||||
}
|
||||
|
|
@ -637,7 +648,7 @@ public class ExcelUtil<T>
|
|||
private Map<String, CellStyle> createStyles(Workbook wb)
|
||||
{
|
||||
// 写入各条记录,每条记录对应excel表中的一行
|
||||
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
|
||||
Map<String, CellStyle> styles = new HashMap<String, CellStyle>(Constants.COMMON_COLLECTION_SIZE);
|
||||
CellStyle style = wb.createCellStyle();
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
|
|
@ -691,7 +702,7 @@ public class ExcelUtil<T>
|
|||
*/
|
||||
private Map<String, CellStyle> annotationHeaderStyles(Workbook wb, Map<String, CellStyle> styles)
|
||||
{
|
||||
Map<String, CellStyle> headerStyles = new HashMap<String, CellStyle>();
|
||||
Map<String, CellStyle> headerStyles = new HashMap<String, CellStyle>(Constants.COMMON_COLLECTION_SIZE);
|
||||
for (Object[] os : fields)
|
||||
{
|
||||
Excel excel = (Excel) os[1];
|
||||
|
|
@ -727,7 +738,7 @@ public class ExcelUtil<T>
|
|||
*/
|
||||
private Map<String, CellStyle> annotationDataStyles(Workbook wb)
|
||||
{
|
||||
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
|
||||
Map<String, CellStyle> styles = new HashMap<String, CellStyle>(Constants.COMMON_COLLECTION_SIZE);
|
||||
for (Object[] os : fields)
|
||||
{
|
||||
Field field = (Field) os[0];
|
||||
|
|
@ -822,6 +833,7 @@ public class ExcelUtil<T>
|
|||
*/
|
||||
public void setCellVo(Object value, Excel attr, Cell cell)
|
||||
{
|
||||
final String emptyCollectionString = "[]";
|
||||
if (ColumnType.STRING == attr.cellType() || ColumnType.TEXT == attr.cellType())
|
||||
{
|
||||
String cellValue = Convert.toStr(value);
|
||||
|
|
@ -830,7 +842,7 @@ public class ExcelUtil<T>
|
|||
{
|
||||
cellValue = RegExUtils.replaceFirst(cellValue, FORMULA_REGEX_STR, "\t$0");
|
||||
}
|
||||
if (value instanceof Collection && StringUtils.equals("[]", cellValue))
|
||||
if (value instanceof Collection && StringUtils.equals(emptyCollectionString, cellValue))
|
||||
{
|
||||
cellValue = StringUtils.EMPTY;
|
||||
}
|
||||
|
|
@ -873,12 +885,15 @@ public class ExcelUtil<T>
|
|||
*/
|
||||
public int getImageType(byte[] value)
|
||||
{
|
||||
|
||||
final String extensionJpg = "JPG";
|
||||
final String extensionPng = "PNG";
|
||||
String type = FileTypeUtils.getFileExtendName(value);
|
||||
if ("JPG".equalsIgnoreCase(type))
|
||||
if (extensionJpg.equalsIgnoreCase(type))
|
||||
{
|
||||
return Workbook.PICTURE_TYPE_JPEG;
|
||||
}
|
||||
else if ("PNG".equalsIgnoreCase(type))
|
||||
else if (extensionPng.equalsIgnoreCase(type))
|
||||
{
|
||||
return Workbook.PICTURE_TYPE_PNG;
|
||||
}
|
||||
|
|
@ -890,7 +905,7 @@ public class ExcelUtil<T>
|
|||
*/
|
||||
public void setDataValidation(Excel attr, Row row, int column)
|
||||
{
|
||||
if (attr.name().indexOf("注:") >= 0)
|
||||
if (attr.name().indexOf(NOTE_PREFIX) >= 0)
|
||||
{
|
||||
sheet.setColumnWidth(column, 6000);
|
||||
}
|
||||
|
|
@ -901,7 +916,7 @@ public class ExcelUtil<T>
|
|||
}
|
||||
if (StringUtils.isNotEmpty(attr.prompt()) || attr.combo().length > 0)
|
||||
{
|
||||
if (attr.combo().length > 15 || StringUtils.join(attr.combo()).length() > 255)
|
||||
if (attr.combo().length > MAX_COMBO_LENGTH || StringUtils.join(attr.combo()).length() > MAX_COMBO_STRING_LENGTH)
|
||||
{
|
||||
// 如果下拉数大于15或字符串长度大于255,则使用一个新sheet存储,避免生成的模板下拉值获取不到
|
||||
setXSSFValidationWithHidden(sheet, attr.combo(), attr.prompt(), 1, 100, column, column);
|
||||
|
|
@ -1220,7 +1235,7 @@ public class ExcelUtil<T>
|
|||
if (StringUtils.isNotEmpty(excel.targetAttr()))
|
||||
{
|
||||
String target = excel.targetAttr();
|
||||
if (target.contains("."))
|
||||
if (target.contains(TARGET_WITH_SEPARATOR))
|
||||
{
|
||||
String[] targets = target.split("[.]");
|
||||
for (String name : targets)
|
||||
|
|
@ -1283,7 +1298,9 @@ public class ExcelUtil<T>
|
|||
if (field.isAnnotationPresent(Excel.class))
|
||||
{
|
||||
Excel attr = field.getAnnotation(Excel.class);
|
||||
if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
|
||||
boolean isAttrValidAndMatching = attr != null && (attr.type() == Type.ALL || attr.type() == type);
|
||||
|
||||
if (isAttrValidAndMatching)
|
||||
{
|
||||
field.setAccessible(true);
|
||||
fields.add(new Object[] { field, attr });
|
||||
|
|
@ -1302,10 +1319,12 @@ public class ExcelUtil<T>
|
|||
{
|
||||
Excels attrs = field.getAnnotation(Excels.class);
|
||||
Excel[] excels = attrs.value();
|
||||
|
||||
for (Excel attr : excels)
|
||||
{
|
||||
if (!ArrayUtils.contains(this.excludeFields, field.getName() + "." + attr.targetAttr())
|
||||
&& (attr != null && (attr.type() == Type.ALL || attr.type() == type)))
|
||||
boolean isFieldAndAttrValidAndNotExcluded = !ArrayUtils.contains(this.excludeFields, field.getName() + "." + attr.targetAttr())
|
||||
&& (attr != null && (attr.type() == Type.ALL || attr.type() == type));
|
||||
if (isFieldAndAttrValidAndNotExcluded)
|
||||
{
|
||||
field.setAccessible(true);
|
||||
fields.add(new Object[] { field, attr });
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package com.bonus.common.core.utils.sign;
|
|||
* @author bonus
|
||||
*/
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public final class Base64
|
||||
{
|
||||
static private final int BASELENGTH = 128;
|
||||
|
|
@ -21,15 +22,19 @@ public final class Base64
|
|||
|
||||
static
|
||||
{
|
||||
final char char_Z = 'Z';
|
||||
final char char_A = 'A';
|
||||
final char char_z = 'z';
|
||||
final char char_a = 'a';
|
||||
for (int i = 0; i < BASELENGTH; ++i)
|
||||
{
|
||||
BASE64ALPHABET[i] = -1;
|
||||
}
|
||||
for (int i = 'Z'; i >= 'A'; i--)
|
||||
for (int i = char_Z; i >= char_A; i--)
|
||||
{
|
||||
BASE64ALPHABET[i] = (byte) (i - 'A');
|
||||
}
|
||||
for (int i = 'z'; i >= 'a'; i--)
|
||||
for (int i = char_z; i >= char_a; i--)
|
||||
{
|
||||
BASE64ALPHABET[i] = (byte) (i - 'a' + 26);
|
||||
}
|
||||
|
|
@ -160,6 +165,7 @@ public final class Base64
|
|||
* @param encoded string containing Base64 data
|
||||
* @return Array containind decoded data.
|
||||
*/
|
||||
@SuppressWarnings("AlibabaUndefineMagicConstant")
|
||||
public static byte[] decode(String encoded)
|
||||
{
|
||||
if (encoded == null)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import java.security.SecureRandom;
|
|||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import com.bonus.common.core.exception.UtilException;
|
||||
import java.lang.StringBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* 提供通用唯一识别码(universally unique identifier)(UUID)实现
|
||||
|
|
@ -39,16 +41,18 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
|
|||
*/
|
||||
private UUID(byte[] data)
|
||||
{
|
||||
final int byteGroupSize = 8;
|
||||
final int totalBytes = 16;
|
||||
long msb = 0;
|
||||
long lsb = 0;
|
||||
assert data.length == 16 : "data must be 16 bytes in length";
|
||||
for (int i = 0; i < 8; i++)
|
||||
for (int i = 0; i < byteGroupSize; i++)
|
||||
{
|
||||
msb = (msb << 8) | (data[i] & 0xff);
|
||||
msb = (msb << byteGroupSize) | (data[i] & 0xff);
|
||||
}
|
||||
for (int i = 8; i < 16; i++)
|
||||
for (int i = byteGroupSize; i < totalBytes; i++)
|
||||
{
|
||||
lsb = (lsb << 8) | (data[i] & 0xff);
|
||||
lsb = (lsb << byteGroupSize) | (data[i] & 0xff);
|
||||
}
|
||||
this.mostSigBits = msb;
|
||||
this.leastSigBits = lsb;
|
||||
|
|
@ -155,13 +159,14 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
|
|||
public static UUID fromString(String name)
|
||||
{
|
||||
String[] components = name.split("-");
|
||||
if (components.length != 5)
|
||||
final int componentsLength = 5;
|
||||
if (components.length != componentsLength)
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid UUID string: " + name);
|
||||
}
|
||||
for (int i = 0; i < 5; i++)
|
||||
for (int i = 0; i < componentsLength; i++)
|
||||
{
|
||||
components[i] = "0x" + components[i];
|
||||
components[i] = new StringBuilder("0x").append(components[i]).toString();
|
||||
}
|
||||
|
||||
long mostSigBits = Long.decode(components[0]).longValue();
|
||||
|
|
@ -255,8 +260,8 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
|
|||
public long timestamp() throws UnsupportedOperationException
|
||||
{
|
||||
checkTimeBase();
|
||||
return (mostSigBits & 0x0FFFL) << 48//
|
||||
| ((mostSigBits >> 16) & 0x0FFFFL) << 32//
|
||||
return (mostSigBits & 0x0FFFL) << 48
|
||||
| ((mostSigBits >> 16) & 0x0FFFFL) << 32
|
||||
| mostSigBits >>> 32;
|
||||
}
|
||||
|
||||
|
|
@ -435,10 +440,10 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
|
|||
{
|
||||
// The ordering is intentionally set up so that the UUIDs
|
||||
// can simply be numerically compared as two numbers
|
||||
return (this.mostSigBits < val.mostSigBits ? -1 : //
|
||||
(this.mostSigBits > val.mostSigBits ? 1 : //
|
||||
(this.leastSigBits < val.leastSigBits ? -1 : //
|
||||
(this.leastSigBits > val.leastSigBits ? 1 : //
|
||||
return (this.mostSigBits < val.mostSigBits ? -1 :
|
||||
(this.mostSigBits > val.mostSigBits ? 1 :
|
||||
(this.leastSigBits < val.leastSigBits ? -1 :
|
||||
(this.leastSigBits > val.leastSigBits ? 1 :
|
||||
0))));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,14 +71,16 @@ public class PageDomain
|
|||
|
||||
public void setIsAsc(String isAsc)
|
||||
{
|
||||
final String ascendingOrder = "ascending";
|
||||
final String descendingOrder = "descending";
|
||||
if (StringUtils.isNotEmpty(isAsc))
|
||||
{
|
||||
// 兼容前端排序类型
|
||||
if ("ascending".equals(isAsc))
|
||||
if (ascendingOrder.equals(isAsc))
|
||||
{
|
||||
isAsc = "asc";
|
||||
}
|
||||
else if ("descending".equals(isAsc))
|
||||
else if (descendingOrder.equals(isAsc))
|
||||
{
|
||||
isAsc = "desc";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,21 +4,21 @@ package com.bonus.common.security.config;
|
|||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.global.SystemGlobal;
|
||||
import com.bonus.common.security.interceptor.ReadHttpRequestWrapper;
|
||||
import jdk.nashorn.internal.runtime.PropertyDescriptor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
import static cn.hutool.http.Method.POST;
|
||||
import static jdk.nashorn.internal.runtime.PropertyDescriptor.GET;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author bonus
|
||||
*/
|
||||
@Component
|
||||
@WebFilter("/*")
|
||||
public class MyFilter extends OncePerRequestFilter {
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -47,6 +47,8 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
|||
@Override
|
||||
public AjaxResult createCaptcha() throws IOException, CaptchaException
|
||||
{
|
||||
final String mathCaptchaType = "math";
|
||||
final String charCaptchaType = "char";
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
boolean captchaEnabled = captchaProperties.getEnabled();
|
||||
ajax.put("captchaEnabled", captchaEnabled);
|
||||
|
|
@ -64,14 +66,14 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
|||
|
||||
String captchaType = captchaProperties.getType();
|
||||
// 生成验证码
|
||||
if ("math".equals(captchaType))
|
||||
if (mathCaptchaType.equals(captchaType))
|
||||
{
|
||||
String capText = captchaProducerMath.createText();
|
||||
capStr = capText.substring(0, capText.lastIndexOf("@"));
|
||||
code = capText.substring(capText.lastIndexOf("@") + 1);
|
||||
image = captchaProducerMath.createImage(capStr);
|
||||
}
|
||||
else if ("char".equals(captchaType))
|
||||
else if (charCaptchaType.equals(captchaType))
|
||||
{
|
||||
capStr = code = captchaProducer.createText();
|
||||
image = captchaProducer.createImage(capStr);
|
||||
|
|
|
|||
|
|
@ -18,10 +18,23 @@ public interface ISysFileService
|
|||
*/
|
||||
public String uploadFile(MultipartFile file) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 从给定的URL下载文件并将其保存到指定的目标位置。
|
||||
*
|
||||
* @param urlStr 要下载文件的URL地址。
|
||||
* @param destination 文件下载后保存的本地文件系统路径。
|
||||
* @return 布尔值,指示下载是否成功。成功返回true,失败返回false。
|
||||
* @throws Exception 如果在下载过程中遇到任何异常,例如网络问题、文件写入问题等。
|
||||
*/
|
||||
public boolean downloadFile(String urlStr, String destination) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 删除指定URL所指向的文件。
|
||||
*
|
||||
* @param urlStr 要删除文件的URL地址。
|
||||
* @return 布尔值,指示文件删除是否成功。如果文件被成功删除,则返回true;否则返回false。
|
||||
* @throws Exception 如果在删除文件的过程中遇到错误,例如网络问题、文件不存在或没有删除权限等。
|
||||
*/
|
||||
public boolean deleteFile(String urlStr) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@ import java.net.URL;
|
|||
import org.apache.commons.net.ftp.FTP;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
|
||||
/**
|
||||
* 。
|
||||
*
|
||||
* @author weiwei
|
||||
*/
|
||||
public class FileDownloadUtils {
|
||||
|
||||
private final static String HTTP_START_STR = "http://";
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import com.bonus.gen.domain.GenTable;
|
|||
import com.bonus.gen.domain.GenTableColumn;
|
||||
import com.bonus.gen.service.IGenTableColumnService;
|
||||
import com.bonus.gen.service.IGenTableService;
|
||||
|
||||
import com.bonus.common.core.constant.Constants;
|
||||
/**
|
||||
* 代码生成 操作处理
|
||||
*
|
||||
|
|
@ -67,7 +67,7 @@ public class GenController extends BaseController
|
|||
GenTable table = genTableService.selectGenTableById(tableId);
|
||||
List<GenTable> tables = genTableService.selectGenTableAll();
|
||||
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<String, Object>(Constants.COMMON_COLLECTION_SIZE);
|
||||
map.put("info", table);
|
||||
map.put("rows", list);
|
||||
map.put("tables", tables);
|
||||
|
|
|
|||
|
|
@ -297,10 +297,15 @@ public class GenTableServiceImpl implements IGenTableService
|
|||
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
||||
|
||||
dbTableColumns.forEach(column -> {
|
||||
|
||||
GenUtils.initColumnField(column, table);
|
||||
if (tableColumnMap.containsKey(column.getColumnName()))
|
||||
{
|
||||
GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName());
|
||||
boolean shouldPreserveColumnSettings = StringUtils.isNotEmpty(prevColumn.getIsRequired())
|
||||
&& !column.isPk()
|
||||
&& (column.isInsert() || column.isEdit())
|
||||
&& ((column.isUsableColumn()) || (!column.isSuperColumn()));
|
||||
column.setColumnId(prevColumn.getColumnId());
|
||||
if (column.isList())
|
||||
{
|
||||
|
|
@ -308,9 +313,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||
column.setDictType(prevColumn.getDictType());
|
||||
column.setQueryType(prevColumn.getQueryType());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk()
|
||||
&& (column.isInsert() || column.isEdit())
|
||||
&& ((column.isUsableColumn()) || (!column.isSuperColumn())))
|
||||
if (shouldPreserveColumnSettings)
|
||||
{
|
||||
// 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项
|
||||
column.setIsRequired(prevColumn.getIsRequired());
|
||||
|
|
@ -511,8 +514,9 @@ public class GenTableServiceImpl implements IGenTableService
|
|||
*/
|
||||
public static String getGenPath(GenTable table, String template)
|
||||
{
|
||||
final String slash = "/";
|
||||
String genPath = table.getGenPath();
|
||||
if (StringUtils.equals(genPath, "/"))
|
||||
if (StringUtils.equals(genPath, slash))
|
||||
{
|
||||
return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public class GenUtils
|
|||
/**
|
||||
* 初始化表信息
|
||||
*/
|
||||
public static final String PARENTHESIS= "(";
|
||||
public static void initTable(GenTable genTable, String operName)
|
||||
{
|
||||
genTable.setClassName(convertClassName(genTable.getTableName()));
|
||||
|
|
@ -34,6 +35,13 @@ public class GenUtils
|
|||
*/
|
||||
public static void initColumnField(GenTableColumn column, GenTable table)
|
||||
{
|
||||
final String suffixName = "name";
|
||||
final String suffixStatus = "status";
|
||||
final String suffixType = "type";
|
||||
final String suffixSex = "sex";
|
||||
final String suffixImage = "image";
|
||||
final String suffixFile = "file";
|
||||
final String suffixContent = "content";
|
||||
String dataType = getDbType(column.getColumnType());
|
||||
String columnName = column.getColumnName();
|
||||
column.setTableId(table.getTableId());
|
||||
|
|
@ -98,33 +106,33 @@ public class GenUtils
|
|||
}
|
||||
|
||||
// 查询字段类型
|
||||
if (StringUtils.endsWithIgnoreCase(columnName, "name"))
|
||||
if (StringUtils.endsWithIgnoreCase(columnName, suffixName))
|
||||
{
|
||||
column.setQueryType(GenConstants.QUERY_LIKE);
|
||||
}
|
||||
// 状态字段设置单选框
|
||||
if (StringUtils.endsWithIgnoreCase(columnName, "status"))
|
||||
if (StringUtils.endsWithIgnoreCase(columnName, suffixStatus))
|
||||
{
|
||||
column.setHtmlType(GenConstants.HTML_RADIO);
|
||||
}
|
||||
// 类型&性别字段设置下拉框
|
||||
else if (StringUtils.endsWithIgnoreCase(columnName, "type")
|
||||
|| StringUtils.endsWithIgnoreCase(columnName, "sex"))
|
||||
else if (StringUtils.endsWithIgnoreCase(columnName, suffixType)
|
||||
|| StringUtils.endsWithIgnoreCase(columnName, suffixSex))
|
||||
{
|
||||
column.setHtmlType(GenConstants.HTML_SELECT);
|
||||
}
|
||||
// 图片字段设置图片上传控件
|
||||
else if (StringUtils.endsWithIgnoreCase(columnName, "image"))
|
||||
else if (StringUtils.endsWithIgnoreCase(columnName, suffixImage))
|
||||
{
|
||||
column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD);
|
||||
}
|
||||
// 文件字段设置文件上传控件
|
||||
else if (StringUtils.endsWithIgnoreCase(columnName, "file"))
|
||||
else if (StringUtils.endsWithIgnoreCase(columnName, suffixFile))
|
||||
{
|
||||
column.setHtmlType(GenConstants.HTML_FILE_UPLOAD);
|
||||
}
|
||||
// 内容字段设置富文本控件
|
||||
else if (StringUtils.endsWithIgnoreCase(columnName, "content"))
|
||||
else if (StringUtils.endsWithIgnoreCase(columnName, suffixContent))
|
||||
{
|
||||
column.setHtmlType(GenConstants.HTML_EDITOR);
|
||||
}
|
||||
|
|
@ -226,9 +234,9 @@ public class GenUtils
|
|||
*/
|
||||
public static String getDbType(String columnType)
|
||||
{
|
||||
if (StringUtils.indexOf(columnType, "(") > 0)
|
||||
if (StringUtils.indexOf(columnType, PARENTHESIS) > 0)
|
||||
{
|
||||
return StringUtils.substringBefore(columnType, "(");
|
||||
return StringUtils.substringBefore(columnType, PARENTHESIS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -244,7 +252,7 @@ public class GenUtils
|
|||
*/
|
||||
public static Integer getColumnLength(String columnType)
|
||||
{
|
||||
if (StringUtils.indexOf(columnType, "(") > 0)
|
||||
if (StringUtils.indexOf(columnType,PARENTHESIS) > 0)
|
||||
{
|
||||
String length = StringUtils.substringBetween(columnType, "(", ")");
|
||||
return Integer.valueOf(length);
|
||||
|
|
|
|||
|
|
@ -130,7 +130,8 @@ public class VelocityUtils
|
|||
public static List<String> getTemplateList(String tplCategory, String tplWebType)
|
||||
{
|
||||
String useWebType = "vm/vue";
|
||||
if ("element-plus".equals(tplWebType))
|
||||
final String elementPlusTplType = "element-plus";
|
||||
if (elementPlusTplType.equals(tplWebType))
|
||||
{
|
||||
useWebType = "vm/vue/v3";
|
||||
}
|
||||
|
|
@ -175,51 +176,64 @@ public class VelocityUtils
|
|||
// 业务名称
|
||||
String businessName = genTable.getBusinessName();
|
||||
|
||||
// 模板文件名常量,用于根据不同的模板生成不同的文件名
|
||||
String domainJavaVmTemplate = "domain.java.vm";
|
||||
String subDomainJavaVmTemplate = "sub-domain.java.vm";
|
||||
String mapperJavaVmTemplate = "mapper.java.vm";
|
||||
String serviceJavaVmTemplate = "service.java.vm";
|
||||
String serviceImplJavaVmTemplate = "serviceImpl.java.vm";
|
||||
String controllerJavaVmTemplate = "controller.java.vm";
|
||||
String mapperXmlVmTemplate = "mapper.xml.vm";
|
||||
String sqlVmTemplate = "sql.vm";
|
||||
String apiJsVmTemplate = "api.js.vm";
|
||||
String indexVueVmTemplate = "index.vue.vm";
|
||||
String indexTreeVueVmTemplate = "index-tree.vue.vm";
|
||||
|
||||
String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
|
||||
String mybatisPath = MYBATIS_PATH + "/" + moduleName;
|
||||
String vuePath = "vue";
|
||||
|
||||
if (template.contains("domain.java.vm"))
|
||||
if (template.contains(domainJavaVmTemplate))
|
||||
{
|
||||
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
|
||||
}
|
||||
if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
|
||||
if (template.contains(subDomainJavaVmTemplate) && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
|
||||
{
|
||||
fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
|
||||
}
|
||||
else if (template.contains("mapper.java.vm"))
|
||||
else if (template.contains(mapperJavaVmTemplate))
|
||||
{
|
||||
fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
|
||||
}
|
||||
else if (template.contains("service.java.vm"))
|
||||
else if (template.contains(serviceJavaVmTemplate))
|
||||
{
|
||||
fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className);
|
||||
}
|
||||
else if (template.contains("serviceImpl.java.vm"))
|
||||
else if (template.contains(serviceImplJavaVmTemplate))
|
||||
{
|
||||
fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
|
||||
}
|
||||
else if (template.contains("controller.java.vm"))
|
||||
else if (template.contains(controllerJavaVmTemplate))
|
||||
{
|
||||
fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
|
||||
}
|
||||
else if (template.contains("mapper.xml.vm"))
|
||||
else if (template.contains(mapperXmlVmTemplate))
|
||||
{
|
||||
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
|
||||
}
|
||||
else if (template.contains("sql.vm"))
|
||||
else if (template.contains(sqlVmTemplate))
|
||||
{
|
||||
fileName = businessName + "Menu.sql";
|
||||
}
|
||||
else if (template.contains("api.js.vm"))
|
||||
else if (template.contains(apiJsVmTemplate))
|
||||
{
|
||||
fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
|
||||
}
|
||||
else if (template.contains("index.vue.vm"))
|
||||
else if (template.contains(indexVueVmTemplate))
|
||||
{
|
||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||
}
|
||||
else if (template.contains("index-tree.vue.vm"))
|
||||
else if (template.contains(indexTreeVueVmTemplate))
|
||||
{
|
||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,97 +6,106 @@ import com.bonus.common.core.exception.job.TaskException;
|
|||
import com.bonus.job.domain.SysJob;
|
||||
|
||||
/**
|
||||
* 定时任务调度信息信息 服务层
|
||||
*
|
||||
* 定时任务调度信息服务层接口,提供定时任务的管理和操作功能。
|
||||
*
|
||||
* @author bonus
|
||||
*/
|
||||
public interface ISysJobService
|
||||
{
|
||||
/**
|
||||
* 获取quartz调度器的计划任务
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 调度任务集合
|
||||
*/
|
||||
public List<SysJob> selectJobList(SysJob job);
|
||||
public interface ISysJobService {
|
||||
|
||||
/**
|
||||
* 通过调度任务ID查询调度信息
|
||||
*
|
||||
* @param jobId 调度任务ID
|
||||
* @return 调度任务对象信息
|
||||
* 获取quartz调度器的计划任务列表。
|
||||
*
|
||||
* @param job 查询条件,可以为null。
|
||||
* @return 返回符合条件的调度任务集合。
|
||||
*/
|
||||
public SysJob selectJobById(Long jobId);
|
||||
List<SysJob> selectJobList(SysJob job);
|
||||
|
||||
/**
|
||||
* 暂停任务
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 结果
|
||||
* 通过调度任务ID查询调度任务详细信息。
|
||||
*
|
||||
* @param jobId 调度任务ID。
|
||||
* @return 返回对应的调度任务对象,如果没有找到则返回null。
|
||||
*/
|
||||
public int pauseJob(SysJob job) throws SchedulerException;
|
||||
SysJob selectJobById(Long jobId);
|
||||
|
||||
/**
|
||||
* 恢复任务
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 结果
|
||||
* 暂停指定的调度任务。
|
||||
*
|
||||
* @param job 要暂停的调度任务信息。
|
||||
* @return 返回操作结果,成功返回1,失败返回0。
|
||||
* @throws SchedulerException 如果调度器操作失败。
|
||||
*/
|
||||
public int resumeJob(SysJob job) throws SchedulerException;
|
||||
int pauseJob(SysJob job) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 删除任务后,所对应的trigger也将被删除
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 结果
|
||||
* 恢复指定的调度任务。
|
||||
*
|
||||
* @param job 要恢复的调度任务信息。
|
||||
* @return 返回操作结果,成功返回1,失败返回0。
|
||||
* @throws SchedulerException 如果调度器操作失败。
|
||||
*/
|
||||
public int deleteJob(SysJob job) throws SchedulerException;
|
||||
int resumeJob(SysJob job) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 批量删除调度信息
|
||||
*
|
||||
* @param jobIds 需要删除的任务ID
|
||||
* @return 结果
|
||||
* 删除指定的调度任务以及其对应的触发器。
|
||||
*
|
||||
* @param job 要删除的调度任务信息。
|
||||
* @return 返回操作结果,成功返回1,失败返回0。
|
||||
* @throws SchedulerException 如果调度器操作失败。
|
||||
*/
|
||||
public void deleteJobByIds(Long[] jobIds) throws SchedulerException;
|
||||
int deleteJob(SysJob job) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 任务调度状态修改
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 结果
|
||||
* 批量删除指定的调度任务。
|
||||
*
|
||||
* @param jobIds 要删除的任务ID数组。
|
||||
* @throws SchedulerException 如果调度器操作失败。
|
||||
*/
|
||||
public int changeStatus(SysJob job) throws SchedulerException;
|
||||
void deleteJobByIds(Long[] jobIds) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 立即运行任务
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 结果
|
||||
* 修改调度任务的状态。
|
||||
*
|
||||
* @param job 包含新状态的调度任务信息。
|
||||
* @return 返回操作结果,成功返回1,失败返回0。
|
||||
* @throws SchedulerException 如果调度器操作失败。
|
||||
*/
|
||||
public boolean run(SysJob job) throws SchedulerException;
|
||||
int changeStatus(SysJob job) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 新增任务
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 结果
|
||||
* 立即执行指定的调度任务。
|
||||
*
|
||||
* @param job 要立即执行的调度任务信息。
|
||||
* @return 返回操作结果,成功返回true,失败返回false。
|
||||
* @throws SchedulerException 如果调度器操作失败。
|
||||
*/
|
||||
public int insertJob(SysJob job) throws SchedulerException, TaskException;
|
||||
boolean run(SysJob job) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 更新任务
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 结果
|
||||
* 新增一个调度任务。
|
||||
*
|
||||
* @param job 要新增的调度任务信息。
|
||||
* @return 返回操作结果,成功返回1,失败返回0。
|
||||
* @throws SchedulerException 如果调度器操作失败。
|
||||
* @throws TaskException 如果任务相关的错误发生。
|
||||
*/
|
||||
public int updateJob(SysJob job) throws SchedulerException, TaskException;
|
||||
int insertJob(SysJob job) throws SchedulerException, TaskException;
|
||||
|
||||
/**
|
||||
* 校验cron表达式是否有效
|
||||
*
|
||||
* @param cronExpression 表达式
|
||||
* @return 结果
|
||||
* 更新现有的调度任务。
|
||||
*
|
||||
* @param job 包含更新信息的调度任务对象。
|
||||
* @return 返回操作结果,成功返回1,失败返回0。
|
||||
* @throws SchedulerException 如果调度器操作失败。
|
||||
* @throws TaskException 如果任务相关的错误发生。
|
||||
*/
|
||||
public boolean checkCronExpressionIsValid(String cronExpression);
|
||||
int updateJob(SysJob job) throws SchedulerException, TaskException;
|
||||
|
||||
/**
|
||||
* 校验给定的cron表达式是否有效。
|
||||
*
|
||||
* @param cronExpression 要校验的cron表达式。
|
||||
* @return 如果cron表达式有效则返回true,否则返回false。
|
||||
*/
|
||||
boolean checkCronExpressionIsValid(String cronExpression);
|
||||
}
|
||||
|
|
@ -5,6 +5,11 @@ import org.springframework.boot.SpringApplication;
|
|||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* 。
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@EnableCustomSwagger2
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
|
||||
public class BonusMongodbApplication {
|
||||
|
|
|
|||
|
|
@ -33,10 +33,15 @@ public class MongoConfig {
|
|||
private String username;
|
||||
private String password;
|
||||
|
||||
// 移除静态修饰符,避免单例模式
|
||||
/**移除静态修饰符,避免单例模式
|
||||
*
|
||||
*/
|
||||
private MongoClient mongoClient;
|
||||
|
||||
// 使用@Bean注解,并在方法内部进行异常处理
|
||||
/** 使用@Bean注解,并在方法内部进行异常处理
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public MongoClient getMongoClient() {
|
||||
if (mongoClient == null) {
|
||||
|
|
@ -50,12 +55,18 @@ public class MongoConfig {
|
|||
return mongoClient;
|
||||
}
|
||||
|
||||
// 直接返回MongoDatabase实例,依赖注入会处理实例的获取
|
||||
/** 直接返回MongoDatabase实例,依赖注入会处理实例的获取
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public MongoDatabase getMongoDatabase() {
|
||||
return getMongoClient().getDatabase(database);
|
||||
}
|
||||
|
||||
// 创建GridFSBucket的@Bean方法,依赖注入MongoDatabase
|
||||
/** 创建GridFSBucket的@Bean方法,依赖注入MongoDatabase
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public GridFSBucket getGridFsBucket() {
|
||||
return GridFSBuckets.create(getMongoDatabase());
|
||||
|
|
|
|||
|
|
@ -15,6 +15,11 @@ import javax.annotation.Resource;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 。
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/mongodb/")
|
||||
@Slf4j
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ import java.util.Objects;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 。
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@Data
|
||||
public class FileExportVo implements Serializable {
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ import lombok.Data;
|
|||
import org.bson.types.Binary;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
/**
|
||||
* 。
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@Document(collection = "files")
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ package com.bonus.mongodb.repository;
|
|||
import com.bonus.mongodb.damain.MongoFile;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
/**
|
||||
* 。
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
public interface MongoFileRepository extends MongoRepository<MongoFile, String> {
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,11 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 。
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
public interface MongodbService {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 。
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class MongodbServiceImpl implements MongodbService {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ import org.springframework.boot.SpringApplication;
|
|||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* 。
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@EnableCustomSwagger2
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
|
||||
public class BonusObsApplication {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 。
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "obs")
|
||||
public class ObsConfig {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@ import java.net.URLEncoder;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 。
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/obs")
|
||||
public class ObsController {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import lombok.Data;
|
|||
/**
|
||||
* OBS(Object Storage Service)信息类。
|
||||
* 用于封装与OBS对象相关的元数据信息。
|
||||
* @author jiang
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
public interface ObsService {
|
||||
/**
|
||||
* 文件上传
|
||||
|
|
@ -22,6 +27,7 @@ public interface ObsService {
|
|||
* 删除文件从OBS
|
||||
*
|
||||
* @param objectKey 文件在OBS中的键
|
||||
* @return 返回一个包含删除操作结果的响应对象。
|
||||
*/
|
||||
public R<DeleteObjectResult> deleteFile(String objectKey);
|
||||
|
||||
|
|
@ -29,6 +35,7 @@ public interface ObsService {
|
|||
* 下载文件从OBS
|
||||
*
|
||||
* @param objectKey 文件在OBS中的键
|
||||
* @return 返回下载文件的结果
|
||||
*/
|
||||
public R<ObsObject> downloadFile(String objectKey);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,11 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@Service
|
||||
public class ObsServiceImpl implements ObsService {
|
||||
@Resource
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.net.URLConnection;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@Service
|
||||
public class ObsUtils {
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ import org.springframework.boot.SpringApplication;
|
|||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* 。
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@EnableCustomSwagger2
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
|
||||
public class BonusOssApplication {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.springframework.context.annotation.Configuration;
|
|||
* 使用@ConfigurationProperties注解将类绑定到配置文件中以oss为前缀的属性上。
|
||||
* 使用@Configuration注解将此类标记为一个配置类,它会被Spring Boot自动检测并用于配置上下文。
|
||||
* 使用@Data注解来自动生成getter和setter方法,简化了属性访问。
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "oss")
|
||||
|
|
|
|||
|
|
@ -23,7 +23,11 @@ import java.io.UnsupportedEncodingException;
|
|||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/oss")
|
||||
|
|
@ -68,7 +72,8 @@ public class OssController {
|
|||
}
|
||||
|
||||
OSSObject ossObject = ossObjectR.getData();
|
||||
String safeFileName = FileUtils.getName(objectKey); // 假设这个方法进行了恰当的文件名清理和验证
|
||||
// 假设这个方法进行了恰当的文件名清理和验证
|
||||
String safeFileName = FileUtils.getName(objectKey);
|
||||
if (!StringUtils.hasText(safeFileName)) {
|
||||
response.setStatus(HttpStatus.BAD_REQUEST.value());
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import lombok.Data;
|
|||
/**
|
||||
* OssInfo类用于封装OSS(Object Storage Service)对象的相关信息。
|
||||
* 通过此类,可以方便地管理和访问OSS对象的元数据,如名称、路径、大小等。
|
||||
*
|
||||
*
|
||||
* @author jiang
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jiang
|
||||
*/
|
||||
public interface OssService {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author jiang
|
||||
*/
|
||||
@Service
|
||||
public class OssServiceImpl implements OssService {
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.util.concurrent.Future;
|
|||
|
||||
/**
|
||||
* OSS存储服务类
|
||||
* @author jiang
|
||||
*/
|
||||
@Service
|
||||
public class OssUtils {
|
||||
|
|
@ -56,8 +57,9 @@ public class OssUtils {
|
|||
* @return 包含上传文件信息的结果对象
|
||||
*/
|
||||
public R<OssInfo> upload(String objectKey, File file) {
|
||||
final long tenMegabytes = 10 * 1024 * 1024L;
|
||||
try {
|
||||
if (file.length() < 10 * 1024 * 1024L) {
|
||||
if (file.length() < tenMegabytes) {
|
||||
ossClient.putObject(ossConfig.getBucket(), objectKey, file);
|
||||
} else {
|
||||
ossMultipartParallelUpload(objectKey, file);
|
||||
|
|
|
|||
|
|
@ -157,7 +157,9 @@ public class SysUserController extends BaseController
|
|||
public R<Boolean> register(@RequestBody SysUser sysUser)
|
||||
{
|
||||
String username = sysUser.getUserName();
|
||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
|
||||
final String stringTrue = "true";
|
||||
final String configKeyRegisterUser = "sys.account.registerUser";
|
||||
if (!(stringTrue.equals(configService.selectConfigByKey(configKeyRegisterUser))))
|
||||
{
|
||||
return R.fail("当前系统没有开启注册功能!");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import lombok.Data;
|
|||
|
||||
/**
|
||||
* 日志菜单头
|
||||
* @author weiweiw
|
||||
*/
|
||||
@Data
|
||||
public class SysLogsMenuHead {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public interface SysLogininforMapper
|
|||
* 新增系统登录日志
|
||||
*
|
||||
* @param logininfor 访问日志对象
|
||||
* @return 新增日志是否成功
|
||||
*/
|
||||
public int insertLogininfor(SysLogininfor logininfor);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public interface SysOperLogMapper
|
|||
* 新增操作日志
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
* @return 插入结果
|
||||
*/
|
||||
public int insertOperlog(SysOperLog operLog);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public interface ISysLogininforService
|
|||
* 新增系统登录日志
|
||||
*
|
||||
* @param logininfor 访问日志对象
|
||||
* @return 返回插入操作的影响行数。
|
||||
*/
|
||||
public int insertLogininfor(SysLogininfor logininfor);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import com.bonus.common.log.enums.OperaType;
|
|||
import com.bonus.system.api.domain.SysLogsVo;
|
||||
import com.bonus.system.domain.SysLogsMenuHead;
|
||||
import com.bonus.system.domain.SysMenu;
|
||||
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
||||
//import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -31,6 +31,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService
|
|||
{
|
||||
@Resource
|
||||
private SysOperLogMapper operLogMapper;
|
||||
public static final String MENU_TYPE_FILE = "F";
|
||||
|
||||
/**
|
||||
* 新增操作日志
|
||||
|
|
@ -128,7 +129,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService
|
|||
sbAppend(sb);
|
||||
sb.append(vo.getMenuName2());
|
||||
}
|
||||
if("F".equals(type)){
|
||||
if( MENU_TYPE_FILE .equals(type)){
|
||||
if(vo.getMenuName().contains(OperaType.INSERT)){
|
||||
maps.put("bussType",OperaType.INSERT);
|
||||
}else if(vo.getMenuName().contains(OperaType.UPDATE)){
|
||||
|
|
|
|||
Loading…
Reference in New Issue