Browse Source

fix 整理项目文件

Young 2 years ago
parent
commit
8bf2fde8a9
100 changed files with 436 additions and 4413 deletions
  1. 3 73
      pom.xml
  2. 0 1
      src/main/java/com/nosum/DeliverApplication.java
  3. 0 33
      src/main/java/com/nosum/common/annotation/OperateLog.java
  4. 0 12
      src/main/java/com/nosum/common/base/dao/BaseDao.java
  5. 0 16
      src/main/java/com/nosum/common/base/domain/vo/BaseVO.java
  6. 20 3
      src/main/java/com/nosum/common/base/domain/vo/UserSessionVO.java
  7. 0 7
      src/main/java/com/nosum/common/base/service/BaseService.java
  8. 0 7
      src/main/java/com/nosum/common/base/service/impl/BaseServiceImpl.java
  9. 0 24
      src/main/java/com/nosum/common/cache/ConfigCache.java
  10. 0 27
      src/main/java/com/nosum/common/config/MybatisPlusConfig.java
  11. 0 1
      src/main/java/com/nosum/common/config/WebConfigurer.java
  12. 2 12
      src/main/java/com/nosum/common/config/WebConverterConfigurer.java
  13. 0 65
      src/main/java/com/nosum/common/constant/GithubOauth.java
  14. 0 32
      src/main/java/com/nosum/common/context/BeanTool.java
  15. 0 47
      src/main/java/com/nosum/common/util/DateUtil.java
  16. 0 115
      src/main/java/com/nosum/common/util/ErrorMessageUtil.java
  17. 0 38
      src/main/java/com/nosum/common/util/ExceptionUtil.java
  18. 0 1
      src/main/java/com/nosum/common/util/FileUtil.java
  19. 0 135
      src/main/java/com/nosum/common/util/HttpClientDownloader.java
  20. 0 158
      src/main/java/com/nosum/common/util/HttpClientGenerator.java
  21. 0 78
      src/main/java/com/nosum/common/util/HttpClientUtils.java
  22. 0 96
      src/main/java/com/nosum/common/util/HttpContextUtils.java
  23. 0 35
      src/main/java/com/nosum/common/util/Markdown2HtmlUtil.java
  24. 0 35
      src/main/java/com/nosum/common/util/PageUtil.java
  25. 0 72
      src/main/java/com/nosum/common/util/PreviewTextUtils.java
  26. 15 19
      src/main/java/com/nosum/common/util/SessionUtil.java
  27. 0 48
      src/main/java/com/nosum/common/util/ThrowableUtils.java
  28. 0 14
      src/main/java/com/nosum/common/util/ToolUtil.java
  29. 0 30
      src/main/java/com/nosum/deliver/auth/controller/AuthUserController.java
  30. 0 12
      src/main/java/com/nosum/deliver/auth/dao/AuthTokenDao.java
  31. 0 20
      src/main/java/com/nosum/deliver/auth/dao/AuthUserDao.java
  32. 0 22
      src/main/java/com/nosum/deliver/auth/dao/AuthUserSocialDao.java
  33. 9 18
      src/main/java/com/nosum/deliver/auth/domain/po/AuthToken.java
  34. 17 29
      src/main/java/com/nosum/deliver/auth/domain/po/AuthUser.java
  35. 0 88
      src/main/java/com/nosum/deliver/auth/domain/po/AuthUserSocial.java
  36. 0 9
      src/main/java/com/nosum/deliver/auth/domain/validator/InsertSocial.java
  37. 0 9
      src/main/java/com/nosum/deliver/auth/domain/validator/UpdateSocial.java
  38. 0 9
      src/main/java/com/nosum/deliver/auth/domain/validator/UpdateUsers.java
  39. 0 74
      src/main/java/com/nosum/deliver/auth/domain/vo/AuthUserSocialVO.java
  40. 4 8
      src/main/java/com/nosum/deliver/auth/domain/vo/AuthUserVO.java
  41. 1 23
      src/main/java/com/nosum/deliver/auth/service/AuthUserService.java
  42. 51 111
      src/main/java/com/nosum/deliver/auth/service/impl/AuthUserServiceImpl.java
  43. 29 25
      src/main/java/com/nosum/deliver/auth/service/impl/OauthServiceImpl.java
  44. 2 2
      src/main/java/com/nosum/deliver/author/controller/AuthorAdminController.java
  45. 0 83
      src/main/java/com/nosum/deliver/category/controller/CategoryController.java
  46. 0 68
      src/main/java/com/nosum/deliver/category/controller/TagsController.java
  47. 0 31
      src/main/java/com/nosum/deliver/category/dao/CategoryDao.java
  48. 0 16
      src/main/java/com/nosum/deliver/category/dao/CategoryTagsDao.java
  49. 0 16
      src/main/java/com/nosum/deliver/category/dao/TagsDao.java
  50. 0 58
      src/main/java/com/nosum/deliver/category/domain/po/Category.java
  51. 0 59
      src/main/java/com/nosum/deliver/category/domain/po/CategoryTags.java
  52. 0 54
      src/main/java/com/nosum/deliver/category/domain/po/Tags.java
  53. 0 45
      src/main/java/com/nosum/deliver/category/domain/vo/CategoryVO.java
  54. 0 28
      src/main/java/com/nosum/deliver/category/domain/vo/TagsVO.java
  55. 0 65
      src/main/java/com/nosum/deliver/category/service/CategoryService.java
  56. 0 55
      src/main/java/com/nosum/deliver/category/service/TagsService.java
  57. 0 214
      src/main/java/com/nosum/deliver/category/service/impl/CategoryServiceImpl.java
  58. 0 120
      src/main/java/com/nosum/deliver/category/service/impl/TagsServiceImpl.java
  59. 17 45
      src/main/java/com/nosum/deliver/dashboard/service/impl/DashboardServiceImpl.java
  60. 4 12
      src/main/java/com/nosum/deliver/file/controller/UploadFileController.java
  61. 2 3
      src/main/java/com/nosum/deliver/file/factory/UploadFileFactory.java
  62. 0 55
      src/main/java/com/nosum/deliver/file/service/impl/ALiYunOSSUploadFileTemplateServiceImpl.java
  63. 0 53
      src/main/java/com/nosum/deliver/file/service/impl/COSUploadFileTemplateServiceImpl.java
  64. 12 16
      src/main/java/com/nosum/deliver/file/service/impl/DefaultUploadFileTemplateServiceImpl.java
  65. 0 57
      src/main/java/com/nosum/deliver/file/service/impl/QiNiuUploadFileTemplateServiceImpl.java
  66. 7 7
      src/main/java/com/nosum/deliver/monitor/controller/MonitorController.java
  67. 210 208
      src/main/java/com/nosum/deliver/monitor/util/RuntimeUtil.java
  68. 1 1
      src/main/java/com/nosum/deliver/posts/controller/ArchiveController.java
  69. 0 59
      src/main/java/com/nosum/deliver/posts/controller/PostsCommentsController.java
  70. 0 83
      src/main/java/com/nosum/deliver/posts/controller/PostsController.java
  71. 0 16
      src/main/java/com/nosum/deliver/posts/dao/PostsAttributeDao.java
  72. 0 36
      src/main/java/com/nosum/deliver/posts/dao/PostsCommentsDao.java
  73. 1 33
      src/main/java/com/nosum/deliver/posts/dao/PostsDao.java
  74. 0 12
      src/main/java/com/nosum/deliver/posts/dao/PostsTagsDao.java
  75. 2 14
      src/main/java/com/nosum/deliver/posts/domain/po/Posts.java
  76. 0 40
      src/main/java/com/nosum/deliver/posts/domain/po/PostsAttribute.java
  77. 0 55
      src/main/java/com/nosum/deliver/posts/domain/po/PostsComments.java
  78. 0 60
      src/main/java/com/nosum/deliver/posts/domain/po/PostsTags.java
  79. 0 10
      src/main/java/com/nosum/deliver/posts/domain/validator/CrawlerPosts.java
  80. 0 8
      src/main/java/com/nosum/deliver/posts/domain/validator/InsertPostsComments.java
  81. 0 8
      src/main/java/com/nosum/deliver/posts/domain/validator/QueryPostsComments.java
  82. 0 23
      src/main/java/com/nosum/deliver/posts/domain/vo/CNBlogsVO.java
  83. 0 26
      src/main/java/com/nosum/deliver/posts/domain/vo/CSDNVO.java
  84. 0 26
      src/main/java/com/nosum/deliver/posts/domain/vo/JianShuVO.java
  85. 0 26
      src/main/java/com/nosum/deliver/posts/domain/vo/JueJinVO.java
  86. 0 18
      src/main/java/com/nosum/deliver/posts/domain/vo/PostsAttributeVO.java
  87. 0 48
      src/main/java/com/nosum/deliver/posts/domain/vo/PostsCommentsVO.java
  88. 2 15
      src/main/java/com/nosum/deliver/posts/domain/vo/PostsVO.java
  89. 0 26
      src/main/java/com/nosum/deliver/posts/domain/vo/SegmentFaultVO.java
  90. 0 42
      src/main/java/com/nosum/deliver/posts/service/PostsCommentsService.java
  91. 1 44
      src/main/java/com/nosum/deliver/posts/service/PostsService.java
  92. 0 134
      src/main/java/com/nosum/deliver/posts/service/impl/PostsCommentsServiceImpl.java
  93. 15 292
      src/main/java/com/nosum/deliver/posts/service/impl/PostsServiceImpl.java
  94. 0 70
      src/main/java/com/nosum/system/enums/PlatformEnum.java
  95. 9 7
      src/main/java/com/nosum/system/schedule/SchedulerTask.java
  96. 0 13
      src/main/resources/mapper/auth/AuthTokenMapper.xml
  97. 0 24
      src/main/resources/mapper/auth/AuthUserMapper.xml
  98. 0 37
      src/main/resources/mapper/auth/AuthUserSocialMapper.xml
  99. 0 46
      src/main/resources/mapper/category/CategoryMapper.xml
  100. 0 0
      src/main/resources/mapper/category/CategoryTagsMapper.xml

+ 3 - 73
pom.xml

@@ -52,55 +52,18 @@
         </dependency>
 
         <dependency>
-            <groupId>com.baomidou</groupId>
-            <artifactId>mybatis-plus-boot-starter</artifactId>
-            <version>3.2.0</version>
-        </dependency>
-
-        <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
             <version>1.18.4</version>
             <scope>provided</scope>
         </dependency>
 
-        <!--markdown to html-->
-        <dependency>
-            <groupId>com.vladsch.flexmark</groupId>
-            <artifactId>flexmark</artifactId>
-            <version>0.26.4</version>
-        </dependency>
-        <dependency>
-            <groupId>com.vladsch.flexmark</groupId>
-            <artifactId>flexmark-util</artifactId>
-            <version>0.26.4</version>
-        </dependency>
-        <!--表格渲染插件-->
-        <dependency>
-            <groupId>com.vladsch.flexmark</groupId>
-            <artifactId>flexmark-ext-tables</artifactId>
-            <version>0.26.4</version>
-        </dependency>
-
         <dependency>
             <groupId>com.auth0</groupId>
             <artifactId>java-jwt</artifactId>
             <version>3.4.0</version>
         </dependency>
 
-        <!--过滤html标签类库 -->
-        <dependency>
-            <groupId>org.jsoup</groupId>
-            <artifactId>jsoup</artifactId>
-            <version>1.9.2</version>
-        </dependency>
-
-        <dependency>
-            <groupId>com.qiniu</groupId>
-            <artifactId>qiniu-java-sdk</artifactId>
-            <version>7.2.15</version>
-        </dependency>
-
         <dependency>
             <groupId>cn.hutool</groupId>
             <artifactId>hutool-all</artifactId>
@@ -108,42 +71,9 @@
         </dependency>
 
         <dependency>
-            <groupId>us.codecraft</groupId>
-            <artifactId>webmagic-core</artifactId>
-            <version>0.7.3</version>
-            <exclusions>
-            	<exclusion>
-            		<groupId>org.slf4j</groupId>
-            		<artifactId>slf4j-log4j12</artifactId>
-            	</exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>us.codecraft</groupId>
-            <artifactId>webmagic-extension</artifactId>
-            <version>0.7.3</version>
-        </dependency>
-        <dependency>
-            <groupId>com.kotcrab.remark</groupId>
-            <artifactId>remark</artifactId>
-            <version>1.0.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.fusesource</groupId>
-            <artifactId>sigar</artifactId>
-            <version>1.6.4</version>
-        </dependency>
-        <!--  阿里云OSS服务  -->
-        <dependency>
-            <groupId>com.aliyun.oss</groupId>
-            <artifactId>aliyun-sdk-oss</artifactId>
-            <version>3.8.0</version>
-        </dependency>
-        <!--   腾讯云COS服务     -->
-        <dependency>
-            <groupId>com.qcloud</groupId>
-            <artifactId>cos_api</artifactId>
-            <version>5.6.8</version>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.79</version>
         </dependency>
 
     </dependencies>

+ 0 - 1
src/main/java/com/nosum/DeliverApplication.java

@@ -1,7 +1,6 @@
 package com.nosum;
 
 import com.nosum.system.init.ConfigApplicationContextInitializer;
-import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.scheduling.annotation.EnableScheduling;

+ 0 - 33
src/main/java/com/nosum/common/annotation/OperateLog.java

@@ -1,33 +0,0 @@
-package com.nosum.common.annotation;
-
-import com.nosum.common.enums.OperateEnum;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-
-/**
- * 操作日志.
- *
- * @author Young
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface OperateLog {
-
-    /**
-     * 模块名
-     *
-     * @return 模块名称
-     */
-    String module();
-
-    /**
-     * 操作编号
-     *
-     * @return 操作编号
-     */
-    OperateEnum code() default OperateEnum.GET_POSTS_DEFAULT;
-}

+ 0 - 12
src/main/java/com/nosum/common/base/dao/BaseDao.java

@@ -1,12 +0,0 @@
-package com.nosum.common.base.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-/**
- * DAO 层抽象父类.
- *
- * @param <T> 泛型
- * @author Young
- */
-public interface BaseDao<T> extends BaseMapper<T> {
-}

+ 0 - 16
src/main/java/com/nosum/common/base/domain/vo/BaseVO.java

@@ -2,9 +2,7 @@ package com.nosum.common.base.domain.vo;
 
 import com.nosum.common.validator.Messages;
 import com.nosum.common.validator.annotion.IntegerNotNull;
-import com.nosum.common.validator.annotion.NotNull;
 import com.nosum.common.validator.group.Page;
-import com.nosum.common.validator.group.Update;
 import lombok.Data;
 import lombok.experimental.Accessors;
 
@@ -19,12 +17,6 @@ import lombok.experimental.Accessors;
 public class BaseVO<T> {
 
     /**
-     * 主键
-     */
-    @NotNull(message = Messages.ID_NOT_NULL, groups = {Update.class})
-    protected Long id;
-
-    /**
      * 关键词搜索
      */
     protected String keywords;
@@ -41,14 +33,6 @@ public class BaseVO<T> {
     @IntegerNotNull(groups = {Page.class}, message = Messages.SIZE_NOT_NULL)
     protected Integer size;
 
-    public Long getId() {
-        return id;
-    }
-
-    public T setId(Long id) {
-        this.id = id;
-        return (T) this;
-    }
 
     public Integer getSize() {
         return size;

+ 20 - 3
src/main/java/com/nosum/common/base/domain/vo/UserSessionVO.java

@@ -2,6 +2,7 @@ package com.nosum.common.base.domain.vo;
 
 import lombok.Data;
 import lombok.experimental.Accessors;
+import org.bson.types.ObjectId;
 
 /**
  * 用户 Session 实体.
@@ -12,18 +13,34 @@ import lombok.experimental.Accessors;
 @Accessors(chain = true)
 public class UserSessionVO {
 
-    private Long id;
-
-    private String socialId;
+    /**
+     * 用户ID
+     */
+    private ObjectId id;
 
+    /**
+     * 用户名称
+     */
     private String name;
 
+    /**
+     * 头像地址
+     */
     private String avatar;
 
+    /**
+     * 性别
+     */
     private Integer gender;
 
+    /**
+     * 角色
+     */
     private Long roleId;
 
+    /**
+     * TOKEN
+     */
     private String token;
 
 }

+ 0 - 7
src/main/java/com/nosum/common/base/service/BaseService.java

@@ -1,7 +0,0 @@
-package com.nosum.common.base.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-
-public interface BaseService<T> extends IService<T> {
-
-}

+ 0 - 7
src/main/java/com/nosum/common/base/service/impl/BaseServiceImpl.java

@@ -1,7 +0,0 @@
-package com.nosum.common.base.service.impl;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
-public class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> {
-}

+ 0 - 24
src/main/java/com/nosum/common/cache/ConfigCache.java

@@ -1,24 +0,0 @@
-package com.nosum.common.cache;
-
-import org.apache.commons.lang3.StringUtils;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * @description:
- * @author: sumbytes
- * @date: 2019/09/03 11:48
- */
-public class ConfigCache {
-
-    private final static Map<String, String> configCache = new ConcurrentHashMap<>();
-
-    public static void putConfig(String key, String value) {
-        configCache.put(key, value);
-    }
-
-    public static String getConfig(String key) {
-        return StringUtils.trim(configCache.get(key));
-    }
-}

+ 0 - 27
src/main/java/com/nosum/common/config/MybatisPlusConfig.java

@@ -1,27 +0,0 @@
-package com.nosum.common.config;
-
-import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
-import com.baomidou.mybatisplus.core.injector.ISqlInjector;
-import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @Author:sumbytes
- * @Date:2018/09/27 12:52
- */
-@Configuration
-@MapperScan("com.nosum.deliver.*.dao")
-public class MybatisPlusConfig {
-
-    @Bean
-    public PaginationInterceptor paginationInterceptor() {
-        return new PaginationInterceptor();
-    }
-
-    @Bean
-    public ISqlInjector sqlInjector() {
-        return new DefaultSqlInjector();
-    }
-}

+ 0 - 1
src/main/java/com/nosum/common/config/WebConfigurer.java

@@ -1,6 +1,5 @@
 package com.nosum.common.config;
 
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

+ 2 - 12
src/main/java/com/nosum/common/config/WebConverterConfigurer.java

@@ -39,20 +39,10 @@ public class WebConverterConfigurer implements WebMvcConfigurer {
 
 
         // 注册时间反序列化转换器,时间戳字符串转换为LocalDateTime类型
-        registry.addConverter(new Converter<String, LocalDate>() {
-            @Override
-            public LocalDate convert(String source) {
-                return StringUtils.isBlank(source) ? null : new Timestamp(Long.valueOf(source)).toLocalDateTime().toLocalDate();
-            }
-        });
+        registry.addConverter((Converter<String, LocalDate>) source -> StringUtils.isBlank(source) ? null : new Timestamp(Long.parseLong(source)).toLocalDateTime().toLocalDate());
 
         // 注册时间反序列化转换器,时间戳字符串转换为LocalDateTime类型
-        registry.addConverter(new Converter<String, LocalDateTime>() {
-            @Override
-            public LocalDateTime convert(String source) {
-                return StringUtils.isBlank(source) ? null : new Timestamp(Long.valueOf(source)).toLocalDateTime();
-            }
-        });
+        registry.addConverter((Converter<String, LocalDateTime>) source -> StringUtils.isBlank(source) ? null : new Timestamp(Long.parseLong(source)).toLocalDateTime());
     }
 
     @Override

+ 0 - 65
src/main/java/com/nosum/common/constant/GithubOauth.java

@@ -1,65 +0,0 @@
-package com.nosum.common.constant;
-
-import cn.hutool.http.Header;
-import cn.hutool.http.HttpRequest;
-import com.nosum.common.util.HttpClientUtils;
-import com.nosum.common.util.JsonUtil;
-import com.nosum.deliver.auth.domain.vo.AuthUserVO;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-
-public class GithubOauth {
-    private static final String CLIENT_ID = "62315a189a3efded767b";
-    private static final String CLIENT_SECRET = "c0348e4697552e1dcce200d43ab21984bf2e9973";
-    private static final String AUTH_URL = "https://github.com/login/oauth/authorize";
-    private static final String TOKEN_URL = "https://github.com/login/oauth/access_token";
-    private static final String USER_INFO_URL = "https://api.github.com/user";
-
-
-    public static String getAuthUrl() {
-        return AUTH_URL + "?state=c2NvcGU9bm9zdW1ibG9n&client_id=" + CLIENT_ID;
-    }
-
-    public static String getAccessToken(String code) {
-        Map<String, Object> params = new HashMap<>();
-        params.put("code", code);
-        params.put("client_id", CLIENT_ID);
-        params.put("client_secret", CLIENT_SECRET);
-        HttpRequest post = HttpRequest.post(TOKEN_URL);
-        post.body(JsonUtil.toJsonString(params)).contentType("application/json").header(Header.ACCEPT, "application/json");
-        return post.execute().body();
-    }
-
-    public static String getHtml(Object result) {
-        // vue前端获取这个数据,去登录。
-        return "<head><meta charset=\"UTF-8\"></head>" +
-                "<body><p style=\"text-align: center;\"><h3>欢迎访问青涩知夏博客,登录中,请稍后......</h3></p></body>" +
-                "\n <script type=\"text/javascript\">\n" +
-                "  window.onload=function () {\n" +
-                "    var message =" + JsonUtil.toJsonString(result) + ";\n" +
-                "    window.opener.parent.postMessage(message, '*');\n" +
-                "    parent.window.close();\n" +
-                "  }</script>";
-    }
-
-    public static String getErrorHtml() {
-        return getHtml("error");
-    }
-
-    public static AuthUserVO getUserInfo(String code) {
-        Optional<String> optional = Optional.ofNullable(code);
-        if (optional.isPresent()) {
-            Map<String, String> accessTokenMap = JsonUtil.parseHashMap(getAccessToken(optional.get()));
-            String userinfo_url = USER_INFO_URL + "?access_token=" + accessTokenMap.get("access_token"); //通过token获得用户信息
-            Map<String, String> resultMap = JsonUtil.parseHashMap(HttpClientUtils.doGet(userinfo_url));
-            AuthUserVO authUserVO = new AuthUserVO();
-            authUserVO.setSocialId(String.valueOf(resultMap.get("id")));
-            authUserVO.setAvatar(resultMap.get("avatar_url"));
-            authUserVO.setName(resultMap.get("login"));
-            return authUserVO;
-        }
-        return null;
-    }
-}

+ 0 - 32
src/main/java/com/nosum/common/context/BeanTool.java

@@ -18,38 +18,6 @@ public class BeanTool implements ApplicationContextAware {
         BeanTool.applicationContext = applicationContext;
     }
 
-    public static ApplicationContext getApplicationContext() {
-        return applicationContext;
-    }
-
-    /**
-     * 获取当前服务(应用)名称
-     * @return
-     */
-    public static String getApplicationName() {
-        return getProperty("spring.application.name");
-    }
-
-    /**
-     * 根据Bean名称获取 Bean对象
-     * @param
-     * @return
-     */
-    public static Object getBean(String beanName) {
-        return applicationContext.getBean(beanName);
-    }
-
-    /**
-     * 根据Bean名称获取 Bean对象
-     * @param beanName
-     * @param clazz
-     * @param <T>
-     * @return
-     */
-    public static <T> T getBean(String beanName, Class<T> clazz) {
-        return applicationContext.getBean(beanName, clazz);
-    }
-
     /**
      * 根据Class获取 Bean对象
      * @param

+ 0 - 47
src/main/java/com/nosum/common/util/DateUtil.java

@@ -1,47 +0,0 @@
-package com.nosum.common.util;
-
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-
-public class DateUtil {
-
-    public static final LocalTime MAX = LocalTime.of(23,59,59);
-
-    /**
-     * 将LocalDateTime转为自定义的时间格式的字符串
-     */
-    public static String getDateTimeAsString(LocalDateTime localDateTime, String format) {
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
-        return localDateTime.format(formatter);
-    }
-
-
-    /**
-     * 将long类型的timestamp转为LocalDateTime
-     */
-    public static LocalDateTime getDateTimeOfTimestamp(long timestamp) {
-        Instant instant = Instant.ofEpochMilli(timestamp);
-        ZoneId zone = ZoneId.systemDefault();
-        return LocalDateTime.ofInstant(instant, zone);
-    }
-
-    /**
-     * 将LocalDateTime转为long类型的timestamp
-     */
-    public static long getTimestampOfDateTime(LocalDateTime localDateTime) {
-        ZoneId zone = ZoneId.systemDefault();
-        Instant instant = localDateTime.atZone(zone).toInstant();
-        return instant.toEpochMilli();
-    }
-
-    /**
-     * 将某时间字符串转为自定义时间格式的LocalDateTime
-     */
-    public static LocalDateTime parseStringToDateTime(String time, String format) {
-        DateTimeFormatter df = DateTimeFormatter.ofPattern(format);
-        return LocalDateTime.parse(time, df);
-    }
-}

+ 0 - 115
src/main/java/com/nosum/common/util/ErrorMessageUtil.java

@@ -1,115 +0,0 @@
-package com.nosum.common.util;
-
-import com.nosum.common.constant.Constants;
-import com.nosum.common.enums.SystemLanguageEnum;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.core.io.support.PropertiesLoaderUtils;
-import org.springframework.util.CollectionUtils;
-
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * @Description: 异常提示工具类
- * @Author: sumbytes
- * @Date: 2019/2/14 11:55
- */
-public class ErrorMessageUtil {
-
-    /**
-     * 根据错误提示码,获取对应错误提示信息(中文)
-     * @param errorCode
-     * @return
-     */
-    public static String getErrorMessage(String errorCode) {
-        return ErrorMessage.getErrorMessage(errorCode, SystemLanguageEnum.ZH.getCode());
-    }
-
-    /**
-     * 根据错误提示码、语言获取对应错误提示信息
-     * 注意:language 传入空时,按照中文处理
-     * @param errorCode
-     * @param language
-     * @return
-     */
-    public static String getErrorMessage(String errorCode, String language) {
-        return ErrorMessage.getErrorMessage(errorCode, language);
-    }
-
-    /**
-     * 内部类,用于初始化错误提示信息
-     */
-    private static final class ErrorMessage {
-
-        private static final Map<String, Map<String, String>> ERROR_MESSAGE_MAP = new HashMap<>();
-
-        static {
-            try {
-
-                // 初始化需要使用的编码
-                Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
-                Charset UTF_8 = Charset.forName("UTF-8");
-
-                // 循环系统支持语言
-                for (SystemLanguageEnum lang : SystemLanguageEnum.values()) {
-
-                    // 获取对应语言的资源文件路径
-                    List<String> resourcePathList = getResourcesPath(lang.getCode());
-
-                    // 初始化当前语言对应的提示信息容器
-                    Map<String, String> errorMessageMap = new HashMap<>();
-
-                    // 遍历循环资源文件,读取错误提示信息
-                    for (String resourcePath : resourcePathList) {
-                        Properties properties = PropertiesLoaderUtils.loadAllProperties(resourcePath);
-                        properties.forEach((key, value) -> {
-                            errorMessageMap.put(new String(((String) key).getBytes(ISO_8859_1), UTF_8), new String(((String) value).getBytes(ISO_8859_1), UTF_8));
-                        });
-                    }
-
-                    // 缓存当前语言对应的错误提示信息
-                    ERROR_MESSAGE_MAP.put(lang.getCode(), errorMessageMap);
-                }
-            } catch (Exception e) {
-            }
-        }
-
-        /**
-         * 获取内部错误提示信息
-         * @param errorCode
-         * @param language
-         * @return
-         */
-        private static final String getErrorMessage(String errorCode, String language) {
-            language = StringUtils.isBlank(language) ? SystemLanguageEnum.ZH.getCode() : language;
-            Map<String, String> errorMessageMap = ERROR_MESSAGE_MAP.get(language);
-            return CollectionUtils.isEmpty(errorMessageMap) ? null : errorMessageMap.get(errorCode);
-        }
-
-        /**
-         * 根据规则获取错误提示资源文件路径
-         * 注意:目前没有做外置化配置,亦不支持用户自定义;后续有需要则提供代码配置接口
-         * @return
-         */
-        private static final List<String> getResourcesPath(String lang) {
-
-            String[] parentPathArr = new String[]{"resource"};
-            String[] fileNameArr = new String[]{"error-message"};
-            String[] fileNameSuffixArr = new String[]{".properties"};
-
-            List<String> resourcePath = new ArrayList<>();
-            for (String path : parentPathArr) {
-                for (String fileName : fileNameArr) {
-                    for (String suffix : fileNameSuffixArr) {
-                        resourcePath.add(path + Constants.PATH_SEPARATOR + fileName + "-" + lang + suffix);
-                    }
-                }
-            }
-            return resourcePath;
-        }
-    }
-}

+ 0 - 38
src/main/java/com/nosum/common/util/ExceptionUtil.java

@@ -1,10 +1,7 @@
 package com.nosum.common.util;
 
-import com.nosum.common.base.domain.Result;
-import com.nosum.common.constant.ResultConstants;
 import com.nosum.common.enums.ErrorEnum;
 import com.nosum.common.exception.BusinessException;
-import org.apache.commons.lang3.StringUtils;
 
 /**
  * @Author:sumbytes
@@ -12,41 +9,6 @@ import org.apache.commons.lang3.StringUtils;
  */
 public class ExceptionUtil {
 
-    /**
-     * 业务回滚,抛出特定异常:包含错误消息
-     */
-    public static void rollback(String message) {
-        throw new BusinessException(message);
-    }
-
-    /**
-     * 业务回滚,抛出特定异常:包含错误消息,错误编码
-     */
-    public static void rollback(String message, String code) {
-        throw new BusinessException(message, code);
-    }
-
-    /**
-     * 业务回滚,抛出特定异常:包含错误消息,错误原因
-     */
-    public static void rollback(String message, Throwable cause) {
-        throw new BusinessException(message, cause);
-    }
-
-    /**
-     * 业务回滚,抛出特定异常:包含错误消息,错误编码,错误原因
-     */
-    public static void rollback(String message, String code, Throwable cause) {
-        throw new BusinessException(message, code, cause);
-    }
-
-    /**
-     * 业务不需回滚,设置result返回
-     */
-    public static Result setResult(String message) {
-        return Result.createWithErrorMessage(StringUtils.isBlank(message) ? ResultConstants.ERROR_MESSAGE : message, ResultConstants.OPERATION_FAIL);
-    }
-
     public static void rollback(ErrorEnum errorEnum) {
         throw new BusinessException(errorEnum);
     }

+ 0 - 1
src/main/java/com/nosum/common/util/FileUtil.java

@@ -11,7 +11,6 @@ import java.util.UUID;
  */
 public class FileUtil {
 
-
     /**
      * 获取文件后缀名
      */

+ 0 - 135
src/main/java/com/nosum/common/util/HttpClientDownloader.java

@@ -1,135 +0,0 @@
-package com.nosum.common.util;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.util.EntityUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import us.codecraft.webmagic.Page;
-import us.codecraft.webmagic.Request;
-import us.codecraft.webmagic.Site;
-import us.codecraft.webmagic.Task;
-import us.codecraft.webmagic.downloader.AbstractDownloader;
-import us.codecraft.webmagic.downloader.HttpClientRequestContext;
-import us.codecraft.webmagic.downloader.HttpUriRequestConverter;
-import us.codecraft.webmagic.proxy.Proxy;
-import us.codecraft.webmagic.proxy.ProxyProvider;
-import us.codecraft.webmagic.selector.PlainText;
-import us.codecraft.webmagic.utils.CharsetUtils;
-import us.codecraft.webmagic.utils.HttpClientUtils;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author: sumbytes
- * @date: 2019/8/3 14:57
- */
-public class HttpClientDownloader extends AbstractDownloader {
-    private final Map<String, CloseableHttpClient> httpClients = new HashMap<>();
-    private Logger logger = LoggerFactory.getLogger(getClass());
-    private HttpClientGenerator httpClientGenerator = new HttpClientGenerator();
-
-    private HttpUriRequestConverter httpUriRequestConverter = new HttpUriRequestConverter();
-
-    private ProxyProvider proxyProvider;
-
-    private boolean responseHeader = true;
-
-    public void setHttpUriRequestConverter(HttpUriRequestConverter httpUriRequestConverter) {
-        this.httpUriRequestConverter = httpUriRequestConverter;
-    }
-
-    public void setProxyProvider(ProxyProvider proxyProvider) {
-        this.proxyProvider = proxyProvider;
-    }
-
-    private CloseableHttpClient getHttpClient(Site site) {
-        if (site == null) {
-            return httpClientGenerator.getClient(null);
-        }
-        String domain = site.getDomain();
-        CloseableHttpClient httpClient = httpClients.get(domain);
-        if (httpClient == null) {
-            synchronized (this) {
-                httpClient = httpClients.get(domain);
-                if (httpClient == null) {
-                    httpClient = httpClientGenerator.getClient(site);
-                    httpClients.put(domain, httpClient);
-                }
-            }
-        }
-        return httpClient;
-    }
-
-    @Override
-    public Page download(Request request, Task task) {
-        if (task == null || task.getSite() == null) {
-            throw new NullPointerException("task or site can not be null");
-        }
-        CloseableHttpResponse httpResponse = null;
-        CloseableHttpClient httpClient = getHttpClient(task.getSite());
-        Proxy proxy = proxyProvider != null ? proxyProvider.getProxy(task) : null;
-        HttpClientRequestContext requestContext = httpUriRequestConverter.convert(request, task.getSite(), proxy);
-        Page page = Page.fail();
-        try {
-            httpResponse = httpClient.execute(requestContext.getHttpUriRequest(), requestContext.getHttpClientContext());
-            page = handleResponse(request, request.getCharset() != null ? request.getCharset() : task.getSite().getCharset(), httpResponse, task);
-            onSuccess(request);
-            logger.info("downloading page success {}", request.getUrl());
-            return page;
-        } catch (IOException e) {
-            logger.warn("download page {} error", request.getUrl(), e);
-            onError(request);
-            return page;
-        } finally {
-            if (httpResponse != null) {
-                //ensure the connection is released back to pool
-                EntityUtils.consumeQuietly(httpResponse.getEntity());
-            }
-            if (proxyProvider != null && proxy != null) {
-                proxyProvider.returnProxy(proxy, page, task);
-            }
-        }
-    }
-
-    @Override
-    public void setThread(int thread) {
-        httpClientGenerator.setPoolSize(thread);
-    }
-
-    protected Page handleResponse(Request request, String charset, HttpResponse httpResponse, Task task) throws IOException {
-        byte[] bytes = IOUtils.toByteArray(httpResponse.getEntity().getContent());
-        String contentType = httpResponse.getEntity().getContentType() == null ? "" : httpResponse.getEntity().getContentType().getValue();
-        Page page = new Page();
-        page.setBytes(bytes);
-        if (!request.isBinaryContent()) {
-            if (charset == null) {
-                charset = getHtmlCharset(contentType, bytes);
-            }
-            page.setCharset(charset);
-            page.setRawText(new String(bytes, charset));
-        }
-        page.setUrl(new PlainText(request.getUrl()));
-        page.setRequest(request);
-        page.setStatusCode(httpResponse.getStatusLine().getStatusCode());
-        page.setDownloadSuccess(true);
-        if (responseHeader) {
-            page.setHeaders(HttpClientUtils.convertHeaders(httpResponse.getAllHeaders()));
-        }
-        return page;
-    }
-
-    private String getHtmlCharset(String contentType, byte[] contentBytes) throws IOException {
-        String charset = CharsetUtils.detectCharset(contentType, contentBytes);
-        if (charset == null) {
-            charset = Charset.defaultCharset().name();
-            logger.warn("Charset autodetect failed, use {} as charset. Please specify charset in Site.setCharset()", Charset.defaultCharset());
-        }
-        return charset;
-    }
-}

+ 0 - 158
src/main/java/com/nosum/common/util/HttpClientGenerator.java

@@ -1,158 +0,0 @@
-package com.nosum.common.util;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.client.CookieStore;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.config.SocketConfig;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainConnectionSocketFactory;
-import org.apache.http.conn.ssl.DefaultHostnameVerifier;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.impl.client.BasicCookieStore;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.impl.cookie.BasicClientCookie;
-import org.apache.http.protocol.HttpContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import us.codecraft.webmagic.Site;
-import us.codecraft.webmagic.downloader.CustomRedirectStrategy;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-import java.io.IOException;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.Map;
-
-/**
- * @author: sumbytes
- * @date: 2019/8/3 14:57
- * @modified:
- */
-public class HttpClientGenerator {
-    private transient Logger logger = LoggerFactory.getLogger(getClass());
-
-    private PoolingHttpClientConnectionManager connectionManager;
-
-    public HttpClientGenerator() {
-        Registry<ConnectionSocketFactory> reg = RegistryBuilder.<ConnectionSocketFactory>create()
-                .register("http", PlainConnectionSocketFactory.INSTANCE)
-                .register("https", buildSSLConnectionSocketFactory())
-                .build();
-        connectionManager = new PoolingHttpClientConnectionManager(reg);
-        connectionManager.setDefaultMaxPerRoute(100);
-    }
-
-    private SSLConnectionSocketFactory buildSSLConnectionSocketFactory() {
-        try {
-            return new SSLConnectionSocketFactory(createIgnoreVerifySSL(), new String[]{"SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"},
-                    null,
-                    new DefaultHostnameVerifier()); // 优先绕过安全证书
-        } catch (KeyManagementException e) {
-            logger.error("ssl connection fail", e);
-        } catch (NoSuchAlgorithmException e) {
-            logger.error("ssl connection fail", e);
-        }
-        return SSLConnectionSocketFactory.getSocketFactory();
-    }
-
-    private SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
-        // 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
-        X509TrustManager trustManager = new X509TrustManager() {
-
-            @Override
-            public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
-            }
-
-            @Override
-            public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
-            }
-
-            @Override
-            public X509Certificate[] getAcceptedIssuers() {
-                return null;
-            }
-
-        };
-
-        SSLContext sc = SSLContext.getInstance("SSLv3");
-        sc.init(null, new TrustManager[]{trustManager}, null);
-        return sc;
-    }
-
-    public HttpClientGenerator setPoolSize(int poolSize) {
-        connectionManager.setMaxTotal(poolSize);
-        return this;
-    }
-
-    public CloseableHttpClient getClient(Site site) {
-        return generateClient(site);
-    }
-
-    private CloseableHttpClient generateClient(Site site) {
-        HttpClientBuilder httpClientBuilder = HttpClients.custom();
-
-        httpClientBuilder.setConnectionManager(connectionManager);
-        if (site.getUserAgent() != null) {
-            httpClientBuilder.setUserAgent(site.getUserAgent());
-        } else {
-            httpClientBuilder.setUserAgent("");
-        }
-        if (site.isUseGzip()) {
-            httpClientBuilder.addInterceptorFirst(new HttpRequestInterceptor() {
-
-                @Override
-                public void process(
-                        HttpRequest request,
-                        HttpContext context) throws HttpException, IOException {
-                    if (!request.containsHeader("Accept-Encoding")) {
-                        request.addHeader("Accept-Encoding", "gzip");
-                    }
-                }
-            });
-        }
-        //解决post/redirect/post 302跳转问题
-        httpClientBuilder.setRedirectStrategy(new CustomRedirectStrategy());
-
-        SocketConfig.Builder socketConfigBuilder = SocketConfig.custom();
-        socketConfigBuilder.setSoKeepAlive(true).setTcpNoDelay(true);
-        socketConfigBuilder.setSoTimeout(site.getTimeOut());
-        SocketConfig socketConfig = socketConfigBuilder.build();
-        httpClientBuilder.setDefaultSocketConfig(socketConfig);
-        connectionManager.setDefaultSocketConfig(socketConfig);
-        httpClientBuilder.setRetryHandler(new DefaultHttpRequestRetryHandler(site.getRetryTimes(), true));
-        generateCookie(httpClientBuilder, site);
-        return httpClientBuilder.build();
-    }
-
-    private void generateCookie(HttpClientBuilder httpClientBuilder, Site site) {
-        if (site.isDisableCookieManagement()) {
-            httpClientBuilder.disableCookieManagement();
-            return;
-        }
-        CookieStore cookieStore = new BasicCookieStore();
-        for (Map.Entry<String, String> cookieEntry : site.getCookies().entrySet()) {
-            BasicClientCookie cookie = new BasicClientCookie(cookieEntry.getKey(), cookieEntry.getValue());
-            cookie.setDomain(site.getDomain());
-            cookieStore.addCookie(cookie);
-        }
-        for (Map.Entry<String, Map<String, String>> domainEntry : site.getAllCookies().entrySet()) {
-            for (Map.Entry<String, String> cookieEntry : domainEntry.getValue().entrySet()) {
-                BasicClientCookie cookie = new BasicClientCookie(cookieEntry.getKey(), cookieEntry.getValue());
-                cookie.setDomain(domainEntry.getKey());
-                cookieStore.addCookie(cookie);
-            }
-        }
-        httpClientBuilder.setDefaultCookieStore(cookieStore);
-    }
-}

+ 0 - 78
src/main/java/com/nosum/common/util/HttpClientUtils.java

@@ -1,78 +0,0 @@
-package com.nosum.common.util;
-
-import com.alibaba.fastjson.JSONObject;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 请求工具类
- */
-public class HttpClientUtils {
-
-    /**
-     * 发送get请求,利用java代码发送请求
-     */
-    public static String doGet(String url) {
-        try {
-            CloseableHttpClient httpclient = HttpClients.createDefault();
-            HttpGet httpGet = new HttpGet(url);
-            // 发送了一个http请求
-            CloseableHttpResponse response = httpclient.execute(httpGet);
-            // 如果响应200成功,解析响应结果
-            if (response.getStatusLine().getStatusCode() == 200) {
-                // 获取响应的内容
-                HttpEntity responseEntity = response.getEntity();
-                return EntityUtils.toString(responseEntity);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-
-    }
-
-    /**
-     * 将字符串转换成map
-     */
-    public static Map<String, String> getMap(String responseEntity) {
-
-        Map<String, String> map = new HashMap<>();
-        // 以&来解析字符串
-        String[] result = responseEntity.split("\\&");
-
-        for (String str : result) {
-            // 以=来解析字符串
-            String[] split = str.split("=");
-            // 将字符串存入map中
-            if (split.length == 1) {
-                map.put(split[0], null);
-            } else {
-                map.put(split[0], split[1]);
-            }
-
-        }
-        return map;
-    }
-
-    /**
-     * 通过json获得map
-     */
-    public static Map<String, String> getMapByJson(String responseEntity) {
-        Map<String, String> map = new HashMap<>();
-        JSONObject jsonObject = JSONObject.parseObject(responseEntity);
-        for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
-            String key = entry.getKey();
-            // 将obj转换成string
-            String value = String.valueOf(entry.getValue());
-            map.put(key, value);
-        }
-        return map;
-    }
-}
-

+ 0 - 96
src/main/java/com/nosum/common/util/HttpContextUtils.java

@@ -1,96 +0,0 @@
-package com.nosum.common.util;
-
-import eu.bitwalker.useragentutils.Browser;
-import eu.bitwalker.useragentutils.OperatingSystem;
-import eu.bitwalker.useragentutils.UserAgent;
-import eu.bitwalker.useragentutils.Version;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
-
-import javax.servlet.http.HttpServletRequest;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-public class HttpContextUtils {
-	public static HttpServletRequest getHttpServletRequest() {
-		return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
-	}
-
-	/**
-	 * 获取当前网络ip
-	 */
-	public static String getIpAddr(HttpServletRequest request){
-		String ipAddress = request.getHeader("x-forwarded-for");
-		if(ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
-			ipAddress = request.getHeader("Proxy-Client-IP");
-		}
-		if(ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
-			ipAddress = request.getHeader("WL-Proxy-Client-IP");
-		}
-		if(ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
-			ipAddress = request.getRemoteAddr();
-			if(ipAddress.equals("127.0.0.1") || ipAddress.equals("0:0:0:0:0:0:0:1")){
-				//根据网卡取本机配置的IP
-				InetAddress inet=null;
-				try {
-					inet = InetAddress.getLocalHost();
-				} catch (UnknownHostException e) {
-					e.printStackTrace();
-				}
-				ipAddress= inet.getHostAddress();
-			}
-		}
-		//对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
-		if(ipAddress!=null && ipAddress.length()>15){ //"***.***.***.***".length() = 15
-			if(ipAddress.indexOf(",")>0){
-				ipAddress = ipAddress.substring(0,ipAddress.indexOf(","));
-			}
-		}
-		return ipAddress;
-	}
-
-	/**
-	 * 获取发起请求的浏览器名称
-	 */
-	public static String getBrowserName(HttpServletRequest request) {
-		try{
-			String header = request.getHeader("User-Agent");
-			UserAgent userAgent = UserAgent.parseUserAgentString(header);
-			Browser browser = userAgent.getBrowser();
-			return browser.getName();
-		}catch (Exception e){
-			return "not found name";
-		}
-	}
-
-	/**
-	 * 获取发起请求的浏览器版本号
-	 */
-	public static String getBrowserVersion(HttpServletRequest request) {
-		try{
-			String header = request.getHeader("User-Agent");
-			UserAgent userAgent = UserAgent.parseUserAgentString(header);
-			Browser browser = userAgent.getBrowser();// 获取浏览器信息
-			Version version = browser.getVersion(header);// 获取浏览器版本号
-			return version.getVersion();
-		}catch (Exception e){
-			return "not found version";
-		}
-
-	}
-
-	/**
-	 * 获取发起请求的操作系统名称
-	 */
-	public static String getOsName(HttpServletRequest request) {
-		try{
-			String header = request.getHeader("User-Agent");
-			UserAgent userAgent = UserAgent.parseUserAgentString(header);
-			OperatingSystem operatingSystem = userAgent.getOperatingSystem();
-			return operatingSystem.getName();
-		}catch (Exception e){
-			return "not found osName";
-		}
-
-	}
-}

+ 0 - 35
src/main/java/com/nosum/common/util/Markdown2HtmlUtil.java

@@ -1,35 +0,0 @@
-package com.nosum.common.util;
-
-import com.vladsch.flexmark.Extension;
-import com.vladsch.flexmark.ast.Node;
-import com.vladsch.flexmark.ext.tables.TablesExtension;
-import com.vladsch.flexmark.html.HtmlRenderer;
-import com.vladsch.flexmark.parser.Parser;
-import com.vladsch.flexmark.parser.ParserEmulationProfile;
-import com.vladsch.flexmark.util.options.MutableDataSet;
-
-import java.util.Arrays;
-
-/**
- * @author: sumbytes
- * @date: 2019/8/3 14:57
- */
-public class Markdown2HtmlUtil {
-
-    /**
-     * Markdownz转为Html
-     * @param content
-     * @return
-     */
-    public static String html(String content){
-
-        MutableDataSet options = new MutableDataSet();
-        options.setFrom(ParserEmulationProfile.MARKDOWN);
-        options.set(Parser.EXTENSIONS, Arrays.asList(new Extension[]{TablesExtension.create()}));
-        Parser parser = Parser.builder(options).build();
-        HtmlRenderer renderer = HtmlRenderer.builder(options).build();
-        Node document = parser.parse(content);
-
-        return renderer.render(document);
-    }
-}

+ 0 - 35
src/main/java/com/nosum/common/util/PageUtil.java

@@ -1,35 +0,0 @@
-package com.nosum.common.util;
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.nosum.common.base.domain.PageInfo;
-import com.nosum.common.base.domain.vo.BaseVO;
-import com.nosum.common.constant.Constants;
-
-/**
- * @author: sumbytes
- * @date: 2019/8/3 14:57
- */
-public class PageUtil {
-
-    public static Page checkAndInitPage(BaseVO baseVO) {
-        if (baseVO.getPage() == null) {
-             baseVO.setPage(Constants.DEFAULT_PAGE_INDEX);
-        }
-        if (baseVO.getSize() == null){
-            baseVO.setSize(Constants.DEFAULT_PAGE_SIZE);
-        }
-
-        return new Page(baseVO.getPage(), baseVO.getSize());
-    }
-
-    public static Page initPage() {
-        return new Page(Constants.DEFAULT_PAGE_INDEX, Constants.DEFAULT_PAGE_SIZE);
-    }
-
-    public static PageInfo initPageInfo(Page page) {
-        if (page != null) {
-            return new PageInfo().setPage(page.getCurrent()).setSize(page.getSize()).setTotal(page.getTotal());
-        }
-        return null;
-    }
-}

+ 0 - 72
src/main/java/com/nosum/common/util/PreviewTextUtils.java

@@ -1,72 +0,0 @@
-/*
-+--------------------------------------------------------------------------
-|   Mtons [#RELEASE_VERSION#]
-|   ========================================
-|   Copyright (c) 2014, 2015 mtons. All Rights Reserved
-|   http://www.mtons.com
-+---------------------------------------------------------------------------
-*/
-package com.nosum.common.util;
-
-import org.apache.commons.lang3.StringUtils;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.safety.Whitelist;
-
-/**
- * @author: sumbytes
- * @date: 2019/8/3 14:57
- */
-public class PreviewTextUtils {
-    /**
-     * 提取纯文本
-     * @param html 代码
-     * @return string
-     */
-    public static String getText(String html) {
-        if (html == null) {
-            return null;
-        }
-        return Jsoup.clean(html, Whitelist.none()).trim();
-    }
-
-    /**
-     * 提取纯文本
-     * @param html 代码
-     * @param length 提取文本长度
-     * @return string
-     */
-    public static String getText(String html, int length){
-        String text = getText(html);
-        text = StringUtils.abbreviate(text, length);
-        return text;
-    }
-
-    /**
-     * 以下标签可以通过 (b, em, i, strong, u. 纯文本)
-     * @param html 代码
-     * @return string
-     */
-    public static String getSimpleHtml(String html) {
-        if (html == null) {
-            return null;
-        }
-        return Jsoup.clean(html, Whitelist.simpleText());
-    }
-
-    /**
-     * 获取文章中的img url
-     * @param html 代码
-     * @return string
-     */
-    public static String getImgSrc(String html) {
-        if (html == null) {
-            return null;
-        }
-        Document doc = Jsoup.parseBodyFragment(html);
-        Element image = doc.select("img").first();
-        return image == null ? null : image.attr("src");
-    }
-
-}

+ 15 - 19
src/main/java/com/nosum/common/util/SessionUtil.java

@@ -5,42 +5,40 @@ import com.auth0.jwt.JWTVerifier;
 import com.auth0.jwt.algorithms.Algorithm;
 import com.auth0.jwt.exceptions.JWTDecodeException;
 import com.auth0.jwt.exceptions.JWTVerificationException;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.nosum.common.base.domain.vo.UserSessionVO;
 import com.nosum.common.constant.Constants;
 import com.nosum.common.context.BeanTool;
 import com.nosum.common.enums.ErrorEnum;
-import com.nosum.deliver.auth.dao.AuthTokenDao;
-import com.nosum.deliver.auth.dao.AuthUserDao;
 import com.nosum.deliver.auth.domain.po.AuthToken;
 import com.nosum.deliver.auth.domain.po.AuthUser;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 
 import javax.servlet.http.HttpServletRequest;
 import java.time.LocalDateTime;
-import java.util.Optional;
+import java.util.Objects;
 
 /**
- * @Author:sumbytes
- * @Date:2018/09/27 12:52
+ * 会话工具类.
+ *
+ * @author Young
  */
 public class SessionUtil {
 
     /**
      * 获取用户Session信息
      *
-     * @return
+     * @return 用户 Session 信息
      */
     public static UserSessionVO getUserSessionInfo() {
-
         // 获取请求对象
-        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
-
+        HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
         // 获取请求头Token值
-        String token = Optional.ofNullable(request.getHeader(Constants.AUTHENTICATION)).orElse(null);
-
+        String token = request.getHeader(Constants.AUTHENTICATION);
         if (StringUtils.isBlank(token)) {
             return null;
         }
@@ -49,12 +47,12 @@ public class SessionUtil {
         AuthUser authUser = null;
         try {
             authUser = JsonUtil.parseObject(JWT.decode(token).getAudience().get(0), AuthUser.class);
-        } catch (JWTDecodeException j) {
+        } catch (JWTDecodeException e) {
             ExceptionUtil.rollback(ErrorEnum.INVALID_TOKEN);
         }
 
-        AuthUserDao userDao = BeanTool.getBean(AuthUserDao.class);
-        AuthUser user = userDao.selectById(authUser.getId());
+        MongoTemplate mongoTemplate = BeanTool.getBean(MongoTemplate.class);
+        AuthUser user = mongoTemplate.findById(authUser.getId(), AuthUser.class);
         if (user == null) {
             ExceptionUtil.rollback(ErrorEnum.LOGIN_ERROR);
         }
@@ -67,10 +65,8 @@ public class SessionUtil {
             ExceptionUtil.rollback(ErrorEnum.INVALID_TOKEN);
         }
 
-        AuthTokenDao authTokenDao = BeanTool.getBean(AuthTokenDao.class);
-        Integer count = authTokenDao.selectCount(new LambdaQueryWrapper<AuthToken>().eq(AuthToken::getToken, token).eq(AuthToken::getUserId, user.getId()).ge(AuthToken::getExpireTime,
-                LocalDateTime.now()));
-        if (count.equals(Constants.ZERO)) {
+        long count = mongoTemplate.count(Query.query(Criteria.where("token").is(token).and("userId").is(user.getId()).and("expireTime").gte(LocalDateTime.now())), AuthToken.class);
+        if (count == 0) {
             ExceptionUtil.rollback(ErrorEnum.INVALID_TOKEN);
         }
 

+ 0 - 48
src/main/java/com/nosum/common/util/ThrowableUtils.java

@@ -1,48 +0,0 @@
-package com.nosum.common.util;
-
-import cn.hutool.core.collection.CollectionUtil;
-import com.nosum.common.constant.Constants;
-import com.nosum.common.exception.ApiInvalidParamException;
-import org.springframework.validation.BindingResult;
-import org.springframework.validation.FieldError;
-
-import java.util.List;
-import java.util.Objects;
-
-/**
- * @author Andy Chen
- * @date 9/30/19 1:30 PM
- */
-public class ThrowableUtils {
-    /**
-     * 校验参数正确,拼装字段名和值到错误信息
-     * @param result
-     */
-    public static void checkParamArgument(BindingResult result) {
-        if (result != null && result.hasErrors()) {
-            StringBuilder sb = new StringBuilder();
-            List<FieldError> errors = result.getFieldErrors();
-            if(CollectionUtil.isNotEmpty(errors)){
-                FieldError error = errors.get(0);
-                String rejectedValue = Objects.toString(error.getRejectedValue(), "");
-                String defMsg = error.getDefaultMessage();
-                // 排除类上面的注解提示
-                if(rejectedValue.contains(Constants.DELIMITER_TO)){
-                    // 自己去确定错误字段
-                    sb.append(defMsg);
-                }else{
-                    if(Constants.DELIMITER_COLON.contains(defMsg)){
-                        sb.append(error.getField()).append(" ").append(defMsg);
-                    }else{
-                        sb.append(error.getField()).append(" ").append(defMsg).append(":").append(rejectedValue);
-                    }
-                }
-            } else {
-                String msg = result.getAllErrors().get(0).getDefaultMessage();
-                sb.append(msg);
-            }
-            throw new ApiInvalidParamException(sb.toString());
-        }
-
-    }
-}

+ 0 - 14
src/main/java/com/nosum/common/util/ToolUtil.java

@@ -1,14 +0,0 @@
-package com.nosum.common.util;
-
-public class ToolUtil {
-    public static Integer getInteger(Object obj){
-        try{
-            if (obj==null){
-                return 0;
-            }
-            return Integer.parseInt(obj.toString());
-        }catch (Exception e){
-            return 0;
-        }
-    }
-}

+ 0 - 30
src/main/java/com/nosum/deliver/auth/controller/AuthUserController.java

@@ -30,36 +30,6 @@ public class AuthUserController {
         return authUserService.getUserInfo(authUserVO);
     }
 
-
-    @Explain("删除用户")
-    @DeleteMapping("/user/v1/{id}")
-    @LoginRequired(role = RoleEnum.ADMIN)
-    public Result deleteUser(@PathVariable Long id) {
-        return authUserService.deleteUsers(id);
-    }
-
-    @Explain("更新用户状态")
-    @LoginRequired(role = RoleEnum.ADMIN)
-    @PutMapping("/status/v1/update")
-    public Result saveAuthUserStatus(@RequestBody AuthUserVO authUserVO) {
-        return authUserService.saveAuthUserStatus(authUserVO);
-    }
-
-    @Explain("获取用户列表")
-    @LoginRequired
-    @GetMapping("/user/v1/list")
-    public Result getUserList(AuthUserVO authUserVO) {
-        return authUserService.getUserList(authUserVO);
-    }
-
-
-    @Explain("更新用户信息")
-    @LoginRequired
-    @PutMapping("/user/v1/update")
-    public Result updateUser(@RequestBody AuthUserVO authUserVO) {
-        return authUserService.updateUser(authUserVO);
-    }
-
     @Explain("退出登录")
     @PostMapping("/auth/v1/logout")
     public Result logout() {

+ 0 - 12
src/main/java/com/nosum/deliver/auth/dao/AuthTokenDao.java

@@ -1,12 +0,0 @@
-package com.nosum.deliver.auth.dao;
-
-import com.nosum.deliver.auth.domain.po.AuthToken;
-import com.nosum.common.base.dao.BaseDao;
-
-/**
- * @author sumbytes
- * @since 2019-09-18
- */
-public interface AuthTokenDao extends BaseDao<AuthToken> {
-
-}

+ 0 - 20
src/main/java/com/nosum/deliver/auth/dao/AuthUserDao.java

@@ -1,20 +0,0 @@
-package com.nosum.deliver.auth.dao;
-
-import com.nosum.deliver.auth.domain.po.AuthUser;
-import com.nosum.common.base.dao.BaseDao;
-
-/**
- * <p>
- *  Mapper 接口
- * </p>
- *
- * @author sumbytes
- * @since 2019-08-28
- */
-public interface AuthUserDao extends BaseDao<AuthUser> {
-
-    String selectAvatar();
-
-    AuthUser selectAdmin();
-
-}

+ 0 - 22
src/main/java/com/nosum/deliver/auth/dao/AuthUserSocialDao.java

@@ -1,22 +0,0 @@
-package com.nosum.deliver.auth.dao;
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.nosum.deliver.auth.domain.po.AuthUserSocial;
-import com.nosum.deliver.auth.domain.vo.AuthUserSocialVO;
-import com.nosum.common.base.dao.BaseDao;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-
-/**
- * 用户表社交信息表:数据层
- * @author generator
- * @date 2020-01-01 17:34:27
- * @since 1.0
- */
-public interface AuthUserSocialDao extends BaseDao<AuthUserSocial> {
-
-    List<AuthUserSocialVO> selectSocialList(@Param("page") Page<AuthUserSocial> page, @Param("condition") AuthUserSocialVO authUserSocialVO);
-
-}

+ 9 - 18
src/main/java/com/nosum/deliver/auth/domain/po/AuthToken.java

@@ -1,12 +1,10 @@
 package com.nosum.deliver.auth.domain.po;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.bson.types.ObjectId;
+import org.springframework.data.annotation.Id;
 
 import java.io.Serializable;
 import java.time.LocalDateTime;
@@ -18,13 +16,12 @@ import java.time.LocalDateTime;
 @Data
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
-@TableName("auth_token")
-public class AuthToken extends Model<AuthToken> {
+public class AuthToken implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
+    @Id
+    private ObjectId id;
 
     /**
      * token
@@ -32,19 +29,13 @@ public class AuthToken extends Model<AuthToken> {
     private String token;
 
     /**
-     * 过期时间
+     * 创建人
      */
-    private LocalDateTime expireTime;
+    private ObjectId userId;
 
     /**
-     * 创建人
+     * 过期时间
      */
-    private Long userId;
-
-
-    @Override
-    protected Serializable pkVal() {
-        return this.id;
-    }
+    private LocalDateTime expireTime;
 
 }

+ 17 - 29
src/main/java/com/nosum/deliver/auth/domain/po/AuthUser.java

@@ -1,33 +1,31 @@
 package com.nosum.deliver.auth.domain.po;
 
-import com.baomidou.mybatisplus.annotation.*;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.bson.types.ObjectId;
+import org.springframework.data.annotation.Id;
 
 import java.io.Serializable;
 import java.time.LocalDateTime;
 
 /**
- * @author sumbytes
- * @since 2019-08-28
+ * 用户信息实体
+ *
+ * @author Young
  */
 @Data
-@EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
-@TableName("auth_user")
-public class AuthUser extends Model<AuthUser> {
+@EqualsAndHashCode(callSuper = false)
+public class AuthUser implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
     /**
      * 主键
      */
-    @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
-
-    private String socialId;
+    @Id
+    private ObjectId id;
 
     /**
      * 别名
@@ -45,22 +43,11 @@ public class AuthUser extends Model<AuthUser> {
     private String avatar;
 
     /**
-     * 注册时间
-     */
-    private LocalDateTime createTime;
-
-    /**
      * 密码
      */
     private String password;
 
     /**
-     * 个人介绍
-     */
-    @TableField(updateStrategy = FieldStrategy.IGNORED)
-    private String introduction;
-
-    /**
      * 用户状态 0 正常 1 锁定
      */
     private Integer status;
@@ -70,13 +57,14 @@ public class AuthUser extends Model<AuthUser> {
      */
     private String email;
 
-    private String accessKey;
-
-    private String secretKey;
+    /**
+     * 个人介绍
+     */
+    private String introduction;
 
-    @Override
-    protected Serializable pkVal() {
-        return id;
-    }
+    /**
+     * 注册时间
+     */
+    private LocalDateTime createTime;
 
 }

+ 0 - 88
src/main/java/com/nosum/deliver/auth/domain/po/AuthUserSocial.java

@@ -1,88 +0,0 @@
-package com.nosum.deliver.auth.domain.po;
-
-import java.io.Serializable;
-import java.time.LocalDateTime;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-/**
- * 用户表社交信息表 实体类
- * @author nosum
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-@TableName(value = "auth_user_social")
-public class AuthUserSocial extends Model<AuthUserSocial> {
-
-	private static final long serialVersionUID = 1L;
-
-    // columns START
-
-	@TableId(value = "id",type= IdType.AUTO)
-	private Long id;
-
-	/**
-	 * qq、csdn、wechat、weibo、email等
-	 */
-	private String code; 
-
-	/**
-	 * 内容
-	 */
-	@TableField(value = "content")
-	private String content;
-
-	/**
-	 * 展示类型( 1、图片,2、文本,3、链接)
-	 */
-	@TableField(value = "show_type")
-	private Integer showType;
-
-	/**
-	 * 备注
-	 */
-	private String remark;
-
-	/**
-	 * 图标
-	 */
-	private String icon;
-
-	/**
-	 * 是否启用
-	 */
-	@TableField(value = "is_enabled")
-	private Integer isEnabled;
-
-	/**
-	 * 是否主页社交信息
-	 */
-	@TableField(value = "is_home")
-	private Integer isHome;
-
-	/**
-	 * 创建时间
-	 */
-	@TableField(value = "create_time")
-	private LocalDateTime createTime;
-
-	/**
-	 * 更新时间
-	 */
-	@TableField(value = "update_time")
-	private LocalDateTime updateTime;
-	// columns END
-
-	@Override
-	protected Serializable pkVal() {
-		return id;
-	}
-}

+ 0 - 9
src/main/java/com/nosum/deliver/auth/domain/validator/InsertSocial.java

@@ -1,9 +0,0 @@
-package com.nosum.deliver.auth.domain.validator;
-
-import com.nosum.common.validator.group.Insert;
-
-import javax.validation.GroupSequence;
-
-@GroupSequence({Insert.class})
-public interface InsertSocial {
-}

+ 0 - 9
src/main/java/com/nosum/deliver/auth/domain/validator/UpdateSocial.java

@@ -1,9 +0,0 @@
-package com.nosum.deliver.auth.domain.validator;
-
-import com.nosum.common.validator.group.Update;
-
-import javax.validation.GroupSequence;
-
-@GroupSequence({Update.class})
-public interface UpdateSocial {
-}

+ 0 - 9
src/main/java/com/nosum/deliver/auth/domain/validator/UpdateUsers.java

@@ -1,9 +0,0 @@
-package com.nosum.deliver.auth.domain.validator;
-
-import com.nosum.common.validator.group.Update;
-
-import javax.validation.GroupSequence;
-
-@GroupSequence({Update.class})
-public interface UpdateUsers {
-}

+ 0 - 74
src/main/java/com/nosum/deliver/auth/domain/vo/AuthUserSocialVO.java

@@ -1,74 +0,0 @@
-package com.nosum.deliver.auth.domain.vo;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.nosum.deliver.auth.domain.validator.InsertSocial;
-import com.nosum.deliver.auth.domain.validator.UpdateSocial;
-import com.nosum.common.base.domain.vo.BaseVO;
-import com.nosum.common.validator.annotion.IntegerNotNull;
-import com.nosum.common.validator.annotion.NotBlank;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-import java.time.LocalDateTime;
-
-/**
- * 用户表社交信息表 实体类
- * @author nosum
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-@Accessors(chain = true)
-public class AuthUserSocialVO extends BaseVO<AuthUserSocialVO> {
-    // columns START
-	@IntegerNotNull(groups = {UpdateSocial.class})
-	private Long id;
-
-	/**
-	 * qq、csdn、wechat、weibo、email等
-	 */
-	@NotBlank(groups = {InsertSocial.class})
-	private String code;
-	/**
-	 * 内容
-	 */
-	@TableField(value = "content")
-	private String content;
-
-	/**
-	 * 展示类型( 1、显示二维码,2、显示账号,3、跳转链接)
-	 */
-	@TableField(value = "show_type")
-	private Integer showType;
-
-	/**
-	 * 备注
-	 */
-	private String remark;
-
-	private String icon;
-
-	/**
-	 * 是否删除
-	 */
-	@TableField(value = "is_enabled")
-	private Integer isEnabled;
-
-	/**
-	 * 是否主页社交信息
-	 */
-	@TableField(value = "is_home")
-	private Integer isHome;
-
-	/**
-	 * 创建时间
-	 */
-	@TableField(value = "create_time")
-	private LocalDateTime createTime;
-
-	/**
-	 * 更新时间
-	 */
-	@TableField(value = "update_time")
-	private LocalDateTime updateTime;
-	// columns END
-}

+ 4 - 8
src/main/java/com/nosum/deliver/auth/domain/vo/AuthUserVO.java

@@ -1,10 +1,10 @@
 package com.nosum.deliver.auth.domain.vo;
 
 import com.nosum.common.base.domain.vo.BaseVO;
-import com.nosum.common.validator.annotion.IntegerNotNull;
-import com.nosum.deliver.auth.domain.validator.UpdateUsers;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.bson.types.ObjectId;
 
 import java.time.LocalDateTime;
 import java.util.List;
@@ -15,13 +15,13 @@ import java.util.List;
  */
 @Data
 @Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
 public class AuthUserVO extends BaseVO<AuthUserVO> {
 
     /**
      * 主键
      */
-    @IntegerNotNull(groups = {UpdateUsers.class})
-    private Long id;
+    private ObjectId id;
 
     /**
      * 社交账户ID
@@ -70,8 +70,4 @@ public class AuthUserVO extends BaseVO<AuthUserVO> {
      */
     private String email;
 
-    private String accessKey;
-
-    private String secretKey;
-
 }

+ 1 - 23
src/main/java/com/nosum/deliver/auth/service/AuthUserService.java

@@ -1,11 +1,9 @@
 package com.nosum.deliver.auth.service;
 
 import com.nosum.common.base.domain.Result;
-import com.nosum.common.base.service.BaseService;
-import com.nosum.deliver.auth.domain.po.AuthUser;
 import com.nosum.deliver.auth.domain.vo.AuthUserVO;
 
-public interface AuthUserService extends BaseService<AuthUser> {
+public interface AuthUserService {
 
     /**
      * 获取用户信息
@@ -18,11 +16,6 @@ public interface AuthUserService extends BaseService<AuthUser> {
     Result getMasterUserInfo();
 
     /**
-     * 获取用户列表
-     */
-    Result getUserList(AuthUserVO authUserVO);
-
-    /**
      * 退出登录
      */
     Result logout();
@@ -33,21 +26,6 @@ public interface AuthUserService extends BaseService<AuthUser> {
     Result updateAdmin(AuthUserVO authUserVO);
 
     /**
-     * 更新个人资料
-     */
-    Result updateUser(AuthUserVO authUserVO);
-
-    /**
-     * 更新用户状态
-     */
-    Result saveAuthUserStatus(AuthUserVO authUserVO);
-
-    /**
-     * 删除用户
-     */
-    Result deleteUsers(Long id);
-
-    /**
      * 获取管理员头像
      */
     String getAvatar();

+ 51 - 111
src/main/java/com/nosum/deliver/auth/service/impl/AuthUserServiceImpl.java

@@ -1,32 +1,24 @@
 package com.nosum.deliver.auth.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.nosum.common.base.domain.Result;
 import com.nosum.common.base.domain.vo.UserSessionVO;
-import com.nosum.common.constant.Constants;
 import com.nosum.common.enums.ErrorEnum;
 import com.nosum.common.util.ExceptionUtil;
-import com.nosum.common.util.PageUtil;
 import com.nosum.common.util.SessionUtil;
-import com.nosum.deliver.auth.dao.AuthTokenDao;
-import com.nosum.deliver.auth.dao.AuthUserDao;
 import com.nosum.deliver.auth.domain.po.AuthToken;
 import com.nosum.deliver.auth.domain.po.AuthUser;
 import com.nosum.deliver.auth.domain.vo.AuthUserVO;
 import com.nosum.deliver.auth.service.AuthUserService;
 import com.nosum.system.enums.RoleEnum;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.data.mongodb.core.query.Update;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
 
-import java.util.ArrayList;
 import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
+import java.util.Objects;
 
 /**
  * 用户认证服务实现类.
@@ -34,145 +26,93 @@ import java.util.Optional;
  * @author Young
  */
 @Service
-public class AuthUserServiceImpl extends ServiceImpl<AuthUserDao, AuthUser> implements AuthUserService {
+public class AuthUserServiceImpl implements AuthUserService {
 
     @Autowired
-    private AuthUserDao authUserDao;
-
-    @Autowired
-    private AuthTokenDao authTokenDao;
+    private MongoTemplate mongoTemplate;
 
     @Override
     public Result getUserInfo(AuthUserVO authUserVO) {
+        // 从请求中获取用户信息
         UserSessionVO userSessionInfo = SessionUtil.getUserSessionInfo();
-        AuthUser authUser = authUserDao.selectById(userSessionInfo.getId());
+        if (Objects.isNull(userSessionInfo) || Objects.isNull(userSessionInfo.getId())) {
+            return Result.createWithError();
+        }
+
+        AuthUser authUser = mongoTemplate.findById(userSessionInfo.getId(), AuthUser.class);
+        if (Objects.isNull(authUser)) {
+            return Result.createWithError();
+        }
+
+        // 返回用户信息
         return Result.createWithModel(new AuthUserVO()
                 .setStatus(authUser.getStatus())
-                .setRoles(Collections.singletonList(RoleEnum.getEnumTypeMap().get(authUser.getRoleId()).getRoleName()))
                 .setName(authUser.getName())
-                .setIntroduction(authUser.getIntroduction())
                 .setAvatar(authUser.getAvatar())
                 .setEmail(authUser.getEmail())
+                .setIntroduction(authUser.getIntroduction())
+                .setRoles(Collections.singletonList(RoleEnum.getEnumTypeMap().get(authUser.getRoleId()).getRoleName()))
         );
     }
 
     @Override
     public Result getMasterUserInfo() {
-        AuthUser authUser = authUserDao.selectOne(new LambdaQueryWrapper<AuthUser>().eq(AuthUser::getRoleId, RoleEnum.ADMIN.getRoleId()));
+        // 构建查询条件
+        Criteria criteria = Criteria.where("roleId").is(RoleEnum.ADMIN.getRoleId());
+
+        // 如果当前有管理员登录,则查询当前的管理员信息
+        UserSessionVO userSessionInfo = SessionUtil.getUserSessionInfo();
+        if (Objects.nonNull(userSessionInfo) && Objects.nonNull(userSessionInfo.getId())) {
+            criteria.and("id").is(userSessionInfo.getId());
+        }
+
+        // 查询管理员信息并且返回
+        AuthUser authUser = mongoTemplate.findOne(Query.query(criteria), AuthUser.class);
         AuthUserVO authUserVO = new AuthUserVO();
-        if (authUser != null) {
+        if (Objects.nonNull(authUser)) {
             authUserVO.setName(authUser.getName())
                     .setIntroduction(authUser.getIntroduction())
                     .setEmail(authUser.getEmail())
                     .setAvatar(authUser.getAvatar());
         }
-
         return Result.createWithModel(authUserVO);
     }
 
     @Override
-    public Result getUserList(AuthUserVO authUserVO) {
-        Page page = Optional.ofNullable(PageUtil.checkAndInitPage(authUserVO)).orElse(PageUtil.initPage());
-        LambdaQueryWrapper<AuthUser> authUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        if (StringUtils.isNotBlank(authUserVO.getKeywords())) {
-            authUserLambdaQueryWrapper.like(AuthUser::getName, authUserVO.getKeywords());
-        }
-        if (StringUtils.isNotBlank(authUserVO.getName())) {
-            authUserLambdaQueryWrapper.eq(AuthUser::getName, authUserVO.getName());
-        }
-        if (authUserVO.getStatus() != null) {
-            authUserLambdaQueryWrapper.eq(AuthUser::getStatus, authUserVO.getStatus());
-        }
-
-        IPage<AuthUser> authUserIPage = authUserDao.selectPage(page, authUserLambdaQueryWrapper.orderByDesc(AuthUser::getRoleId).orderByDesc(AuthUser::getCreateTime));
-        List<AuthUser> records = authUserIPage.getRecords();
-
-        List<AuthUserVO> authUserVOList = new ArrayList<>();
-        if (!CollectionUtils.isEmpty(records)) {
-            records.forEach(authUser -> {
-                authUserVOList.add(new AuthUserVO()
-                        .setId(authUser.getId())
-                        .setStatus(authUser.getStatus())
-                        .setName(authUser.getName())
-                        .setRoleId(authUser.getRoleId())
-                        .setIntroduction(authUser.getIntroduction())
-                        .setStatus(authUser.getStatus())
-                );
-            });
-        }
-
-        return Result.createWithPaging(authUserVOList, PageUtil.initPageInfo(page));
-    }
-
-    @Override
     public Result logout() {
         UserSessionVO userSessionInfo = SessionUtil.getUserSessionInfo();
-        authTokenDao.delete(new LambdaQueryWrapper<AuthToken>().eq(AuthToken::getUserId, userSessionInfo.getId()));
-        return Result.createWithSuccessMessage();
-    }
-
-    @Override
-    public Result updateAdmin(AuthUserVO authUserVO) {
-
-        if (authUserVO == null) {
-            ExceptionUtil.rollback(ErrorEnum.PARAM_ERROR);
+        if (Objects.nonNull(userSessionInfo) && Objects.nonNull(userSessionInfo.getId())) {
+            mongoTemplate.remove(Query.query(Criteria.where("userId").is(userSessionInfo.getId())), AuthToken.class);
         }
-
-        UserSessionVO userSessionInfo = SessionUtil.getUserSessionInfo();
-        authUserDao.updateById(new AuthUser()
-                .setId(userSessionInfo.getId())
-                .setEmail(authUserVO.getEmail())
-                .setAvatar(authUserVO.getAvatar())
-                .setName(authUserVO.getName())
-                .setIntroduction(authUserVO.getIntroduction())
-        );
-
         return Result.createWithSuccessMessage();
     }
 
     @Override
-    public Result updateUser(AuthUserVO authUserVO) {
-        if (authUserVO == null) {
+    public Result updateAdmin(AuthUserVO authUserVO) {
+        UserSessionVO userSessionInfo = null;
+        if (Objects.isNull(authUserVO) || Objects.isNull(userSessionInfo = SessionUtil.getUserSessionInfo())) {
             ExceptionUtil.rollback(ErrorEnum.PARAM_ERROR);
         }
-        authUserDao.updateById(new AuthUser()
-                .setId(authUserVO.getId())
-                .setEmail(authUserVO.getEmail())
-                .setAvatar(authUserVO.getAvatar())
-                .setName(authUserVO.getName())
-                .setIntroduction(authUserVO.getIntroduction())
-                .setStatus(authUserVO.getStatus())
-        );
-        // 锁定了账户,强制用户下线
-        if (authUserVO.getStatus() == Constants.ONE) {
-            authTokenDao.delete(new LambdaQueryWrapper<AuthToken>().eq(AuthToken::getUserId, authUserVO.getId()));
-        }
+        Update update = new Update();
+        update.set("name", authUserVO.getName());
+        update.set("email", authUserVO.getEmail());
+        update.set("avatar", authUserVO.getAvatar());
+        update.set("introduction", authUserVO.getIntroduction());
+        mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(userSessionInfo.getId())), update, AuthUser.class);
         return Result.createWithSuccessMessage();
     }
 
     @Override
-    public Result saveAuthUserStatus(AuthUserVO authUserVO) {
-        if (authUserVO.getStatus() != null
-                && authUserVO.getId() != null
-                && authUserDao.selectCount(new LambdaQueryWrapper<AuthUser>()
-                .eq(AuthUser::getId, authUserVO.getId()).eq(AuthUser::getRoleId, Constants.TWO)) == 0) {
-            authUserDao.updateById(new AuthUser().setId(authUserVO.getId()).setStatus(authUserVO.getStatus()));
-            return Result.createWithSuccessMessage();
-        }
-        return Result.createWithError();
-    }
+    public String getAvatar() {
+        // 构建查询条件
+        Criteria criteria = Criteria.where("roleId").is(RoleEnum.ADMIN.getRoleId());
 
-    @Override
-    public Result deleteUsers(Long id) {
-        if (id != null && authUserDao.selectCount(new LambdaQueryWrapper<AuthUser>().eq(AuthUser::getId, id).eq(AuthUser::getRoleId, Constants.TWO)) == 0) {
-            authUserDao.deleteById(id);
-            return Result.createWithSuccessMessage();
+        // 如果当前有管理员登录,则查询当前的管理员信息
+        UserSessionVO userSessionInfo = SessionUtil.getUserSessionInfo();
+        if (Objects.nonNull(userSessionInfo) && Objects.nonNull(userSessionInfo.getId())) {
+            criteria.and("id").is(userSessionInfo.getId());
         }
-        return Result.createWithError();
-    }
 
-    @Override
-    public String getAvatar() {
-        return authUserDao.selectAvatar();
+        return Objects.requireNonNull(mongoTemplate.findOne(Query.query(criteria), AuthUser.class)).getAvatar();
     }
 }

+ 29 - 25
src/main/java/com/nosum/deliver/auth/service/impl/OauthServiceImpl.java

@@ -1,7 +1,6 @@
 package com.nosum.deliver.auth.service.impl;
 
 import cn.hutool.crypto.SecureUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.nosum.common.base.domain.Result;
 import com.nosum.common.base.domain.vo.UserSessionVO;
 import com.nosum.common.constant.Constants;
@@ -9,8 +8,6 @@ import com.nosum.common.enums.ErrorEnum;
 import com.nosum.common.util.ExceptionUtil;
 import com.nosum.common.util.JwtUtil;
 import com.nosum.common.util.SessionUtil;
-import com.nosum.deliver.auth.dao.AuthTokenDao;
-import com.nosum.deliver.auth.dao.AuthUserDao;
 import com.nosum.deliver.auth.domain.po.AuthToken;
 import com.nosum.deliver.auth.domain.po.AuthUser;
 import com.nosum.deliver.auth.domain.vo.AuthUserVO;
@@ -19,34 +16,36 @@ import com.nosum.system.enums.RoleEnum;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.data.mongodb.core.query.Update;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
 import java.util.Collections;
 import java.util.Date;
+import java.util.Objects;
 
 @Service
 @Slf4j
 public class OauthServiceImpl implements OauthService {
 
     @Autowired
-    private AuthUserDao authUserDao;
-
-    @Autowired
-    private AuthTokenDao authTokenDao;
+    private MongoTemplate mongoTemplate;
 
     @Override
     public Result login(AuthUserVO authUserVO) {
-        log.debug("login {}", authUserVO);
         if (authUserVO == null || StringUtils.isBlank(authUserVO.getEmail()) || StringUtils.isBlank(authUserVO.getPassword())) {
             ExceptionUtil.rollback(ErrorEnum.PARAM_ERROR);
         }
         // 查询管理员
-        AuthUser authUser = authUserDao.selectOne(new LambdaQueryWrapper<AuthUser>()
-                .eq(AuthUser::getRoleId, RoleEnum.ADMIN.getRoleId())
-                .eq(AuthUser::getEmail, authUserVO.getEmail()));
-        ExceptionUtil.isRollback(authUser == null, ErrorEnum.ACCOUNT_NOT_EXIST);
+        AuthUser authUser = mongoTemplate.findOne(Query.query(Criteria.where("roleId").is(RoleEnum.ADMIN.getRoleId()).and("email").is(authUserVO.getEmail())), AuthUser.class);
+        if (Objects.isNull(authUser)) {
+            ExceptionUtil.rollback(ErrorEnum.ACCOUNT_NOT_EXIST);
+        }
+
         // 将密码加密后进行验证
         String psw = SecureUtil.md5(authUserVO.getPassword());
         ExceptionUtil.isRollback(!authUser.getPassword().equals(psw), ErrorEnum.PASSWORD_ERROR);
@@ -55,39 +54,44 @@ public class OauthServiceImpl implements OauthService {
         authUserVO.setCreateTime(authUser.getCreateTime());
         String token = JwtUtil.getToken(new AuthUserVO().setPassword(authUser.getPassword()).setName(authUser.getName()).setId(authUser.getId()));
         authUserVO.setToken(token);
-        authTokenDao.insert(new AuthToken().setUserId(authUser.getId()).setToken(token).setExpireTime(new Date(Constants.EXPIRE_TIME + System.currentTimeMillis()).toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime()));
+
+        // 保存登录 token
+        mongoTemplate.insert(new AuthToken()
+                .setToken(token)
+                .setUserId(authUser.getId())
+                .setExpireTime(new Date(Constants.EXPIRE_TIME + System.currentTimeMillis()).toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime()));
         return Result.createWithModel(authUserVO);
     }
 
     @Override
     public Result updatePassword(AuthUserVO authUserVO) {
         if (StringUtils.isBlank(authUserVO.getPassword()) || StringUtils.isBlank(authUserVO.getPasswordOld())) {
-            ExceptionUtil.isRollback(true, ErrorEnum.PARAM_ERROR);
+            ExceptionUtil.rollback(ErrorEnum.PARAM_ERROR);
         }
         UserSessionVO userSessionInfo = SessionUtil.getUserSessionInfo();
-        AuthUser authUser = authUserDao.selectById(userSessionInfo.getId());
-        if (!SecureUtil.md5(authUserVO.getPasswordOld()).equals(authUser.getPassword())) {
-            ExceptionUtil.isRollback(true, ErrorEnum.UPDATE_PASSWORD_ERROR);
+        if (Objects.nonNull(userSessionInfo)) {
+            AuthUser authUser = mongoTemplate.findById(userSessionInfo.getId(), AuthUser.class);
+            if (Objects.nonNull(authUser) && !SecureUtil.md5(authUserVO.getPasswordOld()).equals(authUser.getPassword())) {
+                ExceptionUtil.rollback(ErrorEnum.UPDATE_PASSWORD_ERROR);
+            }
+            mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(userSessionInfo.getId())), Update.update("password", SecureUtil.md5(authUserVO.getPassword())), AuthUser.class);
         }
-        authUserDao.updateById(new AuthUser().setId(userSessionInfo.getId()).setPassword(SecureUtil.md5(authUserVO.getPassword())));
         return Result.createWithSuccessMessage();
     }
 
     @Override
     public Result registerAdmin(AuthUserVO authUserVO) {
-        AuthUser authUser = authUserDao.selectOne(new LambdaQueryWrapper<AuthUser>().eq(AuthUser::getRoleId, RoleEnum.ADMIN.getRoleId()));
+        AuthUser authUser = mongoTemplate.findOne(Query.query(Criteria.where("roleId").is(RoleEnum.ADMIN.getRoleId())), AuthUser.class);
         if (authUser == null) {
             authUser = new AuthUser();
             authUser.setName(authUserVO.getEmail())
                     .setEmail(authUserVO.getEmail())
-                    .setRoleId(RoleEnum.ADMIN.getRoleId())
-                    .setPassword(SecureUtil.md5(authUserVO.getPassword()))
                     .setCreateTime(LocalDateTime.now())
-                    .setAccessKey(authUserVO.getAccessKey())
-                    .setSecretKey(authUserVO.getSecretKey());
-            authUserDao.insert(authUser);
+                    .setRoleId(RoleEnum.ADMIN.getRoleId())
+                    .setPassword(SecureUtil.md5(authUserVO.getPassword()));
+            mongoTemplate.insert(authUser);
         } else {
-            ExceptionUtil.isRollback(true, ErrorEnum.ACCOUNT_EXIST);
+            ExceptionUtil.rollback(ErrorEnum.ACCOUNT_EXIST);
         }
         return Result.createWithSuccessMessage();
     }

+ 2 - 2
src/main/java/com/nosum/deliver/author/controller/AuthorAdminController.java

@@ -1,6 +1,5 @@
 package com.nosum.deliver.author.controller;
 
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.nosum.common.base.domain.PageInfo;
 import com.nosum.common.base.domain.Result;
 import com.nosum.deliver.author.domain.po.Author;
@@ -10,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.UUID;
 
 /**
  * 作者信息接口层.
@@ -36,7 +36,7 @@ public class AuthorAdminController {
         Author author1 = models.get(0);
         for (int i = 0; i < 1000; i++) {
             author1.setId(ObjectId.get());
-            author1.setFinderUin(i + IdWorker.get32UUID());
+            author1.setFinderUin(i + UUID.randomUUID().toString());
             save(author1);
         }
 

+ 0 - 83
src/main/java/com/nosum/deliver/category/controller/CategoryController.java

@@ -1,83 +0,0 @@
-package com.nosum.deliver.category.controller;
-
-import com.nosum.common.validator.group.Insert;
-import com.nosum.common.validator.group.Update;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.BindingResult;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.nosum.common.annotation.LoginRequired;
-import com.nosum.common.base.domain.Result;
-import com.nosum.common.util.ThrowableUtils;
-import com.nosum.deliver.category.domain.vo.CategoryVO;
-import com.nosum.deliver.category.service.CategoryService;
-
-/**
- * @author sumbytes
- * @since 2019-08-28
- */
-@RestController
-@RequestMapping("/category")
-public class CategoryController {
-
-    @Autowired
-    private CategoryService categoryService;
-
-    @LoginRequired
-    @PostMapping("/category/v1/add")
-    public Result saveCategory(@Validated({Insert.class}) @RequestBody CategoryVO categoryVO, BindingResult result) {
-        ThrowableUtils.checkParamArgument(result);
-        return categoryService.saveCategory(categoryVO);
-    }
-
-
-    @LoginRequired
-    @GetMapping("/statistics/v1/list")
-    public  Result statisticsList(CategoryVO categoryVO){
-        return categoryService.statisticsList(categoryVO);
-    }
-
-    @LoginRequired
-    @PutMapping("/category/v1/update")
-    public Result updateCategory(@Validated({Update.class}) @RequestBody CategoryVO categoryVO, BindingResult result) {
-        ThrowableUtils.checkParamArgument(result);
-        return categoryService.updateCategory(categoryVO);
-    }
-
-    @LoginRequired
-    @GetMapping("/category-tags/v1/{id}")
-    public Result getCategoryTags(@PathVariable(value = "id", required = true) Long id) {
-        return categoryService.getCategoryTags(id);
-    }
-
-    @LoginRequired
-    @GetMapping("/category-tags/v1/list")
-    public Result getCategoryTagsList(CategoryVO categoryVO) {
-        return categoryService.getCategoryTagsList(categoryVO);
-    }
-
-    @GetMapping("/category/v1/{id}")
-    public Result getCategory(@PathVariable(value = "id", required = true) Long id) {
-        return categoryService.getCategory(id);
-    }
-
-    @GetMapping("/category/v1/list")
-    public Result getCategoryList(CategoryVO categoryVO) {
-        return categoryService.getCategoryList(categoryVO);
-    }
-
-    @LoginRequired
-    @DeleteMapping("/category/v1/{id}")
-    public Result deleteCategory(@PathVariable(value = "id", required = true) Long id) {
-        return categoryService.deleteCategory(id);
-    }
-
-}

+ 0 - 68
src/main/java/com/nosum/deliver/category/controller/TagsController.java

@@ -1,68 +0,0 @@
-package com.nosum.deliver.category.controller;
-
-import com.nosum.common.annotation.LoginRequired;
-import com.nosum.common.base.domain.Result;
-import com.nosum.common.util.ThrowableUtils;
-import com.nosum.common.validator.group.Insert;
-import com.nosum.common.validator.group.Update;
-import com.nosum.deliver.category.domain.vo.TagsVO;
-import com.nosum.deliver.category.service.TagsService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.BindingResult;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * @author sumbytes
- * @since 2019-08-28
- */
-@RestController
-@RequestMapping("/tags")
-public class TagsController {
-
-    @Autowired
-    private TagsService tagsService;
-
-    @GetMapping("/tags/v1/list")
-    public Result getTagsList(TagsVO tagsVO) {
-        return this.tagsService.getTagsList(tagsVO);
-    }
-
-    @GetMapping("/tags-article-quantity/v1/list")
-    public Result getTagsAndArticleQuantityList(TagsVO tagsVO, BindingResult result) {
-        ThrowableUtils.checkParamArgument(result);
-        return this.tagsService.getTagsAndArticleQuantityList(tagsVO);
-    }
-
-    @GetMapping("/tags/v1/{id}")
-    public Result getTags(@PathVariable Long id) {
-        return this.tagsService.getTags(id);
-    }
-
-    @LoginRequired
-    @PostMapping("/tags/v1/add")
-    public Result saveTags(@Validated({Insert.class}) @RequestBody TagsVO tagsVO,BindingResult result) {
-        ThrowableUtils.checkParamArgument(result);
-        return this.tagsService.saveTags(tagsVO);
-    }
-
-    @LoginRequired
-    @PutMapping("/tags/v1/update")
-    public Result updateTags(@Validated({Update.class}) @RequestBody TagsVO tagsVO,BindingResult result) {
-        ThrowableUtils.checkParamArgument(result);
-        return this.tagsService.updateTags(tagsVO);
-    }
-
-    @LoginRequired
-    @DeleteMapping("/tags/v1/{id}")
-    public Result updateTags(@PathVariable Long id) {
-        return this.tagsService.deleteTags(id);
-    }
-}

+ 0 - 31
src/main/java/com/nosum/deliver/category/dao/CategoryDao.java

@@ -1,31 +0,0 @@
-package com.nosum.deliver.category.dao;
-
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.Constants;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.nosum.deliver.category.domain.po.Category;
-import com.nosum.deliver.category.domain.vo.CategoryVO;
-import com.nosum.common.base.dao.BaseDao;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * <p>
- * Mapper 接口
- * </p>
- * @author sumbytes
- * @since 2019-08-28
- */
-public interface CategoryDao extends BaseDao<Category> {
-
-    /**
-     * 查询一个分类有多少篇文章
-     * @return
-     */
-    List<CategoryVO> selectCategoryPostsTotal();
-    IPage<CategoryVO> selectStatistics(Page page, @Param(Constants.WRAPPER) Wrapper<CategoryVO> queryWrapper);
-
-    IPage<Category> selectListPage(@Param("page") Page page, @Param("condition") CategoryVO categoryVO);
-}

+ 0 - 16
src/main/java/com/nosum/deliver/category/dao/CategoryTagsDao.java

@@ -1,16 +0,0 @@
-package com.nosum.deliver.category.dao;
-
-import com.nosum.deliver.category.domain.po.CategoryTags;
-import com.nosum.common.base.dao.BaseDao;
-
-/**
- * <p>
- *  Mapper 接口
- * </p>
- *
- * @author sumbytes
- * @since 2019-08-28
- */
-public interface CategoryTagsDao extends BaseDao<CategoryTags> {
-
-}

+ 0 - 16
src/main/java/com/nosum/deliver/category/dao/TagsDao.java

@@ -1,16 +0,0 @@
-package com.nosum.deliver.category.dao;
-
-import com.nosum.deliver.category.domain.po.Tags;
-import com.nosum.common.base.dao.BaseDao;
-
-/**
- * <p>
- * 标签表 Mapper 接口
- * </p>
- *
- * @author sumbytes
- * @since 2019-08-28
- */
-public interface TagsDao extends BaseDao<Tags> {
-
-}

+ 0 - 58
src/main/java/com/nosum/deliver/category/domain/po/Category.java

@@ -1,58 +0,0 @@
-package com.nosum.deliver.category.domain.po;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import com.baomidou.mybatisplus.annotation.TableId;
-import java.time.LocalDateTime;
-import java.io.Serializable;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-/**
- * @author sumbytes
- * @since 2019-08-28
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-@TableName("category")
-public class Category extends Model<Category> {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
-
-    /**
-     * 名称
-     */
-    private String name;
-
-    /**
-     * 排序
-     */
-    private Integer sort;
-
-    /**
-     * 创建时间
-     */
-    private LocalDateTime createTime;
-
-    /**
-     * 更新时间
-     */
-    private LocalDateTime updateTime;
-
-    @TableField(exist = false)
-    private Integer total;
-
-
-    @Override
-    protected Serializable pkVal() {
-        return this.id;
-    }
-
-}

+ 0 - 59
src/main/java/com/nosum/deliver/category/domain/po/CategoryTags.java

@@ -1,59 +0,0 @@
-package com.nosum.deliver.category.domain.po;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import com.baomidou.mybatisplus.annotation.TableId;
-import java.time.LocalDateTime;
-import java.io.Serializable;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-/**
- * @author sumbytes
- * @since 2019-08-28
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-@TableName("category_tags")
-public class CategoryTags extends Model<CategoryTags> {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
-
-    /**
-     * 名称
-     */
-    private Long tagsId;
-
-    /**
-     * 分类的主键
-     */
-    private Long categoryId;
-
-    /**
-     * 排序
-     */
-    private Integer sort;
-
-    /**
-     * 创建时间
-     */
-    private LocalDateTime createTime;
-
-    /**
-     * 更新时间
-     */
-    private LocalDateTime updateTime;
-
-
-    @Override
-    protected Serializable pkVal() {
-        return this.id;
-    }
-
-}

+ 0 - 54
src/main/java/com/nosum/deliver/category/domain/po/Tags.java

@@ -1,54 +0,0 @@
-package com.nosum.deliver.category.domain.po;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import com.baomidou.mybatisplus.annotation.TableId;
-import java.time.LocalDateTime;
-import java.io.Serializable;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-/**
- * @author sumbytes
- * @since 2019-08-28
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-@TableName("tags")
-public class Tags extends Model<Tags> {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
-
-    /**
-     * 名称
-     */
-    private String name;
-
-    /**
-     * 排序
-     */
-    private Integer sort;
-
-    /**
-     * 创建时间
-     */
-    private LocalDateTime createTime;
-
-    /**
-     * 更新时间
-     */
-    private LocalDateTime updateTime;
-
-
-    @Override
-    protected Serializable pkVal() {
-        return this.id;
-    }
-
-}

+ 0 - 45
src/main/java/com/nosum/deliver/category/domain/vo/CategoryVO.java

@@ -1,45 +0,0 @@
-package com.nosum.deliver.category.domain.vo;
-
-import com.nosum.common.base.domain.vo.BaseVO;
-import com.nosum.common.validator.annotion.NotBlank;
-import com.nosum.common.validator.group.Insert;
-import com.nosum.common.validator.group.Update;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import java.time.LocalDateTime;
-import java.util.List;
-
-/**
- * @author sumbytes
- * @since 2019-08-28
- */
-@Data
-@Accessors(chain = true)
-public class CategoryVO extends BaseVO<CategoryVO> {
-
-    /**
-     * 名称
-     */
-    @NotBlank(groups = {Insert.class, Update.class})
-    private String name;
-
-    /**
-     * 排序
-     */
-    private Integer sort;
-
-    /**
-     * 创建时间
-     */
-    private LocalDateTime createTime;
-
-    /**
-     * 更新时间
-     */
-    private LocalDateTime updateTime;
-
-    private List<TagsVO> tagsList;
-
-    private Integer total;
-}

+ 0 - 28
src/main/java/com/nosum/deliver/category/domain/vo/TagsVO.java

@@ -1,28 +0,0 @@
-package com.nosum.deliver.category.domain.vo;
-
-import com.nosum.common.base.domain.vo.BaseVO;
-import com.nosum.common.validator.annotion.NotBlank;
-import com.nosum.common.validator.group.Insert;
-import com.nosum.common.validator.group.Update;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-/**
- * @date: 2019/9/1 20:52
- * @modified:
- */
-@Data
-@Accessors(chain = true)
-public class TagsVO extends BaseVO<TagsVO> {
-
-    /**
-     * 名称
-     */
-    @NotBlank(groups = {Insert.class, Update.class})
-    private String name;
-
-    /**
-     * 文章总数
-     */
-    private Integer postsTotal;
-}

+ 0 - 65
src/main/java/com/nosum/deliver/category/service/CategoryService.java

@@ -1,65 +0,0 @@
-package com.nosum.deliver.category.service;
-
-import com.nosum.common.base.domain.Result;
-import com.nosum.common.base.service.BaseService;
-import com.nosum.deliver.category.domain.po.Category;
-import com.nosum.deliver.category.domain.vo.CategoryVO;
-
-/**
- * @author sumbytes
- * @since 2019-08-28
- */
-public interface CategoryService extends BaseService<Category> {
-
-    /**
-     * 新增分类
-     * @param categoryVO
-     * @return
-     */
-    Result saveCategory(CategoryVO categoryVO);
-
-    /**
-     * 查询分类列表
-     * @param categoryVO
-     * @return
-     */
-    Result getCategoryList(CategoryVO categoryVO);
-
-
-    /**
-     * 查询带有分类标签列表
-     * @param categoryVO
-     * @return
-     */
-    Result getCategoryTagsList(CategoryVO categoryVO);
-
-    /**
-     * 查询带有分类标签
-     * @param id
-     * @return
-     */
-    Result getCategoryTags(Long id);
-
-    /**
-     * 查询分类
-     * @param id
-     * @return
-     */
-    Result getCategory(Long id);
-
-    /**
-     * 更新分类
-     * @param categoryVO
-     * @return
-     */
-    Result updateCategory(CategoryVO categoryVO);
-
-    /**
-     * 删除分类
-     * @param id
-     * @return
-     */
-    Result deleteCategory(Long id);
-
-    Result statisticsList(CategoryVO categoryVO);
-}

+ 0 - 55
src/main/java/com/nosum/deliver/category/service/TagsService.java

@@ -1,55 +0,0 @@
-package com.nosum.deliver.category.service;
-
-import com.nosum.common.base.domain.Result;
-import com.nosum.common.base.service.BaseService;
-import com.nosum.deliver.category.domain.po.Tags;
-import com.nosum.deliver.category.domain.vo.TagsVO;
-
-/**
- * @author sumbytes
- * @since 2019-08-28
- */
-public interface TagsService extends BaseService<Tags> {
-
-    /**
-     * 查询标签的列表
-     * @param tagsVO
-     * @return
-     */
-    Result<TagsVO> getTagsAndArticleQuantityList(TagsVO tagsVO);
-
-    /**
-     * 查询标签的列表
-     * @param tagsVO
-     * @return
-     */
-    Result<TagsVO> getTagsList(TagsVO tagsVO);
-
-    /**
-     * 查询标签
-     * @param id
-     * @return
-     */
-    Result<TagsVO> getTags(Long id);
-
-    /**
-     * 查询标签
-     * @param tagsVO
-     * @return
-     */
-    Result<TagsVO> updateTags(TagsVO tagsVO);
-
-    /**
-     * 删除标签
-     * @param id
-     * @return
-     */
-    Result<TagsVO> deleteTags(Long id);
-
-    /**
-     * 新增标签
-     * @param tagsVO
-     * @return
-     */
-    Result<TagsVO> saveTags(TagsVO tagsVO);
-}

+ 0 - 214
src/main/java/com/nosum/deliver/category/service/impl/CategoryServiceImpl.java

@@ -1,214 +0,0 @@
-package com.nosum.deliver.category.service.impl;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.nosum.common.base.domain.Result;
-import com.nosum.common.constant.Constants;
-import com.nosum.common.enums.ErrorEnum;
-import com.nosum.common.util.ExceptionUtil;
-import com.nosum.common.util.PageUtil;
-import com.nosum.deliver.category.dao.CategoryDao;
-import com.nosum.deliver.category.dao.CategoryTagsDao;
-import com.nosum.deliver.category.dao.TagsDao;
-import com.nosum.deliver.category.domain.po.Category;
-import com.nosum.deliver.category.domain.po.CategoryTags;
-import com.nosum.deliver.category.domain.po.Tags;
-import com.nosum.deliver.category.domain.vo.CategoryVO;
-import com.nosum.deliver.category.domain.vo.TagsVO;
-import com.nosum.deliver.category.service.CategoryService;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-/**
- * <p>
- * 服务实现类
- * </p>
- *
- * @author sumbytes
- * @since 2019-08-28
- */
-@Service
-public class CategoryServiceImpl extends ServiceImpl<CategoryDao, Category> implements CategoryService {
-
-    @Autowired
-    private CategoryDao categoryDao;
-
-    @Autowired
-    private TagsDao tagsDao;
-
-    @Autowired
-    private CategoryTagsDao categoryTagsDao;
-
-    @Override
-    public Result saveCategory(CategoryVO categoryVO) {
-        Category category = new Category().setName(categoryVO.getName()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
-        this.categoryDao.insert(category);
-
-        List<TagsVO> tagsList = categoryVO.getTagsList();
-        if (!CollectionUtils.isEmpty(tagsList)) {
-            tagsList.forEach(tagsVO -> {
-                if (tagsVO.getId() == null) {
-                    Tags tags = new Tags().setName(tagsVO.getName()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
-                    this.tagsDao.insert(tags);
-                    tagsVO.setId(tags.getId());
-                }
-                categoryTagsDao.insert(new CategoryTags().setCategoryId(category.getId()).setTagsId(tagsVO.getId()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now()));
-            });
-        }
-
-        return Result.createWithSuccessMessage();
-    }
-
-    @Override
-    public Result getCategoryList(CategoryVO categoryVO) {
-
-        List<Category> categoryList = this.categoryDao.selectList(new LambdaQueryWrapper<Category>().orderByDesc(Category::getCreateTime));
-        List<CategoryVO> categoryPostsTotal = this.categoryDao.selectCategoryPostsTotal();
-        Map<Long, Integer> map = new HashMap<>();
-        if (!CollectionUtils.isEmpty(categoryPostsTotal)) {
-            map = categoryPostsTotal.stream().collect(Collectors.toMap(CategoryVO::getId, CategoryVO::getTotal, Integer::sum));
-        }
-
-        List<CategoryVO> categoryVOList = new ArrayList<>();
-        if (!CollectionUtils.isEmpty(categoryList)) {
-            Map<Long, Integer> finalMap = map;
-            categoryList.forEach(category -> {
-                Integer total = finalMap.get(category.getId());
-                categoryVOList.add(new CategoryVO().setId(category.getId()).setName(category.getName()).setTotal(total));
-            });
-        }
-
-        return Result.createWithModels(categoryVOList);
-    }
-
-    @Override
-    public Result getCategoryTagsList(CategoryVO categoryVO) {
-        Page page = Optional.ofNullable(PageUtil.checkAndInitPage(categoryVO)).orElse(PageUtil.initPage());
-        IPage<Category> categoryIPage = this.categoryDao.selectListPage(page,categoryVO);
-        List<Category> categoryList = categoryIPage.getRecords();
-
-        List<CategoryVO> categoryVOList = new ArrayList<>();
-        if (!CollectionUtils.isEmpty(categoryList)) {
-            categoryList.forEach(category -> {
-                List<CategoryTags> categoryTags =
-                        categoryTagsDao.selectList(new LambdaQueryWrapper<CategoryTags>().eq(CategoryTags::getCategoryId, category.getId()));
-                List<TagsVO> tagsVOList = new ArrayList<>();
-                if (!CollectionUtils.isEmpty(categoryTags)) {
-                    categoryTags.forEach(categoryTags1 -> {
-                        Tags tags =
-                                Optional.ofNullable(this.tagsDao.selectById(categoryTags1.getTagsId())).orElse(new Tags());
-                        tagsVOList.add(new TagsVO().setName(tags.getName()));
-                    });
-                }
-                categoryVOList.add(new CategoryVO().setId(category.getId()).setName(category.getName()).setTagsList(tagsVOList));
-            });
-        }
-
-        return Result.createWithPaging(categoryVOList, PageUtil.initPageInfo(page));
-    }
-
-    @Override
-    public Result getCategoryTags(Long id) {
-
-        Category category = this.categoryDao.selectOne(new LambdaQueryWrapper<Category>().eq(Category::getId, id));
-
-        List<CategoryTags> categoryTags =
-                categoryTagsDao.selectList(new LambdaQueryWrapper<CategoryTags>().eq(CategoryTags::getCategoryId,
-                        category.getId()));
-        List<TagsVO> tagsVOList = new ArrayList<>();
-        if (!CollectionUtils.isEmpty(categoryTags)) {
-            categoryTags.forEach(categoryTags1 -> {
-                Tags tags = this.tagsDao.selectById(categoryTags1.getTagsId());
-                tagsVOList.add(new TagsVO().setId(tags.getId()).setName(tags.getName()));
-            });
-        }
-
-        CategoryVO categoryVO =
-                new CategoryVO().setId(category.getId()).setName(category.getName()).setTagsList(tagsVOList);
-        return Result.createWithModel(categoryVO);
-    }
-
-    @Override
-    public Result getCategory(Long id) {
-        Category category = this.categoryDao.selectOne(new LambdaQueryWrapper<Category>().eq(Category::getId, id));
-
-        List<CategoryTags> categoryTags =
-                categoryTagsDao.selectList(new LambdaQueryWrapper<CategoryTags>().eq(CategoryTags::getCategoryId,
-                        category.getId()));
-        List<TagsVO> tagsVOList = new ArrayList<>();
-        if (!CollectionUtils.isEmpty(categoryTags)) {
-            categoryTags.forEach(categoryTags1 -> {
-                Tags tags = this.tagsDao.selectById(categoryTags1.getTagsId());
-                tagsVOList.add(new TagsVO().setId(tags.getId()).setName(tags.getName()));
-            });
-        }
-
-        CategoryVO categoryVO =
-                new CategoryVO().setId(category.getId()).setName(category.getName()).setTagsList(tagsVOList);
-        return Result.createWithModel(categoryVO);
-    }
-
-    @Override
-    public Result updateCategory(CategoryVO categoryVO) {
-
-        Integer count = this.categoryDao.selectCount(new LambdaQueryWrapper<Category>().eq(Category::getId,
-                categoryVO.getId()));
-        if (count.equals(Constants.ZERO)) {
-            ExceptionUtil.rollback(ErrorEnum.DATA_NO_EXIST);
-        }
-
-        Category category = new Category().setId(categoryVO.getId()).setName(categoryVO.getName()).setUpdateTime(LocalDateTime.now());
-        this.categoryDao.updateById(category);
-
-        List<TagsVO> tagsList = categoryVO.getTagsList();
-
-        this.categoryTagsDao.delete(new LambdaUpdateWrapper<CategoryTags>().eq(CategoryTags::getCategoryId, category.getId()));
-        if (!CollectionUtils.isEmpty(tagsList)) {
-            tagsList.forEach(tagsVO -> {
-                if (tagsVO.getId() == null) {
-                    // saveLogs
-                    Tags tags =
-                            new Tags().setName(tagsVO.getName()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
-                    this.tagsDao.insert(tags);
-                    tagsVO.setId(tags.getId());
-                }
-                categoryTagsDao.insert(new CategoryTags().setCategoryId(category.getId()).setTagsId(tagsVO.getId()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now()));
-            });
-        }
-
-        return Result.createWithSuccessMessage();
-    }
-
-    @Override
-    public Result deleteCategory(Long id) {
-
-        this.categoryDao.deleteById(id);
-        this.categoryTagsDao.delete(new LambdaQueryWrapper<CategoryTags>().eq(CategoryTags::getCategoryId, id));
-
-        return Result.createWithSuccessMessage();
-    }
-
-    @Override
-    public Result statisticsList(CategoryVO categoryVO) {
-        Page page = Optional.of(PageUtil.checkAndInitPage(categoryVO)).orElse(PageUtil.initPage());
-        LambdaQueryWrapper<CategoryVO> categoryLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        if (StringUtils.isNotBlank(categoryVO.getKeywords())) {
-            categoryLambdaQueryWrapper.like(CategoryVO::getName, categoryVO.getKeywords());
-        }
-        IPage<CategoryVO> categoryVOList = this.categoryDao.selectStatistics(page,categoryLambdaQueryWrapper);
-        return Result.createWithPaging(categoryVOList.getRecords(), PageUtil.initPageInfo(page));
-    }
-}

+ 0 - 120
src/main/java/com/nosum/deliver/category/service/impl/TagsServiceImpl.java

@@ -1,120 +0,0 @@
-package com.nosum.deliver.category.service.impl;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.nosum.common.base.domain.Result;
-import com.nosum.common.constant.Constants;
-import com.nosum.common.enums.ErrorEnum;
-import com.nosum.common.util.ExceptionUtil;
-import com.nosum.common.util.PageUtil;
-import com.nosum.deliver.category.dao.CategoryTagsDao;
-import com.nosum.deliver.category.dao.TagsDao;
-import com.nosum.deliver.category.domain.po.CategoryTags;
-import com.nosum.deliver.category.domain.po.Tags;
-import com.nosum.deliver.category.domain.vo.TagsVO;
-import com.nosum.deliver.category.service.TagsService;
-import com.nosum.deliver.posts.dao.PostsTagsDao;
-import com.nosum.deliver.posts.domain.po.PostsTags;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author sumbytes
- * @since 2019-08-28
- */
-@Service
-public class TagsServiceImpl extends ServiceImpl<TagsDao, Tags> implements TagsService {
-
-    @Autowired
-    private TagsDao tagsDao;
-
-    @Autowired
-    private PostsTagsDao postsTagsDao;
-
-    @Autowired
-    private CategoryTagsDao categoryTagsDao;
-
-    @Override
-    public Result<TagsVO> getTagsAndArticleQuantityList(TagsVO tagsVO) {
-        List<Tags> records = this.tagsDao.selectList(new LambdaQueryWrapper<Tags>().orderByDesc(Tags::getCreateTime));
-
-        List<TagsVO> tagsList = new ArrayList<>();
-        if (!CollectionUtils.isEmpty(records)) {
-            records.forEach(tags -> {
-                Integer total = postsTagsDao.selectCount(new LambdaQueryWrapper<PostsTags>().eq(PostsTags::getTagsId, tags.getId()));
-                tagsList.add(new TagsVO().setId(tags.getId()).setPostsTotal(total).setName(tags.getName()));
-            });
-        }
-
-        return Result.createWithModels(tagsList);
-    }
-
-    @Override
-    public Result<TagsVO> getTagsList(TagsVO tagsVO) {
-
-        List<TagsVO> tagsList = new ArrayList<>();
-        if (tagsVO == null || tagsVO.getPage() == null || tagsVO.getSize() == null) {
-            List<Tags> records = this.tagsDao.selectList(new LambdaQueryWrapper<Tags>().orderByDesc(Tags::getCreateTime));
-            if (!CollectionUtils.isEmpty(records)) {
-                records.forEach(tags -> {
-                    tagsList.add(new TagsVO().setId(tags.getId()).setName(tags.getName()));
-                });
-            }
-            return Result.createWithModels(tagsList);
-        }
-        LambdaQueryWrapper<Tags> tagsLambdaQueryWrapper = new LambdaQueryWrapper<Tags>();
-        if (StringUtils.isNotBlank(tagsVO.getKeywords())){
-            tagsLambdaQueryWrapper.like(Tags::getName, tagsVO.getKeywords());
-        }
-        if (StringUtils.isNotBlank(tagsVO.getName())){
-            tagsLambdaQueryWrapper.eq(Tags::getName, tagsVO.getName());
-        }
-        Page page = PageUtil.checkAndInitPage(tagsVO);
-        IPage<TagsVO> tagsIPage = this.tagsDao.selectPage(page,tagsLambdaQueryWrapper.orderByDesc(Tags::getCreateTime));
-        return Result.createWithPaging(tagsIPage.getRecords(), PageUtil.initPageInfo(page));
-    }
-
-    @Override
-    public Result<TagsVO> getTags(Long id) {
-
-        Tags tags = this.tagsDao.selectById(id);
-        return Result.createWithModel(new TagsVO().setId(tags.getId()).setName(tags.getName()));
-    }
-
-    @Override
-    public Result<TagsVO> updateTags(TagsVO tagsVO) {
-
-        Integer count  = this.tagsDao.selectCount(new LambdaQueryWrapper<Tags>().eq(Tags::getId,tagsVO.getId()));
-        if (count.equals(Constants.ZERO)) {
-            ExceptionUtil.rollback(ErrorEnum.DATA_NO_EXIST);
-        }
-
-        this.tagsDao.updateById(new Tags().setId(tagsVO.getId()).setName(tagsVO.getName()).setUpdateTime(LocalDateTime.now()));
-        return Result.createWithSuccessMessage();
-    }
-
-    @Override
-    public Result<TagsVO> deleteTags(Long id) {
-
-        this.tagsDao.deleteById(id);
-        this.categoryTagsDao.delete(new LambdaQueryWrapper<CategoryTags>().eq(CategoryTags::getTagsId, id));
-        this.postsTagsDao.delete(new LambdaQueryWrapper<PostsTags>().eq(PostsTags::getTagsId, id));
-
-        return Result.createWithSuccessMessage();
-    }
-
-    @Override
-    public Result<TagsVO> saveTags(TagsVO tagsVO) {
-
-        this.tagsDao.insert(new Tags().setName(tagsVO.getName()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now()));
-        return Result.createWithSuccessMessage();
-    }
-}

+ 17 - 45
src/main/java/com/nosum/deliver/dashboard/service/impl/DashboardServiceImpl.java

@@ -1,61 +1,33 @@
 package com.nosum.deliver.dashboard.service.impl;
 
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-//import com.nosum.deliver.log.dao.AuthUserLogDao;
-//import com.nosum.deliver.log.domain.vo.AuthUserLogVO;
 import com.nosum.common.base.domain.Result;
-import com.nosum.common.constant.Constants;
-import com.nosum.common.enums.DateTypeEnum;
-import com.nosum.common.enums.ErrorEnum;
-import com.nosum.common.util.DateUtil;
-import com.nosum.common.util.ExceptionUtil;
-import com.nosum.common.util.PageUtil;
 import com.nosum.deliver.dashboard.service.DashboardService;
-import com.nosum.deliver.posts.dao.PostsDao;
-import com.nosum.deliver.posts.domain.po.Posts;
-import com.nosum.deliver.posts.domain.vo.PostsVO;
-import com.nosum.system.enums.ArticleStatusEnum;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
 
-import java.time.*;
-import java.time.temporal.TemporalAdjusters;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * @author: sumbytes
- * @date: 2019/09/03 18:56
- */
 @Service
 public class DashboardServiceImpl implements DashboardService {
 
-    @Autowired
-    private PostsDao postsDao;
+    //@Autowired
+    //private PostsDao postsDao;
 
-//    @Autowired
-//    private AuthUserLogDao authUserLogDao;
+    //@Autowired
+    //private AuthUserLogDao authUserLogDao;
 
     @Override
     public Result getPostsQuantityTotal() {
-        PostsVO postsVO = Optional.ofNullable(postsDao.selectPostsTotal()).orElse(new PostsVO().setViewsTotal(Constants.ZERO).setCommentsTotal(Constants.ZERO));
-        Integer article = postsDao.selectCount(null);
-        postsVO.setArticleTotal(article);
-        Integer draft = postsDao.selectCount(new LambdaQueryWrapper<Posts>().eq(Posts::getStatus, ArticleStatusEnum.DRAFT.getStatus()));
-        postsVO.setDraftTotal(draft);
-        postsVO.setPublishTotal(article - draft);
-        Integer syncTotal = postsDao.selectCount(new LambdaQueryWrapper<Posts>().eq(Posts::getSyncStatus, Constants.YES));
-        postsVO.setSyncTotal(syncTotal);
-        Integer todayPublishTotal = postsDao.selectCount(new LambdaQueryWrapper<Posts>().eq(Posts::getStatus, ArticleStatusEnum.PUBLISH.getStatus())
-                .between(Posts::getCreateTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIN), LocalDateTime.of(LocalDate.now(), DateUtil.MAX)));
-        postsVO.setTodayPublishTotal(todayPublishTotal);
-        return Result.createWithModel(postsVO);
+        //PostsVO postsVO = Optional.ofNullable(postsDao.selectPostsTotal()).orElse(new PostsVO().setViewsTotal(Constants.ZERO).setCommentsTotal(Constants.ZERO));
+        //Integer article = postsDao.selectCount(null);
+        //postsVO.setArticleTotal(article);
+        //Integer draft = postsDao.selectCount(new LambdaQueryWrapper<Posts>().eq(Posts::getStatus, ArticleStatusEnum.DRAFT.getStatus()));
+        //postsVO.setDraftTotal(draft);
+        //postsVO.setPublishTotal(article - draft);
+        //Integer syncTotal = postsDao.selectCount(new LambdaQueryWrapper<Posts>().eq(Posts::getSyncStatus, Constants.YES));
+        //postsVO.setSyncTotal(syncTotal);
+        //Integer todayPublishTotal = postsDao.selectCount(new LambdaQueryWrapper<Posts>().eq(Posts::getStatus, ArticleStatusEnum.PUBLISH.getStatus())
+        //        .between(Posts::getCreateTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIN), LocalDateTime.of(LocalDate.now(), DateUtil.MAX)));
+        //postsVO.setTodayPublishTotal(todayPublishTotal);
+        //return Result.createWithModel(postsVO);
+        return null;
     }
 
 //    @Override

+ 4 - 12
src/main/java/com/nosum/deliver/file/controller/UploadFileController.java

@@ -1,29 +1,21 @@
 package com.nosum.deliver.file.controller;
 
-import com.nosum.deliver.file.factory.UploadFileFactory;
 import com.nosum.common.base.domain.Result;
+import com.nosum.deliver.file.factory.UploadFileFactory;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-
-/**
- * @author: zsg
- * @description:
- * @date: 2019/1/13 10:51
- * @modified:
- */
 @RestController
 @RequestMapping("/file")
 public class UploadFileController {
 
     @PostMapping("/file/v1/upload")
-    public Result uploadFile(@RequestParam(value = "file") final MultipartFile file, final HttpServletRequest request) throws IOException {
-        final String store = UploadFileFactory.getUploadFileService().saveFileStore(file);
+    public Result uploadFile(@RequestParam(value = "file") final MultipartFile file) {
+        String storyType = "";
+        final String store = UploadFileFactory.getUploadFileService(storyType).saveFileStore(file);
         return Result.createWithSuccessMessage().setExtra(store);
     }
 

+ 2 - 3
src/main/java/com/nosum/deliver/file/factory/UploadFileFactory.java

@@ -1,6 +1,5 @@
 package com.nosum.deliver.file.factory;
 
-import com.nosum.common.cache.ConfigCache;
 import com.nosum.common.constant.Constants;
 import com.nosum.common.validator.annotion.NotNull;
 import com.nosum.deliver.file.service.UploadFileTemplateService;
@@ -20,8 +19,8 @@ public class UploadFileFactory {
      *
      * @return
      */
-    public static UploadFileTemplateService getUploadFileService() {
-        return uploadFileServiceMap.get(ConfigCache.getConfig(Constants.STORE_TYPE));
+    public static UploadFileTemplateService getUploadFileService(String storyType) {
+        return uploadFileServiceMap.get(storyType);
     }
 
     /**

+ 0 - 55
src/main/java/com/nosum/deliver/file/service/impl/ALiYunOSSUploadFileTemplateServiceImpl.java

@@ -1,55 +0,0 @@
-package com.nosum.deliver.file.service.impl;
-
-import com.aliyun.oss.OSS;
-import com.aliyun.oss.OSSClientBuilder;
-import com.aliyun.oss.internal.OSSHeaders;
-import com.aliyun.oss.model.ObjectMetadata;
-import com.aliyun.oss.model.PutObjectRequest;
-import com.aliyun.oss.model.StorageClass;
-import com.nosum.deliver.file.factory.UploadFileFactory;
-import com.nosum.deliver.file.service.UploadFileTemplateService;
-import com.nosum.common.cache.ConfigCache;
-import com.nosum.common.constant.Constants;
-import com.nosum.common.util.FileUtil;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.io.IOException;
-
-@Service
-public class ALiYunOSSUploadFileTemplateServiceImpl implements UploadFileTemplateService, InitializingBean {
-
-    @Override
-    public boolean doCheck(final MultipartFile file) {
-        return true;
-    }
-
-    @Override
-    public String doSaveFileStore(final MultipartFile file) {
-        final OSS ossClient = new OSSClientBuilder()
-                .build(ConfigCache.getConfig(Constants.ALIYUN_OSS_ENDPOINT),
-                        ConfigCache.getConfig(Constants.ALIYUN_OSS_ACCESS_KEY),
-                        ConfigCache.getConfig(Constants.ALIYUN_OSS_SECRET_KEY));
-        try {
-            final String fileName = FileUtil.createSingleFilePath(ConfigCache.getConfig(Constants.ALIYUN_OSS_PATH), file.getOriginalFilename());
-            final PutObjectRequest putObjectRequest = new PutObjectRequest(ConfigCache.getConfig(Constants.ALIYUN_OSS_BUCKET), fileName, file.getInputStream());
-            final ObjectMetadata metadata = new ObjectMetadata();
-            metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString());
-            putObjectRequest.setMetadata(metadata);
-            ossClient.putObject(putObjectRequest);
-            return ConfigCache.getConfig(Constants.ALIYUN_OSS_IMAGE_DOMAIN) + fileName;
-        } catch (final IOException e) {
-            return "";
-        } finally {
-            if (ossClient != null) {
-                ossClient.shutdown();
-            }
-        }
-    }
-
-    @Override
-    public void afterPropertiesSet() throws Exception {
-        UploadFileFactory.register(Constants.ALIYUN_OSS, this);
-    }
-}

+ 0 - 53
src/main/java/com/nosum/deliver/file/service/impl/COSUploadFileTemplateServiceImpl.java

@@ -1,53 +0,0 @@
-package com.nosum.deliver.file.service.impl;
-
-import com.nosum.deliver.file.factory.UploadFileFactory;
-import com.nosum.deliver.file.service.UploadFileTemplateService;
-import com.nosum.common.cache.ConfigCache;
-import com.nosum.common.constant.Constants;
-import com.nosum.common.util.FileUtil;
-import com.qcloud.cos.COSClient;
-import com.qcloud.cos.ClientConfig;
-import com.qcloud.cos.auth.BasicCOSCredentials;
-import com.qcloud.cos.auth.COSCredentials;
-import com.qcloud.cos.model.PutObjectRequest;
-import com.qcloud.cos.region.Region;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.io.IOException;
-
-@Service
-public class COSUploadFileTemplateServiceImpl implements UploadFileTemplateService, InitializingBean {
-
-    @Override
-    public boolean doCheck(final MultipartFile file) {
-        return true;
-    }
-
-    @Override
-    public String doSaveFileStore(final MultipartFile file) {
-        COSClient cosClient = null;
-        try {
-            final COSCredentials cred = new BasicCOSCredentials(ConfigCache.getConfig(Constants.COS_ACCESS_KEY), ConfigCache.getConfig(Constants.COS_SECRET_KEY));
-            final Region region = new Region(ConfigCache.getConfig(Constants.COS_REGION));
-            final ClientConfig clientConfig = new ClientConfig(region);
-            cosClient = new COSClient(cred, clientConfig);
-            final String fileName = FileUtil.createSingleFilePath(ConfigCache.getConfig(Constants.COS_PATH), file.getOriginalFilename());
-            final PutObjectRequest putObjectRequest = new PutObjectRequest(ConfigCache.getConfig(Constants.COS_BUCKET), fileName, file.getInputStream(), null);
-            cosClient.putObject(putObjectRequest);
-            return ConfigCache.getConfig(Constants.COS_IMAGE_DOMAIN) + fileName;
-        } catch (final IOException e) {
-            return "";
-        } finally {
-            if (cosClient != null) {
-                cosClient.shutdown();
-            }
-        }
-    }
-
-    @Override
-    public void afterPropertiesSet() throws Exception {
-        UploadFileFactory.register(Constants.COS, this);
-    }
-}

+ 12 - 16
src/main/java/com/nosum/deliver/file/service/impl/DefaultUploadFileTemplateServiceImpl.java

@@ -2,15 +2,11 @@ package com.nosum.deliver.file.service.impl;
 
 import com.nosum.deliver.file.factory.UploadFileFactory;
 import com.nosum.deliver.file.service.UploadFileTemplateService;
-import com.nosum.common.cache.ConfigCache;
 import com.nosum.common.constant.Constants;
-import com.nosum.common.util.FileUtil;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.io.File;
-import java.io.IOException;
 
 @Service
 public class DefaultUploadFileTemplateServiceImpl implements UploadFileTemplateService, InitializingBean {
@@ -22,18 +18,18 @@ public class DefaultUploadFileTemplateServiceImpl implements UploadFileTemplateS
 
     @Override
     public String doSaveFileStore(final MultipartFile file) {
-//        final String filePath = ConstantsModels.getDefaultPath(ConfigCache.getConfig(Constants.DEFAULT_PATH));
-//        final String fileName = FileUtil.createSingleFileName(file.getOriginalFilename());
-//        try {
-//            final File destFile = new File(filePath);
-//            if (!destFile.exists()) {
-//                destFile.mkdirs();
-//            }
-//            file.transferTo(new File(filePath + fileName));
-//        } catch (final IOException e) {
-//            e.printStackTrace();
-//        }
-//        return ConfigCache.getConfig(Constants.DEFAULT_IMAGE_DOMAIN)+Constants.FILE_URL+fileName;
+        //final String filePath = ConstantsModels.getDefaultPath(ConfigCache.getConfig(Constants.DEFAULT_PATH));
+        //final String fileName = FileUtil.createSingleFileName(file.getOriginalFilename());
+        //try {
+        //    final File destFile = new File(filePath);
+        //    if (!destFile.exists()) {
+        //        destFile.mkdirs();
+        //    }
+        //    file.transferTo(new File(filePath + fileName));
+        //} catch (final IOException e) {
+        //    e.printStackTrace();
+        //}
+        //return ConfigCache.getConfig(Constants.DEFAULT_IMAGE_DOMAIN)+Constants.FILE_URL+fileName;
         return null;
     }
 

+ 0 - 57
src/main/java/com/nosum/deliver/file/service/impl/QiNiuUploadFileTemplateServiceImpl.java

@@ -1,57 +0,0 @@
-package com.nosum.deliver.file.service.impl;
-
-import com.nosum.deliver.file.factory.UploadFileFactory;
-import com.nosum.deliver.file.service.UploadFileTemplateService;
-import com.nosum.common.cache.ConfigCache;
-import com.nosum.common.constant.Constants;
-import com.nosum.common.util.FileUtil;
-import com.google.gson.Gson;
-import com.qiniu.common.Zone;
-import com.qiniu.http.Response;
-import com.qiniu.storage.Configuration;
-import com.qiniu.storage.UploadManager;
-import com.qiniu.storage.model.DefaultPutRet;
-import com.qiniu.util.Auth;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.io.IOException;
-
-/**
- * @author Administrator
- */
-@Service
-public class QiNiuUploadFileTemplateServiceImpl implements UploadFileTemplateService, InitializingBean {
-
-    @Override
-    public boolean doCheck(final MultipartFile file) {
-        return true;
-    }
-
-    @Override
-    public String doSaveFileStore(final MultipartFile file) {
-        final Configuration cfg = new Configuration(Zone.autoZone());
-        final UploadManager uploadManager = new UploadManager(cfg);
-        final Auth auth = Auth.create(ConfigCache.getConfig(Constants.QINIU_ACCESS_KEY), ConfigCache.getConfig(Constants.QINIU_SECRET_KEY));
-        final String upToken = auth.uploadToken(ConfigCache.getConfig(Constants.QINIU_BUCKET));
-        try {
-            final Response response = uploadManager.put(file.getInputStream(), FileUtil.createSingleFileName(file.getOriginalFilename()), upToken, null, null);
-            final DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
-            return ConfigCache.getConfig(Constants.QINIU_IMAGE_DOMAIN) + putRet.key;
-        } catch (final IOException e) {
-            e.printStackTrace();
-        }
-        return "";
-    }
-
-    /**
-     * 注册到工厂
-     *
-     * @throws Exception
-     */
-    @Override
-    public void afterPropertiesSet() throws Exception {
-        UploadFileFactory.register(Constants.QINIU, this);
-    }
-}

+ 7 - 7
src/main/java/com/nosum/deliver/monitor/controller/MonitorController.java

@@ -4,15 +4,11 @@ import com.alibaba.fastjson.JSONObject;
 import com.nosum.common.annotation.LoginRequired;
 import com.nosum.common.base.domain.Result;
 import com.nosum.system.enums.RoleEnum;
-import org.hyperic.sigar.Mem;
-import org.hyperic.sigar.Sigar;
-import org.hyperic.sigar.SigarException;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import com.nosum.deliver.monitor.util.RuntimeUtil;
 
-import java.math.BigDecimal;
 
 @RestController
 @RequestMapping("/monitor")
@@ -48,18 +44,22 @@ public class MonitorController {
     @GetMapping("/file/v1/get")
     @LoginRequired(role = RoleEnum.ADMIN)
     public Result getFile() {
-        return RuntimeUtil.getFile();
+        //return RuntimeUtil.getFile();
+
+        return null;
     }
 
     @GetMapping("/net/v1/get")
     @LoginRequired(role = RoleEnum.ADMIN)
     public Result getNet() {
-        return RuntimeUtil.getNet();
+        //return RuntimeUtil.getNet();
+        return null;
     }
 
     @GetMapping("/ethernet/v1/get")
     @LoginRequired(role = RoleEnum.ADMIN)
     public Result getEthernet() {
-        return RuntimeUtil.getEthernet();
+        //return RuntimeUtil.getEthernet();
+        return null;
     }
 }

+ 210 - 208
src/main/java/com/nosum/deliver/monitor/util/RuntimeUtil.java

@@ -1,242 +1,244 @@
 package com.nosum.deliver.monitor.util;
- 
-import java.math.BigDecimal;
-import java.net.InetAddress;
-import java.util.Map;
-import java.util.Properties;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.nosum.common.base.domain.Result;
-import org.hyperic.sigar.CpuInfo;
-import org.hyperic.sigar.CpuPerc;
-import org.hyperic.sigar.FileSystem;
-import org.hyperic.sigar.FileSystemUsage;
-import org.hyperic.sigar.Mem;
-import org.hyperic.sigar.NetFlags;
-import org.hyperic.sigar.NetInterfaceConfig;
-import org.hyperic.sigar.NetInterfaceStat;
-import org.hyperic.sigar.Sigar;
+
+import java.net.InetAddress;
+import java.util.Map;
+import java.util.Properties;
 
 public class RuntimeUtil {
 
     /**
      * 获取系统属性
      */
-    public static Result<JSONObject> getProperty(){
-        JSONObject obj=new JSONObject();
-        try{
+    public static Result<JSONObject> getProperty() {
+        JSONObject obj = new JSONObject();
+        try {
             Runtime r = Runtime.getRuntime();
             Properties props = System.getProperties();
             InetAddress addr = InetAddress.getLocalHost();
             Map<String, String> map = System.getenv();
-            obj.put("ip",addr.getHostName());
-            obj.put("hostName",InetAddress.getLocalHost());
-            obj.put("userName",map.get("USERNAME"));
-            obj.put("computerName",map.get("COMPUTERNAME"));
-            obj.put("userDomain",map.get("USERDOMAIN"));
-            obj.put("totalMemory",r.totalMemory());//JVM可以使用的总内存
+            obj.put("ip", addr.getHostName());
+            obj.put("hostName", InetAddress.getLocalHost());
+            obj.put("userName", map.get("USERNAME"));
+            obj.put("computerName", map.get("COMPUTERNAME"));
+            obj.put("userDomain", map.get("USERDOMAIN"));
+            obj.put("totalMemory", r.totalMemory());//JVM可以使用的总内存
             obj.put("freeMemory", r.freeMemory());// JVM可以使用的剩余内存
-            obj.put("availableProcessors",r.availableProcessors()); // JVM可以使用的处理器个数
-            obj.put("javaVersion",props.getProperty("java.version")); // Java的运行环境版本
-            obj.put("javaVendor",props.getProperty("java.vendor")); // Java的运行环境供应商
-            obj.put("javaVendorUrl",props.getProperty("java.vendor.url")); // Java供应商的URL
-            obj.put("javaHome",props.getProperty("java.home")); // Java的安装路径
-            obj.put("java.vm.specification.version",props.getProperty("java.vm.specification.version")); // Java的虚拟机规范版本
+            obj.put("availableProcessors", r.availableProcessors()); // JVM可以使用的处理器个数
+            obj.put("javaVersion", props.getProperty("java.version")); // Java的运行环境版本
+            obj.put("javaVendor", props.getProperty("java.vendor")); // Java的运行环境供应商
+            obj.put("javaVendorUrl", props.getProperty("java.vendor.url")); // Java供应商的URL
+            obj.put("javaHome", props.getProperty("java.home")); // Java的安装路径
+            obj.put("java.vm.specification.version", props.getProperty("java.vm.specification.version")); // Java的虚拟机规范版本
 //            obj.put("javaClassPath",props.getProperty("java.class.path"));// Java的类路径
 //            obj.put("javaLibraryPath",props.getProperty("java.library.path"));// 加载库时搜索的路径列表
-            obj.put("javaIoTmpdir",props.getProperty("java.io.tmpdir"));// 默认的临时文件路径
-            obj.put("javaExtDirs",props.getProperty("java.ext.dirs")); // 一个或多个扩展目录的路径
-            obj.put("osName",props.getProperty("os.name")); // 操作系统的名称
-            obj.put("osArch",props.getProperty("os.arch")); // 操作系统的构架
-            obj.put("osVersion",props.getProperty("os.version")); // 操作系统的版本
-            obj.put("fileSeparator",props.getProperty("file.separator")); // 文件分隔符
-            obj.put("pathSeparator",props.getProperty("path.separator"));// 路径分隔符
-            obj.put("lineSeparator",props.getProperty("line.separator"));// 行分隔符
-            obj.put("userNameDir",props.getProperty("user.name"));// 用户的账户名称
-            obj.put("userHome",props.getProperty("user.home"));// 用户的主目录
-            obj.put("userDir",props.getProperty("user.dir")); // 用户的当前工作目录
-        }catch (Exception e){ e.printStackTrace(); }
+            obj.put("javaIoTmpdir", props.getProperty("java.io.tmpdir"));// 默认的临时文件路径
+            obj.put("javaExtDirs", props.getProperty("java.ext.dirs")); // 一个或多个扩展目录的路径
+            obj.put("osName", props.getProperty("os.name")); // 操作系统的名称
+            obj.put("osArch", props.getProperty("os.arch")); // 操作系统的构架
+            obj.put("osVersion", props.getProperty("os.version")); // 操作系统的版本
+            obj.put("fileSeparator", props.getProperty("file.separator")); // 文件分隔符
+            obj.put("pathSeparator", props.getProperty("path.separator"));// 路径分隔符
+            obj.put("lineSeparator", props.getProperty("line.separator"));// 行分隔符
+            obj.put("userNameDir", props.getProperty("user.name"));// 用户的账户名称
+            obj.put("userHome", props.getProperty("user.home"));// 用户的主目录
+            obj.put("userDir", props.getProperty("user.dir")); // 用户的当前工作目录
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         return Result.createWithModel(obj);
     }
 
     /**
      * 获取内存信息
      */
-    public static Result<JSONObject> getMemory(){
-        JSONObject obj=new JSONObject();
-        try{
-            Sigar sigar = new Sigar();
-            Mem mem = sigar.getMem();
-            BigDecimal total = BigDecimal.valueOf(mem.getTotal()).divide(BigDecimal.valueOf(1024 * 1024 * 1024), BigDecimal.ROUND_HALF_UP);
-            BigDecimal used = BigDecimal.valueOf(mem.getUsed()).divide(BigDecimal.valueOf(1024 * 1024 * 1024), BigDecimal.ROUND_HALF_UP);
-            BigDecimal free = BigDecimal.valueOf(mem.getFree()).divide(BigDecimal.valueOf(1024 * 1024 * 1024), BigDecimal.ROUND_HALF_UP);
-            // 内存总量
-            obj.put("total",total);
-            // 当前内存使用量
-            obj.put("used", used);
-            // 当前内存剩余量
-            obj.put("free", free);
-            // 使用率
-            obj.put("usedRatio",(used.divide(total,3, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100))).setScale(2,BigDecimal.ROUND_HALF_UP));
-//            Swap swap = sigar.getSwap();
-//            obj.put("swapTotal",swap.getTotal() / 1024L / 1024L);// 交换区总量
-//            obj.put("swapUsed",swap.getUsed() / 1024L / 1024L);// 当前交换区使用量
-//            obj.put("swapFree",swap.getFree() / 1024L / 1024L);// 当前交换区剩余量
-        }catch (Exception e){e.printStackTrace();}
-        return Result.createWithModel(obj);
-    }
-
-    public static Result<JSONArray> getCpu(){
-        JSONArray obj=new JSONArray();
-        try{
-            Sigar sigar = new Sigar();
-            CpuInfo infos[] = sigar.getCpuInfoList();
-            CpuPerc cpuList[] = null;
-            cpuList = sigar.getCpuPercList();
-            for (int i = 0; i < infos.length; i++) {// 不管是单块CPU还是多CPU都适用
-                CpuInfo info = infos[i];
-                JSONObject cpuObj=new JSONObject();
-                cpuObj.put("Mhz",info.getMhz());// CPU的总量MHz
-                cpuObj.put("vendor",info.getVendor());// 获得CPU的卖主,如:Intel
-                cpuObj.put("model",info.getModel());// 获得CPU的类别,如:Celeron
-                cpuObj.put("cacheSize",info.getCacheSize());// 缓冲存储器数量
-                cpuObj.putAll(getCpuPerc(cpuList[i]));
-                obj.add(cpuObj);
-            }
-        }catch (Exception e){
+    public static Result<JSONObject> getMemory() {
+        JSONObject obj = new JSONObject();
+        try {
+            //Sigar sigar = new Sigar();
+            //Mem mem = sigar.getMem();
+            //BigDecimal total = BigDecimal.valueOf(mem.getTotal()).divide(BigDecimal.valueOf(1024 * 1024 * 1024), BigDecimal.ROUND_HALF_UP);
+            //BigDecimal used = BigDecimal.valueOf(mem.getUsed()).divide(BigDecimal.valueOf(1024 * 1024 * 1024), BigDecimal.ROUND_HALF_UP);
+            //BigDecimal free = BigDecimal.valueOf(mem.getFree()).divide(BigDecimal.valueOf(1024 * 1024 * 1024), BigDecimal.ROUND_HALF_UP);
+            //// 内存总量
+            //obj.put("total",total);
+            //// 当前内存使用量
+            //obj.put("used", used);
+            //// 当前内存剩余量
+            //obj.put("free", free);
+            //// 使用率
+            //obj.put("usedRatio",(used.divide(total,3, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100))).setScale(2,BigDecimal.ROUND_HALF_UP));
+            //Swap swap = sigar.getSwap();
+            //obj.put("swapTotal",swap.getTotal() / 1024L / 1024L);// 交换区总量
+            //obj.put("swapUsed",swap.getUsed() / 1024L / 1024L);// 当前交换区使用量
+            //obj.put("swapFree",swap.getFree() / 1024L / 1024L);// 当前交换区剩余量
+        } catch (Exception e) {
             e.printStackTrace();
         }
         return Result.createWithModel(obj);
     }
 
-    /**
-     * 获取CPU信息
-     */
-    private static JSONObject getCpuPerc(CpuPerc cpu) {
-        JSONObject obj=new JSONObject();
-        obj.put("user", CpuPerc.format(cpu.getUser()));// 用户使用率
-        obj.put("sys",CpuPerc.format(cpu.getSys()));// 系统使用率
-        obj.put("wait",CpuPerc.format(cpu.getWait()));// 当前等待率
-        obj.put("nice",CpuPerc.format(cpu.getNice()));// 当前错误率
-        obj.put("idle",CpuPerc.format(cpu.getIdle()));// 当前空闲率
-        obj.put("combined",CpuPerc.format(cpu.getCombined()));// 总的使用率
-        return obj;
-    }
-
- 
-    public static Result<JSONObject> getFile(){
-        JSONObject obj = new JSONObject();
-        try{
-            Sigar sigar = new Sigar();
-            FileSystem fslist[] = sigar.getFileSystemList();
-            JSONArray jsonArray = new JSONArray();
-            for (int i = 0, len = fslist.length; i < len; i++) {
-                FileSystem fs = fslist[i];
-                JSONObject jso = new JSONObject();
-                jso.put("dev.name", fs.getDevName()); //分区盘符名称
-                jso.put("dir.name", fs.getDirName()); //分区盘符名称
-                jso.put("flags", fs.getFlags()); //分区盘符类型
-                jso.put("sys.type.name", fs.getSysTypeName()); //文件系统类型
-                jso.put("type.name", fs.getTypeName()); //分区盘符类型名
-                jso.put("type", fs.getType()); //分区盘符文件系统类型
-                FileSystemUsage usage = null;
-                try {
-                    usage = sigar.getFileSystemUsage(fs.getDirName());
-                } catch (Exception e) { e.printStackTrace();}
-                if (usage == null) {
-                    continue;
-                }
-                switch (fs.getType()) {
-                    case 0: // TYPE_UNKNOWN :未知
-                        break;
-                    case 1: // TYPE_NONE
-                        break;
-                    case 2: // TYPE_LOCAL_DISK : 本地硬盘
-                        jso.put("usage.totle", usage.getTotal() / 1024); // 分区总大小
-                        jso.put("usage.free", usage.getFree() / 1024); // 分区剩余大小
-                        jso.put("usage.avail", usage.getAvail() / 1024); // 分区可用大小
-                        jso.put("usage.used", usage.getUsed() / 1024); // 分区已经使用量
-                        jso.put("usage.use.percent", usage.getUsePercent() * 100D); // 分区资源的利用率
-                        break;
-                    case 3:// TYPE_NETWORK :网络
-                        break;
-                    case 4:// TYPE_RAM_DISK :闪存
-                        break;
-                    case 5:// TYPE_CDROM :光驱
-                        break;
-                    case 6:// TYPE_SWAP :页面交换
-                        break;
-                }
-                jso.put("disk.reads", usage.getDiskReads()); // 读出
-                jso.put("disk.writes", usage.getDiskWrites()); // 写入
-                jsonArray.add(jso);
-            }
-            obj.put("file.system", jsonArray);
-        }catch (Exception e){e.printStackTrace();}
+    public static Result<JSONArray> getCpu() {
+        JSONArray obj = new JSONArray();
+        //try{
+        //    Sigar sigar = new Sigar();
+        //    CpuInfo infos[] = sigar.getCpuInfoList();
+        //    CpuPerc cpuList[] = null;
+        //    cpuList = sigar.getCpuPercList();
+        //    for (int i = 0; i < infos.length; i++) {// 不管是单块CPU还是多CPU都适用
+        //        CpuInfo info = infos[i];
+        //        JSONObject cpuObj=new JSONObject();
+        //        cpuObj.put("Mhz",info.getMhz());// CPU的总量MHz
+        //        cpuObj.put("vendor",info.getVendor());// 获得CPU的卖主,如:Intel
+        //        cpuObj.put("model",info.getModel());// 获得CPU的类别,如:Celeron
+        //        cpuObj.put("cacheSize",info.getCacheSize());// 缓冲存储器数量
+        //        cpuObj.putAll(getCpuPerc(cpuList[i]));
+        //        obj.add(cpuObj);
+        //    }
+        //}catch (Exception e){
+        //    e.printStackTrace();
+        //}
         return Result.createWithModel(obj);
     }
 
-    /**
-     * 获取网络信息
-     */
-    public static Result<JSONObject> getNet() {
-        JSONObject jsonObject = new JSONObject();
-        try{
-            Sigar sigar = new Sigar();
-            String ifNames[] = sigar.getNetInterfaceList();
-            JSONArray jsonArray = new JSONArray();
-            for (int i = 0, len = ifNames.length; i < len; i++) {
-                String name = ifNames[i];
-                JSONObject jso = new JSONObject();
-                NetInterfaceConfig ifconfig = sigar.getNetInterfaceConfig(name);
-                jso.put("name", name); // 网络设备名
-                jso.put("address", ifconfig.getAddress()); // IP地址
-                jso.put("mask", ifconfig.getNetmask()); // 子网掩码
-                if ((ifconfig.getFlags() & 1L) <= 0L) {
-                    continue;
-                }
-                NetInterfaceStat ifstat = sigar.getNetInterfaceStat(name);
-                jso.put("rx.packets", ifstat.getRxPackets());// 接收的总包裹数
-                jso.put("tx.packets", ifstat.getTxPackets());// 发送的总包裹数
-                jso.put("rx.bytes", ifstat.getRxBytes());// 接收到的总字节数
-                jso.put("tx.bytes", ifstat.getTxBytes());// 发送的总字节数
-                jso.put("rx.errors", ifstat.getRxErrors());// 接收到的错误包数
-                jso.put("tx.errors", ifstat.getTxErrors());// 发送数据包时的错误数
-                jso.put("rx.dropped", ifstat.getRxDropped());// 接收时丢弃的包数
-                jso.put("tx.dropped", ifstat.getTxDropped());// 发送时丢弃的包数
-                jsonArray.add(jso);
-            }
-            jsonObject.put("net", jsonArray);
-        }catch (Exception e){e.printStackTrace();}
-        return Result.createWithModel(jsonObject);
-    }
+    ///**
+    // * 获取CPU信息
+    // */
+    //private static JSONObject getCpuPerc(CpuPerc cpu) {
+    //    JSONObject obj = new JSONObject();
+    //    obj.put("user", CpuPerc.format(cpu.getUser()));// 用户使用率
+    //    obj.put("sys", CpuPerc.format(cpu.getSys()));// 系统使用率
+    //    obj.put("wait", CpuPerc.format(cpu.getWait()));// 当前等待率
+    //    obj.put("nice", CpuPerc.format(cpu.getNice()));// 当前错误率
+    //    obj.put("idle", CpuPerc.format(cpu.getIdle()));// 当前空闲率
+    //    obj.put("combined", CpuPerc.format(cpu.getCombined()));// 总的使用率
+    //    return obj;
+    //}
 
-    /**
-     * 获取网卡信息
-     */
-    public static Result<JSONObject> getEthernet() {
-        JSONObject jsonObject = new JSONObject();
-        try{
-            Sigar sigar = new Sigar();
-            String[] ifaces = sigar.getNetInterfaceList();
-            JSONArray jsonArray = new JSONArray();
-            for (int i = 0, len = ifaces.length; i < len; i++) {
-                NetInterfaceConfig cfg = sigar.getNetInterfaceConfig(ifaces[i]);
-                if (NetFlags.LOOPBACK_ADDRESS.equals(cfg.getAddress()) || (cfg.getFlags() & NetFlags.IFF_LOOPBACK) != 0 || NetFlags.NULL_HWADDR.equals(cfg.getHwaddr())) {
-                    continue;
-                }
-                JSONObject jso = new JSONObject();
-                jso.put("address", cfg.getAddress());// IP地址
-                jso.put("broad.cast", cfg.getBroadcast());// 网关广播地址
-                jso.put("hwaddr", cfg.getHwaddr());// 网卡MAC地址
-                jso.put("net.mask", cfg.getNetmask());// 子网掩码
-                jso.put("description", cfg.getDescription());// 网卡描述信息
-                jso.put("type", cfg.getType());// 网卡类型
-                jsonArray.add(jso);
-            }
-            jsonObject.put("ethernet", jsonArray);
-        }catch (Exception e){e.printStackTrace(); }
-        return Result.createWithModel(jsonObject);
-    }
+
+    //public static Result<JSONObject> getFile() {
+    //    JSONObject obj = new JSONObject();
+    //    try {
+    //        Sigar sigar = new Sigar();
+    //        FileSystem fslist[] = sigar.getFileSystemList();
+    //        JSONArray jsonArray = new JSONArray();
+    //        for (int i = 0, len = fslist.length; i < len; i++) {
+    //            FileSystem fs = fslist[i];
+    //            JSONObject jso = new JSONObject();
+    //            jso.put("dev.name", fs.getDevName()); //分区盘符名称
+    //            jso.put("dir.name", fs.getDirName()); //分区盘符名称
+    //            jso.put("flags", fs.getFlags()); //分区盘符类型
+    //            jso.put("sys.type.name", fs.getSysTypeName()); //文件系统类型
+    //            jso.put("type.name", fs.getTypeName()); //分区盘符类型名
+    //            jso.put("type", fs.getType()); //分区盘符文件系统类型
+    //            FileSystemUsage usage = null;
+    //            try {
+    //                usage = sigar.getFileSystemUsage(fs.getDirName());
+    //            } catch (Exception e) {
+    //                e.printStackTrace();
+    //            }
+    //            if (usage == null) {
+    //                continue;
+    //            }
+    //            switch (fs.getType()) {
+    //                case 0: // TYPE_UNKNOWN :未知
+    //                    break;
+    //                case 1: // TYPE_NONE
+    //                    break;
+    //                case 2: // TYPE_LOCAL_DISK : 本地硬盘
+    //                    jso.put("usage.totle", usage.getTotal() / 1024); // 分区总大小
+    //                    jso.put("usage.free", usage.getFree() / 1024); // 分区剩余大小
+    //                    jso.put("usage.avail", usage.getAvail() / 1024); // 分区可用大小
+    //                    jso.put("usage.used", usage.getUsed() / 1024); // 分区已经使用量
+    //                    jso.put("usage.use.percent", usage.getUsePercent() * 100D); // 分区资源的利用率
+    //                    break;
+    //                case 3:// TYPE_NETWORK :网络
+    //                    break;
+    //                case 4:// TYPE_RAM_DISK :闪存
+    //                    break;
+    //                case 5:// TYPE_CDROM :光驱
+    //                    break;
+    //                case 6:// TYPE_SWAP :页面交换
+    //                    break;
+    //            }
+    //            jso.put("disk.reads", usage.getDiskReads()); // 读出
+    //            jso.put("disk.writes", usage.getDiskWrites()); // 写入
+    //            jsonArray.add(jso);
+    //        }
+    //        obj.put("file.system", jsonArray);
+    //    } catch (Exception e) {
+    //        e.printStackTrace();
+    //    }
+    //    return Result.createWithModel(obj);
+    //}
+
+    ///**
+    // * 获取网络信息
+    // */
+    //public static Result<JSONObject> getNet() {
+    //    JSONObject jsonObject = new JSONObject();
+    //    try {
+    //        Sigar sigar = new Sigar();
+    //        String ifNames[] = sigar.getNetInterfaceList();
+    //        JSONArray jsonArray = new JSONArray();
+    //        for (int i = 0, len = ifNames.length; i < len; i++) {
+    //            String name = ifNames[i];
+    //            JSONObject jso = new JSONObject();
+    //            NetInterfaceConfig ifconfig = sigar.getNetInterfaceConfig(name);
+    //            jso.put("name", name); // 网络设备名
+    //            jso.put("address", ifconfig.getAddress()); // IP地址
+    //            jso.put("mask", ifconfig.getNetmask()); // 子网掩码
+    //            if ((ifconfig.getFlags() & 1L) <= 0L) {
+    //                continue;
+    //            }
+    //            NetInterfaceStat ifstat = sigar.getNetInterfaceStat(name);
+    //            jso.put("rx.packets", ifstat.getRxPackets());// 接收的总包裹数
+    //            jso.put("tx.packets", ifstat.getTxPackets());// 发送的总包裹数
+    //            jso.put("rx.bytes", ifstat.getRxBytes());// 接收到的总字节数
+    //            jso.put("tx.bytes", ifstat.getTxBytes());// 发送的总字节数
+    //            jso.put("rx.errors", ifstat.getRxErrors());// 接收到的错误包数
+    //            jso.put("tx.errors", ifstat.getTxErrors());// 发送数据包时的错误数
+    //            jso.put("rx.dropped", ifstat.getRxDropped());// 接收时丢弃的包数
+    //            jso.put("tx.dropped", ifstat.getTxDropped());// 发送时丢弃的包数
+    //            jsonArray.add(jso);
+    //        }
+    //        jsonObject.put("net", jsonArray);
+    //    } catch (Exception e) {
+    //        e.printStackTrace();
+    //    }
+    //    return Result.createWithModel(jsonObject);
+    //}
+
+    ///**
+    // * 获取网卡信息
+    // */
+    //public static Result<JSONObject> getEthernet() {
+    //    JSONObject jsonObject = new JSONObject();
+    //    try {
+    //        Sigar sigar = new Sigar();
+    //        String[] ifaces = sigar.getNetInterfaceList();
+    //        JSONArray jsonArray = new JSONArray();
+    //        for (int i = 0, len = ifaces.length; i < len; i++) {
+    //            NetInterfaceConfig cfg = sigar.getNetInterfaceConfig(ifaces[i]);
+    //            if (NetFlags.LOOPBACK_ADDRESS.equals(cfg.getAddress()) || (cfg.getFlags() & NetFlags.IFF_LOOPBACK) != 0 || NetFlags.NULL_HWADDR.equals(cfg.getHwaddr())) {
+    //                continue;
+    //            }
+    //            JSONObject jso = new JSONObject();
+    //            jso.put("address", cfg.getAddress());// IP地址
+    //            jso.put("broad.cast", cfg.getBroadcast());// 网关广播地址
+    //            jso.put("hwaddr", cfg.getHwaddr());// 网卡MAC地址
+    //            jso.put("net.mask", cfg.getNetmask());// 子网掩码
+    //            jso.put("description", cfg.getDescription());// 网卡描述信息
+    //            jso.put("type", cfg.getType());// 网卡类型
+    //            jsonArray.add(jso);
+    //        }
+    //        jsonObject.put("ethernet", jsonArray);
+    //    } catch (Exception e) {
+    //        e.printStackTrace();
+    //    }
+    //    return Result.createWithModel(jsonObject);
+    //}
 }

+ 1 - 1
src/main/java/com/nosum/deliver/posts/controller/ArchiveController.java

@@ -17,7 +17,7 @@ public class ArchiveController {
 
     @GetMapping("/archive/v1/list")
     public Result<PostsVO> getArchiveTotalByDateList(PostsVO postsVO) {
-        return postsService.getArchiveTotalByDateList(postsVO);
+         return postsService.getArchiveTotalByDateList(postsVO);
     }
 
     @GetMapping("/year/v1/list")

+ 0 - 59
src/main/java/com/nosum/deliver/posts/controller/PostsCommentsController.java

@@ -1,59 +0,0 @@
-package com.nosum.deliver.posts.controller;
-
-import com.nosum.common.annotation.LoginRequired;
-import com.nosum.common.base.domain.Result;
-import com.nosum.deliver.posts.domain.validator.InsertPostsComments;
-import com.nosum.deliver.posts.domain.validator.QueryPostsComments;
-import com.nosum.deliver.posts.domain.vo.PostsCommentsVO;
-import com.nosum.deliver.posts.service.PostsCommentsService;
-import com.nosum.system.enums.RoleEnum;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-/**
- * @author sumbytes
- * @since 2019-09-03
- */
-@RestController
-@RequestMapping("/comments")
-public class PostsCommentsController {
-
-    @Autowired
-    private PostsCommentsService postsCommentsService;
-
-    @LoginRequired(role = RoleEnum.USER)
-    @PostMapping("/comments/v1/add")
-    public Result savePostsComments(@Validated({InsertPostsComments.class}) @RequestBody PostsCommentsVO postsCommentsVO) {
-        return this.postsCommentsService.savePostsComments(postsCommentsVO);
-    }
-
-    @LoginRequired(role = RoleEnum.USER)
-    @PostMapping("/admin/v1/reply")
-    public Result replyComments(@RequestBody PostsCommentsVO postsCommentsVO) {
-        return this.postsCommentsService.replyComments(postsCommentsVO);
-    }
-
-    @LoginRequired
-    @DeleteMapping("/comments/v1/{id}")
-    public Result deletePostsComments(@PathVariable(value = "id") Long id) {
-        return this.postsCommentsService.deletePostsComments(id);
-    }
-
-    @LoginRequired
-    @GetMapping("/comments/v1/{id}")
-    public Result getPostsComment(@PathVariable(value = "id") Long id) {
-        return this.postsCommentsService.getPostsComment(id);
-    }
-
-    @GetMapping("/comments-posts/v1/list")
-    public Result getPostsCommentsByPostsIdList(@Validated({QueryPostsComments.class}) PostsCommentsVO postsCommentsVO) {
-        return this.postsCommentsService.getPostsCommentsByPostsIdList(postsCommentsVO);
-    }
-
-    @LoginRequired
-    @GetMapping("/comments/v1/list")
-    public Result getPostsCommentsList(PostsCommentsVO postsCommentsVO) {
-        return this.postsCommentsService.getPostsCommentsList(postsCommentsVO);
-    }
-}

+ 0 - 83
src/main/java/com/nosum/deliver/posts/controller/PostsController.java

@@ -1,26 +1,11 @@
 package com.nosum.deliver.posts.controller;
 
 import com.nosum.common.annotation.Explain;
-import com.nosum.common.annotation.LoginRequired;
-import com.nosum.common.annotation.OperateLog;
 import com.nosum.common.base.domain.Result;
-import com.nosum.common.enums.OperateEnum;
-import com.nosum.common.util.ThrowableUtils;
-import com.nosum.deliver.posts.domain.validator.CrawlerPosts;
-import com.nosum.deliver.posts.domain.validator.InsertPosts;
-import com.nosum.deliver.posts.domain.validator.UpdatePosts;
-import com.nosum.deliver.posts.domain.validator.UpdateStatus;
 import com.nosum.deliver.posts.domain.vo.PostsVO;
 import com.nosum.deliver.posts.service.PostsService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.BindingResult;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -32,84 +17,16 @@ public class PostsController {
     @Autowired
     private PostsService postsService;
 
-    @Explain("文章列表")
-    @OperateLog(module = "文章列表", code=OperateEnum.GET_POSTS_LIST)
-    @GetMapping("/posts/v1/list")
-    public Result<PostsVO> getPostsList(PostsVO postsVO) {
-        return postsService.getPostsList(postsVO);
-    }
-
-    @Explain("文章权重列表")
-    @OperateLog(module = "权重列表", code=OperateEnum.GET_POSTS_LIST)
-    @GetMapping("/weight/v1/list")
-    public Result<PostsVO> getWeightList(PostsVO postsVO) {
-        postsVO.setIsWeight(1);
-        return postsService.getPostsList(postsVO);
-    }
-
     @Explain("按照时间归档文章数量")
     @GetMapping("/archive/v1/list")
     public Result<PostsVO> getArchiveTotalByDateList(PostsVO postsVO) {
         return postsService.getArchiveTotalByDateList(postsVO);
     }
 
-    @Explain("查询热门文章")
-    @GetMapping("/hot/v1/list")
-    public Result getHotPostsList(PostsVO postsVO) {
-        return postsService.getHotPostsList(postsVO);
-    }
-
-    @OperateLog(module = "获取文章", code=OperateEnum.GET_POSTS_DETAIL)
-    @GetMapping("/posts/v1/{id}")
-    public Result getPosts(@PathVariable Long id) {
-        return this.postsService.getPosts(id);
-    }
-
-
     @Explain("查询文章统计")
     @GetMapping("/posts/v1/statistics")
     public Result getPostStatistics(){
         return this.postsService.getPostStatistics();
     }
 
-
-    @Explain("添加文章")
-    @LoginRequired
-    @PostMapping("/posts/v1/add")
-    public Result savePosts(@Validated({InsertPosts.class}) @RequestBody PostsVO postsVO, BindingResult result) {
-        ThrowableUtils.checkParamArgument(result);
-        return postsService.savePosts(postsVO);
-    }
-
-    @Explain("删除文章")
-    @LoginRequired
-    @DeleteMapping("/posts/v1/{id}")
-    public Result deletePosts(@PathVariable Long id) {
-        return this.postsService.deletePosts(id);
-    }
-
-    @Explain("修改文章")
-    @PutMapping("/posts/v1/update")
-    @LoginRequired
-    public Result updatePosts(@Validated({UpdatePosts.class}) @RequestBody PostsVO postsVO, BindingResult result) {
-        ThrowableUtils.checkParamArgument(result);
-        return this.postsService.updatePosts(postsVO);
-    }
-
-    @Explain("修改文章状态")
-    @PutMapping("/status/v1/update")
-    @LoginRequired
-    public Result updatePostsStatus(@Validated({UpdateStatus.class}) @RequestBody PostsVO postsVO, BindingResult result) {
-        ThrowableUtils.checkParamArgument(result);
-        return this.postsService.updatePostsStatus(postsVO);
-    }
-
-    @Explain("博客搬家")
-    @PostMapping("/posts/v1/crawler")
-    @LoginRequired
-    public Result getPlatformArticle(@Validated({CrawlerPosts.class}) @RequestBody PostsVO postsVO, BindingResult result) {
-        ThrowableUtils.checkParamArgument(result);
-        return this.postsService.getPlatformArticle(postsVO);
-    }
-
 }

+ 0 - 16
src/main/java/com/nosum/deliver/posts/dao/PostsAttributeDao.java

@@ -1,16 +0,0 @@
-package com.nosum.deliver.posts.dao;
-
-import com.nosum.deliver.posts.domain.po.PostsAttribute;
-import com.nosum.common.base.dao.BaseDao;
-
-/**
- * <p>
- *  Mapper 接口
- * </p>
- *
- * @author sumbytes
- * @since 2019-08-28
- */
-public interface PostsAttributeDao extends BaseDao<PostsAttribute> {
-
-}

+ 0 - 36
src/main/java/com/nosum/deliver/posts/dao/PostsCommentsDao.java

@@ -1,36 +0,0 @@
-package com.nosum.deliver.posts.dao;
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.nosum.deliver.posts.domain.po.PostsComments;
-import com.nosum.deliver.posts.domain.vo.PostsCommentsVO;
-import com.nosum.common.base.dao.BaseDao;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * <p>
- * 评论表 Mapper 接口
- * </p>
- * @author sumbytes
- * @since 2019-09-03
- */
-public interface PostsCommentsDao extends BaseDao<PostsComments> {
-
-    /**
-     * 查询评论列表
-     * @param page
-     * @param postsId
-     * @return
-     */
-    List<PostsCommentsVO> selectPostsCommentsByPostsIdList(Page<PostsCommentsVO> page, @Param("postsId") Long postsId);
-
-    /**
-     * 查询评论后台评论管理列表
-     * @param page
-     * @param keywords
-     * @return
-     */
-    List<PostsCommentsVO> selectPostsCommentsList(Page<PostsCommentsVO> page, @Param("postsComments") PostsCommentsVO postsCommentsVO);
-    List<PostsCommentsVO> selectPostsCommentsList(@Param("postsComments") PostsCommentsVO postsCommentsVO);
-}

+ 1 - 33
src/main/java/com/nosum/deliver/posts/dao/PostsDao.java

@@ -1,11 +1,7 @@
 package com.nosum.deliver.posts.dao;
 
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.nosum.deliver.posts.domain.po.Posts;
 import com.nosum.deliver.posts.domain.vo.PostsStatisticsVO;
 import com.nosum.deliver.posts.domain.vo.PostsVO;
-import com.nosum.common.base.dao.BaseDao;
-import org.apache.ibatis.annotations.Param;
 
 import java.time.LocalDateTime;
 import java.util.List;
@@ -14,25 +10,15 @@ import java.util.List;
  * @author sumbytes
  * @since 2019-08-28
  */
-public interface PostsDao extends BaseDao<Posts> {
-
-    /**
-     * 查询文章列表
-     * @param page
-     * @param condition
-     * @return
-     */
-    List<PostsVO> selectPostsList(Page<PostsVO> page, @Param("condition") PostsVO condition);
+public interface PostsDao{
 
     /**
      * 看板统计
-     * @return
      */
     PostsVO selectPostsTotal();
 
     /**
      * 按照时间进行归档统计某个时间有多个文章
-     * @return
      */
     List<PostsVO> selectArchiveTotalGroupDateList();
 
@@ -42,26 +28,8 @@ public interface PostsDao extends BaseDao<Posts> {
      */
     List<PostsVO> selectArchiveGroupYearList();
 
-    /**
-     * 自增浏览量
-     * @param id
-     * @return
-     */
-    int incrementView(@Param("id") Long id);
-
-    /**
-     * 自增评论量
-     * @param id
-     * @return
-     */
-    int incrementComments(@Param("id") Long id);
-
-    Posts selectOneById(Long id);
-
     List<PostsVO> selectByArchiveDate(LocalDateTime archiveDate);
 
-    List<PostsVO> selectHotPostsList(Page<PostsVO> page, @Param("condition") PostsVO condition);
-
     PostsStatisticsVO selectByStatistics();
 
 }

+ 0 - 12
src/main/java/com/nosum/deliver/posts/dao/PostsTagsDao.java

@@ -1,12 +0,0 @@
-package com.nosum.deliver.posts.dao;
-
-import com.nosum.deliver.posts.domain.po.PostsTags;
-import com.nosum.common.base.dao.BaseDao;
-
-/**
- * @author sumbytes
- * @since 2019-09-02
- */
-public interface PostsTagsDao extends BaseDao<PostsTags> {
-
-}

+ 2 - 14
src/main/java/com/nosum/deliver/posts/domain/po/Posts.java

@@ -1,10 +1,5 @@
 package com.nosum.deliver.posts.domain.po;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -16,21 +11,20 @@ import java.time.LocalDateTime;
  * <p>
  *
  * </p>
+ *
  * @author sumbytes
  * @since 2019-08-28
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
-@TableName("posts")
-public class Posts extends Model<Posts> {
+public class Posts {
 
     private static final long serialVersionUID = 1L;
 
     /**
      * 主键
      */
-    @TableId(value = "id", type = IdType.AUTO)
     private Long id;
 
     /**
@@ -101,12 +95,6 @@ public class Posts extends Model<Posts> {
     /**
      * 文章分类名称
      */
-    @TableField(exist = false)
     private String categoryName;
 
-    @Override
-    protected Serializable pkVal() {
-        return this.id;
-    }
-
 }

+ 0 - 40
src/main/java/com/nosum/deliver/posts/domain/po/PostsAttribute.java

@@ -1,40 +0,0 @@
-package com.nosum.deliver.posts.domain.po;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-import java.io.Serializable;
-
-/**
- * <p>
- *
- * </p>
- * @author sumbytes
- * @since 2019-08-28
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-@TableName("posts_attribute")
-public class PostsAttribute extends Model<PostsAttribute> {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
-
-    private String content;
-
-    private Long postsId;
-
-    @Override
-    protected Serializable pkVal() {
-        return this.id;
-    }
-
-}

+ 0 - 55
src/main/java/com/nosum/deliver/posts/domain/po/PostsComments.java

@@ -1,55 +0,0 @@
-package com.nosum.deliver.posts.domain.po;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-import java.io.Serializable;
-import java.time.LocalDateTime;
-
-/**
- * <p>
- * 评论表
- * </p>
- * @author sumbytes
- * @since 2019-09-03
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-@Accessors(chain = true)
-@TableName("posts_comments")
-public class PostsComments extends Model<PostsComments> {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
-
-    private Long authorId;
-
-    private String content;
-
-    private Long parentId;
-
-    private Integer status;
-
-    private Long postsId;
-
-    /**
-     * 层级结构
-     */
-    private String treePath;
-
-    private LocalDateTime createTime;
-
-
-    @Override
-    protected Serializable pkVal() {
-        return this.id;
-    }
-
-}

+ 0 - 60
src/main/java/com/nosum/deliver/posts/domain/po/PostsTags.java

@@ -1,60 +0,0 @@
-package com.nosum.deliver.posts.domain.po;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-import java.io.Serializable;
-import java.time.LocalDateTime;
-
-/**
- * @author sumbytes
- * @since 2019-09-02
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-@Accessors(chain = true)
-@TableName("posts_tags")
-public class PostsTags extends Model<PostsTags> {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
-
-    /**
-     * 名称
-     */
-    private Long tagsId;
-
-    /**
-     * 文章主键
-     */
-    private Long postsId;
-
-    /**
-     * 排序
-     */
-    private Integer sort;
-
-    /**
-     * 创建时间
-     */
-    private LocalDateTime createTime;
-
-    /**
-     * 更新时间
-     */
-    private LocalDateTime updateTime;
-
-
-    @Override
-    protected Serializable pkVal() {
-        return this.id;
-    }
-
-}

+ 0 - 10
src/main/java/com/nosum/deliver/posts/domain/validator/CrawlerPosts.java

@@ -1,10 +0,0 @@
-package com.nosum.deliver.posts.domain.validator;
-
-/**
- * @author: zsg
- * @description:
- * @date: 2019/9/30 20:47
- * @modified:
- */
-public interface CrawlerPosts {
-}

+ 0 - 8
src/main/java/com/nosum/deliver/posts/domain/validator/InsertPostsComments.java

@@ -1,8 +0,0 @@
-package com.nosum.deliver.posts.domain.validator;
-
-/**
- * @author: sumbytes
- * @date: 2019/9/30 19:13
- */
-public interface InsertPostsComments {
-}

+ 0 - 8
src/main/java/com/nosum/deliver/posts/domain/validator/QueryPostsComments.java

@@ -1,8 +0,0 @@
-package com.nosum.deliver.posts.domain.validator;
-
-/**
- * @author: sumbytes
- * @date: 2019/9/30 19:13
- */
-public interface QueryPostsComments {
-}

+ 0 - 23
src/main/java/com/nosum/deliver/posts/domain/vo/CNBlogsVO.java

@@ -1,23 +0,0 @@
-package com.nosum.deliver.posts.domain.vo;
-
-import lombok.Data;
-import lombok.experimental.Accessors;
-import us.codecraft.webmagic.model.annotation.ExtractBy;
-
-import java.util.List;
-
-/**
- * @description:
- * @author: sumbytes
- * @date: 2019/09/03 18:49
- */
-@Data
-@Accessors(chain = true)
-public class CNBlogsVO {
-
-    @ExtractBy("//*[@id=\"cb_post_title_url\"]/text()")
-    private String title;
-
-    @ExtractBy("//*[@id=\"cnblogs_post_body\"]")
-    private List<String> content;
-}

+ 0 - 26
src/main/java/com/nosum/deliver/posts/domain/vo/CSDNVO.java

@@ -1,26 +0,0 @@
-package com.nosum.deliver.posts.domain.vo;
-
-import lombok.Data;
-import lombok.experimental.Accessors;
-import us.codecraft.webmagic.model.annotation.ExtractBy;
-
-import java.util.List;
-
-/**
- * @author: zsg
- * @description:
- * @date: 2019/8/3 13:15
- * @modified:
- */
-
-@Data
-@Accessors(chain = true)
-public class CSDNVO {
-
-    @ExtractBy("//*[@id=\"mainBox\"]/main/div[1]/div/div/div[1]/h1/text()")
-    private String title;
-
-    @ExtractBy("//*[@id='content_views']")
-    private List<String> content;
-
-}

+ 0 - 26
src/main/java/com/nosum/deliver/posts/domain/vo/JianShuVO.java

@@ -1,26 +0,0 @@
-package com.nosum.deliver.posts.domain.vo;
-
-import lombok.Data;
-import lombok.experimental.Accessors;
-import us.codecraft.webmagic.model.annotation.ExtractBy;
-
-import java.util.List;
-
-/**
- * @author: zsg
- * @description:
- * @date: 2019/8/3 13:15
- * @modified:
- */
-
-@Data
-@Accessors(chain = true)
-public class JianShuVO {
-
-    @ExtractBy("//*[@id='__next']/div[1]/div/div/section[1]/h1/text()")
-    private String title;
-
-    @ExtractBy("//*[@id='__next']/div[1]/div/div/section[1]/article")
-    private List<String> content;
-
-}

+ 0 - 26
src/main/java/com/nosum/deliver/posts/domain/vo/JueJinVO.java

@@ -1,26 +0,0 @@
-package com.nosum.deliver.posts.domain.vo;
-
-import lombok.Data;
-import lombok.experimental.Accessors;
-import us.codecraft.webmagic.model.annotation.ExtractBy;
-
-import java.util.List;
-
-/**
- * @author: zsg
- * @description:
- * @date: 2019/8/3 13:15
- * @modified:
- */
-
-@Data
-@Accessors(chain = true)
-public class JueJinVO {
-
-    @ExtractBy("//*[@id='juejin']/div[2]/main/div/div[1]/article/h1/text()")
-    private String title;
-
-    @ExtractBy("//*[@class='article-content']")
-    private List<String> content;
-
-}

+ 0 - 18
src/main/java/com/nosum/deliver/posts/domain/vo/PostsAttributeVO.java

@@ -1,18 +0,0 @@
-package com.nosum.deliver.posts.domain.vo;
-
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-/**
- * @author sumbytes
- * @since 2019-08-28
- */
-@Data
-@Accessors(chain = true)
-public class PostsAttributeVO {
-
-    private Long id;
-
-    private String content;
-
-}

+ 0 - 48
src/main/java/com/nosum/deliver/posts/domain/vo/PostsCommentsVO.java

@@ -1,48 +0,0 @@
-package com.nosum.deliver.posts.domain.vo;
-
-import com.nosum.deliver.posts.domain.validator.InsertPostsComments;
-import com.nosum.deliver.posts.domain.validator.QueryPostsComments;
-import com.nosum.common.base.domain.vo.BaseVO;
-import com.nosum.common.validator.annotion.NotBlank;
-import com.nosum.common.validator.annotion.NotNull;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import java.time.LocalDateTime;
-
-/**
- * <p>
- * 评论表
- * </p>
- * @author sumbytes
- * @since 2019-09-03
- */
-@Data
-@Accessors(chain = true)
-public class PostsCommentsVO extends BaseVO<PostsCommentsVO> {
-
-    private Long authorId;
-
-    @NotBlank(groups = {InsertPostsComments.class})
-    private String content;
-
-    private Long parentId;
-
-    private Integer status;
-
-    @NotNull(groups = {InsertPostsComments.class, QueryPostsComments.class})
-    private Long postsId;
-
-    private String treePath;
-
-    private String authorName;
-
-    private String authorAvatar;
-
-    private String parentUserName;
-
-    private LocalDateTime createTime;
-
-    private String postTitle;
-
-}

+ 2 - 15
src/main/java/com/nosum/deliver/posts/domain/vo/PostsVO.java

@@ -1,14 +1,8 @@
 package com.nosum.deliver.posts.domain.vo;
 
-import com.nosum.deliver.category.domain.vo.TagsVO;
-import com.nosum.deliver.posts.domain.validator.CrawlerPosts;
-import com.nosum.deliver.posts.domain.validator.InsertPosts;
-import com.nosum.deliver.posts.domain.validator.UpdatePosts;
-import com.nosum.deliver.posts.domain.validator.UpdateStatus;
 import com.nosum.common.base.domain.vo.BaseVO;
-import com.nosum.common.validator.annotion.IntegerNotNull;
-import com.nosum.common.validator.annotion.NotBlank;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
 import java.time.LocalDateTime;
@@ -23,18 +17,16 @@ import java.util.List;
  */
 @Data
 @Accessors(chain = true)
-public class PostsVO extends BaseVO<PostsVO> {
+public class PostsVO  {
 
     /**
      * 文章标题
      */
-    @NotBlank(groups = {InsertPosts.class, UpdatePosts.class})
     private String title;
 
     /**
      * 文章内容
      */
-    @NotBlank(groups = {InsertPosts.class, UpdatePosts.class})
     private String content;
 
     /**
@@ -50,7 +42,6 @@ public class PostsVO extends BaseVO<PostsVO> {
     /**
      * 状态 1 草稿 2 发布
      */
-    @IntegerNotNull(groups = {InsertPosts.class, UpdatePosts.class, UpdateStatus.class})
     private Integer status;
 
     /**
@@ -71,7 +62,6 @@ public class PostsVO extends BaseVO<PostsVO> {
     /**
      * 外链地址
      */
-    @NotBlank(groups = {CrawlerPosts.class})
     private String sourceUri;
 
     /**
@@ -103,9 +93,6 @@ public class PostsVO extends BaseVO<PostsVO> {
 
     private String author;
 
-    private List<TagsVO> tagsList;
-
-    @IntegerNotNull(groups = {CrawlerPosts.class})
     private Integer platformType;
 
     private Integer commentsTotal;

+ 0 - 26
src/main/java/com/nosum/deliver/posts/domain/vo/SegmentFaultVO.java

@@ -1,26 +0,0 @@
-package com.nosum.deliver.posts.domain.vo;
-
-import lombok.Data;
-import lombok.experimental.Accessors;
-import us.codecraft.webmagic.model.annotation.ExtractBy;
-
-import java.util.List;
-
-/**
- * @author: zsg
- * @description:
- * @date: 2019/8/3 13:15
- * @modified:
- */
-
-@Data
-@Accessors(chain = true)
-public class SegmentFaultVO {
-
-    @ExtractBy("//*[@id='articleTitle']/a/text()")
-    private String title;
-
-    @ExtractBy("/html/body/div[3]/div[2]/div/div[1]/div[3]//*")
-    private List<String> content;
-
-}

+ 0 - 42
src/main/java/com/nosum/deliver/posts/service/PostsCommentsService.java

@@ -1,42 +0,0 @@
-package com.nosum.deliver.posts.service;
-
-import com.nosum.common.base.domain.Result;
-import com.nosum.common.base.service.BaseService;
-import com.nosum.deliver.posts.domain.po.PostsComments;
-import com.nosum.deliver.posts.domain.vo.PostsCommentsVO;
-
-/**
- * <p>
- * 评论表 服务类
- * </p>
- * @author sumbytes
- * @since 2019-09-03
- */
-public interface PostsCommentsService extends BaseService<PostsComments> {
-
-    /**
-     * 新增评论
-     */
-    Result savePostsComments(PostsCommentsVO postsCommentsVO);
-
-    /**
-     * 根据文章的主键查询评论列表
-     */
-    Result getPostsCommentsByPostsIdList(PostsCommentsVO postsCommentsVO);
-
-    /**
-     * 查询评论列表
-     */
-    Result getPostsCommentsList(PostsCommentsVO postsCommentsVO);
-
-    /**
-     * 删除评论
-     */
-    Result deletePostsComments(Long id);
-
-
-    Result getPostsComment(Long id);
-
-    Result replyComments(PostsCommentsVO postsCommentsVO);
-
-}

+ 1 - 44
src/main/java/com/nosum/deliver/posts/service/PostsService.java

@@ -1,41 +1,9 @@
 package com.nosum.deliver.posts.service;
 
 import com.nosum.common.base.domain.Result;
-import com.nosum.common.base.service.BaseService;
-import com.nosum.deliver.posts.domain.po.Posts;
 import com.nosum.deliver.posts.domain.vo.PostsVO;
 
-public interface PostsService extends BaseService<Posts> {
-
-    /**
-     * 保存文章
-     */
-    Result savePosts(PostsVO postsVO);
-
-    /**
-     * 编辑文章
-     */
-    Result updatePosts(PostsVO postsVO);
-
-    /**
-     * 删除文章
-     */
-    Result deletePosts(Long id);
-
-    /**
-     * 查询单个文章
-     */
-    Result getPosts(Long id);
-
-    /**
-     * 查询文章的列表
-     */
-    Result<PostsVO> getPostsList(PostsVO postsVO);
-
-    /**
-     * 博客搬家 抓取其他平台我的博客
-     */
-    Result getPlatformArticle(PostsVO postsVO);
+public interface PostsService {
 
     /**
      * 按照时间归档文章数量
@@ -47,17 +15,6 @@ public interface PostsService extends BaseService<Posts> {
      */
     Result getArchiveGroupYearList(PostsVO postsVO);
 
-    /**
-     * 更新文章的状态
-     */
-    Result updatePostsStatus(PostsVO postsVO);
-
-
-    /**
-     *  查询热门文章
-     */
-    Result getHotPostsList(PostsVO postsVO);
-
     Result getPostStatistics();
 
 

+ 0 - 134
src/main/java/com/nosum/deliver/posts/service/impl/PostsCommentsServiceImpl.java

@@ -1,134 +0,0 @@
-package com.nosum.deliver.posts.service.impl;
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.nosum.deliver.auth.dao.AuthUserDao;
-import com.nosum.deliver.auth.domain.po.AuthUser;
-import com.nosum.common.base.domain.Result;
-import com.nosum.common.base.domain.vo.UserSessionVO;
-import com.nosum.common.base.service.impl.BaseServiceImpl;
-import com.nosum.common.constant.Constants;
-import com.nosum.common.enums.ErrorEnum;
-import com.nosum.common.util.ExceptionUtil;
-import com.nosum.common.util.PageUtil;
-import com.nosum.common.util.SessionUtil;
-import com.nosum.deliver.posts.dao.PostsCommentsDao;
-import com.nosum.deliver.posts.dao.PostsDao;
-import com.nosum.deliver.posts.domain.po.PostsComments;
-import com.nosum.deliver.posts.domain.vo.PostsCommentsVO;
-import com.nosum.deliver.posts.service.PostsCommentsService;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.time.LocalDateTime;
-import java.util.List;
-import java.util.Optional;
-
-/**
- * <p>
- * 评论表 服务实现类
- * </p>
- * @author sumbytes
- * @since 2019-09-03
- */
-@Service
-public class PostsCommentsServiceImpl extends BaseServiceImpl<PostsCommentsDao, PostsComments> implements PostsCommentsService {
-
-    @Autowired
-    private PostsCommentsDao postsCommentsDao;
-
-    @Autowired
-    private PostsDao postsDao;
-
-    @Autowired
-    private AuthUserDao authUserDao;
-
-    @Override
-    public Result savePostsComments(PostsCommentsVO postsCommentsVO) {
-        UserSessionVO userSessionInfo = SessionUtil.getUserSessionInfo();
-        PostsComments postsComments = new PostsComments();
-        postsComments.setAuthorId(userSessionInfo.getId());
-        postsComments.setContent(postsCommentsVO.getContent());
-        postsComments.setPostsId(postsCommentsVO.getPostsId());
-        postsComments.setCreateTime(LocalDateTime.now());
-
-        String treePath;
-        if (postsCommentsVO.getParentId() == null) {
-            this.postsCommentsDao.insert(postsComments);
-            treePath = postsComments.getId() + Constants.TREE_PATH;
-        } else {
-            PostsComments parentPostsComments = this.postsCommentsDao.selectById(postsCommentsVO.getParentId());
-            if (parentPostsComments == null) {
-                ExceptionUtil.rollback(ErrorEnum.DATA_NO_EXIST);
-            }
-
-            postsComments.setParentId(postsCommentsVO.getParentId());
-            this.postsCommentsDao.insert(postsComments);
-
-            treePath = parentPostsComments.getTreePath() + postsComments.getId() + Constants.TREE_PATH;
-        }
-
-        this.postsCommentsDao.updateById(postsComments.setTreePath(treePath));
-
-        this.postsDao.incrementComments( postsCommentsVO.getPostsId());
-
-        return Result.createWithSuccessMessage();
-    }
-
-
-    @Override
-    public Result replyComments(PostsCommentsVO postsCommentsVO) {
-        // 查询用户信息
-        UserSessionVO userSessionInfo = SessionUtil.getUserSessionInfo();
-        AuthUser authUser = authUserDao.selectById(userSessionInfo.getId());
-        PostsComments postsComments=postsCommentsDao.selectById(postsCommentsVO.getParentId());
-        // 准备更新前的参数内容
-        postsComments.setParentId(postsCommentsVO.getParentId())
-                .setContent(postsCommentsVO.getContent())
-                .setAuthorId(authUser.getId())
-                .setCreateTime(LocalDateTime.now())
-                .setId(null);
-        // 添加评论
-        this.postsCommentsDao.insert(postsComments);
-        // 增加完成后会默认获取id,此时需要将id,增加到层级结构当中
-        this.postsCommentsDao.updateById(postsComments.setTreePath(postsComments.getTreePath() + postsComments.getId() + Constants.TREE_PATH));
-        // 为文章添加评论数
-        this.postsDao.incrementComments( postsCommentsVO.getPostsId());
-        return Result.createWithSuccessMessage();
-    }
-
-    @Override
-    public Result getPostsCommentsByPostsIdList(PostsCommentsVO postsCommentsVO) {
-
-        Page page = Optional.ofNullable(PageUtil.checkAndInitPage(postsCommentsVO)).orElse(PageUtil.initPage());
-        List<PostsCommentsVO> postsCommentsVOLis = this.postsCommentsDao.selectPostsCommentsByPostsIdList(page, postsCommentsVO.getPostsId());
-
-        return Result.createWithPaging(postsCommentsVOLis, PageUtil.initPageInfo(page));
-    }
-
-    @Override
-    public Result getPostsCommentsList(PostsCommentsVO postsCommentsVO) {
-        Page page = Optional.ofNullable(PageUtil.checkAndInitPage(postsCommentsVO)).orElse(PageUtil.initPage());
-        if (StringUtils.isNotBlank(postsCommentsVO.getKeywords())) {
-            postsCommentsVO.setKeywords("%" + postsCommentsVO.getKeywords() + "%");
-        }
-        List<PostsCommentsVO> postsCommentsVOLis = this.postsCommentsDao.selectPostsCommentsList(page, postsCommentsVO);
-        return Result.createWithPaging(postsCommentsVOLis, PageUtil.initPageInfo(page));
-    }
-
-    @Override
-    public Result deletePostsComments(Long id) {
-        this.postsCommentsDao.deleteById(id);
-        return Result.createWithSuccessMessage();
-}
-
-    @Override
-    public Result getPostsComment(Long id) {
-        ExceptionUtil.isRollback(id==null,ErrorEnum.PARAM_ERROR);
-        List<PostsCommentsVO> postsCommentsVOLis = this.postsCommentsDao.selectPostsCommentsList(new PostsCommentsVO().setId(id));
-        if (postsCommentsVOLis!=null && postsCommentsVOLis.size()>0){
-            return Result.createWithModel(postsCommentsVOLis.get(0));
-        }
-        return Result.createWithError();
-    }
-}

+ 15 - 292
src/main/java/com/nosum/deliver/posts/service/impl/PostsServiceImpl.java

@@ -1,317 +1,40 @@
 package com.nosum.deliver.posts.service.impl;
 
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.nosum.deliver.category.dao.TagsDao;
-import com.nosum.deliver.category.domain.po.Tags;
-import com.nosum.deliver.category.domain.vo.TagsVO;
-//import com.nosum.deliver.log.dao.AuthUserLogDao;
-//import com.nosum.deliver.log.domain.vo.AuthUserLogVO;
-import com.nosum.deliver.posts.domain.vo.*;
 import com.nosum.common.base.domain.Result;
-import com.nosum.common.base.domain.vo.BaseVO;
-import com.nosum.common.base.domain.vo.UserSessionVO;
-import com.nosum.common.constant.Constants;
-import com.nosum.common.enums.ErrorEnum;
-import com.nosum.common.enums.OperateEnum;
-import com.nosum.common.util.*;
-import com.nosum.deliver.posts.dao.PostsAttributeDao;
-import com.nosum.deliver.posts.dao.PostsDao;
-import com.nosum.deliver.posts.dao.PostsTagsDao;
-import com.nosum.deliver.posts.domain.po.Posts;
-import com.nosum.deliver.posts.domain.po.PostsAttribute;
-import com.nosum.deliver.posts.domain.po.PostsTags;
+import com.nosum.deliver.posts.domain.vo.PostsVO;
 import com.nosum.deliver.posts.service.PostsService;
-import com.nosum.system.enums.PlatformEnum;
-import com.overzealous.remark.Remark;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-import us.codecraft.webmagic.Site;
-import us.codecraft.webmagic.Spider;
-import us.codecraft.webmagic.model.OOSpider;
-
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
 
 @Service
 @Slf4j
-public class PostsServiceImpl extends ServiceImpl<PostsDao, Posts> implements PostsService {
-
-    @Autowired
-    private PostsDao postsDao;
-
-    @Autowired
-    private PostsAttributeDao postsAttributeDao;
-
-    @Autowired
-    private TagsDao tagsDao;
-
-    @Autowired
-    private PostsTagsDao postsTagsDao;
-
-//    @Autowired
-//    private AuthUserLogDao authUserLogDao;
-
-    @Override
-    public Result savePosts(PostsVO postsVO) {
-
-        UserSessionVO userSessionInfo = SessionUtil.getUserSessionInfo();
-        String html = Markdown2HtmlUtil.html(postsVO.getContent());
-
-        Posts posts = new Posts();
-        posts.setTitle(postsVO.getTitle()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now()).setThumbnail(postsVO.getThumbnail());
-        posts.setStatus(postsVO.getStatus()).setSummary(PreviewTextUtils.getText(html, 126)).setIsComment(postsVO.getIsComment())
-                .setAuthorId(userSessionInfo.getId()).setCategoryId(postsVO.getCategoryId()).setWeight(postsVO.getWeight());
-        postsDao.insert(posts);
-        postsVO.setId(posts.getId());
-
-        postsAttributeDao.insert(new PostsAttribute().setContent(postsVO.getContent()).setPostsId(posts.getId()));
-        List<TagsVO> tagsList = postsVO.getTagsList();
-        if (!CollectionUtils.isEmpty(tagsList)) {
-            tagsList.forEach(tagsVO -> {
-                if (tagsVO.getId() == null) {
-                    Tags tags = new Tags().setName(tagsVO.getName()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());// saveMenu
-                    tagsDao.insert(tags);
-                    tagsVO.setId(tags.getId());
-                }
-                postsTagsDao.insert(new PostsTags().setPostsId(posts.getId()).setTagsId(tagsVO.getId()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now()));
-            });
-        }
-        return Result.createWithSuccessMessage();
-    }
-
-    @Override
-    public Result updatePosts(PostsVO postsVO) {
-
-        UserSessionVO userSessionInfo = SessionUtil.getUserSessionInfo();
-        String html = Markdown2HtmlUtil.html(postsVO.getContent());
-
-        Posts posts1 = postsDao.selectOne(new LambdaQueryWrapper<Posts>().eq(Posts::getId, postsVO.getId()));
-        if (posts1 == null) {
-            ExceptionUtil.rollback(ErrorEnum.DATA_NO_EXIST);
-        }
-
-        posts1.setTitle(postsVO.getTitle()).setUpdateTime(LocalDateTime.now()).setThumbnail(postsVO.getThumbnail());
-        posts1.setStatus(postsVO.getStatus()).setSyncStatus(Constants.NO).setSummary(PreviewTextUtils.getText(html, 126)).setIsComment(postsVO.getIsComment())
-                .setAuthorId(userSessionInfo.getId()).setCategoryId(postsVO.getCategoryId()).setWeight(postsVO.getWeight());
-
-        postsDao.updateById(posts1);
-        Wrapper<PostsAttribute> wrapper = new LambdaUpdateWrapper<PostsAttribute>().eq(PostsAttribute::getPostsId, posts1.getId());
-        if (postsAttributeDao.selectCount(wrapper) > 0) {
-            postsAttributeDao.update(new PostsAttribute().setContent(postsVO.getContent()), wrapper);
-        } else {
-            postsAttributeDao.insert(new PostsAttribute().setContent(postsVO.getContent()).setPostsId(posts1.getId()));
-        }
-
-        List<TagsVO> tagsList = postsVO.getTagsList();
-
-        if (!CollectionUtils.isEmpty(tagsList)) {
-            List<PostsTags> originalList = postsTagsDao.selectList(new LambdaQueryWrapper<PostsTags>().eq(PostsTags::getPostsId, posts1.getId()));
-            List<PostsTags> categoryTagsList = originalList.stream().filter(postsTags -> !postsVO.getTagsList().stream().map(BaseVO::getId).collect(Collectors.toList())
-                    .contains(postsTags.getTagsId())).collect(Collectors.toList());
-
-            if (!CollectionUtils.isEmpty(categoryTagsList)) {
-                categoryTagsList.forEach(categoryTags -> {
-                    postsTagsDao.deleteById(categoryTags.getId());
-                });
-            }
-
-            tagsList.forEach(tagsVO -> {
-                if (tagsVO.getId() == null) {
-                    // saveMenu
-                    Tags tags = new Tags().setName(tagsVO.getName()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
-                    tagsDao.insert(tags);
-                    tagsVO.setId(tags.getId());
-                    postsTagsDao.insert(new PostsTags().setPostsId(posts1.getId()).setTagsId(tagsVO.getId()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now()));
-                } else {
-                    PostsTags postsTags = postsTagsDao.selectOne(new LambdaQueryWrapper<PostsTags>().eq(PostsTags::getPostsId, posts1.getId()).eq(PostsTags::getTagsId, tagsVO.getId()));
-                    if (postsTags == null) {
-                        postsTagsDao.insert(new PostsTags().setPostsId(posts1.getId()).setTagsId(tagsVO.getId()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now()));
-                    }
-                }
-            });
-        } else {
-
-            postsTagsDao.delete(new LambdaQueryWrapper<PostsTags>().eq(PostsTags::getPostsId, posts1.getId()));
-        }
-        return Result.createWithSuccessMessage();
-    }
-
-    @Override
-    public Result deletePosts(Long id) {
-
-        Posts posts = postsDao.selectById(id);
-        if (posts == null) {
-            ExceptionUtil.rollback(ErrorEnum.DATA_NO_EXIST);
-        }
+public class PostsServiceImpl implements PostsService {
 
-        postsDao.deleteById(id);
-        postsAttributeDao.delete(new LambdaUpdateWrapper<PostsAttribute>().eq(PostsAttribute::getPostsId, id));
-        postsTagsDao.delete(new LambdaUpdateWrapper<PostsTags>().eq(PostsTags::getPostsId, id));
-
-        return Result.createWithSuccessMessage();
-    }
-
-    @Override
-    public Result getPosts(Long id) {
-        Posts posts = postsDao.selectOneById(id);
-        if (posts == null) {
-            ExceptionUtil.rollback(ErrorEnum.DATA_NO_EXIST);
-        }
-
-        PostsVO postsVO = new PostsVO();
-        postsVO.setId(posts.getId())
-                .setCreateTime(posts.getCreateTime())
-                .setSummary(posts.getSummary())
-                .setTitle(posts.getTitle())
-                .setThumbnail(posts.getThumbnail())
-                .setIsComment(posts.getIsComment())
-                .setViews(posts.getViews())
-                .setComments(posts.getComments())
-                .setCategoryId(posts.getCategoryId())
-                .setWeight(posts.getWeight())
-                .setCategoryName(posts.getCategoryName());
-
-        PostsAttribute postsAttribute = postsAttributeDao.selectOne(new LambdaQueryWrapper<PostsAttribute>().eq(PostsAttribute::getPostsId, posts.getId()));
-        if (postsAttribute != null) {
-            postsVO.setContent(postsAttribute.getContent());
-        }
-        List<PostsTags> postsTagsList = postsTagsDao.selectList(new LambdaQueryWrapper<PostsTags>().eq(PostsTags::getPostsId, posts.getId()));
-        List<TagsVO> tagsVOList = new ArrayList<>();
-        if (!CollectionUtils.isEmpty(postsTagsList)) {
-            postsTagsList.forEach(postsTags -> {
-                Tags tags = tagsDao.selectById(postsTags.getTagsId());
-                tagsVOList.add(new TagsVO().setId(tags.getId()).setName(tags.getName()));
-            });
-        }
-
-        postsVO.setTagsList(tagsVOList);
-
-        postsDao.incrementView(posts.getId());
-        return Result.createWithModel(postsVO);
-    }
-
-    @Override
-    public Result<PostsVO> getPostsList(PostsVO postsVO) {
-        postsVO = Optional.ofNullable(postsVO).orElse(new PostsVO());
-        Page page = Optional.of(PageUtil.checkAndInitPage(postsVO)).orElse(PageUtil.initPage());
-        if (StringUtils.isNotBlank(postsVO.getKeywords())) {
-            postsVO.setKeywords("%" + postsVO.getKeywords() + "%");
-        }
-        if (StringUtils.isNoneBlank(postsVO.getTitle())) {
-            postsVO.setTitle("%" + postsVO.getTitle() + "%");
-        }
-        List<PostsVO> postsVOList = postsDao.selectPostsList(page, postsVO);
-        if (!CollectionUtils.isEmpty(postsVOList)) {
-            postsVOList.forEach(postsVO1 -> {
-                List<PostsTags> postsTagsList = postsTagsDao.selectList(new LambdaQueryWrapper<PostsTags>().eq(PostsTags::getPostsId, postsVO1.getId()));
-                List<TagsVO> tagsVOList = new ArrayList<>();
-                if (!CollectionUtils.isEmpty(postsTagsList)) {
-                    postsTagsList.forEach(postsTags -> {
-                        Tags tags = tagsDao.selectById(postsTags.getTagsId());
-                        tagsVOList.add(new TagsVO().setId(tags.getId()).setName(tags.getName()));
-                    });
-                }
-                postsVO1.setTagsList(tagsVOList);
-            });
-        }
-
-        return Result.createWithPaging(postsVOList, PageUtil.initPageInfo(page));
-    }
-
-    @Override
-    public Result getPlatformArticle(PostsVO postsVO) {
-        crawler(postsVO);
-        return Result.createWithModel(postsVO);
-    }
+    //@Autowired
+    //private PostsDao postsDao;
 
     @Override
     public Result<PostsVO> getArchiveTotalByDateList(PostsVO postsVO) {
-        List<PostsVO> postsVOList = postsDao.selectArchiveTotalGroupDateList();
-        postsVOList.forEach(obj -> {
-            // 查询每一个时间点中的文章
-            obj.setArchivePosts(postsDao.selectByArchiveDate(obj.getArchiveDate()));
-        });
-        return Result.createWithModels(postsVOList);
+        //List<PostsVO> postsVOList = postsDao.selectArchiveTotalGroupDateList();
+        //postsVOList.forEach(obj -> {
+        //    // 查询每一个时间点中的文章
+        //    obj.setArchivePosts(postsDao.selectByArchiveDate(obj.getArchiveDate()));
+        //});
+        //return Result.createWithModels(postsVOList);
+        return null;
     }
 
     @Override
     public Result getArchiveGroupYearList(PostsVO postsVO) {
-        List<PostsVO> postsVOList = postsDao.selectArchiveGroupYearList();
-        return Result.createWithModels(postsVOList);
-    }
-
-    @Override
-    public Result updatePostsStatus(PostsVO postsVO) {
-        postsDao.updateById(new Posts().setId(postsVO.getId()).setStatus(postsVO.getStatus()).setUpdateTime(LocalDateTime.now()));
-        return Result.createWithSuccessMessage();
-    }
-
-    @Override
-    public Result getHotPostsList(PostsVO postsVO) {
-//        postsVO = Optional.ofNullable(postsVO).orElse(new PostsVO());
-//        Page page = Optional.of(PageUtil.checkAndInitPage(postsVO)).orElse(PageUtil.initPage());
-//        if (StringUtils.isNotBlank(postsVO.getKeywords())) {
-//            postsVO.setKeywords("%" + postsVO.getKeywords() + "%");
-//        }
-//        List<AuthUserLogVO> logVOList = authUserLogDao.selectListByCode(OperateEnum.GET_POSTS_DETAIL.getCode());
-//        List<Long> ids = new ArrayList<>();
-//        logVOList.forEach(obj -> {
-//            JSONObject json = JSONObject.parseObject(obj.getParameter());
-//            ids.add(json.getLong("id"));
-//        });
-//        postsDao.selectPage(page, new QueryWrapper<Posts>().in("id", ids));
-//        return Result.createWithPaging(page.getRecords(), PageUtil.initPageInfo(page));
+        //List<PostsVO> postsVOList = postsDao.selectArchiveGroupYearList();
+        //return Result.createWithModels(postsVOList);
         return null;
     }
 
-
     @Override
     public Result getPostStatistics() {
-        return Result.createWithModel(postsDao.selectByStatistics());
+        //return Result.createWithModel(postsDao.selectByStatistics());
+        return null;
     }
 
-    private void crawler(PostsVO postsVO) {
-        Class platformClass = PlatformEnum.getEnumTypeMap().get(postsVO.getPlatformType()).getPlatformClass();
-        Spider spider = OOSpider.create(Site.me(), platformClass).setDownloader(new HttpClientDownloader());
-        Object object = spider.get(postsVO.getSourceUri());
-
-        String join = "";
-        if (postsVO.getPlatformType().equals(PlatformEnum.JIAN_SHU.getType())) {
-            JianShuVO jianShuVO = (JianShuVO) object;
-            postsVO.setTitle(jianShuVO.getTitle());
-            join = String.join("", jianShuVO.getContent());
-        } else if (postsVO.getPlatformType().equals(PlatformEnum.JUE_JIN.getType())) {
-            JueJinVO jueJinVO = (JueJinVO) object;
-            postsVO.setTitle(jueJinVO.getTitle());
-            join = String.join("", jueJinVO.getContent());
-        } else if (postsVO.getPlatformType().equals(PlatformEnum.SEGMENT_FAULT.getType())) {
-            SegmentFaultVO segmentFaultVO = (SegmentFaultVO) object;
-            postsVO.setTitle(segmentFaultVO.getTitle());
-            join = String.join("", segmentFaultVO.getContent());
-        } else if (postsVO.getPlatformType().equals(PlatformEnum.CSDN.getType())) {
-            CSDNVO csdnVO = (CSDNVO) object;
-            postsVO.setTitle(csdnVO.getTitle());
-            join = String.join("", csdnVO.getContent());
-        } else if (postsVO.getPlatformType().equals(PlatformEnum.CN_BLOGS.getType())) {
-            CNBlogsVO cnBlogsVO = (CNBlogsVO) object;
-            postsVO.setTitle(cnBlogsVO.getTitle());
-            join = String.join("", cnBlogsVO.getContent());
-        } else {
-            ExceptionUtil.rollback(ErrorEnum.PARAM_ERROR);
-        }
-        String converted = new Remark().convertFragment(join);
-        postsVO.setContent(converted);
-    }
 }

+ 0 - 70
src/main/java/com/nosum/system/enums/PlatformEnum.java

@@ -1,70 +0,0 @@
-package com.nosum.system.enums;
-
-import com.nosum.deliver.posts.domain.vo.CNBlogsVO;
-import com.nosum.deliver.posts.domain.vo.CSDNVO;
-import com.nosum.deliver.posts.domain.vo.JianShuVO;
-import com.nosum.deliver.posts.domain.vo.JueJinVO;
-import com.nosum.deliver.posts.domain.vo.SegmentFaultVO;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author: sumbytes
- * @date: 2019/09/03 14:33
- */
-public enum PlatformEnum {
-
-    /**
-     * 掘金
-     */
-    JUE_JIN(1, JueJinVO.class),
-
-    /**
-     * 简书
-     */
-    JIAN_SHU(2, JianShuVO.class),
-
-    /**
-     * CSDN
-     */
-    CSDN(3, CSDNVO.class),
-
-    /**
-     * 思否
-     */
-    SEGMENT_FAULT(4, SegmentFaultVO.class),
-
-    /**
-     * 博客园
-     */
-    CN_BLOGS(5, CNBlogsVO.class);
-
-    private static final Map<Integer, PlatformEnum> enumTypeMap = new HashMap<>();
-
-    static {
-        for (PlatformEnum platformEnum : PlatformEnum.values()) {
-            enumTypeMap.put(platformEnum.type, platformEnum);
-        }
-    }
-
-    private final Integer type;
-    private final Class platformClass;
-
-    PlatformEnum(Integer type, Class platformClass) {
-        this.type = type;
-        this.platformClass = platformClass;
-    }
-
-    public Integer getType() {
-        return type;
-    }
-
-    public Class getPlatformClass() {
-        return platformClass;
-    }
-
-    public static Map<Integer, PlatformEnum> getEnumTypeMap() {
-        return enumTypeMap;
-    }
-}

+ 9 - 7
src/main/java/com/nosum/system/schedule/SchedulerTask.java

@@ -1,29 +1,31 @@
 package com.nosum.system.schedule;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.nosum.deliver.auth.dao.AuthTokenDao;
-import com.nosum.deliver.auth.domain.po.AuthToken;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import java.time.LocalDateTime;
 
+
 /**
- * @Author:sumbytes
- * @Date:2018/09/27 12:52
+ * 定时清理过期 TOKEN
+ *
+ * @author Young
  */
 @Component
 @Slf4j
 public class SchedulerTask {
 
     @Autowired
-    private AuthTokenDao authTokenDao;
+    private MongoTemplate mongoTemplate;
 
     @Scheduled(cron = "0 0/1 * * * ?")
     private void scanToken() {
         log.debug(" {} 扫描过期Token", LocalDateTime.now());
-        authTokenDao.delete(new LambdaQueryWrapper<AuthToken>().le(AuthToken::getExpireTime, LocalDateTime.now()));
+        mongoTemplate.remove(Query.query(Criteria.where("expireTime").lte(LocalDateTime.now())));
     }
 }

+ 0 - 13
src/main/resources/mapper/auth/AuthTokenMapper.xml

@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.nosum.deliver.auth.dao.AuthTokenDao">
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.nosum.deliver.auth.domain.po.AuthToken">
-        <id column="id" property="id" />
-        <result column="token" property="token" />
-        <result column="expire_time" property="expireTime" />
-        <result column="user_id" property="userId" />
-    </resultMap>
-
-</mapper>

+ 0 - 24
src/main/resources/mapper/auth/AuthUserMapper.xml

@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.nosum.deliver.auth.dao.AuthUserDao">
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.nosum.deliver.auth.domain.po.AuthUser">
-        <id column="id" property="id" />
-        <result column="username" property="username" />
-        <result column="nickname" property="nickname" />
-        <result column="role_id" property="roleId" />
-        <result column="avatar" property="avatar" />
-        <result column="create_time" property="createTime" />
-        <result column="status" property="status"/>
-    </resultMap>
-    <select id="selectAvatar" resultType="java.lang.String">
-        SELECT avatar FROM auth_user WHERE role_id=2 limit 1
-    </select>
-    <select id="selectAdmin" resultType="com.nosum.deliver.auth.domain.po.AuthUser">
-        SELECT `id`, `social_id`, `password`, `name`, `role_id`, `email`, `introduction`, `avatar`, `create_time`, `access_key`, `secret_key`, `status`
-        FROM auth_user
-        WHERE role_id=2 limit 1
-    </select>
-
-</mapper>

+ 0 - 37
src/main/resources/mapper/auth/AuthUserSocialMapper.xml

@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.nosum.deliver.auth.dao.AuthUserSocialDao">
-	<!-- 通用查询结果列 -->
-    <sql id="Base_Column_List">
-        id,code,content,show_type as showType,remark,icon,is_enabled as isEnabled,is_home as isHome,create_time as createTime,update_time as updateTime
-    </sql>
-
-
-    <resultMap id="BaseResultMap" type="com.nosum.deliver.auth.domain.po.AuthUserSocial">
-		<id column="id" property="id" />
-		<result column="code" property="code" />
-		<result column="content" property="content" />
-		<result column="show_type" property="showType" />
-		<result column="remark" property="remark" />
-		<result column="icon" property="icon" />
-		<result column="is_enabled" property="isEnabled" />
-		<result column="is_home" property="isHome" />
-		<result column="create_time" property="createTime" />
-		<result column="update_time" property="updateTime" />
-    </resultMap>
-
-	<select id="selectSocialList" resultType="com.nosum.deliver.auth.domain.vo.AuthUserSocialVO">
-		SELECT <include refid="Base_Column_List"/> FROM auth_user_social
-		<where>
-			<if test="condition.code != null and condition.code != ''"> AND code=#{condition.code}</if>
-			<if test="condition.content != null and condition.content != ''"> AND content=#{condition.content}</if>
-			<if test="condition.showType != null "> AND show_type=#{condition.showType}</if>
-			<if test="condition.remark != null and condition.remark != ''"> AND remark=#{condition.remark}</if>
-			<if test="condition.isEnabled != null"> AND is_enabled=#{condition.isEnabled}</if>
-			<if test="condition.isHome != null "> AND is_home=#{condition.isHome}</if>
-			<if test="condition.keywords != null and condition.keywords != ''"> AND code LIKE #{condition.keywords}</if>
-		</where>
-		ORDER BY id DESC
-	</select>
-
-</mapper>

+ 0 - 46
src/main/resources/mapper/category/CategoryMapper.xml

@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.nosum.deliver.category.dao.CategoryDao">
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.nosum.deliver.category.domain.po.Category">
-        <id column="id" property="id"/>
-        <result column="name" property="name"/>
-        <result column="sort" property="sort"/>
-        <result column="create_time" property="createTime"/>
-        <result column="update_time" property="updateTime"/>
-    </resultMap>
-
-    <sql id="BASE_SQL">id,name,sort,create_time, create_by, update_time, update_by</sql>
-
-    <select id="selectCategoryPostsTotal" resultType="com.nosum.deliver.category.domain.vo.CategoryVO">
-       SELECT
-        categoryTags.category_id id,
-        COUNT(*) total
-        FROM
-        category_tags categoryTags
-        LEFT JOIN posts_tags postsTags ON postsTags.tags_id = categoryTags.tags_id
-        WHERE
-        postsTags.posts_id IS NOT NULL
-        GROUP BY categoryTags.category_id
-    </select>
-    <select id="selectStatistics" resultType="com.nosum.deliver.category.domain.vo.CategoryVO">
-        SELECT
-           id,(SELECT COUNT( 1 ) FROM posts WHERE category_id = category.id AND status=2) as total, name
-        FROM
-            category AS category
-    </select>
-    <select id="selectListPage" resultType="com.nosum.deliver.category.domain.po.Category">
-        SELECT <include refid="BASE_SQL"/>
-        FROM category
-        <where>
-            <if test="condition.keywords != null and condition.keywords != ''">
-                AND name like #{condition.name}
-            </if>
-            <if test="condition.name != null and condition.name != ''">
-                AND name = #{condition.name}
-            </if>
-        </where>
-        ORDER BY id DESC
-    </select>
-</mapper>

+ 0 - 0
src/main/resources/mapper/category/CategoryTagsMapper.xml


Some files were not shown because too many files changed in this diff