添加 javadoc
This commit is contained in:
parent
6b363cf37b
commit
fcfb8b3cf9
28
README.md
28
README.md
@ -1 +1,27 @@
|
|||||||
"# vertical"
|
# vertical
|
||||||
|
vertical [vərtikəl],取纵横之`纵`,寓为奔放自如、笔意纵横
|
||||||
|
## 开发计划
|
||||||
|
### 已完成
|
||||||
|
- [x] 首页
|
||||||
|
- [x] 会员登录/注册
|
||||||
|
- [x] 文章发布/编辑/详情/删除
|
||||||
|
- [x] 个人主页
|
||||||
|
- [x] 找回密码
|
||||||
|
- [x] 用户管理
|
||||||
|
- [x] 角色/权限管理 (2019/12/05 21:52 更新)
|
||||||
|
- [x] 专题管理 (2019/12/05 21:52 更新)
|
||||||
|
### 待完成
|
||||||
|
- [ ] 个人信息修改
|
||||||
|
- [ ] 标签管理
|
||||||
|
- [ ] 专题-标签管理
|
||||||
|
- [ ] 用户-标签管理
|
||||||
|
- [ ] 消息系统
|
||||||
|
- [ ] 评论系统
|
||||||
|
- [ ] SEO 优化
|
||||||
|
- [ ] 分享功能
|
||||||
|
- [ ] 数据统计
|
||||||
|
### 构想
|
||||||
|
- [ ] 专业知识题库
|
||||||
|
- [ ] 社区贡献系统
|
||||||
|
- [ ] 会员系统
|
||||||
|
- [ ] 勋章系统
|
||||||
|
@ -9,6 +9,9 @@ import javax.persistence.Table;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Table(name = "vertical_article")
|
@Table(name = "vertical_article")
|
||||||
public class Article implements Serializable,Cloneable {
|
public class Article implements Serializable,Cloneable {
|
||||||
|
@ -8,6 +8,9 @@ import javax.persistence.Id;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Table(name = "vertical_article_content")
|
@Table(name = "vertical_article_content")
|
||||||
public class ArticleContent {
|
public class ArticleContent {
|
||||||
|
@ -8,12 +8,15 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础DO类,提供toString快方法
|
* 基础DO类,提供toString快方法
|
||||||
* Created by liwei on 2015/6/16.
|
*
|
||||||
|
* @author liwei
|
||||||
|
* @date 2015/6/16
|
||||||
*/
|
*/
|
||||||
public class BaseDO implements Serializable {
|
public class BaseDO implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -1394589131426860408L;
|
private static final long serialVersionUID = -1394589131426860408L;
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,9 @@ import javax.persistence.Table;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Table(name = "vertical_tag")
|
@Table(name = "vertical_tag")
|
||||||
public class Tag implements Serializable,Cloneable {
|
public class Tag implements Serializable,Cloneable {
|
||||||
|
@ -12,6 +12,9 @@ import javax.persistence.Table;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@Table(name = "vertical_user")
|
@Table(name = "vertical_user")
|
||||||
@Data
|
@Data
|
||||||
public class User implements Serializable,Cloneable {
|
public class User implements Serializable,Cloneable {
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.rymcu.vertical.jwt.def;
|
package com.rymcu.vertical.jwt.def;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
public class JwtConstants {
|
public class JwtConstants {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,10 +7,8 @@ package com.rymcu.vertical.jwt.model;
|
|||||||
*/
|
*/
|
||||||
public class TokenModel {
|
public class TokenModel {
|
||||||
|
|
||||||
//用户id
|
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
//随机生成的uuid
|
|
||||||
private String token;
|
private String token;
|
||||||
|
|
||||||
public TokenModel(String username, String token) {
|
public TokenModel(String username, String token) {
|
||||||
|
@ -10,16 +10,55 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
public interface ArticleService extends Service<Article> {
|
public interface ArticleService extends Service<Article> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据检索内容/标签查询文章列表
|
||||||
|
* @param searchText
|
||||||
|
* @param tag
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
List<ArticleDTO> findArticles(String searchText, String tag);
|
List<ArticleDTO> findArticles(String searchText, String tag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询文章详情信息
|
||||||
|
* @param id
|
||||||
|
* @param i
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
ArticleDTO findArticleDTOById(Integer id, int i);
|
ArticleDTO findArticleDTOById(Integer id, int i);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询主题下文章列表
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
List<ArticleDTO> findArticlesByTopicName(String name);
|
List<ArticleDTO> findArticlesByTopicName(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询标签下文章列表
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
List<ArticleDTO> findArticlesByTagName(String name);
|
List<ArticleDTO> findArticlesByTagName(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户文章列表
|
||||||
|
* @param idUser
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
List<ArticleDTO> findUserArticlesByIdUser(Integer idUser);
|
List<ArticleDTO> findUserArticlesByIdUser(Integer idUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增/更新文章
|
||||||
|
* @param article
|
||||||
|
* @param request
|
||||||
|
* @throws UnsupportedEncodingException
|
||||||
|
* @throws BaseApiException
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
Map postArticle(ArticleDTO article, HttpServletRequest request) throws UnsupportedEncodingException, BaseApiException;
|
Map postArticle(ArticleDTO article, HttpServletRequest request) throws UnsupportedEncodingException, BaseApiException;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,9 @@ import java.util.List;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by CodeGenerator on 2018/05/29.
|
*
|
||||||
|
* @author CodeGenerator
|
||||||
|
* @date 2018/05/29
|
||||||
*/
|
*/
|
||||||
public interface PermissionService extends Service<Permission> {
|
public interface PermissionService extends Service<Permission> {
|
||||||
|
|
||||||
|
@ -9,15 +9,38 @@ import java.util.Map;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by CodeGenerator on 2018/05/29.
|
*
|
||||||
|
* @author CodeGenerator
|
||||||
|
* @date 2018/05/29
|
||||||
*/
|
*/
|
||||||
public interface RoleService extends Service<Role> {
|
public interface RoleService extends Service<Role> {
|
||||||
|
|
||||||
List<Role> selectRoleByUser(User sysUser);
|
/**
|
||||||
|
* 查询用户角色
|
||||||
|
* @param user
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
|
List<Role> selectRoleByUser(User user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户角色
|
||||||
|
* @param idUser
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
List<Role> findByIdUser(Integer idUser);
|
List<Role> findByIdUser(Integer idUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户状态
|
||||||
|
* @param idRole
|
||||||
|
* @param status
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
Map updateStatus(Integer idRole, String status);
|
Map updateStatus(Integer idRole, String status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加/更新角色
|
||||||
|
* @param role
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
Map saveRole(Role role);
|
Map saveRole(Role role);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,17 @@ import com.rymcu.vertical.web.api.exception.BaseApiException;
|
|||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
public interface TagService extends Service<Tag> {
|
public interface TagService extends Service<Tag> {
|
||||||
|
|
||||||
void saveTagArticle(Article article) throws UnsupportedEncodingException, BaseApiException;
|
/**
|
||||||
|
* 保存文章标签
|
||||||
|
* @param article
|
||||||
|
* @throws UnsupportedEncodingException
|
||||||
|
* @throws BaseApiException
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
|
Integer saveTagArticle(Article article) throws UnsupportedEncodingException, BaseApiException;
|
||||||
}
|
}
|
||||||
|
@ -26,5 +26,10 @@ public interface TopicService extends Service<Topic> {
|
|||||||
* */
|
* */
|
||||||
Map findTopicByTopicUri(String topicUri, Integer page, Integer rows);
|
Map findTopicByTopicUri(String topicUri, Integer page, Integer rows);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增/更新主题信息
|
||||||
|
* @param topic 主题信息
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
Map saveTopic(Topic topic);
|
Map saveTopic(Topic topic);
|
||||||
}
|
}
|
||||||
|
@ -9,21 +9,65 @@ import java.util.Map;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by CodeGenerator on 2018/05/29.
|
*
|
||||||
|
* @author CodeGenerator
|
||||||
|
* @date 2018/05/29
|
||||||
*/
|
*/
|
||||||
public interface UserService extends Service<User> {
|
public interface UserService extends Service<User> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过账号查询用户信息
|
||||||
|
* @param account
|
||||||
|
* @throws TooManyResultsException
|
||||||
|
* @return User
|
||||||
|
* */
|
||||||
User findByAccount(String account) throws TooManyResultsException;
|
User findByAccount(String account) throws TooManyResultsException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册接口
|
||||||
|
* @param email 邮箱
|
||||||
|
* @param password 密码
|
||||||
|
* @param code 验证码
|
||||||
|
* @return Map
|
||||||
|
* */
|
||||||
Map register(String email, String password, String code);
|
Map register(String email, String password, String code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录接口
|
||||||
|
* @param account 邮箱
|
||||||
|
* @param password 密码
|
||||||
|
* @return Map
|
||||||
|
* */
|
||||||
Map login(String account, String password);
|
Map login(String account, String password);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过 nickname 获取用户信息接口
|
||||||
|
* @param nickname 昵称
|
||||||
|
* @return UserDTO
|
||||||
|
* */
|
||||||
UserDTO findUserDTOByNickname(String nickname);
|
UserDTO findUserDTOByNickname(String nickname);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 找回密码接口
|
||||||
|
* @param code 验证码
|
||||||
|
* @param password 密码
|
||||||
|
* @return Map
|
||||||
|
* */
|
||||||
Map forgetPassword(String code, String password);
|
Map forgetPassword(String code, String password);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户角色接口
|
||||||
|
* @param idUser 用户 id
|
||||||
|
* @param idRole 角色 id
|
||||||
|
* @return Map
|
||||||
|
* */
|
||||||
Map updateUserRole(Integer idUser, Integer idRole);
|
Map updateUserRole(Integer idUser, Integer idRole);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户状态
|
||||||
|
* @param idUser 用户 id
|
||||||
|
* @param status 状态
|
||||||
|
* @return Map
|
||||||
|
* */
|
||||||
Map updateStatus(Integer idUser, String status);
|
Map updateStatus(Integer idUser, String status);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,9 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ArticleServiceImpl extends AbstractService<Article> implements ArticleService {
|
public class ArticleServiceImpl extends AbstractService<Article> implements ArticleService {
|
||||||
|
|
||||||
@ -78,7 +81,7 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = { UnsupportedEncodingException.class,BaseApiException.class })
|
||||||
public Map postArticle(ArticleDTO article, HttpServletRequest request) throws UnsupportedEncodingException, BaseApiException {
|
public Map postArticle(ArticleDTO article, HttpServletRequest request) throws UnsupportedEncodingException, BaseApiException {
|
||||||
Map map = new HashMap(1);
|
Map map = new HashMap(1);
|
||||||
if(StringUtils.isBlank(article.getArticleTitle())){
|
if(StringUtils.isBlank(article.getArticleTitle())){
|
||||||
|
@ -17,6 +17,9 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
||||||
|
|
||||||
@ -24,8 +27,8 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
|||||||
private TagMapper tagMapper;
|
private TagMapper tagMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor = { UnsupportedEncodingException.class,BaseApiException.class })
|
||||||
public void saveTagArticle(Article article) throws UnsupportedEncodingException, BaseApiException {
|
public Integer saveTagArticle(Article article) throws UnsupportedEncodingException, BaseApiException {
|
||||||
User user = UserUtils.getWxCurrentUser();
|
User user = UserUtils.getWxCurrentUser();
|
||||||
String articleTags = article.getArticleTags();
|
String articleTags = article.getArticleTags();
|
||||||
if(StringUtils.isNotBlank(articleTags)){
|
if(StringUtils.isNotBlank(articleTags)){
|
||||||
@ -62,6 +65,8 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
|||||||
tagMapper.insertUserTag(tag.getIdTag(),user.getIdUser(),1);
|
tagMapper.insertUserTag(tag.getIdTag(),user.getIdUser(),1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import java.security.SecureRandom;
|
|||||||
*
|
*
|
||||||
* 返回ByteSource,可进一步被编码为Hex, Base64或UrlSafeBase64
|
* 返回ByteSource,可进一步被编码为Hex, Base64或UrlSafeBase64
|
||||||
*
|
*
|
||||||
|
* @author ronger
|
||||||
*/
|
*/
|
||||||
public class Digests {
|
public class Digests {
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import java.net.URLEncoder;
|
|||||||
* 2.自制的base62 编码
|
* 2.自制的base62 编码
|
||||||
* 3.Commons-Lang的xml/html escape
|
* 3.Commons-Lang的xml/html escape
|
||||||
* 4.JDK提供的URLEncoder
|
* 4.JDK提供的URLEncoder
|
||||||
|
* @author ronger
|
||||||
*/
|
*/
|
||||||
public class Encodes {
|
public class Encodes {
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.rymcu.vertical.util;
|
package com.rymcu.vertical.util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by kaenry on 2016/9/20.
|
*
|
||||||
|
* @author kaenry
|
||||||
|
* @date 2016/9/20
|
||||||
* ErrorCode
|
* ErrorCode
|
||||||
*/
|
*/
|
||||||
public enum ErrorCode {
|
public enum ErrorCode {
|
||||||
|
@ -9,6 +9,7 @@ import java.io.StringWriter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 关于异常的工具类.
|
* 关于异常的工具类.
|
||||||
|
* @author ronger
|
||||||
*/
|
*/
|
||||||
public class Exceptions {
|
public class Exceptions {
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.rymcu.vertical.util;
|
package com.rymcu.vertical.util;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@ -12,6 +14,8 @@ import java.net.URLEncoder;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FileUtils {
|
public class FileUtils {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FileUtils.class);
|
||||||
/**
|
/**
|
||||||
* 获取文件扩展名
|
* 获取文件扩展名
|
||||||
*
|
*
|
||||||
@ -159,7 +163,7 @@ public class FileUtils {
|
|||||||
File fileDelete = new File(strFileName);
|
File fileDelete = new File(strFileName);
|
||||||
|
|
||||||
if (!fileDelete.exists() || !fileDelete.isFile()) {
|
if (!fileDelete.exists() || !fileDelete.isFile()) {
|
||||||
//LogUtil.info("错误: " + strFileName + "不存在!");
|
logger.info("错误: " + strFileName + "不存在!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@ import javax.swing.text.html.HTMLEditorKit;
|
|||||||
import javax.swing.text.html.parser.ParserDelegator;
|
import javax.swing.text.html.parser.ParserDelegator;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
public class Html2TextUtil extends HTMLEditorKit.ParserCallback {
|
public class Html2TextUtil extends HTMLEditorKit.ParserCallback {
|
||||||
|
|
||||||
private static Html2TextUtil html2Text = new Html2TextUtil();
|
private static Html2TextUtil html2Text = new Html2TextUtil();
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
package com.rymcu.vertical.util;
|
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
|
||||||
import javax.net.ssl.TrustManager;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.Socket;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.security.KeyManagementException;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
|
|
||||||
public class MailSSLSocketFactory extends SSLSocketFactory {
|
|
||||||
|
|
||||||
private SSLSocketFactory factory;
|
|
||||||
|
|
||||||
public MailSSLSocketFactory() throws NoSuchAlgorithmException, KeyManagementException {
|
|
||||||
SSLContext sslcontext = SSLContext.getInstance("TLS");
|
|
||||||
sslcontext.init(null, new TrustManager[] { new MailTrustManager() }, null);
|
|
||||||
factory = sslcontext.getSocketFactory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getDefaultCipherSuites() {
|
|
||||||
return factory.getDefaultCipherSuites();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getSupportedCipherSuites() {
|
|
||||||
return factory.getSupportedCipherSuites();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Socket createSocket(Socket socket, String s, int i, boolean b) throws IOException {
|
|
||||||
return factory.createSocket(socket, s, i, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Socket createSocket(String s, int i) throws IOException, UnknownHostException {
|
|
||||||
return factory.createSocket(s, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Socket createSocket(String s, int i, InetAddress inetAddress, int i1) throws IOException, UnknownHostException {
|
|
||||||
return factory.createSocket(s, i, inetAddress, i1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Socket createSocket(InetAddress inetAddress, int i) throws IOException {
|
|
||||||
return factory.createSocket(inetAddress, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Socket createSocket(InetAddress inetAddress, int i, InetAddress inetAddress1, int i1) throws IOException {
|
|
||||||
return factory.createSocket(inetAddress, i, inetAddress1, i1);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package com.rymcu.vertical.util;
|
|
||||||
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
|
|
||||||
public class MailTrustManager implements X509TrustManager {
|
|
||||||
@Override
|
|
||||||
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
|
||||||
return new X509Certificate[0];
|
|
||||||
}
|
|
||||||
}
|
|
@ -20,6 +20,7 @@ import java.util.Date;
|
|||||||
/**
|
/**
|
||||||
* 以静态变量保存Spring ApplicationContext, 可在任何代码任何地方任何时候取出ApplicaitonContext.
|
* 以静态变量保存Spring ApplicationContext, 可在任何代码任何地方任何时候取出ApplicaitonContext.
|
||||||
*
|
*
|
||||||
|
* @author ronger
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Lazy(false)
|
@Lazy(false)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.rymcu.vertical.util;
|
package com.rymcu.vertical.util;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.rymcu.vertical.dto.ArticleDTO;
|
||||||
import com.rymcu.vertical.entity.User;
|
import com.rymcu.vertical.entity.User;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.apache.shiro.session.InvalidSessionException;
|
import org.apache.shiro.session.InvalidSessionException;
|
||||||
@ -9,7 +11,12 @@ import org.springframework.core.env.Environment;
|
|||||||
|
|
||||||
import java.time.*;
|
import java.time.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
public class Utils {
|
public class Utils {
|
||||||
public static final String HASH_ALGORITHM = "SHA-1";
|
public static final String HASH_ALGORITHM = "SHA-1";
|
||||||
public static final int HASH_INTERATIONS = 1024;
|
public static final int HASH_INTERATIONS = 1024;
|
||||||
@ -53,7 +60,7 @@ public class Utils {
|
|||||||
if (session != null){
|
if (session != null){
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
// subject.logout();
|
subject.logout();
|
||||||
}catch (InvalidSessionException e){
|
}catch (InvalidSessionException e){
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -110,6 +117,14 @@ public class Utils {
|
|||||||
return timeAgo;
|
return timeAgo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map getPagination(PageInfo pageInfo) {
|
||||||
|
Map pagination = new HashMap(3);
|
||||||
|
pagination.put("pageSize",pageInfo.getPageSize());
|
||||||
|
pagination.put("total",pageInfo.getTotal());
|
||||||
|
pagination.put("currentPage",pageInfo.getPageNum());
|
||||||
|
return pagination;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
LocalDate localDate = LocalDate.parse("2019-11-15");
|
LocalDate localDate = LocalDate.parse("2019-11-15");
|
||||||
ZoneId zone = ZoneId.systemDefault();
|
ZoneId zone = ZoneId.systemDefault();
|
||||||
@ -117,4 +132,15 @@ public class Utils {
|
|||||||
String s = getTimeAgo(Date.from(instant));
|
String s = getTimeAgo(Date.from(instant));
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map getArticlesGlobalResult(PageInfo<ArticleDTO> pageInfo) {
|
||||||
|
Map map = new HashMap(2);
|
||||||
|
map.put("articles", pageInfo.getList());
|
||||||
|
Map pagination = new HashMap(3);
|
||||||
|
pagination.put("pageSize",pageInfo.getPageSize());
|
||||||
|
pagination.put("total",pageInfo.getTotal());
|
||||||
|
pagination.put("currentPage",pageInfo.getPageNum());
|
||||||
|
map.put("pagination", pagination);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.rymcu.vertical.entity.User;
|
|||||||
import com.rymcu.vertical.service.RoleService;
|
import com.rymcu.vertical.service.RoleService;
|
||||||
import com.rymcu.vertical.service.TopicService;
|
import com.rymcu.vertical.service.TopicService;
|
||||||
import com.rymcu.vertical.service.UserService;
|
import com.rymcu.vertical.service.UserService;
|
||||||
|
import com.rymcu.vertical.util.Utils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -34,13 +35,13 @@ public class AdminController {
|
|||||||
private TopicService topicService;
|
private TopicService topicService;
|
||||||
|
|
||||||
@GetMapping("/users")
|
@GetMapping("/users")
|
||||||
public GlobalResult users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
public GlobalResult<Map<String, Object>> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<User> list = userService.findAll();
|
List<User> list = userService.findAll();
|
||||||
PageInfo pageInfo = new PageInfo(list);
|
PageInfo<User> pageInfo = new PageInfo<>(list);
|
||||||
Map map = new HashMap(2);
|
Map<String, Object> map = new HashMap<String, Object>(2);
|
||||||
map.put("users", pageInfo.getList());
|
map.put("users", pageInfo.getList());
|
||||||
Map pagination = new HashMap(3);
|
Map<String, Number> pagination = new HashMap<>(3);
|
||||||
pagination.put("pageSize",pageInfo.getPageSize());
|
pagination.put("pageSize",pageInfo.getPageSize());
|
||||||
pagination.put("total",pageInfo.getTotal());
|
pagination.put("total",pageInfo.getTotal());
|
||||||
pagination.put("currentPage",pageInfo.getPageNum());
|
pagination.put("currentPage",pageInfo.getPageNum());
|
||||||
@ -49,67 +50,61 @@ public class AdminController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/user/{idUser}/role")
|
@GetMapping("/user/{idUser}/role")
|
||||||
public GlobalResult userRole(@PathVariable Integer idUser){
|
public GlobalResult<List<Role>> userRole(@PathVariable Integer idUser){
|
||||||
List<Role> roles = roleService.findByIdUser(idUser);
|
List<Role> roles = roleService.findByIdUser(idUser);
|
||||||
return GlobalResultGenerator.genSuccessResult(roles);
|
return GlobalResultGenerator.genSuccessResult(roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/roles")
|
@GetMapping("/roles")
|
||||||
public GlobalResult roles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
public GlobalResult<Map<String, Object>> roles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<Role> list = roleService.findAll();
|
List<Role> list = roleService.findAll();
|
||||||
PageInfo pageInfo = new PageInfo(list);
|
PageInfo<Role> pageInfo = new PageInfo<>(list);
|
||||||
Map map = new HashMap(2);
|
Map<String, Object> map = new HashMap<String, Object>(2);
|
||||||
map.put("roles", pageInfo.getList());
|
map.put("roles", pageInfo.getList());
|
||||||
Map pagination = new HashMap(3);
|
Map pagination = Utils.getPagination(pageInfo);
|
||||||
pagination.put("pageSize",pageInfo.getPageSize());
|
|
||||||
pagination.put("total",pageInfo.getTotal());
|
|
||||||
pagination.put("currentPage",pageInfo.getPageNum());
|
|
||||||
map.put("pagination", pagination);
|
map.put("pagination", pagination);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/user/update-role")
|
@PatchMapping("/user/update-role")
|
||||||
public GlobalResult updateUserRole(@RequestBody UserRoleDTO userRole){
|
public GlobalResult<Map> updateUserRole(@RequestBody UserRoleDTO userRole){
|
||||||
Map map = userService.updateUserRole(userRole.getIdUser(),userRole.getIdRole());
|
Map map = userService.updateUserRole(userRole.getIdUser(),userRole.getIdRole());
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/user/update-status")
|
@PatchMapping("/user/update-status")
|
||||||
public GlobalResult updateUserStatus(@RequestBody User user){
|
public GlobalResult<Map> updateUserStatus(@RequestBody User user){
|
||||||
Map map = userService.updateStatus(user.getIdUser(),user.getStatus());
|
Map map = userService.updateStatus(user.getIdUser(),user.getStatus());
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/role/update-status")
|
@PatchMapping("/role/update-status")
|
||||||
public GlobalResult updateRoleStatus(@RequestBody Role role){
|
public GlobalResult<Map> updateRoleStatus(@RequestBody Role role){
|
||||||
Map map = roleService.updateStatus(role.getIdRole(),role.getStatus());
|
Map map = roleService.updateStatus(role.getIdRole(),role.getStatus());
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/role/post")
|
@PostMapping("/role/post")
|
||||||
public GlobalResult addRole(@RequestBody Role role){
|
public GlobalResult<Map> addRole(@RequestBody Role role){
|
||||||
Map map = roleService.saveRole(role);
|
Map map = roleService.saveRole(role);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/role/post")
|
@PutMapping("/role/post")
|
||||||
public GlobalResult updateRole(@RequestBody Role role){
|
public GlobalResult<Map> updateRole(@RequestBody Role role){
|
||||||
Map map = roleService.saveRole(role);
|
Map map = roleService.saveRole(role);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/topics")
|
@GetMapping("/topics")
|
||||||
public GlobalResult topics(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
public GlobalResult<Map<String, Object>> topics(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<Topic> list = topicService.findAll();
|
List<Topic> list = topicService.findAll();
|
||||||
PageInfo pageInfo = new PageInfo(list);
|
PageInfo<Topic> pageInfo = new PageInfo<>(list);
|
||||||
Map map = new HashMap(2);
|
Map<String, Object> map = new HashMap<>(2);
|
||||||
map.put("topics", pageInfo.getList());
|
map.put("topics", pageInfo.getList());
|
||||||
Map pagination = new HashMap(3);
|
Map pagination = Utils.getPagination(pageInfo);
|
||||||
pagination.put("pageSize",pageInfo.getPageSize());
|
|
||||||
pagination.put("total",pageInfo.getTotal());
|
|
||||||
pagination.put("currentPage",pageInfo.getPageNum());
|
|
||||||
map.put("pagination", pagination);
|
map.put("pagination", pagination);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
@ -124,19 +119,19 @@ public class AdminController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/topic/detail/{idTopic}")
|
@GetMapping("/topic/detail/{idTopic}")
|
||||||
public GlobalResult topicDetail(@PathVariable Integer idTopic){
|
public GlobalResult<Topic> topicDetail(@PathVariable Integer idTopic){
|
||||||
Topic topic = topicService.findById(idTopic.toString());
|
Topic topic = topicService.findById(idTopic.toString());
|
||||||
return GlobalResultGenerator.genSuccessResult(topic);
|
return GlobalResultGenerator.genSuccessResult(topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/topic/post")
|
@PostMapping("/topic/post")
|
||||||
public GlobalResult addTopic(@RequestBody Topic topic){
|
public GlobalResult<Map> addTopic(@RequestBody Topic topic){
|
||||||
Map map = topicService.saveTopic(topic);
|
Map map = topicService.saveTopic(topic);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/topic/post")
|
@PutMapping("/topic/post")
|
||||||
public GlobalResult updateTopic(@RequestBody Topic topic){
|
public GlobalResult<Map> updateTopic(@RequestBody Topic topic){
|
||||||
Map map = topicService.saveTopic(topic);
|
Map map = topicService.saveTopic(topic);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,9 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/article")
|
@RequestMapping("/api/v1/article")
|
||||||
public class ArticleController {
|
public class ArticleController {
|
||||||
|
@ -13,6 +13,7 @@ import com.rymcu.vertical.service.ArticleService;
|
|||||||
import com.rymcu.vertical.service.JavaMailService;
|
import com.rymcu.vertical.service.JavaMailService;
|
||||||
import com.rymcu.vertical.service.UserService;
|
import com.rymcu.vertical.service.UserService;
|
||||||
import com.rymcu.vertical.util.UserUtils;
|
import com.rymcu.vertical.util.UserUtils;
|
||||||
|
import com.rymcu.vertical.util.Utils;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -22,6 +23,9 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/console")
|
@RequestMapping("/api/v1/console")
|
||||||
public class CommonApiController {
|
public class CommonApiController {
|
||||||
@ -35,8 +39,8 @@ public class CommonApiController {
|
|||||||
|
|
||||||
@ApiOperation(value = "获取邮件验证码")
|
@ApiOperation(value = "获取邮件验证码")
|
||||||
@PostMapping("/get-email-code")
|
@PostMapping("/get-email-code")
|
||||||
public GlobalResult getEmailCode(@RequestParam("email") String email) throws MessagingException {
|
public GlobalResult<Map<String, String>> getEmailCode(@RequestParam("email") String email) throws MessagingException {
|
||||||
Map map = new HashMap();
|
Map<String, String> map = new HashMap<>(1);
|
||||||
map.put("message",GlobalResultMessage.SEND_SUCCESS.getMessage());
|
map.put("message",GlobalResultMessage.SEND_SUCCESS.getMessage());
|
||||||
User user = userService.findByAccount(email);
|
User user = userService.findByAccount(email);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
@ -52,8 +56,8 @@ public class CommonApiController {
|
|||||||
|
|
||||||
@ApiOperation(value = "获取找回密码邮件")
|
@ApiOperation(value = "获取找回密码邮件")
|
||||||
@PostMapping("/get-forget-password-email")
|
@PostMapping("/get-forget-password-email")
|
||||||
public GlobalResult getForgetPasswordEmail(@RequestParam("email") String email) throws MessagingException {
|
public GlobalResult<Map<Object, Object>> getForgetPasswordEmail(@RequestParam("email") String email) throws MessagingException {
|
||||||
Map map = new HashMap<>(1);
|
Map<Object, Object> map = new HashMap<>(1);
|
||||||
map.put("message",GlobalResultMessage.SEND_SUCCESS.getMessage());
|
map.put("message",GlobalResultMessage.SEND_SUCCESS.getMessage());
|
||||||
User user = userService.findByAccount(email);
|
User user = userService.findByAccount(email);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
@ -68,13 +72,13 @@ public class CommonApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
public GlobalResult register(@RequestParam("email") String email, @RequestParam("password") String password, @RequestParam("code") String code){
|
public GlobalResult<Map> register(@RequestParam("email") String email, @RequestParam("password") String password, @RequestParam("code") String code){
|
||||||
Map map = userService.register(email,password,code);
|
Map map = userService.register(email,password,code);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public GlobalResult login(@RequestParam("account") String account, @RequestParam("password") String password){
|
public GlobalResult<Map> login(@RequestParam("account") String account, @RequestParam("password") String password){
|
||||||
Map map = userService.login(account,password);
|
Map map = userService.login(account,password);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
@ -85,32 +89,26 @@ public class CommonApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/articles")
|
@GetMapping("/articles")
|
||||||
public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page,@RequestParam(defaultValue = "10") Integer rows,@RequestParam(defaultValue = "") String searchText,@RequestParam(defaultValue = "") String tag){
|
public GlobalResult<Map> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @RequestParam(defaultValue = "") String searchText, @RequestParam(defaultValue = "") String tag){
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<ArticleDTO> list = articleService.findArticles(searchText,tag);
|
List<ArticleDTO> list = articleService.findArticles(searchText,tag);
|
||||||
PageInfo pageInfo = new PageInfo(list);
|
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||||
Map map = new HashMap(2);
|
Map map = Utils.getArticlesGlobalResult(pageInfo);
|
||||||
map.put("articles", pageInfo.getList());
|
|
||||||
Map pagination = new HashMap(3);
|
|
||||||
pagination.put("pageSize",pageInfo.getPageSize());
|
|
||||||
pagination.put("total",pageInfo.getTotal());
|
|
||||||
pagination.put("currentPage",pageInfo.getPageNum());
|
|
||||||
map.put("pagination", pagination);
|
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/article/{id}")
|
@GetMapping("/article/{id}")
|
||||||
public GlobalResult detail(@PathVariable Integer id){
|
public GlobalResult<Map<String, Object>> detail(@PathVariable Integer id){
|
||||||
ArticleDTO articleDTO = articleService.findArticleDTOById(id,1);
|
ArticleDTO articleDTO = articleService.findArticleDTOById(id,1);
|
||||||
Map map = new HashMap<>(1);
|
Map<String, Object> map = new HashMap<>(1);
|
||||||
map.put("article", articleDTO);
|
map.put("article", articleDTO);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/update/{id}")
|
@GetMapping("/update/{id}")
|
||||||
public GlobalResult update(@PathVariable Integer id){
|
public GlobalResult<Map<String, Object>> update(@PathVariable Integer id){
|
||||||
ArticleDTO articleDTO = articleService.findArticleDTOById(id,2);
|
ArticleDTO articleDTO = articleService.findArticleDTOById(id,2);
|
||||||
Map map = new HashMap<>(1);
|
Map map = new HashMap<>(1);
|
||||||
map.put("article", articleDTO);
|
map.put("article", articleDTO);
|
||||||
@ -118,13 +116,13 @@ public class CommonApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/token/{token}")
|
@GetMapping("/token/{token}")
|
||||||
public GlobalResult token(@PathVariable String token){
|
public GlobalResult<TokenUser> token(@PathVariable String token){
|
||||||
TokenUser tokenUser = UserUtils.getTokenUser(token);
|
TokenUser tokenUser = UserUtils.getTokenUser(token);
|
||||||
return GlobalResultGenerator.genSuccessResult(tokenUser);
|
return GlobalResultGenerator.genSuccessResult(tokenUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/forget-password")
|
@PatchMapping("/forget-password")
|
||||||
public GlobalResult forgetPassword(@RequestBody ForgetPasswordDTO forgetPassword){
|
public GlobalResult<Map> forgetPassword(@RequestBody ForgetPasswordDTO forgetPassword){
|
||||||
Map map = userService.forgetPassword(forgetPassword.getCode(), forgetPassword.getPassword());
|
Map map = userService.forgetPassword(forgetPassword.getCode(), forgetPassword.getPassword());
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,16 @@ import com.rymcu.vertical.core.result.GlobalResult;
|
|||||||
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
||||||
import com.rymcu.vertical.dto.ArticleDTO;
|
import com.rymcu.vertical.dto.ArticleDTO;
|
||||||
import com.rymcu.vertical.service.ArticleService;
|
import com.rymcu.vertical.service.ArticleService;
|
||||||
|
import com.rymcu.vertical.util.Utils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/tag")
|
@RequestMapping("/api/v1/tag")
|
||||||
public class TagController {
|
public class TagController {
|
||||||
@ -24,14 +27,8 @@ public class TagController {
|
|||||||
public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable String name){
|
public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable String name){
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<ArticleDTO> list = articleService.findArticlesByTagName(name);
|
List<ArticleDTO> list = articleService.findArticlesByTagName(name);
|
||||||
PageInfo pageInfo = new PageInfo(list);
|
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||||
Map map = new HashMap(2);
|
Map map = Utils.getArticlesGlobalResult(pageInfo);
|
||||||
map.put("articles", pageInfo.getList());
|
|
||||||
Map pagination = new HashMap(3);
|
|
||||||
pagination.put("pageSize",pageInfo.getPageSize());
|
|
||||||
pagination.put("total",pageInfo.getTotal());
|
|
||||||
pagination.put("currentPage",pageInfo.getPageNum());
|
|
||||||
map.put("pagination", pagination);
|
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,16 @@ import com.rymcu.vertical.dto.ArticleDTO;
|
|||||||
import com.rymcu.vertical.entity.Topic;
|
import com.rymcu.vertical.entity.Topic;
|
||||||
import com.rymcu.vertical.service.ArticleService;
|
import com.rymcu.vertical.service.ArticleService;
|
||||||
import com.rymcu.vertical.service.TopicService;
|
import com.rymcu.vertical.service.TopicService;
|
||||||
|
import com.rymcu.vertical.util.Utils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@SuppressWarnings("ALL")
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/topic")
|
@RequestMapping("/api/v1/topic")
|
||||||
public class TopicController {
|
public class TopicController {
|
||||||
@ -34,14 +36,8 @@ public class TopicController {
|
|||||||
public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable String name){
|
public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable String name){
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<ArticleDTO> list = articleService.findArticlesByTopicName(name);
|
List<ArticleDTO> list = articleService.findArticlesByTopicName(name);
|
||||||
PageInfo pageInfo = new PageInfo(list);
|
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||||
Map map = new HashMap(2);
|
Map map = Utils.getArticlesGlobalResult(pageInfo);
|
||||||
map.put("articles", pageInfo.getList());
|
|
||||||
Map pagination = new HashMap(3);
|
|
||||||
pagination.put("pageSize",pageInfo.getPageSize());
|
|
||||||
pagination.put("total",pageInfo.getTotal());
|
|
||||||
pagination.put("currentPage",pageInfo.getPageNum());
|
|
||||||
map.put("pagination", pagination);
|
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,16 @@ import com.rymcu.vertical.dto.ArticleDTO;
|
|||||||
import com.rymcu.vertical.dto.UserDTO;
|
import com.rymcu.vertical.dto.UserDTO;
|
||||||
import com.rymcu.vertical.service.ArticleService;
|
import com.rymcu.vertical.service.ArticleService;
|
||||||
import com.rymcu.vertical.service.UserService;
|
import com.rymcu.vertical.service.UserService;
|
||||||
|
import com.rymcu.vertical.util.Utils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/user")
|
@RequestMapping("/api/v1/user")
|
||||||
public class UserController {
|
public class UserController {
|
||||||
@ -39,14 +41,8 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<ArticleDTO> list = articleService.findUserArticlesByIdUser(userDTO.getIdUser());
|
List<ArticleDTO> list = articleService.findUserArticlesByIdUser(userDTO.getIdUser());
|
||||||
PageInfo pageInfo = new PageInfo(list);
|
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||||
Map map = new HashMap(2);
|
Map map = Utils.getArticlesGlobalResult(pageInfo);
|
||||||
map.put("articles", pageInfo.getList());
|
|
||||||
Map pagination = new HashMap(3);
|
|
||||||
pagination.put("pageSize",pageInfo.getPageSize());
|
|
||||||
pagination.put("total",pageInfo.getTotal());
|
|
||||||
pagination.put("currentPage",pageInfo.getPageNum());
|
|
||||||
map.put("pagination", pagination);
|
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user