模块化拆分
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package cn.celess.common.config;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@MapperScan("cn.celess.common.mapper")
|
||||
public class MybatisConfig {
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.celess.common.enmu;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-05-25 08:58
|
||||
* @Desc:
|
||||
*/
|
||||
@Getter
|
||||
public enum CommentStatusEnum {
|
||||
// 正常
|
||||
NORMAL(0, "正常"),
|
||||
DELETED(3, "已删除");
|
||||
|
||||
private final int code;
|
||||
private final String msg;
|
||||
|
||||
CommentStatusEnum(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package cn.celess.common.enmu;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 15:37
|
||||
*/
|
||||
public enum ResponseEnum {
|
||||
// Response enum
|
||||
|
||||
SUCCESS(0, "成功"),
|
||||
FAILURE(-1, "失败"),
|
||||
ERROR(-2, "错误"),
|
||||
|
||||
DATA_IS_DELETED(1000, "数据已被删除"),
|
||||
|
||||
//文章类
|
||||
ARTICLE_NOT_EXIST(2010, "文章不存在"),
|
||||
ARTICLE_HAS_EXIST(2020, "文章已存在"),
|
||||
ARTICLE_NOT_PUBLIC(2030, "文章暂未公开"),
|
||||
ARTICLE_NOT_BELONG_YOU(2040, "无权限操作别人的文章"),
|
||||
|
||||
//用户类
|
||||
HAVE_NOT_LOG_IN(3010, "还未登录"),
|
||||
PERMISSION_ERROR(3020, "没有此权限"),
|
||||
USER_NOT_EXIST(3030, "用户不存在"),
|
||||
USERNAME_HAS_EXIST(3040, "用户名已存在"),
|
||||
USERNAME_TOO_SHORT(3050, "用户名太短"),
|
||||
PASSWORD_TOO_SHORT_OR_LONG(3060, "密码长度过长或者过短"),
|
||||
LOGIN_FAILURE(3100, "登录失败,用户名/密码不正确"),
|
||||
USEREMAIL_NULL(3310, "未设置邮箱"),
|
||||
USEREMAIL_NOT_VERIFY(3320, "邮箱未验证"),
|
||||
LOGIN_LATER(3500, "错误次数已达5次,请稍后再试"),
|
||||
PWD_SAME(3601, "新密码与原密码相同"),
|
||||
PWD_NOT_SAME(3602, "新密码与原密码不相同"),
|
||||
LOGIN_EXPIRED(3700, "登陆过期"),
|
||||
LOGOUT(3710, "账户已注销"),
|
||||
CAN_NOT_USE(3711, "账户不可用"),
|
||||
PWD_WRONG(3800, "密码不正确"),
|
||||
|
||||
JWT_EXPIRED(3810, "Token过期"),
|
||||
JWT_MALFORMED(3820, "Token格式不对"),
|
||||
JWT_SIGNATURE(3830, "Token签名错误"),
|
||||
JWT_NOT_SUPPORT(3840, "不支持的Token"),
|
||||
|
||||
//标签
|
||||
TAG_NOT_EXIST(4010, "标签不存在"),
|
||||
TAG_HAS_EXIST(4020, "标签已存在"),
|
||||
|
||||
//分类
|
||||
CATEGORY_NOT_EXIST(5010, "分类不存在"),
|
||||
CATEGORY_HAS_EXIST(5020, "分类已存在"),
|
||||
|
||||
//评论/留言
|
||||
COMMENT_NOT_EXIST(6010, "评论/留言不存在"),
|
||||
COMMENT_HAS_EXIST(6020, "评论/留言已存在,请不要重复提交"),
|
||||
|
||||
//webUdpateInfo amd PartnerSite
|
||||
DATA_NOT_EXIST(7010, "数据不存在"),
|
||||
DATA_HAS_EXIST(7020, "数据已存在"),
|
||||
|
||||
//其他
|
||||
APPLY_LINK_NO_ADD_THIS_SITE(7200, "暂未在您的网站中抓取到本站链接"),
|
||||
DATA_EXPIRED(7300, "数据过期"),
|
||||
CANNOT_GET_DATA(7400, "暂无法获取到数据"),
|
||||
NO_FILE(7500, "未选择文件,请重新选择"),
|
||||
|
||||
|
||||
//提交更新之前,没有获取数据/,
|
||||
DID_NOT_GET_THE_DATA(8020, "非法访问"),
|
||||
IMG_CODE_TIMEOUT(8100, "验证码已失效"),
|
||||
IMG_CODE_DIDNOTVERIFY(8200, "请先验证验证码"),
|
||||
VERIFY_ERROR(8300, "验证失败"),
|
||||
PARAMETERS_ERROR(8500, "参数错误"),
|
||||
PARAMETERS_URL_ERROR(8510, "链接格式错误"),
|
||||
PARAMETERS_EMAIL_ERROR(8520, "邮箱格式错误"),
|
||||
PARAMETERS_PHONE_ERROR(8530, "手机格式错误"),
|
||||
PARAMETERS_QQ_ERROR(8540, "QQ格式错误"),
|
||||
PARAMETERS_PWD_ERROR(8550, "密码格式错误"),
|
||||
VERIFY_OUT(8400, "已经验证过了");
|
||||
private final int code;
|
||||
private final String msg;
|
||||
|
||||
|
||||
ResponseEnum(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.celess.common.enmu;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-05-24 16:31
|
||||
* @Desc:
|
||||
*/
|
||||
@Getter
|
||||
public enum RoleEnum {
|
||||
// admin 权限
|
||||
ADMIN_ROLE("admin"),
|
||||
// user 权限
|
||||
USER_ROLE("user");
|
||||
|
||||
|
||||
private final String roleName;
|
||||
|
||||
RoleEnum(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package cn.celess.common.enmu;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-05-22 21:32
|
||||
* @Desc:
|
||||
*/
|
||||
public enum UserAccountStatusEnum {
|
||||
|
||||
/**
|
||||
* 账户正常
|
||||
*/
|
||||
NORMAL(0, "正常"),
|
||||
/**
|
||||
* 账户被锁定
|
||||
*/
|
||||
LOCKED(1, "锁定"),
|
||||
/**
|
||||
* 账户被删除
|
||||
*/
|
||||
DELETED(2, "已删除");
|
||||
|
||||
|
||||
private final int code;
|
||||
private final String desc;
|
||||
|
||||
UserAccountStatusEnum(int code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public static UserAccountStatusEnum get(int code) {
|
||||
for (UserAccountStatusEnum value : UserAccountStatusEnum.values()) {
|
||||
if (value.code == code) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static UserAccountStatusEnum get(Map<String, Object> map) {
|
||||
for (UserAccountStatusEnum value : UserAccountStatusEnum.values()) {
|
||||
if (value.code == (int) map.get("code") && value.desc.equals(map.get("desc"))) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public Map<String, Object> toJson() {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("code", code);
|
||||
map.put("desc", desc);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 14:51
|
||||
*/
|
||||
@Data
|
||||
public class Article implements Serializable {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 摘要
|
||||
*/
|
||||
private String summary;
|
||||
|
||||
/**
|
||||
* Markdown正文
|
||||
*/
|
||||
private String mdContent;
|
||||
|
||||
/**
|
||||
* 文章类型 true(1)为原创 false(0)为转载
|
||||
*/
|
||||
private Boolean type;
|
||||
|
||||
/**
|
||||
* 若为转载 则为转载文章的url
|
||||
*/
|
||||
private String url = null;
|
||||
|
||||
private Date publishDate;
|
||||
|
||||
private Date updateDate = null;
|
||||
|
||||
private Long readingNumber;
|
||||
|
||||
/**
|
||||
* 文章的状态 true:公开 false:不公开
|
||||
*/
|
||||
private Boolean open;
|
||||
|
||||
private Category category;
|
||||
|
||||
private List<Tag> tags;
|
||||
|
||||
private Integer likeCount;
|
||||
|
||||
private Integer dislikeCount;
|
||||
|
||||
private User user;
|
||||
|
||||
private boolean deleted = false;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-05-24 14:52
|
||||
* @Desc:
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ArticleTag implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private Article article;
|
||||
|
||||
private TagCategory tag;
|
||||
|
||||
public ArticleTag(Article article, TagCategory tag) {
|
||||
this.article = article;
|
||||
this.tag = tag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 22:18
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
public class Category extends TagCategory implements Serializable {
|
||||
public Category(String name) {
|
||||
super.setName(name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/29 16:47
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class Comment implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private int status;
|
||||
|
||||
private String pagePath;
|
||||
|
||||
private String content;
|
||||
|
||||
private Date date;
|
||||
|
||||
private User fromUser;
|
||||
|
||||
private User toUser;
|
||||
/**
|
||||
* 评论的父ID
|
||||
*/
|
||||
private Long pid;
|
||||
|
||||
// private boolean delete;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 友链
|
||||
*
|
||||
* @author : xiaohai
|
||||
* @date : 2019/05/12 11:33
|
||||
*/
|
||||
@Data
|
||||
public class PartnerSite implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String url;
|
||||
|
||||
private Boolean open;
|
||||
|
||||
private String iconPath;
|
||||
|
||||
private String desc;
|
||||
|
||||
private Boolean delete = false;
|
||||
|
||||
private String email;
|
||||
|
||||
private Boolean notification = true;
|
||||
|
||||
public PartnerSite() {
|
||||
}
|
||||
|
||||
public PartnerSite(String name, String url, Boolean open) {
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
this.open = open;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import cn.celess.common.enmu.ResponseEnum;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Data;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 15:24
|
||||
*/
|
||||
@Data
|
||||
public class Response<T> implements Serializable {
|
||||
private int code;
|
||||
private String msg;
|
||||
private T result;
|
||||
|
||||
public Response() {
|
||||
}
|
||||
|
||||
public Response(int code, String msg, T result) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功相应
|
||||
*
|
||||
* @param result 结果
|
||||
* @return Response
|
||||
*/
|
||||
public static <T> Response<T> success(T result) {
|
||||
return new Response<T>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败的响应
|
||||
*
|
||||
* @param result 结果
|
||||
* @return Response
|
||||
*/
|
||||
public static Response<String> failure(String result) {
|
||||
return new Response<String>(ResponseEnum.FAILURE.getCode(), ResponseEnum.FAILURE.getMsg(), result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 其他的响应
|
||||
*
|
||||
* @param r 枚举常量
|
||||
* @param result 结果
|
||||
* @return Response
|
||||
*/
|
||||
public static <T> Response<T> response(ResponseEnum r, T result) {
|
||||
return new Response<T>(r.getCode(), r.getMsg(), result);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ObjectMapper().writeValueAsString(this);
|
||||
}
|
||||
}
|
||||
17
blog-common/src/main/java/cn/celess/common/entity/Tag.java
Normal file
17
blog-common/src/main/java/cn/celess/common/entity/Tag.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 22:19
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
public class Tag extends TagCategory implements Serializable {
|
||||
|
||||
public Tag(String name) {
|
||||
super.setName(name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-05-24 14:03
|
||||
* @Desc:
|
||||
*/
|
||||
@Data
|
||||
public class TagCategory implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Boolean category = true;
|
||||
|
||||
private Boolean deleted = false;
|
||||
}
|
||||
54
blog-common/src/main/java/cn/celess/common/entity/User.java
Normal file
54
blog-common/src/main/java/cn/celess/common/entity/User.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 14:52
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class User implements Serializable {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@JsonIgnore
|
||||
private String pwd;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String displayName;
|
||||
|
||||
private Boolean emailStatus = false;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
private String avatarImgUrl;
|
||||
|
||||
private String desc;
|
||||
|
||||
private Date recentlyLandedDate;
|
||||
|
||||
private String role = "user";
|
||||
|
||||
private int status;
|
||||
|
||||
public User(String email, String pwd) {
|
||||
this.email = email;
|
||||
this.pwd = pwd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/04/02 22:14
|
||||
*/
|
||||
@Data
|
||||
public class Visitor implements Serializable {
|
||||
|
||||
private long id;
|
||||
private String ip;
|
||||
private Date date;
|
||||
private String ua;
|
||||
private boolean delete;
|
||||
|
||||
public Visitor(String ip, Date date, String ua) {
|
||||
this.ip = ip;
|
||||
this.date = date;
|
||||
this.ua = ua;
|
||||
}
|
||||
|
||||
public Visitor() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.celess.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/05/12 11:29
|
||||
*/
|
||||
@Data
|
||||
public class WebUpdate implements Serializable {
|
||||
|
||||
private long id;
|
||||
|
||||
private String updateInfo;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
private boolean delete;
|
||||
|
||||
public WebUpdate() {
|
||||
}
|
||||
|
||||
public WebUpdate(String updateInfo) {
|
||||
this.updateInfo = updateInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.celess.common.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/06/01 22:46
|
||||
*/
|
||||
@Data
|
||||
public class ArticleReq implements Serializable {
|
||||
private Long id;
|
||||
private String title;
|
||||
private String mdContent;
|
||||
private String[] tags;
|
||||
private Boolean type;
|
||||
private String url;
|
||||
private String category;
|
||||
private Boolean open = true;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.celess.common.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/06/02 10:35
|
||||
*/
|
||||
@Data
|
||||
public class CommentReq implements Serializable {
|
||||
private Long id;
|
||||
private String content;
|
||||
private long pid = -1;
|
||||
private String pagePath;
|
||||
private long toUserId = -1;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.celess.common.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2020/07/31 20:50
|
||||
*/
|
||||
@Data
|
||||
public class LinkApplyReq implements Serializable {
|
||||
private String name;
|
||||
private String email;
|
||||
private String url;
|
||||
private String linkUrl;
|
||||
private String desc;
|
||||
private String iconPath;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.celess.common.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/06/02 11:40
|
||||
*/
|
||||
@Data
|
||||
public class LinkReq implements Serializable {
|
||||
private long id;
|
||||
private String name;
|
||||
private String url;
|
||||
private String iconPath;
|
||||
private String desc;
|
||||
private boolean open;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.celess.common.entity.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/06/01 22:47
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LoginReq implements Serializable {
|
||||
private String email;
|
||||
private String password;
|
||||
/**
|
||||
* isRememberMe默认为false
|
||||
*/
|
||||
private Boolean isRememberMe = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.celess.common.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/09/06 13:33
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class UserReq implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private String email;
|
||||
|
||||
private String pwd;
|
||||
|
||||
private String displayName;
|
||||
|
||||
private Boolean emailStatus;
|
||||
|
||||
private String desc;
|
||||
|
||||
private String role;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import cn.celess.common.entity.Tag;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/04/23 12:02
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ArticleModel implements Serializable {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 摘要
|
||||
*/
|
||||
private String summary;
|
||||
|
||||
/**
|
||||
* Markdown正文
|
||||
*/
|
||||
private String mdContent;
|
||||
|
||||
/**
|
||||
* 文章类型 true(1)为原创 false(0)为转载
|
||||
*/
|
||||
private Boolean original;
|
||||
|
||||
/**
|
||||
* 若为转载 则为转载文章的url
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
private String publishDateFormat;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private String updateDateFormat;
|
||||
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
private List<Tag> tags;
|
||||
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
private UserModel author;
|
||||
|
||||
private ArticleModel preArticle;
|
||||
|
||||
private ArticleModel nextArticle;
|
||||
|
||||
/**
|
||||
* 阅读数
|
||||
*/
|
||||
private Long readingNumber;
|
||||
|
||||
private Integer likeCount;
|
||||
|
||||
private Integer dislikeCount;
|
||||
|
||||
/**
|
||||
* 文章的状态 true:公开 false:不公开
|
||||
*/
|
||||
private Boolean open;
|
||||
|
||||
private boolean deleted;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-03-29 12:18
|
||||
* @Desc:
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CategoryModel implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private List<ArticleModel> articles;
|
||||
private boolean deleted;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/04/22 21:50
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class CommentModel implements Serializable {
|
||||
private long id;
|
||||
|
||||
private UserModel fromUser;
|
||||
|
||||
private UserModel toUser;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 文章标题
|
||||
*/
|
||||
private String pagePath;
|
||||
|
||||
/**
|
||||
* 发布日期
|
||||
*/
|
||||
private String date;
|
||||
|
||||
/**
|
||||
* 评论的父ID
|
||||
*/
|
||||
private Long pid;
|
||||
|
||||
private List<CommentModel> respComment;
|
||||
|
||||
private int status;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-05-25 17:13
|
||||
* @Desc:
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PageData<T> implements Serializable {
|
||||
|
||||
private List<T> list;
|
||||
|
||||
private long total;
|
||||
|
||||
private int pageSize;
|
||||
|
||||
private int pageNum;
|
||||
|
||||
public PageData(PageInfo pageInfo) {
|
||||
this.pageNum = pageInfo.getPageNum();
|
||||
this.pageSize = pageInfo.getPageSize();
|
||||
this.total = pageInfo.getTotal();
|
||||
}
|
||||
|
||||
public PageData(PageInfo pageInfo, List<T> data) {
|
||||
this(pageInfo);
|
||||
this.list = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/04/21 22:43
|
||||
*/
|
||||
public class QiniuResponse implements Serializable {
|
||||
public String key;
|
||||
public String hash;
|
||||
public String bucket;
|
||||
public long fsize;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-03-29 13:56
|
||||
* @Desc:
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TagModel implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private List<ArticleModel> articles;
|
||||
|
||||
private boolean deleted;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import cn.celess.common.enmu.UserAccountStatusEnum;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/04/22 23:13
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class UserModel implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String displayName;
|
||||
|
||||
private Boolean emailStatus = false;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
private String avatarImgUrl;
|
||||
|
||||
private String desc;
|
||||
|
||||
private String recentlyLandedDate;
|
||||
|
||||
private String role = "user";
|
||||
|
||||
private String token;
|
||||
|
||||
private UserAccountStatusEnum status;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/05/05 16:05
|
||||
*/
|
||||
@Data
|
||||
public class VisitorModel implements Serializable {
|
||||
private long id;
|
||||
|
||||
private String ip;
|
||||
|
||||
private String date;
|
||||
|
||||
private String browserName;
|
||||
|
||||
private String browserVersion;
|
||||
|
||||
private String OSName;
|
||||
|
||||
private String location;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.celess.common.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/05/12 11:32
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class WebUpdateModel implements Serializable {
|
||||
private long id;
|
||||
|
||||
private String info;
|
||||
|
||||
private String time;
|
||||
|
||||
public WebUpdateModel(long id, String info, String time) {
|
||||
this.id = id;
|
||||
this.info = info;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
private boolean deleted;
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package cn.celess.common.exception;
|
||||
|
||||
import cn.celess.common.enmu.ResponseEnum;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.service.MailService;
|
||||
import cn.celess.common.util.DateFormatUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 17:02
|
||||
*/
|
||||
|
||||
@ControllerAdvice
|
||||
public class ExceptionHandle {
|
||||
public static final Logger logger = LoggerFactory.getLogger(ExceptionHandle.class);
|
||||
@Resource
|
||||
MailService mailService;
|
||||
@Autowired
|
||||
HttpServletRequest request;
|
||||
@Value("${spring.profiles.active}")
|
||||
private String activeModel;
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
@ResponseBody
|
||||
public Response handle(Exception e) {
|
||||
//自定义错误
|
||||
if (e instanceof MyException) {
|
||||
MyException exception = (MyException) e;
|
||||
logger.debug("返回了自定义的exception,[code={},msg={},result={}]", exception.getCode(), e.getMessage(), exception.getResult());
|
||||
return new Response(exception.getCode(), e.getMessage(), exception.getResult());
|
||||
}
|
||||
//请求路径不支持该方法
|
||||
if (e instanceof HttpRequestMethodNotSupportedException) {
|
||||
logger.debug("遇到请求路径与请求方法不匹配的请求,[msg={},path:{},method:{}]", e.getMessage(), request.getRequestURL(), request.getMethod());
|
||||
return new Response(ResponseEnum.ERROR.getCode(), e.getMessage(), null);
|
||||
}
|
||||
//数据输入类型不匹配
|
||||
if (e instanceof MethodArgumentTypeMismatchException) {
|
||||
logger.debug("输入类型不匹配,[msg={}]", e.getMessage());
|
||||
return new Response(ResponseEnum.PARAMETERS_ERROR.getCode(), "数据输入有问题,请修改后再访问", null);
|
||||
}
|
||||
//数据验证失败
|
||||
if (e instanceof BindException) {
|
||||
logger.debug("数据验证失败,[msg={}]", e.getMessage());
|
||||
return new Response(ResponseEnum.PARAMETERS_ERROR.getCode(), "数据输入有问题,请修改", null);
|
||||
}
|
||||
//数据输入不完整
|
||||
if (e instanceof MissingServletRequestParameterException) {
|
||||
logger.debug("数据输入不完整,[msg={}]", e.getMessage());
|
||||
return new Response(ResponseEnum.PARAMETERS_ERROR.getCode(), "数据输入不完整,请检查", null);
|
||||
}
|
||||
|
||||
// 发送错误信息到邮箱
|
||||
if ("prod".equals(activeModel)) {
|
||||
logger.debug("有一个未捕获的bug,已发送到邮箱");
|
||||
sendMessage(e);
|
||||
}
|
||||
e.printStackTrace();
|
||||
return new Response(ResponseEnum.ERROR.getCode(), "服务器出现错误,已记录", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送错误信息
|
||||
*
|
||||
* @param e 错误
|
||||
*/
|
||||
private void sendMessage(Exception e) {
|
||||
SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
|
||||
simpleMailMessage.setTo("a@celess.cn");
|
||||
simpleMailMessage.setSubject("服务器出现了错误");
|
||||
StringBuilder msg = new StringBuilder();
|
||||
String queryString = request.getQueryString();
|
||||
msg.append("requirePath:\n").append(request.getRequestURL().toString());
|
||||
if (queryString != null) {
|
||||
msg.append("?").append(queryString);
|
||||
}
|
||||
msg.append("\n\n\n");
|
||||
msg.append("msg:\n").append(e.getMessage()).append("\n\n\n");
|
||||
msg.append("date:\n").append(DateFormatUtil.getNow()).append("\n\n\n");
|
||||
msg.append("from:\n").append(request.getHeader("User-Agent")).append("\n\n\n");
|
||||
msg.append("ip:\n").append(request.getRemoteAddr()).append("\n\n\n");
|
||||
simpleMailMessage.setText(msg.toString());
|
||||
mailService.AsyncSend(simpleMailMessage);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package cn.celess.common.exception;
|
||||
|
||||
import cn.celess.common.enmu.ResponseEnum;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 16:56
|
||||
*/
|
||||
@Data
|
||||
public class MyException extends RuntimeException {
|
||||
private int code;
|
||||
private Object result;
|
||||
|
||||
public MyException(int code, String msg) {
|
||||
super(msg);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public MyException(ResponseEnum e) {
|
||||
super(e.getMsg());
|
||||
this.code = e.getCode();
|
||||
}
|
||||
|
||||
public MyException(ResponseEnum e, Object result) {
|
||||
super(e.getMsg());
|
||||
this.code = e.getCode();
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public MyException(ResponseEnum e, String msg) {
|
||||
super(msg + e.getMsg());
|
||||
this.code = e.getCode();
|
||||
}
|
||||
|
||||
public MyException(ResponseEnum e, String msg, Object result) {
|
||||
super(e.getMsg());
|
||||
this.code = e.getCode();
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.common.entity.Article;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/06/27 20:43
|
||||
* @Description:
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface ArticleMapper {
|
||||
|
||||
int insert(Article a);
|
||||
|
||||
int delete(long id);
|
||||
|
||||
int update(Article a);
|
||||
|
||||
Article getLastestArticle();
|
||||
|
||||
Article findArticleById(long id);
|
||||
|
||||
boolean existsByTitle(String title);
|
||||
|
||||
boolean isDeletedById(long id);
|
||||
|
||||
List<Article> findAllByAuthorId(long authorId);
|
||||
|
||||
List<Article> findAllByOpen(boolean isOpen);
|
||||
|
||||
String getTitleById(long id);
|
||||
|
||||
List<Article> findAllByCategoryId(long id);
|
||||
|
||||
List<Article> findAllByCategoryIdAndOpen(long id);
|
||||
|
||||
List<Article> findAll();
|
||||
|
||||
@Cacheable(value = {"articleDao"}, key = "'getPreArticle:'+#id")
|
||||
Article getPreArticle(Long id);
|
||||
|
||||
@Cacheable(value = {"articleDao"}, key = "'getNextArticle:'+#id")
|
||||
Article getNextArticle(Long id);
|
||||
|
||||
int updateReadingNumber(long id);
|
||||
|
||||
long count();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.common.entity.ArticleTag;
|
||||
import cn.celess.common.entity.Tag;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-05-24 14:21
|
||||
* @Desc:
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface ArticleTagMapper {
|
||||
|
||||
int insert(ArticleTag articleTag);
|
||||
|
||||
int update(ArticleTag articleTag);
|
||||
|
||||
ArticleTag findOneById(Long id);
|
||||
|
||||
int deleteById(Long id);
|
||||
|
||||
int deleteByArticleId(Long articleId);
|
||||
|
||||
List<ArticleTag> findAllByArticleId(Long articleId);
|
||||
|
||||
List<Tag> findTagByArticleId(Long articleId);
|
||||
|
||||
int deleteMultiById(List<ArticleTag> articleTags);
|
||||
|
||||
List<ArticleTag> findArticleByTag(Long tagId);
|
||||
|
||||
List<ArticleTag> findArticleByTagAndOpen(Long tagId);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.common.entity.Category;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/06/30 12:56
|
||||
* @Description:
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface CategoryMapper {
|
||||
int insert(Category c);
|
||||
|
||||
int delete(long id);
|
||||
|
||||
int update(Category c);
|
||||
|
||||
boolean existsByName(String name);
|
||||
|
||||
boolean existsById(long id);
|
||||
|
||||
Category findCategoryByName(String name);
|
||||
|
||||
Category findCategoryById(long id);
|
||||
|
||||
List<Category> findAll();
|
||||
|
||||
List<String> getAllName();
|
||||
|
||||
String getNameById(long id);
|
||||
|
||||
Long getIdByName(String name);
|
||||
|
||||
Category getLastestCategory();
|
||||
|
||||
long count();
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.common.entity.Comment;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/06/30 16:19
|
||||
* @Description:
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface CommentMapper {
|
||||
int insert(Comment c);
|
||||
|
||||
int updateContent(String content, long id);
|
||||
|
||||
int delete(long id);
|
||||
|
||||
int deleteByPagePath(String pagePath);
|
||||
|
||||
boolean existsById(long id);
|
||||
|
||||
Comment findCommentById(long id);
|
||||
|
||||
Comment getLastestComment();
|
||||
|
||||
List<Comment> findAllByFromUser(long id);
|
||||
|
||||
List<Comment> findAllByPid(long pid);
|
||||
|
||||
List<Comment> findAllByPagePath(String pagePath);
|
||||
|
||||
List<Comment> findAllByPagePathAndFromUser(String pagePath, long userId);
|
||||
|
||||
List<Comment> findAllByPagePathAndPidAndNormal(String pagePath, long pid);
|
||||
|
||||
long countByPagePath(String pagePath);
|
||||
|
||||
long count();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.common.entity.PartnerSite;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/07/03 00:22
|
||||
* @Description:
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface PartnerMapper {
|
||||
int insert(PartnerSite site);
|
||||
|
||||
int delete(long id);
|
||||
|
||||
int update(PartnerSite site);
|
||||
|
||||
boolean existsById(long id);
|
||||
|
||||
boolean existsByName(String name);
|
||||
|
||||
boolean existsByUrl(String url);
|
||||
|
||||
PartnerSite findById(long id);
|
||||
|
||||
PartnerSite findByName(String name);
|
||||
|
||||
PartnerSite findByUrl(String url);
|
||||
|
||||
PartnerSite getLastest();
|
||||
|
||||
List<PartnerSite> findAll();
|
||||
|
||||
List<PartnerSite> findAll(Boolean deleted);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.common.entity.Tag;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/06/29 22:00
|
||||
* @Description:
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface TagMapper {
|
||||
int insert(Tag tag);
|
||||
|
||||
int update(Tag tag);
|
||||
|
||||
int delete(long id);
|
||||
|
||||
Tag findTagById(long id);
|
||||
|
||||
Tag findTagByName(String name);
|
||||
|
||||
Boolean existsByName(String name);
|
||||
|
||||
Tag getLastestTag();
|
||||
|
||||
List<Tag> findAll();
|
||||
|
||||
long count();
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.common.entity.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/07/03 00:23
|
||||
* @Description:
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface UserMapper {
|
||||
|
||||
int addUser(User user);
|
||||
|
||||
int updateInfo(String desc, String displayName, long id);
|
||||
|
||||
int updateAvatarImgUrl(String avatarImgUrl, long id);
|
||||
|
||||
int updateLoginTime(String email);
|
||||
|
||||
int updateEmailStatus(String email, boolean status);
|
||||
|
||||
int updatePwd(String email, String pwd);
|
||||
|
||||
String getPwd(String email);
|
||||
|
||||
boolean existsByEmail(String email);
|
||||
|
||||
User findByEmail(String email);
|
||||
|
||||
User findById(long id);
|
||||
|
||||
String getAvatarImgUrlById(long id);
|
||||
|
||||
String getEmail(long id);
|
||||
|
||||
String getDisPlayName(long id);
|
||||
|
||||
String getRoleByEmail(String email);
|
||||
|
||||
String getRoleById(long id);
|
||||
|
||||
long count();
|
||||
|
||||
int delete(long id);
|
||||
|
||||
int lock(long id);
|
||||
|
||||
int setUserRole(Long id, String role);
|
||||
|
||||
List<User> findAll(Integer status);
|
||||
|
||||
List<User> findAll();
|
||||
|
||||
int update(User user);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.common.entity.Visitor;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/07/03 00:23
|
||||
* @Description:
|
||||
*/
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface VisitorMapper {
|
||||
int insert(Visitor visitor);
|
||||
|
||||
int delete(long id);
|
||||
|
||||
List<Visitor> findAll();
|
||||
|
||||
List<Visitor> findAllNotDeleted();
|
||||
|
||||
long count();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.common.entity.WebUpdate;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/07/03 00:24
|
||||
* @Description:
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface WebUpdateInfoMapper {
|
||||
int insert(WebUpdate webUpdate);
|
||||
|
||||
int delete(long id);
|
||||
|
||||
int update(long id, String info);
|
||||
|
||||
boolean existsById(long id);
|
||||
|
||||
WebUpdate findById(long id);
|
||||
|
||||
List<WebUpdate> findAll();
|
||||
|
||||
List<WebUpdate> findAllNotDeleted();
|
||||
|
||||
WebUpdate getLastestOne();
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.common.entity.dto.ArticleReq;
|
||||
import cn.celess.common.entity.vo.ArticleModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 15:20
|
||||
*/
|
||||
@Service
|
||||
public interface ArticleService {
|
||||
/**
|
||||
* 新增一篇文章
|
||||
*
|
||||
* @param reqBody 请求文章的数据
|
||||
* @return 文章数据
|
||||
*/
|
||||
ArticleModel create(ArticleReq reqBody);
|
||||
|
||||
/**
|
||||
* 删除一篇文章
|
||||
*
|
||||
* @param articleID 文章id
|
||||
* @return 删除状态 true:删除成功 false:失败
|
||||
*/
|
||||
boolean delete(long articleID);
|
||||
|
||||
/**
|
||||
* 更新一篇文章
|
||||
*
|
||||
* @param reqBody 请求数据
|
||||
* @return 文章数据
|
||||
*/
|
||||
ArticleModel update(ArticleReq reqBody);
|
||||
|
||||
/**
|
||||
* 获取一篇文章的数据
|
||||
*
|
||||
* @param articleId 文章id
|
||||
* @param is4update 是否是因文章更新而请求数据
|
||||
* @return 文章数据
|
||||
*/
|
||||
ArticleModel retrieveOneById(long articleId, boolean is4update);
|
||||
|
||||
/**
|
||||
* 管理员 获取分页数据
|
||||
*
|
||||
* @param count 单页数据量
|
||||
* @param page 数据页
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageData<ArticleModel> adminArticles(int count, int page, Boolean deleted);
|
||||
|
||||
/**
|
||||
* 获取文章状态为开放的文章
|
||||
*
|
||||
* @param count 单页数据量
|
||||
* @param page 数据页
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageData<ArticleModel> retrievePageForOpen(int count, int page);
|
||||
|
||||
/**
|
||||
* 根据分类名获取文章数据
|
||||
*
|
||||
* @param name 分类名
|
||||
* @param count 单页数据量
|
||||
* @param page 数据页
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageData<ArticleModel> findByCategory(String name, int page, int count);
|
||||
|
||||
/**
|
||||
* 根据标签名获取文章数据
|
||||
*
|
||||
* @param name 标签名
|
||||
* @param count 单页数据量
|
||||
* @param page 数据页
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageData<ArticleModel> findByTag(String name, int page, int count);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.common.entity.vo.CategoryModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 22:42
|
||||
*/
|
||||
@Service
|
||||
public interface CategoryService {
|
||||
/**
|
||||
* 增加一个分类
|
||||
*
|
||||
* @param name 分类名
|
||||
* @return 所增加的分类数据
|
||||
*/
|
||||
CategoryModel create(String name);
|
||||
|
||||
/**
|
||||
* 通过id删除分类
|
||||
*
|
||||
* @param id 分类id
|
||||
* @return 删除状态
|
||||
*/
|
||||
boolean delete(long id);
|
||||
|
||||
/**
|
||||
* 编辑分类的名字
|
||||
*
|
||||
* @param id 分类id
|
||||
* @param name 分类名字
|
||||
* @return 更新后的分类的数据
|
||||
*/
|
||||
CategoryModel update(Long id, String name);
|
||||
|
||||
/**
|
||||
* 获取全部的分类数据
|
||||
*
|
||||
* @return 全部的分类数据
|
||||
*/
|
||||
PageData<CategoryModel> retrievePage(int page, int count);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package cn.celess.common.service;
|
||||
|
||||
|
||||
import cn.celess.common.entity.dto.CommentReq;
|
||||
import cn.celess.common.entity.vo.CommentModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/29 16:58
|
||||
*/
|
||||
@Service
|
||||
public interface CommentService {
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param reqBody 请求数据体
|
||||
* @return 增加的comment数据
|
||||
*/
|
||||
CommentModel create(CommentReq reqBody);
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id comment的id
|
||||
* @return 删除状态
|
||||
*/
|
||||
boolean delete(long id);
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*
|
||||
* @param reqBody comment请求体
|
||||
* @return 更新后的数据
|
||||
*/
|
||||
CommentModel update(CommentReq reqBody);
|
||||
|
||||
/**
|
||||
* 分页获取数据
|
||||
*
|
||||
* @param pagePath pagePath
|
||||
* @param count 单页数据量
|
||||
* @param page 数据页
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageData<CommentModel> retrievePage(String pagePath, int page, int count);
|
||||
|
||||
/**
|
||||
* 通过pid获取数据
|
||||
*
|
||||
* @param pid 父id
|
||||
* @return 分页数据
|
||||
*/
|
||||
List<CommentModel> retrievePageByPid(long pid);
|
||||
|
||||
|
||||
/**
|
||||
* 根据评论者获取数据
|
||||
*
|
||||
* @param pagePath pagePath
|
||||
* @param count 单页数据量
|
||||
* @param page 数据页
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageData<CommentModel> retrievePageByAuthor(String pagePath, int page, int count);
|
||||
|
||||
|
||||
/**
|
||||
* 根据数据的type和pid获取数据
|
||||
*
|
||||
* @param pagePath pagePath
|
||||
* @param pid 父id
|
||||
* @param count 单页数据量
|
||||
* @param page 数据页
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageData<CommentModel> retrievePageByPageAndPid(String pagePath, long pid, int page, int count);
|
||||
|
||||
/**
|
||||
* 根据type获取数据
|
||||
*
|
||||
* @param pagePath pagePath
|
||||
* @param count 单页数据量
|
||||
* @param page 数据页
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageData<CommentModel> retrievePageByPage(String pagePath, int page, int count);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package cn.celess.common.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/04/02 22:04
|
||||
*/
|
||||
@Service
|
||||
public interface CountService {
|
||||
/**
|
||||
* 获取评论的数据量
|
||||
*
|
||||
* @return 评论的数据量
|
||||
*/
|
||||
long getCommentCount();
|
||||
|
||||
/**
|
||||
* 获取文章的篇数
|
||||
*
|
||||
* @return 文章的篇数
|
||||
*/
|
||||
long getArticleCount();
|
||||
|
||||
/**
|
||||
* 获取分类数量
|
||||
*
|
||||
* @return 分类数量
|
||||
*/
|
||||
long getCategoriesCount();
|
||||
|
||||
/**
|
||||
* 获取标签数量
|
||||
*
|
||||
* @return 标签数量
|
||||
*/
|
||||
long getTagsCount();
|
||||
|
||||
/**
|
||||
* 获取用户量
|
||||
*
|
||||
* @return 用户量
|
||||
*/
|
||||
long getUserCount();
|
||||
|
||||
/**
|
||||
* 获取总访问量
|
||||
*
|
||||
* @return 总访问量
|
||||
*/
|
||||
long getVisitorCount();
|
||||
|
||||
/**
|
||||
* 获取日访问量
|
||||
*
|
||||
* @return 日访问量
|
||||
*/
|
||||
long getDayVisitCount();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.celess.common.service;
|
||||
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/04/22 14:25
|
||||
*/
|
||||
@Service
|
||||
public interface MailService {
|
||||
/**
|
||||
* 异步发生邮件
|
||||
*
|
||||
* @param message SimpleMailMessage对象
|
||||
* @return //
|
||||
*/
|
||||
Boolean AsyncSend(SimpleMailMessage message);
|
||||
|
||||
/**
|
||||
* 同步发送邮件
|
||||
*
|
||||
* @param message SimpleMailMessage对象
|
||||
* @return 发送状态
|
||||
*/
|
||||
Boolean send(SimpleMailMessage message);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.common.entity.PartnerSite;
|
||||
import cn.celess.common.entity.dto.LinkApplyReq;
|
||||
import cn.celess.common.entity.dto.LinkReq;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/05/12 11:42
|
||||
*/
|
||||
@Service
|
||||
public interface PartnerSiteService {
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param reqBody 数据请求体
|
||||
* @return 新增数据
|
||||
*/
|
||||
PartnerSite create(LinkReq reqBody);
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id 数据id
|
||||
* @return 删除状态
|
||||
*/
|
||||
Boolean del(long id);
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*
|
||||
* @param reqBody 数据请求体
|
||||
* @return 更新后的数据
|
||||
*/
|
||||
PartnerSite update(LinkReq reqBody);
|
||||
|
||||
/**
|
||||
* 分页获取数据
|
||||
*
|
||||
* @param count 单页数据量
|
||||
* @param page 数据页
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageData<PartnerSite> partnerSitePages(int page, int count, Boolean deleted);
|
||||
|
||||
/**
|
||||
* 获取全部数据
|
||||
*
|
||||
* @return 全部友链数据
|
||||
*/
|
||||
List<PartnerSite> findAll();
|
||||
|
||||
/**
|
||||
* 申请友链
|
||||
*
|
||||
* @param linkApplyReq linkApplyReq
|
||||
* @return linkApplyReq
|
||||
*/
|
||||
PartnerSite apply(LinkApplyReq linkApplyReq);
|
||||
|
||||
/**
|
||||
* 重写申请友链
|
||||
*
|
||||
* @param key key
|
||||
* @return msg
|
||||
*/
|
||||
String reapply(String key);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.common.entity.vo.QiniuResponse;
|
||||
import com.qiniu.storage.model.FileInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/04/25 18:15
|
||||
*/
|
||||
@Service
|
||||
public interface QiniuService {
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param is InputStream流
|
||||
* @param fileName 文件名
|
||||
* @return 响应数据
|
||||
*/
|
||||
QiniuResponse uploadFile(InputStream is, String fileName);
|
||||
|
||||
/**
|
||||
* 获取文件列表
|
||||
*
|
||||
* @return 文件列表
|
||||
*/
|
||||
FileInfo[] getFileList();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.entity.vo.TagModel;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 22:23
|
||||
*/
|
||||
@Service
|
||||
public interface TagService {
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param name 标签名
|
||||
* @return 新增后的数据
|
||||
*/
|
||||
TagModel create(String name);
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param tagId 标签id
|
||||
* @return 删除状态
|
||||
*/
|
||||
boolean delete(long tagId);
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*
|
||||
* @param id 标签id
|
||||
* @param name 改名的name值
|
||||
* @return 更新后的数据
|
||||
*/
|
||||
TagModel update(Long id, String name);
|
||||
|
||||
/**
|
||||
* 分页获取标签数据
|
||||
*
|
||||
* @param count 单页数据量
|
||||
* @param page 数据页
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageData<TagModel> retrievePage(int page, int count);
|
||||
|
||||
/**
|
||||
* 获取全部标签数据
|
||||
*
|
||||
* @return 标签数据列表
|
||||
*/
|
||||
List<TagModel> findAll();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.common.entity.dto.LoginReq;
|
||||
import cn.celess.common.entity.dto.UserReq;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.entity.vo.UserModel;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/30 18:40
|
||||
*/
|
||||
@Service
|
||||
public interface UserService {
|
||||
/**
|
||||
* 注册
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @param password 密码
|
||||
* @return 注册状态
|
||||
*/
|
||||
Boolean registration(String email, String password);
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
* @param loginReq 请求数据
|
||||
* @return 用户数据
|
||||
*/
|
||||
UserModel login(LoginReq loginReq);
|
||||
|
||||
/**
|
||||
* 注销登录
|
||||
*
|
||||
* @return **
|
||||
*/
|
||||
Object logout();
|
||||
|
||||
/**
|
||||
* 更新用户数据
|
||||
*
|
||||
* @param desc 用户描述
|
||||
* @param displayName 显示昵称
|
||||
* @return 用户数据
|
||||
*/
|
||||
UserModel update(String desc, String displayName);
|
||||
|
||||
/**
|
||||
* 更新头像
|
||||
*
|
||||
* @param is 头像文件的输入流
|
||||
* @param mime 文件的mime
|
||||
* @return 响应数据
|
||||
*/
|
||||
Object updateUserAavatarImg(InputStream is, String mime);
|
||||
|
||||
/**
|
||||
* 获取session中存储的用户资料
|
||||
*
|
||||
* @return 用户资料
|
||||
*/
|
||||
UserModel getUserInfoBySession();
|
||||
|
||||
/**
|
||||
* 获取用户的角色
|
||||
*
|
||||
* @param email 用户的邮箱
|
||||
* @return role
|
||||
*/
|
||||
String getUserRoleByEmail(String email);
|
||||
|
||||
/**
|
||||
* 获取邮箱是否注册过
|
||||
*
|
||||
* @param email 用户邮箱
|
||||
* @return 注册状态
|
||||
*/
|
||||
boolean isExistOfEmail(String email);
|
||||
|
||||
/**
|
||||
* 发送重置密码邮件
|
||||
*
|
||||
* @param email 用户邮箱
|
||||
* @return 发送状态
|
||||
*/
|
||||
Object sendResetPwdEmail(String email);
|
||||
|
||||
/**
|
||||
* 发送验证邮箱邮件
|
||||
*
|
||||
* @param email 用户邮箱
|
||||
* @return 发送状态
|
||||
*/
|
||||
Object sendVerifyEmail(String email);
|
||||
|
||||
/**
|
||||
* 验证邮箱
|
||||
*
|
||||
* @param verifyId 验证码
|
||||
* @param email 邮箱
|
||||
* @return 验证状态
|
||||
*/
|
||||
Object verifyEmail(String verifyId, String email);
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*
|
||||
* @param verifyId 验证码
|
||||
* @param email 邮箱
|
||||
* @param pwd 新密码
|
||||
* @return 修改状态
|
||||
*/
|
||||
Object reSetPwd(String verifyId, String email, String pwd);
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param id 用户id的数组
|
||||
* @return 对应id 的删除状态
|
||||
*/
|
||||
Object deleteUser(Integer[] id);
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*
|
||||
* @param count 单页数据量
|
||||
* @param page 数据页
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageData<UserModel> getUserList(Integer page, Integer count, Integer status);
|
||||
|
||||
/**
|
||||
* 更改用户信息
|
||||
*
|
||||
* @param user 用户数据
|
||||
* @return 用户信息
|
||||
*/
|
||||
UserModel adminUpdate(UserReq user);
|
||||
|
||||
/**
|
||||
* 获取电子邮件的存在状态
|
||||
*
|
||||
* @param email email
|
||||
* @return true:存在 false:不存在
|
||||
*/
|
||||
boolean getStatusOfEmail(String email);
|
||||
|
||||
/**
|
||||
* 设置密码
|
||||
*
|
||||
* @param pwd pwd
|
||||
* @param newPwd newPwd
|
||||
* @param confirmPwd confirmPwd
|
||||
* @return UserModel
|
||||
*/
|
||||
UserModel setPwd(String pwd, String newPwd, String confirmPwd);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.celess.common.service;
|
||||
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.entity.vo.VisitorModel;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/04/02 23:03
|
||||
*/
|
||||
@Service
|
||||
public interface VisitorService {
|
||||
/**
|
||||
* 分页获取访客数据
|
||||
*
|
||||
* @param count 单页数据量
|
||||
* @param page 数据页
|
||||
* @param showLocation 是否显示位置信息 开启改选项数据响应超慢
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageData<VisitorModel> visitorPage(int page, int count, boolean showLocation);
|
||||
|
||||
/**
|
||||
* 新增访客
|
||||
*
|
||||
* @param request HttpServletRequest
|
||||
* @return 返回状态 null: 访客信息已记录、爬虫
|
||||
*/
|
||||
VisitorModel addVisitor(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 获取位置信息
|
||||
*
|
||||
* @param ip ip地址
|
||||
* @return 位置信息
|
||||
*/
|
||||
String location(String ip);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package cn.celess.common.service;
|
||||
|
||||
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.entity.vo.WebUpdateModel;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/05/12 11:42
|
||||
*/
|
||||
@Service
|
||||
public interface WebUpdateInfoService {
|
||||
/**
|
||||
* 新增记录
|
||||
*
|
||||
* @param info 更新内容
|
||||
* @return 创建状态
|
||||
*/
|
||||
WebUpdateModel create(String info);
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id 数据id
|
||||
* @return 删除状态
|
||||
*/
|
||||
Boolean del(long id);
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*
|
||||
* @param id 数据id
|
||||
* @param info 新内容
|
||||
* @return 数据
|
||||
*/
|
||||
WebUpdateModel update(long id, String info);
|
||||
|
||||
/**
|
||||
* 分页获取更新记录
|
||||
*
|
||||
* @param count 单页数据量
|
||||
* @param page 数据页
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageData<WebUpdateModel> pages(int count, int page);
|
||||
|
||||
/**
|
||||
* 获取全部的更新记录
|
||||
*
|
||||
* @return 更新记录
|
||||
*/
|
||||
List<WebUpdateModel> findAll();
|
||||
|
||||
/**
|
||||
* 获取最后更新时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getLastestUpdateTime();
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.celess.common.util;
|
||||
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 17:22
|
||||
*/
|
||||
public class DateFormatUtil {
|
||||
public static String get(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
public static String getForXmlDate(Date date) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZ");
|
||||
GregorianCalendar gc = new GregorianCalendar();
|
||||
String dateString = sdf.format(date);
|
||||
try {
|
||||
gc.setTime(sdf.parse(dateString));
|
||||
XMLGregorianCalendar date2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
|
||||
return date2.toString();
|
||||
} catch (DatatypeConfigurationException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getNow() {
|
||||
return get(new Date());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package cn.celess.common.util;
|
||||
|
||||
|
||||
import com.gargoylesoftware.htmlunit.BrowserVersion;
|
||||
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
|
||||
import com.gargoylesoftware.htmlunit.Page;
|
||||
import com.gargoylesoftware.htmlunit.WebClient;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-04-23 15:51
|
||||
* @Desc:
|
||||
*/
|
||||
public class HttpUtil {
|
||||
public static String get(String urlStr) {
|
||||
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) {
|
||||
webClient.getOptions().setCssEnabled(false);
|
||||
webClient.getOptions().setJavaScriptEnabled(false);
|
||||
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
|
||||
webClient.getOptions().setThrowExceptionOnScriptError(false);
|
||||
webClient.getOptions().setDownloadImages(false);
|
||||
webClient.getOptions().setActiveXNative(false);
|
||||
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
|
||||
Page clientPage = webClient.getPage(urlStr);
|
||||
if (clientPage.isHtmlPage()) {
|
||||
return clientPage.toString();
|
||||
}
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getAfterRendering(String url) {
|
||||
try (final WebClient webClient = new WebClient(BrowserVersion.BEST_SUPPORTED)) {
|
||||
webClient.getOptions().setCssEnabled(false);
|
||||
webClient.getOptions().setJavaScriptEnabled(true);
|
||||
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
|
||||
webClient.getOptions().setThrowExceptionOnScriptError(false);
|
||||
webClient.getOptions().setDownloadImages(false);
|
||||
webClient.getOptions().setActiveXNative(false);
|
||||
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
|
||||
final HtmlPage page = webClient.getPage(url);
|
||||
return page.asXml();
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
14
blog-common/src/main/java/cn/celess/common/util/MD5Util.java
Normal file
14
blog-common/src/main/java/cn/celess/common/util/MD5Util.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package cn.celess.common.util;
|
||||
|
||||
import org.springframework.util.DigestUtils;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/30 18:56
|
||||
*/
|
||||
public class MD5Util {
|
||||
public static String getMD5(String str) {
|
||||
String md5 = DigestUtils.md5DigestAsHex(str.getBytes());
|
||||
return md5;
|
||||
}
|
||||
}
|
||||
112
blog-common/src/main/java/cn/celess/common/util/ModalTrans.java
Normal file
112
blog-common/src/main/java/cn/celess/common/util/ModalTrans.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package cn.celess.common.util;
|
||||
|
||||
|
||||
import cn.celess.common.enmu.UserAccountStatusEnum;
|
||||
import cn.celess.common.entity.*;
|
||||
import cn.celess.common.entity.vo.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2020-05-24 18:04
|
||||
* @Desc:
|
||||
*/
|
||||
public class ModalTrans {
|
||||
|
||||
public static ArticleModel article(Article article) {
|
||||
if (article == null) {
|
||||
return null;
|
||||
}
|
||||
ArticleModel articleModel = new ArticleModel();
|
||||
BeanUtils.copyProperties(article, articleModel);
|
||||
articleModel.setPublishDateFormat(DateFormatUtil.get(article.getPublishDate()));
|
||||
articleModel.setUpdateDateFormat(DateFormatUtil.get(article.getUpdateDate()));
|
||||
articleModel.setOriginal(article.getType());
|
||||
articleModel.setCategory(article.getCategory().getName());
|
||||
articleModel.setAuthor(user(article.getUser()));
|
||||
articleModel.getTags().forEach(tag -> {
|
||||
tag.setCategory(null);
|
||||
tag.setDeleted(null);
|
||||
});
|
||||
return articleModel;
|
||||
}
|
||||
|
||||
|
||||
public static ArticleModel article(Article article, boolean noMdContent) {
|
||||
ArticleModel article1 = article(article);
|
||||
if (!noMdContent || article1 == null) {
|
||||
return article1;
|
||||
}
|
||||
article1.setMdContent(null);
|
||||
article1.setOpen(null);
|
||||
return article1;
|
||||
}
|
||||
|
||||
public static UserModel userFullInfo(User user) {
|
||||
if (user == null || user.getId() == -1) {
|
||||
return null;
|
||||
}
|
||||
UserModel userModel = new UserModel();
|
||||
BeanUtils.copyProperties(user, userModel);
|
||||
userModel.setStatus(UserAccountStatusEnum.get(user.getStatus()));
|
||||
userModel.setAvatarImgUrl(user.getAvatarImgUrl() == null || user.getAvatarImgUrl().length() == 0 ?
|
||||
null :
|
||||
"http://cdn.celess.cn/" + user.getAvatarImgUrl());
|
||||
userModel.setDisplayName(user.getDisplayName() == null ? user.getEmail() : user.getDisplayName());
|
||||
userModel.setRecentlyLandedDate(DateFormatUtil.get(user.getRecentlyLandedDate()));
|
||||
return userModel;
|
||||
}
|
||||
|
||||
public static UserModel user(User user) {
|
||||
UserModel model = userFullInfo(user);
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
model.setRole(null);
|
||||
model.setEmailStatus(null);
|
||||
return model;
|
||||
}
|
||||
|
||||
public static CategoryModel category(Category category) {
|
||||
if (category == null) {
|
||||
return null;
|
||||
}
|
||||
CategoryModel model = new CategoryModel();
|
||||
BeanUtils.copyProperties(category, model);
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
public static TagModel tag(Tag tag) {
|
||||
if (tag == null) {
|
||||
return null;
|
||||
}
|
||||
TagModel model = new TagModel();
|
||||
BeanUtils.copyProperties(tag, model);
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
public static WebUpdateModel webUpdate(WebUpdate update) {
|
||||
if (update == null) {
|
||||
return null;
|
||||
}
|
||||
WebUpdateModel model = new WebUpdateModel();
|
||||
model.setId(update.getId());
|
||||
model.setInfo(update.getUpdateInfo());
|
||||
model.setTime(DateFormatUtil.get(update.getUpdateTime()));
|
||||
return model;
|
||||
}
|
||||
|
||||
public static CommentModel comment(Comment comment) {
|
||||
if (comment == null) {
|
||||
return null;
|
||||
}
|
||||
CommentModel model = new CommentModel();
|
||||
BeanUtils.copyProperties(comment, model);
|
||||
model.setFromUser(user(comment.getFromUser()));
|
||||
model.setToUser(user(comment.getToUser()));
|
||||
model.setDate(DateFormatUtil.get(comment.getDate()));
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package cn.celess.common.util;
|
||||
|
||||
|
||||
import com.dyuproject.protostuff.LinkedBuffer;
|
||||
import com.dyuproject.protostuff.ProtostuffIOUtil;
|
||||
import com.dyuproject.protostuff.Schema;
|
||||
import com.dyuproject.protostuff.runtime.RuntimeSchema;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ProtoStuffSerializerUtil
|
||||
*
|
||||
* @author Sirius
|
||||
* @date 2019-1-8
|
||||
*/
|
||||
public class ProtoStuffSerializerUtil {
|
||||
/**
|
||||
* 序列化对象
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
public static <T> byte[] serialize(T obj) {
|
||||
if (obj == null) {
|
||||
throw new RuntimeException("序列化对象(" + obj + ")!");
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Schema<T> schema = (Schema<T>) RuntimeSchema.getSchema(obj.getClass());
|
||||
LinkedBuffer buffer = LinkedBuffer.allocate(1024 * 1024);
|
||||
byte[] protostuff = null;
|
||||
try {
|
||||
protostuff = ProtostuffIOUtil.toByteArray(obj, schema, buffer);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("序列化(" + obj.getClass() + ")对象(" + obj + ")发生异常!", e);
|
||||
} finally {
|
||||
buffer.clear();
|
||||
}
|
||||
return protostuff;
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化对象
|
||||
*
|
||||
* @param paramArrayOfByte
|
||||
* @param targetClass
|
||||
* @return
|
||||
*/
|
||||
public static <T> T deserialize(byte[] paramArrayOfByte, Class<T> targetClass) {
|
||||
if (paramArrayOfByte == null || paramArrayOfByte.length == 0) {
|
||||
throw new RuntimeException("反序列化对象发生异常,byte序列为空!");
|
||||
}
|
||||
T instance = null;
|
||||
try {
|
||||
instance = targetClass.newInstance();
|
||||
} catch (InstantiationException e1) {
|
||||
throw new RuntimeException("反序列化过程中依据类型创建对象失败!", e1);
|
||||
} catch (IllegalAccessException e2) {
|
||||
throw new RuntimeException("反序列化过程中依据类型创建对象失败!", e2);
|
||||
}
|
||||
Schema<T> schema = RuntimeSchema.getSchema(targetClass);
|
||||
ProtostuffIOUtil.mergeFrom(paramArrayOfByte, instance, schema);
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 序列化列表
|
||||
*
|
||||
* @param objList
|
||||
* @return
|
||||
*/
|
||||
public static <T> byte[] serializeList(List<T> objList) {
|
||||
if (objList == null || objList.isEmpty()) {
|
||||
throw new RuntimeException("序列化对象列表(" + objList + ")参数异常!");
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Schema<T> schema = (Schema<T>) RuntimeSchema.getSchema(objList.get(0).getClass());
|
||||
LinkedBuffer buffer = LinkedBuffer.allocate(1024 * 1024);
|
||||
byte[] protostuff = null;
|
||||
ByteArrayOutputStream bos = null;
|
||||
try {
|
||||
bos = new ByteArrayOutputStream();
|
||||
ProtostuffIOUtil.writeListTo(bos, objList, schema, buffer);
|
||||
protostuff = bos.toByteArray();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("序列化对象列表(" + objList + ")发生异常!", e);
|
||||
} finally {
|
||||
buffer.clear();
|
||||
try {
|
||||
if (bos != null) {
|
||||
bos.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return protostuff;
|
||||
}
|
||||
|
||||
/**
|
||||
* 反序列化列表
|
||||
*
|
||||
* @param paramArrayOfByte
|
||||
* @param targetClass
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<T> deserializeList(byte[] paramArrayOfByte, Class<T> targetClass) {
|
||||
if (paramArrayOfByte == null || paramArrayOfByte.length == 0) {
|
||||
throw new RuntimeException("反序列化对象发生异常,byte序列为空!");
|
||||
}
|
||||
|
||||
Schema<T> schema = RuntimeSchema.getSchema(targetClass);
|
||||
List<T> result = null;
|
||||
try {
|
||||
result = ProtostuffIOUtil.parseListFrom(new ByteArrayInputStream(paramArrayOfByte), schema);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("反序列化对象列表发生异常!", e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
1378
blog-common/src/main/java/cn/celess/common/util/RedisUtil.java
Normal file
1378
blog-common/src/main/java/cn/celess/common/util/RedisUtil.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,80 @@
|
||||
package cn.celess.common.util;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/05/12 11:04
|
||||
*/
|
||||
public class RegexUtil {
|
||||
/**
|
||||
* 网址匹配
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
public static boolean urlMatch(String url) {
|
||||
if (url == null || url.replaceAll(" ", "").isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
//正则 (http(s)://www.celess/xxxx,www.celess.cn/xxx)
|
||||
String pattern = "^(http://|https://|)([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$";
|
||||
return match(url, pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮箱验证
|
||||
*
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
public static boolean emailMatch(String email) {
|
||||
if (email == null || email.replaceAll(" ", "").isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
//正则
|
||||
String pattern = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
|
||||
return match(email, pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号匹配
|
||||
*
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
public static boolean phoneMatch(String phone) {
|
||||
if (phone == null || phone.replaceAll(" ", "").isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
//正则
|
||||
String pattern = "^([1][3,4,5,6,7,8,9])\\d{9}$";
|
||||
return match(phone, pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* 密码正则
|
||||
* 最短6位,最长16位 {6,16}
|
||||
* 可以包含小写大母 [a-z] 和大写字母 [A-Z]
|
||||
* 可以包含数字 [0-9]
|
||||
* 可以包含下划线 [ _ ] 和减号 [ - ]
|
||||
*
|
||||
* @param pwd
|
||||
* @return
|
||||
*/
|
||||
public static boolean pwdMatch(String pwd) {
|
||||
if (pwd == null || pwd.replaceAll(" ", "").isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
//正则
|
||||
String pattern = "^[\\w_-]{6,16}$";
|
||||
return match(pwd, pattern);
|
||||
}
|
||||
|
||||
private static boolean match(String str, String pattern) {
|
||||
Pattern r = Pattern.compile(pattern);
|
||||
Matcher m = r.matcher(str);
|
||||
return m.matches();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.celess.common.util;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/10/18 15:44
|
||||
* @Description:
|
||||
*/
|
||||
public class RequestUtil {
|
||||
public static String getCompleteUrlAndMethod(HttpServletRequest request) {
|
||||
// like this : /articles?page=1&count=5:GET
|
||||
return request.getRequestURI() +
|
||||
(request.getQueryString() == null ? "" : "?" + request.getQueryString()) +
|
||||
":" + request.getMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.celess.common.util;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/03/28 17:21
|
||||
*/
|
||||
public class StringFromHtmlUtil {
|
||||
public static String getString(String html) {
|
||||
//从html中提取纯文本
|
||||
//剔出<html>的标签
|
||||
String txtcontent = html.replaceAll("</?[^>]+>", "");
|
||||
//去除字符串中的空格,回车,换行符,制表符
|
||||
txtcontent = txtcontent.replaceAll("<a>\\s*|\t|\r|\n</a>", "");
|
||||
return txtcontent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package cn.celess.common.util;
|
||||
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2019/04/11 15:42
|
||||
*/
|
||||
|
||||
public class VeriCodeUtil {
|
||||
// 验证码字符集
|
||||
private static final char[] chars = {
|
||||
'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',
|
||||
'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'};
|
||||
|
||||
// 字符数量
|
||||
private static final int SIZE = 4;
|
||||
// 干扰线数量
|
||||
private static final int LINES = 5;
|
||||
// 宽度
|
||||
private static final int WIDTH = 80;
|
||||
// 高度
|
||||
private static final int HEIGHT = 40;
|
||||
// 字体大小
|
||||
private static final int FONT_SIZE = 30;
|
||||
|
||||
/**
|
||||
* 生成随机验证码及图片
|
||||
* Object[0]:验证码字符串;
|
||||
* Object[1]:验证码图片。
|
||||
*/
|
||||
public static Object[] createImage() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
// 1.创建空白图片
|
||||
BufferedImage image = new BufferedImage(
|
||||
WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
|
||||
// 2.获取图片画笔
|
||||
Graphics graphic = image.getGraphics();
|
||||
// 3.设置画笔颜色
|
||||
graphic.setColor(Color.LIGHT_GRAY);
|
||||
// 4.绘制矩形背景
|
||||
graphic.fillRect(0, 0, WIDTH, HEIGHT);
|
||||
// 5.画随机字符
|
||||
Random ran = new Random();
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
// 取随机字符索引
|
||||
int n = ran.nextInt(chars.length);
|
||||
// 设置随机颜色
|
||||
graphic.setColor(getRandomColor());
|
||||
// 设置字体大小
|
||||
graphic.setFont(new Font(
|
||||
null, Font.BOLD + Font.ITALIC, FONT_SIZE));
|
||||
// 画字符
|
||||
graphic.drawString(
|
||||
chars[n] + "", i * WIDTH / SIZE, HEIGHT * 2 / 3);
|
||||
// 记录字符
|
||||
sb.append(chars[n]);
|
||||
}
|
||||
// 6.画干扰线
|
||||
for (int i = 0; i < LINES; i++) {
|
||||
// 设置随机颜色
|
||||
graphic.setColor(getRandomColor());
|
||||
// 随机画线
|
||||
graphic.drawLine(ran.nextInt(WIDTH), ran.nextInt(HEIGHT),
|
||||
ran.nextInt(WIDTH), ran.nextInt(HEIGHT));
|
||||
}
|
||||
// 7.返回验证码和图片
|
||||
return new Object[]{sb.toString(), image};
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机取色
|
||||
*/
|
||||
public static Color getRandomColor() {
|
||||
Random ran = new Random();
|
||||
Color color = new Color(ran.nextInt(256),
|
||||
ran.nextInt(256), ran.nextInt(256));
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user