🎨 代码结构优化
This commit is contained in:
parent
562c4fcd9b
commit
594090c626
@ -55,7 +55,6 @@ public class ShiroConfig implements EnvironmentAware {
|
|||||||
|
|
||||||
filterChainDefinitionMap.put("/api/**", "anon");
|
filterChainDefinitionMap.put("/api/**", "anon");
|
||||||
filterChainDefinitionMap.put("/ws/**", "anon");
|
filterChainDefinitionMap.put("/ws/**", "anon");
|
||||||
filterChainDefinitionMap.put("/wx/**", "anon");
|
|
||||||
filterChainDefinitionMap.put("/**", "auth");
|
filterChainDefinitionMap.put("/**", "auth");
|
||||||
//配置shiro默认登录界面地址,前后端分离中登录界面跳转应由前端路由控制,后台仅返回json数据
|
//配置shiro默认登录界面地址,前后端分离中登录界面跳转应由前端路由控制,后台仅返回json数据
|
||||||
shiroFilterFactoryBean.setLoginUrl("/login");
|
shiroFilterFactoryBean.setLoginUrl("/login");
|
||||||
|
@ -23,6 +23,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring MVC 配置
|
* Spring MVC 配置
|
||||||
|
*
|
||||||
* @author ronger
|
* @author ronger
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@ -49,7 +50,7 @@ public class WebMvcConfigurer extends WebMvcConfigurationSupport {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 解决跨域问题
|
* 解决跨域问题
|
||||||
* */
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
registry.addMapping("/**")
|
registry.addMapping("/**")
|
||||||
@ -65,17 +66,18 @@ public class WebMvcConfigurer extends WebMvcConfigurationSupport {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加拦截器
|
* 添加拦截器
|
||||||
* */
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
registry.addInterceptor(restAuthTokenInterceptor()).addPathPatterns("/api/**")
|
registry.addInterceptor(restAuthTokenInterceptor()).addPathPatterns("/api/**")
|
||||||
.excludePathPatterns("/api/v1/console/**","/api/v1/article/articles/**","/api/v1/article/detail/**","/api/v1/topic/**","/api/v1/user/**");
|
.excludePathPatterns("/api/v1/console/**", "/api/v1/article/articles/**", "/api/v1/article/detail/**"
|
||||||
|
, "/api/v1/topic/**", "/api/v1/user/**", "/api/v1/article/*/comments");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 访问静态资源
|
* 访问静态资源
|
||||||
* */
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
/**
|
/**
|
||||||
|
@ -9,6 +9,7 @@ import com.rymcu.vertical.core.service.redis.RedisService;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import redis.clients.jedis.Jedis;
|
import redis.clients.jedis.Jedis;
|
||||||
@ -27,6 +28,7 @@ import java.util.*;
|
|||||||
* 16/10/30 下午5:28
|
* 16/10/30 下午5:28
|
||||||
*/
|
*/
|
||||||
@Component("redisService")
|
@Component("redisService")
|
||||||
|
@EnableConfigurationProperties({RedisProperties.class})
|
||||||
public class RedisServiceImpl implements RedisService {
|
public class RedisServiceImpl implements RedisService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RedisServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(RedisServiceImpl.class);
|
||||||
|
@ -50,8 +50,6 @@ public class ArticleDTO {
|
|||||||
|
|
||||||
private List<ArticleTagDTO> tags;
|
private List<ArticleTagDTO> tags;
|
||||||
|
|
||||||
private List<CommentDTO> articleComments;
|
|
||||||
|
|
||||||
private List<PortfolioArticleDTO> portfolios;
|
private List<PortfolioArticleDTO> portfolios;
|
||||||
|
|
||||||
private Integer sortNo;
|
private Integer sortNo;
|
||||||
|
@ -19,9 +19,10 @@ public interface ArticleMapper extends Mapper<Article> {
|
|||||||
* 获取文章列表
|
* 获取文章列表
|
||||||
* @param searchText
|
* @param searchText
|
||||||
* @param tag
|
* @param tag
|
||||||
|
* @param topicUri
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<ArticleDTO> selectArticles(@Param("searchText") String searchText, @Param("tag") String tag);
|
List<ArticleDTO> selectArticles(@Param("searchText") String searchText, @Param("tag") String tag, @Param("topicUri") String topicUri);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据文章 ID 查询文章
|
* 根据文章 ID 查询文章
|
||||||
|
@ -2,6 +2,7 @@ package com.rymcu.vertical.service;
|
|||||||
|
|
||||||
import com.rymcu.vertical.core.service.Service;
|
import com.rymcu.vertical.core.service.Service;
|
||||||
import com.rymcu.vertical.dto.ArticleDTO;
|
import com.rymcu.vertical.dto.ArticleDTO;
|
||||||
|
import com.rymcu.vertical.dto.ArticleSearchDTO;
|
||||||
import com.rymcu.vertical.entity.Article;
|
import com.rymcu.vertical.entity.Article;
|
||||||
import com.rymcu.vertical.web.api.exception.BaseApiException;
|
import com.rymcu.vertical.web.api.exception.BaseApiException;
|
||||||
|
|
||||||
@ -17,11 +18,10 @@ public interface ArticleService extends Service<Article> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据检索内容/标签查询文章列表
|
* 根据检索内容/标签查询文章列表
|
||||||
* @param searchText
|
* @param searchDTO
|
||||||
* @param tag
|
|
||||||
* @return
|
* @return
|
||||||
* */
|
* */
|
||||||
List<ArticleDTO> findArticles(String searchText, String tag);
|
List<ArticleDTO> findArticles(ArticleSearchDTO searchDTO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询文章详情信息
|
* 查询文章详情信息
|
||||||
|
@ -52,10 +52,16 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
|
|
||||||
private static final int MAX_PREVIEW = 200;
|
private static final int MAX_PREVIEW = 200;
|
||||||
private static final String defaultStatus = "0";
|
private static final String defaultStatus = "0";
|
||||||
|
private static final String defaultTopicUri = "news";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ArticleDTO> findArticles(String searchText, String tag) {
|
public List<ArticleDTO> findArticles(ArticleSearchDTO searchDTO) {
|
||||||
List<ArticleDTO> list = articleMapper.selectArticles(searchText, tag);
|
List<ArticleDTO> list;
|
||||||
|
if (StringUtils.isNotBlank(searchDTO.getTopicUri()) && !defaultTopicUri.equals(searchDTO.getTopicUri())) {
|
||||||
|
list = articleMapper.selectArticlesByTopicUri(searchDTO.getTopicUri());
|
||||||
|
} else {
|
||||||
|
list = articleMapper.selectArticles(searchDTO.getSearchText(), searchDTO.getTag(), searchDTO.getTopicUri());
|
||||||
|
}
|
||||||
list.forEach(article->{
|
list.forEach(article->{
|
||||||
genArticle(article,0);
|
genArticle(article,0);
|
||||||
});
|
});
|
||||||
@ -292,14 +298,13 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle());
|
ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle());
|
||||||
if (type.equals(ARTICLE_VIEW)){
|
if (type.equals(ARTICLE_VIEW)){
|
||||||
article.setArticleContent(articleContent.getArticleContentHtml());
|
article.setArticleContent(articleContent.getArticleContentHtml());
|
||||||
// 获取评论列表数据
|
|
||||||
List<CommentDTO> commentDTOList = commentService.getArticleComments(article.getIdArticle());
|
|
||||||
article.setArticleComments(commentDTOList);
|
|
||||||
// 获取所属作品集列表数据
|
// 获取所属作品集列表数据
|
||||||
List<PortfolioArticleDTO> portfolioArticleDTOList = articleMapper.selectPortfolioArticles(article.getIdArticle());
|
List<PortfolioArticleDTO> portfolioArticleDTOList = articleMapper.selectPortfolioArticles(article.getIdArticle());
|
||||||
article.setPortfolios(portfolioArticleDTOList);
|
article.setPortfolios(portfolioArticleDTOList);
|
||||||
} else if (type.equals(ARTICLE_EDIT)) {
|
} else if (type.equals(ARTICLE_EDIT)) {
|
||||||
article.setArticleContent(articleContent.getArticleContent());
|
article.setArticleContent(articleContent.getArticleContent());
|
||||||
|
} else {
|
||||||
|
article.setArticleContent(articleContent.getArticleContentHtml());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return article;
|
return article;
|
||||||
|
@ -39,6 +39,7 @@ public class Utils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 一般检查工具密码比对 add by xlf 2018-11-8
|
* 一般检查工具密码比对 add by xlf 2018-11-8
|
||||||
|
*
|
||||||
* @param pwd
|
* @param pwd
|
||||||
* @param enpwd 加密的密码
|
* @param enpwd 加密的密码
|
||||||
* @return
|
* @return
|
||||||
@ -77,9 +78,10 @@ public class Utils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取配置文件内属性
|
* 获取配置文件内属性
|
||||||
|
*
|
||||||
* @param key 键值
|
* @param key 键值
|
||||||
* @return 属性值
|
* @return 属性值
|
||||||
* */
|
*/
|
||||||
public static String getProperty(String key) {
|
public static String getProperty(String key) {
|
||||||
return env.getProperty(key);
|
return env.getProperty(key);
|
||||||
}
|
}
|
||||||
@ -110,7 +112,7 @@ public class Utils {
|
|||||||
timeAgo = hours + " 小时前 ";
|
timeAgo = hours + " 小时前 ";
|
||||||
} else {
|
} else {
|
||||||
int minutes = (int) ((to - from) / (1000 * 60));
|
int minutes = (int) ((to - from) / (1000 * 60));
|
||||||
if(minutes == 0){
|
if (minutes < 5) {
|
||||||
timeAgo = " 刚刚 ";
|
timeAgo = " 刚刚 ";
|
||||||
} else {
|
} else {
|
||||||
timeAgo = minutes + " 分钟前 ";
|
timeAgo = minutes + " 分钟前 ";
|
||||||
|
@ -92,9 +92,9 @@ public class CommonApiController {
|
|||||||
|
|
||||||
@GetMapping("/articles")
|
@GetMapping("/articles")
|
||||||
@VisitLogger
|
@VisitLogger
|
||||||
public GlobalResult<Map> 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, ArticleSearchDTO searchDTO){
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<ArticleDTO> list = articleService.findArticles(searchText,tag);
|
List<ArticleDTO> list = articleService.findArticles(searchDTO);
|
||||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||||
Map map = Utils.getArticlesGlobalResult(pageInfo);
|
Map map = Utils.getArticlesGlobalResult(pageInfo);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
|
@ -33,7 +33,7 @@ public class UploadController {
|
|||||||
|
|
||||||
private final static String UPLOAD_SIMPLE_URL = "/api/upload/file";
|
private final static String UPLOAD_SIMPLE_URL = "/api/upload/file";
|
||||||
private final static String UPLOAD_URL = "/api/upload/file/batch";
|
private final static String UPLOAD_URL = "/api/upload/file/batch";
|
||||||
public static final String ctxHeadPicPath = "/usr/local/src/tomcat-hp/webapps/vertical";
|
public static final String ctxHeadPicPath = "/usr/local/src/nebula/static";
|
||||||
|
|
||||||
@PostMapping("/file")
|
@PostMapping("/file")
|
||||||
public GlobalResult uploadPicture(@RequestParam(value = "file", required = false) MultipartFile multipartFile,@RequestParam(defaultValue = "1")Integer type, HttpServletRequest request){
|
public GlobalResult uploadPicture(@RequestParam(value = "file", required = false) MultipartFile multipartFile,@RequestParam(defaultValue = "1")Integer type, HttpServletRequest request){
|
||||||
|
Loading…
Reference in New Issue
Block a user