修改bug
This commit is contained in:
parent
fdd2ca4a78
commit
b9253786ce
|
|
@ -0,0 +1,63 @@
|
||||||
|
|
||||||
|
package com.ebts.common.utils.md5;
|
||||||
|
|
||||||
|
import com.google.common.primitives.Bytes;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Byte工具
|
||||||
|
*
|
||||||
|
* @author yinzhennan
|
||||||
|
* @version V1.0
|
||||||
|
* @since 2020-08-27 09:28
|
||||||
|
*/
|
||||||
|
public class BytesUtils {
|
||||||
|
|
||||||
|
public static final int FF = 0xFF;
|
||||||
|
|
||||||
|
public static byte[] long2bytes(long v) {
|
||||||
|
byte[] ret = new byte[]{0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
long2bytes(v, ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] trim(byte[] bytes) {
|
||||||
|
LinkedList<Byte> linkedList = new LinkedList<>(Bytes.asList(bytes));
|
||||||
|
while(linkedList.getFirst() == 0){
|
||||||
|
linkedList.remove(0);
|
||||||
|
}
|
||||||
|
return Bytes.toArray(linkedList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long bytes2Long(byte[] input){
|
||||||
|
final int size = input.length;
|
||||||
|
if(size > 8){
|
||||||
|
throw new IllegalArgumentException("输入参数最多8位");
|
||||||
|
}
|
||||||
|
int unsigned = input[0] & FF;
|
||||||
|
long value = 0;
|
||||||
|
value = value | unsigned;
|
||||||
|
// 循环读取每个字节通过移位运算完成long的8个字节拼装
|
||||||
|
for(int i=1;i< size;++i){
|
||||||
|
unsigned = input[i] & FF;
|
||||||
|
value = value << 8 | unsigned;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void long2bytes(long v, byte[] b) {
|
||||||
|
long2bytes(v, b, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void long2bytes(long v, byte[] b, int off) {
|
||||||
|
b[off + 7] = (byte)((int)v);
|
||||||
|
b[off + 6] = (byte)((int)(v >>> 8));
|
||||||
|
b[off + 5] = (byte)((int)(v >>> 16));
|
||||||
|
b[off + 4] = (byte)((int)(v >>> 24));
|
||||||
|
b[off + 3] = (byte)((int)(v >>> 32));
|
||||||
|
b[off + 2] = (byte)((int)(v >>> 40));
|
||||||
|
b[off + 1] = (byte)((int)(v >>> 48));
|
||||||
|
b[off + 0] = (byte)((int)(v >>> 56));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.ebts.common.utils.md5;
|
||||||
|
|
||||||
|
import com.ebts.common.config.MD5Config;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.springframework.util.DigestUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Clay
|
||||||
|
* @date: 2022/1/5 15:07
|
||||||
|
* @description:IdObfuscator
|
||||||
|
* @email: clay@hchyun.com
|
||||||
|
*/
|
||||||
|
public class Md5Obfuscator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验等级 1-16,等级越高,密级越高(没什么卵用),encode结果越长
|
||||||
|
*/
|
||||||
|
private static final int VALID_LEVEL = 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编码
|
||||||
|
*/
|
||||||
|
public static String encode(String id){
|
||||||
|
byte[] idBytes;
|
||||||
|
if (id == null| "".equals(id)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
idBytes = BytesUtils.long2bytes(Long.parseLong(id));
|
||||||
|
}catch (Exception e){
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
idBytes = BytesUtils.trim(idBytes);
|
||||||
|
final byte[] md5 = DigestUtils.md5Digest(ArrayUtils.addAll(idBytes, MD5Config.getSecretKey().getBytes()));
|
||||||
|
final byte[] combine = ArrayUtils.addAll(Arrays.copyOf(md5, VALID_LEVEL), idBytes);
|
||||||
|
return Base64.getUrlEncoder().encodeToString(combine).replaceAll("=", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解码
|
||||||
|
*/
|
||||||
|
public static String decode(String raw){
|
||||||
|
if (raw == null | "".equals(raw)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final byte[] bytes = Base64.getUrlDecoder().decode(raw);
|
||||||
|
final byte[] md5ValidBytes = Arrays.copyOfRange(bytes, 0, VALID_LEVEL);
|
||||||
|
final byte[] idBytes = Arrays.copyOfRange(bytes, VALID_LEVEL, bytes.length);
|
||||||
|
//验证
|
||||||
|
final byte[] md5 = DigestUtils.md5Digest(ArrayUtils.addAll(idBytes, MD5Config.getSecretKey().getBytes()));
|
||||||
|
for (int i = 0; i < md5ValidBytes.length; i++) {
|
||||||
|
if (md5ValidBytes[i] != md5[i]){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.valueOf(BytesUtils.bytes2Long(idBytes));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -60,7 +60,7 @@ public class ${ClassName}Controller extends EBTSController {
|
||||||
@ApiOperation("查询${functionName}列表")
|
@ApiOperation("查询${functionName}列表")
|
||||||
@PreAuthorize("@ebts.hasPermi('${permissionPrefix}:list')")
|
@PreAuthorize("@ebts.hasPermi('${permissionPrefix}:list')")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public Serializable list(@Validated @RequestBody ${ClassName} ${className}) {
|
public Serializable list(@RequestBody ${ClassName} ${className}) {
|
||||||
startPage(${className}.getPageInfo());
|
startPage(${className}.getPageInfo());
|
||||||
ServerResult<List<${ClassName}>> genServerResult = ${className}Service.select${ClassName}List(${className});
|
ServerResult<List<${ClassName}>> genServerResult = ${className}Service.select${ClassName}List(${className});
|
||||||
if (genServerResult.isStart()) {
|
if (genServerResult.isStart()) {
|
||||||
|
|
@ -81,7 +81,7 @@ public class ${ClassName}Controller extends EBTSController {
|
||||||
@PreAuthorize("@ebts.hasPermi('${permissionPrefix}:export')")
|
@PreAuthorize("@ebts.hasPermi('${permissionPrefix}:export')")
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public AjaxResult export(@Validated @RequestBody ${ClassName} ${className}) {
|
public AjaxResult export(@RequestBody ${ClassName} ${className}) {
|
||||||
ServerResult<List<${ClassName}>> genServerResult = ${className}Service.select${ClassName}List(${className});
|
ServerResult<List<${ClassName}>> genServerResult = ${className}Service.select${ClassName}List(${className});
|
||||||
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}. class);
|
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}. class);
|
||||||
if (genServerResult.isStart()) {
|
if (genServerResult.isStart()) {
|
||||||
|
|
|
||||||
|
|
@ -551,7 +551,7 @@ export default {
|
||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
$column.javaField: [
|
$column.javaField: [
|
||||||
{ required: true, message: "${comment}不能为空}", trigger: #if($column.htmlType == "select")"change"#else"blur"#end },
|
{ required: true, message: "${comment}不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end },
|
||||||
#if($column.isRegular != 1)
|
#if($column.isRegular != 1)
|
||||||
{ pattern: /${column.regular}/, message: '${column.columnComment}格式有误', trigger:"blur"},
|
{ pattern: /${column.regular}/, message: '${column.columnComment}格式有误', trigger:"blur"},
|
||||||
#end
|
#end
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ebts.system.entity;
|
||||||
|
|
||||||
import com.ebts.common.annotation.Excel;
|
import com.ebts.common.annotation.Excel;
|
||||||
import com.ebts.common.core.entity.BaseEntity;
|
import com.ebts.common.core.entity.BaseEntity;
|
||||||
|
import com.ebts.system.utils.FtpUtils;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
|
@ -158,6 +159,9 @@ public class SysFile extends BaseEntity {
|
||||||
|
|
||||||
public void setIsPublic(String isPublic) {
|
public void setIsPublic(String isPublic) {
|
||||||
this.isPublic = isPublic;
|
this.isPublic = isPublic;
|
||||||
|
if ("1".equals(isPublic)&&("jpg".equals(fileType)||"png".equals(fileType))){
|
||||||
|
this.setRemark(FtpUtils.getResources()+fileAddr+"/"+mapping);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsPublic() {
|
public String getIsPublic() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue