mirror of
https://github.com/201206030/novel-plus.git
synced 2025-04-26 17:20:52 +00:00
refactor: 引入xxy-common相关依赖
This commit is contained in:
parent
776083076c
commit
16e4c98a45
@ -123,6 +123,24 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<artifactId>xxy-model</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<artifactId>xxy-web</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<artifactId>xxy-util</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
package com.java2nb.novel.controller;
|
||||
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import com.java2nb.novel.core.bean.ResultBean;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
|
||||
import com.java2nb.novel.entity.CrawlSingleTask;
|
||||
import com.java2nb.novel.entity.CrawlSource;
|
||||
import com.java2nb.novel.service.CrawlService;
|
||||
import io.github.xxyopen.model.resp.RestResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -23,10 +24,10 @@ public class CrawlController {
|
||||
* 新增爬虫源
|
||||
* */
|
||||
@PostMapping("addCrawlSource")
|
||||
public ResultBean<Void> addCrawlSource(CrawlSource source){
|
||||
public RestResult<Void> addCrawlSource(CrawlSource source){
|
||||
crawlService.addCrawlSource(source);
|
||||
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
|
||||
}
|
||||
|
||||
@ -34,30 +35,30 @@ public class CrawlController {
|
||||
* 爬虫源分页列表查询
|
||||
* */
|
||||
@GetMapping("listCrawlByPage")
|
||||
public ResultBean<PageBean<CrawlSource>> listCrawlByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize){
|
||||
public RestResult<PageBean<CrawlSource>> listCrawlByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize){
|
||||
|
||||
return ResultBean.ok(crawlService.listCrawlByPage(page,pageSize));
|
||||
return RestResult.ok(crawlService.listCrawlByPage(page,pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启或停止爬虫
|
||||
* */
|
||||
@PostMapping("openOrCloseCrawl")
|
||||
public ResultBean<Void> openOrCloseCrawl(Integer sourceId,Byte sourceStatus){
|
||||
public RestResult<Void> openOrCloseCrawl(Integer sourceId,Byte sourceStatus){
|
||||
|
||||
crawlService.openOrCloseCrawl(sourceId,sourceStatus);
|
||||
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增单本采集任务
|
||||
* */
|
||||
@PostMapping("addCrawlSingleTask")
|
||||
public ResultBean<Void> addCrawlSingleTask(CrawlSingleTask singleTask){
|
||||
public RestResult<Void> addCrawlSingleTask(CrawlSingleTask singleTask){
|
||||
crawlService.addCrawlSingleTask(singleTask);
|
||||
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
|
||||
}
|
||||
|
||||
@ -65,20 +66,20 @@ public class CrawlController {
|
||||
* 单本采集任务分页列表查询
|
||||
* */
|
||||
@GetMapping("listCrawlSingleTaskByPage")
|
||||
public ResultBean<PageBean<CrawlSingleTask>> listCrawlSingleTaskByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize){
|
||||
public RestResult<PageBean<CrawlSingleTask>> listCrawlSingleTaskByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize){
|
||||
|
||||
return ResultBean.ok(crawlService.listCrawlSingleTaskByPage(page,pageSize));
|
||||
return RestResult.ok(crawlService.listCrawlSingleTaskByPage(page,pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除采集任务
|
||||
* */
|
||||
@DeleteMapping("delCrawlSingleTask/{id}")
|
||||
public ResultBean<Void> delCrawlSingleTask(@PathVariable("id") Long id){
|
||||
public RestResult<Void> delCrawlSingleTask(@PathVariable("id") Long id){
|
||||
|
||||
crawlService.delCrawlSingleTask(id);
|
||||
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.java2nb.novel.entity.Book;
|
||||
import com.java2nb.novel.entity.BookContent;
|
||||
import com.java2nb.novel.entity.BookIndex;
|
||||
import com.java2nb.novel.utils.Constants;
|
||||
import io.github.xxyopen.util.IdWorker;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -26,7 +27,7 @@ import static java.util.regex.Pattern.compile;
|
||||
@Slf4j
|
||||
public class CrawlParser {
|
||||
|
||||
private static final IdWorker idWorker = new IdWorker();
|
||||
private static final IdWorker idWorker = IdWorker.INSTANCE;
|
||||
|
||||
private static final RestTemplate restTemplate = RestTemplateUtil.getInstance("utf-8");
|
||||
|
||||
|
@ -3,9 +3,9 @@ package com.java2nb.novel.core.schedule;
|
||||
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import com.java2nb.novel.core.utils.ThreadUtil;
|
||||
import com.java2nb.novel.entity.CrawlSource;
|
||||
import com.java2nb.novel.service.CrawlService;
|
||||
import io.github.xxyopen.util.ThreadUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.java2nb.novel.service;
|
||||
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import com.java2nb.novel.core.crawl.RuleBean;
|
||||
import com.java2nb.novel.entity.CrawlSingleTask;
|
||||
import com.java2nb.novel.entity.CrawlSource;
|
||||
|
@ -2,17 +2,17 @@ package com.java2nb.novel.service.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import com.java2nb.novel.core.crawl.CrawlParser;
|
||||
import com.java2nb.novel.core.crawl.RuleBean;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.core.exception.BusinessException;
|
||||
import com.java2nb.novel.core.utils.BeanUtil;
|
||||
import com.java2nb.novel.core.utils.IdWorker;
|
||||
import com.java2nb.novel.core.utils.SpringUtil;
|
||||
import com.java2nb.novel.core.utils.ThreadUtil;
|
||||
import io.github.xxyopen.model.page.builder.pagehelper.PageBuilder;
|
||||
import io.github.xxyopen.util.IdWorker;
|
||||
import io.github.xxyopen.util.ThreadUtil;
|
||||
import io.github.xxyopen.web.exception.BusinessException;
|
||||
import io.github.xxyopen.web.util.BeanUtil;
|
||||
import com.java2nb.novel.entity.Book;
|
||||
import com.java2nb.novel.entity.CrawlSingleTask;
|
||||
import com.java2nb.novel.entity.CrawlSource;
|
||||
@ -24,6 +24,7 @@ import com.java2nb.novel.service.BookService;
|
||||
import com.java2nb.novel.service.CrawlService;
|
||||
import com.java2nb.novel.vo.CrawlSingleTaskVO;
|
||||
import com.java2nb.novel.vo.CrawlSourceVO;
|
||||
import io.github.xxyopen.web.util.SpringUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -79,7 +80,7 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
List<CrawlSource> crawlSources = crawlSourceMapper.selectMany(render);
|
||||
PageBean<CrawlSource> pageBean = new PageBean<>(crawlSources);
|
||||
PageBean<CrawlSource> pageBean = PageBuilder.build(crawlSources);
|
||||
pageBean.setList(BeanUtil.copyList(crawlSources, CrawlSourceVO.class));
|
||||
return pageBean;
|
||||
}
|
||||
@ -168,7 +169,7 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
List<CrawlSingleTask> crawlSingleTasks = crawlSingleTaskMapper.selectMany(render);
|
||||
PageBean<CrawlSingleTask> pageBean = new PageBean<>(crawlSingleTasks);
|
||||
PageBean<CrawlSingleTask> pageBean = PageBuilder.build(crawlSingleTasks);
|
||||
pageBean.setList(BeanUtil.copyList(crawlSingleTasks, CrawlSingleTaskVO.class));
|
||||
return pageBean;
|
||||
}
|
||||
@ -299,7 +300,7 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
book.setCrawlBookId(bookId);
|
||||
book.setCrawlSourceId(sourceId);
|
||||
book.setCrawlLastTime(new Date());
|
||||
book.setId(new IdWorker().nextId());
|
||||
book.setId(IdWorker.INSTANCE.nextId());
|
||||
//解析章节目录
|
||||
CrawlParser.parseBookIndexAndContent(bookId, book, ruleBean, new HashMap<>(0), chapter -> {
|
||||
bookService.saveBookAndIndexAndContent(book, chapter.getBookIndexList(), chapter.getBookContentList());
|
||||
|
@ -1,10 +1,11 @@
|
||||
package com.java2nb.novel.controller;
|
||||
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import com.java2nb.novel.core.bean.ResultBean;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
|
||||
import com.java2nb.novel.core.bean.UserDetails;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.core.exception.BusinessException;
|
||||
import io.github.xxyopen.model.resp.RestResult;
|
||||
import io.github.xxyopen.web.exception.BusinessException;
|
||||
import com.java2nb.novel.entity.Author;
|
||||
import com.java2nb.novel.entity.AuthorIncome;
|
||||
import com.java2nb.novel.entity.AuthorIncomeDetail;
|
||||
@ -35,25 +36,25 @@ public class AuthorController extends BaseController{
|
||||
* 校验笔名是否存在
|
||||
* */
|
||||
@GetMapping("checkPenName")
|
||||
public ResultBean<Boolean> checkPenName(String penName){
|
||||
public RestResult<Boolean> checkPenName(String penName){
|
||||
|
||||
return ResultBean.ok(authorService.checkPenName(penName));
|
||||
return RestResult.ok(authorService.checkPenName(penName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 作家发布小说分页列表查询
|
||||
* */
|
||||
@GetMapping("listBookByPage")
|
||||
public ResultBean<PageBean<Book>> listBookByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize , HttpServletRequest request){
|
||||
public RestResult<PageBean<Book>> listBookByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize , HttpServletRequest request){
|
||||
|
||||
return ResultBean.ok(bookService.listBookPageByUserId(getUserDetails(request).getId(),page,pageSize));
|
||||
return RestResult.ok(bookService.listBookPageByUserId(getUserDetails(request).getId(),page,pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布小说
|
||||
* */
|
||||
@PostMapping("addBook")
|
||||
public ResultBean<Void> addBook(@RequestParam("bookDesc") String bookDesc,Book book,HttpServletRequest request){
|
||||
public RestResult<Void> addBook(@RequestParam("bookDesc") String bookDesc,Book book,HttpServletRequest request){
|
||||
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
@ -64,20 +65,20 @@ public class AuthorController extends BaseController{
|
||||
//发布小说
|
||||
bookService.addBook(book,author.getId(),author.getPenName());
|
||||
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新小说状态,上架或下架
|
||||
* */
|
||||
@PostMapping("updateBookStatus")
|
||||
public ResultBean<Void> updateBookStatus(Long bookId,Byte status,HttpServletRequest request){
|
||||
public RestResult<Void> updateBookStatus(Long bookId,Byte status,HttpServletRequest request){
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
//更新小说状态,上架或下架
|
||||
bookService.updateBookStatus(bookId,status,author.getId());
|
||||
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
|
||||
@ -86,28 +87,28 @@ public class AuthorController extends BaseController{
|
||||
* 删除章节
|
||||
*/
|
||||
@DeleteMapping("deleteIndex/{indexId}")
|
||||
public ResultBean<Void> deleteIndex(@PathVariable("indexId") Long indexId, HttpServletRequest request) {
|
||||
public RestResult<Void> deleteIndex(@PathVariable("indexId") Long indexId, HttpServletRequest request) {
|
||||
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
//删除章节
|
||||
bookService.deleteIndex(indexId, author.getId());
|
||||
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新章节名
|
||||
*/
|
||||
@PostMapping("updateIndexName")
|
||||
public ResultBean<Void> updateIndexName(Long indexId, String indexName, HttpServletRequest request) {
|
||||
public RestResult<Void> updateIndexName(Long indexId, String indexName, HttpServletRequest request) {
|
||||
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
//更新章节名
|
||||
bookService.updateIndexName(indexId, indexName, author.getId());
|
||||
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
|
||||
@ -117,7 +118,7 @@ public class AuthorController extends BaseController{
|
||||
* 发布章节内容
|
||||
*/
|
||||
@PostMapping("addBookContent")
|
||||
public ResultBean<Void> addBookContent(Long bookId, String indexName, String content,Byte isVip, HttpServletRequest request) {
|
||||
public RestResult<Void> addBookContent(Long bookId, String indexName, String content,Byte isVip, HttpServletRequest request) {
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
content = content.replaceAll("\\n", "<br>")
|
||||
@ -125,14 +126,14 @@ public class AuthorController extends BaseController{
|
||||
//发布章节内容
|
||||
bookService.addBookContent(bookId, indexName, content,isVip, author.getId());
|
||||
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询章节内容
|
||||
*/
|
||||
@GetMapping("queryIndexContent/{indexId}")
|
||||
public ResultBean<String> queryIndexContent(@PathVariable("indexId") Long indexId, HttpServletRequest request) {
|
||||
public RestResult<String> queryIndexContent(@PathVariable("indexId") Long indexId, HttpServletRequest request) {
|
||||
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
@ -141,14 +142,14 @@ public class AuthorController extends BaseController{
|
||||
content = content.replaceAll("<br>", "\n")
|
||||
.replaceAll(" ", " ");
|
||||
|
||||
return ResultBean.ok(content);
|
||||
return RestResult.ok(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新章节内容
|
||||
*/
|
||||
@PostMapping("updateBookContent")
|
||||
public ResultBean<Void> updateBookContent(Long indexId, String indexName, String content, HttpServletRequest request) {
|
||||
public RestResult<Void> updateBookContent(Long indexId, String indexName, String content, HttpServletRequest request) {
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
content = content.replaceAll("\\n", "<br>")
|
||||
@ -156,17 +157,17 @@ public class AuthorController extends BaseController{
|
||||
//更新章节内容
|
||||
bookService.updateBookContent(indexId, indexName, content, author.getId());
|
||||
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改小说封面
|
||||
*/
|
||||
@PostMapping("updateBookPic")
|
||||
public ResultBean<Void> updateBookPic(@RequestParam("bookId") Long bookId,@RequestParam("bookPic") String bookPic,HttpServletRequest request) {
|
||||
public RestResult<Void> updateBookPic(@RequestParam("bookId") Long bookId,@RequestParam("bookPic") String bookPic,HttpServletRequest request) {
|
||||
Author author = checkAuthor(request);
|
||||
bookService.updateBookPic(bookId,bookPic, author.getId());
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
|
||||
@ -174,14 +175,14 @@ public class AuthorController extends BaseController{
|
||||
* 作家日收入统计数据分页列表查询
|
||||
* */
|
||||
@GetMapping("listIncomeDailyByPage")
|
||||
public ResultBean<PageBean<AuthorIncomeDetail>> listIncomeDailyByPage(@RequestParam(value = "curr", defaultValue = "1") int page,
|
||||
public RestResult<PageBean<AuthorIncomeDetail>> listIncomeDailyByPage(@RequestParam(value = "curr", defaultValue = "1") int page,
|
||||
@RequestParam(value = "limit", defaultValue = "10") int pageSize ,
|
||||
@RequestParam(value = "bookId", defaultValue = "0") Long bookId,
|
||||
@RequestParam(value = "startTime",defaultValue = "2020-05-01") Date startTime,
|
||||
@RequestParam(value = "endTime",defaultValue = "2030-01-01") Date endTime,
|
||||
HttpServletRequest request){
|
||||
|
||||
return ResultBean.ok(authorService.listIncomeDailyByPage(page,pageSize,getUserDetails(request).getId(),bookId,startTime,endTime));
|
||||
return RestResult.ok(authorService.listIncomeDailyByPage(page,pageSize,getUserDetails(request).getId(),bookId,startTime,endTime));
|
||||
}
|
||||
|
||||
|
||||
@ -189,12 +190,12 @@ public class AuthorController extends BaseController{
|
||||
* 作家月收入统计数据分页列表查询
|
||||
* */
|
||||
@GetMapping("listIncomeMonthByPage")
|
||||
public ResultBean<PageBean<AuthorIncome>> listIncomeMonthByPage(@RequestParam(value = "curr", defaultValue = "1") int page,
|
||||
public RestResult<PageBean<AuthorIncome>> listIncomeMonthByPage(@RequestParam(value = "curr", defaultValue = "1") int page,
|
||||
@RequestParam(value = "limit", defaultValue = "10") int pageSize ,
|
||||
@RequestParam(value = "bookId", defaultValue = "0") Long bookId,
|
||||
HttpServletRequest request){
|
||||
|
||||
return ResultBean.ok(authorService.listIncomeMonthByPage(page,pageSize,getUserDetails(request).getId(),bookId));
|
||||
return RestResult.ok(authorService.listIncomeMonthByPage(page,pageSize,getUserDetails(request).getId(),bookId));
|
||||
}
|
||||
|
||||
private Author checkAuthor(HttpServletRequest request) {
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.java2nb.novel.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import com.java2nb.novel.core.bean.ResultBean;
|
||||
import com.java2nb.novel.core.bean.UserDetails;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.entity.Book;
|
||||
@ -15,6 +12,9 @@ import com.java2nb.novel.vo.BookSettingVO;
|
||||
import com.java2nb.novel.vo.BookSpVO;
|
||||
import com.java2nb.novel.service.BookService;
|
||||
import com.java2nb.novel.vo.BookVO;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import io.github.xxyopen.model.page.builder.pagehelper.PageBuilder;
|
||||
import io.github.xxyopen.model.resp.RestResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
@ -49,56 +49,56 @@ public class BookController extends BaseController {
|
||||
* 查询首页小说设置列表数据
|
||||
*/
|
||||
@GetMapping("listBookSetting")
|
||||
public ResultBean<Map<Byte, List<BookSettingVO>>> listBookSetting() {
|
||||
return ResultBean.ok(bookService.listBookSettingVO());
|
||||
public RestResult<Map<Byte, List<BookSettingVO>>> listBookSetting() {
|
||||
return RestResult.ok(bookService.listBookSettingVO());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询首页点击榜单数据
|
||||
*/
|
||||
@GetMapping("listClickRank")
|
||||
public ResultBean<List<Book>> listClickRank() {
|
||||
return ResultBean.ok(bookService.listClickRank());
|
||||
public RestResult<List<Book>> listClickRank() {
|
||||
return RestResult.ok(bookService.listClickRank());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询首页新书榜单数据
|
||||
*/
|
||||
@GetMapping("listNewRank")
|
||||
public ResultBean<List<Book>> listNewRank() {
|
||||
return ResultBean.ok(bookService.listNewRank());
|
||||
public RestResult<List<Book>> listNewRank() {
|
||||
return RestResult.ok(bookService.listNewRank());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询首页更新榜单数据
|
||||
*/
|
||||
@GetMapping("listUpdateRank")
|
||||
public ResultBean<List<BookVO>> listUpdateRank() {
|
||||
return ResultBean.ok(bookService.listUpdateRank());
|
||||
public RestResult<List<BookVO>> listUpdateRank() {
|
||||
return RestResult.ok(bookService.listUpdateRank());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小说分类列表
|
||||
*/
|
||||
@GetMapping("listBookCategory")
|
||||
public ResultBean<List<BookCategory>> listBookCategory() {
|
||||
return ResultBean.ok(bookService.listBookCategory());
|
||||
public RestResult<List<BookCategory>> listBookCategory() {
|
||||
return RestResult.ok(bookService.listBookCategory());
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页搜索
|
||||
*/
|
||||
@GetMapping("searchByPage")
|
||||
public ResultBean<?> searchByPage(BookSpVO bookSP, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "20") int pageSize) {
|
||||
return ResultBean.ok(bookService.searchByPage(bookSP, page, pageSize));
|
||||
public RestResult<?> searchByPage(BookSpVO bookSP, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "20") int pageSize) {
|
||||
return RestResult.ok(bookService.searchByPage(bookSP, page, pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小说详情信息
|
||||
*/
|
||||
@GetMapping("queryBookDetail/{id}")
|
||||
public ResultBean<Book> queryBookDetail(@PathVariable("id") Long id) {
|
||||
return ResultBean.ok(bookService.queryBookDetail(id));
|
||||
public RestResult<Book> queryBookDetail(@PathVariable("id") Long id) {
|
||||
return RestResult.ok(bookService.queryBookDetail(id));
|
||||
}
|
||||
|
||||
|
||||
@ -106,28 +106,28 @@ public class BookController extends BaseController {
|
||||
* 查询小说排行信息
|
||||
*/
|
||||
@GetMapping("listRank")
|
||||
public ResultBean<List<Book>> listRank(@RequestParam(value = "type", defaultValue = "0") Byte type, @RequestParam(value = "limit", defaultValue = "30") Integer limit) {
|
||||
return ResultBean.ok(bookService.listRank(type, limit));
|
||||
public RestResult<List<Book>> listRank(@RequestParam(value = "type", defaultValue = "0") Byte type, @RequestParam(value = "limit", defaultValue = "30") Integer limit) {
|
||||
return RestResult.ok(bookService.listRank(type, limit));
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加点击次数
|
||||
*/
|
||||
@PostMapping("addVisitCount")
|
||||
public ResultBean<Void> addVisitCount(Long bookId) {
|
||||
public RestResult<Void> addVisitCount(Long bookId) {
|
||||
if (enableMq == 1) {
|
||||
rabbitTemplate.convertAndSend("ADD-BOOK-VISIT-EXCHANGE", null, bookId);
|
||||
} else {
|
||||
bookService.addVisitCount(bookId, 1);
|
||||
}
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询章节相关信息
|
||||
*/
|
||||
@GetMapping("queryBookIndexAbout")
|
||||
public ResultBean<Map<String, Object>> queryBookIndexAbout(Long bookId, Long lastBookIndexId) {
|
||||
public RestResult<Map<String, Object>> queryBookIndexAbout(Long bookId, Long lastBookIndexId) {
|
||||
Map<String, Object> data = new HashMap<>(2);
|
||||
data.put("bookIndexCount", bookService.queryIndexCount(bookId));
|
||||
BookIndex bookIndex = bookService.queryBookIndex(lastBookIndexId);
|
||||
@ -136,15 +136,15 @@ public class BookController extends BaseController {
|
||||
lastBookContent = lastBookContent.substring(0, 42);
|
||||
}
|
||||
data.put("lastBookContent", lastBookContent);
|
||||
return ResultBean.ok(data);
|
||||
return RestResult.ok(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分类id查询同类推荐书籍
|
||||
*/
|
||||
@GetMapping("listRecBookByCatId")
|
||||
public ResultBean<List<Book>> listRecBookByCatId(Integer catId) {
|
||||
return ResultBean.ok(bookService.listRecBookByCatId(catId));
|
||||
public RestResult<List<Book>> listRecBookByCatId(Integer catId) {
|
||||
return RestResult.ok(bookService.listRecBookByCatId(catId));
|
||||
}
|
||||
|
||||
|
||||
@ -152,37 +152,37 @@ public class BookController extends BaseController {
|
||||
* 分页查询书籍评论列表
|
||||
*/
|
||||
@GetMapping("listCommentByPage")
|
||||
public ResultBean<PageBean<BookCommentVO>> listCommentByPage(@RequestParam("bookId") Long bookId, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize) {
|
||||
return ResultBean.ok(bookService.listCommentByPage(null, bookId, page, pageSize));
|
||||
public RestResult<PageBean<BookCommentVO>> listCommentByPage(@RequestParam("bookId") Long bookId, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize) {
|
||||
return RestResult.ok(bookService.listCommentByPage(null, bookId, page, pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增评价
|
||||
*/
|
||||
@PostMapping("addBookComment")
|
||||
public ResultBean<?> addBookComment(BookComment comment, HttpServletRequest request) {
|
||||
public RestResult<?> addBookComment(BookComment comment, HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
bookService.addBookComment(userDetails.getId(), comment);
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据小说ID查询小说前十条最新更新目录集合
|
||||
*/
|
||||
@GetMapping("queryNewIndexList")
|
||||
public ResultBean<List<BookIndex>> queryNewIndexList(Long bookId) {
|
||||
return ResultBean.ok(bookService.queryIndexList(bookId, "index_num desc", 1, 10));
|
||||
public RestResult<List<BookIndex>> queryNewIndexList(Long bookId) {
|
||||
return RestResult.ok(bookService.queryIndexList(bookId, "index_num desc", 1, 10));
|
||||
}
|
||||
|
||||
/**
|
||||
* 目录页
|
||||
*/
|
||||
@GetMapping("/queryIndexList")
|
||||
public ResultBean<PageBean<BookIndex>> indexList(Long bookId, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize, @RequestParam(value = "orderBy", defaultValue = "index_num desc") String orderBy) {
|
||||
return ResultBean.ok(new PageBean<>(bookService.queryIndexList(bookId, orderBy, page, pageSize)));
|
||||
public RestResult<PageBean<BookIndex>> indexList(Long bookId, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize, @RequestParam(value = "orderBy", defaultValue = "index_num desc") String orderBy) {
|
||||
return RestResult.ok(PageBuilder.build(bookService.queryIndexList(bookId, orderBy, page, pageSize)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
package com.java2nb.novel.controller;
|
||||
|
||||
import com.java2nb.novel.core.bean.ResultBean;
|
||||
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.service.BookService;
|
||||
import com.java2nb.novel.service.FriendLinkService;
|
||||
import com.java2nb.novel.service.NewsService;
|
||||
import io.github.xxyopen.model.resp.RestResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -40,9 +41,9 @@ public class CacheController {
|
||||
* @param type 缓存类型,1:首页书籍推荐,2:首页新闻,3:首页友情链接
|
||||
* */
|
||||
@GetMapping("refresh/{pass}/{type}")
|
||||
public ResultBean<Void> refreshCache(@PathVariable("type") Byte type, @PathVariable("pass") String pass){
|
||||
public RestResult<Void> refreshCache(@PathVariable("type") Byte type, @PathVariable("pass") String pass){
|
||||
if(!cacheManagerPass.equals(pass)){
|
||||
return ResultBean.fail(ResponseStatus.PASSWORD_ERROR);
|
||||
return RestResult.fail(ResponseStatus.PASSWORD_ERROR);
|
||||
}
|
||||
switch (type){
|
||||
case 1:{
|
||||
@ -69,7 +70,7 @@ public class CacheController {
|
||||
|
||||
}
|
||||
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
package com.java2nb.novel.controller;
|
||||
|
||||
import com.java2nb.novel.core.bean.ResultBean;
|
||||
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.core.exception.BusinessException;
|
||||
import com.java2nb.novel.core.utils.Constants;
|
||||
import com.java2nb.novel.core.utils.FileUtil;
|
||||
import com.java2nb.novel.core.utils.RandomValidateCodeUtil;
|
||||
import com.java2nb.novel.core.utils.UUIDUtil;
|
||||
import io.github.xxyopen.model.resp.RestResult;
|
||||
import io.github.xxyopen.util.UUIDUtil;
|
||||
import io.github.xxyopen.web.exception.BusinessException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -19,9 +20,8 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author 11797
|
||||
@ -64,7 +64,7 @@ public class FileController {
|
||||
@SneakyThrows
|
||||
@ResponseBody
|
||||
@PostMapping("/picUpload")
|
||||
ResultBean<String> upload(@RequestParam("file") MultipartFile file) {
|
||||
RestResult<String> upload(@RequestParam("file") MultipartFile file) {
|
||||
Date currentDate = new Date();
|
||||
String savePath =
|
||||
Constants.LOCAL_PIC_PREFIX + DateUtils.formatDate(currentDate, "yyyy") + "/" +
|
||||
@ -86,7 +86,7 @@ public class FileController {
|
||||
saveFile.delete();
|
||||
throw new BusinessException(ResponseStatus.FILE_NOT_IMAGE);
|
||||
};
|
||||
return ResultBean.ok(savePath + "/" + saveFileName);
|
||||
return RestResult.ok(savePath + "/" + saveFileName);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.java2nb.novel.controller;
|
||||
|
||||
import com.java2nb.novel.core.bean.ResultBean;
|
||||
|
||||
import com.java2nb.novel.entity.FriendLink;
|
||||
import com.java2nb.novel.service.FriendLinkService;
|
||||
import io.github.xxyopen.model.resp.RestResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@ -27,8 +27,8 @@ public class FriendLinkController {
|
||||
* 查询首页友情链接
|
||||
* */
|
||||
@GetMapping("listIndexLink")
|
||||
public ResultBean<List<FriendLink>> listIndexLink(){
|
||||
return ResultBean.ok(friendLinkService.listIndexLink());
|
||||
public RestResult<List<FriendLink>> listIndexLink(){
|
||||
return RestResult.ok(friendLinkService.listIndexLink());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.java2nb.novel.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import com.java2nb.novel.core.bean.ResultBean;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import com.java2nb.novel.entity.News;
|
||||
import com.java2nb.novel.service.NewsService;
|
||||
import io.github.xxyopen.model.resp.RestResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -26,25 +26,25 @@ public class NewsController {
|
||||
* 查询首页新闻
|
||||
* */
|
||||
@GetMapping("listIndexNews")
|
||||
public ResultBean<List<News>> listIndexNews(){
|
||||
return ResultBean.ok(newsService.listIndexNews());
|
||||
public RestResult<List<News>> listIndexNews(){
|
||||
return RestResult.ok(newsService.listIndexNews());
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询新闻列表
|
||||
* */
|
||||
@GetMapping("listByPage")
|
||||
public ResultBean<PageBean<News>> listByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize){
|
||||
return ResultBean.ok(newsService.listByPage(page,pageSize));
|
||||
public RestResult<PageBean<News>> listByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize){
|
||||
return RestResult.ok(newsService.listByPage(page,pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加新闻阅读量
|
||||
* */
|
||||
@PostMapping("addReadCount")
|
||||
public ResultBean<Void> addReadCount(@RequestParam(value = "newsId") Integer newsId){
|
||||
public RestResult<Void> addReadCount(@RequestParam(value = "newsId") Integer newsId){
|
||||
newsService.addReadCount(newsId);
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
package com.java2nb.novel.controller;
|
||||
|
||||
import com.java2nb.novel.core.bean.ResultBean;
|
||||
|
||||
import com.java2nb.novel.core.bean.UserDetails;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.core.utils.RandomValidateCodeUtil;
|
||||
import com.java2nb.novel.core.valid.AddGroup;
|
||||
import com.java2nb.novel.core.valid.UpdateGroup;
|
||||
import com.java2nb.novel.entity.User;
|
||||
import com.java2nb.novel.entity.UserBuyRecord;
|
||||
import com.java2nb.novel.service.BookService;
|
||||
import com.java2nb.novel.service.UserService;
|
||||
import io.github.xxyopen.model.resp.RestResult;
|
||||
import io.github.xxyopen.web.valid.AddGroup;
|
||||
import io.github.xxyopen.web.valid.UpdateGroup;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -41,7 +42,7 @@ public class UserController extends BaseController {
|
||||
* 登陆
|
||||
*/
|
||||
@PostMapping("login")
|
||||
public ResultBean<Map<String, Object>> login(User user) {
|
||||
public RestResult<Map<String, Object>> login(User user) {
|
||||
|
||||
//登陆
|
||||
UserDetails userDetails = userService.login(user);
|
||||
@ -49,7 +50,7 @@ public class UserController extends BaseController {
|
||||
Map<String, Object> data = new HashMap<>(1);
|
||||
data.put("token", jwtTokenUtil.generateToken(userDetails));
|
||||
|
||||
return ResultBean.ok(data);
|
||||
return RestResult.ok(data);
|
||||
|
||||
|
||||
}
|
||||
@ -58,12 +59,12 @@ public class UserController extends BaseController {
|
||||
* 注册
|
||||
*/
|
||||
@PostMapping("register")
|
||||
public ResultBean<?> register(@Validated({AddGroup.class}) User user, @RequestParam(value = "velCode", defaultValue = "") String velCode) {
|
||||
public RestResult<?> register(@Validated({AddGroup.class}) User user, @RequestParam(value = "velCode", defaultValue = "") String velCode) {
|
||||
|
||||
|
||||
//判断验证码是否正确
|
||||
if (!velCode.equals(cacheService.get(RandomValidateCodeUtil.RANDOM_CODE_KEY))) {
|
||||
return ResultBean.fail(ResponseStatus.VEL_CODE_ERROR);
|
||||
return RestResult.fail(ResponseStatus.VEL_CODE_ERROR);
|
||||
}
|
||||
|
||||
//注册
|
||||
@ -71,7 +72,7 @@ public class UserController extends BaseController {
|
||||
Map<String, Object> data = new HashMap<>(1);
|
||||
data.put("token", jwtTokenUtil.generateToken(userDetails));
|
||||
|
||||
return ResultBean.ok(data);
|
||||
return RestResult.ok(data);
|
||||
|
||||
|
||||
}
|
||||
@ -81,7 +82,7 @@ public class UserController extends BaseController {
|
||||
* 刷新token
|
||||
*/
|
||||
@PostMapping("refreshToken")
|
||||
public ResultBean<?> refreshToken(HttpServletRequest request) {
|
||||
public RestResult<?> refreshToken(HttpServletRequest request) {
|
||||
String token = getToken(request);
|
||||
if (jwtTokenUtil.canRefresh(token)) {
|
||||
token = jwtTokenUtil.refreshToken(token);
|
||||
@ -90,10 +91,10 @@ public class UserController extends BaseController {
|
||||
UserDetails userDetail = jwtTokenUtil.getUserDetailsFromToken(token);
|
||||
data.put("username", userDetail.getUsername());
|
||||
data.put("nickName", userDetail.getNickName());
|
||||
return ResultBean.ok(data);
|
||||
return RestResult.ok(data);
|
||||
|
||||
} else {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
|
||||
}
|
||||
@ -102,131 +103,131 @@ public class UserController extends BaseController {
|
||||
* 查询小说是否已加入书架
|
||||
*/
|
||||
@GetMapping("queryIsInShelf")
|
||||
public ResultBean<?> queryIsInShelf(Long bookId, HttpServletRequest request) {
|
||||
public RestResult<?> queryIsInShelf(Long bookId, HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
return ResultBean.ok(userService.queryIsInShelf(userDetails.getId(), bookId));
|
||||
return RestResult.ok(userService.queryIsInShelf(userDetails.getId(), bookId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入书架
|
||||
* */
|
||||
@PostMapping("addToBookShelf")
|
||||
public ResultBean<Void> addToBookShelf(Long bookId,Long preContentId, HttpServletRequest request) {
|
||||
public RestResult<Void> addToBookShelf(Long bookId,Long preContentId, HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
userService.addToBookShelf(userDetails.getId(),bookId,preContentId);
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移出书架
|
||||
* */
|
||||
@DeleteMapping("removeFromBookShelf/{bookId}")
|
||||
public ResultBean<?> removeFromBookShelf(@PathVariable("bookId") Long bookId, HttpServletRequest request) {
|
||||
public RestResult<?> removeFromBookShelf(@PathVariable("bookId") Long bookId, HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
userService.removeFromBookShelf(userDetails.getId(),bookId);
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询书架
|
||||
* */
|
||||
@GetMapping("listBookShelfByPage")
|
||||
public ResultBean<?> listBookShelfByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize,HttpServletRequest request) {
|
||||
public RestResult<?> listBookShelfByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize,HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
return ResultBean.ok(userService.listBookShelfByPage(userDetails.getId(),page,pageSize));
|
||||
return RestResult.ok(userService.listBookShelfByPage(userDetails.getId(),page,pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询阅读记录
|
||||
* */
|
||||
@GetMapping("listReadHistoryByPage")
|
||||
public ResultBean<?> listReadHistoryByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize,HttpServletRequest request) {
|
||||
public RestResult<?> listReadHistoryByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize,HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
return ResultBean.ok(userService.listReadHistoryByPage(userDetails.getId(),page,pageSize));
|
||||
return RestResult.ok(userService.listReadHistoryByPage(userDetails.getId(),page,pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加阅读记录
|
||||
* */
|
||||
@PostMapping("addReadHistory")
|
||||
public ResultBean<?> addReadHistory(Long bookId,Long preContentId, HttpServletRequest request) {
|
||||
public RestResult<?> addReadHistory(Long bookId,Long preContentId, HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
userService.addReadHistory(userDetails.getId(),bookId,preContentId);
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加反馈
|
||||
* */
|
||||
@PostMapping("addFeedBack")
|
||||
public ResultBean<?> addFeedBack(String content, HttpServletRequest request) {
|
||||
public RestResult<?> addFeedBack(String content, HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
userService.addFeedBack(userDetails.getId(),content);
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询我的反馈列表
|
||||
* */
|
||||
@GetMapping("listUserFeedBackByPage")
|
||||
public ResultBean<?> listUserFeedBackByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize, HttpServletRequest request){
|
||||
public RestResult<?> listUserFeedBackByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize, HttpServletRequest request){
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
return ResultBean.ok(userService.listUserFeedBackByPage(userDetails.getId(),page,pageSize));
|
||||
return RestResult.ok(userService.listUserFeedBackByPage(userDetails.getId(),page,pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询个人信息
|
||||
* */
|
||||
@GetMapping("userInfo")
|
||||
public ResultBean<?> userInfo(HttpServletRequest request) {
|
||||
public RestResult<?> userInfo(HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
return ResultBean.ok(userService.userInfo(userDetails.getId()));
|
||||
return RestResult.ok(userService.userInfo(userDetails.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新个人信息
|
||||
* */
|
||||
@PostMapping("updateUserInfo")
|
||||
public ResultBean<?> updateUserInfo(@Validated({UpdateGroup.class}) User user, HttpServletRequest request) {
|
||||
public RestResult<?> updateUserInfo(@Validated({UpdateGroup.class}) User user, HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
userService.updateUserInfo(userDetails.getId(),user);
|
||||
if(user.getNickName() != null){
|
||||
userDetails.setNickName(user.getNickName());
|
||||
Map<String, Object> data = new HashMap<>(1);
|
||||
data.put("token", jwtTokenUtil.generateToken(userDetails));
|
||||
return ResultBean.ok(data);
|
||||
return RestResult.ok(data);
|
||||
}
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
|
||||
@ -234,28 +235,28 @@ public class UserController extends BaseController {
|
||||
* 更新密码
|
||||
* */
|
||||
@PostMapping("updatePassword")
|
||||
public ResultBean<?> updatePassword(String oldPassword,String newPassword1,String newPassword2,HttpServletRequest request) {
|
||||
public RestResult<?> updatePassword(String oldPassword,String newPassword1,String newPassword2,HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
if(!(StringUtils.isNotBlank(newPassword1) && newPassword1.equals(newPassword2))){
|
||||
ResultBean.fail(ResponseStatus.TWO_PASSWORD_DIFF);
|
||||
RestResult.fail(ResponseStatus.TWO_PASSWORD_DIFF);
|
||||
}
|
||||
userService.updatePassword(userDetails.getId(),oldPassword,newPassword1);
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询用户书评
|
||||
* */
|
||||
@GetMapping("listCommentByPage")
|
||||
public ResultBean<?> listCommentByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize,HttpServletRequest request) {
|
||||
public RestResult<?> listCommentByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize,HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
return ResultBean.ok(bookService.listCommentByPage(userDetails.getId(),null,page,pageSize));
|
||||
return RestResult.ok(bookService.listCommentByPage(userDetails.getId(),null,page,pageSize));
|
||||
}
|
||||
|
||||
|
||||
@ -263,14 +264,14 @@ public class UserController extends BaseController {
|
||||
* 购买小说章节
|
||||
* */
|
||||
@PostMapping("buyBookIndex")
|
||||
public ResultBean<?> buyBookIndex(UserBuyRecord buyRecord, HttpServletRequest request) {
|
||||
public RestResult<?> buyBookIndex(UserBuyRecord buyRecord, HttpServletRequest request) {
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
return RestResult.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
buyRecord.setBuyAmount(bookService.queryBookIndex(buyRecord.getBookIndexId()).getBookPrice());
|
||||
userService.buyBookIndex(userDetails.getId(),buyRecord);
|
||||
return ResultBean.ok();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,8 @@ package com.java2nb.novel.core.filter;
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import com.java2nb.novel.core.utils.*;
|
||||
import io.github.xxyopen.util.UUIDUtil;
|
||||
import io.github.xxyopen.web.util.SpringUtil;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.Cookie;
|
||||
|
@ -2,6 +2,7 @@ package com.java2nb.novel.core.utils;
|
||||
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import io.github.xxyopen.web.util.SpringUtil;
|
||||
|
||||
/**
|
||||
* 模板操作工具类
|
||||
|
@ -1,13 +1,13 @@
|
||||
package com.java2nb.novel.page;
|
||||
|
||||
import com.java2nb.novel.controller.BaseController;
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import com.java2nb.novel.core.bean.UserDetails;
|
||||
import com.java2nb.novel.core.utils.ThreadLocalUtil;
|
||||
import com.java2nb.novel.entity.*;
|
||||
import com.java2nb.novel.service.*;
|
||||
import com.java2nb.novel.vo.BookCommentVO;
|
||||
import com.java2nb.novel.vo.BookSettingVO;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.java2nb.novel.service;
|
||||
|
||||
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import com.java2nb.novel.entity.Author;
|
||||
import com.java2nb.novel.entity.AuthorIncome;
|
||||
import com.java2nb.novel.entity.AuthorIncomeDetail;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.java2nb.novel.service;
|
||||
|
||||
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import com.java2nb.novel.entity.*;
|
||||
import com.java2nb.novel.vo.BookCommentVO;
|
||||
import com.java2nb.novel.vo.BookSettingVO;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.java2nb.novel.service;
|
||||
|
||||
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import com.java2nb.novel.entity.News;
|
||||
import com.java2nb.novel.vo.NewsVO;
|
||||
|
||||
|
@ -1,11 +1,8 @@
|
||||
package com.java2nb.novel.service;
|
||||
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import com.java2nb.novel.entity.Book;
|
||||
import com.java2nb.novel.vo.BookSpVO;
|
||||
import com.java2nb.novel.vo.BookVO;
|
||||
import com.java2nb.novel.vo.EsBookVO;
|
||||
|
||||
/**
|
||||
@ -26,5 +23,5 @@ public interface SearchService {
|
||||
* @param pageSize 每页大小
|
||||
* @return 分页信息
|
||||
*/
|
||||
PageBean<EsBookVO> searchBook(BookSpVO params, int page, int pageSize);
|
||||
io.github.xxyopen.model.page.PageBean<EsBookVO> searchBook(BookSpVO params, int page, int pageSize);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.java2nb.novel.service;
|
||||
|
||||
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import com.java2nb.novel.core.bean.UserDetails;
|
||||
import com.java2nb.novel.entity.UserBuyRecord;
|
||||
import com.java2nb.novel.entity.UserFeedback;
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.java2nb.novel.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.core.exception.BusinessException;
|
||||
import io.github.xxyopen.model.page.builder.pagehelper.PageBuilder;
|
||||
import io.github.xxyopen.web.exception.BusinessException;
|
||||
import com.java2nb.novel.entity.Author;
|
||||
import com.java2nb.novel.entity.AuthorIncome;
|
||||
import com.java2nb.novel.entity.AuthorIncomeDetail;
|
||||
@ -173,7 +174,7 @@ public class AuthorServiceImpl implements AuthorService {
|
||||
@Override
|
||||
public PageBean<AuthorIncomeDetail> listIncomeDailyByPage(int page, int pageSize, Long userId, Long bookId, Date startTime, Date endTime) {
|
||||
PageHelper.startPage(page, pageSize);
|
||||
return new PageBean<>(authorIncomeDetailMapper.selectMany(
|
||||
return PageBuilder.build(authorIncomeDetailMapper.selectMany(
|
||||
select(AuthorIncomeDetailDynamicSqlSupport.incomeDate, AuthorIncomeDetailDynamicSqlSupport.incomeAccount
|
||||
, AuthorIncomeDetailDynamicSqlSupport.incomeCount, AuthorIncomeDetailDynamicSqlSupport.incomeNumber)
|
||||
.from(AuthorIncomeDetailDynamicSqlSupport.authorIncomeDetail)
|
||||
@ -190,7 +191,7 @@ public class AuthorServiceImpl implements AuthorService {
|
||||
@Override
|
||||
public PageBean<AuthorIncome> listIncomeMonthByPage(int page, int pageSize, Long userId, Long bookId) {
|
||||
PageHelper.startPage(page, pageSize);
|
||||
return new PageBean<>(authorIncomeMapper.selectMany(select(AuthorIncomeDynamicSqlSupport.incomeMonth
|
||||
return PageBuilder.build(authorIncomeMapper.selectMany(select(AuthorIncomeDynamicSqlSupport.incomeMonth
|
||||
, AuthorIncomeDynamicSqlSupport.preTaxIncome
|
||||
, AuthorIncomeDynamicSqlSupport.afterTaxIncome
|
||||
, AuthorIncomeDynamicSqlSupport.payStatus
|
||||
|
@ -2,15 +2,12 @@ package com.java2nb.novel.service.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import com.java2nb.novel.core.config.BookPriceProperties;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.core.exception.BusinessException;
|
||||
import com.java2nb.novel.core.utils.BeanUtil;
|
||||
import io.github.xxyopen.web.util.BeanUtil;
|
||||
import com.java2nb.novel.core.utils.Constants;
|
||||
import com.java2nb.novel.core.utils.IdWorker;
|
||||
import com.java2nb.novel.core.utils.StringUtil;
|
||||
import com.java2nb.novel.entity.Book;
|
||||
import com.java2nb.novel.entity.*;
|
||||
@ -23,6 +20,10 @@ import com.java2nb.novel.vo.BookCommentVO;
|
||||
import com.java2nb.novel.vo.BookSettingVO;
|
||||
import com.java2nb.novel.vo.BookSpVO;
|
||||
import com.java2nb.novel.vo.BookVO;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import io.github.xxyopen.model.page.builder.pagehelper.PageBuilder;
|
||||
import io.github.xxyopen.util.IdWorker;
|
||||
import io.github.xxyopen.web.exception.BusinessException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -216,8 +217,7 @@ public class BookServiceImpl implements BookService {
|
||||
if (StringUtils.isNotBlank(params.getSort())) {
|
||||
OrderByHelper.orderBy(params.getSort() + " desc");
|
||||
}
|
||||
return new PageBean<>(bookMapper.searchByPage(params));
|
||||
|
||||
return PageBuilder.build(bookMapper.searchByPage(params));
|
||||
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ public class BookServiceImpl implements BookService {
|
||||
public PageBean<BookCommentVO> listCommentByPage(Long userId, Long bookId, int page, int pageSize) {
|
||||
PageHelper.startPage(page, pageSize);
|
||||
OrderByHelper.orderBy("t1.create_time desc");
|
||||
return new PageBean<>(bookCommentMapper.listCommentByPage(userId, bookId));
|
||||
return PageBuilder.build(bookCommentMapper.listCommentByPage(userId, bookId));
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -428,7 +428,7 @@ public class BookServiceImpl implements BookService {
|
||||
} else {
|
||||
//作者不存在,先创建作者
|
||||
Date currentDate = new Date();
|
||||
authorId = new IdWorker().nextId();
|
||||
authorId = IdWorker.INSTANCE.nextId();
|
||||
BookAuthor bookAuthor = new BookAuthor();
|
||||
bookAuthor.setId(authorId);
|
||||
bookAuthor.setPenName(authorName);
|
||||
@ -505,7 +505,7 @@ public class BookServiceImpl implements BookService {
|
||||
.orderBy(BookDynamicSqlSupport.createTime.descending())
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
return new PageBean<>(bookMapper.selectMany(selectStatement));
|
||||
return PageBuilder.build(bookMapper.selectMany(selectStatement));
|
||||
|
||||
}
|
||||
|
||||
@ -548,7 +548,7 @@ public class BookServiceImpl implements BookService {
|
||||
//并不是更新自己的小说
|
||||
return;
|
||||
}
|
||||
Long lastIndexId = new IdWorker().nextId();
|
||||
Long lastIndexId = IdWorker.INSTANCE.nextId();
|
||||
Date currentDate = new Date();
|
||||
int wordCount = StringUtil.getStrValidWordCount(content);
|
||||
|
||||
|
@ -7,14 +7,10 @@ import com.java2nb.novel.service.BookContentService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
||||
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.java2nb.novel.mapper.BookContentDynamicSqlSupport.bookContent;
|
||||
import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;
|
||||
import static org.mybatis.dynamic.sql.SqlBuilder.update;
|
||||
import static org.mybatis.dynamic.sql.select.SelectDSL.select;
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.java2nb.novel.service.impl;
|
||||
|
||||
import com.java2nb.novel.core.utils.BeanUtil;
|
||||
import io.github.xxyopen.web.util.BeanUtil;
|
||||
import com.java2nb.novel.service.FriendLinkService;
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.java2nb.novel.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import com.java2nb.novel.core.utils.BeanUtil;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import io.github.xxyopen.web.util.BeanUtil;
|
||||
import com.java2nb.novel.mapper.FrontNewsMapper;
|
||||
import com.java2nb.novel.service.NewsService;
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
@ -10,6 +10,7 @@ import com.java2nb.novel.core.cache.CacheService;
|
||||
import com.java2nb.novel.entity.News;
|
||||
import com.java2nb.novel.mapper.NewsMapper;
|
||||
import com.java2nb.novel.vo.NewsVO;
|
||||
import io.github.xxyopen.model.page.builder.pagehelper.PageBuilder;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
||||
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
|
||||
@ -69,7 +70,7 @@ public class NewsServiceImpl implements NewsService {
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
List<News> news = newsMapper.selectMany(selectStatement);
|
||||
PageBean<News> pageBean = new PageBean<>(news);
|
||||
PageBean<News> pageBean = PageBuilder.build(news);
|
||||
pageBean.setList(BeanUtil.copyList(news,NewsVO.class));
|
||||
return pageBean;
|
||||
}
|
||||
|
@ -2,15 +2,13 @@ package com.java2nb.novel.service.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.core.exception.BusinessException;
|
||||
import com.java2nb.novel.core.utils.StringUtil;
|
||||
import io.github.xxyopen.util.StringUtil;
|
||||
import io.github.xxyopen.web.exception.BusinessException;
|
||||
import com.java2nb.novel.entity.Book;
|
||||
import com.java2nb.novel.vo.BookSpVO;
|
||||
import com.java2nb.novel.service.SearchService;
|
||||
import com.java2nb.novel.vo.BookVO;
|
||||
import com.java2nb.novel.vo.EsBookVO;
|
||||
import io.searchbox.client.JestClient;
|
||||
import io.searchbox.core.Count;
|
||||
@ -200,8 +198,7 @@ public class SearchServiceImpl implements SearchService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new PageBean<>(page,pageSize,total.longValue(),bookList);
|
||||
return new PageBean<>(page, pageSize, total.longValue(), bookList);
|
||||
}
|
||||
throw new BusinessException(ResponseStatus.ES_SEARCH_FAIL);
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
package com.java2nb.novel.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.java2nb.novel.core.bean.PageBean;
|
||||
import io.github.xxyopen.model.page.PageBean;
|
||||
import com.java2nb.novel.core.bean.UserDetails;
|
||||
import com.java2nb.novel.core.utils.BeanUtil;
|
||||
import com.java2nb.novel.entity.*;
|
||||
import com.java2nb.novel.entity.User;
|
||||
import com.java2nb.novel.service.UserService;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.core.exception.BusinessException;
|
||||
import io.github.xxyopen.model.page.builder.pagehelper.PageBuilder;
|
||||
import io.github.xxyopen.util.IdWorker;
|
||||
import io.github.xxyopen.util.MD5Util;
|
||||
import io.github.xxyopen.web.exception.BusinessException;
|
||||
import com.java2nb.novel.mapper.*;
|
||||
import com.java2nb.novel.vo.BookReadHistoryVO;
|
||||
import com.java2nb.novel.vo.BookShelfVO;
|
||||
import com.java2nb.novel.core.utils.IdWorker;
|
||||
import com.java2nb.novel.core.utils.MD5Util;
|
||||
import com.java2nb.novel.vo.UserFeedbackVO;
|
||||
import io.github.xxyopen.web.util.BeanUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.Charsets;
|
||||
@ -73,7 +74,7 @@ public class UserServiceImpl implements UserService {
|
||||
User entity = new User();
|
||||
BeanUtils.copyProperties(user,entity);
|
||||
//数据库生成注册记录
|
||||
Long id = new IdWorker().nextId();
|
||||
Long id = IdWorker.INSTANCE.nextId();
|
||||
entity.setId(id);
|
||||
entity.setNickName(entity.getUsername());
|
||||
Date currentDate = new Date();
|
||||
@ -150,7 +151,7 @@ public class UserServiceImpl implements UserService {
|
||||
@Override
|
||||
public PageBean<BookShelfVO> listBookShelfByPage(Long userId, int page, int pageSize) {
|
||||
PageHelper.startPage(page, pageSize);
|
||||
return new PageBean<>(userBookshelfMapper.listBookShelf(userId));
|
||||
return PageBuilder.build(userBookshelfMapper.listBookShelf(userId));
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -211,7 +212,7 @@ public class UserServiceImpl implements UserService {
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
List<UserFeedback> userFeedbacks = userFeedbackMapper.selectMany(selectStatement);
|
||||
PageBean<UserFeedback> pageBean = new PageBean<>(userFeedbacks);
|
||||
PageBean<UserFeedback> pageBean = PageBuilder.build(userFeedbacks);
|
||||
pageBean.setList(BeanUtil.copyList(userFeedbacks,UserFeedbackVO.class));
|
||||
return pageBean;
|
||||
}
|
||||
@ -229,7 +230,7 @@ public class UserServiceImpl implements UserService {
|
||||
@Override
|
||||
public PageBean<BookReadHistoryVO> listReadHistoryByPage(Long userId, int page, int pageSize) {
|
||||
PageHelper.startPage(page, pageSize);
|
||||
return new PageBean<>(userReadHistoryMapper.listReadHistory(userId));
|
||||
return PageBuilder.build(userReadHistoryMapper.listReadHistory(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 8080
|
||||
port: 8083
|
||||
|
||||
spring:
|
||||
profiles:
|
||||
|
34
pom.xml
34
pom.xml
@ -78,35 +78,33 @@
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<id>ali</id>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<id>oss</id>
|
||||
<url>https://s01.oss.sonatype.org/content/groups/public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<id>ali-plugin</id>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
|
Loading…
x
Reference in New Issue
Block a user