调整数据库字段,优化部分接口 #1
@@ -7,9 +7,9 @@ import cn.celess.blog.entity.request.LinkReq;
|
|||||||
import cn.celess.blog.exception.MyException;
|
import cn.celess.blog.exception.MyException;
|
||||||
import cn.celess.blog.service.MailService;
|
import cn.celess.blog.service.MailService;
|
||||||
import cn.celess.blog.service.PartnerSiteService;
|
import cn.celess.blog.service.PartnerSiteService;
|
||||||
|
import cn.celess.blog.util.DateFormatUtil;
|
||||||
import cn.celess.blog.util.RedisUtil;
|
import cn.celess.blog.util.RedisUtil;
|
||||||
import cn.celess.blog.util.RegexUtil;
|
import cn.celess.blog.util.RegexUtil;
|
||||||
import cn.celess.blog.util.DateFormatUtil;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.mail.SimpleMailMessage;
|
import org.springframework.mail.SimpleMailMessage;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|||||||
@@ -15,14 +15,18 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package cn.celess.blog.enmu;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: 小海
|
|
||||||
* @Date: 2019/06/29 00:00
|
|
||||||
* @Description: 文章数据模型转换的级别(响应参数的选择)
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
public enum LevelEnum {
|
|
||||||
//低级
|
|
||||||
LOW(0),
|
|
||||||
//中级
|
|
||||||
MIDDLE(1),
|
|
||||||
//另一个级别的转化
|
|
||||||
BETWEEN_M_AND_H(2),
|
|
||||||
//高级
|
|
||||||
HEIGHT(3);
|
|
||||||
|
|
||||||
private int levelCode;
|
|
||||||
|
|
||||||
LevelEnum(int levelCode) {
|
|
||||||
this.levelCode = levelCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -70,8 +70,8 @@ public enum ResponseEnum {
|
|||||||
PARAMETERS_QQ_ERROR(8540, "QQ格式错误"),
|
PARAMETERS_QQ_ERROR(8540, "QQ格式错误"),
|
||||||
PARAMETERS_PWD_ERROR(8550, "密码格式错误"),
|
PARAMETERS_PWD_ERROR(8550, "密码格式错误"),
|
||||||
VERIFY_OUT(8400, "已经验证过了");
|
VERIFY_OUT(8400, "已经验证过了");
|
||||||
private int code;
|
private final int code;
|
||||||
private String msg;
|
private final String msg;
|
||||||
|
|
||||||
|
|
||||||
ResponseEnum(int code, String msg) {
|
ResponseEnum(int code, String msg) {
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package cn.celess.blog.enmu;
|
package cn.celess.blog.enmu;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: 小海
|
* @Author: 小海
|
||||||
* @Date: 2020-05-22 21:32
|
* @Date: 2020-05-22 21:32
|
||||||
@@ -26,7 +24,7 @@ public enum UserAccountStatusEnum {
|
|||||||
private final int code;
|
private final int code;
|
||||||
private final String desc;
|
private final String desc;
|
||||||
|
|
||||||
private UserAccountStatusEnum(int code, String desc) {
|
UserAccountStatusEnum(int code, String desc) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import cn.celess.blog.entity.Tag;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package cn.celess.blog.entity.model;
|
package cn.celess.blog.entity.model;
|
||||||
|
|
||||||
import cn.celess.blog.entity.Article;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package cn.celess.blog.entity.model;
|
package cn.celess.blog.entity.model;
|
||||||
|
|
||||||
import cn.celess.blog.entity.User;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package cn.celess.blog.mapper;
|
package cn.celess.blog.mapper;
|
||||||
|
|
||||||
import cn.celess.blog.entity.Article;
|
import cn.celess.blog.entity.Article;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public interface CommentMapper {
|
|||||||
|
|
||||||
List<Comment> findAllByPagePath(String pagePath);
|
List<Comment> findAllByPagePath(String pagePath);
|
||||||
|
|
||||||
List<Comment> findAllByPagePathAndFromUser(String pagePath,long userId);
|
List<Comment> findAllByPagePathAndFromUser(String pagePath, long userId);
|
||||||
|
|
||||||
List<Comment> findAllByPagePathAndPid(String pagePath, long pid);
|
List<Comment> findAllByPagePathAndPid(String pagePath, long pid);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import cn.celess.blog.entity.User;
|
|||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import cn.celess.blog.entity.WebUpdate;
|
|||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
package cn.celess.blog.service;
|
package cn.celess.blog.service;
|
||||||
|
|
||||||
import cn.celess.blog.entity.Category;
|
|
||||||
import cn.celess.blog.entity.model.CategoryModel;
|
import cn.celess.blog.entity.model.CategoryModel;
|
||||||
import cn.celess.blog.entity.model.PageData;
|
import cn.celess.blog.entity.model.PageData;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : xiaohai
|
* @author : xiaohai
|
||||||
* @date : 2019/03/28 22:42
|
* @date : 2019/03/28 22:42
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package cn.celess.blog.service;
|
|||||||
import cn.celess.blog.entity.model.CommentModel;
|
import cn.celess.blog.entity.model.CommentModel;
|
||||||
import cn.celess.blog.entity.model.PageData;
|
import cn.celess.blog.entity.model.PageData;
|
||||||
import cn.celess.blog.entity.request.CommentReq;
|
import cn.celess.blog.entity.request.CommentReq;
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package cn.celess.blog.service;
|
package cn.celess.blog.service;
|
||||||
|
|
||||||
import cn.celess.blog.entity.Tag;
|
|
||||||
import cn.celess.blog.entity.model.PageData;
|
import cn.celess.blog.entity.model.PageData;
|
||||||
import cn.celess.blog.entity.model.TagModel;
|
import cn.celess.blog.entity.model.TagModel;
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
package cn.celess.blog.service;
|
package cn.celess.blog.service;
|
||||||
|
|
||||||
import cn.celess.blog.entity.User;
|
|
||||||
import cn.celess.blog.entity.model.PageData;
|
import cn.celess.blog.entity.model.PageData;
|
||||||
import cn.celess.blog.entity.model.UserModel;
|
import cn.celess.blog.entity.model.UserModel;
|
||||||
import cn.celess.blog.entity.request.LoginReq;
|
import cn.celess.blog.entity.request.LoginReq;
|
||||||
import cn.celess.blog.entity.request.UserReq;
|
import cn.celess.blog.entity.request.UserReq;
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : xiaohai
|
* @author : xiaohai
|
||||||
@@ -154,6 +149,7 @@ public interface UserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置密码
|
* 设置密码
|
||||||
|
*
|
||||||
* @param pwd pwd
|
* @param pwd pwd
|
||||||
* @param newPwd newPwd
|
* @param newPwd newPwd
|
||||||
* @param confirmPwd confirmPwd
|
* @param confirmPwd confirmPwd
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package cn.celess.blog.service;
|
|||||||
|
|
||||||
import cn.celess.blog.entity.model.PageData;
|
import cn.celess.blog.entity.model.PageData;
|
||||||
import cn.celess.blog.entity.model.VisitorModel;
|
import cn.celess.blog.entity.model.VisitorModel;
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package cn.celess.blog.service;
|
|||||||
|
|
||||||
import cn.celess.blog.entity.model.PageData;
|
import cn.celess.blog.entity.model.PageData;
|
||||||
import cn.celess.blog.entity.model.WebUpdateModel;
|
import cn.celess.blog.entity.model.WebUpdateModel;
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ import cn.celess.blog.exception.MyException;
|
|||||||
import cn.celess.blog.mapper.*;
|
import cn.celess.blog.mapper.*;
|
||||||
import cn.celess.blog.service.ArticleService;
|
import cn.celess.blog.service.ArticleService;
|
||||||
import cn.celess.blog.service.UserService;
|
import cn.celess.blog.service.UserService;
|
||||||
import cn.celess.blog.util.*;
|
import cn.celess.blog.util.ModalTrans;
|
||||||
|
import cn.celess.blog.util.RedisUserUtil;
|
||||||
|
import cn.celess.blog.util.RegexUtil;
|
||||||
|
import cn.celess.blog.util.StringFromHtmlUtil;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.youbenzi.mdtool.tool.MDTool;
|
import com.youbenzi.mdtool.tool.MDTool;
|
||||||
@@ -22,7 +25,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import cn.celess.blog.mapper.ArticleMapper;
|
|||||||
import cn.celess.blog.mapper.CommentMapper;
|
import cn.celess.blog.mapper.CommentMapper;
|
||||||
import cn.celess.blog.mapper.UserMapper;
|
import cn.celess.blog.mapper.UserMapper;
|
||||||
import cn.celess.blog.service.CommentService;
|
import cn.celess.blog.service.CommentService;
|
||||||
import cn.celess.blog.service.UserService;
|
|
||||||
import cn.celess.blog.util.DateFormatUtil;
|
|
||||||
import cn.celess.blog.util.ModalTrans;
|
import cn.celess.blog.util.ModalTrans;
|
||||||
import cn.celess.blog.util.RedisUserUtil;
|
import cn.celess.blog.util.RedisUserUtil;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
@@ -23,7 +21,6 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,10 +73,10 @@ public class CommentServiceImpl implements CommentService {
|
|||||||
@Override
|
@Override
|
||||||
public boolean delete(long id) {
|
public boolean delete(long id) {
|
||||||
Comment b = commentMapper.findCommentById(id);
|
Comment b = commentMapper.findCommentById(id);
|
||||||
if (b == null ) {
|
if (b == null) {
|
||||||
throw new MyException(ResponseEnum.COMMENT_NOT_EXIST);
|
throw new MyException(ResponseEnum.COMMENT_NOT_EXIST);
|
||||||
}
|
}
|
||||||
if(b.isDelete()){
|
if (b.isDelete()) {
|
||||||
throw new MyException(ResponseEnum.DATA_IS_DELETED);
|
throw new MyException(ResponseEnum.DATA_IS_DELETED);
|
||||||
}
|
}
|
||||||
commentMapper.delete(id);
|
commentMapper.delete(id);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.io.InputStream;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class QiniuServiceImpl implements QiniuService {
|
public class QiniuServiceImpl implements QiniuService {
|
||||||
private static Configuration cfg = new Configuration(Zone.zone2());
|
private static final Configuration cfg = new Configuration(Zone.zone2());
|
||||||
private static UploadManager uploadManager;
|
private static UploadManager uploadManager;
|
||||||
private static BucketManager bucketManager;
|
private static BucketManager bucketManager;
|
||||||
private static Auth auth;
|
private static Auth auth;
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package cn.celess.blog.service.serviceimpl;
|
package cn.celess.blog.service.serviceimpl;
|
||||||
|
|
||||||
import cn.celess.blog.enmu.ResponseEnum;
|
import cn.celess.blog.enmu.ResponseEnum;
|
||||||
import cn.celess.blog.entity.Article;
|
|
||||||
import cn.celess.blog.entity.ArticleTag;
|
import cn.celess.blog.entity.ArticleTag;
|
||||||
import cn.celess.blog.entity.Tag;
|
import cn.celess.blog.entity.Tag;
|
||||||
import cn.celess.blog.entity.TagCategory;
|
|
||||||
import cn.celess.blog.entity.model.ArticleModel;
|
import cn.celess.blog.entity.model.ArticleModel;
|
||||||
import cn.celess.blog.entity.model.PageData;
|
import cn.celess.blog.entity.model.PageData;
|
||||||
import cn.celess.blog.entity.model.TagModel;
|
import cn.celess.blog.entity.model.TagModel;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class HttpUtil {
|
|||||||
try (
|
try (
|
||||||
InputStream inputStream = urlConnection.getInputStream();
|
InputStream inputStream = urlConnection.getInputStream();
|
||||||
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
|
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
|
||||||
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
|
BufferedReader bufferedReader = new BufferedReader(inputStreamReader)
|
||||||
) {
|
) {
|
||||||
//将bufferReader的值给放到buffer里
|
//将bufferReader的值给放到buffer里
|
||||||
String str = null;
|
String str = null;
|
||||||
|
|||||||
@@ -21,17 +21,15 @@ import java.util.Map;
|
|||||||
@Component
|
@Component
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class JwtUtil {
|
public class JwtUtil {
|
||||||
private static final String CLAIM_KEY_USERNAME = "sub";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 5天(毫秒)
|
* 5天(毫秒)
|
||||||
*/
|
*/
|
||||||
public static final long EXPIRATION_LONG_TIME = 432000000;
|
public static final long EXPIRATION_LONG_TIME = 432000000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 两小时(毫秒)
|
* 两小时(毫秒)
|
||||||
*/
|
*/
|
||||||
public static final long EXPIRATION_SHORT_TIME = 7200000;
|
public static final long EXPIRATION_SHORT_TIME = 7200000;
|
||||||
|
private static final String CLAIM_KEY_USERNAME = "sub";
|
||||||
/**
|
/**
|
||||||
* JWT 秘钥需自行设置不可泄露
|
* JWT 秘钥需自行设置不可泄露
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* Redis工具类
|
* Redis工具类
|
||||||
*
|
*
|
||||||
* @author WangFan
|
* @author WangFan
|
||||||
* @date 2018-02-24 下午03:09:50
|
|
||||||
* @version 1.1 (GitHub文档: https://github.com/whvcse/RedisUtil )
|
* @version 1.1 (GitHub文档: https://github.com/whvcse/RedisUtil )
|
||||||
|
* @date 2018-02-24 下午03:09:50
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -29,14 +29,14 @@ public class RedisUtil {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private StringRedisTemplate redisTemplate;
|
private StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
public void setRedisTemplate(StringRedisTemplate redisTemplate) {
|
|
||||||
this.redisTemplate = redisTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringRedisTemplate getRedisTemplate() {
|
public StringRedisTemplate getRedisTemplate() {
|
||||||
return this.redisTemplate;
|
return this.redisTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRedisTemplate(StringRedisTemplate redisTemplate) {
|
||||||
|
this.redisTemplate = redisTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
/** -------------------key相关操作--------------------- */
|
/** -------------------key相关操作--------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -196,6 +196,7 @@ public class RedisUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置指定 key 的值
|
* 设置指定 key 的值
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
@@ -205,6 +206,7 @@ public class RedisUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定 key 的值
|
* 获取指定 key 的值
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -214,6 +216,7 @@ public class RedisUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回 key 中字符串值的子字符
|
* 返回 key 中字符串值的子字符
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param start
|
* @param start
|
||||||
* @param end
|
* @param end
|
||||||
@@ -259,10 +262,8 @@ public class RedisUtil {
|
|||||||
* 设置ASCII码, 字符串'a'的ASCII码是97, 转为二进制是'01100001', 此方法是将二进制第offset位值变为value
|
* 设置ASCII码, 字符串'a'的ASCII码是97, 转为二进制是'01100001', 此方法是将二进制第offset位值变为value
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param postion
|
* @param offset 位置
|
||||||
* 位置
|
* @param value 值,true为1, false为0
|
||||||
* @param value
|
|
||||||
* 值,true为1, false为0
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean setBit(String key, long offset, boolean value) {
|
public boolean setBit(String key, long offset, boolean value) {
|
||||||
@@ -274,10 +275,8 @@ public class RedisUtil {
|
|||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
* @param timeout
|
* @param timeout 过期时间
|
||||||
* 过期时间
|
* @param unit 时间单位, 天:TimeUnit.DAYS 小时:TimeUnit.HOURS 分钟:TimeUnit.MINUTES
|
||||||
* @param unit
|
|
||||||
* 时间单位, 天:TimeUnit.DAYS 小时:TimeUnit.HOURS 分钟:TimeUnit.MINUTES
|
|
||||||
* 秒:TimeUnit.SECONDS 毫秒:TimeUnit.MILLISECONDS
|
* 秒:TimeUnit.SECONDS 毫秒:TimeUnit.MILLISECONDS
|
||||||
*/
|
*/
|
||||||
public void setEx(String key, String value, long timeout, TimeUnit unit) {
|
public void setEx(String key, String value, long timeout, TimeUnit unit) {
|
||||||
@@ -289,7 +288,7 @@ public class RedisUtil {
|
|||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
* @return 之前已经存在返回false,不存在返回true
|
* @return 之前已经存在返回false, 不存在返回true
|
||||||
*/
|
*/
|
||||||
public boolean setIfAbsent(String key, String value) {
|
public boolean setIfAbsent(String key, String value) {
|
||||||
return redisTemplate.opsForValue().setIfAbsent(key, value);
|
return redisTemplate.opsForValue().setIfAbsent(key, value);
|
||||||
@@ -300,8 +299,7 @@ public class RedisUtil {
|
|||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
* @param offset
|
* @param offset 从指定位置开始覆写
|
||||||
* 从指定位置开始覆写
|
|
||||||
*/
|
*/
|
||||||
public void setRange(String key, String value, long offset) {
|
public void setRange(String key, String value, long offset) {
|
||||||
redisTemplate.opsForValue().set(key, value, offset);
|
redisTemplate.opsForValue().set(key, value, offset);
|
||||||
@@ -330,7 +328,7 @@ public class RedisUtil {
|
|||||||
* 同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在
|
* 同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在
|
||||||
*
|
*
|
||||||
* @param maps
|
* @param maps
|
||||||
* @return 之前已经存在返回false,不存在返回true
|
* @return 之前已经存在返回false, 不存在返回true
|
||||||
*/
|
*/
|
||||||
public boolean multiSetIfAbsent(Map<String, String> maps) {
|
public boolean multiSetIfAbsent(Map<String, String> maps) {
|
||||||
return redisTemplate.opsForValue().multiSetIfAbsent(maps);
|
return redisTemplate.opsForValue().multiSetIfAbsent(maps);
|
||||||
@@ -340,7 +338,7 @@ public class RedisUtil {
|
|||||||
* 增加(自增长), 负数则为自减
|
* 增加(自增长), 负数则为自减
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param increment
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Long incrBy(String key, long increment) {
|
public Long incrBy(String key, long increment) {
|
||||||
@@ -348,9 +346,8 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param increment
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Double incrByFloat(String key, double increment) {
|
public Double incrByFloat(String key, double increment) {
|
||||||
@@ -526,10 +523,8 @@ public class RedisUtil {
|
|||||||
* 获取列表指定范围内的元素
|
* 获取列表指定范围内的元素
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param start
|
* @param start 开始位置, 0是开始位置
|
||||||
* 开始位置, 0是开始位置
|
* @param end 结束位置, -1返回所有
|
||||||
* @param end
|
|
||||||
* 结束位置, -1返回所有
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<String> lRange(String key, long start, long end) {
|
public List<String> lRange(String key, long start, long end) {
|
||||||
@@ -548,7 +543,6 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
@@ -558,7 +552,6 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
@@ -591,7 +584,6 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
@@ -601,7 +593,6 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
@@ -611,7 +602,6 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
@@ -647,8 +637,7 @@ public class RedisUtil {
|
|||||||
* 通过索引设置列表元素的值
|
* 通过索引设置列表元素的值
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param index
|
* @param index 位置
|
||||||
* 位置
|
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
public void lSet(String key, long index, String value) {
|
public void lSet(String key, long index, String value) {
|
||||||
@@ -669,10 +658,8 @@ public class RedisUtil {
|
|||||||
* 移出并获取列表的第一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止
|
* 移出并获取列表的第一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param timeout
|
* @param timeout 等待时间
|
||||||
* 等待时间
|
* @param unit 时间单位
|
||||||
* @param unit
|
|
||||||
* 时间单位
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String lBLeftPop(String key, long timeout, TimeUnit unit) {
|
public String lBLeftPop(String key, long timeout, TimeUnit unit) {
|
||||||
@@ -693,10 +680,8 @@ public class RedisUtil {
|
|||||||
* 移出并获取列表的最后一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止
|
* 移出并获取列表的最后一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param timeout
|
* @param timeout 等待时间
|
||||||
* 等待时间
|
* @param unit 时间单位
|
||||||
* @param unit
|
|
||||||
* 时间单位
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String lBRightPop(String key, long timeout, TimeUnit unit) {
|
public String lBRightPop(String key, long timeout, TimeUnit unit) {
|
||||||
@@ -734,8 +719,7 @@ public class RedisUtil {
|
|||||||
* 删除集合中值等于value得元素
|
* 删除集合中值等于value得元素
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param index
|
* @param index index=0, 删除所有值等于value的元素; index>0, 从头部开始删除第一个值等于value的元素;
|
||||||
* index=0, 删除所有值等于value的元素; index>0, 从头部开始删除第一个值等于value的元素;
|
|
||||||
* index<0, 从尾部开始删除第一个值等于value的元素;
|
* index<0, 从尾部开始删除第一个值等于value的元素;
|
||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
@@ -981,8 +965,6 @@ public class RedisUtil {
|
|||||||
* 获取集合所有元素
|
* 获取集合所有元素
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param otherKeys
|
|
||||||
* @param destKey
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<String> setMembers(String key) {
|
public Set<String> setMembers(String key) {
|
||||||
@@ -1022,7 +1004,6 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param options
|
* @param options
|
||||||
* @return
|
* @return
|
||||||
@@ -1046,7 +1027,6 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param values
|
* @param values
|
||||||
* @return
|
* @return
|
||||||
@@ -1056,7 +1036,6 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param values
|
* @param values
|
||||||
* @return
|
* @return
|
||||||
@@ -1103,10 +1082,8 @@ public class RedisUtil {
|
|||||||
* 获取集合的元素, 从小到大排序
|
* 获取集合的元素, 从小到大排序
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param start
|
* @param start 开始位置
|
||||||
* 开始位置
|
* @param end 结束位置, -1查询所有
|
||||||
* @param end
|
|
||||||
* 结束位置, -1查询所有
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<String> zRange(String key, long start, long end) {
|
public Set<String> zRange(String key, long start, long end) {
|
||||||
@@ -1130,10 +1107,8 @@ public class RedisUtil {
|
|||||||
* 根据Score值查询集合元素
|
* 根据Score值查询集合元素
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param min
|
* @param min 最小值
|
||||||
* 最小值
|
* @param max 最大值
|
||||||
* @param max
|
|
||||||
* 最大值
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<String> zRangeByScore(String key, double min, double max) {
|
public Set<String> zRangeByScore(String key, double min, double max) {
|
||||||
@@ -1144,10 +1119,8 @@ public class RedisUtil {
|
|||||||
* 根据Score值查询集合元素, 从小到大排序
|
* 根据Score值查询集合元素, 从小到大排序
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param min
|
* @param min 最小值
|
||||||
* 最小值
|
* @param max 最大值
|
||||||
* @param max
|
|
||||||
* 最大值
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<TypedTuple<String>> zRangeByScoreWithScores(String key,
|
public Set<TypedTuple<String>> zRangeByScoreWithScores(String key,
|
||||||
@@ -1156,7 +1129,6 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param min
|
* @param min
|
||||||
* @param max
|
* @param max
|
||||||
@@ -1224,7 +1196,6 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param min
|
* @param min
|
||||||
* @param max
|
* @param max
|
||||||
@@ -1318,7 +1289,6 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param otherKeys
|
* @param otherKeys
|
||||||
* @param destKey
|
* @param destKey
|
||||||
@@ -1359,7 +1329,6 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param options
|
* @param options
|
||||||
* @return
|
* @return
|
||||||
@@ -1370,6 +1339,7 @@ public class RedisUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Redis List 序列化
|
* 获取Redis List 序列化
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param targetClass
|
* @param targetClass
|
||||||
* @param <T>
|
* @param <T>
|
||||||
|
|||||||
@@ -33,18 +33,28 @@ import java.util.Map;
|
|||||||
@Component
|
@Component
|
||||||
public class SitemapGenerateUtil {
|
public class SitemapGenerateUtil {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ArticleMapper articleMapper;
|
||||||
@Value("${sitemap.path}")
|
@Value("${sitemap.path}")
|
||||||
private String path;
|
private String path;
|
||||||
private Map<String, String> urlList;
|
private Map<String, String> urlList;
|
||||||
|
|
||||||
@Autowired
|
private static DocumentBuilder getDocumentBuilder() {
|
||||||
ArticleMapper articleMapper;
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||||
|
DocumentBuilder db = null;
|
||||||
|
try {
|
||||||
|
db = dbf.newDocumentBuilder();
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void createSitemap() {
|
public void createSitemap() {
|
||||||
initList();
|
initList();
|
||||||
if ("".equals(path) || "classpath".equals(path)) {
|
if ("".equals(path) || "classpath".equals(path)) {
|
||||||
path = System.getProperty("user.dir")+"/sitemap.xml";
|
path = System.getProperty("user.dir") + "/sitemap.xml";
|
||||||
}
|
}
|
||||||
File file = new File(path);
|
File file = new File(path);
|
||||||
try {
|
try {
|
||||||
@@ -96,17 +106,5 @@ public class SitemapGenerateUtil {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static DocumentBuilder getDocumentBuilder() {
|
|
||||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
|
||||||
DocumentBuilder db = null;
|
|
||||||
try {
|
|
||||||
db = dbf.newDocumentBuilder();
|
|
||||||
} catch (ParserConfigurationException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user