From b7e0468007d834d9980058f6654c3b7774e7e5ff Mon Sep 17 00:00:00 2001 From: ronger Date: Wed, 24 Jun 2020 10:45:23 +0800 Subject: [PATCH 1/4] first commit --- src/main/resources/application.yml | 83 +++++------------------------- 1 file changed, 14 insertions(+), 69 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d4a3203..4dd536e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: -# profiles: -# active: dev + # profiles: + # active: pord thymeleaf: prefix: classpath:/templates/ suffix: .html @@ -12,7 +12,7 @@ spring: redis: host: 127.0.0.1 port: 6379 - password: d9d2j9w2 + password: # redis 密码 database: 1 timeout: 3000 jedis: @@ -22,86 +22,31 @@ spring: max-idle: 500 min-idle: 0 datasource: - url: jdbc:mysql://101.132.182.12:3306/vertical?characterEncoding=UTF-8&autoReconnect=true&useSSL=false + url: jdbc:mysql://localhost:3306/vertical?characterEncoding=UTF-8&autoReconnect=true&useSSL=false username: root - password: d9d2j9w2.RYMCU + password: # 数据库密码 driver-class-name: com.mysql.cj.jdbc.Driver - max-wait: 60000 - min-idle: 20 - initial-size: 10 - max-active: 50 - # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 - time-between-eviction-runs-millis: 60000 - # 配置一个连接在池中最小生存的时间,单位是毫秒 - min-evictable-idle-time-millis: 30000 - validation-query: SELECT 1 FROM DUAL - test-while-idle: true - test-on-borrow: false - test-on-return: false - log-slow-sql: true - filters: config,stat,wall,log4j - max-pool-prepared-statement-per-connection-size: 100 - stat-view-servlet: - enabled: true - pool-prepared-statements: true resources: add-mappings: true mail: - host: smtp.ym.163.com + host: smtp.163.com port: 465 - username: service@rymcu.com - password: Aa12345678 - servlet: - multipart: - max-file-size: 10MB - max-request-size: 20MB -wx: - open: - componentAppId: wx9c4a7dfb3238d5f6 - componentSecret: e32a6f75ab6b746ec3ae38a39a79ba22 - componentToken: rymcu - componentAesKey: NWIwMDQyZjU0YWI2NGFlZThkOWZhZTg3NTg4NzQwN2E - mp: - configs: - - appId: wxf085386aa07c0857 - secret: aabd075d2851764714fd14a0d0b1b8b4 - token: rymcu - aesKey: NWIwMDQyZjU0YWI2NGFlZThkOWZhZTg3NTg4NzQwN2E - - appId: wxa49093339a5a822b - secret: 29e9390e6d58d57a2b2a2350dbee8754 - token: qwert - aesKey: - miniapp: - configs: - - appid: wxf57df4f171606a26 - secret: 574ff86cb48a42f3980b221e942c53b1 - token: #微信小程序消息服务器配置的token - aesKey: #微信小程序消息服务器配置的EncodingAESKey - msgDataFormat: JSON -env: pord + username: # 邮箱 + password: # 密码 +env: dev logging: file: path: /logs/vertical - level: - com: - rymcu: - vertical: - wx: debug - web: debug server: port: 8099 servlet: context-path: /vertical - compression: - enabled: true - mime-types: application/json,application/xml,text/html,text/xml,text/plain - min-response-size: 1024 - max-http-header-size: 1024 version: 1.0 resource: - domain: https://rymcu.com - file-path: https://rymcu.com/vertical + file-path: https://abc.com/vertical baidu: data: - site: https://www.rymcu.com - token: 9cdKR6bVCJzxDEJS \ No newline at end of file + site: https://abc.com # 百度搜索资源配置网址 + token: xxxx # 百度搜索资源token +reserved-words: \u7cfb\u7edf\u516c\u544a\u002c\u516c\u544a + From 26d8674f340fff1a071e1fc2ae789b63ab140455 Mon Sep 17 00:00:00 2001 From: x ronger Date: Sat, 1 Aug 2020 00:43:58 +0800 Subject: [PATCH 2/4] =?UTF-8?q?:sparkles:=20=20=E4=B8=93=E9=A2=98=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=8A=9F=E8=83=BD=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/rymcu/vertical/dto/ArticleDTO.java | 2 -- .../rymcu/vertical/dto/ArticleSearchDTO.java | 17 +++++++++++++++++ .../rymcu/vertical/mapper/ArticleMapper.java | 3 ++- .../rymcu/vertical/service/ArticleService.java | 6 +++--- .../service/impl/ArticleServiceImpl.java | 13 ++++++++----- .../web/api/common/CommonApiController.java | 12 ++++++------ 6 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/rymcu/vertical/dto/ArticleSearchDTO.java diff --git a/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java b/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java index aaa0759..ac89644 100644 --- a/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java +++ b/src/main/java/com/rymcu/vertical/dto/ArticleDTO.java @@ -50,8 +50,6 @@ public class ArticleDTO { private List tags; - private List articleComments; - private List portfolios; private Integer sortNo; diff --git a/src/main/java/com/rymcu/vertical/dto/ArticleSearchDTO.java b/src/main/java/com/rymcu/vertical/dto/ArticleSearchDTO.java new file mode 100644 index 0000000..1e3bb6f --- /dev/null +++ b/src/main/java/com/rymcu/vertical/dto/ArticleSearchDTO.java @@ -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; + +} diff --git a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java index 6194cee..8c74ece 100644 --- a/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/ArticleMapper.java @@ -19,9 +19,10 @@ public interface ArticleMapper extends Mapper
{ * 获取文章列表 * @param searchText * @param tag + * @param topicUri * @return */ - List selectArticles(@Param("searchText") String searchText, @Param("tag") String tag); + List selectArticles(@Param("searchText") String searchText, @Param("tag") String tag, @Param("topicUri") String topicUri); /** * 根据文章 ID 查询文章 diff --git a/src/main/java/com/rymcu/vertical/service/ArticleService.java b/src/main/java/com/rymcu/vertical/service/ArticleService.java index 497cdf8..65f6718 100644 --- a/src/main/java/com/rymcu/vertical/service/ArticleService.java +++ b/src/main/java/com/rymcu/vertical/service/ArticleService.java @@ -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
{ /** * 根据检索内容/标签查询文章列表 - * @param searchText - * @param tag + * @param searchDTO * @return * */ - List findArticles(String searchText, String tag); + List findArticles(ArticleSearchDTO searchDTO); /** * 查询文章详情信息 diff --git a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java index 271c40d..a041b7f 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java @@ -52,10 +52,16 @@ public class ArticleServiceImpl extends AbstractService
implements Arti private static final int MAX_PREVIEW = 200; private static final String defaultStatus = "0"; + private static final String defaultTopicUri = "news"; @Override - public List findArticles(String searchText, String tag) { - List list = articleMapper.selectArticles(searchText, tag); + public List findArticles(ArticleSearchDTO searchDTO) { + List 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,9 +298,6 @@ public class ArticleServiceImpl extends AbstractService
implements Arti ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle()); if (type.equals(ARTICLE_VIEW)){ article.setArticleContent(articleContent.getArticleContentHtml()); - // 获取评论列表数据 - List commentDTOList = commentService.getArticleComments(article.getIdArticle()); - article.setArticleComments(commentDTOList); // 获取所属作品集列表数据 List portfolioArticleDTOList = articleMapper.selectPortfolioArticles(article.getIdArticle()); article.setPortfolios(portfolioArticleDTOList); diff --git a/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java b/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java index 722b5bc..34f4971 100644 --- a/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java +++ b/src/main/java/com/rymcu/vertical/web/api/common/CommonApiController.java @@ -43,14 +43,14 @@ public class CommonApiController { @GetMapping("/get-email-code") public GlobalResult> getEmailCode(@RequestParam("email") String email) throws MessagingException { Map 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> getForgetPasswordEmail(@RequestParam("email") String email) throws MessagingException { Map 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 articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @RequestParam(defaultValue = "") String searchText, @RequestParam(defaultValue = "") String tag){ + public GlobalResult articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO searchDTO){ PageHelper.startPage(page, rows); - List list = articleService.findArticles(searchText,tag); + List list = articleService.findArticles(searchDTO); PageInfo pageInfo = new PageInfo(list); Map map = Utils.getArticlesGlobalResult(pageInfo); return GlobalResultGenerator.genSuccessResult(map); From 0d50debe6ad4dc2bca99383c7598a9f062bc7d65 Mon Sep 17 00:00:00 2001 From: x ronger Date: Mon, 3 Aug 2020 00:01:52 +0800 Subject: [PATCH 3/4] =?UTF-8?q?:bug:=20=E8=8D=89=E7=A8=BF=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/vertical/config/WebMvcConfigurer.java | 12 +++++++----- .../vertical/service/impl/ArticleServiceImpl.java | 2 ++ .../vertical/web/api/common/UploadController.java | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/rymcu/vertical/config/WebMvcConfigurer.java b/src/main/java/com/rymcu/vertical/config/WebMvcConfigurer.java index c45c0b0..8c053f0 100644 --- a/src/main/java/com/rymcu/vertical/config/WebMvcConfigurer.java +++ b/src/main/java/com/rymcu/vertical/config/WebMvcConfigurer.java @@ -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); } } diff --git a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java index a041b7f..ef3808d 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/ArticleServiceImpl.java @@ -303,6 +303,8 @@ public class ArticleServiceImpl extends AbstractService
implements Arti article.setPortfolios(portfolioArticleDTOList); } else if (type.equals(ARTICLE_EDIT)) { article.setArticleContent(articleContent.getArticleContent()); + } else { + article.setArticleContent(articleContent.getArticleContentHtml()); } } return article; diff --git a/src/main/java/com/rymcu/vertical/web/api/common/UploadController.java b/src/main/java/com/rymcu/vertical/web/api/common/UploadController.java index e2ae5c9..f8f9ddf 100644 --- a/src/main/java/com/rymcu/vertical/web/api/common/UploadController.java +++ b/src/main/java/com/rymcu/vertical/web/api/common/UploadController.java @@ -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){ From 7f1f92c82dbe4d9733128b459ab37bb1f7670f1d Mon Sep 17 00:00:00 2001 From: ronger Date: Mon, 3 Aug 2020 08:49:21 +0800 Subject: [PATCH 4/4] first commit --- src/main/resources/application.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4dd536e..afa7b24 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: - # profiles: - # active: pord +# profiles: +# active: dev thymeleaf: prefix: classpath:/templates/ suffix: .html