├── LICENSE ├── README.md ├── blog-api ├── .gitignore ├── blogapi.iml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── datealive │ │ │ ├── BlogapiApplication.java │ │ │ ├── annotation │ │ │ └── LogAnno.java │ │ │ ├── aop │ │ │ └── LogAopAspect.java │ │ │ ├── common │ │ │ ├── PageResult.java │ │ │ ├── Result.java │ │ │ ├── ResultCode.java │ │ │ └── StaticFinalCode.java │ │ │ ├── config │ │ │ ├── CorsConfig.java │ │ │ ├── DruidConfig.java │ │ │ ├── GiteeImgConfig.java │ │ │ ├── KaptchaConfig.java │ │ │ ├── RedisConfig.java │ │ │ ├── ShiroConfig.java │ │ │ ├── SwaggerConfig.java │ │ │ └── TaskPoolConfig.java │ │ │ ├── controller │ │ │ ├── BlogArticleController.java │ │ │ ├── CateGoryController.java │ │ │ ├── CommentController.java │ │ │ ├── FriendsController.java │ │ │ ├── LoginController.java │ │ │ ├── MomentController.java │ │ │ ├── SiteSettingController.java │ │ │ ├── TagController.java │ │ │ ├── TestController.java │ │ │ └── admin │ │ │ │ ├── BlogArticleAdminController.java │ │ │ │ ├── CateGoryAdminController.java │ │ │ │ ├── CommentAdminCotroller.java │ │ │ │ ├── FriendsAdminController.java │ │ │ │ ├── LogAdminController.java │ │ │ │ ├── MomentAdminController.java │ │ │ │ ├── SiteSettingAdminController.java │ │ │ │ ├── TagAdminController.java │ │ │ │ ├── UpLoadController.java │ │ │ │ └── UpLoadImgController.java │ │ │ ├── exception │ │ │ └── AllExceptionHandler.java │ │ │ ├── mapper │ │ │ ├── BlogArticleMapper.java │ │ │ ├── CateGoryMapper.java │ │ │ ├── CommentMapper.java │ │ │ ├── FriendsMapper.java │ │ │ ├── LogMapper.java │ │ │ ├── MomentMapper.java │ │ │ ├── SiteSettingMapper.java │ │ │ ├── TagMapper.java │ │ │ └── UserMapper.java │ │ │ ├── pojo │ │ │ ├── BlogArticle.java │ │ │ ├── CateGory.java │ │ │ ├── Comment.java │ │ │ ├── Friends.java │ │ │ ├── Log.java │ │ │ ├── Moment.java │ │ │ ├── SiteSetting.java │ │ │ ├── Tag.java │ │ │ └── User.java │ │ │ ├── service │ │ │ ├── BlogArticleService.java │ │ │ ├── CateGoryService.java │ │ │ ├── CommentService.java │ │ │ ├── FriendsService.java │ │ │ ├── LogService.java │ │ │ ├── MomentService.java │ │ │ ├── SendMailService.java │ │ │ ├── SiteSettingService.java │ │ │ ├── TagService.java │ │ │ ├── UpLoadService.java │ │ │ ├── UserService.java │ │ │ ├── dto │ │ │ │ ├── BlogUpdStatus.java │ │ │ │ ├── CommentQuery.java │ │ │ │ ├── CommentUpdStatus.java │ │ │ │ ├── FriendsUpdStatus.java │ │ │ │ ├── LogQuery.java │ │ │ │ ├── LoginDto.java │ │ │ │ ├── ModifyPwd.java │ │ │ │ ├── MomentUpdStatus.java │ │ │ │ └── RegisterDto.java │ │ │ ├── impl │ │ │ │ ├── BlogArticleServiceImpl.java │ │ │ │ ├── CateGoryServiceImpl.java │ │ │ │ ├── CommentServiceImpl.java │ │ │ │ ├── FriendsServiceImpl.java │ │ │ │ ├── LogServiceImpl.java │ │ │ │ ├── MomentServiceImpl.java │ │ │ │ ├── SendMailServiceImpl.java │ │ │ │ ├── SiteSettingServiceImpl.java │ │ │ │ ├── TagServiceImpl.java │ │ │ │ ├── UpLoadImageImpl.java │ │ │ │ └── UserServiceImpl.java │ │ │ └── vo │ │ │ │ ├── Badge.java │ │ │ │ ├── BlogArticleCateAndTag.java │ │ │ │ ├── BlogArticleIdAndTitle.java │ │ │ │ ├── BlogArticleInfo.java │ │ │ │ ├── CateGory.java │ │ │ │ ├── CommentSub.java │ │ │ │ ├── Copyright.java │ │ │ │ ├── Favorite.java │ │ │ │ ├── GiteeImageVo.java │ │ │ │ ├── Introduction.java │ │ │ │ └── Tag.java │ │ │ ├── shiro │ │ │ ├── JwtFilter.java │ │ │ ├── JwtToken.java │ │ │ ├── MyProfile.java │ │ │ └── MyShiroRealm.java │ │ │ ├── task │ │ │ └── RedisViewCountTask.java │ │ │ └── utils │ │ │ ├── BilibiliAnimeUtils.java │ │ │ ├── DateUtils.java │ │ │ ├── JacksonUtils.java │ │ │ ├── JwtUtils.java │ │ │ ├── MailUtils.java │ │ │ ├── QQInfoUtils.java │ │ │ ├── RedisUtil.java │ │ │ ├── StringUtils.java │ │ │ ├── UserAgentUtils.java │ │ │ ├── UserUtils.java │ │ │ ├── ValidatorUtil.java │ │ │ └── markdowntoHtml │ │ │ ├── MarkdownUtils.java │ │ │ └── ext │ │ │ └── cover │ │ │ ├── Cover.java │ │ │ ├── CoverExtension.java │ │ │ └── internal │ │ │ ├── AbstractCoverNodeRenderer.java │ │ │ ├── CoverDelimiterProcessor.java │ │ │ ├── CoverHtmlNodeRenderer.java │ │ │ └── CoverTextContentNodeRenderer.java │ └── resources │ │ ├── META-INF │ │ └── spring-devtools.properties │ │ ├── application.yml │ │ ├── ipdb │ │ └── ip2region.db │ │ ├── log4j2.xml │ │ └── mapper │ │ ├── BlogArticle.xml │ │ ├── CateGoryMapper.xml │ │ ├── CommentMapper.xml │ │ ├── FriendsMapper.xml │ │ ├── LogMapper.xml │ │ ├── MomentMapper.xml │ │ ├── SiteSettingMapper.xml │ │ ├── TagMapper.xml │ │ └── UserMapper.xml │ └── test │ └── java │ └── com │ └── datealive │ └── test │ └── testTest.java ├── blog-front-cms ├── .browserslistrc ├── .gitignore ├── .prettierrc ├── babel.config.js ├── package.json ├── postcss.config.js ├── public │ └── index.html ├── src │ ├── App.vue │ ├── api │ │ └── index.js │ ├── assets │ │ ├── css │ │ │ ├── color-dark.css │ │ │ ├── icon.css │ │ │ ├── main.css │ │ │ └── theme-green │ │ │ │ ├── color-green.css │ │ │ │ ├── fonts │ │ │ │ ├── element-icons.ttf │ │ │ │ └── element-icons.woff │ │ │ │ └── index.css │ │ ├── img │ │ │ ├── b-login.jpg │ │ │ ├── comment-1.gif │ │ │ ├── img.jpg │ │ │ └── login-bg.jpg │ │ └── logo.png │ ├── components │ │ ├── common │ │ │ ├── Header.vue │ │ │ ├── Home.vue │ │ │ ├── Sidebar.vue │ │ │ ├── Tags.vue │ │ │ ├── bus.js │ │ │ └── directives.js │ │ └── page │ │ │ ├── 404.vue │ │ │ ├── Articles.vue │ │ │ ├── BlogEdit.vue │ │ │ ├── BlogTag.vue │ │ │ ├── CateGory.vue │ │ │ ├── Comments.vue │ │ │ ├── FriendList.vue │ │ │ ├── ImageBed.vue │ │ │ ├── Login.vue │ │ │ ├── Moment.vue │ │ │ ├── SiteSetting.vue │ │ │ ├── SysIndex.vue │ │ │ └── log │ │ │ ├── Errorlogs.vue │ │ │ ├── Joblogs.vue │ │ │ ├── Loginlogs.vue │ │ │ ├── Operationlogs.vue │ │ │ └── Vistorlogs.vue │ ├── main.js │ ├── permission.js │ ├── plugins │ │ └── axios.js │ ├── router │ │ └── index.js │ ├── store │ │ └── store.js │ └── utils │ │ └── request.js └── vue.config.js └── blog-front-view ├── .gitignore ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── public ├── favicon.ico └── index.html ├── src ├── App.vue ├── assets │ ├── beian.png │ ├── csdn.png │ ├── dianzan.png │ ├── github.png │ ├── icon_QQ.png │ ├── introduction.png │ ├── lianjie.png │ ├── logo.png │ ├── love.png │ ├── love2.png │ ├── star.png │ ├── style.css │ ├── tag.png │ ├── totop.png │ ├── typo.css │ ├── vue.jpg │ └── 置顶.png ├── components │ ├── BlogsByTagCate.vue │ ├── Comment.vue │ ├── Footer.vue │ ├── FriendSider.vue │ ├── Head.vue │ ├── Introduction.vue │ ├── Tocbot.vue │ ├── categorys.vue │ └── tags.vue ├── i18n │ ├── i18n.js │ └── langs │ │ ├── en.js │ │ └── zh.js ├── main.js ├── plugins │ └── axios.js ├── router │ └── index.js ├── store │ ├── actions.js │ ├── getters.js │ ├── index.js │ ├── mutations-types.js │ ├── mutations.js │ └── state.js └── views │ ├── About.vue │ ├── Archive.vue │ ├── Article.vue │ ├── Friends.vue │ ├── Home.vue │ └── Moment.vue └── vue.config.js /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 梦独吟 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /blog-api/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | # Custom Items 26 | # target 27 | 28 | target/ 29 | main/test/ 30 | main/resources/application.yml 31 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/BlogapiApplication.java: -------------------------------------------------------------------------------- 1 | package com.datealive; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableAsync; 6 | import org.springframework.transaction.annotation.EnableTransactionManagement; 7 | 8 | @EnableAsync 9 | @EnableTransactionManagement 10 | @SpringBootApplication 11 | public class BlogapiApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(BlogapiApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/annotation/LogAnno.java: -------------------------------------------------------------------------------- 1 | package com.datealive.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @Classname LogAnno 10 | * @Description 日志注解 11 | * @Date 2021/2/17 15:06 12 | * @author 冰羽 13 | */ 14 | @Target(ElementType.METHOD) // 方法注解 15 | @Retention(RetentionPolicy.RUNTIME) // 运行时可见 16 | public @interface LogAnno { 17 | String operateType();// 记录日志的操作类型 18 | String description();//记录日志操作描述 19 | int classification();//记录日志类别 20 | 21 | } -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/common/PageResult.java: -------------------------------------------------------------------------------- 1 | package com.datealive.common; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.util.List; 8 | 9 | /** 10 | * @ClassName: PageResult 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/1/31 22:25 14 | */ 15 | @Data 16 | public class PageResult implements Serializable { 17 | 18 | /** 19 | * 状态码 20 | */ 21 | private Integer code; 22 | /** 23 | * 总页数 24 | */ 25 | private Integer totalPage; 26 | /** 27 | * 当前页 28 | */ 29 | private Integer currentPage; 30 | /** 31 | * 当前页数据 32 | */ 33 | private List data; 34 | 35 | public PageResult(Integer code,Integer totalPage, Integer currentPage, List data) { 36 | this.code=code; 37 | this.totalPage = totalPage; 38 | this.currentPage = currentPage; 39 | this.data = data; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/common/Result.java: -------------------------------------------------------------------------------- 1 | package com.datealive.common; 2 | 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @ClassName: Result 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/1/31 13:15 14 | */ 15 | @NoArgsConstructor 16 | @Getter 17 | @Setter 18 | public class Result implements Serializable { 19 | 20 | private Integer code; 21 | private String msg; 22 | private Object data; 23 | 24 | private Result(Integer code, String msg) { 25 | this.code = code; 26 | this.msg = msg; 27 | this.data=null; 28 | } 29 | 30 | private Result(Integer code, String msg, Object data) { 31 | this.code = code; 32 | this.msg = msg; 33 | this.data = data; 34 | } 35 | 36 | public static Result success(String msg,Object data){ 37 | return new Result(ResultCode.Success,msg,data); 38 | } 39 | 40 | public static Result success(String msg){ 41 | return new Result(ResultCode.Success,msg); 42 | } 43 | 44 | public static Result success(Integer code,String msg){ 45 | return new Result(code,msg); 46 | } 47 | 48 | public static Result error(String msg) { 49 | return new Result(ResultCode.Server_Error, msg); 50 | } 51 | public static Result error(Integer code,String msg) { 52 | return new Result(code, msg); 53 | } 54 | 55 | public static Result error() { 56 | return new Result(ResultCode.Server_Error, "异常错误"); 57 | } 58 | 59 | public static Result create(Integer code, String msg, Object data) { 60 | return new Result(code, msg, data); 61 | } 62 | 63 | public static Result create(Integer code, String msg) { 64 | return new Result(code, msg); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/common/ResultCode.java: -------------------------------------------------------------------------------- 1 | package com.datealive.common; 2 | 3 | /** 4 | * @ClassName: ResultCode 5 | * @Description: TODO 6 | * @author: datealive 7 | * @date: 2021/2/1 9:20 8 | */ 9 | public class ResultCode { 10 | /** 11 | * 服务器成功返回用户请求的数据 12 | */ 13 | public static final int Success=200; 14 | /** 15 | * 用户新建或修改数据成功。 16 | */ 17 | public static final int CREATED_SuccessCode=201; 18 | /** 19 | * 用户删除数据成功。 20 | */ 21 | public static final int Delete_SuccessCode=204; 22 | public static final int INVALID_REQUEST=400; 23 | /** 24 | * 表示用户没有权限 25 | */ 26 | public static final int Un_authorized=401; 27 | /** 28 | * 表示用户得到授权(与401错误相对),但是访问是被禁止的 29 | */ 30 | public static final int Forbidden=403; 31 | /** 32 | * 用户发出的请求针对的是不存在的记录,服务器没有进行操作 33 | */ 34 | public static final int Not_Found=404; 35 | /** 36 | * 服务器发生错误,用户将无法判断发出的请求是否成功 37 | */ 38 | public static final int Server_Error=500; 39 | } 40 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/common/StaticFinalCode.java: -------------------------------------------------------------------------------- 1 | package com.datealive.common; 2 | 3 | 4 | 5 | /** 6 | * @ClassName: StaticFinalCode 7 | * @Description: TODO 8 | * @author: datealive 9 | * @date: 2021/2/2 10:09 10 | */ 11 | public class StaticFinalCode { 12 | 13 | /** 14 | * 每页显示5条数据 15 | */ 16 | public static final int pageSize = 5; 17 | /** 18 | * 每页显示10条日志数据 19 | */ 20 | public static final int logPageSize=10; 21 | /** 22 | * 每页显示20个数据 23 | */ 24 | public static final int ImgPageSize = 20; 25 | /** 26 | * 文章浏览量key前缀 27 | */ 28 | public static final String KEY_BLOG_ARTICLE_VIEW_ProFix="VIEW:post:"; 29 | /** 30 | * 文章点赞 key前缀 31 | */ 32 | public static final String KEY_BLOG_ARTICLE_LIKE_ProFix="LIKE:post:"; 33 | /** 34 | * gitee图片数据 35 | */ 36 | public static final String GITEE_IMAGE_PRO_FIX ="Gitee:AllImage:"; 37 | /** 38 | * 站点信息map key前缀 39 | */ 40 | public static final String SITE_INFO_MAP = "siteInfoMap:get:"; 41 | } 42 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | package com.datealive.config; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 6 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 8 | 9 | /** 10 | * @ClassName: CorsConfig 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/1/31 18:59 14 | */ 15 | @Configuration 16 | public class CorsConfig implements WebMvcConfigurer { 17 | /** 18 | * 图片保存路径,自动从yml文件中获取数据 19 | * 示例: E:/images/ 20 | */ 21 | @Value("${file-save-path}") 22 | private String fileSavePath; 23 | 24 | @Override 25 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 26 | /** 27 | * 配置资源映射 28 | * 意思是:如果访问的资源路径是以“/images/”开头的, 29 | * 就给我映射到本机的“E:/images/”这个文件夹内,去找你要的资源 30 | * 注意:E:/images/ 后面的 “/”一定要带上 31 | */ 32 | registry.addResourceHandler("/images/**") 33 | .addResourceLocations("file:"+fileSavePath); 34 | } 35 | 36 | @Override 37 | public void addCorsMappings(CorsRegistry registry) { 38 | registry.addMapping("/**") 39 | .allowedOrigins("*") 40 | .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS") 41 | .allowCredentials(true) 42 | .maxAge(3600) 43 | .allowedHeaders("*"); 44 | } 45 | 46 | 47 | } -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/config/DruidConfig.java: -------------------------------------------------------------------------------- 1 | package com.datealive.config; 2 | 3 | import com.alibaba.druid.pool.DruidDataSource; 4 | import com.alibaba.druid.support.http.StatViewServlet; 5 | import com.alibaba.druid.support.http.WebStatFilter; 6 | import org.hibernate.validator.internal.constraintvalidators.hv.LengthValidator; 7 | import org.springframework.boot.context.properties.ConfigurationProperties; 8 | import org.springframework.boot.web.servlet.FilterRegistrationBean; 9 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | import javax.sql.DataSource; 14 | import java.util.Arrays; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | /** 19 | * @ClassName: DruidConfig 20 | * @Description: TODO 21 | * @author: datealive 22 | * @date: 2021/1/31 13:35 23 | */ 24 | @Configuration 25 | public class DruidConfig { 26 | 27 | 28 | @ConfigurationProperties(prefix = "spring.datasource") 29 | @Bean 30 | public DataSource druidDataSource() { 31 | return new DruidDataSource(); 32 | } 33 | 34 | //配置 Druid 监控管理后台的Servlet; 35 | //内置 Servlet 容器时没有web.xml文件,所以使用 Spring Boot 的注册 Servlet 方式 36 | @Bean 37 | public ServletRegistrationBean statViewServlet() { 38 | ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*"); 39 | 40 | // 这些参数可以在 com.alibaba.druid.support.http.StatViewServlet 41 | // 的父类 com.alibaba.druid.support.http.ResourceServlet 中找到 42 | Map initParams = new HashMap<>(); 43 | initParams.put("loginUsername", "admin"); //后台管理界面的登录账号 44 | initParams.put("loginPassword", "admin"); //后台管理界面的登录密码 45 | // initParams.put("initConnectionSqls", "set names utf8mb4;"); 46 | //后台允许谁可以访问 47 | initParams.put("allow", "localhost");//表示只有本机可以访问 48 | //initParams.put("allow", ""):为空或者为null时,表示允许所有访问 49 | //initParams.put("allow", ""); 50 | //deny:Druid 后台拒绝谁访问 51 | //initParams.put("kuangshen", "192.168.1.20");表示禁止此ip访问 52 | 53 | //设置初始化参数 54 | bean.setInitParameters(initParams); 55 | return bean; 56 | } 57 | 58 | //配置 Druid 监控 之 web 监控的 filter 59 | //WebStatFilter:用于配置Web和Druid数据源之间的管理关联监控统计 60 | @Bean 61 | public FilterRegistrationBean webStatFilter() { 62 | FilterRegistrationBean bean = new FilterRegistrationBean(); 63 | bean.setFilter(new WebStatFilter()); 64 | 65 | //exclusions:设置哪些请求进行过滤排除掉,从而不进行统计 66 | Map initParams = new HashMap<>(); 67 | initParams.put("exclusions", "*.js,*.css,/druid/*,/jdbc/*"); 68 | bean.setInitParameters(initParams); 69 | 70 | //"/*" 表示过滤所有请求 71 | bean.setUrlPatterns(Arrays.asList("/*")); 72 | return bean; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/config/GiteeImgConfig.java: -------------------------------------------------------------------------------- 1 | package com.datealive.config; 2 | 3 | import lombok.Data; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.boot.context.properties.ConfigurationProperties; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.text.SimpleDateFormat; 10 | import java.util.Date; 11 | 12 | /** 13 | * @ClassName: GiteeImgConfig 14 | * @Description: TODO 15 | * @author: datealive 16 | * @date: 2021/4/11 10:16 17 | */ 18 | @Slf4j 19 | @Data 20 | @Component 21 | public class GiteeImgConfig { 22 | 23 | public static String getNowDate() { 24 | Date now = new Date(); 25 | SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); 26 | return formatter.format(now); 27 | } 28 | 29 | //码云私人令牌,需要补充 30 | public static String ACCESS_TOKEN ; 31 | //个人空间名,需要补充 32 | public static String OWNER ; 33 | //仓库名,需要补充 34 | public static String REPO_NAME; 35 | //文件夹路径 36 | public static final String PATH = "/blogImg/"; 37 | //message消息 38 | public static final String ADD_MESSAGE = "add img"; 39 | public static final String DEl_MESSAGE = "del img"; 40 | 41 | 42 | @Value("${datealive.gitee.ACCESS_TOKEN}") 43 | public void setAccessToken(String accessToken) { 44 | ACCESS_TOKEN = accessToken; 45 | } 46 | @Value("${datealive.gitee.OWNER}") 47 | public void setOWNER(String OWNER) { 48 | GiteeImgConfig.OWNER = OWNER; 49 | } 50 | 51 | @Value("${datealive.gitee.REPO_NAME}") 52 | public void setRepoName(String repoName) { 53 | REPO_NAME = repoName; 54 | } 55 | 56 | /** 57 | * 新建文件请求路径 58 | *

59 | * owner* 仓库所属空间地址(企业、组织或个人的地址path) 60 | * repo* 仓库路径 61 | * path* 文件的路径 62 | * content* 文件内容, 要用 base64 编码 63 | * message* 提交信息 64 | *

65 | * %s =>仓库所属空间地址(企业、组织或个人的地址path) (owner) 66 | * %s => 仓库路径(repo) 67 | * %s => 文件的路径(path) 68 | */ 69 | public static String CREATE_REPOS_URL = "https://gitee.com/api/v5/repos/%s/%s/contents/%s"; 70 | /** 71 | * 获取路径下所有的内容 72 | *

73 | * owner* 仓库所属空间地址(企业、组织或个人的地址path) 74 | * repo* 仓库路径 75 | * path* 文件的路径 76 | * content* 文件内容, 要用 base64 编码 77 | * message* 提交信息 78 | *

79 | * %s =>仓库所属空间地址(企业、组织或个人的地址path) (owner) 80 | * %s => 仓库路径(repo) 81 | * %s => 文件的路径(path) 82 | */ 83 | public static String GET_IMG_URL = "https://gitee.com/api/v5/repos/%s/%s/contents/%s"; 84 | 85 | /** 86 | * 删除文件请求路径 87 | *

88 | * owner* 仓库所属空间地址(企业、组织或个人的地址path) 89 | * repo* 仓库路径 90 | * path* 文件的路径 91 | * content* 文件内容, 要用 base64 编码 92 | * message* 提交信息 93 | *

94 | * %s =>仓库所属空间地址(企业、组织或个人的地址path) (owner) 95 | * %s => 仓库路径(repo) 96 | * %s => 文件的路径(path) 97 | */ 98 | public static String DEL_IMG_URL = "https://gitee.com/api/v5/repos/%s/%s/contents/%s"; 99 | } 100 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/config/KaptchaConfig.java: -------------------------------------------------------------------------------- 1 | package com.datealive.config; 2 | 3 | import com.google.code.kaptcha.impl.DefaultKaptcha; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import java.util.Properties; 7 | import com.google.code.kaptcha.util.Config; 8 | import org.springframework.context.annotation.Primary; 9 | 10 | 11 | /** 12 | * @Classname KaptchaConfig 13 | * @Description 谷歌验证码配置文件 14 | * @Date 2021/2/15 15:06 15 | * @author 冰羽 16 | */ 17 | 18 | @Configuration 19 | public class KaptchaConfig { 20 | @Primary 21 | @Bean(name = "captchaProducer") 22 | public DefaultKaptcha getKaptchaBean() 23 | { 24 | DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); 25 | Properties properties = new Properties(); 26 | properties.setProperty("kaptcha.border", "yes"); 27 | properties.setProperty("kaptcha.border.color", "105,179,90"); 28 | properties.setProperty("kaptcha.textproducer.font.color", "blue"); 29 | properties.setProperty("kaptcha.image.width", "160"); 30 | properties.setProperty("kaptcha.image.height", "60"); 31 | properties.setProperty("kaptcha.textproducer.font.size", "28"); 32 | properties.setProperty("kaptcha.session.key", "kaptchaCode"); 33 | properties.setProperty("kaptcha.textproducer.char.spac", "35"); 34 | properties.setProperty("kaptcha.textproducer.char.length", "5"); 35 | properties.setProperty("kaptcha.textproducer.font.names", "Arial,Courier"); 36 | properties.setProperty("kaptcha.noise.color", "white"); 37 | Config config = new Config(properties); 38 | defaultKaptcha.setConfig(config); 39 | return defaultKaptcha; 40 | } 41 | 42 | @Bean(name = "captchaProducerMath") 43 | public DefaultKaptcha getKaptchaBeanMath() 44 | { 45 | DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); 46 | Properties properties = new Properties(); 47 | properties.setProperty("kaptcha.border", "yes"); 48 | properties.setProperty("kaptcha.border.color", "105,179,90"); 49 | properties.setProperty("kaptcha.textproducer.font.color", "blue"); 50 | properties.setProperty("kaptcha.image.width", "100"); 51 | properties.setProperty("kaptcha.image.height", "30"); 52 | properties.setProperty("kaptcha.textproducer.font.size", "30"); 53 | properties.setProperty("kaptcha.session.key", "kaptchaCodeMath"); 54 | properties.setProperty("kaptcha.textproducer.impl", "com.lhf.springboot.support.KaptchaTextCreator"); 55 | properties.setProperty("kaptcha.textproducer.char.spac", "5"); 56 | properties.setProperty("kaptcha.textproducer.char.length", "6"); 57 | properties.setProperty("kaptcha.textproducer.font.names", "Arial,Courier"); 58 | properties.setProperty("kaptcha.noise.color", "white"); 59 | properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise"); 60 | properties.setProperty("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.ShadowGimpy"); 61 | Config config = new Config(properties); 62 | defaultKaptcha.setConfig(config); 63 | return defaultKaptcha; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.datealive.config; 2 | 3 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 4 | import com.fasterxml.jackson.annotation.PropertyAccessor; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.data.redis.connection.RedisConnectionFactory; 9 | import org.springframework.data.redis.core.RedisTemplate; 10 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; 11 | import org.springframework.data.redis.serializer.StringRedisSerializer; 12 | 13 | /** 14 | * @ClassName: RedisConfig 15 | * @Description: TODO 16 | * @author: datealive 17 | * @date: 2021/2/12 8:06 18 | */ 19 | @Configuration 20 | public class RedisConfig { 21 | @Bean 22 | @SuppressWarnings("all") 23 | public RedisTemplate redisTemplate(RedisConnectionFactory factory) { 24 | RedisTemplate template = new RedisTemplate<>(); 25 | template.setConnectionFactory(factory); 26 | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); 27 | ObjectMapper objectMapper = new ObjectMapper(); 28 | objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); 29 | objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); 30 | jackson2JsonRedisSerializer.setObjectMapper(objectMapper); 31 | StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); 32 | // key 采用 String 的序列化方式 33 | template.setKeySerializer(stringRedisSerializer); 34 | // hash 的 key 也采用 String 的序列化方式 35 | template.setHashKeySerializer(stringRedisSerializer); 36 | // value 的序列化方式采用 JSON 37 | template.setValueSerializer(jackson2JsonRedisSerializer); 38 | // hash value 的序列化方式也采用 JSON 39 | template.setHashValueSerializer(jackson2JsonRedisSerializer); 40 | template.afterPropertiesSet(); 41 | return template; 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.datealive.config; 2 | 3 | import com.google.common.base.Predicates; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import springfox.documentation.builders.ApiInfoBuilder; 7 | import springfox.documentation.builders.PathSelectors; 8 | import springfox.documentation.builders.RequestHandlerSelectors; 9 | import springfox.documentation.service.ApiInfo; 10 | import springfox.documentation.service.Contact; 11 | import springfox.documentation.spi.DocumentationType; 12 | import springfox.documentation.spring.web.plugins.Docket; 13 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 14 | /** 15 | * @Classname SwaggerConfig 16 | * @Description Swagger配置文件 17 | * @Date 2021/2/15 15:06 18 | * @author 冰羽 19 | */ 20 | 21 | @Configuration 22 | @EnableSwagger2 23 | public class SwaggerConfig { 24 | //版本 25 | public static final String VERSION = "1.0.0"; 26 | 27 | @Bean 28 | public Docket createRestApi() { 29 | return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).enable(true).select() 30 | .apis(RequestHandlerSelectors.any()) 31 | .paths(Predicates.not(PathSelectors.regex("/error.*")))//错误路径不监控 32 | .paths(PathSelectors.any()).build().groupName("admin"); 33 | } 34 | 35 | private ApiInfo apiInfo() { 36 | return new ApiInfoBuilder().title("Hi-Dream博客系统接口文档") //设置文档的标题 37 | .description("后台管理系统") // 设置文档的描述 38 | .description("管理中心接口 => Created by Hi-Dream-Blog") // 设置文档的描述 39 | /**设置文档的联系方式*/ 40 | .contact(new Contact("Hi-Dream-Blog", "https://github.com/Hi-Dream-Blog", "xzhxpx@qq.com")) 41 | /**设置文档的License信息->1.3 License information*/ 42 | .license("CC BY-NC-SA ") 43 | .licenseUrl("https://creativecommons.org/licenses/by-nc-sa/4.0/") 44 | .version(VERSION) // 设置文档的版本信息-> 1.0.0 Version information 45 | .build(); 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/config/TaskPoolConfig.java: -------------------------------------------------------------------------------- 1 | package com.datealive.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 6 | 7 | import java.util.concurrent.Executor; 8 | import java.util.concurrent.ThreadPoolExecutor; 9 | 10 | /** 11 | * @ClassName: TaskPoolConfig 12 | * @Description: 定义异步任务执行线程池 13 | * @author: datealive 14 | * @date: 2021/2/16 9:25 15 | */ 16 | @Configuration 17 | public class TaskPoolConfig { 18 | 19 | @Bean("taskExecutor") 20 | public Executor taskExecutor(){ 21 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); 22 | // 核心线程数10:线程池创建时候初始化的线程数 23 | executor.setCorePoolSize(10); 24 | // 最大线程数20:线程池最大的线程数,只有在缓冲队列满了之后才会申请超过核心线程数的线程 25 | executor.setMaxPoolSize(15); 26 | // 缓冲队列200:用来缓冲执行任务的队列 27 | executor.setQueueCapacity(200); 28 | // 允许线程的空闲时间60秒:当超过了核心线程数之外的线程在空闲时间到达之后会被销毁 29 | executor.setKeepAliveSeconds(60); 30 | // 线程池名的前缀:设置好了之后可以方便定位处理任务所在的线程池 31 | executor.setThreadNamePrefix("taskExecutor-"); 32 | /* 33 | 线程池对拒绝任务的处理策略:这里采用了CallerRunsPolicy策略, 34 | 当线程池没有处理能力的时候,该策略会直接在 execute 方法的调用线程中运行被拒绝的任务; 35 | 如果执行程序已关闭,则会丢弃该任务 36 | */ 37 | executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); 38 | // 设置线程池关闭的时候等待所有任务都完成再继续销毁其他的Bean 39 | executor.setWaitForTasksToCompleteOnShutdown(true); 40 | // 设置线程池中任务的等待时间,如果超过这个时候还没有销毁就强制销毁,以确保应用最后能够被关闭,而不是阻塞住。 41 | executor.setAwaitTerminationSeconds(600); 42 | return executor; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/controller/BlogArticleController.java: -------------------------------------------------------------------------------- 1 | package com.datealive.controller; 2 | 3 | import com.datealive.annotation.LogAnno; 4 | import com.datealive.common.PageResult; 5 | import com.datealive.common.Result; 6 | import com.datealive.common.ResultCode; 7 | import com.datealive.pojo.BlogArticle; 8 | import com.datealive.service.BlogArticleService; 9 | import com.datealive.service.vo.BlogArticleIdAndTitle; 10 | import com.datealive.service.vo.BlogArticleInfo; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | /** 16 | * @ClassName: BlogArticleController 17 | * @Description: TODO 18 | * @author: datealive 19 | * @date: 2021/1/31 22:37 20 | */ 21 | @RestController 22 | @Slf4j 23 | public class BlogArticleController { 24 | 25 | @Autowired 26 | BlogArticleService blogArticleService; 27 | 28 | 29 | @LogAnno(operateType="GET",description = "访问文章",classification = 0) 30 | /** 31 | * 博客文章详情 32 | * @param blog_id 33 | * @return 34 | */ 35 | @GetMapping("/blog/{id}") 36 | public Result getBlogArticleById(@PathVariable("id") Integer blog_id){ 37 | BlogArticle article = blogArticleService.getBlogArticleByIdToHtml(blog_id); 38 | if(article!=null){ 39 | blogArticleService.increaseBlogView(article); 40 | return Result.success("请求成功",article); 41 | }else{ 42 | return Result.error(ResultCode.Not_Found,"没有数据"); 43 | } 44 | 45 | } 46 | 47 | /** 48 | * 博客文章数量 49 | * @return 50 | */ 51 | @GetMapping("/blogsCount") 52 | public Result getBlogArticlesCount(){ 53 | int blogs_count = blogArticleService.countBlogArticle(); 54 | return Result.success("请求成功",blogs_count); 55 | } 56 | 57 | @LogAnno(operateType="GET",description = "访问首页",classification = 0) 58 | @GetMapping("/blogList") 59 | public PageResult getAllBlogArticle(@RequestParam(defaultValue = "1") Integer currentPage){ 60 | PageResult blogArticle = blogArticleService.getAllBlogArticle(currentPage); 61 | return blogArticle; 62 | } 63 | 64 | 65 | @GetMapping("/blogArchive") 66 | public PageResult getBlogArticleIdAndTitle(@RequestParam(defaultValue = "1") Integer currentPage){ 67 | PageResult articleIdAndTitle = blogArticleService.getBlogArticleIdAndTitle(currentPage); 68 | return articleIdAndTitle; 69 | } 70 | 71 | @GetMapping("/searchBlog/{title}") 72 | public PageResult getBlogArticleByTitle(@PathVariable("title") String blog_title,@RequestParam(defaultValue = "1") Integer currentPage){ 73 | PageResult blogArticleByTitle = blogArticleService.getBlogArticleByTitle(blog_title, currentPage); 74 | return blogArticleByTitle; 75 | } 76 | 77 | @PostMapping("/likeBlog/{id}") 78 | public Result increaseBlogLikeCnt(@PathVariable("id") Integer blog_id){ 79 | boolean blogLike = blogArticleService.increaseBlogLike(blog_id); 80 | if(blogLike){ 81 | log.info("点赞操作成功"); 82 | return Result.success("点赞成功"); 83 | }else{ 84 | log.error("点赞操作失败"); 85 | return Result.error("点赞失败"); 86 | } 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/controller/CateGoryController.java: -------------------------------------------------------------------------------- 1 | package com.datealive.controller; 2 | 3 | import com.datealive.common.PageResult; 4 | import com.datealive.common.Result; 5 | import com.datealive.common.ResultCode; 6 | import com.datealive.pojo.CateGory; 7 | import com.datealive.service.CateGoryService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestParam; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * @ClassName: CateGoryController 18 | * @Description: TODO 19 | * @author: datealive 20 | * @date: 2021/2/1 22:08 21 | */ 22 | @RestController 23 | public class CateGoryController { 24 | 25 | @Autowired 26 | CateGoryService cateGoryService; 27 | 28 | @GetMapping("/getAllCategory") 29 | public Result getAllCateGory(){ 30 | List gateGoryIdAndName = cateGoryService.getGateGoryIdAndName(); 31 | if(gateGoryIdAndName.isEmpty()){ 32 | return Result.error(ResultCode.Not_Found,"无数据"); 33 | }else{ 34 | return Result.success("请求成功",gateGoryIdAndName); 35 | } 36 | } 37 | 38 | @GetMapping("/getCateGoryByName/{name}") 39 | public Result getCateGoryByName(@PathVariable("name") String category_name){ 40 | com.datealive.service.vo.CateGory cateGoryByName = cateGoryService.getCateGoryByName(category_name); 41 | if(cateGoryByName==null){ 42 | return Result.error(ResultCode.Not_Found,"无数据"); 43 | }else{ 44 | return Result.success("请求成功",cateGoryByName); 45 | } 46 | } 47 | 48 | @GetMapping("/cateGoryBlogs/{id}") 49 | public PageResult getCateGoryBlogs(@PathVariable("id") Integer category_id,@RequestParam(defaultValue = "1") Integer currentPage){ 50 | PageResult blogInfoByCategory = cateGoryService.getBlogInfoByCategory(category_id, currentPage); 51 | return blogInfoByCategory; 52 | } 53 | 54 | 55 | 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/controller/CommentController.java: -------------------------------------------------------------------------------- 1 | package com.datealive.controller; 2 | 3 | import com.datealive.common.PageResult; 4 | import com.datealive.common.Result; 5 | import com.datealive.pojo.Comment; 6 | import com.datealive.service.CommentService; 7 | import com.datealive.service.SendMailService; 8 | import com.datealive.service.dto.CommentQuery; 9 | import com.datealive.service.vo.CommentSub; 10 | import com.datealive.utils.MailUtils; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.validation.annotation.Validated; 14 | import org.springframework.web.bind.annotation.PostMapping; 15 | import org.springframework.web.bind.annotation.RequestBody; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | 19 | /** 20 | * @ClassName: CommentController 21 | * @Description: TODO 22 | * @author: datealive 23 | * @date: 2021/2/10 14:31 24 | */ 25 | @RestController 26 | @Slf4j 27 | public class CommentController { 28 | 29 | @Autowired 30 | CommentService commentService; 31 | 32 | @Autowired 33 | SendMailService sendMailService; 34 | 35 | 36 | @PostMapping("/comment/query") 37 | public PageResult getComment(@RequestBody CommentQuery commentQuery){ 38 | return commentService.getAllCommentByQuery(commentQuery); 39 | } 40 | 41 | @PostMapping("/comment/save") 42 | public Result saveComment(@Validated @RequestBody CommentSub commentSub){ 43 | boolean saveComment = commentService.saveComment(commentSub); 44 | if(saveComment){ 45 | String path=""; 46 | log.info(commentSub.getNick_name()+"评论成功"); 47 | if(commentSub.getPage()==0){ 48 | path="/article/"+commentSub.getBlog_id(); 49 | }else if(commentSub.getPage()==1){ 50 | path = "/friends"; 51 | }else if(commentSub.getPage()== 2){ 52 | path = "/about"; 53 | } 54 | sendMailService.sendSimpleMailByCommentSub(commentSub,path); 55 | return Result.success("评论成功,待博主审核"); 56 | }else{ 57 | log.error(commentSub.getNick_name()+"评论失败"); 58 | return Result.error("评论失败,请检查你的格式"); 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/controller/FriendsController.java: -------------------------------------------------------------------------------- 1 | package com.datealive.controller; 2 | 3 | import com.datealive.annotation.LogAnno; 4 | import com.datealive.common.PageResult; 5 | import com.datealive.common.Result; 6 | import com.datealive.common.ResultCode; 7 | import com.datealive.pojo.Friends; 8 | import com.datealive.service.FriendsService; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.context.properties.bind.DefaultValue; 12 | import org.springframework.validation.annotation.Validated; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * @ClassName: FriendsController 19 | * @Description: TODO 20 | * @author: datealive 21 | * @date: 2021/2/1 17:13 22 | */ 23 | @RestController 24 | @Slf4j 25 | public class FriendsController { 26 | 27 | @Autowired 28 | FriendsService friendsService; 29 | 30 | @GetMapping("/allFriends") 31 | public Result getAllFriends(){ 32 | List friends = friendsService.getAllFriends(); 33 | return Result.success("请求成功",friends); 34 | } 35 | 36 | @GetMapping("/queryFriend/{name}") 37 | public Result getFriendsByName(@PathVariable("name") String name){ 38 | List friends = friendsService.queryFriendsByName(name); 39 | if(friends.isEmpty()){ 40 | return Result.error(ResultCode.Not_Found,"无数据"); 41 | }else{ 42 | return Result.success("请求成功",friends); 43 | } 44 | 45 | } 46 | 47 | @PostMapping("/saveFriend") 48 | public Result saveFriend(@Validated @RequestBody Friends friends){ 49 | friends.setStatus(0); 50 | boolean saveFriend = friendsService.saveFriend(friends); 51 | if(saveFriend){ 52 | log.info("友链申请成功"); 53 | return Result.success("申请成功"); 54 | }else{ 55 | log.error("友链申请失败"); 56 | return Result.error("申请失败"); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/controller/MomentController.java: -------------------------------------------------------------------------------- 1 | package com.datealive.controller; 2 | 3 | import com.datealive.annotation.LogAnno; 4 | import com.datealive.common.PageResult; 5 | import com.datealive.common.Result; 6 | import com.datealive.pojo.Moment; 7 | import com.datealive.service.MomentService; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | /** 13 | * @ClassName: MomentController 14 | * @Description: TODO 15 | * @author: datealive 16 | * @date: 2021/2/17 19:06 17 | */ 18 | @RestController 19 | @Slf4j 20 | public class MomentController { 21 | 22 | @Autowired 23 | MomentService momentService; 24 | 25 | @LogAnno(operateType="GET",description = "访问动态",classification = 0) 26 | @GetMapping("/momentList") 27 | public PageResult getMomentListWithPublish(@RequestParam(defaultValue = "1") Integer currentPage){ 28 | PageResult momentListWithPublish = momentService.getMomentListWithPublish(currentPage); 29 | return momentListWithPublish; 30 | } 31 | 32 | @PostMapping("/likeMoment/{id}") 33 | public Result likeMomentById(@PathVariable("id")Integer id){ 34 | boolean likeByMomentId = momentService.addLikeByMomentId(id); 35 | if(likeByMomentId){ 36 | log.info("点赞操作成功"); 37 | return Result.success("点赞成功"); 38 | }else{ 39 | log.error("点赞操作失败"); 40 | return Result.error("点赞失败"); 41 | } 42 | } 43 | 44 | @GetMapping("/queryMomentById/{id}") 45 | public Result getMomentById(@PathVariable("id") Integer id){ 46 | Moment momentById = momentService.getMomentByIdToHtml(id); 47 | return Result.success("请求成功",momentById); 48 | } 49 | 50 | @GetMapping("/momentCount") 51 | public Result getMomentCountWithPublish(){ 52 | return Result.success("请求成功", momentService.getMomentCountWithPublish()); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/controller/SiteSettingController.java: -------------------------------------------------------------------------------- 1 | package com.datealive.controller; 2 | 3 | import com.datealive.common.Result; 4 | import com.datealive.common.ResultCode; 5 | import com.datealive.service.SiteSettingService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import java.util.Map; 12 | 13 | /** 14 | * @ClassName: SiteSettingController 15 | * @Description: TODO 16 | * @author: datealive 17 | * @date: 2021/2/26 12:57 18 | */ 19 | @RestController 20 | @Slf4j 21 | public class SiteSettingController { 22 | 23 | @Autowired 24 | SiteSettingService siteSettingService; 25 | 26 | @GetMapping("/siteInfo") 27 | public Result getSiteInfo(){ 28 | Map siteInfo = siteSettingService.getSiteInfo(); 29 | if(siteInfo.isEmpty()){ 30 | return Result.error(ResultCode.Not_Found,"无数据"); 31 | }else{ 32 | return Result.success("请求成功",siteInfo); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/controller/TagController.java: -------------------------------------------------------------------------------- 1 | package com.datealive.controller; 2 | 3 | import com.datealive.common.PageResult; 4 | import com.datealive.common.Result; 5 | import com.datealive.common.ResultCode; 6 | import com.datealive.pojo.Tag; 7 | import com.datealive.service.TagService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestParam; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * @ClassName: TagController 18 | * @Description: TODO 19 | * @author: datealive 20 | * @date: 2021/2/3 12:22 21 | */ 22 | @RestController 23 | public class TagController { 24 | 25 | @Autowired 26 | TagService tagService; 27 | 28 | @GetMapping("/getAllTag") 29 | public Result getAllTag(){ 30 | List tagIdAndName = tagService.getTagIdAndName(); 31 | if(tagIdAndName.isEmpty()){ 32 | return Result.error(ResultCode.Not_Found,"无数据"); 33 | }else{ 34 | return Result.success("请求成功",tagIdAndName); 35 | } 36 | } 37 | 38 | @GetMapping("/getTagByName/{name}") 39 | public Result getTagByName(@PathVariable("name") String tag_name){ 40 | com.datealive.service.vo.Tag tagByName = tagService.getTagByName(tag_name); 41 | if(tagByName==null){ 42 | return Result.error(ResultCode.Not_Found,"无数据"); 43 | }else{ 44 | return Result.success("请求成功",tagByName); 45 | } 46 | } 47 | 48 | @GetMapping("/tagBlogs/{id}") 49 | public PageResult getTagBlogs(@PathVariable("id") Integer tag_id, @RequestParam(defaultValue = "1") Integer currentPage){ 50 | PageResult blogInfoByTag = tagService.getBlogInfoByTag(tag_id, currentPage); 51 | return blogInfoByTag; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.datealive.controller; 2 | 3 | import com.datealive.annotation.LogAnno; 4 | import com.datealive.common.PageResult; 5 | import com.datealive.common.Result; 6 | import com.datealive.common.ResultCode; 7 | import com.datealive.pojo.Comment; 8 | import com.datealive.pojo.User; 9 | import com.datealive.service.CommentService; 10 | import com.datealive.service.UserService; 11 | import com.datealive.service.dto.CommentQuery; 12 | import com.datealive.utils.QQInfoUtils; 13 | import com.datealive.utils.UserAgentUtils; 14 | import com.datealive.utils.UserUtils; 15 | import org.apache.shiro.authz.annotation.RequiresAuthentication; 16 | import org.crazycake.shiro.RedisCache; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.validation.annotation.Validated; 19 | import org.springframework.web.bind.annotation.*; 20 | 21 | import java.io.UnsupportedEncodingException; 22 | import java.util.HashMap; 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | /** 27 | * @ClassName: UserController 28 | * @Description: TODO 29 | * @author: datealive 30 | * @date: 2021/1/31 12:59 31 | */ 32 | @RestController 33 | public class TestController { 34 | 35 | @Autowired 36 | UserService userService; 37 | @Autowired 38 | CommentService commentService; 39 | @Autowired 40 | UserAgentUtils agentUtils; 41 | 42 | 43 | // @RequiresAuthentication 44 | // @RequestMapping("/test") 45 | // public Result test(){ 46 | // 47 | // String testname="admin"; 48 | // User user = userService.getUserByName(testname); 49 | // return Result.success("成功",user); 50 | // } 51 | // 52 | // @PostMapping("/user") 53 | // public Result user(@Validated @RequestBody User user){ 54 | // return Result.success("获取成功", user); 55 | // } 56 | // 57 | // @GetMapping("/qqtest/{qq}") 58 | // public Result getQQavatar(@PathVariable("qq")String qq) throws UnsupportedEncodingException { 59 | // //对应的QQ获取头像类有自动切割qq邮箱的功能,所以这里不需要自己去切割了 60 | // String substring = qq.substring(0, qq.indexOf('@')); 61 | // System.out.println(substring); 62 | // String qqAvatarURL = QQInfoUtils.getQQAvatarURL(qq); 63 | // String qqNickname = QQInfoUtils.getQQNickname(qq); 64 | // Map map = new HashMap<>(); 65 | // map.put("qqAvatarURL",qqAvatarURL); 66 | // map.put("qqNickname",qqNickname); 67 | // return Result.success("请求成功",map); 68 | // 69 | // } 70 | // @GetMapping("/ipadress/{ip}") 71 | // public Result ipadress(@PathVariable("ip") String ip){ 72 | // String cityInfo = UserUtils.getCityInfo(ip); 73 | // return Result.success("请求成功",cityInfo); 74 | // } 75 | // 76 | // @LogAnno(operateType="error",description = "异常",classification = 0) 77 | // @GetMapping("/testError") 78 | // public Result testError() throws Exception{ 79 | // throw new Exception("我抛出来的"); 80 | // } 81 | 82 | 83 | } 84 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/controller/admin/CateGoryAdminController.java: -------------------------------------------------------------------------------- 1 | package com.datealive.controller.admin; 2 | 3 | 4 | import com.datealive.annotation.LogAnno; 5 | import com.datealive.common.PageResult; 6 | import com.datealive.common.Result; 7 | import com.datealive.service.CateGoryService; 8 | import com.datealive.service.vo.CateGory; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.apache.shiro.authz.annotation.Logical; 11 | import org.apache.shiro.authz.annotation.RequiresAuthentication; 12 | import org.apache.shiro.authz.annotation.RequiresPermissions; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.transaction.annotation.Transactional; 15 | import org.springframework.validation.annotation.Validated; 16 | import org.springframework.web.bind.annotation.*; 17 | 18 | /** 19 | * @ClassName: CateGoryAdminController 20 | * @Description: TODO 21 | * @author: datealive 22 | * @date: 2021/2/2 21:17 23 | */ 24 | @RestController 25 | @RequestMapping("/admin") 26 | @Slf4j 27 | public class CateGoryAdminController { 28 | 29 | @Autowired 30 | CateGoryService cateGoryService; 31 | 32 | @RequiresPermissions(value ={"admin"},logical= Logical.OR) 33 | @LogAnno(operateType="POST",description = "添加分类",classification = 1) 34 | @RequiresAuthentication 35 | @PostMapping("/saveCategory") 36 | public Result saveCategory(@Validated @RequestBody CateGory cateGory){ 37 | boolean saveCategory = cateGoryService.saveCategory(cateGory); 38 | if(saveCategory){ 39 | return Result.success("添加分类成功",cateGory.getCategory_id()); 40 | }else{ 41 | return Result.error("添加分类失败"); 42 | } 43 | } 44 | 45 | @RequiresPermissions(value ={"admin"},logical= Logical.OR) 46 | @LogAnno(operateType="PUT",description = "修改分类",classification = 1) 47 | @RequiresAuthentication 48 | @PutMapping("/updateCategory") 49 | public Result updateCategory(@Validated @RequestBody CateGory cateGory){ 50 | boolean updateCategory = cateGoryService.updateCategory(cateGory); 51 | if(updateCategory){ 52 | return Result.success("修改分类成功"); 53 | }else{ 54 | return Result.error("修改分类失败"); 55 | } 56 | } 57 | 58 | @RequiresPermissions(value ={"admin"},logical= Logical.OR) 59 | @LogAnno(operateType="DELETE",description = "删除分类",classification = 1) 60 | @RequiresAuthentication 61 | @DeleteMapping("/deleteCategory") 62 | public Result deleteCategoryById(@RequestParam Integer category_id){ 63 | //删除某个分类的时候,需要将该分类与文章的分类联系表也删除掉,防止数据出现错误,这里需要开启事务 64 | boolean deleteCategory = cateGoryService.deleteCategory(category_id); 65 | if(deleteCategory){ 66 | log.info("删除分类成功"); 67 | return Result.success("删除分类成功"); 68 | }else{ 69 | log.error("删除分类失败"); 70 | return Result.error("删除分类失败"); 71 | } 72 | } 73 | 74 | @RequiresAuthentication 75 | @GetMapping("/categoryList") 76 | public PageResult getCateGoryByPage(@RequestParam(defaultValue = "1") Integer currentPage){ 77 | PageResult cateGoryByPage = cateGoryService.getCateGoryByPage(currentPage); 78 | return cateGoryByPage; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/controller/admin/LogAdminController.java: -------------------------------------------------------------------------------- 1 | package com.datealive.controller.admin; 2 | 3 | import com.datealive.common.PageResult; 4 | import com.datealive.common.Result; 5 | import com.datealive.pojo.Log; 6 | import com.datealive.service.LogService; 7 | import com.datealive.service.dto.LogQuery; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.shiro.authz.annotation.Logical; 10 | import org.apache.shiro.authz.annotation.RequiresAuthentication; 11 | import org.apache.shiro.authz.annotation.RequiresPermissions; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | /** 16 | * @ClassName: LogAdminController 17 | * @Description: TODO 18 | * @author: datealive 19 | * @date: 2021/2/23 9:46 20 | */ 21 | @RestController 22 | @RequestMapping("/admin") 23 | @Slf4j 24 | public class LogAdminController { 25 | 26 | @Autowired 27 | LogService logService; 28 | 29 | @RequiresAuthentication 30 | @PostMapping("/logList/query") 31 | public PageResult getLogListByLogQuery(@RequestBody LogQuery logQuery){ 32 | return logService.getLogListByLogQuery(logQuery); 33 | } 34 | 35 | @RequiresPermissions(value ={"admin"},logical= Logical.OR) 36 | @RequiresAuthentication 37 | @DeleteMapping("/deleteLog") 38 | public Result deleteLogById(@RequestParam Integer id){ 39 | boolean deleteLogById = logService.deleteLogById(id); 40 | if(deleteLogById){ 41 | return Result.success("删除成功"); 42 | }else{ 43 | return Result.error("删除失败"); 44 | } 45 | } 46 | 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/controller/admin/SiteSettingAdminController.java: -------------------------------------------------------------------------------- 1 | package com.datealive.controller.admin; 2 | 3 | import com.datealive.annotation.LogAnno; 4 | import com.datealive.common.Result; 5 | import com.datealive.common.ResultCode; 6 | import com.datealive.pojo.SiteSetting; 7 | import com.datealive.service.SiteSettingService; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.shiro.authz.annotation.Logical; 10 | import org.apache.shiro.authz.annotation.RequiresAuthentication; 11 | import org.apache.shiro.authz.annotation.RequiresPermissions; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | import java.util.LinkedHashMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | /** 20 | * @ClassName: SiteSettingAdminController 21 | * @Description: TODO 22 | * @author: datealive 23 | * @date: 2021/2/26 10:16 24 | */ 25 | @RestController 26 | @RequestMapping("/admin") 27 | @Slf4j 28 | public class SiteSettingAdminController { 29 | 30 | @Autowired 31 | SiteSettingService siteSettingService; 32 | 33 | /** 34 | * 获取所有站点配置信息 35 | * 36 | * @return 37 | */ 38 | @RequiresAuthentication 39 | @GetMapping("/siteSettings") 40 | public Result siteSettings() { 41 | Map> typeMap = siteSettingService.getSiteList(); 42 | if(typeMap.isEmpty()){ 43 | return Result.error(ResultCode.Not_Found,"数据为空"); 44 | } 45 | return Result.success("请求成功", typeMap); 46 | } 47 | 48 | /** 49 | * 修改、删除(部分配置可为空,但不可删除)、添加(只能添加部分)站点配置 50 | * 51 | * @param map 包含所有站点信息更新后的数据 map => {settings=[更新后的所有配置List], deleteIds=[要删除的配置id List]} 52 | * @return 53 | */ 54 | @RequiresPermissions(value ={"admin"},logical= Logical.OR) 55 | @LogAnno(operateType="POST",description = "修改站点信息",classification = 1) 56 | @RequiresAuthentication 57 | @PostMapping("/saveSiteSettings") 58 | public Result updateAll(@RequestBody Map map) { 59 | List siteSettings = (List) map.get("settings"); 60 | List deleteIds = (List) map.get("deleteIds"); 61 | siteSettingService.updateSiteSetting(siteSettings, deleteIds); 62 | return Result.success("更新成功"); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/controller/admin/TagAdminController.java: -------------------------------------------------------------------------------- 1 | package com.datealive.controller.admin; 2 | 3 | import com.datealive.annotation.LogAnno; 4 | import com.datealive.common.PageResult; 5 | import com.datealive.common.Result; 6 | import com.datealive.service.TagService; 7 | import com.datealive.service.vo.Tag; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.shiro.authz.annotation.Logical; 10 | import org.apache.shiro.authz.annotation.RequiresAuthentication; 11 | import org.apache.shiro.authz.annotation.RequiresPermissions; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.validation.annotation.Validated; 14 | import org.springframework.web.bind.annotation.*; 15 | 16 | /** 17 | * @ClassName: TagAdminController 18 | * @Description: TODO 19 | * @author: datealive 20 | * @date: 2021/2/3 18:58 21 | */ 22 | @RestController 23 | @RequestMapping("/admin") 24 | @Slf4j 25 | public class TagAdminController { 26 | 27 | @Autowired 28 | TagService tagService; 29 | 30 | @RequiresPermissions(value ={"admin"},logical= Logical.OR) 31 | @LogAnno(operateType="POST",description = "添加标签",classification = 1) 32 | @RequiresAuthentication 33 | @PostMapping("/saveTag") 34 | public Result saveTag(@Validated @RequestBody Tag tag){ 35 | boolean saveTag = tagService.saveTag(tag); 36 | if(saveTag){ 37 | return Result.success("添加标签成功",tag.getTag_id()); 38 | }else{ 39 | return Result.error("添加标签失败"); 40 | } 41 | } 42 | 43 | @RequiresPermissions(value ={"admin"},logical= Logical.OR) 44 | @LogAnno(operateType="PUT",description = "修改标签",classification = 1) 45 | @RequiresAuthentication 46 | @PutMapping("/updateTag") 47 | public Result updateTag(@Validated @RequestBody Tag tag){ 48 | boolean updateTag = tagService.updateTag(tag); 49 | if(updateTag){ 50 | return Result.success("修改标签成功"); 51 | }else{ 52 | return Result.error("修改标签失败"); 53 | } 54 | } 55 | 56 | @RequiresPermissions(value ={"admin"},logical= Logical.OR) 57 | @LogAnno(operateType="DELETE",description = "删除标签",classification = 1) 58 | @RequiresAuthentication 59 | @DeleteMapping("/deleteTag") 60 | public Result deleteTag(@RequestParam Integer tag_id){ 61 | boolean deleteTag = tagService.deleteTag(tag_id); 62 | if(deleteTag){ 63 | log.info("删除标签成功"); 64 | return Result.success("删除标签成功"); 65 | }else{ 66 | log.error("删除标签失败"); 67 | return Result.error("删除标签失败"); 68 | } 69 | } 70 | 71 | @RequiresAuthentication 72 | @GetMapping("/tagList") 73 | public PageResult getTagByPage(@RequestParam(defaultValue = "1") Integer currentPage){ 74 | PageResult tagByPage = tagService.getTagByPage(currentPage); 75 | return tagByPage; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/controller/admin/UpLoadController.java: -------------------------------------------------------------------------------- 1 | package com.datealive.controller.admin; 2 | 3 | import com.datealive.annotation.LogAnno; 4 | import com.datealive.common.Result; 5 | import com.datealive.service.UpLoadService; 6 | import com.datealive.shiro.MyProfile; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.apache.commons.io.IOUtils; 9 | import org.apache.shiro.authz.annotation.Logical; 10 | import org.apache.shiro.authz.annotation.RequiresAuthentication; 11 | import org.apache.shiro.authz.annotation.RequiresPermissions; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.beans.factory.annotation.Value; 14 | import org.springframework.util.ResourceUtils; 15 | import org.springframework.web.bind.annotation.PostMapping; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RequestParam; 18 | import org.springframework.web.bind.annotation.RestController; 19 | import org.springframework.web.multipart.MultipartFile; 20 | 21 | import javax.servlet.http.HttpServletRequest; 22 | import java.io.File; 23 | import java.io.FileNotFoundException; 24 | import java.io.FileOutputStream; 25 | import java.io.IOException; 26 | import java.security.Principal; 27 | import java.text.SimpleDateFormat; 28 | import java.util.Date; 29 | import java.util.UUID; 30 | 31 | /** 32 | * @ClassName: UpLoadController 33 | * @Description: TODO 34 | * @author: datealive 35 | * @date: 2021/2/8 16:44 36 | */ 37 | @RestController 38 | @RequestMapping("/admin") 39 | @Slf4j 40 | public class UpLoadController { 41 | 42 | @Autowired 43 | UpLoadService upLoadService; 44 | 45 | @RequiresPermissions(value ={"admin"},logical= Logical.OR) 46 | @RequiresAuthentication 47 | @LogAnno(operateType="POST",description = "上传图片",classification = 1) 48 | @PostMapping("/uploadImg") 49 | public Result UpLoadImg(HttpServletRequest request, @RequestParam("blog_img") MultipartFile file){ 50 | Result result = upLoadService.UpLoadImage(request, file); 51 | return result; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/exception/AllExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.datealive.exception; 2 | 3 | import com.datealive.common.Result; 4 | import com.datealive.common.ResultCode; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.shiro.ShiroException; 7 | import org.apache.shiro.authz.AuthorizationException; 8 | import org.apache.shiro.authz.UnauthenticatedException; 9 | import org.apache.shiro.authz.UnauthorizedException; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.validation.BindingResult; 12 | import org.springframework.validation.ObjectError; 13 | import org.springframework.web.bind.MethodArgumentNotValidException; 14 | import org.springframework.web.bind.annotation.ExceptionHandler; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | import org.springframework.web.bind.annotation.ResponseStatus; 17 | import org.springframework.web.bind.annotation.RestControllerAdvice; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | /** 23 | * @ClassName: ExceptionHandler 24 | * @Description: TODO 25 | * @author: datealive 26 | * @date: 2021/1/31 18:03 27 | */ 28 | @Slf4j 29 | @RestControllerAdvice 30 | public class AllExceptionHandler { 31 | 32 | @ResponseStatus(HttpStatus.BAD_REQUEST) 33 | @ExceptionHandler(value = RuntimeException.class) 34 | public Result handler(RuntimeException e) { 35 | log.error("运行时异常:----------------{}", e); 36 | return Result.error(e.getMessage()); 37 | } 38 | 39 | 40 | @ResponseStatus(HttpStatus.UNAUTHORIZED) 41 | @ExceptionHandler(value = ShiroException.class) 42 | public Result handler(ShiroException e) { 43 | log.error("shiro异常:----------------{}", e); 44 | return Result.error(ResultCode.Un_authorized,e.getMessage()); 45 | } 46 | 47 | @ResponseStatus(HttpStatus.FORBIDDEN) 48 | @ExceptionHandler(value = UnauthorizedException.class) 49 | public Result handler(UnauthorizedException e) { 50 | log.error("权限异常:----------------{}", e); 51 | return Result.error(ResultCode.Forbidden,"权限不足"); 52 | } 53 | 54 | 55 | 56 | 57 | @ResponseStatus(HttpStatus.BAD_REQUEST) 58 | @ExceptionHandler(value = MethodArgumentNotValidException.class) 59 | public Result handler(MethodArgumentNotValidException e) { 60 | log.error("实体校验异常:----------------{}", e); 61 | BindingResult bindingResult = e.getBindingResult(); 62 | ObjectError objectError = bindingResult.getAllErrors().stream().findFirst().get(); 63 | return Result.error(objectError.getDefaultMessage()); 64 | } 65 | 66 | @ResponseStatus(HttpStatus.BAD_REQUEST) 67 | @ExceptionHandler(value = IllegalArgumentException.class) 68 | public Result handler(IllegalArgumentException e) { 69 | log.error("Assert异常:----------------{}", e); 70 | return Result.error(e.getMessage()); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/mapper/CateGoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.datealive.mapper; 2 | 3 | import com.datealive.common.PageResult; 4 | import com.datealive.service.vo.BlogArticleInfo; 5 | import com.datealive.service.vo.CateGory; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.apache.ibatis.annotations.Param; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @ClassName: CateGoryMapper 14 | * @Description: TODO 15 | * @author: datealive 16 | * @date: 2021/2/1 20:05 17 | */ 18 | @Mapper 19 | @Repository 20 | public interface CateGoryMapper { 21 | 22 | /** 23 | * 查询所有分类的id和名字 注意这里的Category是在vo包下的 24 | * @return 25 | */ 26 | public List getGateGoryIdAndName(); 27 | 28 | /** 29 | * 根据分类id查询该分类下所有博客文章 30 | * @param category_id 31 | * @return 32 | */ 33 | public List getBlogInfoByCategory(@Param("category_id")Integer category_id); 34 | 35 | /** 36 | * 获取分类的数量 37 | * @return 38 | */ 39 | public int getCateGoryCnt(); 40 | 41 | /** 42 | * 获取某个分类的文章数量 43 | * @param category_id 44 | * @return 45 | */ 46 | public int getCateGoryBlogCnt(@Param("category_id")Integer category_id); 47 | 48 | /** 49 | * 根据分类名称获取分类 50 | * @param category_name 51 | * @return 52 | */ 53 | public CateGory getCateGoryByName(@Param("category_name") String category_name); 54 | /** 55 | * 添加分类 56 | * @param cateGory 57 | * @return 58 | */ 59 | public int saveCategory(CateGory cateGory); 60 | 61 | /** 62 | * 修改分类 63 | * @param cateGory 64 | * @return 65 | */ 66 | public int updateCategory(CateGory cateGory); 67 | 68 | /** 69 | * 根据分类id删除分类表 70 | * @param category_id 71 | * @return 72 | */ 73 | public int deleteCategory(@Param("category_id")Integer category_id); 74 | 75 | /** 76 | * 根据文章id和分类id添加分类联系表 77 | * @param blog_id 78 | * @param category_id 79 | * @return 80 | */ 81 | public int saveCategoryRelation(@Param("blog_id")Integer blog_id,@Param("category_id")Integer category_id); 82 | 83 | /** 84 | * 根据文章id和分类id查找联系id 85 | * @param blog_id 86 | * @param category_id 87 | * @return 88 | */ 89 | public int getRelationId(@Param("blog_id")Integer blog_id,@Param("category_id")Integer category_id); 90 | 91 | /** 92 | * 根据文章id和分类id修改分类联系表 93 | * @param blog_id 94 | * @param category_id 95 | * @return 96 | */ 97 | public int updateCategoryRelation(@Param("blog_id")Integer blog_id,@Param("category_id")Integer category_id,@Param("relation_id")Integer relation_id); 98 | 99 | /** 100 | * 根据分类id删除分类联系表 101 | * @param category_id 102 | * @return 103 | */ 104 | public int deleteCategoryRelationBycateId(@Param("category_id")Integer category_id); 105 | 106 | /** 107 | * 根据文章id删除分类联系表 108 | * @param blog_id 109 | * @return 110 | */ 111 | public int deleteCateGoryRelationByblogId(@Param("blog_id")Integer blog_id); 112 | } 113 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/mapper/CommentMapper.java: -------------------------------------------------------------------------------- 1 | package com.datealive.mapper; 2 | 3 | 4 | import com.datealive.pojo.Comment; 5 | import com.datealive.service.dto.CommentQuery; 6 | import com.datealive.service.vo.CommentSub; 7 | import org.apache.ibatis.annotations.Mapper; 8 | import org.apache.ibatis.annotations.Param; 9 | import org.springframework.stereotype.Repository; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @ClassName: CommentMapper 15 | * @Description: TODO 16 | * @author: datealive 17 | * @date: 2021/2/9 19:49 18 | */ 19 | @Mapper 20 | @Repository 21 | public interface CommentMapper { 22 | /** 23 | * 查询父级评论 24 | * @param commentQuery 25 | * @return 26 | */ 27 | public List getParentComment(CommentQuery commentQuery); 28 | 29 | /** 30 | * 查询子级评论 31 | * @param comment_id 32 | * @return 33 | */ 34 | public List getChildComment(@Param("comment_id") Integer comment_id); 35 | 36 | /** 37 | * 查询父级评论的数量 38 | * @param commentQuery 39 | * @return 40 | */ 41 | public int getParentCommentCnt(CommentQuery commentQuery); 42 | 43 | /** 44 | * 后台获取所有评论 45 | * @return 46 | */ 47 | public List getAllComment(); 48 | 49 | /** 50 | * 根据评论者名称搜索评论 51 | * @param nick_name 52 | * @return 53 | */ 54 | public List getCommentByNickName(@Param("nick_name")String nick_name); 55 | 56 | /** 57 | * 根据commentid查询子级评论,这里的没有is_check的判断 58 | * @param comment_id 59 | * @return 60 | */ 61 | public List getCommentByCommentId(@Param("comment_id") Integer comment_id); 62 | 63 | /** 64 | * 所有评论的数量 65 | * @return 66 | */ 67 | public int getAllCommentCnt(); 68 | 69 | /** 70 | * 提交评论 71 | * @param commentSub 72 | * @return 73 | */ 74 | public int saveComment(CommentSub commentSub); 75 | 76 | /** 77 | * 删除评论,如果是父级,还要删除子级评论 78 | * @param comment_id 79 | * @return 80 | */ 81 | public int deleteComment(@Param("comment_id")Integer comment_id); 82 | 83 | /** 84 | * 修改评论的状态 85 | * @param comment_id 86 | * @param is_check 87 | * @return 88 | */ 89 | public int checkComment(@Param("comment_id")Integer comment_id,@Param("is_check")Integer is_check); 90 | 91 | /** 92 | * 根据commentId找到对应的评论邮箱 93 | * @param comment_id 94 | * @return 95 | */ 96 | public String getEmailByCommentId(@Param("comment_id")Integer comment_id); 97 | 98 | /** 99 | * 根据pid查找对应的父级评论 100 | * @param comment_id 101 | * @return 102 | */ 103 | public Comment getCommentByPid(@Param("comment_id")Integer comment_id); 104 | } 105 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/mapper/FriendsMapper.java: -------------------------------------------------------------------------------- 1 | package com.datealive.mapper; 2 | 3 | import com.datealive.pojo.Friends; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @ClassName: FriendsMapper 12 | * @Description: TODO 13 | * @author: datealive 14 | * @date: 2021/2/1 16:59 15 | */ 16 | @Mapper 17 | @Repository 18 | public interface FriendsMapper { 19 | /** 20 | * 获取已经审核通过的友链 21 | * @return 22 | */ 23 | public List getAllFriends(); 24 | 25 | /** 26 | * 管理员获得所有友链 27 | * @return 28 | */ 29 | public List getAllFriendsWithStatus(); 30 | /** 31 | * 获取友链数量 32 | * @return 33 | */ 34 | public int getFriendsCnt(); 35 | 36 | /** 37 | * 通过名字查找友链 38 | * @param link_name 39 | * @return 40 | */ 41 | public List queryFriendsByName(@Param("link_name") String link_name); 42 | 43 | /** 44 | * 添加友链 45 | * @param friends 46 | * @return 47 | */ 48 | public int saveFriend(Friends friends); 49 | 50 | /** 51 | * 更新友链 52 | * @param friends 53 | * @return 54 | */ 55 | public int updateFriend(Friends friends); 56 | 57 | /** 58 | * 更新友链状态 59 | * @param link_id 60 | * @return 61 | */ 62 | public int updateStatus(@Param("link_id") Integer link_id,@Param("status") Integer status); 63 | 64 | /** 65 | * 根据id删除友链 66 | * @param link_id 67 | * @return 68 | */ 69 | public int deleteFriend(@Param("link_id")Integer link_id); 70 | 71 | } 72 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/mapper/LogMapper.java: -------------------------------------------------------------------------------- 1 | package com.datealive.mapper; 2 | 3 | import java.util.List; 4 | 5 | import com.datealive.pojo.Log; 6 | import com.datealive.service.dto.LogQuery; 7 | import org.apache.ibatis.annotations.Mapper; 8 | import org.apache.ibatis.annotations.Param; 9 | import org.springframework.stereotype.Repository; 10 | 11 | 12 | 13 | /** 14 | * @Classname LogMapper 15 | * @Description 日志Mapper 16 | * @Date 2021/2/17 15:06 17 | * @author 冰羽 18 | */ 19 | 20 | @Mapper 21 | @Repository 22 | public interface LogMapper { 23 | 24 | /*** 25 | * //向数据库添加日志 26 | * @param log 27 | * @return 28 | */ 29 | int insertLog(Log log); 30 | 31 | /** 32 | * 根据LogQuery 的查询条件查询log日志 33 | * @param logQuery 34 | * @return 35 | */ 36 | public List getLogListByLogQuery(LogQuery logQuery); 37 | 38 | /** 39 | * 查询不同分类log的数量 40 | * @param classification 41 | * @return 42 | */ 43 | public int getLogCountByClassification(@Param("classification") Integer classification); 44 | 45 | /** 46 | * 根据id删除日志 47 | * @param id 48 | * @return 49 | */ 50 | public int deleteLog(@Param("id")Integer id); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/mapper/MomentMapper.java: -------------------------------------------------------------------------------- 1 | package com.datealive.mapper; 2 | 3 | import com.datealive.pojo.Moment; 4 | import io.swagger.models.auth.In; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @ClassName: MomentMapper 13 | * @Description: TODO 14 | * @author: datealive 15 | * @date: 2021/2/17 18:20 16 | */ 17 | @Mapper 18 | @Repository 19 | public interface MomentMapper { 20 | /** 21 | * 获取所有动态 22 | * @return 23 | */ 24 | List getMomentList(); 25 | 26 | /** 27 | * 获取已经发布的动态 28 | * @return 29 | */ 30 | List getMomentListWithPublish(); 31 | 32 | /** 33 | * 点赞动态 34 | * @param momentId 35 | * @return 36 | */ 37 | int addLikeByMomentId(Integer momentId); 38 | 39 | /** 40 | * 更新动态状态 41 | * @param momentId 42 | * @param is_published 43 | * @return 44 | */ 45 | int updateMomentPublishedById(@Param("momentId") Integer momentId, @Param("is_published") Integer is_published); 46 | 47 | /** 48 | * 根据id获取动态 49 | * @param id 50 | * @return 51 | */ 52 | Moment getMomentById(Integer id); 53 | 54 | /** 55 | * 根据id删除动态 56 | * @param id 57 | * @return 58 | */ 59 | int deleteMomentById(Integer id); 60 | 61 | /** 62 | * 添加动态 63 | * @param moment 64 | * @return 65 | */ 66 | int saveMoment(Moment moment); 67 | 68 | /** 69 | * 更新动态 70 | * @param moment 71 | * @return 72 | */ 73 | int updateMoment(Moment moment); 74 | 75 | /** 76 | * 获取已经公开的动态数量 77 | * @return 78 | */ 79 | int getMomentCountWithPublish(); 80 | 81 | /** 82 | * 获取所有动态 83 | * @return 84 | */ 85 | int getMomentCount(); 86 | } 87 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/mapper/SiteSettingMapper.java: -------------------------------------------------------------------------------- 1 | package com.datealive.mapper; 2 | 3 | import com.datealive.pojo.SiteSetting; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @ClassName: SiteSettingMapper 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/26 9:04 14 | */ 15 | @Mapper 16 | @Repository 17 | public interface SiteSettingMapper { 18 | /** 19 | * 获取站点配置list 20 | * @return 21 | */ 22 | List getList(); 23 | 24 | /** 25 | * 获取友链页面信息自定义 26 | * @return 27 | */ 28 | List getFriendInfo(); 29 | 30 | /** 31 | * 更新站点自定义 32 | * @param siteSetting 33 | * @return 34 | */ 35 | int updateSiteSetting(SiteSetting siteSetting); 36 | 37 | /** 38 | * 根据id删除站点自定义 39 | * @param id 40 | * @return 41 | */ 42 | int deleteSiteSettingById(Integer id); 43 | 44 | /** 45 | * 插入站点自定义 46 | * @param siteSetting 47 | * @return 48 | */ 49 | int saveSiteSetting(SiteSetting siteSetting); 50 | } 51 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/mapper/TagMapper.java: -------------------------------------------------------------------------------- 1 | package com.datealive.mapper; 2 | 3 | import com.datealive.service.vo.CateGory; 4 | import com.datealive.service.vo.Tag; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @ClassName: TagMapper 13 | * @Description: TODO 14 | * @author: datealive 15 | * @date: 2021/2/3 10:30 16 | */ 17 | @Mapper 18 | @Repository 19 | public interface TagMapper { 20 | 21 | /** 22 | * 查询所有标签的id和名字 注意这里的Tag是在vo包下的 23 | * @return 24 | */ 25 | public List getTagIdAndName(); 26 | 27 | /** 28 | * 根据标签id查询该分类下所有博客文章 29 | * @param tag_id 30 | * @return 31 | */ 32 | public List getBlogInfoByTag(@Param("tag_id")Integer tag_id); 33 | 34 | /** 35 | * 获取某个标签的文章数量 36 | * @param tag_id 37 | * @return 38 | */ 39 | public int getTagCntBlog(@Param("tag_id")Integer tag_id); 40 | 41 | /** 42 | * 根据标签名称获取标签 43 | * @param tag_name 44 | * @return 45 | */ 46 | public Tag getTagByName(@Param("tag_name") String tag_name); 47 | 48 | /** 49 | * 获取标签的数量 50 | * @return 51 | */ 52 | public int getTagCnt(); 53 | 54 | /** 55 | * 添加标签 56 | * @param tag 57 | * @return 58 | */ 59 | public int saveTag(Tag tag); 60 | 61 | /** 62 | * 修改标签 63 | * @param tag 64 | * @return 65 | */ 66 | public int updateTag(Tag tag); 67 | 68 | /** 69 | * 根据标签id删除标签表 70 | * @param tag_id 71 | * @return 72 | */ 73 | public int deleteTag(@Param("tag_id")Integer tag_id); 74 | 75 | /** 76 | * 根据标签id和分类id添加标签联系表 77 | * @param blog_id 78 | * @param tag_id 79 | * @return 80 | */ 81 | public int saveTagRelation(@Param("blog_id")Integer blog_id,@Param("tag_id")Integer tag_id); 82 | 83 | /** 84 | * 根据文章id和标签id查找联系id 85 | * @param blog_id 86 | * @param tag_id 87 | * @return 88 | */ 89 | public int getRelationId(@Param("blog_id")Integer blog_id,@Param("tag_id")Integer tag_id); 90 | 91 | /** 92 | * 根据联系id,标签id和文章id修改tag联系表 93 | * @param blog_id 94 | * @param tag_id 95 | * @param relation_id 96 | * @return 97 | */ 98 | public int updateTagRelation(@Param("blog_id")Integer blog_id,@Param("tag_id")Integer tag_id,@Param("relation_id")Integer relation_id); 99 | 100 | /** 101 | * 根据标签id删除标签联系表 102 | * @param tag_id 103 | * @return 104 | */ 105 | public int deleteTagRelationBytagId(@Param("tag_id")Integer tag_id); 106 | 107 | /** 108 | * 根据文章id删除标签联系表 109 | * @param blog_id 110 | * @return 111 | */ 112 | public int deleteTagRelationByblogId(@Param("blog_id")Integer blog_id); 113 | 114 | } 115 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.datealive.mapper; 2 | 3 | import com.datealive.pojo.User; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | import org.springframework.stereotype.Repository; 7 | 8 | /** 9 | * @ClassName: UserMapper 10 | * @Description: TODO 11 | * @author: datealive 12 | * @date: 2021/1/31 12:41 13 | */ 14 | @Mapper 15 | @Repository 16 | public interface UserMapper { 17 | 18 | /** 19 | * 通过名字查找用户 20 | * @param username 21 | * @return 22 | */ 23 | User getUserByName(@Param("username") String username); 24 | 25 | /** 26 | * 根据id查找用户 27 | * @param userId 28 | * @return 29 | */ 30 | User getUserById(@Param("userId")Integer userId); 31 | 32 | /** 33 | * 修改密码 34 | * @param userName 35 | * @param password 36 | * @return 37 | */ 38 | int changePassword(@Param("userName") String userName,@Param("password") String password); 39 | 40 | /** 41 | * 注册用户 42 | * @param user 43 | * @return 44 | */ 45 | int registerUser(User user); 46 | } 47 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/pojo/BlogArticle.java: -------------------------------------------------------------------------------- 1 | package com.datealive.pojo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.hibernate.validator.constraints.NotBlank; 8 | 9 | import java.lang.ref.PhantomReference; 10 | import java.util.ArrayList; 11 | import java.util.Date; 12 | import java.util.List; 13 | 14 | /** 15 | * @ClassName: BlogArticle 16 | * @Description: TODO 17 | * @author: datealive 18 | * @date: 2021/1/31 20:13 19 | */ 20 | @Data 21 | @AllArgsConstructor 22 | @NoArgsConstructor 23 | public class BlogArticle { 24 | 25 | private Integer blog_id; 26 | @NotBlank(message = "文章不能为空") 27 | private String blog_title; 28 | private String blog_cover_image; 29 | private String blog_content; 30 | 31 | private String blog_summary; 32 | private Integer blog_status; 33 | private Integer blog_visits; 34 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") 35 | private Date create_time; 36 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") 37 | private Date update_time; 38 | private Integer is_top; 39 | private Integer blog_like; 40 | private Integer comment_cnt; 41 | 42 | /** 43 | * 分类 44 | */ 45 | private List cateGory=new ArrayList<>(); 46 | 47 | /** 48 | * 标签 49 | * */ 50 | private List tags=new ArrayList<>(); 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/pojo/CateGory.java: -------------------------------------------------------------------------------- 1 | package com.datealive.pojo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.hibernate.validator.constraints.NotBlank; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * @ClassName: CateGory 13 | * @Description: TODO 14 | * @author: datealive 15 | * @date: 2021/1/31 20:28 16 | */ 17 | @Data 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | public class CateGory { 21 | 22 | private Integer category_id; 23 | @NotBlank(message = "分类不能为空") 24 | private String category_name; 25 | 26 | /** 27 | * 该分类下的所有文章 28 | */ 29 | private List blogs=new ArrayList<>(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/pojo/Comment.java: -------------------------------------------------------------------------------- 1 | package com.datealive.pojo; 2 | 3 | import com.datealive.service.vo.BlogArticleIdAndTitle; 4 | import com.fasterxml.jackson.annotation.JsonFormat; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.hibernate.validator.constraints.NotBlank; 9 | 10 | import java.util.ArrayList; 11 | import java.util.Date; 12 | import java.util.List; 13 | 14 | /** 15 | * @ClassName: Comment 16 | * @Description: TODO 17 | * @author: datealive 18 | * @date: 2021/1/31 20:32 19 | */ 20 | @Data 21 | @AllArgsConstructor 22 | @NoArgsConstructor 23 | public class Comment { 24 | 25 | private Integer comment_id; 26 | @NotBlank(message = "评论内容不能为空") 27 | private String content; 28 | private Integer blog_id; 29 | @NotBlank(message = "昵称不能为空") 30 | private String nick_name; 31 | private String avatar; 32 | private String email; 33 | private String reply_nick_name; 34 | private Integer pid; 35 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") 36 | private Date create_time; 37 | private String site_url; 38 | private Integer page; 39 | private Integer is_check; 40 | 41 | private List replyComments=new ArrayList<>(); 42 | } 43 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/pojo/Friends.java: -------------------------------------------------------------------------------- 1 | package com.datealive.pojo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.hibernate.validator.constraints.NotBlank; 7 | 8 | /** 9 | * @ClassName: Friends 10 | * @Description: TODO 11 | * @author: datealive 12 | * @date: 2021/1/31 20:11 13 | */ 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | public class Friends { 18 | 19 | private Integer link_id; 20 | @NotBlank(message = "站点名称不能为空") 21 | private String link_name; 22 | @NotBlank(message = "站点url不能为空") 23 | private String link_url; 24 | private String link_info; 25 | private String avatar; 26 | private Integer status; 27 | } 28 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/pojo/Log.java: -------------------------------------------------------------------------------- 1 | package com.datealive.pojo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * @Classname Log 12 | * @Description 日志实体类 13 | * @Date 2021/2/17 15:06 14 | * @author 冰羽 15 | */ 16 | @Data 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | public class Log { 20 | private Integer id; 21 | 22 | private String operateor; 23 | 24 | private String operatetype; 25 | 26 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") 27 | private Date operatedate; 28 | 29 | private String operateresult; 30 | 31 | private String ip; 32 | 33 | private String ipSource; 34 | 35 | private String description; 36 | 37 | private String os; 38 | 39 | private String browser; 40 | 41 | private String error; 42 | 43 | private Integer classification; 44 | 45 | private Integer SpendTime; 46 | 47 | private String url; 48 | } -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/pojo/Moment.java: -------------------------------------------------------------------------------- 1 | package com.datealive.pojo; 2 | 3 | 4 | import com.fasterxml.jackson.annotation.JsonFormat; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.hibernate.validator.constraints.NotBlank; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * @ClassName: Moment 14 | * @Description: 博客动态,说说 15 | * @author: datealive 16 | * @date: 2021/2/17 18:19 17 | */ 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | public class Moment { 22 | 23 | private Integer id; 24 | @NotBlank(message = "内容不能为空") 25 | private String content; 26 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") 27 | private Date createTime; 28 | private Integer likes; 29 | private Integer published; 30 | } 31 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/pojo/SiteSetting.java: -------------------------------------------------------------------------------- 1 | package com.datealive.pojo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * @ClassName: SiteSetting 10 | * @Description: TODO 11 | * @author: datealive 12 | * @date: 2021/2/26 9:02 13 | */ 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @JsonIgnoreProperties(ignoreUnknown = true) 18 | public class SiteSetting { 19 | 20 | private Integer id; 21 | private String name_en; 22 | private String name_zh; 23 | private String value; 24 | /** 25 | * 1基础设置,2页脚徽标,3资料卡,4友链信息 26 | */ 27 | private Integer type; 28 | } 29 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/pojo/Tag.java: -------------------------------------------------------------------------------- 1 | package com.datealive.pojo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.hibernate.validator.constraints.NotBlank; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * @ClassName: Tag 13 | * @Description: TODO 14 | * @author: datealive 15 | * @date: 2021/1/31 20:26 16 | */ 17 | @Data 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | public class Tag { 21 | 22 | private Integer tag_id; 23 | @NotBlank(message = "标签名称不能为空") 24 | private String tag_name; 25 | /** 26 | * 该标签下的所有文章 27 | */ 28 | private List blogs=new ArrayList<>(); 29 | } 30 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/pojo/User.java: -------------------------------------------------------------------------------- 1 | package com.datealive.pojo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.hibernate.validator.constraints.NotBlank; 7 | 8 | /** 9 | * @ClassName: User 10 | * @Description: TODO 11 | * @author: datealive 12 | * @date: 2021/1/31 12:33 13 | */ 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | public class User { 18 | 19 | private Integer user_id; 20 | 21 | @NotBlank(message = "昵称不能为空") 22 | private String username; 23 | @NotBlank(message = "密码不能为空") 24 | 25 | private String password; 26 | private String nick_name; 27 | private String avatar; 28 | private String introduce; 29 | private String roles; 30 | private String email; 31 | } 32 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/BlogArticleService.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service; 2 | 3 | import com.datealive.common.PageResult; 4 | import com.datealive.pojo.BlogArticle; 5 | import com.datealive.service.vo.BlogArticleIdAndTitle; 6 | import com.datealive.service.vo.BlogArticleInfo; 7 | 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @ClassName: BlogArticleService 13 | * @Description: TODO 14 | * @author: datealive 15 | * @date: 2021/1/31 22:04 16 | */ 17 | public interface BlogArticleService { 18 | 19 | /** 20 | * 根据分页获取全部文章,,不携带内容字段 21 | * 22 | * @return 23 | */ 24 | public PageResult getAllBlogArticle(Integer pageNum); 25 | 26 | /** 27 | * 根据分页获取全部文章,,不携带内容字段 管理员 28 | * @param pageNum 29 | * @return 30 | */ 31 | public PageResult getAllBlogArticleWithStatus(Integer pageNum); 32 | 33 | /** 34 | * 根据title搜索文章 35 | * @param blog_title 36 | * @param pageNum 37 | * @return 38 | */ 39 | public PageResult getBlogArticleByTitle(String blog_title,Integer pageNum); 40 | 41 | /** 42 | * 获取发布的文章总数量 43 | * @return 44 | */ 45 | public int countBlogArticle(); 46 | 47 | /** 48 | * 获取所有文章数量 49 | * @return 50 | */ 51 | public int countBlogArticleWithStatus(); 52 | 53 | /** 54 | * 根据title获取文章数量 55 | * @return 56 | */ 57 | public int countBlogArticleByTitle(String blog_title); 58 | 59 | /** 60 | * 根据文章id获取文章详情 这里返回给后台编写 61 | * @param blog_id 62 | * @return 63 | */ 64 | public BlogArticle getBlogArticleById(Integer blog_id); 65 | 66 | /** 67 | * 根据文章id获取文章详情 这里是转为html返回给前端前台页面 68 | * @param blog_id 69 | * @return 70 | */ 71 | public BlogArticle getBlogArticleByIdToHtml(Integer blog_id); 72 | 73 | /** 74 | * 获取文章id和标题 75 | * @param pageNum 76 | * @return 77 | */ 78 | public PageResult getBlogArticleIdAndTitle(Integer pageNum); 79 | 80 | /** 81 | * 根据id删除文章 82 | * @param blog_id 83 | * @return 84 | */ 85 | public boolean deleteBlogById(Integer blog_id); 86 | 87 | /** 88 | * 添加博客文章 89 | * @param blogArticle 90 | * @return 91 | */ 92 | public boolean saveBlogArticle(BlogArticle blogArticle); 93 | 94 | /** 95 | * 添加文章点赞量 96 | * @param blog_id 97 | * @return 98 | */ 99 | public boolean increaseBlogLike(Integer blog_id); 100 | 101 | /** 102 | * 添加文章访问量 103 | * @param article 104 | * @return 105 | */ 106 | public boolean increaseBlogView(BlogArticle article); 107 | 108 | /** 109 | * 在页面(这里不是详情页)获取redis的文章访问量并返回 110 | * @param blogLists 111 | */ 112 | public void hGetBlogPageRedisViewCnt(List blogLists); 113 | 114 | /** 115 | * 在详情页获取redis中的文章访问量 116 | * @param blog 117 | */ 118 | public void hGetBlogDeatilRedisViewCnt(BlogArticle blog); 119 | 120 | /** 121 | * 更新文章置顶操作 122 | * @param blog_id 123 | * @param is_top 124 | * @return 125 | */ 126 | public boolean updateBlogTopById(Integer blog_id, Integer is_top); 127 | } 128 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/CateGoryService.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service; 2 | 3 | import com.datealive.common.PageResult; 4 | import com.datealive.service.vo.CateGory; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @ClassName: CateGoryService 10 | * @Description: TODO 11 | * @author: datealive 12 | * @date: 2021/2/1 21:02 13 | */ 14 | public interface CateGoryService { 15 | /** 16 | * 查询所有分类的id和名字 注意这里的Category是在vo包下的 17 | * @return 18 | */ 19 | public List getGateGoryIdAndName(); 20 | 21 | /** 22 | * 根据分类id查询该分类下所有博客文章 23 | * @param category_id 24 | * @return 25 | */ 26 | public PageResult getBlogInfoByCategory(Integer category_id,Integer pageNum); 27 | 28 | /** 29 | * 分页获取分类 30 | * @param pageNum 31 | * @return 32 | */ 33 | public PageResult getCateGoryByPage(Integer pageNum); 34 | 35 | /** 36 | * 根据分类名称获取分类 37 | * @param category_name 38 | * @return 39 | */ 40 | public CateGory getCateGoryByName(String category_name); 41 | /** 42 | * 添加分类 43 | * @param cateGory 44 | * @return 45 | */ 46 | public boolean saveCategory(CateGory cateGory); 47 | 48 | /** 49 | * 修改分类 50 | * @param cateGory 51 | * @return 52 | */ 53 | public boolean updateCategory(CateGory cateGory); 54 | 55 | /** 56 | * 根据文章id和分类id查找联系id 57 | * @param blog_id 58 | * @param category_id 59 | * @return 60 | */ 61 | public int getRelationId(Integer blog_id,Integer category_id); 62 | 63 | /** 64 | * 根据文章id和分类id添加分类联系表 65 | * @param blog_id 66 | * @param category_id 67 | * @return 68 | */ 69 | public boolean saveCategoryRelation(Integer blog_id,Integer category_id); 70 | 71 | /** 72 | * 根据文章id和分类id修改分类联系表 73 | * @param blog_id 74 | * @param category_id 75 | * @return 76 | */ 77 | public boolean updateCategoryRelation(Integer blog_id,Integer category_id,Integer relation_id); 78 | 79 | /** 80 | * 根据分类id删除分类表,和分类联系表 81 | * @param category_id 82 | * @return 83 | */ 84 | public boolean deleteCategory(Integer category_id); 85 | 86 | 87 | /** 88 | * 根据文章id删除分类与文章联系表 89 | * @param blog_id 90 | * @return 91 | */ 92 | public boolean deleteCateGoryRelationByblogId(Integer blog_id); 93 | } 94 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/CommentService.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service; 2 | 3 | 4 | import com.datealive.common.PageResult; 5 | import com.datealive.pojo.Comment; 6 | import com.datealive.service.dto.CommentQuery; 7 | import com.datealive.service.vo.CommentSub; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @ClassName: CommentService 13 | * @Description: TODO 14 | * @author: datealive 15 | * @date: 2021/2/9 20:42 16 | */ 17 | public interface CommentService { 18 | /** 19 | * 获取页面评论 20 | * @param commentQuery 21 | * @return 22 | */ 23 | public PageResult getAllCommentByQuery(CommentQuery commentQuery); 24 | 25 | /** 26 | * 后台获取评论 27 | * @param pageNum 28 | * @return 29 | */ 30 | public PageResult getAllComment(Integer pageNum); 31 | 32 | /** 33 | * 根据名称获取评论 34 | * @param nick_name 35 | * @return 36 | */ 37 | public List getCommentByNickName(String nick_name); 38 | 39 | /** 40 | * 获取所有评论数量 41 | * @return 42 | */ 43 | public int getAllCommentCnt(); 44 | 45 | /** 46 | * 提交评论 47 | * @param commentSub 48 | * @return 49 | */ 50 | public boolean saveComment(CommentSub commentSub); 51 | 52 | /** 53 | * 如果是父级评论,还需要删除子级评论 54 | * @param comment_id 55 | * @return 56 | */ 57 | public boolean deleteComment(Integer comment_id); 58 | 59 | /** 60 | * 修改评论状态 61 | * @param comment_id 62 | * @param is_check 63 | * @return 64 | */ 65 | public boolean checkComment(Integer comment_id,Integer is_check); 66 | 67 | /** 68 | * 根据评论id查找comment对应的email 69 | * @param comment_id 70 | * @return 71 | */ 72 | public String getEmailByCommentId(Integer comment_id); 73 | 74 | /** 75 | * 根据pid查找父级评论 76 | * @param comment_id 77 | * @return 78 | */ 79 | public Comment getCommentByPid(Integer comment_id); 80 | } 81 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/FriendsService.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service; 2 | 3 | import com.datealive.common.PageResult; 4 | import com.datealive.pojo.Friends; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @ClassName: FriendsService 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/1 17:11 14 | */ 15 | public interface FriendsService { 16 | 17 | 18 | /** 19 | * 获取所有友链 20 | * @return 21 | */ 22 | public List getAllFriends(); 23 | 24 | /** 25 | * 管理员分页获取友链 26 | * @param pageNum 27 | * @return 28 | */ 29 | public PageResult getAllFriendsByPage(Integer pageNum); 30 | 31 | /** 32 | * 通过名字查找友链 33 | * @param link_name 34 | * @return 35 | */ 36 | public List queryFriendsByName(String link_name); 37 | 38 | /** 39 | * 添加友链 40 | * @param friends 41 | * @return 42 | */ 43 | public boolean saveFriend(Friends friends); 44 | 45 | /** 46 | * 更新友链 47 | * @param friends 48 | * @return 49 | */ 50 | public boolean updateFriend(Friends friends); 51 | 52 | /** 53 | * 更新友链状态 54 | * @param link_id 55 | * @param status 56 | * @return 57 | */ 58 | public boolean updateStatus(Integer link_id, Integer status); 59 | 60 | /** 61 | * 根据id删除友链 62 | * @param link_id 63 | * @return 64 | */ 65 | public boolean deleteFriend(Integer link_id); 66 | } 67 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/LogService.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service; 2 | 3 | import com.datealive.common.PageResult; 4 | import com.datealive.pojo.Log; 5 | import com.datealive.service.dto.LogQuery; 6 | import org.springframework.scheduling.annotation.Async; 7 | 8 | import java.sql.SQLException; 9 | import java.util.List; 10 | 11 | 12 | 13 | 14 | /** 15 | * @Classname LogService 16 | * @Description 日志Service 17 | * @Date 2021/2/17 15:06 18 | * @author 冰羽 19 | */ 20 | 21 | public interface LogService { 22 | /** 23 | * 添加日志 24 | * @param log 25 | * @return 26 | * @throws SQLException 27 | */ 28 | public void addLog(Log log) throws SQLException; 29 | 30 | /** 31 | * 根据logQuery 查询log日志 32 | * @param logQuery 33 | * @return 34 | */ 35 | public PageResult getLogListByLogQuery(LogQuery logQuery); 36 | 37 | /** 38 | * 根据id删除日志 39 | * @param id 40 | * @return 41 | */ 42 | public boolean deleteLogById(Integer id); 43 | } -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/MomentService.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service; 2 | 3 | import com.datealive.common.PageResult; 4 | import com.datealive.pojo.Moment; 5 | 6 | 7 | /** 8 | * @ClassName: MomentService 9 | * @Description: TODO 10 | * @author: datealive 11 | * @date: 2021/2/17 18:27 12 | */ 13 | public interface MomentService { 14 | /** 15 | * 分页获取所有动态 16 | * @param pageNum 17 | * @return 18 | */ 19 | PageResult getMomentList(Integer pageNum); 20 | 21 | /** 22 | * 分页获取已经发布的了动态 23 | * @param pageNum 24 | * @return 25 | */ 26 | PageResult getMomentListWithPublish(Integer pageNum); 27 | 28 | /** 29 | * 点赞动态 30 | * @param momentId 31 | * @return 32 | */ 33 | boolean addLikeByMomentId(Integer momentId); 34 | 35 | /** 36 | * 更新动态状态 37 | * @param momentId 38 | * @param published 39 | * @return 40 | */ 41 | boolean updateMomentPublishedById(Integer momentId, Integer published); 42 | 43 | /** 44 | * 根据id获取动态 返回给前端后台编写 md格式 45 | * @param id 46 | * @return 47 | */ 48 | Moment getMomentById(Integer id); 49 | 50 | /** 51 | * 根据id获取动态 返回给前端前台展示 html格式 52 | * @param id 53 | * @return 54 | */ 55 | Moment getMomentByIdToHtml(Integer id); 56 | 57 | /** 58 | * 删除动态 59 | * @param id 60 | * @return 61 | */ 62 | boolean deleteMomentById(Integer id); 63 | 64 | /** 65 | * 添加动态 66 | * @param moment 67 | * @return 68 | */ 69 | boolean saveMoment(Moment moment); 70 | 71 | /** 72 | * 更新动态 73 | * @param moment 74 | * @return 75 | */ 76 | boolean updateMoment(Moment moment); 77 | 78 | /** 79 | * 获取已经发布了的动态数量 80 | * @return 81 | */ 82 | int getMomentCountWithPublish(); 83 | 84 | /** 85 | * 获取所有动态数量 86 | * @return 87 | */ 88 | int getMomentCount(); 89 | } 90 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/SendMailService.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service; 2 | 3 | import com.datealive.service.vo.CommentSub; 4 | 5 | /** 6 | * @ClassName: SendMail 7 | * @Description: TODO 8 | * @author: datealive 9 | * @date: 2021/2/16 9:11 10 | */ 11 | public interface SendMailService { 12 | /** 13 | * 根据提交的评论vo类发送普通邮件 14 | * @param commentSub 15 | * @param path 16 | */ 17 | void sendSimpleMailByCommentSub(CommentSub commentSub,String path); 18 | 19 | /** 20 | * 封装一个普通的邮件发送函数,便于controller层调用 21 | * @param text 22 | * @param title 23 | * @param to 24 | * @return 25 | */ 26 | void sendSimpleMail(String text, String title, String to); 27 | 28 | /** 29 | * 发送复杂邮件,这个业务层暂时用不到,如果有需要,参数请修改,需要传入file 30 | * @param commentSub 31 | * @return 32 | */ 33 | void sendComplexMail(CommentSub commentSub); 34 | } 35 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/SiteSettingService.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service; 2 | 3 | import com.datealive.pojo.SiteSetting; 4 | 5 | import java.util.LinkedHashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | /** 10 | * @ClassName: SiteSettingService 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/26 9:22 14 | */ 15 | public interface SiteSettingService { 16 | /** 17 | * 获取站点配置 18 | * @return 19 | */ 20 | Map> getSiteList(); 21 | 22 | /** 23 | * 获取站点配置 24 | * @return 25 | */ 26 | Map getSiteInfo(); 27 | 28 | /** 29 | * 更新和删除和添加 站点 30 | * @param siteSettings 31 | * @param deleteIds 32 | * @return 33 | */ 34 | boolean updateSiteSetting(List siteSettings, List deleteIds); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/TagService.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service; 2 | 3 | import com.datealive.common.PageResult; 4 | import com.datealive.service.vo.Tag; 5 | 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @ClassName: TagService 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/3 11:57 14 | */ 15 | public interface TagService { 16 | 17 | /** 18 | * 查询所有标签的id和名字 注意这里的Tag是在vo包下的 19 | * @return 20 | */ 21 | public List getTagIdAndName(); 22 | 23 | /** 24 | * 分页获取标签 25 | * @param pageNum 26 | * @return 27 | */ 28 | public PageResult getTagByPage(Integer pageNum); 29 | 30 | /** 31 | * 根据标签id查询该分类下所有博客文章 32 | * @param tag_id 33 | * @return 34 | */ 35 | public PageResult getBlogInfoByTag(Integer tag_id,Integer pageNum); 36 | 37 | /** 38 | * 根据标签名查询标签 39 | * @param tag_name 40 | * @return 41 | */ 42 | public Tag getTagByName(String tag_name); 43 | 44 | /** 45 | * 添加标签 46 | * @param tag 47 | * @return 48 | */ 49 | public boolean saveTag(Tag tag); 50 | 51 | /** 52 | * 修改标签 53 | * @param tag 54 | * @return 55 | */ 56 | public boolean updateTag(Tag tag); 57 | 58 | /** 59 | * 根据标签id删除标签表 60 | * @param tag_id 61 | * @return 62 | */ 63 | public boolean deleteTag(Integer tag_id); 64 | 65 | /** 66 | * 根据标签id和分类id添加标签联系表 67 | * @param blog_id 68 | * @param tag_id 69 | * @return 70 | */ 71 | public boolean saveTagRelation(Integer blog_id,Integer tag_id); 72 | 73 | /** 74 | * 根据文章id和标签id查找联系id 75 | * @param blog_id 76 | * @param tag_id 77 | * @return 78 | */ 79 | public int getRelationId(Integer blog_id,Integer tag_id); 80 | 81 | /** 82 | * 根据联系id,标签id和文章id修改tag联系表 83 | * @param blog_id 84 | * @param tag_id 85 | * @param relation_id 86 | * @return 87 | */ 88 | public boolean updateTagRelation(Integer blog_id,Integer tag_id,Integer relation_id); 89 | 90 | 91 | /** 92 | * 根据文章id删除标签联系表 93 | * @param blog_id 94 | * @return 95 | */ 96 | public boolean deleteTagRelationByblogId(Integer blog_id); 97 | } 98 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/UpLoadService.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service; 2 | 3 | import com.datealive.common.Result; 4 | import org.springframework.web.multipart.MultipartFile; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | 8 | /** 9 | * @ClassName: UpLoadService 10 | * @Description: TODO 11 | * @author: datealive 12 | * @date: 2021/2/24 18:51 13 | */ 14 | public interface UpLoadService { 15 | /** 16 | * 上传图片 17 | * @param request 18 | * @param file 19 | * @return 20 | */ 21 | public Result UpLoadImage(HttpServletRequest request,MultipartFile file); 22 | } 23 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service; 2 | 3 | import com.datealive.common.Result; 4 | import com.datealive.pojo.User; 5 | import com.datealive.service.dto.RegisterDto; 6 | 7 | /** 8 | * @ClassName: UserService 9 | * @Description: TODO 10 | * @author: datealive 11 | * @date: 2021/1/31 12:50 12 | */ 13 | public interface UserService { 14 | 15 | /** 16 | * 业务层用户接口 17 | * @param username 18 | * @return 19 | */ 20 | User getUserByName(String username); 21 | 22 | /** 23 | * 根据id获取用户 24 | * @param userId 25 | * @return 26 | */ 27 | User getUserById(Integer userId); 28 | 29 | /** 30 | * 修改密码 31 | * @param userName 32 | * @param newPassword 33 | * @return 34 | */ 35 | Result changePassword(String userName, String newPassword); 36 | 37 | /** 38 | * 注册用户 39 | * @param registerDto 40 | * @return 41 | */ 42 | boolean RegisterUser(RegisterDto registerDto); 43 | } 44 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/dto/BlogUpdStatus.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @ClassName: BlogUpdStatus 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/25 12:21 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class BlogUpdStatus implements Serializable { 19 | 20 | private Integer blog_id; 21 | private Integer is_top; 22 | } 23 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/dto/CommentQuery.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @ClassName: CommentQuery 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/10 11:19 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class CommentQuery implements Serializable { 19 | 20 | private int blog_id; 21 | private int currentPage; 22 | private int page; 23 | } 24 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/dto/CommentUpdStatus.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.dto; 2 | 3 | import io.swagger.models.auth.In; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * @ClassName: CommentUpdStatus 12 | * @Description: TODO 13 | * @author: datealive 14 | * @date: 2021/2/25 12:02 15 | */ 16 | @Data 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | public class CommentUpdStatus implements Serializable { 20 | 21 | private Integer comment_id; 22 | private Integer is_check; 23 | } 24 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/dto/FriendsUpdStatus.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @ClassName: FriendsUpdStatus 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/25 12:16 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class FriendsUpdStatus implements Serializable { 19 | 20 | private Integer link_id; 21 | private Integer status; 22 | } 23 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/dto/LogQuery.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @ClassName: LogQuery 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/22 23:37 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class LogQuery implements Serializable { 19 | 20 | private int currentPage; 21 | private int classification; 22 | private int pageSize; 23 | } 24 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/dto/LoginDto.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.dto; 2 | 3 | import lombok.Data; 4 | import org.hibernate.validator.constraints.NotBlank; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @ClassName: LoginDto 10 | * @Description: TODO 11 | * @author: datealive 12 | * @date: 2021/1/31 19:09 13 | */ 14 | @Data 15 | public class LoginDto implements Serializable { 16 | 17 | @NotBlank(message = "昵称不能为空") 18 | private String username; 19 | 20 | @NotBlank(message = "密码不能为空") 21 | private String password; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/dto/ModifyPwd.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.dto; 2 | 3 | import lombok.Data; 4 | import org.hibernate.validator.constraints.NotBlank; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @ClassName: ModifyPwd 10 | * @Description: TODO 11 | * @author: datealive 12 | * @date: 2021/2/20 13:52 13 | */ 14 | @Data 15 | public class ModifyPwd implements Serializable { 16 | 17 | @NotBlank(message = "昵称不能为空") 18 | private String userName; 19 | 20 | @NotBlank(message = "密码不能为空") 21 | private String oldPassword; 22 | 23 | @NotBlank(message = "密码不能为空") 24 | private String newPassword; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/dto/MomentUpdStatus.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @ClassName: MomentUpdStatus 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/25 12:18 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class MomentUpdStatus implements Serializable { 19 | private Integer id; 20 | private Integer isPublish; 21 | } 22 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/dto/RegisterDto.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * @ClassName: RegisterDto 12 | * @Description: TODO 13 | * @author: datealive 14 | * @date: 2021/3/5 14:01 15 | */ 16 | @Data 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | public class RegisterDto implements Serializable { 20 | 21 | private String username; 22 | private String password; 23 | private String nick_name; 24 | private String email; 25 | private String roles; 26 | } 27 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/impl/FriendsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.impl; 2 | 3 | import com.datealive.common.PageResult; 4 | import com.datealive.common.Result; 5 | import com.datealive.common.ResultCode; 6 | import com.datealive.common.StaticFinalCode; 7 | import com.datealive.mapper.FriendsMapper; 8 | import com.datealive.pojo.Friends; 9 | import com.datealive.service.FriendsService; 10 | import com.github.pagehelper.PageHelper; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * @ClassName: FriendsServiceImpl 18 | * @Description: TODO 19 | * @author: datealive 20 | * @date: 2021/2/1 17:12 21 | */ 22 | @Service 23 | public class FriendsServiceImpl implements FriendsService { 24 | 25 | @Autowired 26 | FriendsMapper friendsMapper; 27 | 28 | 29 | @Override 30 | public List getAllFriends() { 31 | return friendsMapper.getAllFriends(); 32 | } 33 | 34 | @Override 35 | public PageResult getAllFriendsByPage(Integer pageNum) { 36 | int friendsCnt = friendsMapper.getFriendsCnt(); 37 | int totalPage = (int) Math.ceil(friendsCnt* 1.0 / StaticFinalCode.pageSize); 38 | PageHelper.startPage(pageNum,StaticFinalCode.pageSize); 39 | List friends = friendsMapper.getAllFriendsWithStatus(); 40 | if(friends.isEmpty()){ 41 | return new PageResult(ResultCode.Not_Found,totalPage,pageNum,null); 42 | }else{ 43 | return new PageResult(ResultCode.Success,totalPage,pageNum,friends); 44 | } 45 | } 46 | 47 | @Override 48 | public List queryFriendsByName(String link_name) { 49 | return friendsMapper.queryFriendsByName(link_name); 50 | } 51 | 52 | 53 | @Override 54 | public boolean saveFriend(Friends friends) { 55 | int saveFriend = friendsMapper.saveFriend(friends); 56 | if(saveFriend>0){ 57 | return true; 58 | }else { 59 | return false; 60 | } 61 | } 62 | 63 | @Override 64 | public boolean updateFriend(Friends friends) { 65 | Integer link_id = friends.getLink_id(); 66 | if(link_id!=null&&link_id!=0){ 67 | friendsMapper.updateFriend(friends); 68 | return true; 69 | }else{ 70 | return false; 71 | } 72 | } 73 | 74 | @Override 75 | public boolean updateStatus(Integer link_id, Integer status) { 76 | int updateStatus = friendsMapper.updateStatus(link_id, status); 77 | if(updateStatus>0){ 78 | return true; 79 | }else{ 80 | return false; 81 | } 82 | } 83 | 84 | @Override 85 | public boolean deleteFriend(Integer link_id) { 86 | int isDelete = friendsMapper.deleteFriend(link_id); 87 | if(isDelete>0){ 88 | return true; 89 | }else{ 90 | return false; 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/impl/LogServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.impl; 2 | 3 | import java.sql.SQLException; 4 | import java.util.List; 5 | 6 | import com.datealive.common.PageResult; 7 | import com.datealive.common.ResultCode; 8 | import com.datealive.common.StaticFinalCode; 9 | import com.datealive.mapper.LogMapper; 10 | import com.datealive.pojo.Log; 11 | import com.datealive.service.LogService; 12 | import com.datealive.service.dto.LogQuery; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.scheduling.annotation.Async; 15 | import org.springframework.stereotype.Service; 16 | import org.springframework.transaction.annotation.Isolation; 17 | import org.springframework.transaction.annotation.Propagation; 18 | import org.springframework.transaction.annotation.Transactional; 19 | 20 | import com.github.pagehelper.PageHelper; 21 | import com.github.pagehelper.PageInfo; 22 | 23 | 24 | 25 | /** 26 | * @Classname LogServiceImpl 27 | * @Description 日志管理实现 28 | * @Date 2021/2/17 15:06 29 | * @author 冰羽 30 | */ 31 | @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) 32 | @Service 33 | public class LogServiceImpl implements LogService { 34 | 35 | @Autowired 36 | private LogMapper logMapper; 37 | 38 | @Async 39 | @Override 40 | public void addLog(Log log) throws SQLException { 41 | logMapper.insertLog(log); 42 | } 43 | 44 | @Override 45 | public PageResult getLogListByLogQuery(LogQuery logQuery) { 46 | int count = logMapper.getLogCountByClassification(logQuery.getClassification()); 47 | int totalPage = (int) Math.ceil(count* 1.0 / logQuery.getPageSize()); 48 | PageHelper.startPage(logQuery.getCurrentPage(),logQuery.getPageSize()); 49 | List logList = logMapper.getLogListByLogQuery(logQuery); 50 | if(logList.isEmpty()){ 51 | return new PageResult(ResultCode.Not_Found,totalPage,logQuery.getCurrentPage(),null); 52 | }else{ 53 | return new PageResult(ResultCode.Success,totalPage,logQuery.getCurrentPage(),logList); 54 | } 55 | } 56 | 57 | 58 | @Override 59 | public boolean deleteLogById(Integer id) { 60 | int deleteLog = logMapper.deleteLog(id); 61 | if(deleteLog>0){ 62 | return true; 63 | }else{ 64 | return false; 65 | } 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/impl/UpLoadImageImpl.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.impl; 2 | 3 | import com.datealive.common.Result; 4 | import com.datealive.service.UpLoadService; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.web.multipart.MultipartFile; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | import java.io.File; 11 | import java.io.IOException; 12 | import java.text.SimpleDateFormat; 13 | import java.util.Date; 14 | import java.util.UUID; 15 | 16 | /** 17 | * @ClassName: UpLoadImageImpl 18 | * @Description: TODO 19 | * @author: datealive 20 | * @date: 2021/2/24 18:52 21 | */ 22 | @Service 23 | public class UpLoadImageImpl implements UpLoadService { 24 | 25 | /** 26 | * 时间格式化 27 | */ 28 | private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd/"); 29 | 30 | /** 31 | * 图片保存路径,自动从yml文件中获取数据 32 | * 示例: E:/images/ 33 | */ 34 | @Value("${file-save-path}") 35 | private String fileSavePath; 36 | 37 | @Override 38 | public Result UpLoadImage(HttpServletRequest request, MultipartFile file) { 39 | //1.后半段目录: 2020/03/15 40 | String directory = simpleDateFormat.format(new Date()); 41 | /** 42 | * 2.文件保存目录 E:/images/2020/03/15/ 43 | * 如果目录不存在,则创建 44 | */ 45 | File dir = new File(fileSavePath + directory); 46 | if (!dir.exists()) { 47 | dir.mkdirs(); 48 | } 49 | //3.给文件重新设置一个名字 50 | //后缀 51 | String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); 52 | String newFileName= UUID.randomUUID().toString().replaceAll("-", "")+suffix; 53 | //4.创建这个新文件 54 | File newFile = new File(fileSavePath + directory + newFileName); 55 | //5.复制操作 56 | try { 57 | file.transferTo(newFile); 58 | //协议 :// ip地址 :端口号 / 文件目录(/images/2020/03/15/xxx.jpg) 59 | //String url = request.getScheme() + "://" + request.getServerName() + "/images/" + directory + newFileName; 60 | String url = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/images/" + directory + newFileName; 61 | return Result.success("图片上传成功",url); 62 | } catch (IOException e) { 63 | return Result.error("图片上传失败"); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.impl; 2 | 3 | import com.datealive.common.Result; 4 | import com.datealive.common.ResultCode; 5 | import com.datealive.mapper.UserMapper; 6 | import com.datealive.pojo.User; 7 | import com.datealive.service.UserService; 8 | import com.datealive.service.dto.RegisterDto; 9 | import com.datealive.utils.QQInfoUtils; 10 | import org.apache.shiro.crypto.hash.Md5Hash; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | 14 | /** 15 | * @ClassName: UserServiceImpl 16 | * @Description: TODO 17 | * @author: datealive 18 | * @date: 2021/1/31 12:51 19 | */ 20 | @Service 21 | public class UserServiceImpl implements UserService { 22 | 23 | @Autowired 24 | UserMapper userMapper; 25 | 26 | @Override 27 | public User getUserByName(String username) { 28 | User user=userMapper.getUserByName(username); 29 | if(user==null){ 30 | return null; 31 | } 32 | return user; 33 | } 34 | 35 | @Override 36 | public User getUserById(Integer userId) { 37 | User user=userMapper.getUserById(userId); 38 | if(user==null){ 39 | return null; 40 | } 41 | return user; 42 | } 43 | 44 | 45 | @Override 46 | public Result changePassword(String userName, String newPassword) { 47 | String hashMd5AfterPassword=new Md5Hash(newPassword,userName,1024).toHex(); 48 | userMapper.changePassword(userName,hashMd5AfterPassword); 49 | return Result.success(ResultCode.Success,"修改成功!"); 50 | } 51 | 52 | @Override 53 | public boolean RegisterUser(RegisterDto registerDto) { 54 | //注册用户业务层,需要对用户名,邮箱进行验证,对密码进行哈希盐值加密后存储 55 | User user=new User(); 56 | user.setUsername(registerDto.getUsername()); 57 | user.setPassword(registerDto.getPassword()); 58 | user.setEmail(registerDto.getEmail()); 59 | user.setNick_name(registerDto.getNick_name()); 60 | user.setRoles(registerDto.getRoles()); 61 | //用户头像通过邮箱获取qq邮箱 62 | user.setAvatar(QQInfoUtils.getQQAvatarURL(registerDto.getEmail())); 63 | //简介默认为空 64 | user.setIntroduce("test"); 65 | int registerUser = userMapper.registerUser(user); 66 | if(registerUser>0){ 67 | return true; 68 | }else { 69 | return false; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/vo/Badge.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.springframework.context.annotation.Bean; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * @ClassName: Badge 12 | * @Description: TODO 13 | * @author: datealive 14 | * @date: 2021/2/26 9:46 15 | */ 16 | @Data 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | public class Badge implements Serializable { 20 | private String title; 21 | private String url; 22 | private String subject; 23 | private String value; 24 | private String color; 25 | } 26 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/vo/BlogArticleCateAndTag.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.vo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | import java.util.Date; 10 | 11 | /** 12 | * @ClassName: BlogArticleCateAndTag 13 | * @Description: TODO 14 | * @author: datealive 15 | * @date: 2021/2/2 9:53 16 | */ 17 | @Data 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | public class BlogArticleCateAndTag implements Serializable { 21 | private Integer blog_id; 22 | private String blog_title; 23 | private String blog_cover_image; 24 | 25 | 26 | private String blog_summary; 27 | private Integer blog_status; 28 | private Integer blog_visits; 29 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") 30 | private Date create_time; 31 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") 32 | private Date update_time; 33 | private Integer is_top; 34 | 35 | private Integer blog_like; 36 | 37 | private Integer comment_cnt; 38 | } 39 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/vo/BlogArticleIdAndTitle.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.vo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | import java.util.Date; 10 | 11 | /** 12 | * @ClassName: BlogArticleIdAndTitle 13 | * @Description: TODO 14 | * @author: datealive 15 | * @date: 2021/2/1 14:02 16 | */ 17 | @Data 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | public class BlogArticleIdAndTitle implements Serializable { 21 | 22 | private Integer blog_id; 23 | private String blog_title; 24 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") 25 | private Date create_time; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/vo/BlogArticleInfo.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.vo; 2 | 3 | import com.datealive.pojo.Tag; 4 | import com.fasterxml.jackson.annotation.JsonFormat; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | import java.io.Serializable; 10 | import java.util.ArrayList; 11 | import java.util.Date; 12 | import java.util.List; 13 | 14 | /** 15 | * @ClassName: BlogArticleInfo 16 | * @Description: TODO 17 | * @author: datealive 18 | * @date: 2021/1/31 21:49 19 | */ 20 | @Data 21 | @AllArgsConstructor 22 | @NoArgsConstructor 23 | public class BlogArticleInfo implements Serializable { 24 | 25 | private Integer blog_id; 26 | private String blog_title; 27 | private String blog_cover_image; 28 | 29 | 30 | private String blog_summary; 31 | private Integer blog_status; 32 | private Integer blog_visits; 33 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") 34 | private Date create_time; 35 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") 36 | private Date update_time; 37 | private Integer is_top; 38 | 39 | private Integer blog_like; 40 | 41 | private Integer comment_cnt; 42 | 43 | private CateGory cateGory; 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/vo/CateGory.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @ClassName: CateGory 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/1 10:57 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class CateGory implements Serializable { 19 | 20 | private Integer category_id; 21 | private String category_name; 22 | } 23 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/vo/CommentSub.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.vo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.hibernate.validator.constraints.NotBlank; 8 | 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * @ClassName: Comment 14 | * @Description: TODO 15 | * @author: datealive 16 | * @date: 2021/2/9 16:54 17 | */ 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | public class CommentSub implements Serializable { 22 | 23 | @NotBlank(message = "评论内容不能为空") 24 | private String content; 25 | private Integer blog_id; 26 | @NotBlank(message = "昵称不能为空") 27 | private String nick_name; 28 | private String avatar; 29 | private String email; 30 | private String reply_nick_name; 31 | private Integer pid; 32 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") 33 | private Date create_time; 34 | private String site_url; 35 | private Integer page; 36 | private Integer is_check; 37 | } 38 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/vo/Copyright.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @ClassName: Copyright 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/26 9:45 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class Copyright implements Serializable { 19 | private String title; 20 | private String siteName; 21 | } 22 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/vo/Favorite.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @ClassName: Favorite 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/26 9:48 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class Favorite implements Serializable { 19 | 20 | private String title; 21 | private String content; 22 | } 23 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/vo/GiteeImageVo.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @ClassName: GiteeImageVo 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/4/15 20:02 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class GiteeImageVo implements Serializable { 19 | 20 | 21 | private String type; 22 | private String name; 23 | private String sha; 24 | private String download_url; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/vo/Introduction.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.springframework.context.annotation.Bean; 7 | 8 | import java.io.Serializable; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * @ClassName: Introduction 14 | * @Description: TODO 15 | * @author: datealive 16 | * @date: 2021/2/26 9:48 17 | */ 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | public class Introduction implements Serializable { 22 | 23 | private String avatar; 24 | private String name; 25 | private String github; 26 | private String qq; 27 | private String bilibili; 28 | private String netease; 29 | private String email; 30 | private String musicId; 31 | private String backGroundImage; 32 | 33 | private List rollText = new ArrayList<>(); 34 | private List favorites = new ArrayList<>(); 35 | } 36 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/service/vo/Tag.java: -------------------------------------------------------------------------------- 1 | package com.datealive.service.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @ClassName: Tag 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/1 10:55 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class Tag implements Serializable { 19 | private Integer tag_id; 20 | private String tag_name; 21 | } 22 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/shiro/JwtToken.java: -------------------------------------------------------------------------------- 1 | package com.datealive.shiro; 2 | 3 | import org.apache.shiro.authc.AuthenticationToken; 4 | 5 | /** 6 | * @ClassName: JwtToken 7 | * @Description: TODO 8 | * @author: datealive 9 | * @date: 2021/1/31 16:50 10 | */ 11 | public class JwtToken implements AuthenticationToken { 12 | 13 | private String token; 14 | public JwtToken(String token){ 15 | this.token=token; 16 | } 17 | 18 | @Override 19 | public Object getPrincipal() { 20 | return token; 21 | } 22 | 23 | @Override 24 | public Object getCredentials() { 25 | return token; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/shiro/MyProfile.java: -------------------------------------------------------------------------------- 1 | package com.datealive.shiro; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @ClassName: MyProfile 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/1/31 17:56 14 | */ 15 | @Data 16 | public class MyProfile implements Serializable { 17 | 18 | private Integer user_id; 19 | private String user_name; 20 | private String nick_name; 21 | private String avatar; 22 | private String introduce; 23 | 24 | public Integer getId(){ 25 | return user_id; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/shiro/MyShiroRealm.java: -------------------------------------------------------------------------------- 1 | package com.datealive.shiro; 2 | 3 | import cn.hutool.core.bean.BeanUtil; 4 | import com.datealive.pojo.User; 5 | import com.datealive.service.UserService; 6 | import com.datealive.utils.JwtUtils; 7 | import org.apache.shiro.authc.*; 8 | import org.apache.shiro.authz.AuthorizationException; 9 | import org.apache.shiro.authz.AuthorizationInfo; 10 | import org.apache.shiro.authz.SimpleAuthorizationInfo; 11 | import org.apache.shiro.realm.AuthorizingRealm; 12 | import org.apache.shiro.subject.PrincipalCollection; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Component; 15 | 16 | /** 17 | * @ClassName: MyShiroRealm 18 | * @Description: TODO 19 | * @author: datealive 20 | * @date: 2021/1/31 16:16 21 | */ 22 | @Component 23 | public class MyShiroRealm extends AuthorizingRealm { 24 | 25 | @Autowired 26 | JwtUtils jwtUtils; 27 | 28 | @Autowired 29 | UserService userService; 30 | 31 | @Override 32 | public boolean supports(AuthenticationToken token) { 33 | return token instanceof JwtToken; 34 | } 35 | @Override 36 | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { 37 | //获取用户登录信息 38 | MyProfile user = (MyProfile) principalCollection.getPrimaryPrincipal(); 39 | // System.out.println("user====>"+user); 40 | //这里根据用户信息再查一遍权限表 由于这里没有权限表 所以直接查询用户表 获取它的role 41 | User realUser = userService.getUserById(user.getUser_id()); 42 | //添加角色和权限 43 | SimpleAuthorizationInfo authorizationInfo=new SimpleAuthorizationInfo(); 44 | //System.out.println("=========>"+realUser.getRoles()); 45 | authorizationInfo.addStringPermission(realUser.getRoles()); 46 | return authorizationInfo; 47 | } 48 | 49 | @Override 50 | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { 51 | 52 | JwtToken jwt = (JwtToken) token; 53 | String userId = jwtUtils.getClaimByToken((String) jwt.getPrincipal()).getSubject(); 54 | User user = userService.getUserById(Integer.valueOf(userId)); 55 | if (user == null) { 56 | throw new UnknownAccountException("账号或密码不正确"); 57 | } 58 | MyProfile profile=new MyProfile(); 59 | BeanUtil.copyProperties(user, profile); 60 | 61 | return new SimpleAuthenticationInfo(profile, jwt.getCredentials(), getName()); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/task/RedisViewCountTask.java: -------------------------------------------------------------------------------- 1 | package com.datealive.task; 2 | 3 | import com.datealive.annotation.LogAnno; 4 | import com.datealive.common.StaticFinalCode; 5 | import com.datealive.mapper.BlogArticleMapper; 6 | import com.datealive.service.vo.BlogArticleInfo; 7 | import com.datealive.utils.RedisUtil; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.scheduling.annotation.EnableScheduling; 11 | import org.springframework.scheduling.annotation.Scheduled; 12 | import org.springframework.stereotype.Component; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * @ClassName: RedisViewCountTask 18 | * @Description: TODO 19 | * @author: datealive 20 | * @date: 2021/2/12 16:41 21 | */ 22 | @Component 23 | @EnableScheduling 24 | @Slf4j 25 | public class RedisViewCountTask { 26 | 27 | @Autowired 28 | RedisUtil redisUtil; 29 | 30 | @Autowired 31 | BlogArticleMapper blogArticleMapper; 32 | 33 | @LogAnno(operateType="saveViewCntToDataBase",description = "从redis中读取浏览量到数据库",classification = 3) 34 | @Scheduled(cron = "0 0 1 * * ?") 35 | // @Scheduled(cron = "0 */1 * * * ?") 1分钟 36 | public void saveViewCntToDataBase(){ 37 | log.info("进行了定时任务"); 38 | List blogList = blogArticleMapper.getAllBlogArticleWithStatus(); 39 | for (BlogArticleInfo blog : blogList) { 40 | String key= StaticFinalCode.KEY_BLOG_ARTICLE_VIEW_ProFix+blog.getBlog_id(); 41 | Integer hGetViewCnt = (Integer) redisUtil.hget(key, "post:viewCount"); 42 | if(hGetViewCnt!=null) { 43 | blogArticleMapper.increaseBlogViews(blog.getBlog_id(),hGetViewCnt); 44 | redisUtil.del(key); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/BilibiliAnimeUtils.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils; 2 | 3 | /** 4 | * @ClassName: BilibiliAnime 5 | * @Description: TODO 6 | * @author: datealive 7 | * @date: 2021/2/17 23:57 8 | */ 9 | public class BilibiliAnimeUtils { 10 | } 11 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/DateUtils.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import java.text.ParseException; 6 | import java.text.SimpleDateFormat; 7 | import java.util.Date; 8 | 9 | /** 10 | * @ClassName: DateUtils 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/3 9:52 14 | */ 15 | @Component 16 | public class DateUtils { 17 | public static Date getCurrentTime() throws ParseException { 18 | Date date = new Date(); 19 | String strDateFormat = "yyyy-MM-dd HH:mm:ss"; 20 | SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); 21 | String currentdate = sdf.format(date); 22 | return sdf.parse(currentdate); 23 | } 24 | 25 | public static String getToday() { 26 | Date date = new Date(); 27 | String strDateFormat = "yyyy-MM-dd"; 28 | SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); 29 | return sdf.format(date); 30 | } 31 | 32 | public static String getCurrentHHMMTime() { 33 | Date date = new Date(); 34 | String strDateFormat = "HH:mm"; 35 | SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); 36 | return sdf.format(date); 37 | } 38 | 39 | /** 40 | * Unix时间戳转换成北京时间 41 | * 42 | * @param unixTime 43 | * @return 44 | */ 45 | public static String unixTime2BeiJingDate(int unixTime){ 46 | String unixTimeString = String.valueOf(unixTime); 47 | return new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(Long.parseLong(unixTimeString)*1000)); 48 | } 49 | 50 | /** 51 | * time1 - time2 52 | * 53 | * @param time1 HH:mm 54 | * @param time2 HH:mm 55 | * @return 56 | */ 57 | public static int compareTime(String time1, String time2) { 58 | int compareResult; 59 | String[] time1PartArray = time1.split(":"); 60 | int time1Hour = Integer.parseInt(time1PartArray[0]); 61 | int time1Minute = Integer.parseInt(time1PartArray[1]); 62 | String[] time2PartArray = time2.split(":"); 63 | int time2Hour = Integer.parseInt(time2PartArray[0]); 64 | int time2Minute = Integer.parseInt(time2PartArray[1]); 65 | if (time1Hour > time2Hour) { 66 | compareResult = 1; 67 | } else if (time1Hour < time2Hour) { 68 | compareResult = -1; 69 | } else { 70 | if(time1Minute > time2Minute){ 71 | compareResult = 1; 72 | } else if(time1Minute < time2Minute){ 73 | compareResult = -1; 74 | } else { 75 | compareResult = 0; 76 | } 77 | } 78 | 79 | return compareResult; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/JacksonUtils.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.core.type.TypeReference; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | 10 | /** 11 | * @ClassName: JacksonUtils 12 | * @Description: TODO 13 | * @author: datealive 14 | * @date: 2021/2/26 10:09 15 | */ 16 | public class JacksonUtils { 17 | private static ObjectMapper objectMapper = new ObjectMapper(); 18 | 19 | public static String writeValueAsString(Object value) { 20 | try { 21 | return objectMapper.writeValueAsString(value); 22 | } catch (JsonProcessingException e) { 23 | e.printStackTrace(); 24 | return ""; 25 | } 26 | } 27 | 28 | public static T readValue(String content, Class valueType) { 29 | try { 30 | return objectMapper.readValue(content, valueType); 31 | } catch (IOException e) { 32 | e.printStackTrace(); 33 | return null; 34 | } 35 | } 36 | 37 | public static T readValue(String content, TypeReference valueTypeRef) { 38 | try { 39 | return objectMapper.readValue(content, valueTypeRef); 40 | } catch (IOException e) { 41 | e.printStackTrace(); 42 | return null; 43 | } 44 | } 45 | 46 | public static T readValue(InputStream src, Class valueType) { 47 | try { 48 | return objectMapper.readValue(src, valueType); 49 | } catch (IOException e) { 50 | e.printStackTrace(); 51 | return null; 52 | } 53 | } 54 | 55 | public static T convertValue(Object fromValue, Class toValueType) { 56 | return objectMapper.convertValue(fromValue, toValueType); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/JwtUtils.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils; 2 | 3 | import io.jsonwebtoken.Claims; 4 | import io.jsonwebtoken.Jwts; 5 | import io.jsonwebtoken.SignatureAlgorithm; 6 | import lombok.Data; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.boot.context.properties.ConfigurationProperties; 9 | import org.springframework.stereotype.Component; 10 | 11 | import java.util.Date; 12 | 13 | /** 14 | * @ClassName: JwtUtils 15 | * @Description: TODO 16 | * @author: datealive 17 | * @date: 2021/1/31 17:11 18 | */ 19 | @Slf4j 20 | @Data 21 | @Component 22 | @ConfigurationProperties(prefix = "datealive.jwt") 23 | public class JwtUtils { 24 | 25 | private String secret; 26 | private long expire; 27 | private String header; 28 | 29 | /** 30 | * 生成jwt token 31 | */ 32 | public String generateToken(Integer userId) { 33 | Date nowDate = new Date(); 34 | //过期时间 35 | Date expireDate = new Date(nowDate.getTime() + expire * 1000); 36 | 37 | return Jwts.builder() 38 | .setHeaderParam("typ", "JWT") 39 | .setSubject(userId+"") 40 | .setIssuedAt(nowDate) 41 | .setExpiration(expireDate) 42 | .signWith(SignatureAlgorithm.HS512, secret) 43 | .compact(); 44 | } 45 | 46 | public Claims getClaimByToken(String token) { 47 | try { 48 | return Jwts.parser() 49 | .setSigningKey(secret) 50 | .parseClaimsJws(token) 51 | .getBody(); 52 | }catch (Exception e){ 53 | log.debug("validate is token error ", e); 54 | return null; 55 | } 56 | } 57 | 58 | /** 59 | * token是否过期 60 | * @return true:过期 61 | */ 62 | public boolean isTokenExpired(Date expiration) { 63 | return expiration.before(new Date()); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/MailUtils.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.mail.SimpleMailMessage; 5 | import org.springframework.mail.javamail.JavaMailSender; 6 | import org.springframework.mail.javamail.JavaMailSenderImpl; 7 | import org.springframework.mail.javamail.MimeMessageHelper; 8 | import org.springframework.mail.javamail.MimeMessagePreparator; 9 | import org.springframework.stereotype.Component; 10 | 11 | import javax.mail.internet.MimeMessage; 12 | import java.io.File; 13 | 14 | /** 15 | * 邮件工具类 16 | * @author dateaive 17 | */ 18 | @Component 19 | public class MailUtils { 20 | 21 | @Autowired 22 | private JavaMailSender javaMailSender; 23 | 24 | 25 | /** 26 | * 发送简单邮件 27 | * 28 | * @param text 邮件正文 29 | * @param title 标题 30 | * @param to 接收方 31 | */ 32 | public boolean sendSimpleMail(String text, String title, String... to) { 33 | try { 34 | MimeMessage mimeMessage = javaMailSender.createMimeMessage(); 35 | MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage); 36 | messageHelper.setFrom("2448282543@qq.com"); 37 | messageHelper.setTo(to); 38 | messageHelper.setSubject(title); 39 | messageHelper.setText(text, true); 40 | javaMailSender.send(mimeMessage); 41 | //发送成功返回true 42 | return true; 43 | } catch (Exception e) { 44 | e.printStackTrace(); 45 | } 46 | //发送失败返回false 47 | return false; 48 | } 49 | 50 | 51 | /** 52 | * 发送复杂邮件 53 | * 54 | * @param text 邮件正文 55 | * @param title 标题 56 | * @param fileName 附件名 57 | * @param file 附件 58 | * @param to 接收方 59 | */ 60 | public boolean sendComplexMail(String text, String title, String fileName, File file, String... to) { 61 | try { 62 | //一个复杂的邮件任务 63 | MimeMessage mimeMessage = javaMailSender.createMimeMessage(); 64 | //组装邮件 65 | MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true); 66 | helper.setSubject(title); 67 | helper.setText(text, true); 68 | helper.addAttachment(fileName, file);//添加附件 69 | helper.setTo(to);//设置发送给谁 70 | helper.setFrom("2448282543@qq.com");//设置从哪里来的 71 | javaMailSender.send(mimeMessage);//发送邮件 72 | //发送成功返回true 73 | return true; 74 | } catch (Exception e) { 75 | e.printStackTrace(); 76 | } 77 | //发送失败返回false 78 | return false; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/QQInfoUtils.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils; 2 | 3 | import org.springframework.web.client.RestTemplate; 4 | 5 | import java.io.UnsupportedEncodingException; 6 | 7 | /** 8 | * @ClassName: QQInfoUtils 9 | * @Description: 获取qq头像和昵称 10 | * @author: datealive 11 | * @date: 2021/2/17 13:20 12 | */ 13 | public class QQInfoUtils { 14 | 15 | private static RestTemplate restTemplate = new RestTemplate(); 16 | private static final String QQ_NICKNAME_URL = "https://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?uins={1}"; 17 | private static final String QQ_AVATAR_URL = "http://q.qlogo.cn/g?b=qq&nk=%s&s=100"; 18 | 19 | public static String getQQNickname(String qq) throws UnsupportedEncodingException { 20 | String res = restTemplate.getForObject(QQ_NICKNAME_URL, String.class, qq); 21 | byte[] bytes = res.getBytes("iso-8859-1"); 22 | String nickname = new String(bytes, "gb18030").split(",")[6].replace("\"", ""); 23 | if ("".equals(nickname)) { 24 | return "nickname"; 25 | } 26 | return nickname; 27 | } 28 | 29 | public static String getQQAvatarURL(String qq) { 30 | return String.format(QQ_AVATAR_URL, qq); 31 | } 32 | 33 | public static boolean isQQNumber(String nickname) { 34 | return nickname.matches("^[1-9][0-9]{4,10}$"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/StringUtils.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils; 2 | 3 | import java.io.PrintWriter; 4 | import java.io.StringWriter; 5 | 6 | /** 7 | * @ClassName: StringUtils 8 | * @Description: TODO 9 | * @author: datealive 10 | * @date: 2021/2/22 14:44 11 | */ 12 | public class StringUtils { 13 | /** 14 | * 判断字符串是否为空 15 | * 16 | * @param str 待校验字符串 17 | * @return 18 | */ 19 | public static boolean isEmpty(String... str) { 20 | for (String s : str) { 21 | if (s == null || "".equals(s.trim())) { 22 | return true; 23 | } 24 | } 25 | return false; 26 | } 27 | 28 | /** 29 | * 判断字符串中是否包含特殊字符 30 | * 31 | * @param str 待校验字符串 32 | * @return 33 | */ 34 | public static boolean hasSpecialChar(String... str) { 35 | for (String s : str) { 36 | if (s.contains("%") || s.contains("_") || s.contains("[") || s.contains("#") || s.contains("*")||s.contains("/")||s.contains("<")||s.contains(">")) { 37 | return true; 38 | } 39 | } 40 | return false; 41 | } 42 | 43 | /** 44 | * 截取字符串 45 | * 46 | * @param str 原始字符串 47 | * @param start 起始位置 48 | * @param end 结束位置 49 | * @return 50 | */ 51 | public static String substring(String str, int start, int end) { 52 | if (str == null || "".equals(str)) { 53 | return ""; 54 | } 55 | if (start < 0 || end < 0) { 56 | return str; 57 | } 58 | if (end > str.length()) { 59 | end = str.length(); 60 | } 61 | if (start >= end) { 62 | return ""; 63 | } 64 | return str.substring(start, end); 65 | } 66 | 67 | /** 68 | * 获取堆栈信息 69 | * 70 | * @param throwable 异常 71 | * @return 72 | */ 73 | public static String getStackTrace(Throwable throwable) { 74 | StringWriter sw = new StringWriter(); 75 | try (PrintWriter pw = new PrintWriter(sw)) { 76 | throwable.printStackTrace(pw); 77 | return sw.toString(); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/UserAgentUtils.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils; 2 | 3 | import nl.basjes.parse.useragent.UserAgent; 4 | import nl.basjes.parse.useragent.UserAgentAnalyzer; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | 11 | /** 12 | * @ClassName: UserAgentUtils 13 | * @Description: UserAgent解析工具类 14 | * @author: datealive 15 | * @date: 2021/2/17 13:45 16 | */ 17 | @Component 18 | public class UserAgentUtils { 19 | private UserAgentAnalyzer uaa; 20 | 21 | public UserAgentUtils() { 22 | this.uaa = UserAgentAnalyzer 23 | .newBuilder() 24 | .hideMatcherLoadStats() 25 | .withField("OperatingSystemNameVersionMajor") 26 | .withField("AgentNameVersion") 27 | .build(); 28 | } 29 | 30 | /** 31 | * 从User-Agent解析客户端操作系统和浏览器版本 32 | * 33 | * @param userAgent 34 | * @return 35 | */ 36 | public Map parseOsAndBrowser(String userAgent) { 37 | UserAgent agent = uaa.parse(userAgent); 38 | String os = agent.getValue("OperatingSystemNameVersionMajor"); 39 | String browser = agent.getValue("AgentNameVersion"); 40 | Map map = new HashMap<>(); 41 | map.put("os", os); 42 | map.put("browser", browser); 43 | return map; 44 | } 45 | } -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/markdowntoHtml/ext/cover/Cover.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils.markdowntoHtml.ext.cover; 2 | 3 | import org.commonmark.node.CustomNode; 4 | import org.commonmark.node.Delimited; 5 | 6 | /** 7 | * @ClassName: Cover 8 | * @Description: TODO 9 | * @author: datealive 10 | * @date: 2021/2/27 9:51 11 | */ 12 | public class Cover extends CustomNode implements Delimited { 13 | private static final String DELIMITER = "%%"; 14 | 15 | @Override 16 | public String getOpeningDelimiter() { 17 | return DELIMITER; 18 | } 19 | 20 | @Override 21 | public String getClosingDelimiter() { 22 | return DELIMITER; 23 | } 24 | } -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/markdowntoHtml/ext/cover/CoverExtension.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils.markdowntoHtml.ext.cover; 2 | 3 | import com.datealive.utils.markdowntoHtml.ext.cover.internal.CoverDelimiterProcessor; 4 | import com.datealive.utils.markdowntoHtml.ext.cover.internal.CoverHtmlNodeRenderer; 5 | import com.datealive.utils.markdowntoHtml.ext.cover.internal.CoverTextContentNodeRenderer; 6 | import org.commonmark.Extension; 7 | import org.commonmark.parser.Parser; 8 | import org.commonmark.renderer.NodeRenderer; 9 | import org.commonmark.renderer.html.HtmlNodeRendererContext; 10 | import org.commonmark.renderer.html.HtmlNodeRendererFactory; 11 | import org.commonmark.renderer.html.HtmlRenderer; 12 | import org.commonmark.renderer.text.TextContentNodeRendererContext; 13 | import org.commonmark.renderer.text.TextContentNodeRendererFactory; 14 | import org.commonmark.renderer.text.TextContentRenderer; 15 | 16 | /** 17 | * @ClassName: CoverExtension 18 | * @Description: TODO 19 | * @author: datealive 20 | * @date: 2021/2/27 9:51 21 | */ 22 | public class CoverExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension, TextContentRenderer.TextContentRendererExtension { 23 | private CoverExtension() { 24 | } 25 | 26 | public static Extension create() { 27 | return new CoverExtension(); 28 | } 29 | 30 | @Override 31 | public void extend(Parser.Builder parserBuilder) { 32 | parserBuilder.customDelimiterProcessor(new CoverDelimiterProcessor()); 33 | } 34 | 35 | @Override 36 | public void extend(HtmlRenderer.Builder rendererBuilder) { 37 | rendererBuilder.nodeRendererFactory(new HtmlNodeRendererFactory() { 38 | @Override 39 | public NodeRenderer create(HtmlNodeRendererContext context) { 40 | return new CoverHtmlNodeRenderer(context); 41 | } 42 | }); 43 | } 44 | 45 | @Override 46 | public void extend(TextContentRenderer.Builder rendererBuilder) { 47 | rendererBuilder.nodeRendererFactory(new TextContentNodeRendererFactory() { 48 | @Override 49 | public NodeRenderer create(TextContentNodeRendererContext context) { 50 | return new CoverTextContentNodeRenderer(context); 51 | } 52 | }); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/markdowntoHtml/ext/cover/internal/AbstractCoverNodeRenderer.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils.markdowntoHtml.ext.cover.internal; 2 | 3 | import com.datealive.utils.markdowntoHtml.ext.cover.Cover; 4 | import org.commonmark.node.Node; 5 | import org.commonmark.renderer.NodeRenderer; 6 | import java.util.Collections; 7 | import java.util.Set; 8 | 9 | /** 10 | * @ClassName: AbstractCoverNodeRenderer 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/27 9:53 14 | */ 15 | abstract class AbstractCoverNodeRenderer implements NodeRenderer { 16 | @Override 17 | public Set> getNodeTypes() { 18 | return Collections.>singleton(Cover.class); 19 | } 20 | } -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/markdowntoHtml/ext/cover/internal/CoverDelimiterProcessor.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils.markdowntoHtml.ext.cover.internal; 2 | 3 | import com.datealive.utils.markdowntoHtml.ext.cover.Cover; 4 | import org.commonmark.node.Node; 5 | import org.commonmark.node.Text; 6 | import org.commonmark.parser.delimiter.DelimiterProcessor; 7 | import org.commonmark.parser.delimiter.DelimiterRun; 8 | /** 9 | * @ClassName: CoverDelimiterProcessor 10 | * @Description: TODO 11 | * @author: datealive 12 | * @date: 2021/2/27 9:54 13 | */ 14 | public class CoverDelimiterProcessor implements DelimiterProcessor { 15 | @Override 16 | public char getOpeningCharacter() { 17 | return '%'; 18 | } 19 | 20 | @Override 21 | public char getClosingCharacter() { 22 | return '%'; 23 | } 24 | 25 | @Override 26 | public int getMinLength() { 27 | return 2; 28 | } 29 | 30 | @Override 31 | public int getDelimiterUse(DelimiterRun opener, DelimiterRun closer) { 32 | if (opener.length() >= 2 && closer.length() >= 2) { 33 | // Use exactly two delimiters even if we have more, and don't care about internal openers/closers. 34 | return 2; 35 | } else { 36 | return 0; 37 | } 38 | } 39 | 40 | @Override 41 | public void process(Text opener, Text closer, int delimiterCount) { 42 | // Wrap nodes between delimiters in cover. 43 | Node cover = new Cover(); 44 | 45 | Node tmp = opener.getNext(); 46 | while (tmp != null && tmp != closer) { 47 | Node next = tmp.getNext(); 48 | cover.appendChild(tmp); 49 | tmp = next; 50 | } 51 | 52 | opener.insertAfter(cover); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/markdowntoHtml/ext/cover/internal/CoverHtmlNodeRenderer.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils.markdowntoHtml.ext.cover.internal; 2 | 3 | import org.commonmark.node.Node; 4 | import org.commonmark.renderer.html.HtmlNodeRendererContext; 5 | import org.commonmark.renderer.html.HtmlWriter; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | /** 10 | * @ClassName: CoverHtmlNodeRenderer 11 | * @Description: TODO 12 | * @author: datealive 13 | * @date: 2021/2/27 9:55 14 | */ 15 | public class CoverHtmlNodeRenderer extends AbstractCoverNodeRenderer { 16 | private final HtmlNodeRendererContext context; 17 | private final HtmlWriter html; 18 | 19 | public CoverHtmlNodeRenderer(HtmlNodeRendererContext context) { 20 | this.context = context; 21 | this.html = context.getWriter(); 22 | } 23 | 24 | @Override 25 | public void render(Node node) { 26 | Map attributes = new HashMap<>(); 27 | attributes.put("class", "m-text-cover"); 28 | html.tag("span", context.extendAttributes(node, "span", attributes)); 29 | renderChildren(node); 30 | html.tag("/span"); 31 | } 32 | 33 | private void renderChildren(Node parent) { 34 | Node node = parent.getFirstChild(); 35 | while (node != null) { 36 | Node next = node.getNext(); 37 | context.render(node); 38 | node = next; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /blog-api/src/main/java/com/datealive/utils/markdowntoHtml/ext/cover/internal/CoverTextContentNodeRenderer.java: -------------------------------------------------------------------------------- 1 | package com.datealive.utils.markdowntoHtml.ext.cover.internal; 2 | 3 | import org.commonmark.node.Node; 4 | import org.commonmark.renderer.text.TextContentNodeRendererContext; 5 | import org.commonmark.renderer.text.TextContentWriter; 6 | /** 7 | * @ClassName: CoverTextContentNodeRenderer 8 | * @Description: TODO 9 | * @author: datealive 10 | * @date: 2021/2/27 9:56 11 | */ 12 | public class CoverTextContentNodeRenderer extends AbstractCoverNodeRenderer { 13 | private final TextContentNodeRendererContext context; 14 | private final TextContentWriter textContent; 15 | 16 | public CoverTextContentNodeRenderer(TextContentNodeRendererContext context) { 17 | this.context = context; 18 | this.textContent = context.getWriter(); 19 | } 20 | 21 | @Override 22 | public void render(Node node) { 23 | textContent.write('/'); 24 | renderChildren(node); 25 | textContent.write('/'); 26 | } 27 | 28 | private void renderChildren(Node parent) { 29 | Node node = parent.getFirstChild(); 30 | while (node != null) { 31 | Node next = node.getNext(); 32 | context.render(node); 33 | node = next; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /blog-api/src/main/resources/META-INF/spring-devtools.properties: -------------------------------------------------------------------------------- 1 | restart.include.shiro-redis=/shiro-[\\w-\\.]+jar 2 | restart.include.pagehelper=/pagehelper-[\\w-\\.]+jar -------------------------------------------------------------------------------- /blog-api/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8089 3 | website: 4 | url: https://blog.datealive.top/ #评论邮箱回复前缀链接 这里是你的前端页面url 5 | max-http-header-size: 16KB 6 | file-save-path: D:/blogimg #/www/wwwroot/api.datealive.top/image/ #文件上传位置 7 | 8 | spring: 9 | datasource: 10 | username: root 11 | password: root 12 | url: jdbc:mysql://127.0.0.1:3306/blog_db?serverTimezone=GMT%2B8 13 | driver-class-name: com.mysql.cj.jdbc.Driver 14 | type: com.alibaba.druid.pool.DruidDataSource # 自定义数据源 15 | #Spring Boot 默认是不注入这些属性值的,需要自己绑定 16 | #druid 数据源专有配置 17 | initialSize: 5 18 | minIdle: 5 19 | maxActive: 20 20 | maxWait: 60000 21 | timeBetweenEvictionRunsMillis: 60000 22 | minEvictableIdleTimeMillis: 300000 23 | validationQuery: SELECT 1 FROM DUAL 24 | testWhileIdle: false 25 | testOnBorrow: false 26 | testOnReturn: false 27 | poolPreparedStatements: true 28 | stat-view-servlet: 29 | enabled: false 30 | web-stat-filter: 31 | enabled: false 32 | filter: 33 | config: 34 | enabled: false 35 | #配置监控统计拦截的filters,stat:监控统计、log4j:日志记录、wall:防御sql注入 36 | #如果允许时报错 java.lang.ClassNotFoundException: org.apache.log4j.Priority 37 | #则导入 log4j 依赖即可,Maven 地址:https://mvnrepository.com/artifact/log4j/log4j 38 | filters: stat,log4j2,wall 39 | maxPoolPreparedStatementPerConnectionSize: 20 40 | useGlobalDataSourceStat: true 41 | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500 42 | connectionInitSqls : set names utf8mb4 43 | redis: 44 | host: 127.0.0.1 45 | port: 6379 46 | timeout: 20000 47 | mail: #邮件任务 48 | host: smtp.qq.com 49 | username: 2448282543@qq.com 50 | password: drmydefgaptbdjif 51 | properties: 52 | mail: 53 | smtp: 54 | ssl: 55 | enable: true 56 | 57 | 58 | mybatis: 59 | mapper-locations: classpath:mapper/*.xml 60 | type-aliases-package: com.datealive.pojo 61 | 62 | shiro-redis: 63 | enabled: true 64 | redis-manager: 65 | host: 127.0.0.1:6379 66 | 67 | datealive: 68 | jwt: 69 | # 加密秘钥 70 | secret: zrf5201314348f86b67cde581c0f9e11 71 | # token有效时长,7天,单位秒 72 | expire: 604800 73 | header: token 74 | gitee: 75 | #token 76 | ACCESS_TOKEN: 8ade7e71eaa9bd61f9eccedfe0fbb821 #自己去申请 77 | OWNER: zhangrenfeng #个人空间名 78 | REPO_NAME: images #仓库名 79 | 80 | 81 | pagehelper: 82 | helperDialect: mysql 83 | reasonable: true 84 | supportMethodsArguments: true 85 | params: count=countSql 86 | 87 | # 控制台输出sql语句 88 | # 打印mybatis sql执行日志信息 89 | #logging: 90 | # level: 91 | # com.datealive.mapper: debug 92 | -------------------------------------------------------------------------------- /blog-api/src/main/resources/ipdb/ip2region.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-api/src/main/resources/ipdb/ip2region.db -------------------------------------------------------------------------------- /blog-api/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 1 30 | 31 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /blog-api/src/main/resources/mapper/FriendsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 23 | 24 | 27 | 28 | 31 | 32 | 33 | 34 | insert into blog_link(link_name, link_url, link_info, avatar,status) 35 | VALUES(#{link_name},#{link_url},#{link_info},#{avatar},#{status}) 36 | 37 | 38 | 39 | 40 | update blog_link 41 | set link_name = #{link_name}, 42 | link_url= #{link_url}, 43 | link_info=#{link_info}, 44 | avatar=#{avatar}, 45 | status=#{status} 46 | where link_id = #{link_id} 47 | 48 | 49 | 50 | 51 | update blog_link 52 | set `status`=#{status} 53 | where link_id = #{link_id} 54 | 55 | 56 | 57 | 58 | delete from blog_link where link_id = #{link_id} 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /blog-api/src/main/resources/mapper/MomentMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 23 | 24 | 25 | 26 | update moment set likes=likes+1 where id=#{momentId} 27 | 28 | 29 | 30 | 31 | update moment set is_published=#{is_published} where id=#{momentId} 32 | 33 | 34 | 35 | 38 | 39 | 40 | 41 | delete from moment where id=#{id} 42 | 43 | 44 | 45 | 46 | insert into moment (content, create_time, likes, is_published) values (#{content}, #{createTime}, #{likes}, #{published}) 47 | 48 | 49 | 50 | 51 | update moment set content=#{content}, is_published=#{published} where id=#{id} 52 | 53 | 54 | 57 | 60 | -------------------------------------------------------------------------------- /blog-api/src/main/resources/mapper/SiteSettingMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | update site_setting set value=#{value} where id=#{id} 19 | 20 | 21 | 22 | 23 | delete from site_setting where id=#{id} 24 | 25 | 26 | 27 | 28 | insert into site_setting (name_en, name_zh, value, type) values (#{name_en}, #{name_zh}, #{value}, #{type}) 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /blog-api/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 11 | 12 | 16 | 17 | 18 | update blog_user set password = #{password} where username = #{userName} 19 | 20 | 21 | 22 | INSERT INTO 23 | `blog_user`(username, password, nick_name, avatar, introduce, roles, email) 24 | VALUES (#{username},#{password},#{nick_name},#{avatar},#{introduce},#{roles},#{email}) 25 | 26 | -------------------------------------------------------------------------------- /blog-api/src/test/java/com/datealive/test/testTest.java: -------------------------------------------------------------------------------- 1 | package com.datealive.test; 2 | 3 | import cn.hutool.json.JSON; 4 | import cn.hutool.json.JSONObject; 5 | import cn.hutool.json.JSONUtil; 6 | import com.datealive.config.GiteeImgConfig; 7 | import com.datealive.utils.UserUtils; 8 | import org.apache.commons.text.StringEscapeUtils; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.web.client.RestTemplate; 13 | 14 | import static org.junit.jupiter.api.Assertions.*; 15 | /** 16 | * @ClassName: testTest 17 | * @Description: TODO 18 | * @author: datealive 19 | * @date: 2021/2/18 0:00 20 | */ 21 | @SpringBootTest 22 | class testTest { 23 | 24 | 25 | @Test 26 | public void test(){ 27 | String path=GiteeImgConfig.PATH.substring(1,GiteeImgConfig.PATH.length()-1); 28 | System.out.println(path); 29 | } 30 | 31 | 32 | 33 | 34 | } -------------------------------------------------------------------------------- /blog-front-cms/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not ie <= 8 4 | -------------------------------------------------------------------------------- /blog-front-cms/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | example.html 5 | favicon.ico 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | 15 | # Editor directories and files 16 | .idea 17 | .vscode 18 | *.suo 19 | *.ntvs* 20 | *.njsproj 21 | *.sln 22 | *.sw* 23 | -------------------------------------------------------------------------------- /blog-front-cms/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 4, 3 | "singleQuote": true, 4 | "trailingComma": "none", 5 | "printWidth": 140 6 | } -------------------------------------------------------------------------------- /blog-front-cms/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ], 5 | plugins: [ 6 | ["prismjs", { 7 | "languages": ["javascript", "java","css", "markup"], 8 | "plugins": ["line-numbers"], //配置显示行号插件 9 | "theme": "tomorrow", //主体名称 10 | "css": true 11 | }] 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /blog-front-cms/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-manage-system", 3 | "version": "4.2.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "dev": "npm run serve" 9 | }, 10 | "dependencies": { 11 | "axios": "^0.18.1", 12 | "babel-polyfill": "^6.26.0", 13 | "default-passive-events": "^2.0.0", 14 | "element-ui": "^2.11.0", 15 | "mavon-editor": "^2.6.17", 16 | "prismjs": "^1.23.0", 17 | "vue": "^2.6.10", 18 | "vue-clipboard2": "^0.3.1", 19 | "vue-cropperjs": "^3.0.0", 20 | "vue-i18n": "^8.10.0", 21 | "vue-quill-editor": "^3.0.6", 22 | "vue-router": "^3.0.3", 23 | "vue-schart": "^2.0.0", 24 | "vue-waterfall-plugin": "^1.1.0", 25 | "vuedraggable": "^2.17.0", 26 | "vuex": "^3.6.2" 27 | }, 28 | "devDependencies": { 29 | "@vue/cli-plugin-babel": "^3.9.0", 30 | "@vue/cli-service": "^3.9.0", 31 | "babel-plugin-prismjs": "^2.0.1", 32 | "vue-template-compiler": "^2.6.10" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /blog-front-cms/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /blog-front-cms/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | HI-Dream-BLOG后台系统 9 | 10 | 11 | 14 |

15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /blog-front-cms/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 30 | -------------------------------------------------------------------------------- /blog-front-cms/src/api/index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-cms/src/api/index.js -------------------------------------------------------------------------------- /blog-front-cms/src/assets/css/color-dark.css: -------------------------------------------------------------------------------- 1 | .header{ 2 | background-color: #242f42; 3 | } 4 | .login-wrap{ 5 | background: #324157; 6 | } 7 | .plugins-tips{ 8 | background: #eef1f6; 9 | } 10 | .plugins-tips a{ 11 | color: #20a0ff; 12 | } 13 | .el-upload--text em { 14 | color: #20a0ff; 15 | } 16 | .pure-button{ 17 | background: #20a0ff; 18 | } 19 | .tags-li.active { 20 | border: 1px solid #409EFF; 21 | background-color: #409EFF; 22 | } 23 | .message-title{ 24 | color: #20a0ff; 25 | } 26 | .collapse-btn:hover{ 27 | background: rgb(40,52,70); 28 | } -------------------------------------------------------------------------------- /blog-front-cms/src/assets/css/icon.css: -------------------------------------------------------------------------------- 1 | 2 | [class*=" el-icon-lx"], [class^=el-icon-lx] { 3 | font-family: lx-iconfont!important; 4 | } -------------------------------------------------------------------------------- /blog-front-cms/src/assets/css/main.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | } 5 | 6 | html, 7 | body, 8 | #app, 9 | .wrapper { 10 | width: 100%; 11 | height: 100%; 12 | overflow: hidden; 13 | } 14 | 15 | body { 16 | font-family: 'PingFang SC', "Helvetica Neue", Helvetica, "microsoft yahei", arial, STHeiTi, sans-serif; 17 | } 18 | 19 | a { 20 | text-decoration: none 21 | } 22 | 23 | 24 | .content-box { 25 | position: absolute; 26 | left: 250px; 27 | right: 0; 28 | top: 70px; 29 | bottom: 0; 30 | padding-bottom: 30px; 31 | -webkit-transition: left .3s ease-in-out; 32 | transition: left .3s ease-in-out; 33 | background: #f0f0f0; 34 | } 35 | 36 | .content { 37 | width: auto; 38 | height: 100%; 39 | padding: 10px; 40 | overflow-y: scroll; 41 | box-sizing: border-box; 42 | } 43 | 44 | .content-collapse { 45 | left: 65px; 46 | } 47 | 48 | .container { 49 | padding: 30px; 50 | background: #fff; 51 | border: 1px solid #ddd; 52 | border-radius: 5px; 53 | } 54 | 55 | .crumbs { 56 | margin: 10px 0; 57 | } 58 | 59 | .el-table th { 60 | background-color: #f5f7fa !important; 61 | } 62 | 63 | .pagination { 64 | margin: 20px 0; 65 | text-align: right; 66 | } 67 | 68 | .plugins-tips { 69 | padding: 20px 10px; 70 | margin-bottom: 20px; 71 | } 72 | 73 | .el-button+.el-tooltip { 74 | margin-left: 10px; 75 | } 76 | 77 | .el-table tr:hover { 78 | background: #f6faff; 79 | } 80 | 81 | .mgb20 { 82 | margin-bottom: 20px; 83 | } 84 | 85 | .move-enter-active, 86 | .move-leave-active { 87 | transition: opacity .5s; 88 | } 89 | 90 | .move-enter, 91 | .move-leave { 92 | opacity: 0; 93 | } 94 | 95 | /*BaseForm*/ 96 | 97 | .form-box { 98 | width: 600px; 99 | } 100 | 101 | .form-box .line { 102 | text-align: center; 103 | } 104 | 105 | .el-time-panel__content::after, 106 | .el-time-panel__content::before { 107 | margin-top: -7px; 108 | } 109 | 110 | .el-time-spinner__wrapper .el-scrollbar__wrap:not(.el-scrollbar__wrap--hidden-default) { 111 | padding-bottom: 0; 112 | } 113 | 114 | /*Upload*/ 115 | 116 | .pure-button { 117 | width: 150px; 118 | height: 40px; 119 | line-height: 40px; 120 | text-align: center; 121 | color: #fff; 122 | border-radius: 3px; 123 | } 124 | 125 | .g-core-image-corp-container .info-aside { 126 | height: 45px; 127 | } 128 | 129 | .el-upload--text { 130 | background-color: #fff; 131 | border: 1px dashed #d9d9d9; 132 | border-radius: 6px; 133 | box-sizing: border-box; 134 | width: 360px; 135 | height: 180px; 136 | text-align: center; 137 | cursor: pointer; 138 | position: relative; 139 | overflow: hidden; 140 | } 141 | 142 | .el-upload--text .el-icon-upload { 143 | font-size: 67px; 144 | color: #97a8be; 145 | margin: 40px 0 16px; 146 | line-height: 50px; 147 | } 148 | 149 | .el-upload--text { 150 | color: #97a8be; 151 | font-size: 14px; 152 | text-align: center; 153 | } 154 | 155 | .el-upload--text em { 156 | font-style: normal; 157 | } 158 | 159 | /*VueEditor*/ 160 | 161 | .ql-container { 162 | min-height: 400px; 163 | } 164 | 165 | .ql-snow .ql-tooltip { 166 | transform: translateX(117.5px) translateY(10px) !important; 167 | } 168 | 169 | .editor-btn { 170 | margin-top: 20px; 171 | } 172 | 173 | /*markdown*/ 174 | 175 | .v-note-wrapper .v-note-panel { 176 | min-height: 500px; 177 | } 178 | -------------------------------------------------------------------------------- /blog-front-cms/src/assets/css/theme-green/color-green.css: -------------------------------------------------------------------------------- 1 | .header{ 2 | background-color: #07c4a8; 3 | } 4 | .login-wrap{ 5 | background: rgba(56, 157, 170, 0.82);; 6 | } 7 | .plugins-tips{ 8 | background: #f2f2f2; 9 | } 10 | .plugins-tips a{ 11 | color: #00d1b2; 12 | } 13 | .el-upload--text em { 14 | color: #00d1b2; 15 | } 16 | .pure-button{ 17 | background: #00d1b2; 18 | } 19 | .pagination > .active > a, .pagination > .active > a:hover, .pagination > .active > a:focus, .pagination > .active > span, .pagination > .active > span:hover, .pagination > .active > span:focus { 20 | background-color: #00d1b2 !important; 21 | border-color: #00d1b2 !important; 22 | } 23 | .tags-li.active { 24 | border: 1px solid #00d1b2; 25 | background-color: #00d1b2; 26 | } 27 | .collapse-btn:hover{ 28 | background: #00d1b2; 29 | } -------------------------------------------------------------------------------- /blog-front-cms/src/assets/css/theme-green/fonts/element-icons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-cms/src/assets/css/theme-green/fonts/element-icons.ttf -------------------------------------------------------------------------------- /blog-front-cms/src/assets/css/theme-green/fonts/element-icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-cms/src/assets/css/theme-green/fonts/element-icons.woff -------------------------------------------------------------------------------- /blog-front-cms/src/assets/img/b-login.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-cms/src/assets/img/b-login.jpg -------------------------------------------------------------------------------- /blog-front-cms/src/assets/img/comment-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-cms/src/assets/img/comment-1.gif -------------------------------------------------------------------------------- /blog-front-cms/src/assets/img/img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-cms/src/assets/img/img.jpg -------------------------------------------------------------------------------- /blog-front-cms/src/assets/img/login-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-cms/src/assets/img/login-bg.jpg -------------------------------------------------------------------------------- /blog-front-cms/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-cms/src/assets/logo.png -------------------------------------------------------------------------------- /blog-front-cms/src/components/common/Home.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 52 | -------------------------------------------------------------------------------- /blog-front-cms/src/components/common/bus.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | 3 | // 使用 Event Bus 4 | const bus = new Vue(); 5 | 6 | export default bus; -------------------------------------------------------------------------------- /blog-front-cms/src/components/common/directives.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | 3 | // v-dialogDrag: 弹窗拖拽属性 4 | Vue.directive('dialogDrag', { 5 | bind(el, binding, vnode, oldVnode) { 6 | const dialogHeaderEl = el.querySelector('.el-dialog__header'); 7 | const dragDom = el.querySelector('.el-dialog'); 8 | 9 | dialogHeaderEl.style.cssText += ';cursor:move;' 10 | dragDom.style.cssText += ';top:0px;' 11 | 12 | // 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null); 13 | const sty = (() => { 14 | if (window.document.currentStyle) { 15 | return (dom, attr) => dom.currentStyle[attr]; 16 | } else { 17 | return (dom, attr) => getComputedStyle(dom, false)[attr]; 18 | } 19 | })() 20 | 21 | dialogHeaderEl.onmousedown = (e) => { 22 | // 鼠标按下,计算当前元素距离可视区的距离 23 | const disX = e.clientX - dialogHeaderEl.offsetLeft; 24 | const disY = e.clientY - dialogHeaderEl.offsetTop; 25 | 26 | const screenWidth = document.body.clientWidth; // body当前宽度 27 | const screenHeight = document.documentElement.clientHeight; // 可见区域高度(应为body高度,可某些环境下无法获取) 28 | 29 | const dragDomWidth = dragDom.offsetWidth; // 对话框宽度 30 | const dragDomheight = dragDom.offsetHeight; // 对话框高度 31 | 32 | const minDragDomLeft = dragDom.offsetLeft; 33 | const maxDragDomLeft = screenWidth - dragDom.offsetLeft - dragDomWidth; 34 | 35 | const minDragDomTop = dragDom.offsetTop; 36 | const maxDragDomTop = screenHeight - dragDom.offsetTop - dragDomheight; 37 | 38 | 39 | // 获取到的值带px 正则匹配替换 40 | let styL = sty(dragDom, 'left'); 41 | let styT = sty(dragDom, 'top'); 42 | 43 | // 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px 44 | if (styL.includes('%')) { 45 | styL = +document.body.clientWidth * (+styL.replace(/\%/g, '') / 100); 46 | styT = +document.body.clientHeight * (+styT.replace(/\%/g, '') / 100); 47 | } else { 48 | styL = +styL.replace(/\px/g, ''); 49 | styT = +styT.replace(/\px/g, ''); 50 | }; 51 | 52 | document.onmousemove = function (e) { 53 | // 通过事件委托,计算移动的距离 54 | let left = e.clientX - disX; 55 | let top = e.clientY - disY; 56 | 57 | // 边界处理 58 | if (-(left) > minDragDomLeft) { 59 | left = -(minDragDomLeft); 60 | } else if (left > maxDragDomLeft) { 61 | left = maxDragDomLeft; 62 | } 63 | 64 | if (-(top) > minDragDomTop) { 65 | top = -(minDragDomTop); 66 | } else if (top > maxDragDomTop) { 67 | top = maxDragDomTop; 68 | } 69 | 70 | // 移动当前元素 71 | dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`; 72 | }; 73 | 74 | document.onmouseup = function (e) { 75 | document.onmousemove = null; 76 | document.onmouseup = null; 77 | }; 78 | } 79 | } 80 | }) 81 | -------------------------------------------------------------------------------- /blog-front-cms/src/components/page/404.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 26 | 27 | 28 | 60 | -------------------------------------------------------------------------------- /blog-front-cms/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import App from './App.vue'; 3 | import router from './router'; 4 | import ElementUI from 'element-ui'; 5 | import 'element-ui/lib/theme-chalk/index.css'; // 默认主题 6 | // import './assets/css/theme-green/index.css'; // 浅绿色主题 7 | import './assets/css/icon.css'; 8 | import './components/common/directives'; 9 | import 'babel-polyfill'; 10 | import 'default-passive-events' 11 | import store from './store/store' 12 | import './permission.js' // 路由拦截 13 | import axios from '@/plugins/axios' 14 | 15 | Vue.prototype.$axios = axios // 16 | import VueClipboard from 'vue-clipboard2' 17 | 18 | Vue.use(VueClipboard) 19 | 20 | Vue.config.productionTip = false; 21 | Vue.use(ElementUI, { 22 | size: 'small' 23 | }); 24 | 25 | 26 | 27 | 28 | new Vue({ 29 | router, 30 | store, 31 | render: h => h(App) 32 | }).$mount('#app'); 33 | -------------------------------------------------------------------------------- /blog-front-cms/src/permission.js: -------------------------------------------------------------------------------- 1 | import router from "./router"; 2 | // 路由判断登录 根据路由配置文件的参数 3 | router.beforeEach((to, from, next) => { 4 | if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限 5 | const token = localStorage.getItem("token") 6 | // console.log("------------" + token) 7 | if (token) { // 判断当前的token是否存在 ; 登录存入的token 8 | if (to.path === '/login') { 9 | } else { 10 | next() 11 | } 12 | } else { 13 | next({ 14 | path: '/login' 15 | }) 16 | } 17 | } else { 18 | next() 19 | } 20 | }) 21 | -------------------------------------------------------------------------------- /blog-front-cms/src/plugins/axios.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import Element from "element-ui"; 3 | axios.defaults.baseURL = 'http://localhost:8089' 4 | import {Message} from "element-ui" 5 | let CancelToken = axios.CancelToken 6 | axios.interceptors.request.use(config => { 7 | //console.log("前置拦截") 8 | // 可以统一设置请求头 9 | const userJson = window.localStorage.getItem('userInfo') || '{}' 10 | const user = JSON.parse(userJson) 11 | if (userJson !== '{}' && user.roles !== 'admin' && config.method !== 'get') { 12 | config.cancelToken = new CancelToken(function executor(cancel) { 13 | cancel('演示模式,不允许操作') 14 | }) 15 | return config 16 | } 17 | return config 18 | }) 19 | axios.interceptors.response.use(response => { 20 | const res = response.data; 21 | //console.log("后置拦截") 22 | // 当结果的code是否为200的情况 23 | if (res.code === 200 || res.code === 404) { 24 | return response 25 | } else { 26 | // 弹窗异常信息 27 | Element.Message({ 28 | message: response.data.msg, 29 | type: 'error', 30 | duration: 2 * 1000 31 | }) 32 | // 直接拒绝往下面返回结果信息 33 | return Promise.reject(response.data.msg) 34 | } 35 | }, 36 | error => { 37 | // console.log('err==>' + error)// for debug 38 | // if (error.response.status === 401) { 39 | // store.commit('REMOVE_INFO'); 40 | // router.push({ 41 | // path: '/login' 42 | // }); 43 | // error.message = '请重新登录'; 44 | // } 45 | // if (error.response.status === 403) { 46 | // error.message = '权限不足,无法访问'; 47 | // } 48 | // 弹窗异常信息 49 | Message.error(error) 50 | return Promise.reject(error) 51 | }) 52 | export default axios -------------------------------------------------------------------------------- /blog-front-cms/src/store/store.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | Vue.use(Vuex) 5 | 6 | export default new Vuex.Store({ 7 |   state: { 8 |     token: '', 9 |     userInfo: JSON.parse(localStorage.getItem("userInfo")) 10 |   }, 11 |   mutations: { 12 |     SET_TOKEN: (state, token) => { 13 |       state.token = token 14 |       localStorage.setItem("token", token) 15 |     }, 16 |     SET_USERINFO: (state, userInfo) => { 17 |       state.userInfo = userInfo 18 |       localStorage.setItem("userInfo", JSON.stringify(userInfo)) 19 |     }, 20 |     REMOVE_INFO: (state) => { 21 | //       localStorage.setItem("token", '') 22 | //       localStorage.setItem("userInfo", JSON.stringify('')) 23 |       state.userInfo = {} 24 |   state.token = {} 25 | window.localStorage.clear() 26 |     } 27 |   }, 28 |   getters: { 29 |     getUser: state => { 30 |       return state.userInfo 31 |     } 32 |   }, 33 |   actions: {}, 34 |   modules: {} 35 | }) 36 | 37 | -------------------------------------------------------------------------------- /blog-front-cms/src/utils/request.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const service = axios.create({ 4 | // process.env.NODE_ENV === 'development' 来判断是否开发环境 5 | // easy-mock服务挂了,暂时不使用了 6 | // baseURL: 'https://www.easy-mock.com/mock/592501a391470c0ac1fab128', 7 | timeout: 5000 8 | }); 9 | 10 | service.interceptors.request.use( 11 | config => { 12 | return config; 13 | }, 14 | error => { 15 | console.log(error); 16 | return Promise.reject(); 17 | } 18 | ); 19 | 20 | service.interceptors.response.use( 21 | response => { 22 | if (response.status === 200) { 23 | return response.data; 24 | } else { 25 | Promise.reject(); 26 | } 27 | }, 28 | error => { 29 | console.log(error); 30 | return Promise.reject(); 31 | } 32 | ); 33 | 34 | export default service; 35 | -------------------------------------------------------------------------------- /blog-front-cms/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | baseUrl: './', 3 | assetsDir: 'static', 4 | productionSourceMap: false, 5 | // devServer: { 6 | // proxy: { 7 | // '/api':{ 8 | // target:'http://jsonplaceholder.typicode.com', 9 | // changeOrigin:true, 10 | // pathRewrite:{ 11 | // '/api':'' 12 | // } 13 | // } 14 | // } 15 | // } 16 | } -------------------------------------------------------------------------------- /blog-front-view/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /blog-front-view/README.md: -------------------------------------------------------------------------------- 1 | # front-blog 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Customize configuration 19 | See [Configuration Reference](https://cli.vuejs.org/config/). 20 | -------------------------------------------------------------------------------- /blog-front-view/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ], 5 | plugins: [ 6 | ["prismjs", { 7 | "languages": ["javascript", "Java","css", "markup"], 8 | "plugins": ["line-numbers"], //配置显示行号插件 9 | "theme": "tomorrow", //主体名称 10 | "css": true 11 | }] 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /blog-front-view/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "front-blog", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build" 8 | }, 9 | "dependencies": { 10 | "axios": "^0.21.1", 11 | "core-js": "^3.6.5", 12 | "element-ui": "^2.15.0", 13 | "mavon-editor": "^2.9.1", 14 | "node-sass": "^5.0.0", 15 | "prismjs": "^1.23.0", 16 | "sass-loader": "^10.1.1", 17 | "tocbot": "^4.12.2", 18 | "vue": "^2.6.11", 19 | "vue-router": "^3.2.0", 20 | "vuex": "^3.6.0" 21 | }, 22 | "devDependencies": { 23 | "@vue/cli-plugin-babel": "~4.5.0", 24 | "@vue/cli-plugin-router": "~4.5.0", 25 | "@vue/cli-service": "~4.5.0", 26 | "babel-plugin-prismjs": "^2.0.1", 27 | "vue-template-compiler": "^2.6.11" 28 | }, 29 | "browserslist": [ 30 | "> 1%", 31 | "last 2 versions", 32 | "not dead" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /blog-front-view/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/public/favicon.ico -------------------------------------------------------------------------------- /blog-front-view/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 梦独吟博客 11 | 12 | 13 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /blog-front-view/src/assets/beian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/beian.png -------------------------------------------------------------------------------- /blog-front-view/src/assets/csdn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/csdn.png -------------------------------------------------------------------------------- /blog-front-view/src/assets/dianzan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/dianzan.png -------------------------------------------------------------------------------- /blog-front-view/src/assets/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/github.png -------------------------------------------------------------------------------- /blog-front-view/src/assets/icon_QQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/icon_QQ.png -------------------------------------------------------------------------------- /blog-front-view/src/assets/introduction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/introduction.png -------------------------------------------------------------------------------- /blog-front-view/src/assets/lianjie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/lianjie.png -------------------------------------------------------------------------------- /blog-front-view/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/logo.png -------------------------------------------------------------------------------- /blog-front-view/src/assets/love.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/love.png -------------------------------------------------------------------------------- /blog-front-view/src/assets/love2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/love2.png -------------------------------------------------------------------------------- /blog-front-view/src/assets/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/star.png -------------------------------------------------------------------------------- /blog-front-view/src/assets/tag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/tag.png -------------------------------------------------------------------------------- /blog-front-view/src/assets/totop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/totop.png -------------------------------------------------------------------------------- /blog-front-view/src/assets/vue.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/vue.jpg -------------------------------------------------------------------------------- /blog-front-view/src/assets/置顶.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dateolive/Hi-Dream-Blog/a976d13620b5794402dfc1ac367ec516915ad53e/blog-front-view/src/assets/置顶.png -------------------------------------------------------------------------------- /blog-front-view/src/components/categorys.vue: -------------------------------------------------------------------------------- 1 | 27 | 28 | 59 | 60 | -------------------------------------------------------------------------------- /blog-front-view/src/components/tags.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 44 | 45 | -------------------------------------------------------------------------------- /blog-front-view/src/i18n/i18n.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueI18n from 'vue-i18n' 3 | import locale from 'element-ui/lib/locale' 4 | import zh from './langs/zh' 5 | import en from './langs/en' 6 | import enLocale from 'element-ui/lib/locale/lang/en' 7 | import zhLocale from 'element-ui/lib/locale/lang/zh-CN' 8 | 9 | 10 | Vue.use(VueI18n) 11 | 12 | const messages = { 13 | en: Object.assign(en, enLocale), 14 | zh: Object.assign(zh, zhLocale) 15 | } 16 | 17 | console.log(messages.zh) 18 | 19 | const i18n = new VueI18n({ 20 | locale: localStorage.getItem('locale') || 'zh', 21 | messages 22 | }) 23 | 24 | 25 | locale.i18n((key, value) => i18n.t(key, value)) //为了实现element插件的多语言切换 26 | 27 | export default i18n -------------------------------------------------------------------------------- /blog-front-view/src/i18n/langs/en.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | header: { 3 | home: 'Home', 4 | archive: 'Archive', 5 | about: 'About', 6 | language: 'Language', 7 | chinaese: '中文', 8 | english: 'English' 9 | }, 10 | home: { 11 | readMore: 'READ MORE' 12 | }, 13 | tag: { 14 | tag: 'TAGS' 15 | }, 16 | friend: { 17 | friend: 'FRIEDNS', 18 | exchange: 'Exchange' 19 | }, 20 | footer: { 21 | expressLane: 'Express Lane', 22 | gitee: 'Gitee', 23 | admin: 'Backstage Management' 24 | }, 25 | archive: { 26 | article: 'articles' 27 | }, 28 | about: { 29 | aboutMe: 'About Me', 30 | aboutBlog: 'About Blog', 31 | contactMe: 'Contact Me', 32 | blogSource: 'Blog Source', 33 | technology: 'Building Technology', 34 | other: 'Other', 35 | yourName: 'Name', 36 | email: 'Email', 37 | content: 'Content', 38 | nameTip: 'Please enter your name', 39 | emailTip1: 'Please enter your e-mail address', 40 | emailTip2: 'Please input the correct email address', 41 | contentTip: 'Please enter the message content', 42 | submit: 'Submit' 43 | }, 44 | article: { 45 | author: 'Author', 46 | originalLink: 'Original link', 47 | copyright: 'Copyright' 48 | }, 49 | apply: { 50 | process: 'Process', 51 | step1: 'Step1', 52 | step2: 'Step2', 53 | step3: 'Step3', 54 | next: 'Next step', 55 | previous: 'Previous', 56 | blogLink: 'Blog\'Link', 57 | nickName: 'Nickname', 58 | introduction: 'Introduction', 59 | email: 'Email', 60 | notes: 'Notes' 61 | } 62 | } -------------------------------------------------------------------------------- /blog-front-view/src/i18n/langs/zh.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | header: { 3 | home: '首页', 4 | archive: '归档', 5 | about: '关于', 6 | language: '语言', 7 | chinaese: '中文', 8 | english: 'English' 9 | }, 10 | home: { 11 | readMore: '阅读全文' 12 | }, 13 | tag: { 14 | tag: '标签' 15 | }, 16 | friend: { 17 | friend: '友链', 18 | exchange: '互换友链' 19 | }, 20 | footer: { 21 | expressLane: '快速通道', 22 | gitee: '码云', 23 | admin: '后台管理' 24 | }, 25 | archive: { 26 | article: '篇' 27 | }, 28 | about: { 29 | aboutMe: '关于自己', 30 | aboutBlog: '关于博客', 31 | contactMe: '给我留言', 32 | blogSource: '博客开源', 33 | technology: '涉及技术', 34 | other: '其他', 35 | yourName: '称谓', 36 | email: '邮箱', 37 | content: '留言内容', 38 | nameTip: '请输入您的称谓', 39 | emailTip1: '请输入您的邮箱', 40 | emailTip2: '请输入正确的邮箱地址', 41 | contentTip: '请输入留言内容', 42 | submit: '提交留言' 43 | }, 44 | article: { 45 | author: '本文作者', 46 | originalLink: '原文连接', 47 | copyright: '版权声明' 48 | }, 49 | apply: { 50 | process: '申请流程', 51 | step1: '步骤1', 52 | step2: '步骤2', 53 | step3: '步骤3', 54 | next: '下一步', 55 | previous: '上一步', 56 | blogLink: '博客链接', 57 | nickName: '昵称', 58 | introduction: '介绍', 59 | email: '联系邮箱', 60 | notes: '备注' 61 | } 62 | } -------------------------------------------------------------------------------- /blog-front-view/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | import router from './router' 4 | import VueRouter from 'vue-router' 5 | import Element from 'element-ui' 6 | import "element-ui/lib/theme-chalk/index.css" 7 | import 'element-ui/lib/theme-chalk/display.css' 8 | import './assets/style.css' 9 | import "./assets/typo.css"; 10 | import Head from './components/Head' 11 | import Footer from './components/Footer' 12 | import FriendSider from './components/FriendSider' 13 | import tags from './components/tags' 14 | import categorys from './components/categorys' 15 | import commentList from './components/Comment' 16 | import Introduction from './components/Introduction' 17 | import store from './store' 18 | Vue.use(Element) 19 | import axios from '@/plugins/axios' 20 | Vue.prototype.$axios = axios // 21 | // 全局注册 22 | // import with ES6 23 | Vue.component("Head",Head) 24 | Vue.component("Footer",Footer) 25 | Vue.component("FriendSider",FriendSider) 26 | Vue.component("tags",tags) 27 | Vue.component("categorys",categorys) 28 | Vue.component("commentList",commentList) 29 | Vue.component("Introduction",Introduction) 30 | Vue.use(VueRouter) 31 | const cubic = value => Math.pow(value, 3); 32 | const easeInOutCubic = value => value < 0.5 ? cubic(value * 2) / 2 : 1 - cubic((1 - value) * 2) / 2; 33 | Vue.prototype.scrollToTop = function () { 34 | const el = document.documentElement 35 | const beginTime = Date.now() 36 | const beginValue = el.scrollTop 37 | const rAF = window.requestAnimationFrame || (func => setTimeout(func, 16)) 38 | const frameFunc = () => { 39 | const progress = (Date.now() - beginTime) / 500; 40 | if (progress < 1) { 41 | el.scrollTop = beginValue * (1 - easeInOutCubic(progress)) 42 | rAF(frameFunc) 43 | } else { 44 | el.scrollTop = 0 45 | } 46 | } 47 | rAF(frameFunc) 48 | } 49 | Vue.config.productionTip = false 50 | 51 | //希望大家能留下版权信息,十分感谢 52 | console.log("\n %c Hi-Dream’s BLOG 博客系统开源作者:datealive %c https://github.com/dateolive \n", "color: #48dbfb; background: #1b1c1d; padding:5px 0;", "background: #fadfa3; padding:5px 0;") 53 | 54 | new Vue({ 55 | store, 56 | router, 57 | render: h => h(App) 58 | }).$mount('#app') 59 | -------------------------------------------------------------------------------- /blog-front-view/src/plugins/axios.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import Element from "element-ui"; 3 | axios.defaults.baseURL='https://api.datealive.top' 4 | axios.interceptors.request.use(config => { 5 |   //console.log("前置拦截") 6 |   // 可以统一设置请求头 7 |   return config 8 | }) 9 | axios.interceptors.response.use(response => { 10 |     const res = response.data; 11 |     //console.log("后置拦截") 12 | // 当结果的code是否为200的情况 13 |     if (res.code === 200||res.code===404) { 14 |       return response 15 |     } else { 16 | // 弹窗异常信息 17 |       Element.Message({ 18 |         message: response.data.msg, 19 |         type: 'error', 20 |         duration: 2 * 1000 21 |       }) 22 | // 直接拒绝往下面返回结果信息 23 |       return Promise.reject(response.data.msg) 24 |     } 25 |   }, 26 |   error => { 27 |     return Promise.reject(error) 28 |   }) 29 | export default axios -------------------------------------------------------------------------------- /blog-front-view/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueRouter from 'vue-router' 3 | import store from '../store' 4 | import Home from '../views/Home.vue' 5 | import Archive from '../views/Archive.vue' 6 | import Article from '../views/Article.vue' 7 | import BlogsByParams from '../components/BlogsByTagCate.vue' 8 | import friends from '../views/Friends.vue' 9 | import about from '../views/About.vue' 10 | import Moment from '../views/Moment.vue' 11 | 12 | Vue.use(VueRouter) 13 | 14 | const routes = [ 15 | { 16 | path: '/', 17 | component: Home, 18 | meta: { 19 | title: '首页' 20 | } 21 | }, 22 | { 23 | path: '/Home', 24 | name: 'Home', 25 | component: Home, 26 | meta: { 27 | title: '首页' 28 | } 29 | }, 30 | { 31 | path: '/archive', 32 | name: 'archive', 33 | component: Archive, 34 | meta: { 35 | title: '归档' 36 | } 37 | }, 38 | { 39 | path: '/moment', 40 | name: 'moment', 41 | component: Moment, 42 | meta: { 43 | title: '动态说说' 44 | } 45 | }, 46 | { 47 | path: '/article/:blogId', 48 | name: 'article', 49 | component: Article, 50 | meta: { 51 | title: '文章' 52 | } 53 | }, 54 | { 55 | path: '/list/:type/:id', 56 | name: 'list', 57 | component: BlogsByParams, 58 | meta: { 59 | title: '文章' 60 | } 61 | }, 62 | { 63 | path: '/friends', 64 | name: 'friends', 65 | component: friends, 66 | meta: { 67 | title: '友情链接' 68 | } 69 | }, 70 | { 71 | path: '/about', 72 | name: 'about', 73 | component: about, 74 | meta: { 75 | title: '关于我' 76 | } 77 | } 78 | ] 79 | 80 | const router = new VueRouter({ 81 | mode: 'history', 82 | base: process.env.BASE_URL, 83 | routes 84 | }) 85 | 86 | //挂载路由守卫 87 | router.beforeEach((to, from, next) => { 88 | if (to.meta.title) { 89 | if (store.state.siteInfo.webTitleSuffix) { 90 | document.title = to.meta.title + store.state.siteInfo.webTitleSuffix 91 | } else { 92 | document.title = to.meta.title 93 | } 94 | } 95 | next() 96 | }) 97 | export default router 98 | -------------------------------------------------------------------------------- /blog-front-view/src/store/actions.js: -------------------------------------------------------------------------------- 1 | import { 2 | SAVE_SITE_INFO, 3 | SAVE_INTRODUCTION, 4 | SET_IS_BLOG_RENDER_COMPLETE, 5 | } from "./mutations-types"; 6 | 7 | 8 | export default { 9 | saveSiteInfo({commit}, siteInfo) { 10 | commit(SAVE_SITE_INFO, {siteInfo}) 11 | }, 12 | saveIntroduction({commit}, introduction) { 13 | commit(SAVE_INTRODUCTION, {introduction}) 14 | }, 15 | setIsBlogRenderComplete({commit}, ok) { 16 | commit(SET_IS_BLOG_RENDER_COMPLETE, {ok}) 17 | } 18 | } -------------------------------------------------------------------------------- /blog-front-view/src/store/getters.js: -------------------------------------------------------------------------------- 1 | export default { 2 | 3 | } -------------------------------------------------------------------------------- /blog-front-view/src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | import state from './state' 4 | import actions from './actions' 5 | import mutations from './mutations' 6 | import getters from './getters' 7 | 8 | Vue.use(Vuex) 9 | 10 | export default new Vuex.Store({ 11 | state, 12 | actions, 13 | mutations, 14 | getters 15 | }) -------------------------------------------------------------------------------- /blog-front-view/src/store/mutations-types.js: -------------------------------------------------------------------------------- 1 | export const SAVE_INTRODUCTION = 'saveIntroduction' 2 | export const SAVE_SITE_INFO = 'saveSiteInfo' 3 | export const SET_IS_BLOG_RENDER_COMPLETE = 'setIsBlogRenderComplete' -------------------------------------------------------------------------------- /blog-front-view/src/store/mutations.js: -------------------------------------------------------------------------------- 1 | import { 2 | SAVE_SITE_INFO, 3 | SAVE_INTRODUCTION, 4 | SET_IS_BLOG_RENDER_COMPLETE 5 | } from "./mutations-types"; 6 | 7 | export default { 8 | [SAVE_SITE_INFO](state, {siteInfo}) { 9 | state.siteInfo = siteInfo 10 | }, 11 | [SAVE_INTRODUCTION](state, {introduction}) { 12 | state.introduction = introduction 13 | }, 14 | [SET_IS_BLOG_RENDER_COMPLETE](state, {ok}) { 15 | state.isBlogRenderComplete = ok 16 | } 17 | } -------------------------------------------------------------------------------- /blog-front-view/src/store/state.js: -------------------------------------------------------------------------------- 1 | export default { 2 | siteInfo: '', 3 | introduction: { 4 | avatar: '', 5 | name: '', 6 | rollText: [], 7 | }, 8 | //博客文章渲染完成的标记 9 | isBlogRenderComplete: false 10 | } -------------------------------------------------------------------------------- /blog-front-view/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | publicPath: '/', 3 | devServer: { 4 | port: 4569 5 | } 6 | } --------------------------------------------------------------------------------