Merge pull request #13 from rymcu/dev

修复了一些已知问题
This commit is contained in:
ronger 2020-08-03 08:54:03 +08:00 committed by GitHub
commit 612fc2b403
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 98 additions and 75 deletions

View File

@ -23,6 +23,7 @@ import java.util.List;
/**
* Spring MVC 配置
*
* @author ronger
*/
@Configuration
@ -49,7 +50,7 @@ public class WebMvcConfigurer extends WebMvcConfigurationSupport {
/**
* 解决跨域问题
* */
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
@ -65,17 +66,18 @@ public class WebMvcConfigurer extends WebMvcConfigurationSupport {
/**
* 添加拦截器
* */
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
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
public void addResourceHandlers(ResourceHandlerRegistry registry) {
/**
@ -89,7 +91,7 @@ public class WebMvcConfigurer extends WebMvcConfigurationSupport {
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
//将所有/static/** 访问都映射到classpath:/static/ 目录下
registry.addResourceHandler("/static/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX +"/static/");
registry.addResourceHandler("/static/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/static/");
super.addResourceHandlers(registry);
}
}

View File

@ -50,8 +50,6 @@ public class ArticleDTO {
private List<ArticleTagDTO> tags;
private List<CommentDTO> articleComments;
private List<PortfolioArticleDTO> portfolios;
private Integer sortNo;

View File

@ -0,0 +1,17 @@
package com.rymcu.vertical.dto;
import lombok.Data;
/**
* @author ronger
*/
@Data
public class ArticleSearchDTO {
private String searchText;
private String topicUri;
private String tag;
}

View File

@ -19,9 +19,10 @@ public interface ArticleMapper extends Mapper<Article> {
* 获取文章列表
* @param searchText
* @param tag
* @param topicUri
* @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 查询文章

View File

@ -2,6 +2,7 @@ package com.rymcu.vertical.service;
import com.rymcu.vertical.core.service.Service;
import com.rymcu.vertical.dto.ArticleDTO;
import com.rymcu.vertical.dto.ArticleSearchDTO;
import com.rymcu.vertical.entity.Article;
import com.rymcu.vertical.web.api.exception.BaseApiException;
@ -17,11 +18,10 @@ public interface ArticleService extends Service<Article> {
/**
* 根据检索内容/标签查询文章列表
* @param searchText
* @param tag
* @param searchDTO
* @return
* */
List<ArticleDTO> findArticles(String searchText, String tag);
List<ArticleDTO> findArticles(ArticleSearchDTO searchDTO);
/**
* 查询文章详情信息

View File

@ -52,10 +52,16 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
private static final int MAX_PREVIEW = 200;
private static final String defaultStatus = "0";
private static final String defaultTopicUri = "news";
@Override
public List<ArticleDTO> findArticles(String searchText, String tag) {
List<ArticleDTO> list = articleMapper.selectArticles(searchText, tag);
public List<ArticleDTO> findArticles(ArticleSearchDTO searchDTO) {
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->{
genArticle(article,0);
});
@ -292,14 +298,13 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle());
if (type.equals(ARTICLE_VIEW)){
article.setArticleContent(articleContent.getArticleContentHtml());
// 获取评论列表数据
List<CommentDTO> commentDTOList = commentService.getArticleComments(article.getIdArticle());
article.setArticleComments(commentDTOList);
// 获取所属作品集列表数据
List<PortfolioArticleDTO> portfolioArticleDTOList = articleMapper.selectPortfolioArticles(article.getIdArticle());
article.setPortfolios(portfolioArticleDTOList);
} else if (type.equals(ARTICLE_EDIT)) {
article.setArticleContent(articleContent.getArticleContent());
} else {
article.setArticleContent(articleContent.getArticleContentHtml());
}
}
return article;

View File

@ -43,14 +43,14 @@ public class CommonApiController {
@GetMapping("/get-email-code")
public GlobalResult<Map<String, String>> getEmailCode(@RequestParam("email") String email) throws MessagingException {
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);
if (user != null) {
map.put("message","该邮箱已被注册!");
} else {
Integer result = javaMailService.sendEmailCode(email);
if(result == 0){
map.put("message",GlobalResultMessage.SEND_FAIL.getMessage());
map.put("message", GlobalResultMessage.SEND_FAIL.getMessage());
}
}
return GlobalResultGenerator.genSuccessResult(map);
@ -60,12 +60,12 @@ public class CommonApiController {
@GetMapping("/get-forget-password-email")
public GlobalResult<Map<Object, Object>> getForgetPasswordEmail(@RequestParam("email") String email) throws MessagingException {
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);
if (user != null) {
Integer result = javaMailService.sendForgetPasswordEmail(email);
if(result == 0){
map.put("message",GlobalResultMessage.SEND_FAIL.getMessage());
map.put("message", GlobalResultMessage.SEND_FAIL.getMessage());
}
} else {
map.put("message","该邮箱未注册!");
@ -92,9 +92,9 @@ public class CommonApiController {
@GetMapping("/articles")
@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);
List<ArticleDTO> list = articleService.findArticles(searchText,tag);
List<ArticleDTO> list = articleService.findArticles(searchDTO);
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
Map map = Utils.getArticlesGlobalResult(pageInfo);
return GlobalResultGenerator.genSuccessResult(map);

View File

@ -33,7 +33,7 @@ public class UploadController {
private final static String UPLOAD_SIMPLE_URL = "/api/upload/file";
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")
public GlobalResult uploadPicture(@RequestParam(value = "file", required = false) MultipartFile multipartFile,@RequestParam(defaultValue = "1")Integer type, HttpServletRequest request){

View File

@ -1,52 +1,52 @@
spring:
# profiles:
# active: pord
thymeleaf:
prefix: classpath:/templates/
suffix: .html
mode: LEGACYHTML5
encoding: UTF-8
servlet:
content-type: text/html
cache: false
redis:
host: 127.0.0.1
port: 6379
password: # redis 密码
database: 1
timeout: 3000
jedis:
pool:
max-active: 8
max-wait: 1
max-idle: 500
min-idle: 0
datasource:
url: jdbc:mysql://localhost:3306/vertical?characterEncoding=UTF-8&autoReconnect=true&useSSL=false
username: root
password: # 数据库密码
driver-class-name: com.mysql.cj.jdbc.Driver
resources:
add-mappings: true
mail:
host: smtp.163.com
port: 465
username: # 邮箱
password: # 密码
env: dev
logging:
file:
path: /logs/vertical
server:
port: 8099
servlet:
context-path: /vertical
version: 1.0
resource:
file-path: https://abc.com/vertical
baidu:
data:
site: https://abc.com # 百度搜索资源配置网址
token: xxxx # 百度搜索资源token
reserved-words: \u7cfb\u7edf\u516c\u544a\u002c\u516c\u544a
spring:
# profiles:
# active: dev
thymeleaf:
prefix: classpath:/templates/
suffix: .html
mode: LEGACYHTML5
encoding: UTF-8
servlet:
content-type: text/html
cache: false
redis:
host: 127.0.0.1
port: 6379
password: # redis 密码
database: 1
timeout: 3000
jedis:
pool:
max-active: 8
max-wait: 1
max-idle: 500
min-idle: 0
datasource:
url: jdbc:mysql://localhost:3306/vertical?characterEncoding=UTF-8&autoReconnect=true&useSSL=false
username: root
password: # 数据库密码
driver-class-name: com.mysql.cj.jdbc.Driver
resources:
add-mappings: true
mail:
host: smtp.163.com
port: 465
username: # 邮箱
password: # 密码
env: dev
logging:
file:
path: /logs/vertical
server:
port: 8099
servlet:
context-path: /vertical
version: 1.0
resource:
file-path: https://abc.com/vertical
baidu:
data:
site: https://abc.com # 百度搜索资源配置网址
token: xxxx # 百度搜索资源token
reserved-words: \u7cfb\u7edf\u516c\u544a\u002c\u516c\u544a