├── LICENSE ├── README.md ├── blog-springboot ├── blog-springboot.iml ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── minzheng │ │ └── blog │ │ ├── BlogApplication.java │ │ ├── config │ │ ├── MybatisPlusConfig.java │ │ ├── RabbitConfig.java │ │ ├── RedisConfig.java │ │ ├── SwaggerConfig.java │ │ ├── WebMvcConfig.java │ │ └── WebSecurityConfig.java │ │ ├── constant │ │ ├── ArticleConst.java │ │ ├── DeleteConst.java │ │ ├── LoginConst.java │ │ ├── PathConst.java │ │ ├── StatusConst.java │ │ └── UserConst.java │ │ ├── controller │ │ ├── ArticleController.java │ │ ├── BlogInfoController.java │ │ ├── CategoryController.java │ │ ├── CommentController.java │ │ ├── ControllerAdvice.java │ │ ├── FriendLinkController.java │ │ ├── MessageController.java │ │ ├── TagController.java │ │ ├── UserAuthController.java │ │ └── UserInfoController.java │ │ ├── dao │ │ ├── ArticleDao.java │ │ ├── ArticleTagDao.java │ │ ├── CategoryDao.java │ │ ├── CommentDao.java │ │ ├── ElasticsearchDao.java │ │ ├── FriendLinkDao.java │ │ ├── MessageDao.java │ │ ├── TagDao.java │ │ ├── UniqueViewDao.java │ │ ├── UserAuthDao.java │ │ └── UserInfoDao.java │ │ ├── dto │ │ ├── ArchiveDTO.java │ │ ├── ArticleBackDTO.java │ │ ├── ArticleDTO.java │ │ ├── ArticleHomeDTO.java │ │ ├── ArticleOptionDTO.java │ │ ├── ArticlePreviewDTO.java │ │ ├── ArticlePreviewListDTO.java │ │ ├── ArticleRankDTO.java │ │ ├── ArticleSearchDTO.java │ │ ├── BlogBackInfoDTO.java │ │ ├── BlogHomeInfoDTO.java │ │ ├── CategoryBackDTO.java │ │ ├── CategoryDTO.java │ │ ├── CommentBackDTO.java │ │ ├── CommentDTO.java │ │ ├── FriendLinkBackDTO.java │ │ ├── FriendLinkDTO.java │ │ ├── MessageBackDTO.java │ │ ├── MessageDTO.java │ │ ├── PageDTO.java │ │ ├── ReplyCountDTO.java │ │ ├── ReplyDTO.java │ │ ├── TagDTO.java │ │ ├── UserBackDTO.java │ │ └── UserInfoDTO.java │ │ ├── entity │ │ ├── Article.java │ │ ├── ArticleLike.java │ │ ├── ArticleTag.java │ │ ├── Category.java │ │ ├── Comment.java │ │ ├── CommentLike.java │ │ ├── FriendLink.java │ │ ├── Message.java │ │ ├── Tag.java │ │ ├── UniqueView.java │ │ ├── UserAuth.java │ │ └── UserInfo.java │ │ ├── exception │ │ └── ServeException.java │ │ ├── handler │ │ ├── AccessDeniedHandlerImpl.java │ │ ├── AuthenticationEntryPointImpl.java │ │ ├── AuthenticationFailHandlerImpl.java │ │ ├── AuthenticationSuccessHandlerImpl.java │ │ ├── LogoutSuccessHandlerImpl.java │ │ ├── MaxWellReceiver.java │ │ └── ServletRequestListenerImpl.java │ │ ├── service │ │ ├── ArticleService.java │ │ ├── ArticleTagService.java │ │ ├── BlogInfoService.java │ │ ├── CategoryService.java │ │ ├── CommentService.java │ │ ├── FriendLinkService.java │ │ ├── MessageService.java │ │ ├── TagService.java │ │ ├── UniqueViewService.java │ │ ├── UserAuthService.java │ │ ├── UserInfoService.java │ │ └── impl │ │ │ ├── ArticleServiceImpl.java │ │ │ ├── ArticleTagServiceImpl.java │ │ │ ├── BlogInfoServiceImpl.java │ │ │ ├── CategoryServiceImpl.java │ │ │ ├── CommentServiceImpl.java │ │ │ ├── FriendLinkServiceImpl.java │ │ │ ├── MessageServiceImpl.java │ │ │ ├── TagServiceImpl.java │ │ │ ├── UniqueViewServiceImpl.java │ │ │ ├── UserAuthServiceImpl.java │ │ │ ├── UserDetailsServiceImpl.java │ │ │ └── UserInfoServiceImpl.java │ │ ├── utils │ │ ├── BeanCopyUtil.java │ │ ├── HTMLUtil.java │ │ ├── IpUtil.java │ │ ├── OSSUtil.java │ │ └── UserUtil.java │ │ └── vo │ │ ├── ArticleVO.java │ │ ├── CategoryVO.java │ │ ├── CommentVO.java │ │ ├── ConditionVO.java │ │ ├── DeleteVO.java │ │ ├── FriendLinkVO.java │ │ ├── MessageVO.java │ │ ├── PasswordVO.java │ │ ├── Result.java │ │ ├── TagVO.java │ │ ├── UserInfoVO.java │ │ ├── UserRoleVO.java │ │ └── UserVO.java │ └── resources │ ├── application.yml │ └── mapper │ ├── ArticleDao.xml │ ├── CategoryDao.xml │ ├── CommentDao.xml │ ├── UniqueViewDao.xml │ └── UserAuthDao.xml ├── blog-vue ├── admin │ ├── .gitignore │ ├── README.md │ ├── babel.config.js │ ├── package-lock.json │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ ├── src │ │ ├── App.vue │ │ ├── assets │ │ │ └── css │ │ │ │ ├── iconfont.css │ │ │ │ ├── iconfont.eot │ │ │ │ ├── iconfont.svg │ │ │ │ ├── iconfont.ttf │ │ │ │ ├── iconfont.woff │ │ │ │ ├── iconfont.woff2 │ │ │ │ └── index.css │ │ ├── layout │ │ │ ├── components │ │ │ │ ├── NavBar.vue │ │ │ │ └── SideBar.vue │ │ │ └── index.vue │ │ ├── main.js │ │ ├── router │ │ │ └── index.js │ │ ├── store │ │ │ └── index.js │ │ └── views │ │ │ ├── about │ │ │ └── About.vue │ │ │ ├── article │ │ │ ├── Article.vue │ │ │ └── ArticleList.vue │ │ │ ├── category │ │ │ └── Category.vue │ │ │ ├── comment │ │ │ └── Comment.vue │ │ │ ├── friendLink │ │ │ └── FriendLink.vue │ │ │ ├── home │ │ │ └── Home.vue │ │ │ ├── login │ │ │ └── Login.vue │ │ │ ├── message │ │ │ └── Message.vue │ │ │ ├── setting │ │ │ └── Setting.vue │ │ │ ├── swagger │ │ │ └── Swagger.vue │ │ │ ├── tag │ │ │ └── Tag.vue │ │ │ └── user │ │ │ └── user.vue │ └── vue.config.js └── blog │ ├── .gitignore │ ├── README.md │ ├── babel.config.js │ ├── package-lock.json │ ├── package.json │ ├── public │ ├── favicon.ico │ ├── index.html │ └── ribbon.js │ ├── src │ ├── App.vue │ ├── assets │ │ ├── css │ │ │ ├── iconfont.css │ │ │ ├── iconfont.eot │ │ │ ├── iconfont.svg │ │ │ ├── iconfont.ttf │ │ │ ├── iconfont.woff │ │ │ ├── iconfont.woff2 │ │ │ ├── index.css │ │ │ └── markdown.css │ │ ├── img │ │ │ ├── alipay.png │ │ │ ├── ds.png │ │ │ └── wechat.png │ │ └── js │ │ │ └── emoji.js │ ├── components │ │ ├── ArticleList.vue │ │ ├── BackTop.vue │ │ ├── Comment.vue │ │ ├── Emoji.vue │ │ ├── OauthLogin.vue │ │ ├── Paging.vue │ │ ├── Reply.vue │ │ ├── layout │ │ │ ├── Footer.vue │ │ │ ├── SideNavBar.vue │ │ │ └── TopNavBar.vue │ │ ├── model │ │ │ ├── ForgetModel.vue │ │ │ ├── LoginModel.vue │ │ │ ├── RegisterModel.vue │ │ │ └── SearchModel.vue │ │ └── toast │ │ │ ├── Toast.vue │ │ │ └── index.js │ ├── main.js │ ├── plugins │ │ └── vuetify.js │ ├── router │ │ └── index.js │ ├── store │ │ └── index.js │ └── views │ │ ├── about │ │ └── About.vue │ │ ├── archive │ │ └── Archive.vue │ │ ├── article │ │ └── Article.vue │ │ ├── category │ │ └── Category.vue │ │ ├── home │ │ └── Home.vue │ │ ├── link │ │ └── Link.vue │ │ ├── message │ │ └── Messsage.vue │ │ ├── tag │ │ └── Tag.vue │ │ └── user │ │ └── User.vue │ └── vue.config.js └── blog.sql /README.md: -------------------------------------------------------------------------------- 1 | **项目链接:** [www.talkxj.com](https://www.talkxj.com) 2 | 3 | **后台链接:** [www.admin.talkxj.com](https://www.admin.talkxj.com) 4 | 5 | 测试账号:test@qq.com,密码:1234567,可登入后台查看 6 | 7 | **关于本地开发** 8 | 9 | 前端项目位于blog-vue下,blog为前台,admin为后台。 10 | 11 | 后端项目位于blog-springboot下。 12 | 13 | SQL文件位于根目录下。 14 | 15 | 可直接导入该项目于本地,修改后端配置文件中的数据库连接信息,项目中使用到的关于阿里云功能和第三方授权登录等需要自行开通。 16 | 17 | 当你克隆项目到本地后可使用邮箱账号:admin@qq.com,密码:1234567进行登录,也可自行注册并将其修改为admin权限。 18 | 19 | ## 项目特点 20 | 21 | - 前台参考"Hexo"的"Butterfly"设计,美观简洁,响应式体验好 22 | - 后台参考"element-admin"设计,侧边栏,历史标签,面包屑自动生成。 23 | - 采用Markdown编辑器,写法简单。 24 | - 评论支持表情输入回复等,样式参考Valine。 25 | - 代码遵循阿里巴巴开发规范,利于开发者学习。 26 | - 前后端分离部署,适应当前潮流。 27 | - 接入第三方登录,减少注册成本。 28 | - 留言采用弹幕墙,更加炫酷。 29 | - 支持代码高亮和复制,图片预览,深色模式等功能,提升用户体验。 30 | - 搜索文章支持高亮分词,响应速度快 31 | 32 | ## 技术介绍 33 | 34 | **前端:** "vue" + "vuex" + "vue-router" + "axios" + "vuetify" + "element" + "echarts" 35 | 36 | **后端:** "SpringBoot" + "nginx" + "docker" + "SpringSecurity" + "Swagger2" + "MyBatisPlus" + "Mysql" + "Redis" + "elasticsearch" + "rabbitMQ" + "MaxWell" 37 | 38 | **其他:** 接入QQ,微博第三方登录,接入腾讯云人机验证 39 | 40 | ## 运行环境 41 | 42 | **服务器:** 阿里云2核4G CentOS7.2 43 | 44 | **CDN:** 阿里云全站加速 45 | 46 | **对象存储:** 阿里云OSS 47 | 48 | 这套搭配响应速度非常快,可以做到响应100ms以下。 49 | 50 | ## 开发工具 51 | 52 | |开发工具|说明| 53 | |-|-| 54 | |IDEA|Java开发工具IDE| 55 | |VSCode|Vue开发工具IDE| 56 | |Navicat|MySQL远程连接工具| 57 | |Another Redis Desktop Manager|Redis远程连接工具| 58 | |X-shell|Linux远程连接工具| 59 | |filezilla|Linux文件上传工具| 60 | 61 | ## 开发环境 62 | 63 | |工具|版本| 64 | |-|-| 65 | |JDK|1.8| 66 | |MySQL|8.0.20| 67 | |Redis|6.0.5| 68 | |Elasticsearch|6.6.0| 69 | |RabbitMQ|3.8.5| 70 | 71 | ## 项目截图 72 | 73 | ![QQ截图20200629122244.png](https://www.static.talkxj.com/articles/1593404582248.png) 74 | 75 | ![QQ截图20200629122228.png](https://www.static.talkxj.com/articles/1593404582352.png) 76 | 77 | ![QQ截图20200703155942.png](https://www.static.talkxj.com/articles/1593763327991.png) 78 | 79 | ![QQ截图20200711095250.png](https://www.static.talkxj.com/articles/1594432395374.png) 80 | 81 | ## 项目运行环境 82 | 83 | 详见文章[Docker安装运行环境](https://www.talkxj.com/articles/2) 84 | 85 | ## 项目配置 86 | 87 | 详见文章[项目配置教程](https://www.talkxj.com/articles/3) 88 | 89 | ## docker部署教程 90 | 91 | 详见文章[项目部署教程](https://www.talkxj.com/articles/13) 92 | 93 | ## 注意事项 94 | 95 | - 博主用户信息ID默认为1,如需修改请到 /constant/UserConst 处修改BLOGGER_ID 96 | - 邮箱配置,第三方授权配置需要自己申请。 97 | - ElasticSearch需要自己先创建索引,项目运行环境教程中有介绍。 98 | 99 | ## 项目总结 100 | 101 | 博客作为新手入门项目是十分不错的,项目所用的技术栈覆盖的也比较广,适合初学者学习。总的来说,项目逻辑都比较简单,最麻烦的地方在于处理评论回复和第三方登录这块。做的不好的地方请大家见谅,有问题的或者有好的建议可以私聊联系我, 102 | 103 | ## 关注&交流 104 | 105 | ![博客技术交流群聊二维码.png](https://www.static.talkxj.com/articles/1594437310326.png) 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /blog-springboot/blog-springboot.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/BlogApplication.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | 8 | import org.springframework.scheduling.annotation.EnableScheduling; 9 | import org.springframework.web.client.RestTemplate; 10 | 11 | /** 12 | * 博客启动类 13 | * 14 | * @author 11921 15 | */ 16 | @MapperScan("com.minzheng.blog.dao") 17 | @SpringBootApplication 18 | @EnableScheduling 19 | public class BlogApplication { 20 | 21 | public static void main(String[] args) { 22 | System.setProperty("es.set.netty.runtime.available.processors", "false"); 23 | SpringApplication.run(BlogApplication.class, args); 24 | } 25 | 26 | @Bean 27 | public RestTemplate restTemplate() { 28 | return new RestTemplate(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/config/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.config; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; 4 | import org.mybatis.spring.annotation.MapperScan; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.transaction.annotation.EnableTransactionManagement; 8 | 9 | /** 10 | * mybatis plus配置类 11 | * @author xiaojie 12 | */ 13 | @EnableTransactionManagement 14 | @Configuration 15 | @MapperScan("com.baomidou.cloud.service.*.mapper*") 16 | public class MybatisPlusConfig { 17 | 18 | @Bean 19 | public PaginationInterceptor paginationInterceptor() { 20 | PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); 21 | return paginationInterceptor; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/config/RabbitConfig.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.config; 2 | 3 | import org.springframework.amqp.core.*; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * Rabbitmq配置类 9 | * 10 | * @author 11921 11 | */ 12 | @Configuration 13 | public class RabbitConfig { 14 | 15 | @Bean 16 | public Queue insertDirectQueue() { 17 | return new Queue("article", true); 18 | } 19 | 20 | @Bean 21 | FanoutExchange maxWellExchange() { 22 | return new FanoutExchange("maxwell", false, false); 23 | } 24 | 25 | @Bean 26 | Binding bindingArticleDirect() { 27 | return BindingBuilder.bind(insertDirectQueue()).to(maxWellExchange()); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.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 | * redis配置 15 | * @author 11921 16 | */ 17 | @Configuration 18 | public class RedisConfig { 19 | 20 | @Bean 21 | public RedisTemplate redisTemplate(RedisConnectionFactory factory) { 22 | RedisTemplate redisTemplate = new RedisTemplate(); 23 | redisTemplate.setConnectionFactory(factory); 24 | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); 25 | ObjectMapper mapper = new ObjectMapper(); 26 | mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); 27 | mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); 28 | jackson2JsonRedisSerializer.setObjectMapper(mapper); 29 | StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); 30 | // key采用String的序列化方式 31 | redisTemplate.setKeySerializer(stringRedisSerializer); 32 | // hash的key也采用String的序列化方式 33 | redisTemplate.setHashKeySerializer(stringRedisSerializer); 34 | // value序列化方式采用jackson 35 | redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); 36 | // hash的value序列化方式采用jackson 37 | redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer); 38 | redisTemplate.afterPropertiesSet(); 39 | return redisTemplate; 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.config; 2 | 3 | 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 7 | import springfox.documentation.builders.ApiInfoBuilder; 8 | import springfox.documentation.builders.PathSelectors; 9 | import springfox.documentation.builders.RequestHandlerSelectors; 10 | import springfox.documentation.service.ApiInfo; 11 | import springfox.documentation.spi.DocumentationType; 12 | import springfox.documentation.spring.web.plugins.Docket; 13 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 14 | 15 | import java.util.Collections; 16 | 17 | /** 18 | * swagger配置类 19 | * 20 | * @author xiaojie 21 | */ 22 | @Configuration 23 | @EnableSwagger2 24 | public class SwaggerConfig { 25 | @Bean 26 | public Docket createRestApi() { 27 | return new Docket(DocumentationType.SWAGGER_2) 28 | .protocols(Collections.singleton("https")) 29 | .host("www.admin.talkxj.com") 30 | .apiInfo(apiInfo()) 31 | .select() 32 | .apis(RequestHandlerSelectors.basePackage("com.minzheng.blog.controller")) 33 | .paths(PathSelectors.any()) 34 | .build(); 35 | } 36 | 37 | private ApiInfo apiInfo() { 38 | return new ApiInfoBuilder() 39 | .title("博客api文档") 40 | .description("springboot+vue开发的博客项目") 41 | .termsOfServiceUrl("https://www.talkxj.com") 42 | .version("1.0") 43 | .build(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/config/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.config; 2 | 3 | 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 | * mvc配置类 11 | * 12 | * @author xiaojie 13 | */ 14 | @Configuration 15 | public class WebMvcConfig implements WebMvcConfigurer { 16 | 17 | @Override 18 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 19 | registry.addResourceHandler("/swagger-ui.html") 20 | .addResourceLocations("classpath:/META-INF/resources/"); 21 | } 22 | 23 | @Override 24 | public void addCorsMappings(CorsRegistry registry) { 25 | registry.addMapping("/**") 26 | .allowCredentials(true) 27 | .allowedHeaders("*") 28 | .allowedOrigins("*") 29 | .allowedMethods("*"); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/config/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.config; 2 | 3 | import com.minzheng.blog.handler.*; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.http.HttpMethod; 8 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 9 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 | 11 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 12 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 13 | import org.springframework.security.crypto.bcrypt.BCrypt; 14 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 15 | import org.springframework.security.crypto.password.PasswordEncoder; 16 | 17 | /** 18 | * Security配置类 19 | * 20 | * @author 11921 21 | */ 22 | @Configuration 23 | @EnableWebSecurity 24 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 25 | @Autowired 26 | private AuthenticationEntryPointImpl authenticationEntryPoint; 27 | @Autowired 28 | private AccessDeniedHandlerImpl accessDeniedHandler; 29 | @Autowired 30 | private AuthenticationSuccessHandlerImpl authenticationSuccessHandler; 31 | @Autowired 32 | private AuthenticationFailHandlerImpl authenticationFailHandler; 33 | @Autowired 34 | private LogoutSuccessHandlerImpl logoutSuccessHandler; 35 | 36 | /** 37 | * 密码加密 38 | * 39 | * @return 40 | */ 41 | @Bean 42 | public PasswordEncoder passwordEncoder() { 43 | return new BCryptPasswordEncoder(); 44 | } 45 | 46 | /** 47 | * 配置权限 48 | * @param http 49 | * @throws Exception 50 | */ 51 | @Override 52 | protected void configure(HttpSecurity http) throws Exception { 53 | http 54 | .formLogin().loginProcessingUrl("/login").successHandler(authenticationSuccessHandler).failureHandler(authenticationFailHandler).and() 55 | .logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler).and() 56 | .authorizeRequests() 57 | //开放测试账号权限 58 | .antMatchers(HttpMethod.GET,"/admin/**").hasAnyRole("test","admin") 59 | //管理员页面需要权限 60 | .antMatchers("/admin/**").hasRole("admin") 61 | //用户操作,发表评论需要登录 62 | .antMatchers("/users/info","/users/avatar","/comments").authenticated() 63 | .anyRequest().permitAll() 64 | .and() 65 | //关闭跨站请求防护 66 | .csrf().disable().exceptionHandling() 67 | //未登录处理 68 | .authenticationEntryPoint(authenticationEntryPoint) 69 | //权限不足处理 70 | .accessDeniedHandler(accessDeniedHandler).and() 71 | //开启嵌入 72 | .headers().frameOptions().disable(); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/constant/ArticleConst.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.constant; 2 | 3 | /** 4 | * 文章常量 5 | * 6 | * @author 11921 7 | */ 8 | public class ArticleConst { 9 | 10 | /** 11 | * 文章发布状态 12 | */ 13 | public static final int PUBLISH = 0; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/constant/DeleteConst.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.constant; 2 | 3 | /** 4 | * 逻辑删除常量 5 | * @author 11921 6 | */ 7 | public class DeleteConst { 8 | 9 | /** 10 | * 正常状态 11 | */ 12 | public static final int NORMAL = 0; 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/constant/LoginConst.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.constant; 2 | 3 | /** 4 | * 登录状态常量 5 | * @author 11921 6 | */ 7 | public class LoginConst { 8 | 9 | /** 10 | * 邮箱登录 11 | */ 12 | public static final int EMAIL = 0; 13 | 14 | /** 15 | * QQ登录 16 | */ 17 | public static final int QQ = 1; 18 | 19 | /** 20 | * 微博登录 21 | */ 22 | public static final int WEIBO = 2; 23 | } 24 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/constant/PathConst.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.constant; 2 | 3 | /** 4 | * 路径常量 5 | * @author 11921 6 | */ 7 | public class PathConst { 8 | 9 | /** 10 | * 头像路径 11 | */ 12 | public static final String AVATAR = "avatar/"; 13 | 14 | /** 15 | * 文章图片路径 16 | */ 17 | public static final String ARTICLE = "articles/"; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/constant/StatusConst.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.constant; 2 | 3 | /** 4 | * 返回码常量 5 | * 6 | * @author xiaojie 7 | */ 8 | public class StatusConst { 9 | /** 10 | * 成功 11 | */ 12 | public static final int OK = 20000; 13 | 14 | /** 15 | * 失败 16 | */ 17 | public static final int ERROR = 20001; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/constant/UserConst.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.constant; 2 | 3 | /** 4 | * 用户常量 5 | * @author 11921 6 | */ 7 | public class UserConst { 8 | 9 | /** 10 | * 博主id 11 | */ 12 | public static final int BLOGGER_ID = 1; 13 | 14 | /** 15 | * 禁言状态 16 | */ 17 | public static final int SILENCE = 1; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/controller/BlogInfoController.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.controller; 2 | 3 | 4 | import com.minzheng.blog.dto.BlogHomeInfoDTO; 5 | import com.minzheng.blog.service.BlogInfoService; 6 | import com.minzheng.blog.vo.Result; 7 | import com.minzheng.blog.constant.StatusConst; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.GetMapping; 12 | 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | /** 17 | * @author xiaojie 18 | * @since 2020-05-18 19 | */ 20 | @Api(tags = "博客信息模块") 21 | @RestController 22 | public class BlogInfoController { 23 | @Autowired 24 | private BlogInfoService blogInfoService; 25 | 26 | @ApiOperation(value = "查看博客信息") 27 | @GetMapping("/") 28 | private Result getBlogHomeInfo() { 29 | return new Result(true, StatusConst.OK, "查询成功", blogInfoService.getBlogInfo()); 30 | } 31 | 32 | @ApiOperation(value = "查看后台信息") 33 | @GetMapping("/admin") 34 | private Result getBlogBackInfo() { 35 | return new Result(true, StatusConst.OK, "查询成功", blogInfoService.getBlogBackInfo()); 36 | } 37 | 38 | @ApiOperation(value = "查看关于我信息") 39 | @GetMapping("/about") 40 | private Result getAbout() { 41 | return new Result(true, StatusConst.OK, "查询成功", blogInfoService.getAbout()); 42 | } 43 | 44 | @ApiOperation(value = "修改关于我信息") 45 | @PutMapping("/admin/about") 46 | private Result updateAbout(String aboutContent) { 47 | blogInfoService.updateAbout(aboutContent); 48 | return new Result(true, StatusConst.OK, "修改成功"); 49 | } 50 | 51 | @ApiOperation(value = "修改公告") 52 | @PutMapping("/admin/notice") 53 | private Result updateNotice(String notice) { 54 | blogInfoService.updateNotice(notice); 55 | return new Result(true, StatusConst.OK, "修改成功"); 56 | } 57 | 58 | @ApiOperation(value = "查看公告") 59 | @GetMapping("/admin/notice") 60 | private Result getNotice() { 61 | return new Result(true, StatusConst.OK, "查看成功", blogInfoService.getNotice()); 62 | } 63 | 64 | } 65 | 66 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/controller/CategoryController.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.controller; 2 | 3 | 4 | import com.minzheng.blog.dto.ArticlePreviewListDTO; 5 | import com.minzheng.blog.dto.CategoryDTO; 6 | import com.minzheng.blog.dto.PageDTO; 7 | import com.minzheng.blog.entity.Category; 8 | import com.minzheng.blog.exception.ServeException; 9 | import com.minzheng.blog.service.ArticleService; 10 | import com.minzheng.blog.service.CategoryService; 11 | import com.minzheng.blog.vo.CategoryVO; 12 | import com.minzheng.blog.vo.ConditionVO; 13 | import com.minzheng.blog.vo.Result; 14 | import com.minzheng.blog.constant.StatusConst; 15 | import io.swagger.annotations.Api; 16 | import io.swagger.annotations.ApiOperation; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.transaction.annotation.Transactional; 19 | import org.springframework.web.bind.annotation.*; 20 | 21 | import javax.validation.Valid; 22 | import java.util.List; 23 | 24 | 25 | /** 26 | * 27 | * @author xiaojie 28 | * @since 2020-05-18 29 | */ 30 | @Api(tags = "分类模块") 31 | @RestController 32 | public class CategoryController { 33 | @Autowired 34 | private CategoryService categoryService; 35 | @Autowired 36 | private ArticleService articleService; 37 | 38 | @ApiOperation(value = "查看分类列表") 39 | @GetMapping("/categories") 40 | private Result> listCategories() { 41 | return new Result(true, StatusConst.OK, "查询成功", categoryService.listCategories()); 42 | } 43 | 44 | @ApiOperation(value = "查看后台分类列表") 45 | @GetMapping("/admin/categories") 46 | private Result> listCategoryBackDTO(ConditionVO condition) { 47 | return new Result(true, StatusConst.OK, "查询成功", categoryService.listCategoryBackDTO(condition)); 48 | } 49 | 50 | @ApiOperation(value = "添加或修改分类") 51 | @PostMapping("/admin/categories") 52 | private Result saveOrUpdateCategory(@Valid @RequestBody CategoryVO categoryVO) { 53 | categoryService.saveOrUpdate(new Category(categoryVO)); 54 | return new Result(true, StatusConst.OK, "操作成功"); 55 | } 56 | 57 | @ApiOperation(value = "删除分类") 58 | @DeleteMapping("/admin/categories") 59 | private Result deleteCategories(@RequestBody List categoryIdList) { 60 | categoryService.deleteCategory(categoryIdList); 61 | return new Result(true, StatusConst.OK, "删除成功"); 62 | } 63 | 64 | @ApiOperation(value = "查看分类下对应的文章") 65 | @GetMapping("/categories/{categoryId}") 66 | private Result listArticlesByCategoryId(@PathVariable("categoryId") Integer categoryId, Long current) { 67 | return new Result(true, StatusConst.OK, "查询成功", articleService.listArticlesByCondition(new ConditionVO(current, categoryId))); 68 | } 69 | 70 | } 71 | 72 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/controller/ControllerAdvice.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.controller; 2 | 3 | import com.minzheng.blog.exception.ServeException; 4 | import com.minzheng.blog.vo.Result; 5 | import com.minzheng.blog.constant.StatusConst; 6 | import org.springframework.web.bind.MethodArgumentNotValidException; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.bind.annotation.RestControllerAdvice; 9 | 10 | 11 | /** 12 | * 全局异常处理 13 | * 14 | * @author 11921 15 | */ 16 | @RestControllerAdvice 17 | public class ControllerAdvice { 18 | 19 | /** 20 | * 处理服务异常 21 | * 22 | * @param e 23 | * @return 24 | */ 25 | @ExceptionHandler(value = ServeException.class) 26 | public Result errorHandler(ServeException e) { 27 | return new Result(false, StatusConst.ERROR, e.getMessage()); 28 | } 29 | 30 | /** 31 | * 处理参数异常 32 | * @param e 33 | * @return 34 | */ 35 | @ExceptionHandler(MethodArgumentNotValidException.class) 36 | public Result handleValidException(MethodArgumentNotValidException e) { 37 | return new Result(false, StatusConst.ERROR, e.getBindingResult().getFieldError().getDefaultMessage()); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/controller/FriendLinkController.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.controller; 2 | 3 | 4 | import com.minzheng.blog.constant.StatusConst; 5 | import com.minzheng.blog.dto.FriendLinkBackDTO; 6 | import com.minzheng.blog.dto.FriendLinkDTO; 7 | import com.minzheng.blog.dto.PageDTO; 8 | import com.minzheng.blog.entity.FriendLink; 9 | import com.minzheng.blog.exception.ServeException; 10 | import com.minzheng.blog.service.FriendLinkService; 11 | import com.minzheng.blog.vo.*; 12 | import io.swagger.annotations.Api; 13 | import io.swagger.annotations.ApiOperation; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.transaction.annotation.Transactional; 16 | import org.springframework.web.bind.annotation.*; 17 | 18 | import javax.validation.Valid; 19 | import java.util.List; 20 | 21 | /** 22 | * @author xiaojie 23 | * @since 2020-05-18 24 | */ 25 | @Api(tags = "友链模块") 26 | @RestController 27 | public class FriendLinkController { 28 | @Autowired 29 | private FriendLinkService friendLinkService; 30 | 31 | @ApiOperation(value = "查看友链列表") 32 | @GetMapping("/links") 33 | private Result> listFriendLinks() { 34 | return new Result(true, StatusConst.OK, "查询成功", friendLinkService.listFriendLinks()); 35 | } 36 | 37 | @ApiOperation(value = "查看后台友链列表") 38 | @GetMapping("/admin/links") 39 | private Result> listFriendLinkDTO(ConditionVO condition) { 40 | return new Result(true, StatusConst.OK, "查询成功", friendLinkService.listFriendLinkDTO(condition)); 41 | } 42 | 43 | @ApiOperation(value = "保存或修改友链") 44 | @PostMapping("/admin/links") 45 | private Result saveOrUpdateFriendLink(@Valid @RequestBody FriendLinkVO friendLinkVO) { 46 | friendLinkService.saveOrUpdate(new FriendLink(friendLinkVO)); 47 | return new Result(true, StatusConst.OK, "操作成功"); 48 | } 49 | 50 | @ApiOperation(value = "删除友链") 51 | @DeleteMapping("/admin/links") 52 | private Result deleteFriendLink(@RequestBody List linkIdList) { 53 | friendLinkService.removeByIds(linkIdList); 54 | return new Result(true, StatusConst.OK, "删除成功"); 55 | } 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/controller/MessageController.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.controller; 2 | 3 | 4 | import com.minzheng.blog.constant.StatusConst; 5 | import com.minzheng.blog.dto.MessageBackDTO; 6 | import com.minzheng.blog.dto.PageDTO; 7 | import com.minzheng.blog.exception.ServeException; 8 | import com.minzheng.blog.vo.*; 9 | import com.minzheng.blog.dto.MessageDTO; 10 | import com.minzheng.blog.service.MessageService; 11 | import io.swagger.annotations.Api; 12 | import io.swagger.annotations.ApiOperation; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.transaction.annotation.Transactional; 15 | import org.springframework.web.bind.annotation.*; 16 | 17 | import javax.validation.Valid; 18 | import java.util.List; 19 | 20 | /** 21 | * @author xiaojie 22 | * @since 2020-05-18 23 | */ 24 | @Api(tags = "留言模块") 25 | @RestController 26 | public class MessageController { 27 | @Autowired 28 | private MessageService messageService; 29 | 30 | @ApiOperation(value = "添加留言") 31 | @PostMapping("/messages") 32 | private Result saveMessage(@Valid @RequestBody MessageVO messageVO) { 33 | messageService.saveMessage(messageVO); 34 | return new Result(true, StatusConst.OK, "添加成功"); 35 | } 36 | 37 | @ApiOperation(value = "查看留言列表") 38 | @GetMapping("/messages") 39 | private Result> listMessages() { 40 | return new Result(true, StatusConst.OK, "添加成功", messageService.listMessages()); 41 | } 42 | 43 | @ApiOperation(value = "查看后台留言列表") 44 | @GetMapping("/admin/messages") 45 | private Result> listMessageBackDTO(ConditionVO condition) { 46 | return new Result(true, StatusConst.OK, "添加成功", messageService.listMessageBackDTO(condition)); 47 | } 48 | 49 | @ApiOperation(value = "删除留言") 50 | @DeleteMapping("/admin/messages") 51 | public Result deleteMessages(@RequestBody List messageIdList) { 52 | messageService.removeByIds(messageIdList); 53 | return new Result(true, StatusConst.OK, "操作成功"); 54 | } 55 | 56 | } 57 | 58 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/controller/TagController.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.controller; 2 | 3 | 4 | import com.minzheng.blog.constant.StatusConst; 5 | import com.minzheng.blog.dto.ArticlePreviewListDTO; 6 | import com.minzheng.blog.dto.PageDTO; 7 | import com.minzheng.blog.dto.TagDTO; 8 | import com.minzheng.blog.entity.Tag; 9 | import com.minzheng.blog.exception.ServeException; 10 | import com.minzheng.blog.service.ArticleService; 11 | import com.minzheng.blog.service.TagService; 12 | import com.minzheng.blog.vo.*; 13 | import io.swagger.annotations.Api; 14 | import io.swagger.annotations.ApiOperation; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.transaction.annotation.Transactional; 17 | import org.springframework.web.bind.annotation.*; 18 | 19 | import javax.validation.Valid; 20 | import java.util.List; 21 | 22 | 23 | /** 24 | * 25 | * @author xiaojie 26 | * @since 2020-05-18 27 | */ 28 | @Api(tags = "标签模块") 29 | @RestController 30 | public class TagController { 31 | @Autowired 32 | private TagService tagService; 33 | @Autowired 34 | private ArticleService articleService; 35 | 36 | @ApiOperation(value = "查看标签列表") 37 | @GetMapping("/tags") 38 | private Result> listTags(Long current) { 39 | return new Result(true, StatusConst.OK, "查询成功", tagService.listTags()); 40 | } 41 | 42 | @ApiOperation(value = "查看分类下对应的文章") 43 | @GetMapping("/tags/{tagId}") 44 | private Result listArticlesByCategoryId(@PathVariable("tagId") Integer tagId, Long current) { 45 | return new Result(true, StatusConst.OK, "查询成功", articleService.listArticlesByCondition(new ConditionVO(tagId, current))); 46 | } 47 | 48 | @ApiOperation(value = "查看后台标签列表") 49 | @GetMapping("/admin/tags") 50 | private Result> listTagBackDTO(ConditionVO condition) { 51 | return new Result(true, StatusConst.OK, "查询成功", tagService.listTagBackDTO(condition)); 52 | } 53 | 54 | @ApiOperation(value = "添加或修改标签") 55 | @PostMapping("/admin/tags") 56 | private Result saveOrUpdateTag(@Valid @RequestBody TagVO tagVO) { 57 | tagService.saveOrUpdate(new Tag(tagVO)); 58 | return new Result(true, StatusConst.OK, "操作成功"); 59 | } 60 | 61 | @ApiOperation(value = "删除标签") 62 | @DeleteMapping("/admin/tags") 63 | private Result deleteTag(@RequestBody List tagIdList) { 64 | tagService.deleteTag(tagIdList); 65 | return new Result(true, StatusConst.OK, "删除成功"); 66 | } 67 | 68 | 69 | } 70 | 71 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/controller/UserAuthController.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.controller; 2 | 3 | 4 | import com.minzheng.blog.constant.StatusConst; 5 | import com.minzheng.blog.dto.PageDTO; 6 | import com.minzheng.blog.dto.UserInfoDTO; 7 | import com.minzheng.blog.service.UserAuthService; 8 | import com.minzheng.blog.vo.*; 9 | import io.swagger.annotations.Api; 10 | import io.swagger.annotations.ApiImplicitParam; 11 | import io.swagger.annotations.ApiImplicitParams; 12 | import io.swagger.annotations.ApiOperation; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.web.bind.annotation.*; 15 | 16 | import javax.validation.Valid; 17 | 18 | /*** 19 | * @author xiaojie 20 | * @since 2020-05-18 21 | */ 22 | @Api(tags = "用户账号模块") 23 | @RestController 24 | public class UserAuthController { 25 | @Autowired 26 | private UserAuthService userAuthService; 27 | 28 | @ApiOperation(value = "发送邮箱验证码") 29 | @ApiImplicitParam(name = "username", value = "用户名", required = true, dataType = "String") 30 | @GetMapping("/users/code") 31 | private Result sendCode(String username) { 32 | userAuthService.sendCode(username); 33 | return new Result(true, StatusConst.OK, "发送成功!"); 34 | } 35 | 36 | @ApiOperation(value = "查看后台用户列表") 37 | @GetMapping("/admin/users") 38 | private Result listUsers(ConditionVO condition) { 39 | return new Result(true, StatusConst.OK, "查询成功!", userAuthService.listUserBackDTO(condition)); 40 | } 41 | 42 | @ApiOperation(value = "用户注册") 43 | @PostMapping("/users") 44 | private Result saveUser(@Valid @RequestBody UserVO user) { 45 | userAuthService.saveUser(user); 46 | return new Result(true, StatusConst.OK, "注册成功!"); 47 | } 48 | 49 | @ApiOperation(value = "修改密码") 50 | @PutMapping("/users/password") 51 | private Result updatePassword(@Valid @RequestBody UserVO user) { 52 | userAuthService.updatePassword(user); 53 | return new Result(true, StatusConst.OK, "修改成功!"); 54 | } 55 | 56 | @ApiOperation(value = "修改管理员密码") 57 | @PutMapping("/admin/users/password") 58 | private Result updateAdminPassword(@Valid @RequestBody PasswordVO passwordVO) { 59 | userAuthService.updateAdminPassword(passwordVO); 60 | return new Result(true, StatusConst.OK, "修改成功!"); 61 | } 62 | 63 | @ApiOperation(value = "微博登录") 64 | @ApiImplicitParam(name = "code", value = "code", required = true, dataType = "String") 65 | @PostMapping("/users/oauth/weibo") 66 | private Result qqLogin(String code) { 67 | return new Result(true, StatusConst.OK, "登录成功!", userAuthService.weiboLogin(code)); 68 | } 69 | 70 | @ApiOperation(value = "qq登录") 71 | @ApiImplicitParams({ 72 | @ApiImplicitParam(name = "openId", value = "openId", required = true, dataType = "String"), 73 | @ApiImplicitParam(name = "accessToken", value = "accessToken", required = true, dataType = "String") 74 | }) 75 | @PostMapping("/users/oauth/qq") 76 | private Result qqLogin(String openId, String accessToken) { 77 | return new Result(true, StatusConst.OK, "登录成功!", userAuthService.qqLogin(openId, accessToken)); 78 | } 79 | 80 | } 81 | 82 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/controller/UserInfoController.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.controller; 2 | 3 | 4 | import com.minzheng.blog.constant.StatusConst; 5 | import com.minzheng.blog.service.UserInfoService; 6 | import com.minzheng.blog.vo.*; 7 | import io.swagger.annotations.Api; 8 | import io.swagger.annotations.ApiImplicitParam; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import org.springframework.web.multipart.MultipartFile; 14 | 15 | import javax.validation.Valid; 16 | 17 | /** 18 | * 处理用户信息 19 | * 20 | * @author xiaojie 21 | * @since 2020-05-18 22 | */ 23 | @Api(tags = "用户信息模块") 24 | @RestController 25 | public class UserInfoController { 26 | @Autowired 27 | private UserInfoService userInfoService; 28 | 29 | @ApiOperation(value = "修改用户资料") 30 | @PutMapping("/users/info") 31 | private Result updateUserInfo(@Valid @RequestBody UserInfoVO userInfoVO) { 32 | userInfoService.updateUserInfo(userInfoVO); 33 | return new Result(true, StatusConst.OK, "修改成功!"); 34 | } 35 | 36 | @ApiOperation(value = "修改用户头像") 37 | @ApiImplicitParam(name = "file", value = "用户头像", required = true, dataType = "MultipartFile") 38 | @PostMapping("/users/avatar") 39 | private Result updateUserInfo(MultipartFile file) { 40 | return new Result(true, StatusConst.OK, "修改成功!", userInfoService.updateUserAvatar(file)); 41 | } 42 | 43 | @ApiOperation(value = "修改用户权限") 44 | @PutMapping("/admin/users/role") 45 | private Result updateUserRole(@Valid @RequestBody UserRoleVO userRoleVO) { 46 | userInfoService.updateUserRole(userRoleVO); 47 | return new Result(true, StatusConst.OK, "修改成功!"); 48 | } 49 | 50 | @ApiOperation(value = "修改用户禁言状态") 51 | @PutMapping("/admin/users/comment/{userInfoId}") 52 | private Result updateUserSilence(@PathVariable("userInfoId") Integer userInfoId, Integer isSilence) { 53 | userInfoService.updateUserSilence(userInfoId, isSilence); 54 | return new Result(true, StatusConst.OK, "修改成功!"); 55 | } 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dao/ArticleDao.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dao; 2 | 3 | import com.minzheng.blog.dto.*; 4 | import com.minzheng.blog.entity.Article; 5 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 6 | import com.minzheng.blog.vo.ConditionVO; 7 | import org.apache.ibatis.annotations.Param; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * 14 | * @author xiaojie 15 | * @since 2020-05-18 16 | */ 17 | @Repository 18 | public interface ArticleDao extends BaseMapper
{ 19 | 20 | /** 21 | * 查询首页文章 22 | * 23 | * @param current 当前页码 24 | * @return 首页文章集合 25 | */ 26 | List listArticles(Long current); 27 | 28 | /** 29 | * 根据id查询文章 30 | * 31 | * @param articleId 文章id 32 | * @return 文章 33 | */ 34 | ArticleDTO getArticleById(Integer articleId); 35 | 36 | /** 37 | * 根据条件查询文章 38 | * 39 | * @param condition 条件 40 | * @return 文章集合 41 | */ 42 | List listArticlesByCondition(@Param("condition") ConditionVO condition); 43 | 44 | /** 45 | * 查询后台文章 46 | * 47 | * @param condition 条件 48 | * @return 后台文章集合 49 | */ 50 | List listArticleBacks(@Param("condition") ConditionVO condition); 51 | 52 | /** 53 | * 查询后台文章总量 54 | * 55 | * @param condition 条件 56 | * @return 文章总量 57 | */ 58 | Integer countArticleBacks(@Param("condition") ConditionVO condition); 59 | 60 | /** 61 | * 查询文章排行 62 | * 63 | * @param articleIdList 64 | * @return 65 | */ 66 | List
listArticleRank(@Param("articleIdList") List articleIdList); 67 | 68 | } 69 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dao/ArticleTagDao.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dao; 2 | 3 | import com.minzheng.blog.entity.ArticleTag; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * 9 | * @author xiaojie 10 | * @since 2020-05-18 11 | */ 12 | @Repository 13 | public interface ArticleTagDao extends BaseMapper { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dao/CategoryDao.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dao; 2 | 3 | import com.minzheng.blog.dto.CategoryDTO; 4 | import com.minzheng.blog.entity.Category; 5 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 12 | * @author xiaojie 13 | * @since 2020-05-18 14 | */ 15 | @Repository 16 | public interface CategoryDao extends BaseMapper { 17 | 18 | /** 19 | * 查询分类和对应文章数量 20 | * @return 分类集合 21 | */ 22 | List listCategoryDTO(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dao/CommentDao.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dao; 2 | 3 | import com.minzheng.blog.dto.CommentBackDTO; 4 | import com.minzheng.blog.dto.CommentDTO; 5 | import com.minzheng.blog.dto.ReplyCountDTO; 6 | import com.minzheng.blog.dto.ReplyDTO; 7 | import com.minzheng.blog.entity.Comment; 8 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 9 | import com.minzheng.blog.vo.ConditionVO; 10 | import org.apache.ibatis.annotations.Param; 11 | import org.springframework.stereotype.Repository; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * @author xiaojie 17 | * @since 2020-05-18 18 | */ 19 | @Repository 20 | public interface CommentDao extends BaseMapper { 21 | 22 | /** 23 | * 查看评论 24 | * 25 | * @param articleId 文章id 26 | * @param current 当前页码 27 | * @return 评论集合 28 | */ 29 | List listComments(Integer articleId, Long current); 30 | 31 | /** 32 | * 查看评论id集合下的回复 33 | * 34 | * @param commentIdList 评论id集合 35 | * @return 回复集合 36 | */ 37 | List listReplies(@Param("commentIdList") List commentIdList); 38 | 39 | /** 40 | * 查看当条评论下的回复 41 | * 42 | * @param commentId 评论id 43 | * @param current 当前页码 44 | * @return 回复集合 45 | */ 46 | List listRepliesByCommentId(Integer commentId, Long current); 47 | 48 | /** 49 | * 根据评论id查询回复总量 50 | * 51 | * @param commentIdList 评论id集合 52 | * @return 回复数量 53 | */ 54 | List listReplyCountByCommentId(@Param("commentIdList") List commentIdList); 55 | 56 | /** 57 | * 查询后台评论 58 | * 59 | * @param condition 条件 60 | * @return 评论集合 61 | */ 62 | List listCommentBackDTO(@Param("condition") ConditionVO condition); 63 | 64 | /** 65 | * 统计后台评论数量 66 | * 67 | * @param condition 条件 68 | * @return 评论数量 69 | */ 70 | Integer countCommentDTO(@Param("condition") ConditionVO condition); 71 | 72 | } 73 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dao/ElasticsearchDao.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dao; 2 | 3 | import com.minzheng.blog.dto.ArticleSearchDTO; 4 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author 11921 9 | */ 10 | @Repository 11 | public interface ElasticsearchDao extends ElasticsearchRepository { 12 | } 13 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dao/FriendLinkDao.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dao; 2 | 3 | import com.minzheng.blog.entity.FriendLink; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * 9 | * @author xiaojie 10 | * @since 2020-05-18 11 | */ 12 | @Repository 13 | public interface FriendLinkDao extends BaseMapper { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dao/MessageDao.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dao; 2 | 3 | import com.minzheng.blog.entity.Message; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * 9 | * @author xiaojie 10 | * @since 2020-05-18 11 | */ 12 | @Repository 13 | public interface MessageDao extends BaseMapper { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dao/TagDao.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dao; 2 | 3 | import com.minzheng.blog.entity.Tag; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author xiaojie 13 | * @since 2020-05-18 14 | */ 15 | @Repository 16 | public interface TagDao extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dao/UniqueViewDao.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dao; 2 | 3 | import com.minzheng.blog.entity.UniqueView; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author xiaojie 11 | * @since 2020-05-18 12 | */ 13 | @Repository 14 | public interface UniqueViewDao extends BaseMapper { 15 | 16 | /** 17 | * 获取一周用户量 18 | * @return 用户量集合 19 | */ 20 | List listUniqueViews(); 21 | } 22 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dao/UserAuthDao.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dao; 2 | 3 | import com.minzheng.blog.dto.UserBackDTO; 4 | import com.minzheng.blog.entity.UserAuth; 5 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 6 | import com.minzheng.blog.vo.ConditionVO; 7 | import org.apache.ibatis.annotations.Param; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * 14 | * @author xiaojie 15 | * @since 2020-05-18 16 | */ 17 | @Repository 18 | public interface UserAuthDao extends BaseMapper { 19 | 20 | /** 21 | * 查询后台用户列表 22 | * @param condition 条件 23 | * @return 用户集合 24 | */ 25 | List listUsers(@Param("condition") ConditionVO condition); 26 | 27 | /** 28 | * 查询后台用户数量 29 | * @param condition 条件 30 | * @return 用户数量 31 | */ 32 | Integer countUser(@Param("condition") ConditionVO condition); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dao/UserInfoDao.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dao; 2 | 3 | import com.minzheng.blog.entity.UserInfo; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author xiaojie 13 | * @since 2020-05-18 14 | */ 15 | @Repository 16 | public interface UserInfoDao extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/ArchiveDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 归档文章 9 | * @author 11921 10 | */ 11 | @Data 12 | public class ArchiveDTO { 13 | /** 14 | * id 15 | */ 16 | private Integer id; 17 | 18 | /** 19 | * 标题 20 | */ 21 | private String articleTitle; 22 | 23 | /** 24 | * 发表时间 25 | */ 26 | private Date createTime; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/ArticleBackDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | /** 9 | * 后台文章 10 | * 11 | * @author 11921 12 | */ 13 | @Data 14 | public class ArticleBackDTO { 15 | 16 | /** 17 | * id 18 | */ 19 | private Integer id; 20 | 21 | /** 22 | * 标题 23 | */ 24 | private String articleTitle; 25 | 26 | /** 27 | * 发表时间 28 | */ 29 | private Date createTime; 30 | 31 | /** 32 | * 更新时间 33 | */ 34 | private Date updateTime; 35 | 36 | /** 37 | * 点赞量 38 | */ 39 | private Integer likeCount; 40 | 41 | /** 42 | * 浏览量 43 | */ 44 | private Integer viewsCount; 45 | 46 | /** 47 | * 文章分类名 48 | */ 49 | private String categoryName; 50 | 51 | /** 52 | * 文章标签 53 | */ 54 | private List tagDTOList; 55 | 56 | /** 57 | * 是否置顶 58 | */ 59 | private Integer isTop; 60 | 61 | /** 62 | * 是否为草稿 63 | */ 64 | private Integer isDraft; 65 | 66 | /** 67 | * 是否删除 68 | */ 69 | private Integer isDelete; 70 | 71 | } 72 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/ArticleDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | /** 9 | * 文章 10 | * @author 11921 11 | */ 12 | @Data 13 | public class ArticleDTO { 14 | 15 | /** 16 | * id 17 | */ 18 | private Integer id; 19 | 20 | /** 21 | * 文章缩略图 22 | */ 23 | private String articleCover; 24 | 25 | /** 26 | * 标题 27 | */ 28 | private String articleTitle; 29 | 30 | /** 31 | * 内容 32 | */ 33 | private String articleContent; 34 | 35 | /** 36 | * 点赞量 37 | */ 38 | private Integer likeCount; 39 | 40 | /** 41 | * 浏览量 42 | */ 43 | private Integer viewsCount; 44 | 45 | /** 46 | * 发表时间 47 | */ 48 | private Date createTime; 49 | 50 | /** 51 | * 更新时间 52 | */ 53 | private Date updateTime; 54 | 55 | /** 56 | * 文章分类id 57 | */ 58 | private Integer categoryId; 59 | 60 | /** 61 | * 文章分类名 62 | */ 63 | private String categoryName; 64 | 65 | /** 66 | * 文章标签 67 | */ 68 | private List tagDTOList; 69 | 70 | } 71 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/ArticleHomeDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | /** 9 | * 首页文章列表 10 | * @author 11921 11 | */ 12 | @Data 13 | public class ArticleHomeDTO { 14 | 15 | /** 16 | * id 17 | */ 18 | private Integer id; 19 | 20 | /** 21 | * 文章缩略图 22 | */ 23 | private String articleCover; 24 | 25 | /** 26 | * 标题 27 | */ 28 | private String articleTitle; 29 | 30 | /** 31 | * 内容 32 | */ 33 | private String articleContent; 34 | 35 | /** 36 | * 发表时间 37 | */ 38 | private Date createTime; 39 | 40 | /** 41 | * 是否置顶 42 | */ 43 | private Boolean isTop; 44 | 45 | /** 46 | * 文章分类id 47 | */ 48 | private Integer categoryId; 49 | 50 | /** 51 | * 文章分类名 52 | */ 53 | private String categoryName; 54 | 55 | /** 56 | * 文章标签 57 | */ 58 | private List tagDTOList; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/ArticleOptionDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 文章选项 9 | * 10 | * @author 11921 11 | */ 12 | @Data 13 | public class ArticleOptionDTO { 14 | /** 15 | * 文章标签列表 16 | */ 17 | private List tagDTOList; 18 | 19 | /** 20 | * 文章分类列表 21 | */ 22 | private List categoryDTOList; 23 | 24 | public ArticleOptionDTO(List categoryDTOList, List tagDTOList) { 25 | this.categoryDTOList = categoryDTOList; 26 | this.tagDTOList = tagDTOList; 27 | } 28 | 29 | public ArticleOptionDTO() { 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/ArticlePreviewDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | /** 9 | * 分类或标签下的文章 10 | * @author 11921 11 | */ 12 | @Data 13 | public class ArticlePreviewDTO { 14 | 15 | /** 16 | * 文章id 17 | */ 18 | private Integer id; 19 | 20 | /** 21 | * 文章缩略图 22 | */ 23 | private String articleCover; 24 | 25 | /** 26 | * 标题 27 | */ 28 | private String articleTitle; 29 | 30 | /** 31 | * 发表时间 32 | */ 33 | private Date createTime; 34 | 35 | /** 36 | * 文章分类id 37 | */ 38 | private Integer categoryId; 39 | 40 | /** 41 | * 文章分类名 42 | */ 43 | private String categoryName; 44 | 45 | /** 46 | * 文章标签 47 | */ 48 | private List tagDTOList; 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/ArticlePreviewListDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 分类或标签下的文章列表 9 | * @author 11921 10 | */ 11 | @Data 12 | public class ArticlePreviewListDTO { 13 | /** 14 | * 条件对应的文章列表 15 | */ 16 | private List articlePreviewDTOList; 17 | 18 | /** 19 | * 条件名 20 | */ 21 | private String name; 22 | 23 | public ArticlePreviewListDTO(List articlePreviewDTOList, String name) { 24 | this.articlePreviewDTOList = articlePreviewDTOList; 25 | this.name = name; 26 | } 27 | 28 | public ArticlePreviewListDTO() { 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/ArticleRankDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 文章排行 7 | * 8 | * @author 11921 9 | */ 10 | @Data 11 | public class ArticleRankDTO { 12 | 13 | /** 14 | * 标题 15 | */ 16 | private String articleTitle; 17 | 18 | /** 19 | * 浏览量 20 | */ 21 | private Integer viewsCount; 22 | 23 | 24 | public ArticleRankDTO(String articleTitle, Integer viewsCount) { 25 | this.articleTitle = articleTitle; 26 | this.viewsCount = viewsCount; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/ArticleSearchDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import com.minzheng.blog.entity.Article; 4 | import lombok.Data; 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.elasticsearch.annotations.Document; 7 | import org.springframework.data.elasticsearch.annotations.Field; 8 | import org.springframework.data.elasticsearch.annotations.FieldType; 9 | 10 | /** 11 | * 文章搜索结果 12 | * @author 11921 13 | */ 14 | @Data 15 | @Document(indexName = "article", type = "_doc") 16 | public class ArticleSearchDTO { 17 | 18 | /** 19 | * 文章id 20 | */ 21 | @Id 22 | private Integer id; 23 | 24 | /** 25 | * 文章标题 26 | */ 27 | @Field(type = FieldType.Text, analyzer = "ik_max_word") 28 | private String articleTitle; 29 | 30 | /** 31 | * 文章内容 32 | */ 33 | @Field(type = FieldType.Text, analyzer = "ik_max_word") 34 | private String articleContent; 35 | 36 | /** 37 | * 文章状态 38 | */ 39 | @Field(type = FieldType.Integer) 40 | private Integer isDelete; 41 | 42 | public ArticleSearchDTO(Article article) { 43 | this.id = article.getId(); 44 | this.articleTitle = article.getArticleTitle(); 45 | this.articleContent = article.getArticleContent(); 46 | this.isDelete = article.getIsDelete(); 47 | } 48 | 49 | public ArticleSearchDTO() { 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/BlogBackInfoDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 博客后台信息 9 | * 10 | * @author 11921 11 | */ 12 | @Data 13 | public class BlogBackInfoDTO { 14 | /** 15 | * 访问量 16 | */ 17 | private Integer viewsCount; 18 | 19 | /** 20 | * 留言量 21 | */ 22 | private Integer messageCount; 23 | 24 | /** 25 | * 用户量 26 | */ 27 | private Integer userCount; 28 | 29 | /** 30 | * 文章量 31 | */ 32 | private Integer articleCount; 33 | 34 | /** 35 | * 分类统计 36 | */ 37 | private List categoryDTOList; 38 | 39 | /** 40 | * 一周用户量集合 41 | */ 42 | private List uniqueViewDTOList; 43 | 44 | /** 45 | * 文章浏览量排行 46 | */ 47 | private ListarticleRankDTOList; 48 | 49 | public BlogBackInfoDTO(Integer viewsCount, Integer messageCount, Integer userCount, Integer articleCount, List categoryDTOList, List uniqueViewDTOList, List articleRankDTOList) { 50 | this.viewsCount = viewsCount; 51 | this.messageCount = messageCount; 52 | this.userCount = userCount; 53 | this.articleCount = articleCount; 54 | this.categoryDTOList = categoryDTOList; 55 | this.uniqueViewDTOList = uniqueViewDTOList; 56 | this.articleRankDTOList = articleRankDTOList; 57 | } 58 | 59 | public BlogBackInfoDTO(Integer viewsCount, Integer messageCount, Integer userCount, Integer articleCount, List categoryDTOList, List uniqueViewDTOList) { 60 | this.viewsCount = viewsCount; 61 | this.messageCount = messageCount; 62 | this.userCount = userCount; 63 | this.articleCount = articleCount; 64 | this.categoryDTOList = categoryDTOList; 65 | this.uniqueViewDTOList = uniqueViewDTOList; 66 | } 67 | 68 | public BlogBackInfoDTO() { 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/BlogHomeInfoDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 博客首页信息 7 | * 8 | * @author 11921 9 | */ 10 | @Data 11 | public class BlogHomeInfoDTO { 12 | /** 13 | * 博主昵称 14 | */ 15 | private String nickname; 16 | 17 | /** 18 | * 博主头像 19 | */ 20 | private String avatar; 21 | 22 | /** 23 | * 博主简介 24 | */ 25 | private String intro; 26 | 27 | /** 28 | * 文章数量 29 | */ 30 | private Integer articleCount; 31 | 32 | /** 33 | * 分类数量 34 | */ 35 | private Integer categoryCount; 36 | 37 | /** 38 | * 标签数量 39 | */ 40 | private Integer tagCount; 41 | 42 | /** 43 | * 公告 44 | */ 45 | private String notice; 46 | 47 | /** 48 | * 访问量 49 | */ 50 | private String viewsCount; 51 | 52 | public BlogHomeInfoDTO(String nickname, String avatar, String intro, Integer articleCount, Integer categoryCount, Integer tagCount, String notice, String viewsCount) { 53 | this.nickname = nickname; 54 | this.avatar = avatar; 55 | this.intro = intro; 56 | this.articleCount = articleCount; 57 | this.categoryCount = categoryCount; 58 | this.tagCount = tagCount; 59 | this.notice = notice; 60 | this.viewsCount = viewsCount; 61 | } 62 | 63 | public BlogHomeInfoDTO() { 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/CategoryBackDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 后台分类列表 7 | * @author 11921 8 | */ 9 | @Data 10 | public class CategoryBackDTO { 11 | /** 12 | * id 13 | */ 14 | private Integer id; 15 | 16 | /** 17 | * 分类名 18 | */ 19 | private String categoryName; 20 | } 21 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/CategoryDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 分类列表 7 | * @author 11921 8 | */ 9 | @Data 10 | public class CategoryDTO { 11 | 12 | /** 13 | * id 14 | */ 15 | private Integer id; 16 | 17 | /** 18 | * 分类名 19 | */ 20 | private String categoryName; 21 | 22 | /** 23 | * 分类下的文章数量 24 | */ 25 | private Long articleCount; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/CommentBackDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * 后台评论列表 10 | * @author 11921 11 | */ 12 | @Data 13 | public class CommentBackDTO { 14 | /** 15 | * id 16 | */ 17 | private Integer id; 18 | 19 | /** 20 | * 用户头像 21 | */ 22 | private String avatar; 23 | 24 | /** 25 | * 用户昵称 26 | */ 27 | private String nickname; 28 | 29 | /** 30 | * 被回复用户昵称 31 | */ 32 | private String replyNickname; 33 | 34 | /** 35 | * 文章标题 36 | */ 37 | private String articleTitle; 38 | 39 | /** 40 | * 评论内容 41 | */ 42 | private String commentContent; 43 | 44 | /** 45 | * 点赞量 46 | */ 47 | private Integer likeCount; 48 | 49 | /** 50 | * 发表时间 51 | */ 52 | private Date createTime; 53 | 54 | /** 55 | * 状态 56 | */ 57 | private Integer isDelete; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/CommentDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | /** 9 | * 评论列表 10 | * @author 11921 11 | */ 12 | @Data 13 | public class CommentDTO { 14 | /** 15 | * 评论id 16 | */ 17 | private Integer id; 18 | 19 | /** 20 | * 用户id 21 | */ 22 | private Integer userId; 23 | 24 | /** 25 | * 用户昵称 26 | */ 27 | private String nickname; 28 | 29 | /** 30 | * 用户头像 31 | */ 32 | private String avatar; 33 | 34 | /** 35 | * 个人网站 36 | */ 37 | private String webSite; 38 | 39 | /** 40 | * 评论内容 41 | */ 42 | private String commentContent; 43 | 44 | /** 45 | * 点赞数 46 | */ 47 | private Integer likeCount; 48 | 49 | /** 50 | * 评论时间 51 | */ 52 | private Date createTime; 53 | 54 | /** 55 | * 回复量 56 | */ 57 | private Integer replyCount; 58 | 59 | /** 60 | * 回复列表 61 | */ 62 | private List replyDTOList; 63 | 64 | } 65 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/FriendLinkBackDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 后台友链列表 9 | * @author 11921 10 | */ 11 | @Data 12 | public class FriendLinkBackDTO { 13 | /** 14 | * id 15 | */ 16 | private Integer id; 17 | 18 | /** 19 | * 链接名 20 | */ 21 | private String linkName; 22 | 23 | /** 24 | * 链接头像 25 | */ 26 | private String linkAvatar; 27 | 28 | /** 29 | * 链接地址 30 | */ 31 | private String linkAddress; 32 | 33 | /** 34 | * 链接介绍 35 | */ 36 | private String linkIntro; 37 | 38 | /** 39 | * 创建时间 40 | */ 41 | private Date createTime; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/FriendLinkDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 友链列表 7 | * @author 11921 8 | */ 9 | @Data 10 | public class FriendLinkDTO { 11 | /** 12 | * id 13 | */ 14 | private Integer id; 15 | 16 | /** 17 | * 链接名 18 | */ 19 | private String linkName; 20 | 21 | /** 22 | * 链接头像 23 | */ 24 | private String linkAvatar; 25 | 26 | /** 27 | * 链接地址 28 | */ 29 | private String linkAddress; 30 | 31 | /** 32 | * 介绍 33 | */ 34 | private String linkIntro; 35 | } 36 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/MessageBackDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 后台留言列表 9 | * @author 11921 10 | */ 11 | @Data 12 | public class MessageBackDTO { 13 | 14 | /** 15 | * 主键id 16 | */ 17 | private Integer id; 18 | 19 | /** 20 | * 用户ip 21 | */ 22 | private String ipAddress; 23 | 24 | /** 25 | * 用户ip地址 26 | */ 27 | private String ipSource; 28 | 29 | /** 30 | * 昵称 31 | */ 32 | private String nickname; 33 | 34 | /** 35 | * 头像 36 | */ 37 | private String avatar; 38 | 39 | /** 40 | * 留言内容 41 | */ 42 | private String messageContent; 43 | 44 | /** 45 | * 留言时间 46 | */ 47 | private Date createTime; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/MessageDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 留言列表 7 | * @author 11921 8 | */ 9 | @Data 10 | public class MessageDTO { 11 | 12 | /** 13 | * 主键id 14 | */ 15 | private Integer id; 16 | 17 | /** 18 | * 昵称 19 | */ 20 | private String nickname; 21 | 22 | /** 23 | * 头像 24 | */ 25 | private String avatar; 26 | 27 | /** 28 | * 留言内容 29 | */ 30 | private String messageContent; 31 | 32 | /** 33 | * 弹幕速度 34 | */ 35 | private Integer time; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/PageDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 分页列表 9 | * @author 11921 10 | */ 11 | @Data 12 | public class PageDTO { 13 | 14 | /** 15 | * 分页列表 16 | */ 17 | private List recordList; 18 | 19 | /** 20 | * 总数 21 | */ 22 | private Integer count; 23 | 24 | public PageDTO(List recordList, Integer count) { 25 | this.recordList = recordList; 26 | this.count = count; 27 | } 28 | 29 | public PageDTO() { 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/ReplyCountDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 回复数量 7 | * @author 11921 8 | */ 9 | @Data 10 | public class ReplyCountDTO { 11 | 12 | /** 13 | * 评论id 14 | */ 15 | private Integer commentId; 16 | 17 | /** 18 | * 回复数量 19 | */ 20 | private Integer replyCount; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/ReplyDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 回复列表 9 | * @author 11921 10 | */ 11 | @Data 12 | public class ReplyDTO { 13 | 14 | /** 15 | * 评论id 16 | */ 17 | private Integer id; 18 | 19 | /** 20 | * 父评论id 21 | */ 22 | private Integer parentId; 23 | 24 | /** 25 | * 用户id 26 | */ 27 | private Integer userId; 28 | 29 | /** 30 | * 用户昵称 31 | */ 32 | private String nickname; 33 | 34 | /** 35 | * 用户头像 36 | */ 37 | private String avatar; 38 | 39 | /** 40 | * 个人网站 41 | */ 42 | private String webSite; 43 | 44 | /** 45 | * 被回复用户id 46 | */ 47 | private Integer replyId; 48 | 49 | /** 50 | * 被回复用户昵称 51 | */ 52 | private String replyNickname; 53 | 54 | /** 55 | * 被回复个人网站 56 | */ 57 | private String replyWebSite; 58 | 59 | /** 60 | * 评论内容 61 | */ 62 | private String commentContent; 63 | 64 | /** 65 | * 点赞数 66 | */ 67 | private Integer likeCount; 68 | 69 | /** 70 | * 评论时间 71 | */ 72 | private Date createTime; 73 | 74 | } 75 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/TagDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | 4 | import lombok.Data; 5 | 6 | 7 | /** 8 | * 标签 9 | * @author 11921 10 | */ 11 | @Data 12 | public class TagDTO { 13 | 14 | /** 15 | * id 16 | */ 17 | private Integer id; 18 | 19 | /** 20 | * 标签名 21 | */ 22 | private String tagName; 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/UserBackDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 后台用户列表 9 | * 10 | * @author 11921 11 | */ 12 | @Data 13 | public class UserBackDTO { 14 | 15 | /** 16 | * id 17 | */ 18 | private Integer id; 19 | 20 | /** 21 | * 用户信息id 22 | */ 23 | private Integer userInfoId; 24 | 25 | /** 26 | * 头像 27 | */ 28 | private String avatar; 29 | 30 | /** 31 | * 昵称 32 | */ 33 | private String nickname; 34 | 35 | /** 36 | * 用户角色 37 | */ 38 | private String userRole; 39 | 40 | /** 41 | * 登录类型 42 | */ 43 | private Integer loginType; 44 | 45 | /** 46 | * 用户登录ip 47 | */ 48 | private String ipAddr; 49 | 50 | /** 51 | * ip来源 52 | */ 53 | private String ipSource; 54 | 55 | /** 56 | * 创建时间 57 | */ 58 | private Date createTime; 59 | 60 | /** 61 | * 最近登录时间 62 | */ 63 | private Date lastLoginTime; 64 | 65 | /** 66 | * 用户评论状态 67 | */ 68 | private Integer isSilence; 69 | 70 | /** 71 | * 状态 72 | */ 73 | private Integer status; 74 | 75 | } 76 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/dto/UserInfoDTO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.dto; 2 | 3 | import com.minzheng.blog.entity.UserInfo; 4 | import lombok.Data; 5 | 6 | import java.util.Set; 7 | 8 | /** 9 | * 用户登录信息 10 | * 11 | * @author 11921 12 | */ 13 | @Data 14 | public class UserInfoDTO { 15 | 16 | /** 17 | * 用户账号id 18 | */ 19 | private Integer id; 20 | 21 | /** 22 | * 用户信息id 23 | */ 24 | private Integer userInfoId; 25 | 26 | /** 27 | * 用户角色 28 | */ 29 | private String userRole; 30 | 31 | /** 32 | * 用户昵称 33 | */ 34 | private String nickname; 35 | 36 | /** 37 | * 用户头像 38 | */ 39 | private String avatar; 40 | 41 | /** 42 | * 用户简介 43 | */ 44 | private String intro; 45 | 46 | /** 47 | * 个人网站 48 | */ 49 | private String webSite; 50 | 51 | /** 52 | * 用户禁言状态 53 | */ 54 | private Integer isSilence; 55 | 56 | /** 57 | * 点赞文章集合 58 | */ 59 | private Set articleLikeSet; 60 | 61 | /** 62 | * 点赞评论集合 63 | */ 64 | private Set commentLikeSet; 65 | 66 | public UserInfoDTO() { 67 | } 68 | 69 | public UserInfoDTO(Integer id, UserInfo userInfo, Set articleLikeSet, Set commentLikeSet) { 70 | this.id = id; 71 | this.userInfoId = userInfo.getId(); 72 | this.userRole = userInfo.getUserRole(); 73 | this.nickname = userInfo.getNickname(); 74 | this.avatar = userInfo.getAvatar(); 75 | this.isSilence = userInfo.getIsSilence(); 76 | this.intro = userInfo.getIntro(); 77 | this.webSite = userInfo.getWebSite(); 78 | this.articleLikeSet = articleLikeSet; 79 | this.commentLikeSet = commentLikeSet; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/entity/Article.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | 6 | import java.util.Date; 7 | 8 | import com.baomidou.mybatisplus.annotation.TableName; 9 | import com.minzheng.blog.utils.UserUtil; 10 | import com.minzheng.blog.vo.ArticleVO; 11 | import lombok.Data; 12 | 13 | /** 14 | * 文章 15 | * 16 | * @author xiaojie 17 | * @since 2020-05-18 18 | */ 19 | @Data 20 | @TableName("tb_article") 21 | public class Article { 22 | /** 23 | * id 24 | */ 25 | @TableId(value = "id", type = IdType.AUTO) 26 | private Integer id; 27 | 28 | /** 29 | * 作者 30 | */ 31 | private Integer userId; 32 | 33 | /** 34 | * 文章分类 35 | */ 36 | private Integer categoryId; 37 | 38 | /** 39 | * 文章缩略图 40 | */ 41 | private String articleCover; 42 | 43 | /** 44 | * 标题 45 | */ 46 | private String articleTitle; 47 | 48 | /** 49 | * 内容 50 | */ 51 | private String articleContent; 52 | 53 | /** 54 | * 发表时间 55 | */ 56 | private Date createTime; 57 | 58 | /** 59 | * 更新时间 60 | */ 61 | private Date updateTime; 62 | 63 | /** 64 | * 是否置顶 65 | */ 66 | private Integer isTop; 67 | 68 | /** 69 | * 是否为草稿 70 | */ 71 | private Integer isDraft; 72 | 73 | /** 74 | * 状态码 75 | */ 76 | private Integer isDelete; 77 | 78 | public Article(ArticleVO articleVO) { 79 | this.id = articleVO.getId(); 80 | this.userId = UserUtil.getLoginUser().getUserInfoId(); 81 | this.categoryId = articleVO.getCategoryId(); 82 | this.articleCover = articleVO.getArticleCover(); 83 | this.articleTitle = articleVO.getArticleTitle(); 84 | this.articleContent = articleVO.getArticleContent(); 85 | this.createTime = this.id == null ? new Date() : null; 86 | this.updateTime = this.id != null ? new Date() : null; 87 | this.isTop = articleVO.getIsTop(); 88 | this.isDraft = articleVO.getIsDraft(); 89 | } 90 | 91 | public Article(Integer id) { 92 | this.id = id; 93 | this.isTop = 0; 94 | } 95 | 96 | public Article(Integer id, Integer isTop) { 97 | this.id = id; 98 | this.isTop = isTop; 99 | } 100 | 101 | public Article() { 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/entity/ArticleLike.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | 6 | import java.io.Serializable; 7 | 8 | import com.baomidou.mybatisplus.annotation.TableName; 9 | import lombok.Data; 10 | import lombok.EqualsAndHashCode; 11 | import lombok.experimental.Accessors; 12 | 13 | /** 14 | * 文章点赞记录 15 | * 16 | * @author xiaojie 17 | * @since 2020-05-18 18 | */ 19 | @Data 20 | @TableName("tb_article_like") 21 | public class ArticleLike { 22 | 23 | /** 24 | * id 25 | */ 26 | @TableId(value = "id", type = IdType.AUTO) 27 | private Integer id; 28 | 29 | /** 30 | * 点赞用户 31 | */ 32 | private Integer userId; 33 | 34 | /** 35 | * 点赞文章 36 | */ 37 | private Integer articleId; 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/entity/ArticleTag.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | 6 | import java.io.Serializable; 7 | 8 | import com.baomidou.mybatisplus.annotation.TableName; 9 | import lombok.Data; 10 | import lombok.EqualsAndHashCode; 11 | import lombok.experimental.Accessors; 12 | 13 | /** 14 | * 标签 15 | * @author xiaojie 16 | * @since 2020-05-18 17 | */ 18 | @Data 19 | @TableName("tb_article_tag") 20 | public class ArticleTag { 21 | 22 | /** 23 | * id 24 | */ 25 | @TableId(value = "id", type = IdType.AUTO) 26 | private Integer id; 27 | 28 | /** 29 | * 文章id 30 | */ 31 | private Integer articleId; 32 | 33 | /** 34 | * 标签id 35 | */ 36 | private Integer tagId; 37 | 38 | public ArticleTag(Integer articleId, Integer tagId) { 39 | this.articleId = articleId; 40 | this.tagId = tagId; 41 | } 42 | 43 | public ArticleTag() { 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/entity/Category.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | 6 | import java.time.LocalDateTime; 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | import com.baomidou.mybatisplus.annotation.TableName; 11 | import com.minzheng.blog.vo.CategoryVO; 12 | import lombok.Data; 13 | import lombok.EqualsAndHashCode; 14 | import lombok.experimental.Accessors; 15 | 16 | /** 17 | * 分类 18 | * 19 | * @author xiaojie 20 | * @since 2020-05-18 21 | */ 22 | @Data 23 | @TableName("tb_category") 24 | public class Category { 25 | 26 | /** 27 | * id 28 | */ 29 | @TableId(value = "id", type = IdType.AUTO) 30 | private Integer id; 31 | 32 | /** 33 | * 分类名 34 | */ 35 | private String categoryName; 36 | 37 | /** 38 | * 创建时间 39 | */ 40 | private Date createTime; 41 | 42 | public Category(CategoryVO categoryVO) { 43 | this.id = categoryVO.getId(); 44 | this.categoryName = categoryVO.getCategoryName(); 45 | this.createTime = this.id == null ? new Date() : null; 46 | } 47 | 48 | public Category() { 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/entity/Comment.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | 6 | import java.util.Date; 7 | 8 | import com.baomidou.mybatisplus.annotation.TableName; 9 | import com.minzheng.blog.utils.UserUtil; 10 | import com.minzheng.blog.vo.CommentVO; 11 | import lombok.Data; 12 | 13 | /** 14 | * 评论 15 | * 16 | * @author xiaojie 17 | * @since 2020-05-18 18 | */ 19 | @Data 20 | @TableName("tb_comment") 21 | public class Comment { 22 | 23 | /** 24 | * id 25 | */ 26 | @TableId(value = "id", type = IdType.AUTO) 27 | private Integer id; 28 | 29 | /** 30 | * 评论用户Id 31 | */ 32 | private Integer userId; 33 | 34 | /** 35 | * 回复用户id 36 | */ 37 | private Integer replyId; 38 | 39 | /** 40 | * 评论文章id 41 | */ 42 | private Integer articleId; 43 | 44 | /** 45 | * 评论内容 46 | */ 47 | private String commentContent; 48 | 49 | /** 50 | * 评论时间 51 | */ 52 | private Date createTime; 53 | 54 | /** 55 | * 父评论id 56 | */ 57 | private Integer parentId; 58 | 59 | /** 60 | * 状态码 61 | */ 62 | private Integer isDelete; 63 | 64 | public Comment(CommentVO commentVO) { 65 | this.userId = UserUtil.getLoginUser().getUserInfoId(); 66 | this.replyId = commentVO.getReplyId(); 67 | this.articleId = commentVO.getArticleId(); 68 | this.commentContent = commentVO.getCommentContent(); 69 | this.parentId = commentVO.getParentId(); 70 | this.createTime = new Date(); 71 | } 72 | 73 | public Comment(Integer commentId, Integer isDelete) { 74 | this.id = commentId; 75 | this.isDelete = isDelete; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/entity/CommentLike.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | 6 | import java.io.Serializable; 7 | 8 | import com.baomidou.mybatisplus.annotation.TableName; 9 | import lombok.Data; 10 | import lombok.EqualsAndHashCode; 11 | import lombok.experimental.Accessors; 12 | 13 | /** 14 | * 评论点赞 15 | * @author xiaojie 16 | * @since 2020-05-18 17 | */ 18 | @Data 19 | @TableName("tb_comment_like") 20 | public class CommentLike { 21 | 22 | /** 23 | * id 24 | */ 25 | @TableId(value = "id", type = IdType.AUTO) 26 | private Integer id; 27 | 28 | /** 29 | * 点赞用户 30 | */ 31 | private Integer userId; 32 | 33 | /** 34 | * 点赞评论 35 | */ 36 | private Integer commentId; 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/entity/FriendLink.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | 6 | import java.util.Date; 7 | 8 | import com.baomidou.mybatisplus.annotation.TableName; 9 | import com.minzheng.blog.vo.FriendLinkVO; 10 | import lombok.Data; 11 | 12 | /** 13 | * 友链列表 14 | * 15 | * @author xiaojie 16 | * @since 2020-05-18 17 | */ 18 | @Data 19 | @TableName("tb_friend_link") 20 | public class FriendLink { 21 | 22 | /** 23 | * id 24 | */ 25 | @TableId(value = "id", type = IdType.AUTO) 26 | private Integer id; 27 | 28 | /** 29 | * 链接名 30 | */ 31 | private String linkName; 32 | 33 | /** 34 | * 链接头像 35 | */ 36 | private String linkAvatar; 37 | 38 | /** 39 | * 链接地址 40 | */ 41 | private String linkAddress; 42 | 43 | /** 44 | * 介绍 45 | */ 46 | private String linkIntro; 47 | 48 | /** 49 | * 创建时间 50 | */ 51 | private Date createTime; 52 | 53 | 54 | public FriendLink(FriendLinkVO friendLinkVO) { 55 | this.id = friendLinkVO.getId(); 56 | this.linkName = friendLinkVO.getLinkName(); 57 | this.linkAvatar = friendLinkVO.getLinkAvatar(); 58 | this.linkAddress = friendLinkVO.getLinkAddress(); 59 | this.linkIntro = friendLinkVO.getLinkIntro(); 60 | this.createTime = this.id == null ? new Date() : null; 61 | } 62 | 63 | public FriendLink(Integer friendLinkId, Integer isDelete) { 64 | this.id = friendLinkId; 65 | } 66 | 67 | public FriendLink() { 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/entity/Message.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.entity; 2 | 3 | import java.util.Date; 4 | 5 | import com.baomidou.mybatisplus.annotation.IdType; 6 | import com.baomidou.mybatisplus.annotation.TableId; 7 | import com.baomidou.mybatisplus.annotation.TableName; 8 | import com.minzheng.blog.vo.MessageVO; 9 | import lombok.Data; 10 | 11 | /** 12 | * 留言 13 | * 14 | * @author xiaojie 15 | * @since 2020-05-18 16 | */ 17 | @Data 18 | @TableName("tb_message") 19 | public class Message { 20 | 21 | /** 22 | * 主键id 23 | */ 24 | @TableId(value = "id", type = IdType.AUTO) 25 | private Integer id; 26 | 27 | /** 28 | * 用户ip 29 | */ 30 | private String ipAddress; 31 | 32 | /** 33 | * 用户地址 34 | */ 35 | private String ipSource; 36 | 37 | /** 38 | * 昵称 39 | */ 40 | private String nickname; 41 | 42 | /** 43 | * 头像 44 | */ 45 | private String avatar; 46 | 47 | /** 48 | * 留言内容 49 | */ 50 | private String messageContent; 51 | 52 | /** 53 | * 弹幕速度 54 | */ 55 | private Integer time; 56 | 57 | /** 58 | * 留言时间 59 | */ 60 | private Date createTime; 61 | 62 | 63 | public Message(MessageVO messageVO, String ipAddress, String ipSource) { 64 | this.ipAddress = ipAddress; 65 | this.ipSource = ipSource; 66 | this.nickname = messageVO.getNickname(); 67 | this.avatar = messageVO.getAvatar(); 68 | this.messageContent = messageVO.getMessageContent(); 69 | this.time = messageVO.getTime(); 70 | this.createTime = new Date(); 71 | } 72 | 73 | public Message() { 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/entity/Tag.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | 6 | import java.util.Date; 7 | 8 | import com.baomidou.mybatisplus.annotation.TableName; 9 | import com.minzheng.blog.vo.TagVO; 10 | import lombok.Data; 11 | 12 | /** 13 | * 标签 14 | * 15 | * @author xiaojie 16 | * @since 2020-05-18 17 | */ 18 | @Data 19 | @TableName("tb_tag") 20 | public class Tag { 21 | 22 | /** 23 | * id 24 | */ 25 | @TableId(value = "id", type = IdType.AUTO) 26 | private Integer id; 27 | 28 | /** 29 | * 标签名 30 | */ 31 | private String tagName; 32 | 33 | /** 34 | * 创建时间 35 | */ 36 | private Date createTime; 37 | 38 | public Tag(TagVO tagVO) { 39 | this.id = tagVO.getId(); 40 | this.tagName = tagVO.getTagName(); 41 | this.createTime = this.id == null ? new Date() : null; 42 | } 43 | 44 | public Tag() { 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/entity/UniqueView.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | 6 | import java.time.LocalDateTime; 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | import com.baomidou.mybatisplus.annotation.TableName; 11 | import lombok.Data; 12 | import lombok.EqualsAndHashCode; 13 | import lombok.experimental.Accessors; 14 | 15 | /** 16 | * 网站访问量 17 | * 18 | * @author xiaojie 19 | * @since 2020-05-18 20 | */ 21 | @Data 22 | @TableName("tb_unique_view") 23 | public class UniqueView { 24 | 25 | /** 26 | * id 27 | */ 28 | @TableId(value = "id", type = IdType.AUTO) 29 | private Integer id; 30 | 31 | /** 32 | * 时间 33 | */ 34 | private Date createTime; 35 | 36 | /** 37 | * 访问量 38 | */ 39 | private Integer viewsCount; 40 | 41 | public UniqueView(Date createTime, Integer viewsCount) { 42 | this.createTime = createTime; 43 | this.viewsCount = viewsCount; 44 | } 45 | 46 | public UniqueView() { 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/entity/UserAuth.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.entity; 2 | 3 | import java.util.Date; 4 | 5 | import com.baomidou.mybatisplus.annotation.IdType; 6 | import com.baomidou.mybatisplus.annotation.TableId; 7 | import com.baomidou.mybatisplus.annotation.TableName; 8 | import com.minzheng.blog.utils.UserUtil; 9 | import lombok.Data; 10 | import org.springframework.security.crypto.bcrypt.BCrypt; 11 | 12 | /** 13 | * 用户账号 14 | * 15 | * @author xiaojie 16 | * @since 2020-05-18 17 | */ 18 | @Data 19 | @TableName("tb_user_auth") 20 | public class UserAuth { 21 | 22 | /** 23 | * id 24 | */ 25 | @TableId(value = "id", type = IdType.AUTO) 26 | private Integer id; 27 | 28 | /** 29 | * 用户信息id 30 | */ 31 | private Integer userInfoId; 32 | 33 | /** 34 | * 用户名 35 | */ 36 | private String username; 37 | 38 | /** 39 | * 密码 40 | */ 41 | private String password; 42 | 43 | /** 44 | * 登录类型 45 | */ 46 | private Integer loginType; 47 | 48 | /** 49 | * 用户登录ip 50 | */ 51 | private String ipAddr; 52 | 53 | /** 54 | * ip来源 55 | */ 56 | private String ipSource; 57 | 58 | /** 59 | * 创建时间 60 | */ 61 | private Date createTime; 62 | 63 | /** 64 | * 最近登录时间 65 | */ 66 | private Date lastLoginTime; 67 | 68 | public UserAuth() { 69 | } 70 | 71 | public UserAuth(Integer userInfoId, String username, String password, Integer loginType) { 72 | this.userInfoId = userInfoId; 73 | this.username = username; 74 | this.password = password; 75 | this.loginType = loginType; 76 | this.createTime = new Date(); 77 | } 78 | 79 | public UserAuth(Integer userInfoId, String username, String password, Integer loginType, String ipAddr, String ipSource) { 80 | this.userInfoId = userInfoId; 81 | this.username = username; 82 | this.password = password; 83 | this.loginType = loginType; 84 | this.ipAddr = ipAddr; 85 | this.ipSource = ipSource; 86 | this.createTime = new Date(); 87 | this.lastLoginTime = new Date(); 88 | } 89 | 90 | public UserAuth(String ipAddr, String ipSource) { 91 | this.id = UserUtil.getLoginUser().getId(); 92 | this.ipAddr = ipAddr; 93 | this.ipSource = ipSource; 94 | this.lastLoginTime = new Date(); 95 | } 96 | 97 | public UserAuth(String password) { 98 | this.id = UserUtil.getLoginUser().getId(); 99 | this.password = BCrypt.hashpw(password, BCrypt.gensalt()); 100 | } 101 | 102 | 103 | } 104 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/entity/UserInfo.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | 6 | import java.util.Date; 7 | 8 | import com.baomidou.mybatisplus.annotation.TableName; 9 | import com.minzheng.blog.utils.UserUtil; 10 | import com.minzheng.blog.vo.UserInfoVO; 11 | import com.minzheng.blog.vo.UserRoleVO; 12 | import lombok.Data; 13 | 14 | /** 15 | * 用户信息 16 | * 17 | * @author xiaojie 18 | * @since 2020-05-18 19 | */ 20 | @Data 21 | @TableName("tb_user_info") 22 | public class UserInfo { 23 | 24 | /** 25 | * 用户ID 26 | */ 27 | @TableId(value = "id", type = IdType.AUTO) 28 | private Integer id; 29 | 30 | /** 31 | * 用户角色 32 | */ 33 | private String userRole; 34 | 35 | /** 36 | * 用户昵称 37 | */ 38 | private String nickname; 39 | 40 | /** 41 | * 用户头像 42 | */ 43 | private String avatar; 44 | 45 | /** 46 | * 用户简介 47 | */ 48 | private String intro; 49 | 50 | /** 51 | * 个人网站 52 | */ 53 | private String webSite; 54 | 55 | /** 56 | * 是否禁言 57 | */ 58 | private Integer isSilence; 59 | 60 | /** 61 | * 创建时间 62 | */ 63 | private Date createTime; 64 | 65 | 66 | public UserInfo() { 67 | this.nickname = "用户" + System.currentTimeMillis(); 68 | this.createTime = new Date(); 69 | } 70 | 71 | public UserInfo(String nickname, String avatar) { 72 | this.nickname = nickname; 73 | this.avatar = avatar; 74 | this.createTime = new Date(); 75 | } 76 | 77 | public UserInfo(UserInfoVO userInfoVO) { 78 | this.id = UserUtil.getLoginUser().getUserInfoId(); 79 | this.nickname = userInfoVO.getNickname(); 80 | this.intro = userInfoVO.getIntro(); 81 | this.webSite = userInfoVO.getWebSite(); 82 | } 83 | 84 | public UserInfo(String avatar) { 85 | this.id = UserUtil.getLoginUser().getUserInfoId(); 86 | this.avatar = avatar; 87 | } 88 | 89 | public UserInfo(UserRoleVO userRoleVO) { 90 | this.id = userRoleVO.getUserInfoId(); 91 | this.nickname = userRoleVO.getNickname(); 92 | this.userRole = userRoleVO.getUserRole(); 93 | } 94 | 95 | public UserInfo(Integer id, Integer isSilence) { 96 | this.id = id; 97 | this.isSilence = isSilence; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/exception/ServeException.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.exception; 2 | 3 | 4 | 5 | /** 6 | * 自定义异常类 7 | * @author 11921 8 | */ 9 | public class ServeException extends RuntimeException { 10 | public ServeException(String message) { 11 | super(message); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/handler/AccessDeniedHandlerImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.handler; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | 5 | import com.minzheng.blog.vo.Result; 6 | import com.minzheng.blog.constant.StatusConst; 7 | import org.springframework.security.access.AccessDeniedException; 8 | import org.springframework.security.web.access.AccessDeniedHandler; 9 | import org.springframework.stereotype.Component; 10 | 11 | import javax.servlet.ServletException; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | import java.io.IOException; 15 | 16 | /** 17 | * 用户权限处理 18 | * @author 11921 19 | */ 20 | @Component 21 | public class AccessDeniedHandlerImpl implements AccessDeniedHandler { 22 | @Override 23 | public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException { 24 | httpServletResponse.setContentType("application/json;charset=utf-8"); 25 | httpServletResponse.getWriter().write(JSON.toJSONString(new Result(false, StatusConst.ERROR,"没有操作权限"))); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/handler/AuthenticationEntryPointImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.handler; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.minzheng.blog.vo.Result; 5 | import com.minzheng.blog.constant.StatusConst; 6 | import org.springframework.security.core.AuthenticationException; 7 | import org.springframework.security.web.AuthenticationEntryPoint; 8 | import org.springframework.stereotype.Component; 9 | 10 | import javax.servlet.ServletException; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.io.IOException; 14 | 15 | /** 16 | * 用户未登录处理 17 | * 18 | * @author 11921 19 | */ 20 | @Component 21 | public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint { 22 | 23 | @Override 24 | public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException { 25 | httpServletResponse.setContentType("application/json;charset=utf-8"); 26 | httpServletResponse.getWriter().write(JSON.toJSONString(new Result(false, StatusConst.ERROR,"请登录"))); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/handler/AuthenticationFailHandlerImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.handler; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.minzheng.blog.vo.Result; 5 | import com.minzheng.blog.constant.StatusConst; 6 | import org.springframework.security.core.AuthenticationException; 7 | import org.springframework.security.web.authentication.AuthenticationFailureHandler; 8 | import org.springframework.stereotype.Component; 9 | 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import java.io.IOException; 13 | 14 | /** 15 | * 登录失败处理 16 | * @author 11921 17 | */ 18 | @Component 19 | public class AuthenticationFailHandlerImpl implements AuthenticationFailureHandler { 20 | @Override 21 | public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException { 22 | httpServletResponse.setContentType("application/json;charset=UTF-8"); 23 | httpServletResponse.getWriter().write(JSON.toJSONString(new Result(false, StatusConst.ERROR,e.getMessage()))); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/handler/AuthenticationSuccessHandlerImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.handler; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.minzheng.blog.dao.UserAuthDao; 5 | import com.minzheng.blog.dto.UserInfoDTO; 6 | import com.minzheng.blog.entity.UserAuth; 7 | import com.minzheng.blog.utils.IpUtil; 8 | import com.minzheng.blog.utils.UserUtil; 9 | import com.minzheng.blog.vo.Result; 10 | import com.minzheng.blog.constant.StatusConst; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.security.core.Authentication; 13 | import org.springframework.security.web.authentication.AuthenticationSuccessHandler; 14 | import org.springframework.stereotype.Component; 15 | 16 | import javax.servlet.ServletException; 17 | import javax.servlet.http.HttpServletRequest; 18 | import javax.servlet.http.HttpServletResponse; 19 | import java.io.IOException; 20 | 21 | 22 | /** 23 | * 登录成功处理 24 | * 25 | * @author 11921 26 | */ 27 | @Component 28 | public class AuthenticationSuccessHandlerImpl implements AuthenticationSuccessHandler { 29 | @Autowired 30 | private UserAuthDao userAuthDao; 31 | @Autowired 32 | private HttpServletRequest request; 33 | 34 | @Override 35 | public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException { 36 | httpServletResponse.setContentType("application/json;charset=UTF-8"); 37 | httpServletResponse.getWriter().write(JSON.toJSONString(new Result(true, StatusConst.OK, "登录成功!", UserUtil.getLoginUser()))); 38 | //更新用户登录ip地址,最新登录时间 39 | String ipAddr = IpUtil.getIpAddr(request); 40 | String ipSource = IpUtil.getIpSource(ipAddr); 41 | userAuthDao.updateById(new UserAuth(ipAddr, ipSource)); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/handler/LogoutSuccessHandlerImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.handler; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.minzheng.blog.vo.Result; 5 | import com.minzheng.blog.constant.StatusConst; 6 | import org.springframework.security.core.Authentication; 7 | import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; 8 | import org.springframework.stereotype.Component; 9 | 10 | import javax.servlet.ServletException; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.io.IOException; 14 | 15 | /** 16 | * 注销处理 17 | * @author 11921 18 | */ 19 | @Component 20 | public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler { 21 | @Override 22 | public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException { 23 | httpServletResponse.setContentType("application/json;charset=UTF-8"); 24 | httpServletResponse.getWriter().write(JSON.toJSONString(new Result(true, StatusConst.OK,"注销成功"))); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/handler/ServletRequestListenerImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.handler; 2 | 3 | 4 | import com.minzheng.blog.utils.IpUtil; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.data.redis.core.RedisTemplate; 7 | import org.springframework.scheduling.annotation.Scheduled; 8 | import org.springframework.stereotype.Component; 9 | 10 | import javax.servlet.ServletRequestEvent; 11 | import javax.servlet.ServletRequestListener; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpSession; 14 | 15 | 16 | /** 17 | * request监听 18 | * 19 | * @author 11921 20 | */ 21 | @Component 22 | public class ServletRequestListenerImpl implements ServletRequestListener { 23 | @Autowired 24 | private RedisTemplate redisTemplate; 25 | 26 | @Override 27 | public void requestInitialized(ServletRequestEvent sre) { 28 | HttpServletRequest request = (HttpServletRequest) sre.getServletRequest(); 29 | HttpSession session = request.getSession(); 30 | String ip = (String) session.getAttribute("ip"); 31 | //判断当前ip是否访问,增加访问量 32 | String ipAddr = IpUtil.getIpAddr(request); 33 | if (!ipAddr.equals(ip)) { 34 | session.setAttribute("ip", ipAddr); 35 | redisTemplate.boundValueOps("blog_views_count").increment(1); 36 | } 37 | //将ip存入redis,统计每日用户量 38 | redisTemplate.boundSetOps("ip_set").add(ipAddr); 39 | } 40 | 41 | @Scheduled(cron = " 0 1 0 * * ?") 42 | private void clear() { 43 | //清空redis中的ip 44 | redisTemplate.delete("ip_set"); 45 | } 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/ArticleService.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service; 2 | 3 | import com.minzheng.blog.dto.*; 4 | import com.minzheng.blog.entity.Article; 5 | import com.baomidou.mybatisplus.extension.service.IService; 6 | import com.minzheng.blog.vo.ArticleVO; 7 | import com.minzheng.blog.vo.ConditionVO; 8 | import com.minzheng.blog.vo.DeleteVO; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author xiaojie 14 | * @since 2020-05-18 15 | */ 16 | public interface ArticleService extends IService
{ 17 | 18 | /** 19 | * 查询文章归档 20 | * 21 | * @param current 当前页码 22 | * @return 文章 23 | */ 24 | PageDTO listArchives(Long current); 25 | 26 | /** 27 | * 查询后台文章 28 | * 29 | * @param condition 条件 30 | * @return 文章列表 31 | */ 32 | PageDTO listArticleBackDTO(ConditionVO condition); 33 | 34 | /** 35 | * 查询首页文章 36 | * 37 | * @param current 当前页码 38 | * @return 文章 39 | */ 40 | List listArticles(Long current); 41 | 42 | /** 43 | * 根据条件查询文章列表 44 | * 45 | * @param condition 条件 46 | * @return 文章 47 | */ 48 | ArticlePreviewListDTO listArticlesByCondition(ConditionVO condition); 49 | 50 | /** 51 | * 搜索文章 52 | * 53 | * @param condition 条件 54 | * @return 文章 55 | */ 56 | List listArticlesBySearch(ConditionVO condition); 57 | 58 | /** 59 | * 根据id查看后台文章 60 | * 61 | * @param articleId 文章id 62 | * @return 文章 63 | */ 64 | ArticleVO getArticleBackById(Integer articleId); 65 | 66 | /** 67 | * 根据id查看文章 68 | * 69 | * @param articleId 文章id 70 | * @return 文章 71 | */ 72 | ArticleDTO getArticleById(Integer articleId); 73 | 74 | /** 75 | * 查看文章分类标签选项 76 | * 77 | * @return 文章分类标签选项 78 | */ 79 | ArticleOptionDTO listArticleOptionDTO(); 80 | 81 | /** 82 | * 点赞文章 83 | * 84 | * @param articleId 文章id 85 | */ 86 | void saveArticleLike(Integer articleId); 87 | 88 | /** 89 | * 添加或修改文章 90 | * 91 | * @param articleVO 文章对象 92 | */ 93 | void saveOrUpdateArticle(ArticleVO articleVO); 94 | 95 | /** 96 | * 修改文章置顶 97 | * 98 | * @param isTop 置顶状态值 99 | * @param articleId 文章id 100 | */ 101 | void updateArticleTop(Integer articleId, Integer isTop); 102 | 103 | /** 104 | * 删除或恢复文章 105 | * 106 | * @param deleteVO 逻辑删除对象 107 | */ 108 | void updateArticleDelete(DeleteVO deleteVO); 109 | 110 | /** 111 | * 物理删除文章 112 | * @param articleIdList 文章id集合 113 | */ 114 | void deleteArticles(List articleIdList); 115 | 116 | } 117 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/ArticleTagService.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service; 2 | 3 | import com.minzheng.blog.entity.ArticleTag; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | * @author xiaojie 8 | * @since 2020-05-18 9 | */ 10 | public interface ArticleTagService extends IService { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/BlogInfoService.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service; 2 | 3 | import com.minzheng.blog.dto.BlogBackInfoDTO; 4 | import com.minzheng.blog.dto.BlogHomeInfoDTO; 5 | 6 | 7 | /** 8 | * 9 | * @author xiaojie 10 | * @since 2020-05-18 11 | */ 12 | public interface BlogInfoService { 13 | 14 | /** 15 | * 获取首页数据 16 | * @return 博客首页信息 17 | */ 18 | BlogHomeInfoDTO getBlogInfo(); 19 | 20 | /** 21 | * 获取后台首页数据 22 | * @return 博客后台信息 23 | */ 24 | BlogBackInfoDTO getBlogBackInfo(); 25 | 26 | /** 27 | * 获取关于我内容 28 | * @return 关于我内容 29 | */ 30 | String getAbout(); 31 | 32 | /** 33 | * 修改关于我内容 34 | * @param aboutContent 关于我内容 35 | */ 36 | void updateAbout(String aboutContent); 37 | 38 | /** 39 | * 修改公告 40 | * @param notice 公告 41 | */ 42 | void updateNotice(String notice); 43 | 44 | /** 45 | * 后台查看公告 46 | * @return 公告 47 | */ 48 | String getNotice(); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/CategoryService.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service; 2 | 3 | import com.minzheng.blog.dto.CategoryDTO; 4 | import com.minzheng.blog.dto.PageDTO; 5 | import com.minzheng.blog.entity.Category; 6 | import com.baomidou.mybatisplus.extension.service.IService; 7 | import com.minzheng.blog.vo.ConditionVO; 8 | 9 | import java.util.List; 10 | 11 | 12 | /** 13 | * @author xiaojie 14 | * @date 2020-05-16 15 | */ 16 | public interface CategoryService extends IService { 17 | 18 | /** 19 | * 查询分类列表 20 | * 21 | * @return 分类列表 22 | */ 23 | PageDTO listCategories(); 24 | 25 | /** 26 | * 查询后台分类 27 | * 28 | * @param conditionVO 条件 29 | * @return 分类列表 30 | */ 31 | PageDTO listCategoryBackDTO(ConditionVO conditionVO); 32 | 33 | /** 34 | * 删除分类 35 | * 36 | * @param categoryIdList 分类id集合 37 | */ 38 | void deleteCategory(List categoryIdList); 39 | 40 | } -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/CommentService.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service; 2 | 3 | import com.minzheng.blog.dto.CommentBackDTO; 4 | import com.minzheng.blog.dto.CommentDTO; 5 | import com.minzheng.blog.dto.PageDTO; 6 | import com.minzheng.blog.dto.ReplyDTO; 7 | import com.minzheng.blog.entity.Comment; 8 | import com.baomidou.mybatisplus.extension.service.IService; 9 | import com.minzheng.blog.vo.CommentVO; 10 | import com.minzheng.blog.vo.ConditionVO; 11 | import com.minzheng.blog.vo.DeleteVO; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * 17 | * @author xiaojie 18 | * @since 2020-05-18 19 | */ 20 | public interface CommentService extends IService { 21 | 22 | /** 23 | * 查看评论 24 | * 25 | * @param articleId 文章id 26 | * @param current 当前页码 27 | * @return CommentListDTO 28 | */ 29 | PageDTO listComments(Integer articleId, Long current); 30 | 31 | /** 32 | * 查看评论下的回复 33 | * 34 | * @param commentId 评论id 35 | * @param current 当前页码 36 | * @return 回复列表 37 | */ 38 | List listRepliesByCommentId(Integer commentId, Long current); 39 | 40 | /** 41 | * 添加评论 42 | * 43 | * @param commentVO 评论对象 44 | */ 45 | void saveComment(CommentVO commentVO); 46 | 47 | /** 48 | * 点赞评论 49 | * 50 | * @param commentId 评论id 51 | */ 52 | void saveCommentLike(Integer commentId); 53 | 54 | /** 55 | * 恢复或删除评论 56 | * 57 | * @param deleteVO 逻辑删除对象 58 | */ 59 | void updateCommentDelete(DeleteVO deleteVO); 60 | 61 | /** 62 | * 查询后台评论 63 | * 64 | * @param condition 条件 65 | * @return 评论列表 66 | */ 67 | PageDTO listCommentBackDTO(ConditionVO condition); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/FriendLinkService.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service; 2 | 3 | import com.minzheng.blog.dto.FriendLinkBackDTO; 4 | import com.minzheng.blog.dto.FriendLinkDTO; 5 | import com.minzheng.blog.dto.PageDTO; 6 | import com.minzheng.blog.entity.FriendLink; 7 | import com.baomidou.mybatisplus.extension.service.IService; 8 | import com.minzheng.blog.vo.ConditionVO; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author xiaojie 14 | * @since 2020-05-18 15 | */ 16 | public interface FriendLinkService extends IService { 17 | 18 | /** 19 | * 查看友链列表 20 | * 21 | * @return 友链列表 22 | */ 23 | List listFriendLinks(); 24 | 25 | /** 26 | * 查看后台友链列表 27 | * 28 | * @param condition 条件 29 | * @return 友链列表 30 | */ 31 | PageDTO listFriendLinkDTO(ConditionVO condition); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/MessageService.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service; 2 | 3 | import com.minzheng.blog.dto.MessageBackDTO; 4 | import com.minzheng.blog.dto.PageDTO; 5 | import com.minzheng.blog.vo.ConditionVO; 6 | import com.minzheng.blog.vo.MessageVO; 7 | import com.minzheng.blog.dto.MessageDTO; 8 | import com.minzheng.blog.entity.Message; 9 | import com.baomidou.mybatisplus.extension.service.IService; 10 | import com.minzheng.blog.vo.DeleteVO; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * @author xiaojie 16 | * @since 2020-05-18 17 | */ 18 | public interface MessageService extends IService { 19 | 20 | /** 21 | * 添加留言弹幕 22 | * 23 | * @param messageVO 留言对象 24 | */ 25 | void saveMessage(MessageVO messageVO); 26 | 27 | /** 28 | * 查看留言弹幕 29 | * 30 | * @return 留言列表 31 | */ 32 | List listMessages(); 33 | 34 | /** 35 | * 查看后台留言 36 | * 37 | * @param condition 条件 38 | * @return 留言列表 39 | */ 40 | PageDTO listMessageBackDTO(ConditionVO condition); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/TagService.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service; 2 | 3 | import com.minzheng.blog.dto.PageDTO; 4 | import com.minzheng.blog.dto.TagDTO; 5 | import com.minzheng.blog.entity.Tag; 6 | import com.baomidou.mybatisplus.extension.service.IService; 7 | import com.minzheng.blog.vo.ConditionVO; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 13 | * @author xiaojie 14 | * @since 2020-05-18 15 | */ 16 | public interface TagService extends IService { 17 | 18 | /** 19 | * 查询标签列表 20 | * 21 | * @return 标签列表 22 | */ 23 | PageDTO listTags(); 24 | 25 | /** 26 | * 查询后台标签 27 | * 28 | * @param condition 条件 29 | * @return 标签列表 30 | */ 31 | PageDTO listTagBackDTO(ConditionVO condition); 32 | 33 | /** 34 | * 删除标签 35 | * 36 | * @param tagIdList 标签id集合 37 | */ 38 | void deleteTag(List tagIdList); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/UniqueViewService.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service; 2 | 3 | import com.minzheng.blog.entity.UniqueView; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | * 8 | * @author xiaojie 9 | * @since 2020-05-18 10 | */ 11 | public interface UniqueViewService extends IService { 12 | 13 | /** 14 | * 统计每日用户量 15 | */ 16 | void saveUniqueView(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/UserAuthService.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service; 2 | 3 | import com.minzheng.blog.dto.PageDTO; 4 | import com.minzheng.blog.dto.UserBackDTO; 5 | import com.minzheng.blog.dto.UserInfoDTO; 6 | import com.minzheng.blog.entity.UserAuth; 7 | import com.baomidou.mybatisplus.extension.service.IService; 8 | import com.minzheng.blog.vo.ConditionVO; 9 | import com.minzheng.blog.vo.PasswordVO; 10 | import com.minzheng.blog.vo.UserVO; 11 | 12 | 13 | /** 14 | * @author xiaojie 15 | * @since 2020-05-18 16 | */ 17 | public interface UserAuthService extends IService { 18 | 19 | /** 20 | * 发送邮箱验证码 21 | * 22 | * @param username 邮箱号 23 | */ 24 | void sendCode(String username); 25 | 26 | /** 27 | * 用户注册 28 | * 29 | * @param user 用户对象 30 | */ 31 | void saveUser(UserVO user); 32 | 33 | /** 34 | * qq登录 35 | * 36 | * @param openId qq openId 37 | * @param accessToken qq token 38 | * @return 用户登录信息 39 | */ 40 | UserInfoDTO qqLogin(String openId, String accessToken); 41 | 42 | /** 43 | * 微博登录 44 | * 45 | * @param code 微博code 46 | * @return 用户登录信息 47 | */ 48 | UserInfoDTO weiboLogin(String code); 49 | 50 | /** 51 | * 修改密码 52 | * 53 | * @param user 用户对象 54 | */ 55 | void updatePassword(UserVO user); 56 | 57 | /** 58 | * 修改管理员密码 59 | * 60 | * @param passwordVO 密码对象 61 | */ 62 | void updateAdminPassword(PasswordVO passwordVO); 63 | 64 | /** 65 | * 查询后台用户列表 66 | * 67 | * @param condition 条件 68 | * @return 用户列表 69 | */ 70 | PageDTO listUserBackDTO(ConditionVO condition); 71 | 72 | } 73 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/UserInfoService.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service; 2 | 3 | import com.minzheng.blog.entity.UserInfo; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.minzheng.blog.vo.DeleteVO; 6 | import com.minzheng.blog.vo.UserInfoVO; 7 | import com.minzheng.blog.vo.UserRoleVO; 8 | import org.springframework.web.multipart.MultipartFile; 9 | 10 | /** 11 | * @author xiaojie 12 | * @since 2020-05-18 13 | */ 14 | public interface UserInfoService extends IService { 15 | 16 | /** 17 | * 修改用户资料 18 | * 19 | * @param userInfoVO 用户资料 20 | */ 21 | void updateUserInfo(UserInfoVO userInfoVO); 22 | 23 | /** 24 | * 修改用户头像 25 | * 26 | * @param file 头像图片 27 | * @return 头像OSS地址 28 | */ 29 | String updateUserAvatar(MultipartFile file); 30 | 31 | /** 32 | * 修改用户权限 33 | * 34 | * @param userRoleVO 用户权限 35 | */ 36 | void updateUserRole(UserRoleVO userRoleVO); 37 | 38 | /** 39 | * 修改用户禁言状态 40 | * 41 | * @param userInfoId 用户信息id 42 | * @param isSilence 禁言状态 43 | */ 44 | void updateUserSilence(Integer userInfoId, Integer isSilence); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/impl/ArticleTagServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service.impl; 2 | 3 | import com.minzheng.blog.entity.ArticleTag; 4 | import com.minzheng.blog.dao.ArticleTagDao; 5 | import com.minzheng.blog.service.ArticleTagService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * 11 | * @author xiaojie 12 | * @since 2020-05-18 13 | */ 14 | @Service 15 | public class ArticleTagServiceImpl extends ServiceImpl implements ArticleTagService { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/impl/CategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 5 | import com.minzheng.blog.dao.ArticleDao; 6 | import com.minzheng.blog.dto.CategoryDTO; 7 | import com.minzheng.blog.dto.PageDTO; 8 | import com.minzheng.blog.entity.Article; 9 | import com.minzheng.blog.entity.Category; 10 | import com.minzheng.blog.dao.CategoryDao; 11 | import com.minzheng.blog.exception.ServeException; 12 | import com.minzheng.blog.service.CategoryService; 13 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 14 | import com.minzheng.blog.vo.ConditionVO; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Service; 17 | import org.springframework.transaction.annotation.Transactional; 18 | 19 | import java.util.List; 20 | 21 | 22 | 23 | /** 24 | * 25 | * @author xiaojie 26 | * @since 2020-05-18 27 | */ 28 | @Service 29 | public class CategoryServiceImpl extends ServiceImpl implements CategoryService { 30 | @Autowired 31 | private CategoryDao categoryDao; 32 | @Autowired 33 | private ArticleDao articleDao; 34 | 35 | @Override 36 | public PageDTO listCategories() { 37 | //获取分类列表 38 | List categoryDTOList = categoryDao.listCategoryDTO(); 39 | //获取分类数量 40 | Integer count = categoryDao.selectCount(null); 41 | return new PageDTO(categoryDTOList, count); 42 | } 43 | 44 | @Override 45 | public PageDTO listCategoryBackDTO(ConditionVO condition) { 46 | Page page = new Page<>(condition.getCurrent(), condition.getSize()); 47 | QueryWrapper queryWrapper = new QueryWrapper<>(); 48 | queryWrapper.select("id", "category_name", "create_time") 49 | .like(condition.getKeywords() != null, "category_name", condition.getKeywords()); 50 | Page categoryPage = categoryDao.selectPage(page, queryWrapper); 51 | return new PageDTO(categoryPage.getRecords(), (int) categoryPage.getTotal()); 52 | } 53 | 54 | @Transactional(rollbackFor = ServeException.class) 55 | @Override 56 | public void deleteCategory(List categoryIdList) { 57 | //查询分类id下是否有文章 58 | QueryWrapper
queryWrapper = new QueryWrapper<>(); 59 | queryWrapper.select("id").in("category_id", categoryIdList); 60 | if (!articleDao.selectList(queryWrapper).isEmpty()) { 61 | throw new ServeException("删除失败,该分类下存在文章"); 62 | } 63 | categoryDao.deleteBatchIds(categoryIdList); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/impl/FriendLinkServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 5 | import com.minzheng.blog.constant.DeleteConst; 6 | import com.minzheng.blog.dto.FriendLinkBackDTO; 7 | import com.minzheng.blog.dto.FriendLinkDTO; 8 | import com.minzheng.blog.dto.PageDTO; 9 | import com.minzheng.blog.entity.FriendLink; 10 | import com.minzheng.blog.dao.FriendLinkDao; 11 | import com.minzheng.blog.service.FriendLinkService; 12 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 13 | import com.minzheng.blog.utils.BeanCopyUtil; 14 | import com.minzheng.blog.vo.ConditionVO; 15 | import com.minzheng.blog.vo.DeleteVO; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.stereotype.Service; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | /** 23 | * @author xiaojie 24 | * @since 2020-05-18 25 | */ 26 | @Service 27 | public class FriendLinkServiceImpl extends ServiceImpl implements FriendLinkService { 28 | @Autowired 29 | private FriendLinkDao friendLinkDao; 30 | 31 | @Override 32 | public List listFriendLinks() { 33 | QueryWrapper queryWrapper = new QueryWrapper<>(); 34 | queryWrapper.select("id", "link_name", "link_avatar", "link_address", "link_intro"); 35 | return BeanCopyUtil.copyList(friendLinkDao.selectList(queryWrapper), FriendLinkDTO.class); 36 | } 37 | 38 | @Override 39 | public PageDTO listFriendLinkDTO(ConditionVO condition) { 40 | Page page = new Page<>(condition.getCurrent(), condition.getSize()); 41 | QueryWrapper queryWrapper = new QueryWrapper<>(); 42 | queryWrapper.select("id", "link_name", "link_avatar", "link_address", "link_intro", "create_time") 43 | .like(condition.getKeywords() != null, "link_name", condition.getKeywords()); 44 | Page friendLinkPage = friendLinkDao.selectPage(page, queryWrapper); 45 | //转换DTO 46 | List friendLinkBackDTOList = BeanCopyUtil.copyList(friendLinkPage.getRecords(), FriendLinkBackDTO.class); 47 | return new PageDTO(friendLinkBackDTOList, (int) friendLinkPage.getTotal()); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/impl/MessageServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 5 | import com.minzheng.blog.constant.DeleteConst; 6 | import com.minzheng.blog.dto.MessageBackDTO; 7 | import com.minzheng.blog.dto.PageDTO; 8 | import com.minzheng.blog.exception.ServeException; 9 | import com.minzheng.blog.vo.ConditionVO; 10 | import com.minzheng.blog.vo.MessageVO; 11 | import com.minzheng.blog.dto.MessageDTO; 12 | import com.minzheng.blog.entity.Message; 13 | import com.minzheng.blog.dao.MessageDao; 14 | import com.minzheng.blog.service.MessageService; 15 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 16 | import com.minzheng.blog.utils.BeanCopyUtil; 17 | import com.minzheng.blog.utils.IpUtil; 18 | import com.minzheng.blog.vo.DeleteVO; 19 | import org.springframework.beans.factory.annotation.Autowired; 20 | import org.springframework.stereotype.Service; 21 | import org.springframework.transaction.annotation.Transactional; 22 | 23 | import javax.servlet.http.HttpServletRequest; 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | 27 | /** 28 | * @author xiaojie 29 | * @since 2020-05-18 30 | */ 31 | @Service 32 | public class MessageServiceImpl extends ServiceImpl implements MessageService { 33 | @Autowired 34 | private MessageDao messageDao; 35 | @Autowired 36 | private HttpServletRequest request; 37 | 38 | @Transactional(rollbackFor = ServeException.class) 39 | @Override 40 | public void saveMessage(MessageVO messageVO) { 41 | String ipAddr = IpUtil.getIpAddr(request); 42 | String ipSource = IpUtil.getIpSource(ipAddr); 43 | messageDao.insert(new Message(messageVO, ipAddr, ipSource)); 44 | } 45 | 46 | @Override 47 | public List listMessages() { 48 | QueryWrapper queryWrapper = new QueryWrapper<>(); 49 | queryWrapper.select("id", "nickname", "avatar", "message_content", "time"); 50 | return BeanCopyUtil.copyList(messageDao.selectList(queryWrapper), MessageDTO.class); 51 | } 52 | 53 | @Override 54 | public PageDTO listMessageBackDTO(ConditionVO condition) { 55 | Page page = new Page<>(condition.getCurrent(), condition.getSize()); 56 | QueryWrapper queryWrapper = new QueryWrapper<>(); 57 | queryWrapper.select("id", "nickname", "avatar", "ip_address", "ip_source", "message_content", "create_time") 58 | .like(condition.getKeywords() != null, "nickname", condition.getKeywords()) 59 | .orderByDesc("create_time"); 60 | Page messagePage = messageDao.selectPage(page, queryWrapper); 61 | //转换DTO 62 | List messageBackDTOList = BeanCopyUtil.copyList(messagePage.getRecords(), MessageBackDTO.class); 63 | return new PageDTO(messageBackDTOList, (int) messagePage.getTotal()); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/impl/TagServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 5 | import com.minzheng.blog.dao.ArticleTagDao; 6 | import com.minzheng.blog.dto.PageDTO; 7 | import com.minzheng.blog.dto.TagDTO; 8 | import com.minzheng.blog.entity.ArticleTag; 9 | import com.minzheng.blog.entity.Tag; 10 | import com.minzheng.blog.dao.TagDao; 11 | import com.minzheng.blog.exception.ServeException; 12 | import com.minzheng.blog.service.TagService; 13 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 14 | import com.minzheng.blog.utils.BeanCopyUtil; 15 | import com.minzheng.blog.vo.ConditionVO; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.stereotype.Service; 18 | import org.springframework.transaction.annotation.Transactional; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * @author xiaojie 24 | * @since 2020-05-18 25 | */ 26 | @Service 27 | public class TagServiceImpl extends ServiceImpl implements TagService { 28 | @Autowired 29 | private TagDao tagDao; 30 | @Autowired 31 | private ArticleTagDao articleTagDao; 32 | 33 | @Override 34 | public PageDTO listTags() { 35 | QueryWrapper queryWrapper = new QueryWrapper<>(); 36 | queryWrapper.select("id", "tag_name"); 37 | //查询标签列表 38 | List tagDTOList = BeanCopyUtil.copyList(tagDao.selectList(queryWrapper), TagDTO.class); 39 | //查询标签数量 40 | Integer count = tagDao.selectCount(null); 41 | return new PageDTO(tagDTOList, count); 42 | } 43 | 44 | @Override 45 | public PageDTO listTagBackDTO(ConditionVO condition) { 46 | Page page = new Page<>(condition.getCurrent(), condition.getSize()); 47 | QueryWrapper queryWrapper = new QueryWrapper<>(); 48 | queryWrapper.select("id", "tag_name", "create_time") 49 | .like(condition.getKeywords() != null, "tag_name", condition.getKeywords()); 50 | Page tagPage = tagDao.selectPage(page, queryWrapper); 51 | return new PageDTO(tagPage.getRecords(), (int) tagPage.getTotal()); 52 | } 53 | 54 | @Transactional(rollbackFor = ServeException.class) 55 | @Override 56 | public void deleteTag(List tagIdList) { 57 | //查询标签下是否有文章 58 | QueryWrapper queryWrapper = new QueryWrapper<>(); 59 | queryWrapper.select("id").in("tag_id", tagIdList); 60 | if (!articleTagDao.selectList(queryWrapper).isEmpty()) { 61 | throw new ServeException("删除失败,该标签下存在文章"); 62 | } 63 | tagDao.deleteBatchIds(tagIdList); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/impl/UniqueViewServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service.impl; 2 | 3 | import com.minzheng.blog.entity.UniqueView; 4 | import com.minzheng.blog.dao.UniqueViewDao; 5 | import com.minzheng.blog.service.UniqueViewService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.data.redis.core.RedisTemplate; 9 | import org.springframework.scheduling.annotation.Scheduled; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.Calendar; 13 | 14 | /** 15 | * 16 | * @author xiaojie 17 | * @since 2020-05-18 18 | */ 19 | @Service 20 | public class UniqueViewServiceImpl extends ServiceImpl implements UniqueViewService { 21 | @Autowired 22 | private RedisTemplate redisTemplate; 23 | @Autowired 24 | private UniqueViewDao uniqueViewDao; 25 | 26 | @Scheduled(cron = " 0 0 0 * * ?") 27 | @Override 28 | public void saveUniqueView() { 29 | //获取每天用户量 30 | Long count = redisTemplate.boundSetOps("ip_set").size(); 31 | //获取昨天日期 32 | Calendar calendar = Calendar.getInstance(); 33 | calendar.set(Calendar.HOUR_OF_DAY, -24); 34 | uniqueViewDao.insert(new UniqueView(calendar.getTime(), count.intValue())); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/impl/UserDetailsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service.impl; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.minzheng.blog.dao.UserAuthDao; 6 | import com.minzheng.blog.dao.UserInfoDao; 7 | import com.minzheng.blog.dto.UserInfoDTO; 8 | import com.minzheng.blog.entity.UserAuth; 9 | import com.minzheng.blog.entity.UserInfo; 10 | import com.minzheng.blog.exception.ServeException; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.data.redis.core.RedisTemplate; 13 | import org.springframework.security.core.userdetails.User; 14 | import org.springframework.security.core.userdetails.UserDetails; 15 | import org.springframework.security.core.userdetails.UserDetailsService; 16 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 17 | import org.springframework.stereotype.Service; 18 | import org.springframework.util.StringUtils; 19 | 20 | import java.util.Set; 21 | 22 | 23 | /** 24 | * @author 11921 25 | */ 26 | @Service 27 | public class UserDetailsServiceImpl implements UserDetailsService { 28 | @Autowired 29 | private UserAuthDao userAuthDao; 30 | @Autowired 31 | private UserInfoDao userInfoDao; 32 | @Autowired 33 | private RedisTemplate redisTemplate; 34 | 35 | @Override 36 | public UserDetails loadUserByUsername(String username) { 37 | if (StringUtils.isEmpty(username)) { 38 | throw new ServeException("用户名不能为空!"); 39 | } 40 | //查询账号是否存在 41 | QueryWrapper userAuthQueryWrapper = new QueryWrapper<>(); 42 | userAuthQueryWrapper.select("id", "user_info_id", "password").eq("username", username); 43 | UserAuth user = userAuthDao.selectOne(userAuthQueryWrapper); 44 | if (user == null) { 45 | throw new ServeException("用户名不存在"); 46 | } 47 | //查询账号对应的信息 48 | QueryWrapper userInfoWrapper = new QueryWrapper<>(); 49 | userInfoWrapper.select("id", "user_role", "nickname", "avatar", "intro", "web_site", "is_silence").eq("id", user.getUserInfoId()); 50 | UserInfo userInfo = userInfoDao.selectOne(userInfoWrapper); 51 | //查询账号点赞信息 52 | Set articleLikeSet = (Set) redisTemplate.boundHashOps("article_user_like").get(userInfo.getId().toString()); 53 | Set commentLikeSet = (Set) redisTemplate.boundHashOps("comment_user_like").get(userInfo.getId().toString()); 54 | //封装信息 55 | return User.withUsername(JSON.toJSONString(new UserInfoDTO(user.getId(), userInfo, articleLikeSet, commentLikeSet))).password(user.getPassword()).roles(userInfo.getUserRole()).build(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/service/impl/UserInfoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.service.impl; 2 | 3 | import com.minzheng.blog.constant.PathConst; 4 | import com.minzheng.blog.entity.UserInfo; 5 | import com.minzheng.blog.dao.UserInfoDao; 6 | import com.minzheng.blog.exception.ServeException; 7 | import com.minzheng.blog.service.UserInfoService; 8 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 9 | import com.minzheng.blog.utils.OSSUtil; 10 | 11 | import com.minzheng.blog.vo.UserInfoVO; 12 | import com.minzheng.blog.vo.UserRoleVO; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Service; 15 | import org.springframework.transaction.annotation.Transactional; 16 | import org.springframework.web.multipart.MultipartFile; 17 | 18 | 19 | 20 | 21 | /** 22 | * @author xiaojie 23 | * @since 2020-05-18 24 | */ 25 | @Service 26 | public class UserInfoServiceImpl extends ServiceImpl implements UserInfoService { 27 | @Autowired 28 | private UserInfoDao userInfoDao; 29 | 30 | @Override 31 | public void updateUserInfo(UserInfoVO userInfoVO) { 32 | userInfoDao.updateById(new UserInfo(userInfoVO)); 33 | } 34 | 35 | @Transactional(rollbackFor = ServeException.class) 36 | @Override 37 | public String updateUserAvatar(MultipartFile file) { 38 | //头像上传oss,返回图片地址 39 | String avatar = OSSUtil.upload(file, PathConst.AVATAR); 40 | userInfoDao.updateById(new UserInfo(avatar)); 41 | return avatar; 42 | } 43 | 44 | @Transactional(rollbackFor = ServeException.class) 45 | @Override 46 | public void updateUserRole(UserRoleVO userRoleVO) { 47 | userInfoDao.updateById(new UserInfo(userRoleVO)); 48 | } 49 | 50 | @Transactional(rollbackFor = ServeException.class) 51 | @Override 52 | public void updateUserSilence(Integer userInfoId, Integer isSilence) { 53 | userInfoDao.updateById(new UserInfo(userInfoId, isSilence)); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/utils/BeanCopyUtil.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.utils; 2 | 3 | 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | /** 9 | * 复制对象或集合属性 10 | * @author 11921 11 | */ 12 | public class BeanCopyUtil { 13 | 14 | /** 15 | * 根据现有对象的属性创建目标对象,并赋值 16 | * 17 | * @param source 18 | * @param target 19 | * @param 20 | * @return 21 | * @throws Exception 22 | */ 23 | public static T copyObject(Object source, Class target) { 24 | T temp = null; 25 | try { 26 | temp = target.newInstance(); 27 | if (null != source) { 28 | org.springframework.beans.BeanUtils.copyProperties(source, temp); 29 | } 30 | } catch (Exception e) { 31 | e.printStackTrace(); 32 | } 33 | return temp; 34 | } 35 | 36 | /** 37 | * 拷贝集合 38 | * 39 | * @param source 40 | * @param target 41 | * @param 42 | * @param 43 | * @return 44 | */ 45 | public static List copyList(List source, Class target) { 46 | List list = new ArrayList<>(); 47 | if (null != source && source.size() > 0) { 48 | for (Object obj : source) { 49 | list.add(BeanCopyUtil.copyObject(obj, target)); 50 | } 51 | } 52 | return list; 53 | } 54 | 55 | 56 | } -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/utils/HTMLUtil.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.utils; 2 | 3 | /** 4 | * @author 11921 5 | */ 6 | public class HTMLUtil { 7 | 8 | /** 9 | * 删除文章内的markdown 10 | * 11 | * @param source 需要过滤的文本 12 | * @return 过滤后的内容 13 | */ 14 | public static String deleteArticleTag(String source) { 15 | //删除HTML和markdown标签 16 | source = source.replaceAll("!\\[\\]\\((.*?)\\)", "").replaceAll("<[^>]+>", ""); 17 | return deleteTag(source); 18 | } 19 | 20 | /** 21 | * 删除评论内容标签 22 | * 23 | * @param source 需要进行剔除HTML的文本 24 | * @return 过滤后的内容 25 | */ 26 | public static String deleteCommentTag(String source) { 27 | //保留图片标签 28 | source = source.replaceAll("(?!<(img).*?>)<.*?>", ""); 29 | return deleteTag(source); 30 | } 31 | 32 | /** 33 | * 删除标签 34 | * 35 | * @param source 文本 36 | * @return 过滤后的文本 37 | */ 38 | private static String deleteTag(String source) { 39 | //删除转义字符 40 | source = source.replaceAll("&.{2,6}?;", ""); 41 | //删除script标签 42 | source = source.replaceAll("<[\\s]*?script[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?script[\\s]*?>", ""); 43 | //删除style标签 44 | source = source.replaceAll("<[\\s]*?style[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?style[\\s]*?>", ""); 45 | return source; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/utils/IpUtil.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.utils; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONObject; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.client.RestTemplate; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import java.io.BufferedReader; 10 | import java.io.InputStreamReader; 11 | import java.net.InetAddress; 12 | import java.net.URL; 13 | import java.net.UnknownHostException; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | /** 18 | * 用户工具类 19 | * 20 | * @author 11921 21 | */ 22 | @SuppressWarnings("all") 23 | public class IpUtil { 24 | 25 | /** 26 | * 获取用户ip地址 27 | * 28 | * @param request 29 | * @return 30 | */ 31 | public static String getIpAddr(HttpServletRequest request) { 32 | String ipAddress = null; 33 | try { 34 | ipAddress = request.getHeader("x-forwarded-for"); 35 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { 36 | ipAddress = request.getHeader("Proxy-Client-IP"); 37 | } 38 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { 39 | ipAddress = request.getHeader("WL-Proxy-Client-IP"); 40 | } 41 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { 42 | ipAddress = request.getRemoteAddr(); 43 | if ("127.0.0.1".equals(ipAddress)) { 44 | // 根据网卡取本机配置的IP 45 | InetAddress inet = null; 46 | try { 47 | inet = InetAddress.getLocalHost(); 48 | } catch (UnknownHostException e) { 49 | e.printStackTrace(); 50 | } 51 | ipAddress = inet.getHostAddress(); 52 | } 53 | } 54 | // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割 55 | if (ipAddress != null && ipAddress.length() > 15) { 56 | // = 15 57 | if (ipAddress.indexOf(",") > 0) { 58 | ipAddress = ipAddress.substring(0, ipAddress.indexOf(",")); 59 | } 60 | } 61 | } catch (Exception e) { 62 | ipAddress = ""; 63 | } 64 | return ipAddress; 65 | } 66 | 67 | /** 68 | * 解析ip地址 69 | * 70 | * @param ipAddress 71 | * @return 72 | */ 73 | public static String getIpSource(String ipAddress) { 74 | try { 75 | URL url = new URL("http://opendata.baidu.com/api.php?query=" + ipAddress + "&co=&resource_id=6006&oe=utf8"); 76 | BufferedReader reader = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream(), "utf-8")); 77 | String line = null; 78 | StringBuffer result = new StringBuffer(); 79 | while ((line = reader.readLine()) != null) { 80 | result.append(line); 81 | } 82 | reader.close(); 83 | Map map = JSON.parseObject(result.toString(), Map.class); 84 | List> data = (List) map.get("data"); 85 | return data.get(0).get("location"); 86 | } catch (Exception e) { 87 | return ""; 88 | } 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/utils/OSSUtil.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.utils; 2 | 3 | import com.aliyun.oss.OSS; 4 | import com.aliyun.oss.OSSClientBuilder; 5 | import com.aliyun.oss.model.PutObjectRequest; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.web.multipart.MultipartFile; 9 | 10 | import java.io.*; 11 | import java.util.LinkedList; 12 | 13 | /** 14 | * OSS工具类 15 | * 16 | * @author 11921 17 | */ 18 | @Component 19 | public class OSSUtil { 20 | 21 | private static String url; 22 | 23 | private static String endpoint; 24 | 25 | private static String accessKeyId; 26 | 27 | private static String accessKeySecret; 28 | 29 | private static String bucketName; 30 | 31 | @Value("${aliyun.url}") 32 | public void setUrl(String url) { 33 | OSSUtil.url = url; 34 | } 35 | 36 | @Value("${aliyun.endpoint}") 37 | public void setEndpoint(String endpoint) { 38 | OSSUtil.endpoint = endpoint; 39 | } 40 | 41 | @Value("${aliyun.accessKeyId}") 42 | public void setAccessKeyId(String accessKeyId) { 43 | OSSUtil.accessKeyId = accessKeyId; 44 | } 45 | 46 | @Value("${aliyun.accessKeySecret}") 47 | public void setAccessKeySecret(String accessKeySecret) { 48 | OSSUtil.accessKeySecret = accessKeySecret; 49 | } 50 | 51 | @Value("${aliyun.bucketName}") 52 | public void setBucketName(String bucketName) { 53 | OSSUtil.bucketName = bucketName; 54 | } 55 | 56 | /** 57 | * 上传图片 58 | * 59 | * @param file 文件 60 | * @param targetAddr 目标路径 61 | * @return 62 | */ 63 | public static String upload(MultipartFile file, String targetAddr) { 64 | // 获取不重复的随机名 65 | String fileName = String.valueOf(System.currentTimeMillis()); 66 | // 获取文件的扩展名如png,jpg等 67 | String extension = getFileExtension(file.getOriginalFilename()); 68 | // 获取文件存储的相对路径(带文件名) 69 | String relativeAddr = targetAddr + fileName + extension; 70 | try { 71 | // 创建OSSClient实例 72 | OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); 73 | // 上传文件 74 | ossClient.putObject(bucketName, relativeAddr, file.getInputStream()); 75 | // 关闭OSSClient。 76 | ossClient.shutdown(); 77 | } catch (IOException e) { 78 | e.printStackTrace(); 79 | } 80 | return url + relativeAddr; 81 | } 82 | 83 | /** 84 | * 获取输入文件流的扩展名 85 | * 86 | * @param fileName 87 | * @return 88 | */ 89 | private static String getFileExtension(String fileName) { 90 | return fileName.substring(fileName.lastIndexOf(".")); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/utils/UserUtil.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.utils; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.minzheng.blog.dto.UserInfoDTO; 5 | import org.springframework.security.core.context.SecurityContextHolder; 6 | 7 | /** 8 | * 用户工具类 9 | * @author 11921 10 | */ 11 | public class UserUtil { 12 | /** 13 | * 获取当前登录用户 14 | * 15 | * @return 16 | */ 17 | public static UserInfoDTO getLoginUser() { 18 | return JSON.parseObject(SecurityContextHolder.getContext().getAuthentication().getName(), UserInfoDTO.class); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/vo/ArticleVO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.vo; 2 | 3 | 4 | import com.minzheng.blog.entity.Article; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | import lombok.NonNull; 9 | 10 | import javax.validation.constraints.NotBlank; 11 | import javax.validation.constraints.NotNull; 12 | import java.util.Date; 13 | import java.util.List; 14 | 15 | 16 | /** 17 | * 文章VO 18 | * 19 | * @author 11921 20 | */ 21 | @Data 22 | @ApiModel(description = "文章") 23 | public class ArticleVO { 24 | 25 | /** 26 | * 文章id 27 | */ 28 | @ApiModelProperty(name = "id", value = "文章id", dataType = "Integer") 29 | private Integer id; 30 | 31 | /** 32 | * 标题 33 | */ 34 | @NotBlank(message = "文章标题不能为空") 35 | @ApiModelProperty(name = "articleTitle", value = "文章标题", required = true, dataType = "String") 36 | private String articleTitle; 37 | 38 | /** 39 | * 内容 40 | */ 41 | @NotBlank(message = "文章内容不能为空") 42 | @ApiModelProperty(name = "articleContent", value = "文章内容", required = true, dataType = "String") 43 | private String articleContent; 44 | 45 | /** 46 | * 文章封面 47 | */ 48 | @ApiModelProperty(name = "articleCover", value = "文章缩略图", dataType = "String") 49 | private String articleCover; 50 | 51 | /** 52 | * 文章分类 53 | */ 54 | @ApiModelProperty(name = "categoryId", value = "文章分类", dataType = "Integer") 55 | private Integer categoryId; 56 | 57 | /** 58 | * 文章标签 59 | */ 60 | @ApiModelProperty(name = "tagIdList", value = "文章标签", dataType = "List") 61 | private List tagIdList; 62 | 63 | /** 64 | * 是否置顶 65 | */ 66 | @ApiModelProperty(name = "isTop", value = "是否置顶", dataType = "Integer") 67 | private Integer isTop; 68 | 69 | /** 70 | * 是否为草稿 71 | */ 72 | @ApiModelProperty(name = "isDraft", value = "是否为草稿", dataType = "Integer") 73 | private Integer isDraft; 74 | 75 | 76 | public ArticleVO(Article article, List tagIdList) { 77 | this.id = article.getId(); 78 | this.articleTitle = article.getArticleTitle(); 79 | this.articleContent = article.getArticleContent(); 80 | this.articleCover = article.getArticleCover(); 81 | this.categoryId = article.getCategoryId(); 82 | this.isTop = article.getIsTop(); 83 | this.tagIdList = tagIdList; 84 | this.isDraft = article.getIsDraft(); 85 | } 86 | 87 | public ArticleVO() { 88 | } 89 | 90 | 91 | } 92 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/vo/CategoryVO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import javax.validation.constraints.NotBlank; 8 | 9 | 10 | /** 11 | * 分类VO 12 | * @author 11921 13 | */ 14 | @Data 15 | @ApiModel(description = "分类") 16 | public class CategoryVO { 17 | 18 | /** 19 | * id 20 | */ 21 | @ApiModelProperty(name = "id", value = "分类id", dataType = "Integer") 22 | private Integer id; 23 | 24 | /** 25 | * 分类名 26 | */ 27 | @NotBlank(message = "分类名不能为空") 28 | @ApiModelProperty(name = "categoryName", value = "分类名", required = true, dataType = "String") 29 | private String categoryName; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/vo/CommentVO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import javax.validation.constraints.NotBlank; 8 | import javax.validation.constraints.Size; 9 | 10 | /** 11 | * @author 11921 12 | */ 13 | @Data 14 | @ApiModel(description = "评论") 15 | public class CommentVO { 16 | 17 | /** 18 | * 回复用户id 19 | */ 20 | @ApiModelProperty(name = "replyId", value = "回复用户id", dataType = "Integer") 21 | private Integer replyId; 22 | 23 | /** 24 | * 评论文章id 25 | */ 26 | @ApiModelProperty(name = "articleId", value = "文章id", dataType = "Integer") 27 | private Integer articleId; 28 | 29 | /** 30 | * 评论内容 31 | */ 32 | @NotBlank(message = "评论内容不能为空") 33 | @ApiModelProperty(name = "commentContent", value = "评论内容", required = true, dataType = "String") 34 | private String commentContent; 35 | 36 | /** 37 | * 父评论id 38 | */ 39 | @ApiModelProperty(name = "parentId", value = "评论父id", dataType = "Integer") 40 | private Integer parentId; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/vo/ConditionVO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | /** 8 | * 查询条件 9 | * 10 | * @author 11921 11 | */ 12 | @Data 13 | @ApiModel(description = "查询条件") 14 | public class ConditionVO { 15 | 16 | /** 17 | * 分类id 18 | */ 19 | @ApiModelProperty(name = "categoryId", value = "分类id", dataType = "Integer") 20 | private Integer categoryId; 21 | 22 | /** 23 | * 标签id 24 | */ 25 | @ApiModelProperty(name = "tagId", value = "标签id", dataType = "Integer") 26 | private Integer tagId; 27 | 28 | /** 29 | * 当前页码 30 | */ 31 | @ApiModelProperty(name = "current", value = "当前页码", required = true, dataType = "Long") 32 | private Long current; 33 | 34 | /** 35 | * 显示数量 36 | */ 37 | @ApiModelProperty(name = "size", value = "显示数量", required = true, dataType = "Long") 38 | private Long size; 39 | 40 | /** 41 | * 搜索内容 42 | */ 43 | @ApiModelProperty(name = "keywords", value = "搜索内容", required = true, dataType = "String") 44 | private String keywords; 45 | 46 | /** 47 | * 状态值 48 | */ 49 | @ApiModelProperty(name = "isDelete", value = "是否删除", dataType = "Integer") 50 | private Integer isDelete; 51 | public ConditionVO(Integer tagId, Long current) { 52 | this.tagId = tagId; 53 | this.current = current; 54 | } 55 | 56 | /** 57 | * 是否为草稿 58 | */ 59 | @ApiModelProperty(name = "isDraft", value = "草稿状态", dataType = "Integer") 60 | private Integer isDraft; 61 | 62 | public ConditionVO(Long current, Integer categoryId) { 63 | this.current = current; 64 | this.categoryId = categoryId; 65 | } 66 | 67 | public ConditionVO(Long current, String keywords) { 68 | this.current = current; 69 | this.keywords = keywords; 70 | } 71 | 72 | public ConditionVO() { 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/vo/DeleteVO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author 11921 11 | */ 12 | @Data 13 | @ApiModel(description = "逻辑删除") 14 | public class DeleteVO { 15 | 16 | /** 17 | * id列表 18 | */ 19 | @ApiModelProperty(name = "idList", value = "id列表", required = true, dataType = "List") 20 | private List idList; 21 | 22 | /** 23 | * 状态值 24 | */ 25 | @ApiModelProperty(name = "isDelete", value = "删除状态", required = true, dataType = "Integer") 26 | private Integer isDelete; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/vo/FriendLinkVO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import javax.validation.constraints.NotBlank; 8 | 9 | /** 10 | * 友链DTO 11 | * 12 | * @author 11921 13 | */ 14 | @Data 15 | @ApiModel(description = "友链") 16 | public class FriendLinkVO { 17 | /** 18 | * id 19 | */ 20 | @ApiModelProperty(name = "categoryId", value = "友链id", dataType = "Integer") 21 | private Integer id; 22 | 23 | /** 24 | * 链接名 25 | */ 26 | @NotBlank(message = "链接名不能为空") 27 | @ApiModelProperty(name = "linkName", value = "友链名", dataType = "String", required = true) 28 | private String linkName; 29 | 30 | /** 31 | * 链接头像 32 | */ 33 | @NotBlank(message = "链接头像不能为空") 34 | @ApiModelProperty(name = "linkAvatar", value = "友链头像", dataType = "String", required = true) 35 | private String linkAvatar; 36 | 37 | /** 38 | * 链接地址 39 | */ 40 | @NotBlank(message = "链接地址不能为空") 41 | @ApiModelProperty(name = "linkAddress", value = "友链头像", dataType = "String", required = true) 42 | private String linkAddress; 43 | 44 | /** 45 | * 介绍 46 | */ 47 | @NotBlank(message = "链接介绍不能为空") 48 | @ApiModelProperty(name = "linkIntro", value = "友链头像", dataType = "String", required = true) 49 | private String linkIntro; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/vo/MessageVO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import javax.validation.constraints.NotBlank; 8 | import javax.validation.constraints.NotNull; 9 | 10 | /** 11 | * 留言 12 | * @author 11921 13 | */ 14 | @Data 15 | @ApiModel(description = "留言") 16 | public class MessageVO { 17 | 18 | /** 19 | * 昵称 20 | */ 21 | @NotBlank(message = "昵称不能为空") 22 | @ApiModelProperty(name = "nickname", value = "昵称", required = true, dataType = "String") 23 | private String nickname; 24 | 25 | /** 26 | * 头像 27 | */ 28 | @NotBlank(message = "头像不能为空") 29 | @ApiModelProperty(name = "avatar", value = "头像", required = true, dataType = "String") 30 | private String avatar; 31 | 32 | /** 33 | * 留言内容 34 | */ 35 | @NotBlank(message = "留言内容不能为空") 36 | @ApiModelProperty(name = "messageContent", value = "留言内容", required = true, dataType = "String") 37 | private String messageContent; 38 | 39 | /** 40 | * 弹幕速度 41 | */ 42 | @NotNull(message = "弹幕速度不能为空") 43 | @ApiModelProperty(name = "time", value = "弹幕速度", required = true, dataType = "Integer") 44 | private Integer time; 45 | } 46 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/vo/PasswordVO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import javax.validation.constraints.NotBlank; 8 | import javax.validation.constraints.Size; 9 | 10 | /** 11 | * 密码对象 12 | * 13 | * @author 11921 14 | */ 15 | @ApiModel(description = "密码") 16 | @Data 17 | public class PasswordVO { 18 | 19 | /** 20 | * 旧密码 21 | */ 22 | @NotBlank(message = "旧密码不能为空") 23 | @ApiModelProperty(name = "oldPassword", value = "旧密码", required = true, dataType = "String") 24 | private String oldPassword; 25 | 26 | /** 27 | * 新密码 28 | */ 29 | @Size(min = 6, message = "新密码不能少于6位") 30 | @NotBlank(message = "新密码不能为空") 31 | @ApiModelProperty(name = "newPassword", value = "新密码", required = true, dataType = "String") 32 | private String newPassword; 33 | } 34 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/vo/Result.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.vo; 2 | 3 | import com.minzheng.blog.constant.StatusConst; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 接口返回类 10 | * 11 | * @author 11921 12 | */ 13 | @Data 14 | public class Result implements Serializable { 15 | private boolean flag; 16 | private Integer code; 17 | private String message; 18 | private T data; 19 | 20 | public Result(boolean flag, Integer code, String message, Object data) { 21 | this.flag = flag; 22 | this.code = code; 23 | this.message = message; 24 | this.data = (T) data; 25 | } 26 | 27 | public Result(boolean flag, Integer code, String message) { 28 | this.flag = flag; 29 | this.code = code; 30 | this.message = message; 31 | } 32 | 33 | public Result() { 34 | this.flag = true; 35 | this.code = StatusConst.OK; 36 | this.message = "操作成功!"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/vo/TagVO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import javax.validation.constraints.NotBlank; 8 | 9 | /** 10 | * 标签VO 11 | * 12 | * @author 11921 13 | */ 14 | @Data 15 | @ApiModel(description = "标签对象") 16 | public class TagVO { 17 | 18 | /** 19 | * id 20 | */ 21 | @ApiModelProperty(name = "id", value = "标签id", dataType = "Integer") 22 | private Integer id; 23 | 24 | /** 25 | * 标签名 26 | */ 27 | @NotBlank(message = "标签名不能为空") 28 | @ApiModelProperty(name = "categoryName", value = "标签名", required = true, dataType = "String") 29 | private String tagName; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/vo/UserInfoVO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import javax.validation.constraints.NotBlank; 8 | 9 | /** 10 | * 用户信息vo 11 | * 12 | * @author 11921 13 | */ 14 | @Data 15 | @ApiModel(description = "用户信息对象") 16 | public class UserInfoVO { 17 | 18 | /** 19 | * 用户昵称 20 | */ 21 | @NotBlank(message = "昵称不能为空") 22 | @ApiModelProperty(name = "nickname", value = "昵称", dataType = "String") 23 | private String nickname; 24 | 25 | /** 26 | * 用户简介 27 | */ 28 | @ApiModelProperty(name = "intro", value = "介绍", dataType = "String") 29 | private String intro; 30 | 31 | /** 32 | * 个人网站 33 | */ 34 | @ApiModelProperty(name = "webSite", value = "个人网站", dataType = "String") 35 | private String webSite; 36 | } 37 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/vo/UserRoleVO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import javax.validation.constraints.NotBlank; 8 | import javax.validation.constraints.NotNull; 9 | 10 | /** 11 | * 12 | * @author xiaojie 13 | * @since 2020-05-18 14 | */ 15 | @Data 16 | @ApiModel(description = "用户权限") 17 | public class UserRoleVO { 18 | /** 19 | * 用户昵称 20 | */ 21 | @NotNull(message = "id不能为空") 22 | @ApiModelProperty(name = "userInfoId", value = "用户信息id", dataType = "Integer") 23 | private Integer userInfoId; 24 | 25 | /** 26 | * 用户昵称 27 | */ 28 | @NotBlank(message = "昵称不能为空") 29 | @ApiModelProperty(name = "nickname", value = "昵称", dataType = "String") 30 | private String nickname; 31 | 32 | /** 33 | * 用户权限 34 | */ 35 | @NotBlank(message = "用户权限不能为空") 36 | @ApiModelProperty(name = "userRole", value = "权限", dataType = "String") 37 | private String userRole; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /blog-springboot/src/main/java/com/minzheng/blog/vo/UserVO.java: -------------------------------------------------------------------------------- 1 | package com.minzheng.blog.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import javax.validation.constraints.Email; 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.Size; 10 | 11 | /** 12 | * @author 11921 13 | */ 14 | @Data 15 | @ApiModel(description = "用户注册") 16 | public class UserVO { 17 | /** 18 | * 用户名 19 | */ 20 | @NotBlank(message = "邮箱不能为空") 21 | @Email(message = "邮箱格式不正确") 22 | @ApiModelProperty(name = "username", value = "用户名", required = true, dataType = "String") 23 | private String username; 24 | 25 | /** 26 | * 密码 27 | */ 28 | @Size(min = 6, message = "密码不能少于6位") 29 | @NotBlank(message = "密码不能为空") 30 | @ApiModelProperty(name = "password", value = "密码", required = true, dataType = "String") 31 | private String password; 32 | 33 | /** 34 | * 验证码 35 | */ 36 | @NotBlank(message = "验证码不能为空") 37 | @ApiModelProperty(name = "code", value = "邮箱验证码", required = true, dataType = "String") 38 | private String code; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /blog-springboot/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | #配置端口 2 | server: 3 | port: 8080 4 | 5 | #配置mysql数据库 6 | spring: 7 | datasource: 8 | type: com.zaxxer.hikari.HikariDataSource 9 | driver-class-name: com.mysql.cj.jdbc.Driver 10 | url: jdbc:mysql://你的ip:3306/blog?serverTimezone=GMT%2B8&allowMultiQueries=true 11 | username: 数据库账号 12 | password: 数据库密码 13 | hikari: 14 | minimum-idle: 5 15 | # 空闲连接存活最大时间,默认600000(10分钟) 16 | idle-timeout: 180000 17 | # 连接池最大连接数,默认是10 18 | maximum-pool-size: 10 19 | # 此属性控制从池返回的连接的默认自动提交行为,默认值:true 20 | auto-commit: true 21 | # 连接池名称 22 | pool-name: MyHikariCP 23 | # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟 24 | max-lifetime: 1800000 25 | # 数据库连接超时时间,默认30秒,即30000 26 | connection-timeout: 30000 27 | connection-test-query: SELECT 1 28 | #redis配置 29 | redis: 30 | host: 你的密码 31 | port: 6379 32 | password: Redis密码 33 | #es配置 34 | data: 35 | elasticsearch: 36 | cluster-name: elasticsearch 37 | cluster-nodes: 服务器ip:9300 38 | #mq配置 39 | rabbitmq: 40 | host: 服务器ip 41 | port: 5672 42 | username: MQ账号 43 | password: MQ密码 44 | #邮箱配置 45 | mail: 46 | host: smtp.qq.com 47 | username: 邮箱号 48 | password: 邮箱授权码 49 | default-encoding: UTF-8 50 | port: 587 51 | properties: 52 | mail: 53 | smtp: 54 | auth: true 55 | socketFactory: 56 | class: javax.net.ssl.SSLSocketFactory 57 | #图片大小限制 58 | servlet: 59 | multipart: 60 | max-file-size: 40MB 61 | max-request-size: 100MB 62 | 63 | #配置MybatisPlus 64 | mybatis-plus: 65 | mapper-locations: classpath:mapper/*.xml 66 | configuration: 67 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 68 | map-underscore-to-camel-case: true 69 | 70 | #第三方配置信息 71 | qq: 72 | app-id: "QQ APPID" 73 | user-info-url: "https://graph.qq.com/user/get_user_info?openid={openid}&access_token={access_token}&oauth_consumer_key={oauth_consumer_key}" 74 | 75 | weibo: 76 | app-id: "微博APPID" 77 | app-secret: "微博APP密钥" 78 | grant-type: "authorization_code" 79 | redirect-url: "微博回调域名" 80 | access-token-url: "https://api.weibo.com/oauth2/access_token" 81 | user-info-url: "https://api.weibo.com/2/users/show.json?uid={uid}&access_token={access_token}" 82 | 83 | aliyun: 84 | url: "OSS域名" 85 | endpoint: "http://oss-cn-hangzhou.aliyuncs.com" 86 | accessKeyId: "阿里云accessKeyId" 87 | accessKeySecret: "阿里云accessKeySecret" 88 | bucketName: "阿里云bucket名" 89 | 90 | 91 | -------------------------------------------------------------------------------- /blog-springboot/src/main/resources/mapper/CategoryDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /blog-springboot/src/main/resources/mapper/UniqueViewDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /blog-springboot/src/main/resources/mapper/UserAuthDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 28 | 29 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /blog-vue/admin/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | pnpm-debug.log* 14 | 15 | # Editor directories and files 16 | .idea 17 | .vscode 18 | *.suo 19 | *.ntvs* 20 | *.njsproj 21 | *.sln 22 | *.sw? 23 | -------------------------------------------------------------------------------- /blog-vue/admin/README.md: -------------------------------------------------------------------------------- 1 | # admins 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 | ### Run your tests 19 | ``` 20 | npm run test 21 | ``` 22 | 23 | ### Lints and fixes files 24 | ``` 25 | npm run lint 26 | ``` 27 | 28 | ### Customize configuration 29 | See [Configuration Reference](https://cli.vuejs.org/config/). 30 | -------------------------------------------------------------------------------- /blog-vue/admin/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["@vue/cli-plugin-babel/preset"] 3 | }; 4 | -------------------------------------------------------------------------------- /blog-vue/admin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "admins", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "axios": "^0.19.2", 12 | "core-js": "^3.6.5", 13 | "echarts": "^4.8.0", 14 | "element-ui": "^2.13.2", 15 | "mavon-editor": "^2.9.0", 16 | "moment": "^2.26.0", 17 | "vue": "^2.6.11", 18 | "vue-axios": "^2.1.5", 19 | "vue-echarts": "^5.0.0-beta.0", 20 | "vue-router": "^3.2.0", 21 | "vuex": "^3.4.0", 22 | "vuex-persistedstate": "^3.0.1" 23 | }, 24 | "devDependencies": { 25 | "@vue/cli-plugin-babel": "^4.4.0", 26 | "@vue/cli-plugin-eslint": "^4.4.0", 27 | "@vue/cli-service": "^4.4.0", 28 | "@vue/eslint-config-prettier": "^6.0.0", 29 | "babel-eslint": "^10.1.0", 30 | "eslint": "^6.7.2", 31 | "eslint-plugin-prettier": "^3.1.3", 32 | "eslint-plugin-vue": "^6.2.2", 33 | "prettier": "^1.19.1", 34 | "vue-template-compiler": "^2.6.11" 35 | }, 36 | "eslintConfig": { 37 | "root": true, 38 | "env": { 39 | "node": true 40 | }, 41 | "extends": [ 42 | "plugin:vue/essential", 43 | "eslint:recommended", 44 | "@vue/prettier" 45 | ], 46 | "parserOptions": { 47 | "parser": "babel-eslint" 48 | }, 49 | "rules": {} 50 | }, 51 | "browserslist": [ 52 | "> 1%", 53 | "last 2 versions", 54 | "not dead" 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /blog-vue/admin/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/min-lj/Blog/acff796dcb0985833e396a4bd6bafcfa578d72a2/blog-vue/admin/public/favicon.ico -------------------------------------------------------------------------------- /blog-vue/admin/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 后台管理系统 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /blog-vue/admin/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /blog-vue/admin/src/assets/css/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/min-lj/Blog/acff796dcb0985833e396a4bd6bafcfa578d72a2/blog-vue/admin/src/assets/css/iconfont.eot -------------------------------------------------------------------------------- /blog-vue/admin/src/assets/css/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/min-lj/Blog/acff796dcb0985833e396a4bd6bafcfa578d72a2/blog-vue/admin/src/assets/css/iconfont.ttf -------------------------------------------------------------------------------- /blog-vue/admin/src/assets/css/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/min-lj/Blog/acff796dcb0985833e396a4bd6bafcfa578d72a2/blog-vue/admin/src/assets/css/iconfont.woff -------------------------------------------------------------------------------- /blog-vue/admin/src/assets/css/iconfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/min-lj/Blog/acff796dcb0985833e396a4bd6bafcfa578d72a2/blog-vue/admin/src/assets/css/iconfont.woff2 -------------------------------------------------------------------------------- /blog-vue/admin/src/assets/css/index.css: -------------------------------------------------------------------------------- 1 | body{ 2 | padding: 0; 3 | margin: 0; 4 | } 5 | .main-card{ 6 | min-height: calc(100vh - 126px); 7 | } 8 | .operation-container { 9 | display: flex; 10 | align-items: center; 11 | margin-bottom: 1.25rem; 12 | } 13 | .pagination-container { 14 | float: right; 15 | margin-top: 1.25rem; 16 | margin-bottom: 1.25rem; 17 | } 18 | .dialog-title-container { 19 | display: flex; 20 | align-items: center; 21 | font-weight: bold; 22 | } 23 | .dialog-title-container i { 24 | font-size: 1.5rem; 25 | margin-right: 0.5rem; 26 | } 27 | .v-note-wrapper.fullscreen { 28 | height: 100vh !important; 29 | } -------------------------------------------------------------------------------- /blog-vue/admin/src/layout/components/SideBar.vue: -------------------------------------------------------------------------------- 1 | 41 | 42 | 56 | -------------------------------------------------------------------------------- /blog-vue/admin/src/layout/index.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 35 | 36 | 46 | -------------------------------------------------------------------------------- /blog-vue/admin/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import App from "./App.vue"; 3 | import router from "./router"; 4 | import store from "./store"; 5 | import ElementUI from "element-ui"; 6 | import "element-ui/lib/theme-chalk/index.css"; 7 | import "./assets/css/index.css"; 8 | import "./assets/css/iconfont.css"; 9 | import axios from "axios"; 10 | import VueAxios from "vue-axios"; 11 | import ECharts from "vue-echarts"; 12 | import "echarts/lib/chart/line"; 13 | import "echarts/lib/chart/pie"; 14 | import "echarts/lib/chart/bar"; 15 | import "echarts/lib/component/tooltip"; 16 | import "echarts/lib/component/legend"; 17 | import "echarts/lib/component/title"; 18 | import mavonEditor from "mavon-editor"; 19 | import "mavon-editor/dist/css/index.css"; 20 | import moment from "moment"; 21 | 22 | Vue.use(mavonEditor); 23 | Vue.component("v-chart", ECharts); 24 | Vue.use(VueAxios, axios); 25 | Vue.use(ElementUI); 26 | Vue.config.productionTip = false; 27 | Vue.prototype.$moment = moment; 28 | Vue.filter("date", function(value, formatStr = "YYYY-MM-DD") { 29 | return moment(value).format(formatStr); 30 | }); 31 | 32 | router.beforeEach((to, from, next) => { 33 | if (to.meta.requireAuth) { 34 | // 判断该路由是否需要管理员权限 35 | if (store.state.userRole == "admin" || store.state.userRole == "test") { 36 | next(); 37 | } else { 38 | Vue.prototype.$message({ 39 | type: "error", 40 | message: "无权限查看此页面" 41 | }); 42 | next({ 43 | path: "/login", 44 | query: { redirect: to.fullPath } 45 | }); 46 | } 47 | } else { 48 | next(); 49 | } 50 | }); 51 | 52 | new Vue({ 53 | router, 54 | store, 55 | render: h => h(App) 56 | }).$mount("#app"); 57 | -------------------------------------------------------------------------------- /blog-vue/admin/src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import Vuex from "vuex"; 3 | import createPersistedState from "vuex-persistedstate"; 4 | 5 | Vue.use(Vuex); 6 | 7 | export default new Vuex.Store({ 8 | state: { 9 | collapse: false, 10 | tabList: [{ name: "首页", path: "/" }], 11 | userId: null, 12 | userRole: null, 13 | avatar: null, 14 | nickname: null, 15 | intro: null, 16 | webSite: null 17 | }, 18 | mutations: { 19 | saveTab(state, tab) { 20 | if (state.tabList.findIndex(item => item.path === tab.path) == -1) { 21 | state.tabList.push({ name: tab.name, path: tab.path }); 22 | } 23 | }, 24 | removeTab(state, tab) { 25 | var index = state.tabList.findIndex(item => item.name === tab.name); 26 | state.tabList.splice(index, 1); 27 | }, 28 | resetTab(state) { 29 | state.tabList = [{ name: "首页", path: "/" }]; 30 | }, 31 | trigger(state) { 32 | state.collapse = !state.collapse; 33 | }, 34 | login(state, user) { 35 | state.userId = user.userInfoId; 36 | state.userRole = user.userRole; 37 | state.avatar = user.avatar; 38 | state.nickname = user.nickname; 39 | state.intro = user.intro; 40 | state.webSite = user.webSite; 41 | }, 42 | logout(state) { 43 | state.userId = null; 44 | state.userRole = null; 45 | state.avatar = null; 46 | state.nickname = null; 47 | state.intro = null; 48 | state.webSite = null; 49 | }, 50 | updateAvatar(state, avatar) { 51 | state.avatar = avatar; 52 | }, 53 | updateUserInfo(state, user) { 54 | state.nickname = user.nickname; 55 | state.intro = user.intro; 56 | state.webSite = user.webSite; 57 | } 58 | }, 59 | actions: {}, 60 | modules: {}, 61 | plugins: [ 62 | createPersistedState({ 63 | storage: window.sessionStorage 64 | }) 65 | ] 66 | }); 67 | -------------------------------------------------------------------------------- /blog-vue/admin/src/views/about/About.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 51 | 52 | 58 | -------------------------------------------------------------------------------- /blog-vue/admin/src/views/login/Login.vue: -------------------------------------------------------------------------------- 1 | 38 | 39 | 88 | 89 | 121 | -------------------------------------------------------------------------------- /blog-vue/admin/src/views/swagger/Swagger.vue: -------------------------------------------------------------------------------- 1 |