mirror of
https://github.com/201206030/novel-plus.git
synced 2025-06-24 04:46:37 +00:00
refactor: 引入xxy-common相关依赖
This commit is contained in:
@ -1,46 +0,0 @@
|
||||
package com.java2nb.novel.core.advice;
|
||||
|
||||
import com.java2nb.novel.core.bean.ResultBean;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.core.exception.BusinessException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* 通用的异常处理器
|
||||
*
|
||||
* @author 11797*/
|
||||
@Slf4j
|
||||
@RestControllerAdvice(basePackages = "com.java2nb.novel.controller")
|
||||
public class CommonExceptionHandler {
|
||||
|
||||
/**
|
||||
* 处理后台数据校验异常
|
||||
* */
|
||||
@ExceptionHandler(BindException.class)
|
||||
public ResultBean handlerBindException(BindException e){
|
||||
log.error(e.getMessage(),e);
|
||||
return ResultBean.fail(ResponseStatus.PARAM_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理业务异常
|
||||
* */
|
||||
@ExceptionHandler(BusinessException.class)
|
||||
public ResultBean handlerBusinessException(BusinessException e){
|
||||
log.error(e.getMessage(),e);
|
||||
return ResultBean.fail(e.getResStatus());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理系统异常
|
||||
* */
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResultBean handlerException(Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
return ResultBean.error();
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package com.java2nb.novel.core.bean;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 封装通用分页数据,接收PageHelper、SpringData等框架的分页数据,转换成通用的PageBean对象
|
||||
* @author xiongxiaoyang
|
||||
* @version 1.0
|
||||
* @since 2021/2/4
|
||||
* @param <T> 分页集合类型
|
||||
*/
|
||||
@Data
|
||||
public class PageBean<T> {
|
||||
|
||||
private Integer pageNum;
|
||||
private Integer pageSize;
|
||||
private Long total;
|
||||
private List<? extends T> list;
|
||||
|
||||
|
||||
/**
|
||||
* 该构造函数用于PageHelper工具进行分页查询的场景
|
||||
* 接收PageHelper分页后的list
|
||||
*/
|
||||
public PageBean(List<T> list){
|
||||
PageInfo<T> pageInfo = new PageInfo<>(list);
|
||||
this.pageNum = pageInfo.getPageNum();
|
||||
this.pageSize = pageInfo.getPageSize();
|
||||
this.total = pageInfo.getTotal();
|
||||
this.list = pageInfo.getList();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 该构造函数用于通用分页查询的场景
|
||||
* 接收普通分页数据和普通集合
|
||||
*/
|
||||
public PageBean(Integer pageNum, Integer pageSize, Long total, List<T> list) {
|
||||
this.pageNum = pageNum;
|
||||
this.pageSize = pageSize;
|
||||
this.total = total;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
|
||||
//TODO 使用其他的分页工具或框架进行分页查询的场景
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package com.java2nb.novel.core.bean;
|
||||
|
||||
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 自定义响应结构
|
||||
*
|
||||
* @param <T>
|
||||
* @author 11797
|
||||
*/
|
||||
@Data
|
||||
public class ResultBean<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int code = ResponseStatus.OK.getCode();
|
||||
|
||||
/**
|
||||
* 响应消息
|
||||
*/
|
||||
private String msg = ResponseStatus.OK.getMsg();
|
||||
/**
|
||||
* 响应中的数据
|
||||
*/
|
||||
private T data;
|
||||
|
||||
private ResultBean() {
|
||||
|
||||
}
|
||||
|
||||
private ResultBean(ResponseStatus responseStatus) {
|
||||
this.code = responseStatus.getCode();
|
||||
this.msg = responseStatus.getMsg();
|
||||
}
|
||||
|
||||
private ResultBean(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 业务处理成功,无数据返回
|
||||
*/
|
||||
public static ResultBean<Void> ok() {
|
||||
return new ResultBean<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务处理成功,有数据返回
|
||||
*/
|
||||
public static <T> ResultBean<T> ok(T data) {
|
||||
return new ResultBean<>(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务处理失败
|
||||
*/
|
||||
public static ResultBean<Void> fail(ResponseStatus responseStatus) {
|
||||
return new ResultBean<>(responseStatus);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 系统错误
|
||||
*/
|
||||
public static ResultBean<Void> error() {
|
||||
return new ResultBean<>(ResponseStatus.ERROR);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.java2nb.novel.core.enums;
|
||||
|
||||
import io.github.xxyopen.model.resp.IResultCode;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -11,27 +12,7 @@ import lombok.NoArgsConstructor;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public enum ResponseStatus {
|
||||
|
||||
/**
|
||||
* 请求成功
|
||||
* */
|
||||
OK(200,"SUCCESS"),
|
||||
|
||||
/**
|
||||
* 服务器异常
|
||||
* */
|
||||
ERROR(500,"未知异常,请联系管理员!"),
|
||||
|
||||
/**
|
||||
* 参数错误
|
||||
* */
|
||||
PARAM_ERROR(400,"非法参数!"),
|
||||
|
||||
/**
|
||||
* 拒绝访问
|
||||
* */
|
||||
FORBIDDEN(403,"拒绝访问!"),
|
||||
public enum ResponseStatus implements IResultCode {
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,22 +0,0 @@
|
||||
package com.java2nb.novel.core.exception;
|
||||
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 自定义业务异常,用于处理用户请求时,业务错误时抛出
|
||||
*/
|
||||
@Data
|
||||
public class BusinessException extends RuntimeException {
|
||||
|
||||
private ResponseStatus resStatus;
|
||||
|
||||
public BusinessException(ResponseStatus resStatus) {
|
||||
//不调用父类Throwable的fillInStackTrace()方法生成栈追踪信息,提高应用性能
|
||||
//构造器之间的调用必须在第一行
|
||||
super(resStatus.getMsg(), null, false, false);
|
||||
this.resStatus = resStatus;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.java2nb.novel.core.utils;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bean操作工具类
|
||||
* @author Administrator
|
||||
*/
|
||||
public class BeanUtil {
|
||||
|
||||
/**
|
||||
* 复制集合对象属性值,生成新类型集合
|
||||
* @param source 源集合
|
||||
* @param targetClass 目标集合类型
|
||||
* @return 新集合
|
||||
* */
|
||||
@SneakyThrows
|
||||
public static <T> List<T> copyList(List<? super T> source,Class<T> targetClass){
|
||||
List<T> target = new ArrayList<>(source.size());
|
||||
for( int i = 0 ; i < source.size() ; i++){
|
||||
Object sourceItem = source.get(i);
|
||||
T targetItem = targetClass.newInstance();
|
||||
BeanUtils.copyProperties(sourceItem,targetItem);
|
||||
target.add(targetItem);
|
||||
}
|
||||
return target;
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.java2nb.novel.core.utils;
|
||||
|
||||
import io.github.xxyopen.util.UUIDUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -1,163 +0,0 @@
|
||||
package com.java2nb.novel.core.utils;
|
||||
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
|
||||
/**
|
||||
* <p>名称:IdWorker.java</p>
|
||||
* <p>描述:分布式自增长ID</p>
|
||||
* <pre>
|
||||
* Twitter的 Snowflake JAVA实现方案
|
||||
* </pre>
|
||||
* 核心代码为其IdWorker这个类实现,其原理结构如下,我分别用一个0表示一位,用—分割开部分的作用:
|
||||
* 1||0---0000000000 0000000000 0000000000 0000000000 0 --- 00000 ---00000 ---000000000000
|
||||
* 在上面的字符串中,第一位为未使用(实际上也可作为long的符号位),接下来的41位为毫秒级时间,
|
||||
* 然后5位datacenter标识位,5位机器ID(并不算标识符,实际是为线程标识),
|
||||
* 然后12位该毫秒内的当前毫秒内的计数,加起来刚好64位,为一个Long型。
|
||||
* 这样的好处是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由datacenter和机器ID作区分),
|
||||
* 并且效率较高,经测试,snowflake每秒能够产生26万ID左右,完全满足需要。
|
||||
* <p>
|
||||
* 64位ID (42(毫秒)+5(机器ID)+5(业务编码)+12(重复累加))
|
||||
*
|
||||
*/
|
||||
public class IdWorker {
|
||||
// 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动)
|
||||
private final static long twepoch = 1288834974657L;
|
||||
// 机器标识位数
|
||||
private final static long workerIdBits = 5L;
|
||||
// 数据中心标识位数
|
||||
private final static long datacenterIdBits = 5L;
|
||||
// 机器ID最大值
|
||||
private final static long maxWorkerId = -1L ^ (-1L << workerIdBits);
|
||||
// 数据中心ID最大值
|
||||
private final static long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
|
||||
// 毫秒内自增位
|
||||
private final static long sequenceBits = 12L;
|
||||
// 机器ID偏左移12位
|
||||
private final static long workerIdShift = sequenceBits;
|
||||
// 数据中心ID左移17位
|
||||
private final static long datacenterIdShift = sequenceBits + workerIdBits;
|
||||
// 时间毫秒左移22位
|
||||
private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
|
||||
|
||||
private final static long sequenceMask = -1L ^ (-1L << sequenceBits);
|
||||
/* 上次生产id时间戳 */
|
||||
private static long lastTimestamp = -1L;
|
||||
// 0,并发控制
|
||||
private long sequence = 0L;
|
||||
|
||||
private final long workerId;
|
||||
// 数据标识id部分
|
||||
private final long datacenterId;
|
||||
|
||||
public IdWorker(){
|
||||
this.datacenterId = getDatacenterId(maxDatacenterId);
|
||||
this.workerId = getMaxWorkerId(datacenterId, maxWorkerId);
|
||||
}
|
||||
/**
|
||||
* @param workerId
|
||||
* 工作机器ID
|
||||
* @param datacenterId
|
||||
* 序列号
|
||||
*/
|
||||
public IdWorker(long workerId, long datacenterId) {
|
||||
if (workerId > maxWorkerId || workerId < 0) {
|
||||
throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
|
||||
}
|
||||
if (datacenterId > maxDatacenterId || datacenterId < 0) {
|
||||
throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
|
||||
}
|
||||
this.workerId = workerId;
|
||||
this.datacenterId = datacenterId;
|
||||
}
|
||||
/**
|
||||
* 获取下一个ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public synchronized long nextId() {
|
||||
long timestamp = timeGen();
|
||||
if (timestamp < lastTimestamp) {
|
||||
throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
|
||||
}
|
||||
|
||||
if (lastTimestamp == timestamp) {
|
||||
// 当前毫秒内,则+1
|
||||
sequence = (sequence + 1) & sequenceMask;
|
||||
if (sequence == 0) {
|
||||
// 当前毫秒内计数满了,则等待下一秒
|
||||
timestamp = tilNextMillis(lastTimestamp);
|
||||
}
|
||||
} else {
|
||||
sequence = 0L;
|
||||
}
|
||||
lastTimestamp = timestamp;
|
||||
// ID偏移组合生成最终的ID,并返回ID
|
||||
long nextId = ((timestamp - twepoch) << timestampLeftShift)
|
||||
| (datacenterId << datacenterIdShift)
|
||||
| (workerId << workerIdShift) | sequence;
|
||||
|
||||
return nextId;
|
||||
}
|
||||
|
||||
private long tilNextMillis(final long lastTimestamp) {
|
||||
long timestamp = this.timeGen();
|
||||
while (timestamp <= lastTimestamp) {
|
||||
timestamp = this.timeGen();
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
private long timeGen() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 获取 maxWorkerId
|
||||
* </p>
|
||||
*/
|
||||
protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) {
|
||||
StringBuffer mpid = new StringBuffer();
|
||||
mpid.append(datacenterId);
|
||||
String name = ManagementFactory.getRuntimeMXBean().getName();
|
||||
if (!name.isEmpty()) {
|
||||
/*
|
||||
* GET jvmPid
|
||||
*/
|
||||
mpid.append(name.split("@")[0]);
|
||||
}
|
||||
/*
|
||||
* MAC + PID 的 hashcode 获取16个低位
|
||||
*/
|
||||
return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据标识id部分
|
||||
* </p>
|
||||
*/
|
||||
protected static long getDatacenterId(long maxDatacenterId) {
|
||||
long id = 0L;
|
||||
try {
|
||||
InetAddress ip = InetAddress.getLocalHost();
|
||||
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
|
||||
if (network == null) {
|
||||
id = 1L;
|
||||
} else {
|
||||
byte[] mac = network.getHardwareAddress();
|
||||
id = ((0x000000FF & (long) mac[mac.length - 1])
|
||||
| (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6;
|
||||
id = id % (maxDatacenterId + 1);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(" getDatacenterId: " + e.getMessage());
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package com.java2nb.novel.core.utils;
|
||||
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
/**
|
||||
* @author 11797
|
||||
*/
|
||||
public class MD5Util {
|
||||
|
||||
private static final String DEFAUL_CHARSET = "utf-8" ;
|
||||
|
||||
private static String byteArrayToHexString(byte[] b) {
|
||||
StringBuffer resultSb = new StringBuffer();
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
resultSb.append(byteToHexString(b[i]));
|
||||
}
|
||||
|
||||
return resultSb.toString();
|
||||
}
|
||||
|
||||
private static String byteToHexString(byte b) {
|
||||
int n = b;
|
||||
if (n < 0) {
|
||||
n += 256;
|
||||
}
|
||||
int d1 = n / 16;
|
||||
int d2 = n % 16;
|
||||
return HEX_DIGITS[d1] + HEX_DIGITS[d2];
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static String MD5Encode(String origin,String charsetname) {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
if (charsetname == null || "".equals(charsetname)) {
|
||||
return byteArrayToHexString(md.digest(origin
|
||||
.getBytes()));
|
||||
} else {
|
||||
return byteArrayToHexString(md.digest(origin
|
||||
.getBytes(charsetname)));
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static String MD5New(String str) {
|
||||
//首先利用MD5算法将密码加密,变成等长字节
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] b1 = md.digest(str.getBytes());
|
||||
//将等长字节利用Base64算法转换成字符串
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
return encoder.encode(b1);
|
||||
}
|
||||
|
||||
private static final String[] HEX_DIGITS = {"0", "1", "2", "3", "4", "5",
|
||||
"6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
|
||||
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package com.java2nb.novel.core.utils;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Component
|
||||
public class SpringUtil implements ApplicationContextAware {
|
||||
|
||||
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
if (SpringUtil.applicationContext == null) {
|
||||
SpringUtil.applicationContext = applicationContext;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取applicationContext
|
||||
* */
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过name获取 Bean.
|
||||
* */
|
||||
public static Object getBean(String name) {
|
||||
return getApplicationContext().getBean(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过class获取Bean
|
||||
* */
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
return getApplicationContext().getBean(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过name,以及Clazz返回指定的Bean
|
||||
* */
|
||||
public static <T> T getBean(String name, Class<T> clazz) {
|
||||
return getApplicationContext().getBean(name, clazz);
|
||||
}
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package com.java2nb.novel.core.utils;
|
||||
|
||||
/**
|
||||
* 线程工具类
|
||||
* @author Administrator
|
||||
*/
|
||||
public class ThreadUtil {
|
||||
|
||||
/**
|
||||
* 根据线程ID获取线程
|
||||
* */
|
||||
public static Thread findThread(long threadId) {
|
||||
ThreadGroup group = Thread.currentThread().getThreadGroup();
|
||||
while(group != null) {
|
||||
Thread[] threads = new Thread[(int)(group.activeCount() * 1.2)];
|
||||
int count = group.enumerate(threads, true);
|
||||
for(int i = 0; i < count; i++) {
|
||||
if(threadId == threads[i].getId()) {
|
||||
return threads[i];
|
||||
}
|
||||
}
|
||||
group = group.getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
package com.java2nb.novel.core.utils;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
public class UUIDUtil {
|
||||
|
||||
public static final String[] CHARS = new String[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",
|
||||
"m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6",
|
||||
"7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
|
||||
"S", "T", "U", "V", "W", "X", "Y", "Z" };
|
||||
|
||||
/**
|
||||
* 生成指定长度的uuid
|
||||
*
|
||||
* @param length
|
||||
* @return
|
||||
*/
|
||||
private static String getUUID(int length, UUID uuid) {
|
||||
int groupLength = 32 / length;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String id = uuid.toString().replace("-", "");
|
||||
for (int i = 0; i < length; i++) {
|
||||
String str = id.substring(i * groupLength, i * groupLength + groupLength);
|
||||
int x = Integer.parseInt(str, 16);
|
||||
sb.append(CHARS[x % 0x3E]);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 8位UUID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getUUID8() {
|
||||
return getUUID(8, UUID.randomUUID());
|
||||
}
|
||||
|
||||
/**
|
||||
* 8位UUID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getUUID8(byte[] bytes) {
|
||||
return getUUID(8, UUID.nameUUIDFromBytes(bytes));
|
||||
}
|
||||
|
||||
/**
|
||||
* 8位UUID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getUUID8(String fromString) {
|
||||
return getUUID(8, UUID.fromString(fromString));
|
||||
}
|
||||
|
||||
/**
|
||||
* 16位UUID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getUUID16() {
|
||||
return getUUID(16, UUID.randomUUID());
|
||||
}
|
||||
|
||||
/**
|
||||
* 16位UUID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getUUID16(String fromString) {
|
||||
return getUUID(16, UUID.fromString(fromString));
|
||||
}
|
||||
|
||||
/**
|
||||
* 16位UUID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getUUID16(byte[] bytes) {
|
||||
return getUUID(16, UUID.nameUUIDFromBytes(bytes));
|
||||
}
|
||||
|
||||
/**
|
||||
* 32位UUID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getUUID32() {
|
||||
return UUID.randomUUID().toString().replace("-", "");
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.java2nb.novel.core.valid;
|
||||
|
||||
/**
|
||||
* 新增数据的校验分组
|
||||
* @author xiongxiaoyang
|
||||
*/
|
||||
public interface AddGroup {
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.java2nb.novel.core.valid;
|
||||
|
||||
/**
|
||||
* 更新数据的校验分组
|
||||
* @author xiongxiaoyang
|
||||
*/
|
||||
public interface UpdateGroup {
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package com.java2nb.novel.entity;
|
||||
|
||||
import com.java2nb.novel.core.valid.AddGroup;
|
||||
import com.java2nb.novel.core.valid.UpdateGroup;
|
||||
import io.github.xxyopen.web.valid.AddGroup;
|
||||
import io.github.xxyopen.web.valid.UpdateGroup;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.annotation.Generated;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.Date;
|
||||
|
||||
public class User {
|
||||
|
||||
|
Reference in New Issue
Block a user