├── doc ├── requirement.doc ├── website.xmind └── chiner │ ├── codingmore-architecture.png │ └── codingmore-2022116145356.docx ├── dump.rdb ├── .gitattributes ├── codingmore-admin ├── src │ ├── main │ │ ├── resources │ │ │ ├── META-INF │ │ │ │ └── spring-devtools.properties │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── codingmore │ │ │ ├── service │ │ │ ├── IOssService.java │ │ │ ├── ISiteService.java │ │ │ ├── ILinksService.java │ │ │ ├── ICommentsService.java │ │ │ ├── IPostTagRelationService.java │ │ │ ├── IResourceCategoryService.java │ │ │ ├── IResourceService.java │ │ │ ├── IRoleMenuRelationService.java │ │ │ ├── ITermRelationshipsService.java │ │ │ ├── IAdminRoleRelationService.java │ │ │ ├── IRoleResourceRelationService.java │ │ │ ├── IMenuService.java │ │ │ ├── impl │ │ │ │ ├── SiteServiceImpl.java │ │ │ │ ├── LinksServiceImpl.java │ │ │ │ ├── CommentsServiceImpl.java │ │ │ │ ├── PostTagRelationServiceImpl.java │ │ │ │ ├── ResourceCategoryServiceImpl.java │ │ │ │ ├── RoleMenuRelationServiceImpl.java │ │ │ │ ├── AdminRoleRelationServiceImpl.java │ │ │ │ ├── TermRelationshipsServiceImpl.java │ │ │ │ ├── RoleResourceRelationServiceImpl.java │ │ │ │ ├── ResourceServiceImpl.java │ │ │ │ └── MenuServiceImpl.java │ │ │ ├── IScheduleService.java │ │ │ ├── IPostTagService.java │ │ │ ├── ITermTaxonomyService.java │ │ │ ├── IUsersCacheService.java │ │ │ ├── IRoleService.java │ │ │ ├── IPostsService.java │ │ │ └── IUsersService.java │ │ │ ├── controller │ │ │ ├── PostTagRelationController.java │ │ │ ├── LinksController.java │ │ │ ├── TermRelationshipsController.java │ │ │ ├── CommentsController.java │ │ │ └── OssController.java │ │ │ ├── CodingmoreAdminBootstrap.java │ │ │ ├── config │ │ │ ├── OssClientConfig.java │ │ │ ├── MyBatisConfig.java │ │ │ ├── GlobalCorsConfig.java │ │ │ ├── WebConfigBeans.java │ │ │ ├── TreadPoolConfig.java │ │ │ └── CodingmoreSecurityConfig.java │ │ │ └── component │ │ │ └── PublishPostJob.java │ └── test │ │ ├── java │ │ └── com │ │ │ └── codingmore │ │ │ ├── CacheDemoService.java │ │ │ ├── CacheDemoServiceImpl.java │ │ │ └── CodingmoreRedisApplicationTests.java │ │ └── resources │ │ ├── application.yml │ │ ├── logback-test.xml │ │ └── application-dev.yml ├── Dockerfile └── pom.xml ├── codingmore-web ├── src │ ├── main │ │ ├── resources │ │ │ ├── META-INF │ │ │ │ └── spring-devtools.properties │ │ │ ├── static │ │ │ │ ├── images │ │ │ │ │ ├── zan.png │ │ │ │ │ ├── search.png │ │ │ │ │ ├── comment.png │ │ │ │ │ ├── demo-ad.png │ │ │ │ │ ├── demo-pic1.png │ │ │ │ │ ├── demo-pic2.png │ │ │ │ │ ├── demo-pic3.png │ │ │ │ │ ├── demo-pic4.png │ │ │ │ │ ├── demo-pic5.png │ │ │ │ │ ├── itwanger.png │ │ │ │ │ ├── menu-icon.png │ │ │ │ │ ├── reflesh.png │ │ │ │ │ ├── back-to-top.png │ │ │ │ │ ├── close-white.png │ │ │ │ │ ├── gonganbeian.png │ │ │ │ │ ├── logo-ontab.png │ │ │ │ │ ├── logo-ontop.jpg │ │ │ │ │ ├── planet-icon.png │ │ │ │ │ ├── read-count.png │ │ │ │ │ ├── right-pic1.png │ │ │ │ │ ├── like-clicked.png │ │ │ │ │ ├── like-unclicked.png │ │ │ │ │ ├── loading-more.gif │ │ │ │ │ ├── wanger-qrcode.png │ │ │ │ │ ├── menu-close-icon.png │ │ │ │ │ ├── search-pre-icon.png │ │ │ │ │ ├── article-cover-demo.jpg │ │ │ │ │ └── logo-without-name.ico │ │ │ │ ├── js │ │ │ │ │ ├── index.v2.test.js │ │ │ │ │ └── article.js │ │ │ │ ├── plugins │ │ │ │ │ └── nprogress │ │ │ │ │ │ └── nprogress.css │ │ │ │ └── css │ │ │ │ │ ├── github.min.css │ │ │ │ │ └── index.css │ │ │ ├── application.yml │ │ │ ├── logback-spring.xml │ │ │ └── application-dev.yml │ │ └── java │ │ │ └── com │ │ │ └── codingmore │ │ │ ├── service │ │ │ ├── ILearnWebRequestStrategy.java │ │ │ ├── ISiteService.java │ │ │ ├── ILinksService.java │ │ │ ├── ICommentsService.java │ │ │ ├── IUsersService.java │ │ │ ├── IPostTagRelationService.java │ │ │ ├── ITermRelationshipsService.java │ │ │ ├── impl │ │ │ │ ├── ChannelPageRequestStrategy.java │ │ │ │ ├── SiteServiceImpl.java │ │ │ │ ├── LinksServiceImpl.java │ │ │ │ ├── CommentsServiceImpl.java │ │ │ │ ├── PostTagRelationServiceImpl.java │ │ │ │ ├── TermRelationshipsServiceImpl.java │ │ │ │ ├── UsersServiceImpl.java │ │ │ │ ├── PostTagServiceImpl.java │ │ │ │ └── ContentPageRequestStrategy.java │ │ │ ├── IPostTagService.java │ │ │ ├── ITermTaxonomyService.java │ │ │ └── IPostsService.java │ │ │ ├── CodingmoreWebBootstrap.java │ │ │ ├── config │ │ │ ├── MyBatisConfig.java │ │ │ ├── WebConfigBeans.java │ │ │ └── SwaggerConfig.java │ │ │ └── util │ │ │ ├── CusAccessObjectUtil.java │ │ │ └── DateConverter.java │ └── test │ │ └── resources │ │ └── logback-test.xml └── pom.xml ├── codingmore-common ├── src │ └── main │ │ └── java │ │ └── com │ │ └── codingmore │ │ ├── state │ │ ├── PostType.java │ │ ├── PostStatus.java │ │ ├── UserStatus.java │ │ ├── UserType.java │ │ └── TermRelationType.java │ │ ├── webapi │ │ ├── IErrorCode.java │ │ └── ResultCode.java │ │ ├── exception │ │ ├── Asserts.java │ │ ├── GlobalExceptionHandler.java │ │ └── ApiException.java │ │ ├── util │ │ └── FileNameUtil.java │ │ ├── assist │ │ └── RedisConstants.java │ │ └── component │ │ ├── DateConverter.java │ │ └── BindingResultAspect.java └── pom.xml ├── codingmore-security ├── src │ └── main │ │ └── java │ │ └── com │ │ └── codingmore │ │ ├── annotation │ │ └── CacheException.java │ │ ├── component │ │ ├── DynamicSecurityService.java │ │ ├── RestAuthenticationEntryPoint.java │ │ ├── RestfulAccessDeniedHandler.java │ │ ├── DynamicAccessDecisionManager.java │ │ └── DynamicSecurityMetadataSource.java │ │ ├── config │ │ └── IgnoreUrlsConfig.java │ │ ├── util │ │ └── SpringUtil.java │ │ ├── aspect │ │ └── RedisCacheAspect.java │ │ └── model │ │ └── AdminUserDetails.java └── pom.xml ├── codingmore-mbg ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── codingmore │ │ │ │ ├── mapper │ │ │ │ ├── MenuMapper.java │ │ │ │ ├── SiteMapper.java │ │ │ │ ├── LinksMapper.java │ │ │ │ ├── PostTagMapper.java │ │ │ │ ├── CommentsMapper.java │ │ │ │ ├── ResourceMapper.java │ │ │ │ ├── TermTaxonomyMapper.java │ │ │ │ ├── PostTagRelationMapper.java │ │ │ │ ├── ResourceCategoryMapper.java │ │ │ │ ├── RoleMenuRelationMapper.java │ │ │ │ ├── TermRelationshipsMapper.java │ │ │ │ ├── RoleResourceRelationMapper.java │ │ │ │ ├── UsersMapper.java │ │ │ │ ├── AdminRoleRelationMapper.java │ │ │ │ ├── PostsMapper.java │ │ │ │ └── RoleMapper.java │ │ │ │ ├── dto │ │ │ │ ├── MenuNode.java │ │ │ │ ├── RolePageQueryParam.java │ │ │ │ ├── UsersPageQueryParam.java │ │ │ │ ├── UpdateAdminPasswordParam.java │ │ │ │ ├── UsersLoginParam.java │ │ │ │ ├── PostAddTagParam.java │ │ │ │ ├── PostTagParam.java │ │ │ │ ├── UsersParamUpdate.java │ │ │ │ ├── ResourceCategoryParam.java │ │ │ │ ├── TermTaxonomyParam.java │ │ │ │ ├── SiteParam.java │ │ │ │ ├── ResourceParam.java │ │ │ │ ├── RoleParam.java │ │ │ │ ├── UsersParam.java │ │ │ │ ├── MenuParam.java │ │ │ │ ├── PostsParam.java │ │ │ │ └── PostsPageQueryParam.java │ │ │ │ ├── vo │ │ │ │ ├── IndexTermTaxonomyPostVo.java │ │ │ │ ├── IContainerFactory.java │ │ │ │ ├── TermTaxonomyTreeNode.java │ │ │ │ ├── BaseVO.java │ │ │ │ ├── RoleVo.java │ │ │ │ ├── SiteVo.java │ │ │ │ └── PostsVo.java │ │ │ │ ├── model │ │ │ │ ├── PostTag.java │ │ │ │ ├── RoleMenuRelation.java │ │ │ │ ├── AdminRoleRelation.java │ │ │ │ ├── RoleResourceRelation.java │ │ │ │ ├── PostTagRelation.java │ │ │ │ ├── ResourceCategory.java │ │ │ │ ├── TermRelationships.java │ │ │ │ ├── Role.java │ │ │ │ ├── Resource.java │ │ │ │ ├── Links.java │ │ │ │ ├── Menu.java │ │ │ │ ├── Site.java │ │ │ │ ├── TermTaxonomy.java │ │ │ │ ├── Comments.java │ │ │ │ ├── Users.java │ │ │ │ └── Posts.java │ │ │ │ └── util │ │ │ │ └── DateUtil.java │ │ └── resources │ │ │ └── com │ │ │ └── codingmore │ │ │ └── mapper │ │ │ ├── PostTagMapper.xml │ │ │ ├── PostTagRelationMapper.xml │ │ │ ├── RoleMenuRelationMapper.xml │ │ │ ├── RoleResourceRelationMapper.xml │ │ │ ├── ResourceCategoryMapper.xml │ │ │ ├── TermRelationshipsMapper.xml │ │ │ ├── ResourceMapper.xml │ │ │ ├── SiteMapper.xml │ │ │ ├── MenuMapper.xml │ │ │ ├── LinksMapper.xml │ │ │ ├── TermTaxonomyMapper.xml │ │ │ ├── CommentsMapper.xml │ │ │ ├── UsersMapper.xml │ │ │ └── AdminRoleRelationMapper.xml │ └── test │ │ └── resources │ │ └── logback-test.xml └── pom.xml └── .gitignore /doc/requirement.doc: -------------------------------------------------------------------------------- 1 | 需求 -------------------------------------------------------------------------------- /dump.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/dump.rdb -------------------------------------------------------------------------------- /doc/website.xmind: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/doc/website.xmind -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.js linguist-language=java 3 | *.css linguist-language=java 4 | *.html linguist-language=java 5 | -------------------------------------------------------------------------------- /doc/chiner/codingmore-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/doc/chiner/codingmore-architecture.png -------------------------------------------------------------------------------- /codingmore-admin/src/main/resources/META-INF/spring-devtools.properties: -------------------------------------------------------------------------------- 1 | restart.include.projectcommon=/spring-cloud-openfeign-[\\w.-]+.jar -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/META-INF/spring-devtools.properties: -------------------------------------------------------------------------------- 1 | restart.include.projectcommon=/spring-cloud-openfeign-[\\w.-]+.jar -------------------------------------------------------------------------------- /doc/chiner/codingmore-2022116145356.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/doc/chiner/codingmore-2022116145356.docx -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/zan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/zan.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/search.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/comment.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/demo-ad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/demo-ad.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/demo-pic1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/demo-pic1.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/demo-pic2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/demo-pic2.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/demo-pic3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/demo-pic3.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/demo-pic4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/demo-pic4.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/demo-pic5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/demo-pic5.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/itwanger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/itwanger.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/menu-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/menu-icon.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/reflesh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/reflesh.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/back-to-top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/back-to-top.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/close-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/close-white.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/gonganbeian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/gonganbeian.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/logo-ontab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/logo-ontab.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/logo-ontop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/logo-ontop.jpg -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/planet-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/planet-icon.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/read-count.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/read-count.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/right-pic1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/right-pic1.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/like-clicked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/like-clicked.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/like-unclicked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/like-unclicked.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/loading-more.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/loading-more.gif -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/wanger-qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/wanger-qrcode.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/menu-close-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/menu-close-icon.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/search-pre-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/search-pre-icon.png -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/article-cover-demo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/article-cover-demo.jpg -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/images/logo-without-name.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itwanger/coding-more/HEAD/codingmore-web/src/main/resources/static/images/logo-without-name.ico -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/state/PostType.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.state; 2 | 3 | /** 4 | * 文章类型 5 | */ 6 | public enum PostType { 7 | /** 8 | * 内容 9 | */ 10 | POST, 11 | /** 12 | * 页面 13 | */ 14 | PAGE; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/webapi/IErrorCode.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.webapi; 2 | 3 | /** 4 | * 封装API的错误码 5 | * Created by zhanglei on 2019/4/19. 6 | */ 7 | public interface IErrorCode { 8 | long getCode(); 9 | 10 | String getMessage(); 11 | } 12 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/ILearnWebRequestStrategy.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.util.WebRequestParam; 4 | 5 | /** 6 | * 前端请求处理策略 7 | */ 8 | public interface ILearnWebRequestStrategy { 9 | String handleRequest(WebRequestParam webRequestParam); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /codingmore-security/src/main/java/com/codingmore/annotation/CacheException.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * 自定义注解,有该注解的缓存方法会抛出异常 7 | */ 8 | @Documented 9 | @Target(ElementType.METHOD) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | public @interface CacheException { 12 | } 13 | -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/state/PostStatus.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.state; 2 | 3 | /** 4 | * 文章发布状态 5 | */ 6 | public enum PostStatus { 7 | /** 8 | * 发布 9 | */ 10 | PUBLISHED, 11 | /** 12 | * 删除 13 | */ 14 | DELETED, 15 | /** 16 | * 草稿箱 17 | */ 18 | DRAFT; 19 | 20 | } -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IOssService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import org.springframework.web.multipart.MultipartFile; 4 | 5 | import java.io.InputStream; 6 | 7 | public interface IOssService { 8 | String upload(String url); 9 | String upload(MultipartFile file); 10 | boolean needUpload(String imageUrl); 11 | } -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/state/UserStatus.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.state; 2 | 3 | 4 | public enum UserStatus { 5 | ENABLE(0), 6 | DISABLED(1); 7 | private int status; 8 | 9 | UserStatus(int status) { 10 | this.status = status; 11 | } 12 | 13 | public int getStatus() { 14 | return status; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/state/UserType.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.state; 2 | 3 | 4 | public enum UserType { 5 | BACKEND(0), 6 | FRONT(1); 7 | private int userType; 8 | 9 | UserType(int userType) { 10 | this.userType = userType; 11 | } 12 | 13 | public int getUserType() { 14 | return userType; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/ISiteService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.Site; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 站点 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface ISiteService extends IService { 15 | } 16 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/ISiteService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.Site; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 站点 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface ISiteService extends IService { 15 | } 16 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/MenuMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.model.Menu; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * 后台菜单表 Mapper 接口 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2022-03-03 13 | */ 14 | public interface MenuMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/SiteMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.model.Site; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * 站点 Mapper 接口 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface SiteMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-admin/src/test/java/com/codingmore/CacheDemoService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore; 2 | 3 | import org.springframework.cache.annotation.Cacheable; 4 | import org.springframework.cache.annotation.Caching; 5 | 6 | /** 7 | * 微信搜索「沉默王二」,回复 Java 8 | * 9 | * @author 沉默王二 10 | * @date 6/16/22 11 | */ 12 | public interface CacheDemoService { 13 | Object getFromDB(Integer id); 14 | } 15 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/LinksMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.model.Links; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * 链接信息表 Mapper 接口 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface LinksMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/ILinksService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.Links; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 链接信息表 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface ILinksService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/PostTagMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.model.PostTag; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * 标签表 Mapper 接口 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface PostTagMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/ILinksService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.Links; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 链接信息表 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface ILinksService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/CommentsMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.model.Comments; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * 评论表 Mapper 接口 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface CommentsMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/ICommentsService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.Comments; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 评论表 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface ICommentsService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/ResourceMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.model.Resource; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * 后台资源表 Mapper 接口 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2022-03-03 13 | */ 14 | public interface ResourceMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/ICommentsService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.Comments; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 评论表 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface ICommentsService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/IUsersService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.Users; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | /** 6 | *

7 | * 用户表 服务类 8 | *

9 | * 10 | * @author 石磊 11 | * @since 2021-09-12 12 | */ 13 | public interface IUsersService extends IService { 14 | 15 | 16 | 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/TermTaxonomyMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.model.TermTaxonomy; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * 栏目 Mapper 接口 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface TermTaxonomyMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IPostTagRelationService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.PostTagRelation; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 标签文章关系表 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface IPostTagRelationService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/PostTagRelationMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.model.PostTagRelation; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * 标签文章关系表 Mapper 接口 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface PostTagRelationMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/ResourceCategoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.model.ResourceCategory; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * 资源分类表 Mapper 接口 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2022-03-03 13 | */ 14 | public interface ResourceCategoryMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/IPostTagRelationService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.PostTagRelation; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 标签文章关系表 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface IPostTagRelationService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IResourceCategoryService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.ResourceCategory; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 资源分类表 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2022-03-03 13 | */ 14 | public interface IResourceCategoryService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/RoleMenuRelationMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.model.RoleMenuRelation; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * 后台角色菜单关系表 Mapper 接口 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2022-03-03 13 | */ 14 | public interface RoleMenuRelationMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/TermRelationshipsMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.model.TermRelationships; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * 文章属性关系表 Mapper 接口 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface TermRelationshipsMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-security/src/main/java/com/codingmore/component/DynamicSecurityService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.component; 2 | 3 | import org.springframework.security.access.ConfigAttribute; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * 动态权限相关业务类 9 | * on 2020/2/7. 10 | */ 11 | public interface DynamicSecurityService { 12 | /** 13 | * 加载资源ANT通配符和资源对应MAP 14 | */ 15 | Map loadDataSource(); 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IResourceService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.Resource; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 后台资源表 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2022-03-03 13 | */ 14 | public interface IResourceService extends IService { 15 | boolean remove(Long resourceId); 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IRoleMenuRelationService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.RoleMenuRelation; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 后台角色菜单关系表 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2022-03-05 13 | */ 14 | public interface IRoleMenuRelationService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/ITermRelationshipsService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.TermRelationships; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 文章属性关系表 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface ITermRelationshipsService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/ITermRelationshipsService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.TermRelationships; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 文章属性关系表 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | public interface ITermRelationshipsService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IAdminRoleRelationService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.AdminRoleRelation; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 后台用户和角色关系表 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2022-03-05 13 | */ 14 | public interface IAdminRoleRelationService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/MenuNode.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import com.codingmore.model.Menu; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 后台菜单节点封装 11 | * Created by 石磊 on 2020/2/4. 12 | */ 13 | @Data 14 | public class MenuNode extends Menu { 15 | @ApiModelProperty(value = "子级菜单") 16 | private List children; 17 | } 18 | -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/exception/Asserts.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.exception; 2 | 3 | import com.codingmore.webapi.IErrorCode; 4 | 5 | /** 6 | * 断言处理类,用于抛出各种API异常 7 | */ 8 | public class Asserts { 9 | public static void fail(String message) { 10 | throw new ApiException(message); 11 | } 12 | 13 | public static void fail(IErrorCode errorCode) { 14 | throw new ApiException(errorCode); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/RoleResourceRelationMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.model.RoleResourceRelation; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | *

8 | * 后台角色资源关系表 Mapper 接口 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2022-03-03 13 | */ 14 | public interface RoleResourceRelationMapper extends BaseMapper { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IRoleResourceRelationService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.RoleResourceRelation; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | *

8 | * 后台角色资源关系表 服务类 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2022-03-05 13 | */ 14 | public interface IRoleResourceRelationService extends IService { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/CodingmoreWebBootstrap.java: -------------------------------------------------------------------------------- 1 | package com.codingmore; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * 前台展示系统接口 8 | */ 9 | @SpringBootApplication 10 | public class CodingmoreWebBootstrap { 11 | public static void main(String[] args) { 12 | SpringApplication.run(CodingmoreWebBootstrap.class); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/vo/IndexTermTaxonomyPostVo.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.vo; 2 | 3 | import java.util.List; 4 | 5 | import com.codingmore.model.Posts; 6 | import com.codingmore.model.Site; 7 | import com.codingmore.model.TermTaxonomy; 8 | 9 | import lombok.Data; 10 | 11 | /** 12 | * 首页栏目文章列表 13 | */ 14 | @Data 15 | public class IndexTermTaxonomyPostVo { 16 | private TermTaxonomy termTaxonomy; 17 | private List posts; 18 | } 19 | -------------------------------------------------------------------------------- /codingmore-admin/Dockerfile: -------------------------------------------------------------------------------- 1 | #使用jdk8作为基础镜像 2 | FROM java:8 3 | #指定作者 4 | MAINTAINER tom 5 | #暴漏容器的8088端口 6 | EXPOSE 9002 7 | #将复制指定的docker-demo-0.0.1-SNAPSHOT.jar为容器中的job.jar,相当于拷贝到容器中取了个别名 8 | ADD target/learn-admin-1.0-SNAPSHOT.jar /test.jar 9 | #创建一个新的容器并在新的容器中运行命令 10 | RUN bash -c 'touch /job.jar' 11 | #设置时区 12 | ENV TZ=PRC 13 | RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone 14 | #相当于在容器中用cmd命令执行jar包 指定外部配置文件 15 | ENTRYPOINT ["java","-jar","/job.jar"] 16 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/controller/PostTagRelationController.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.stereotype.Controller; 5 | 6 | /** 7 | *

8 | * 标签文章关系表 前端控制器 9 | *

10 | * 11 | * @author 石磊 12 | * @since 2021-09-12 13 | */ 14 | @Controller 15 | @RequestMapping("/postTagRelation") 16 | public class PostTagRelationController { 17 | 18 | } 19 | 20 | -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/js/index.v2.test.js: -------------------------------------------------------------------------------- 1 | $(() => { 2 | 3 | let totalHtml = '' 4 | for (let i = 0; i < 27; i++) { 5 | const isHide = i >= 7 ? true: false 6 | const tempHtml = getFakeArticleHtml(isHide) 7 | totalHtml += tempHtml 8 | } 9 | // $('.article-list').append(totalHtml) 10 | }) 11 | 12 | 13 | function getFakeArticleHtml(isHide) { 14 | 15 | let finallHtml = $('.article-list > .article-item').eq(0)[0].outerHTML 16 | return finallHtml; 17 | } -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/RolePageQueryParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | @Data 9 | @EqualsAndHashCode(callSuper = false) 10 | @ApiModel(value="Role对象", description="角色") 11 | public class RolePageQueryParam { 12 | long pageSize; 13 | long page; 14 | @ApiModelProperty(value = "关键字") 15 | String keyword; 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/controller/LinksController.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.controller; 2 | 3 | 4 | import io.swagger.annotations.Api; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | import org.springframework.stereotype.Controller; 8 | 9 | /** 10 | *

11 | * 链接信息表 前端控制器 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2021-05-22 16 | */ 17 | @Controller 18 | @RequestMapping("/links") 19 | @Api(tags="链接信息") 20 | public class LinksController { 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/vo/IContainerFactory.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.vo; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * 微信搜索「沉默王二」,回复 Java 8 | * 9 | * @author 沉默王二 10 | * @date 4/28/22 11 | */ 12 | public interface IContainerFactory { 13 | IContainerFactory defaultContainerFactory = new IContainerFactory() { 14 | public Map getAttrsMap() { 15 | return new HashMap(); 16 | } 17 | }; 18 | Map getAttrsMap(); 19 | } 20 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/controller/TermRelationshipsController.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.controller; 2 | 3 | import io.swagger.annotations.Api; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.stereotype.Controller; 6 | 7 | /** 8 | *

9 | * 文章属性关系表 前端控制器 10 | *

11 | * 12 | * @author 石磊 13 | * @since 2021-05-22 14 | */ 15 | @Controller 16 | @Api(tags="文章属性关系") 17 | @RequestMapping("/termRelationships") 18 | public class TermRelationshipsController { 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IMenuService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.dto.MenuNode; 4 | import com.codingmore.model.Menu; 5 | import com.baomidou.mybatisplus.extension.service.IService; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | *

11 | * 后台菜单表 服务类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2022-03-03 16 | */ 17 | public interface IMenuService extends IService { 18 | 19 | /** 20 | * 树形结构返回所有菜单列表 21 | */ 22 | List treeList(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /codingmore-security/src/main/java/com/codingmore/config/IgnoreUrlsConfig.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.config; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * 用于配置白名单资源路径 12 | * on 2018/11/5. 13 | */ 14 | @Getter 15 | @Setter 16 | @ConfigurationProperties(prefix = "secure.ignored") 17 | public class IgnoreUrlsConfig { 18 | 19 | private List urls = new ArrayList<>(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/CodingmoreAdminBootstrap.java: -------------------------------------------------------------------------------- 1 | package com.codingmore; 2 | 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.web.servlet.ServletComponentScan; 7 | 8 | /** 9 | * 后台管理系统接口主类 10 | */ 11 | @ServletComponentScan 12 | @SpringBootApplication 13 | public class CodingmoreAdminBootstrap { 14 | public static void main(String[] args) { 15 | SpringApplication.run(CodingmoreAdminBootstrap.class); 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/state/TermRelationType.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.state; 2 | 3 | /** 4 | * 文章栏目关系类型 5 | */ 6 | public enum TermRelationType { 7 | /** 8 | * 内容 9 | */ 10 | CONTENT(1), 11 | /** 12 | * 内容链接 13 | */ 14 | CONTENT_LINK(2), 15 | /** 16 | * 栏目链接 17 | */ 18 | CHANNEL_LINK(3); 19 | 20 | 21 | private Integer type; 22 | 23 | public Integer getType() { 24 | return type; 25 | } 26 | 27 | TermRelationType(Integer type) { 28 | this.type = type; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/impl/ChannelPageRequestStrategy.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.service.ILearnWebRequestStrategy; 4 | import com.codingmore.util.WebRequestParam; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * 栏目请求处理策略 9 | */ 10 | @Service("channelPageRequestStrategy") 11 | public class ChannelPageRequestStrategy implements ILearnWebRequestStrategy { 12 | @Override 13 | public String handleRequest(WebRequestParam webRequestParam) { 14 | return "channel"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/IPostTagService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.PostTag; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | *

10 | * 标签表 服务类 11 | *

12 | * 13 | * @author 石磊 14 | * @since 2021-09-12 15 | */ 16 | public interface IPostTagService extends IService { 17 | 18 | 19 | 20 | /** 21 | * 获取文章标签 22 | * @param postId 23 | * @return 24 | */ 25 | List getByPostId(Long postId); 26 | } 27 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/impl/SiteServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.Site; 4 | import com.codingmore.mapper.SiteMapper; 5 | import com.codingmore.service.ISiteService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | 10 | /** 11 | *

12 | * 站点 服务实现类 13 | *

14 | * 15 | * @author 石磊 16 | * @since 2021-09-12 17 | */ 18 | @Service 19 | public class SiteServiceImpl extends ServiceImpl implements ISiteService { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/impl/SiteServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.Site; 4 | import com.codingmore.mapper.SiteMapper; 5 | import com.codingmore.service.ISiteService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | 10 | /** 11 | *

12 | * 站点 服务实现类 13 | *

14 | * 15 | * @author 石磊 16 | * @since 2021-09-12 17 | */ 18 | @Service 19 | public class SiteServiceImpl extends ServiceImpl implements ISiteService { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/impl/LinksServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.Links; 4 | import com.codingmore.mapper.LinksMapper; 5 | import com.codingmore.service.ILinksService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 链接信息表 服务实现类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2021-09-12 16 | */ 17 | @Service 18 | public class LinksServiceImpl extends ServiceImpl implements ILinksService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/impl/LinksServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.Links; 4 | import com.codingmore.mapper.LinksMapper; 5 | import com.codingmore.service.ILinksService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 链接信息表 服务实现类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2021-09-12 16 | */ 17 | @Service 18 | public class LinksServiceImpl extends ServiceImpl implements ILinksService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | 23 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 24 | hs_err_pid* 25 | 26 | # macOS.gitignore 27 | .DS_Store 28 | 29 | # idea 30 | *.iml 31 | .idea/ 32 | 33 | .vscode/ 34 | 35 | *.log 36 | 37 | target/ 38 | .idea/ 39 | package-lock.json 40 | 41 | # 生产环境的不提交 42 | application-prod.yml 43 | dump.rdb 44 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/UsersPageQueryParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | @Data 9 | @EqualsAndHashCode(callSuper = false) 10 | @ApiModel(value="Users对象", description="用户") 11 | public class UsersPageQueryParam { 12 | long pageSize; 13 | long page; 14 | @ApiModelProperty("用户名") 15 | String userLogin; 16 | @ApiModelProperty("昵称") 17 | String userNicename; 18 | @ApiModelProperty("角色id") 19 | Long roleId; 20 | } 21 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/impl/CommentsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.Comments; 4 | import com.codingmore.mapper.CommentsMapper; 5 | import com.codingmore.service.ICommentsService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 评论表 服务实现类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2021-09-12 16 | */ 17 | @Service 18 | public class CommentsServiceImpl extends ServiceImpl implements ICommentsService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/impl/CommentsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.Comments; 4 | import com.codingmore.mapper.CommentsMapper; 5 | import com.codingmore.service.ICommentsService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 评论表 服务实现类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2021-09-12 16 | */ 17 | @Service 18 | public class CommentsServiceImpl extends ServiceImpl implements ICommentsService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/PostTagMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | post_tag_id, description 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/controller/CommentsController.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.controller; 2 | 3 | 4 | import io.swagger.annotations.Api; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | 9 | import org.springframework.stereotype.Controller; 10 | 11 | /** 12 | *

13 | * 评论表 前端控制器 14 | *

15 | * 16 | * @author 石磊 17 | * @since 2021-05-22 18 | */ 19 | @Controller 20 | @RequestMapping("/comments") 21 | @Api(tags="评论") 22 | public class CommentsController { 23 | private static Logger LOGGER = LoggerFactory.getLogger(CommentsController.class); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/impl/PostTagRelationServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.PostTagRelation; 4 | import com.codingmore.mapper.PostTagRelationMapper; 5 | import com.codingmore.service.IPostTagRelationService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 标签文章关系表 服务实现类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2021-09-12 16 | */ 17 | @Service 18 | public class PostTagRelationServiceImpl extends ServiceImpl implements IPostTagRelationService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/impl/PostTagRelationServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.PostTagRelation; 4 | import com.codingmore.mapper.PostTagRelationMapper; 5 | import com.codingmore.service.IPostTagRelationService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 标签文章关系表 服务实现类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2021-09-12 16 | */ 17 | @Service 18 | public class PostTagRelationServiceImpl extends ServiceImpl implements IPostTagRelationService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IScheduleService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import org.quartz.Job; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 微信搜索「沉默王二」,回复 Java 9 | * 10 | * @author 沉默王二 11 | * @date 4/25/22 12 | */ 13 | public interface IScheduleService { 14 | /** 15 | * 通过 Cron 表达式来调度任务 16 | */ 17 | String scheduleJob(Class jobBeanClass, String cron, String data); 18 | 19 | /** 20 | * 指定时间来调度任务 21 | */ 22 | String scheduleFixTimeJob(Class jobBeanClass, Date startTime, String data); 23 | 24 | /** 25 | * 取消定时任务 26 | */ 27 | Boolean cancelScheduleJob(String jobName); 28 | } 29 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/impl/ResourceCategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.ResourceCategory; 4 | import com.codingmore.mapper.ResourceCategoryMapper; 5 | import com.codingmore.service.IResourceCategoryService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 资源分类表 服务实现类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2022-03-03 16 | */ 17 | @Service 18 | public class ResourceCategoryServiceImpl extends ServiceImpl implements IResourceCategoryService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/impl/RoleMenuRelationServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.RoleMenuRelation; 4 | import com.codingmore.mapper.RoleMenuRelationMapper; 5 | import com.codingmore.service.IRoleMenuRelationService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 后台角色菜单关系表 服务实现类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2022-03-05 16 | */ 17 | @Service 18 | public class RoleMenuRelationServiceImpl extends ServiceImpl implements IRoleMenuRelationService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/impl/TermRelationshipsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.TermRelationships; 4 | import com.codingmore.mapper.TermRelationshipsMapper; 5 | import com.codingmore.service.ITermRelationshipsService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 文章属性关系表 服务实现类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2021-09-12 16 | */ 17 | @Service 18 | public class TermRelationshipsServiceImpl extends ServiceImpl implements ITermRelationshipsService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/impl/AdminRoleRelationServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.AdminRoleRelation; 4 | import com.codingmore.mapper.AdminRoleRelationMapper; 5 | import com.codingmore.service.IAdminRoleRelationService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 后台用户和角色关系表 服务实现类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2022-03-05 16 | */ 17 | @Service 18 | public class AdminRoleRelationServiceImpl extends ServiceImpl implements IAdminRoleRelationService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/impl/TermRelationshipsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.TermRelationships; 4 | import com.codingmore.mapper.TermRelationshipsMapper; 5 | import com.codingmore.service.ITermRelationshipsService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 文章属性关系表 服务实现类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2021-09-12 16 | */ 17 | @Service 18 | public class TermRelationshipsServiceImpl extends ServiceImpl implements ITermRelationshipsService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/impl/RoleResourceRelationServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.RoleResourceRelation; 4 | import com.codingmore.mapper.RoleResourceRelationMapper; 5 | import com.codingmore.service.IRoleResourceRelationService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | *

11 | * 后台角色资源关系表 服务实现类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2022-03-05 16 | */ 17 | @Service 18 | public class RoleResourceRelationServiceImpl extends ServiceImpl implements IRoleResourceRelationService { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /codingmore-admin/src/test/java/com/codingmore/CacheDemoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore; 2 | 3 | import org.springframework.cache.annotation.Cacheable; 4 | import org.springframework.cache.annotation.Caching; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * 微信搜索「沉默王二」,回复 Java 9 | * 10 | * @author 沉默王二 11 | * @date 6/16/22 12 | */ 13 | @Service 14 | public class CacheDemoServiceImpl implements CacheDemoService { 15 | 16 | 17 | @Caching(cacheable = { 18 | @Cacheable(cacheNames = "demoCache", key = "#id + 0"), 19 | }) 20 | @Override 21 | public Object getFromDB(Integer id) { 22 | System.out.println("模拟去db查询~~~" + id); 23 | return "hello cache..."; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/UpdateAdminPasswordParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import javax.validation.constraints.NotEmpty; 8 | 9 | /** 10 | * 修改用户名密码参数 11 | * Created by zhanglei on 2019/10/9. 12 | */ 13 | @Data 14 | @ApiModel(value="用户登录", description="用户表") 15 | public class UpdateAdminPasswordParam { 16 | 17 | @NotEmpty(message = "旧密码不能为空") 18 | @ApiModelProperty(value = "旧密码", required = true) 19 | private String oldPassword; 20 | @NotEmpty(message = "新密码不能为空") 21 | @ApiModelProperty(value = "新密码", required = true) 22 | private String newPassword; 23 | } 24 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/PostTagRelationMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | post_id, post_tag_id, term_order 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/webapi/ResultCode.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.webapi; 2 | 3 | /** 4 | * 枚举了一些常用API操作码 5 | * Created by zhanglei on 2019/4/19. 6 | */ 7 | public enum ResultCode implements IErrorCode { 8 | SUCCESS(0, "操作成功"), 9 | FAILED(500, "操作失败"), 10 | VALIDATE_FAILED(506, "参数检验失败"), 11 | UNAUTHORIZED(401, "暂未登录或token已经过期"), 12 | FORBIDDEN(403, "没有相关权限"); 13 | private long code; 14 | private String message; 15 | 16 | private ResultCode(long code, String message) { 17 | this.code = code; 18 | this.message = message; 19 | } 20 | 21 | public long getCode() { 22 | return code; 23 | } 24 | 25 | public String getMessage() { 26 | return message; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/UsersMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.dto.UsersPageQueryParam; 4 | import com.codingmore.model.Users; 5 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 6 | import com.baomidou.mybatisplus.core.metadata.IPage; 7 | import org.apache.ibatis.annotations.Param; 8 | import com.baomidou.mybatisplus.core.conditions.Wrapper; 9 | import com.baomidou.mybatisplus.core.toolkit.Constants; 10 | /** 11 | *

12 | * 用户表 Mapper 接口 13 | *

14 | * 15 | * @author 石磊 16 | * @since 2021-09-12 17 | */ 18 | public interface UsersMapper extends BaseMapper { 19 | IPage findByPage(IPage page, @Param(Constants.WRAPPER) Wrapper wrapper); 20 | } 21 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/RoleMenuRelationMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | role_menu_relation_id, role_id, menu_id 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/impl/UsersServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.Users; 4 | import com.codingmore.mapper.UsersMapper; 5 | import com.codingmore.service.IUsersService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.stereotype.Service; 10 | 11 | 12 | /** 13 | *

14 | * 用户表 服务实现类 15 | *

16 | * 17 | * @author 石磊 18 | * @since 2021-09-12 19 | */ 20 | @Service 21 | public class UsersServiceImpl extends ServiceImpl implements IUsersService { 22 | private static Logger LOGGER = LoggerFactory.getLogger(UsersServiceImpl.class); 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /codingmore-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | codingmore-common 6 | codingmore-common 7 | 1.0-SNAPSHOT 8 | jar 9 | 10 | 11 | top.codingmore 12 | codingmore 13 | 1.0-SNAPSHOT 14 | ../pom.xml 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev #默认为开发环境 4 | servlet: 5 | multipart: 6 | enabled: true #开启文件上传 7 | max-file-size: 10MB #限制文件上传大小为10M 8 | jackson: 9 | date-format: yyyy-MM-dd HH:mm:ss 10 | time-zone: GMT+8 11 | thymeleaf: 12 | cache: false 13 | prefix: classpath:/templates/ 14 | encoding: UTF-8 #编码 15 | suffix: .html #模板后缀 16 | mode: HTML #模板 17 | 18 | server: 19 | port: 8081 20 | 21 | mybatis-plus: 22 | mapper-locations: 23 | - classpath:dao/*.xml 24 | - classpath*:com/**/mapper/*.xml 25 | global-config: 26 | db-config: 27 | table-underline: true 28 | configuration: 29 | map-underscore-to-camel-case: true 30 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 31 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/RoleResourceRelationMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | role_resource_relation_id, role_id, resource_id 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IPostTagService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.dto.PostAddTagParam; 4 | import com.codingmore.model.PostTag; 5 | import com.baomidou.mybatisplus.extension.service.IService; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | *

11 | * 标签表 服务类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2021-09-12 16 | */ 17 | public interface IPostTagService extends IService { 18 | 19 | boolean savePostTag(PostAddTagParam postAddTagParam); 20 | 21 | /** 22 | * 获取文章标签 23 | * @param postId 24 | * @return 25 | */ 26 | List getByPostId(Long postId); 27 | /** 28 | * 删除标签 29 | * @param postTagId 30 | * @return 31 | */ 32 | boolean removeTag(Long postTagId); 33 | } 34 | -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.exception; 2 | 3 | 4 | import com.codingmore.webapi.ResultObject; 5 | 6 | import org.springframework.web.bind.annotation.ControllerAdvice; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | 10 | /** 11 | * 全局异常处理 12 | * on 2020/2/27. 13 | */ 14 | @ControllerAdvice 15 | public class GlobalExceptionHandler { 16 | @ResponseBody 17 | @ExceptionHandler(value = ApiException.class) 18 | public ResultObject handle(ApiException e) { 19 | if (e.getErrorCode() != null) { 20 | return ResultObject.failed(e.getErrorCode()); 21 | } 22 | return ResultObject.failed(e.getMessage()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/vo/TermTaxonomyTreeNode.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | import java.util.List; 9 | 10 | @Data 11 | @ApiModel(value="栏目树形节点") 12 | public class TermTaxonomyTreeNode implements Serializable { 13 | 14 | @ApiModelProperty(value = "ID") 15 | private Long termTaxonomyId; 16 | 17 | 18 | @ApiModelProperty(value = "父栏目id") 19 | private Long parentId; 20 | 21 | 22 | 23 | @ApiModelProperty(value = "栏目名称") 24 | private String name; 25 | 26 | 27 | 28 | 29 | 30 | @ApiModelProperty(value = "说明") 31 | private String description; 32 | 33 | private List children; 34 | } 35 | -------------------------------------------------------------------------------- /codingmore-mbg/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n 9 | utf8 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/exception/ApiException.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.exception; 2 | 3 | import com.codingmore.webapi.IErrorCode; 4 | 5 | /** 6 | * 自定义API异常 7 | */ 8 | public class ApiException extends RuntimeException { 9 | private IErrorCode errorCode; 10 | 11 | public ApiException(IErrorCode errorCode) { 12 | super(errorCode.getMessage()); 13 | this.errorCode = errorCode; 14 | } 15 | 16 | public ApiException(String message) { 17 | super(message); 18 | } 19 | 20 | public ApiException(Throwable cause) { 21 | super(cause); 22 | } 23 | 24 | public ApiException(String message, Throwable cause) { 25 | super(message, cause); 26 | } 27 | 28 | public IErrorCode getErrorCode() { 29 | return errorCode; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/UsersLoginParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 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 java.io.Serializable; 9 | 10 | /** 11 | *

12 | * 用户表 13 | *

14 | * 15 | * @author 石磊 16 | * @since 2021-09-12 17 | */ 18 | @Data 19 | @ApiModel(value="用户登录", description="用户表") 20 | public class UsersLoginParam implements Serializable { 21 | private static final long serialVersionUID = 1L; 22 | 23 | @ApiModelProperty(value = "登录名") 24 | @NotBlank(message="登录名不能为空") 25 | private String userLogin; 26 | 27 | @ApiModelProperty(value = "密码") 28 | @NotBlank(message="密码不能为空") 29 | private String userPass; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/util/FileNameUtil.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.util; 2 | 3 | import cn.hutool.core.date.DateUtil; 4 | import cn.hutool.core.lang.UUID; 5 | import cn.hutool.core.util.IdUtil; 6 | 7 | /** 8 | * 微信搜索「沉默王二」,回复 Java 9 | * 10 | * @author 沉默王二 11 | * @date 4/22/22 12 | */ 13 | public class FileNameUtil { 14 | private static final String[] imageExtension = {".jpg", ".jpeg", ".png", ".gif"}; 15 | 16 | public static String getImgName(String url) { 17 | String ext = ""; 18 | for (String extItem : imageExtension) { 19 | if (url.indexOf(extItem) != -1) { 20 | ext = extItem; 21 | break; 22 | } 23 | } 24 | // 2022年06月09日 + UUID + .jpg 25 | return DateUtil.today() + UUID.fastUUID() + ext; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/ResourceCategoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | resource_category_id, create_time, name, sort 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/TermRelationshipsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | term_relationships_id, term_taxonomy_id, term_order, type 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/PostAddTagParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | import javax.validation.constraints.NotBlank; 9 | import java.io.Serializable; 10 | 11 | @Data 12 | @EqualsAndHashCode(callSuper = false) 13 | @ApiModel(value="PostTag对象", description="标签表") 14 | public class PostAddTagParam implements Serializable { 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | @ApiModelProperty(value = "标签名称") 19 | @NotBlank(message="标签不能为空") 20 | private String description; 21 | 22 | 23 | 24 | @ApiModelProperty(value = " 对应文章ID") 25 | private Long postId; 26 | 27 | @ApiModelProperty(value = "排序") 28 | private int termOrder; 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/PostTagParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | import java.io.Serializable; 9 | 10 | import javax.validation.constraints.NotBlank; 11 | 12 | /** 13 | *

14 | * 标签表 15 | *

16 | * 17 | * @author 石磊 18 | * @since 2021-09-12 19 | */ 20 | @Data 21 | @EqualsAndHashCode(callSuper = false) 22 | @ApiModel(value="PostTag对象", description="标签表") 23 | public class PostTagParam implements Serializable { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | @ApiModelProperty(value = "post_tag_id") 28 | private Long postTagId; 29 | 30 | @ApiModelProperty(value = "标签名称") 31 | @NotBlank(message = "标签名称不能为空") 32 | private String description; 33 | } -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/ITermTaxonomyService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.TermTaxonomy; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.codingmore.vo.TermTaxonomyTreeNode; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | *

11 | * 栏目 服务类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2021-09-12 16 | */ 17 | public interface ITermTaxonomyService extends IService { 18 | 19 | 20 | 21 | /** 22 | * 根据站点id和父栏目id获得所有子孙栏目节点 23 | * @param parentId 父栏目id 24 | * @return 25 | */ 26 | List getAllByParentId(Long parentId); 27 | 28 | /** 29 | * 根据父栏目id获得直属子栏目 30 | * @param parentId 父栏目id,如果为null则返回null 31 | * @return 32 | */ 33 | List getChildrenByParentId(Long parentId); 34 | } 35 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/ResourceMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | resource_id, category_id, create_time, name, url, description 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/vo/BaseVO.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.vo; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * 微信搜索「沉默王二」,回复 Java 12 | * 13 | * @author 沉默王二 14 | * @date 4/28/22 15 | */ 16 | @Data 17 | public abstract class BaseVO { 18 | @ApiModelProperty(value = "attrs") 19 | protected Map attrs = this.createAttrsMap(); 20 | 21 | public BaseVO() { 22 | } 23 | 24 | private Map createAttrsMap() { 25 | return IContainerFactory.defaultContainerFactory.getAttrsMap(); 26 | } 27 | 28 | public M put(String key, Object value) { 29 | this.attrs.put(key, value); 30 | return (M) this; 31 | } 32 | 33 | public T get(String attr) { 34 | return (T) this.attrs.get(attr); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/PostTag.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import java.io.Serializable; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | /** 12 | *

13 | * 标签表 14 | *

15 | * 16 | * @author 石磊 17 | * @since 2021-09-12 18 | */ 19 | @Data 20 | @EqualsAndHashCode(callSuper = false) 21 | @ApiModel(value="PostTag对象", description="标签表") 22 | public class PostTag implements Serializable { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | @ApiModelProperty(value = "post_tag_id") 27 | @TableId(value = "post_tag_id", type = IdType.AUTO) 28 | private Long postTagId; 29 | 30 | @ApiModelProperty(value = "标签名称") 31 | private String description; 32 | 33 | 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /codingmore-mbg/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | codingmore-mbg 6 | codingmore-mbg 7 | 1.0-SNAPSHOT 8 | jar 9 | 10 | 11 | top.codingmore 12 | codingmore 13 | 1.0-SNAPSHOT 14 | ../pom.xml 15 | 16 | 17 | 18 | 19 | top.codingmore 20 | codingmore-common 21 | 1.0-SNAPSHOT 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/SiteMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | site_id, site_name, site_desc, domain, tel_name, static_dir,create_user_id,create_time,update_time,attribute 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/UsersParamUpdate.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 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 java.io.Serializable; 9 | 10 | /** 11 | *

12 | * 用户表 13 | *

14 | * 15 | * @author 石磊 16 | * @since 2021-09-12 17 | */ 18 | @Data 19 | @ApiModel(value="Users对象", description="用户表") 20 | public class UsersParamUpdate implements Serializable { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | private Long usersId; 25 | 26 | @ApiModelProperty(value = "昵称") 27 | @NotBlank(message="昵称不能为空") 28 | private String userNicename; 29 | 30 | @ApiModelProperty(value = "Email") 31 | private String userEmail; 32 | 33 | 34 | 35 | @ApiModelProperty(value = "网址") 36 | private String userUrl; 37 | 38 | @ApiModelProperty(value = "图像") 39 | private String displayName; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/impl/ResourceServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.model.Resource; 4 | import com.codingmore.mapper.ResourceMapper; 5 | import com.codingmore.service.IResourceService; 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 7 | import com.codingmore.service.IUsersCacheService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | /** 12 | *

13 | * 后台资源表 服务实现类 14 | *

15 | * 16 | * @author 石磊 17 | * @since 2022-03-03 18 | */ 19 | @Service 20 | public class ResourceServiceImpl extends ServiceImpl implements IResourceService { 21 | @Autowired 22 | private IUsersCacheService usersCacheService; 23 | @Override 24 | public boolean remove(Long resourceId) { 25 | usersCacheService.delResourceListByResourceId(resourceId); 26 | return this.removeById(resourceId); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/config/OssClientConfig.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.config; 2 | 3 | 4 | import com.aliyun.oss.OSSClient; 5 | import com.aliyun.oss.OSSClientBuilder; 6 | 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | @Configuration 11 | public class OssClientConfig { 12 | // yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。 13 | @Value("${aliyun.oss.endpoint}") 14 | String endpoint ; 15 | // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。 16 | @Value("${aliyun.oss.accessKeyId}") 17 | String accessKeyId ; 18 | @Value("${aliyun.oss.accessKeySecret}") 19 | String accessKeySecret; 20 | 21 | @Bean 22 | public OSSClient createOssClient() { 23 | return (OSSClient)new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/ITermTaxonomyService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.TermTaxonomy; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.codingmore.vo.TermTaxonomyTreeNode; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | *

11 | * 栏目 服务类 12 | *

13 | * 14 | * @author 石磊 15 | * @since 2021-09-12 16 | */ 17 | public interface ITermTaxonomyService extends IService { 18 | 19 | /** 20 | * 删除栏目 包含了逻辑判断 21 | * @param termTaxonomyId 22 | * @return 23 | */ 24 | boolean removeTermTaxonomy(long termTaxonomyId); 25 | 26 | /** 27 | * 根据站点id和父栏目id获得所有子孙栏目节点 28 | * @param parentId 父栏目id 29 | * @return 30 | */ 31 | List getAllByParentId(Long parentId); 32 | 33 | /** 34 | * 根据父栏目id获得直属子栏目 35 | * @param parentId 父栏目id,如果为null则返回null 36 | * @return 37 | */ 38 | List getChildrenByParentId(Long parentId); 39 | } 40 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/RoleMenuRelation.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import java.io.Serializable; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | /** 12 | *

13 | * 后台角色菜单关系表 14 | *

15 | * 16 | * @author 石磊 17 | * @since 2022-03-03 18 | */ 19 | @Data 20 | @EqualsAndHashCode(callSuper = false) 21 | @ApiModel(value="RoleMenuRelation对象", description="后台角色菜单关系表") 22 | public class RoleMenuRelation implements Serializable { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | @TableId(value = "role_menu_relation_id", type = IdType.AUTO) 27 | private Long roleMenuRelationId; 28 | 29 | @ApiModelProperty(value = "角色ID") 30 | private Long roleId; 31 | 32 | @ApiModelProperty(value = "菜单ID") 33 | private Long menuId; 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/AdminRoleRelation.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import java.io.Serializable; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | /** 12 | *

13 | * 后台用户和角色关系表 14 | *

15 | * 16 | * @author 石磊 17 | * @since 2022-03-03 18 | */ 19 | @Data 20 | @EqualsAndHashCode(callSuper = false) 21 | @ApiModel(value="AdminRoleRelation对象", description="后台用户和角色关系表") 22 | public class AdminRoleRelation implements Serializable { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | @TableId(value = "admin_role_relation_id", type = IdType.AUTO) 27 | private Long adminRoleRelationId; 28 | 29 | @ApiModelProperty(value = "用户id") 30 | private Long usersId; 31 | 32 | @ApiModelProperty(value = "角色id") 33 | private Long roleId; 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/vo/RoleVo.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.vo; 2 | 3 | import java.util.Date; 4 | 5 | import com.baomidou.mybatisplus.annotation.IdType; 6 | import com.baomidou.mybatisplus.annotation.TableId; 7 | 8 | import io.swagger.annotations.ApiModel; 9 | import io.swagger.annotations.ApiModelProperty; 10 | import lombok.Data; 11 | import lombok.EqualsAndHashCode; 12 | 13 | @Data 14 | @ApiModel(value="Role对象", description="后台用户角色表") 15 | public class RoleVo { 16 | private static final long serialVersionUID = 1L; 17 | 18 | @TableId(value = "role_id", type = IdType.AUTO) 19 | private Long roleId; 20 | 21 | @ApiModelProperty(value = "名称") 22 | private String name; 23 | 24 | @ApiModelProperty(value = "描述") 25 | private String description; 26 | 27 | @ApiModelProperty(value = "后台用户数量") 28 | private Integer adminCount; 29 | 30 | @ApiModelProperty(value = "创建时间") 31 | private Date createTime; 32 | 33 | @ApiModelProperty(value = "启用状态:0->禁用;1->启用") 34 | private Integer status; 35 | } 36 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/RoleResourceRelation.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import java.io.Serializable; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | /** 12 | *

13 | * 后台角色资源关系表 14 | *

15 | * 16 | * @author 石磊 17 | * @since 2022-03-03 18 | */ 19 | @Data 20 | @EqualsAndHashCode(callSuper = false) 21 | @ApiModel(value="RoleResourceRelation对象", description="后台角色资源关系表") 22 | public class RoleResourceRelation implements Serializable { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | @TableId(value = "role_resource_relation_id", type = IdType.AUTO) 27 | private Long roleResourceRelationId; 28 | 29 | @ApiModelProperty(value = "角色ID") 30 | private Long roleId; 31 | 32 | @ApiModelProperty(value = "资源ID") 33 | private Long resourceId; 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/MenuMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | menu_id, parent_id, create_time, title, level, sort, name, icon, hidden 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/config/MyBatisConfig.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.config; 2 | 3 | import com.baomidou.mybatisplus.annotation.DbType; 4 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 5 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 6 | import org.mybatis.spring.annotation.MapperScan; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.transaction.annotation.EnableTransactionManagement; 10 | 11 | /** 12 | * MyBatis相关配置 13 | * 14 | */ 15 | @Configuration 16 | @EnableTransactionManagement 17 | @MapperScan({"com.codingmore.mapper","com.codingmore.dao"}) 18 | public class MyBatisConfig { 19 | // 最新版 20 | @Bean 21 | public MybatisPlusInterceptor mybatisPlusInterceptor() { 22 | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); 23 | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); 24 | return interceptor; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/config/MyBatisConfig.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.config; 2 | 3 | import com.baomidou.mybatisplus.annotation.DbType; 4 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 5 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 6 | import org.mybatis.spring.annotation.MapperScan; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.transaction.annotation.EnableTransactionManagement; 10 | 11 | /** 12 | * MyBatis相关配置 13 | * 14 | */ 15 | @Configuration 16 | @EnableTransactionManagement 17 | @MapperScan({"com.codingmore.mapper","com.codingmore.dao"}) 18 | public class MyBatisConfig { 19 | // 最新版 20 | @Bean 21 | public MybatisPlusInterceptor mybatisPlusInterceptor() { 22 | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); 23 | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); 24 | return interceptor; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/AdminRoleRelationMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.model.AdminRoleRelation; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import com.codingmore.model.Resource; 6 | import com.codingmore.model.Role; 7 | import org.apache.ibatis.annotations.Param; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | *

13 | * 后台用户和角色关系表 Mapper 接口 14 | *

15 | * 16 | * @author 石磊 17 | * @since 2022-03-03 18 | */ 19 | public interface AdminRoleRelationMapper extends BaseMapper { 20 | /** 21 | * 批量插入用户角色关系 22 | */ 23 | int insertList(@Param("list") List adminRoleRelationList); 24 | 25 | /** 26 | * 获取用于所有角色 27 | */ 28 | List getRoleList(@Param("usersId") Long usersId); 29 | 30 | 31 | 32 | /** 33 | * 获取用户所有可访问资源 34 | */ 35 | List getResourceList(@Param("usersId") Long usersId); 36 | 37 | /** 38 | * 获取资源相关用户ID列表 39 | */ 40 | List getAdminIdList(@Param("resourceId") Long resourceId); 41 | } 42 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/PostTagRelation.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import java.io.Serializable; 6 | 7 | import com.github.jeffreyning.mybatisplus.anno.MppMultiId; 8 | import io.swagger.annotations.ApiModel; 9 | import io.swagger.annotations.ApiModelProperty; 10 | import lombok.Data; 11 | import lombok.EqualsAndHashCode; 12 | 13 | /** 14 | *

15 | * 标签文章关系表 16 | *

17 | * 18 | * @author 石磊 19 | * @since 2021-09-12 20 | */ 21 | @Data 22 | @EqualsAndHashCode(callSuper = false) 23 | @ApiModel(value="PostTagRelation对象", description="标签文章关系表") 24 | public class PostTagRelation implements Serializable { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | @ApiModelProperty(value = "对应文章ID") 29 | @MppMultiId 30 | private Long postId; 31 | 32 | @ApiModelProperty(value = "标签ID") 33 | @MppMultiId 34 | private Long postTagId; 35 | 36 | @ApiModelProperty(value = "排序") 37 | private Integer termOrder; 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/LinksMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | link_id, link_url, link_name, link_image, link_target, link_description, link_visible, link_owner 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/PostsMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.Wrapper; 4 | import com.baomidou.mybatisplus.core.metadata.IPage; 5 | import com.baomidou.mybatisplus.core.toolkit.Constants; 6 | import com.codingmore.dto.PostsPageQueryParam; 7 | import com.codingmore.model.Posts; 8 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 9 | import com.codingmore.vo.PostsVo; 10 | import org.apache.ibatis.annotations.Param; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | *

16 | * 文章 Mapper 接口 17 | *

18 | * 19 | * @author 石磊 20 | * @since 2021-09-12 21 | */ 22 | public interface PostsMapper extends BaseMapper { 23 | 24 | IPage findByPage(IPage page, @Param(Constants.WRAPPER) Wrapper wrapper); 25 | IPage findByPageWithTag(IPage page, @Param(Constants.WRAPPER) Wrapper wrapper); 26 | List findByPageWithTagPaged(@Param(Constants.WRAPPER) Wrapper wrapper, Long searchTagId, long pageStart, long pageSize); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/ResourceCategory.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import java.util.Date; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import java.io.Serializable; 7 | import io.swagger.annotations.ApiModel; 8 | import io.swagger.annotations.ApiModelProperty; 9 | import lombok.Data; 10 | import lombok.EqualsAndHashCode; 11 | 12 | /** 13 | *

14 | * 资源分类表 15 | *

16 | * 17 | * @author 石磊 18 | * @since 2022-03-03 19 | */ 20 | @Data 21 | @EqualsAndHashCode(callSuper = false) 22 | @ApiModel(value="ResourceCategory对象", description="资源分类表") 23 | public class ResourceCategory implements Serializable { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | @TableId(value = "resource_category_id", type = IdType.AUTO) 28 | private Long resourceCategoryId; 29 | 30 | @ApiModelProperty(value = "创建时间") 31 | private Date createTime; 32 | 33 | @ApiModelProperty(value = "分类名称") 34 | private String name; 35 | 36 | @ApiModelProperty(value = "排序") 37 | private Integer sort; 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/ResourceCategoryParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.NotNull; 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | /** 14 | *

15 | * 资源分类表 16 | *

17 | * 18 | * @author 石磊 19 | * @since 2022-03-03 20 | */ 21 | @Data 22 | @EqualsAndHashCode(callSuper = false) 23 | @ApiModel(value="ResourceCategory对象", description="资源分类表") 24 | public class ResourceCategoryParam implements Serializable { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | private Long resourceCategoryId; 29 | 30 | @ApiModelProperty(value = "创建时间") 31 | private Date createTime; 32 | 33 | @ApiModelProperty(value = "分类名称") 34 | @NotBlank(message="分类名称不能为空") 35 | private String name; 36 | 37 | @ApiModelProperty(value = "排序") 38 | @NotNull(message="排序不能为空") 39 | private Integer sort; 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/TermRelationships.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.github.jeffreyning.mybatisplus.anno.MppMultiId; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | /** 12 | *

13 | * 文章栏目关系表 14 | *

15 | * 16 | * @author 石磊 17 | * @since 2021-09-21 18 | */ 19 | @Data 20 | @EqualsAndHashCode(callSuper = false) 21 | @ApiModel(value="TermRelationships对象", description="文章栏目关系表") 22 | public class TermRelationships implements Serializable { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | @ApiModelProperty(value = "对应文章ID/链接ID") 27 | @MppMultiId 28 | private Long termRelationshipsId; 29 | 30 | @ApiModelProperty(value = "栏目ID") 31 | @MppMultiId 32 | private Long termTaxonomyId; 33 | 34 | @ApiModelProperty(value = "排序") 35 | private Integer termOrder; 36 | 37 | @ApiModelProperty(value = "类型,0:文章内容,1:文章链接,2:栏目链接") 38 | @MppMultiId 39 | private Integer type; 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/util/DateUtil.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.util; 2 | 3 | import cn.hutool.core.date.DateTime; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 微信搜索「沉默王二」,回复 Java 9 | * 10 | * @author 沉默王二 11 | * @date 4/28/22 12 | */ 13 | public class DateUtil { 14 | public static String getShortTime(Date time) { 15 | String shortString = ""; 16 | long now = DateTime.now().getTime(); 17 | 18 | long delTime = (now - time.getTime()) / 1000; 19 | if (delTime > 365 * 24 * 60 * 60) { 20 | shortString = (int) (delTime / (365 * 24 * 60 * 60)) + "年前"; 21 | } else if (delTime > 24 * 60 * 60) { 22 | shortString = (int) (delTime / (24 * 60 * 60)) + "天前"; 23 | } else if (delTime > 60 * 60) { 24 | shortString = (int) (delTime / (60 * 60)) + "小时前"; 25 | } else if (delTime > 60) { 26 | shortString = (int) (delTime / (60)) + "分前"; 27 | } else if (delTime > 1) { 28 | shortString = delTime + "秒前"; 29 | } else { 30 | shortString = "1秒前"; 31 | } 32 | return shortString; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import java.util.Date; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import java.io.Serializable; 7 | import io.swagger.annotations.ApiModel; 8 | import io.swagger.annotations.ApiModelProperty; 9 | import lombok.Data; 10 | import lombok.EqualsAndHashCode; 11 | 12 | /** 13 | *

14 | * 后台用户角色表 15 | *

16 | * 17 | * @author 石磊 18 | * @since 2022-03-03 19 | */ 20 | @Data 21 | @EqualsAndHashCode(callSuper = false) 22 | @ApiModel(value="Role对象", description="后台用户角色表") 23 | public class Role implements Serializable { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | @TableId(value = "role_id", type = IdType.AUTO) 28 | private Long roleId; 29 | 30 | @ApiModelProperty(value = "名称") 31 | private String name; 32 | 33 | @ApiModelProperty(value = "描述") 34 | private String description; 35 | 36 | 37 | 38 | @ApiModelProperty(value = "创建时间") 39 | private Date createTime; 40 | 41 | @ApiModelProperty(value = "启用状态:0->禁用;1->启用") 42 | private Integer status; 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/config/GlobalCorsConfig.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.cors.CorsConfiguration; 6 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; 7 | import org.springframework.web.filter.CorsFilter; 8 | 9 | /** 10 | * 全局跨域配置 11 | * Created by zhanglei on 2019/7/27. 12 | */ 13 | @Configuration 14 | public class GlobalCorsConfig { 15 | 16 | /** 17 | * 允许跨域调用的过滤器 18 | */ 19 | @Bean 20 | public CorsFilter corsFilter() { 21 | CorsConfiguration config = new CorsConfiguration(); 22 | //允许所有域名进行跨域调用 23 | config.addAllowedOriginPattern("*"); 24 | //允许跨域发送cookie 25 | config.setAllowCredentials(true); 26 | //放行全部原始头信息 27 | config.addAllowedHeader("*"); 28 | //允许所有请求方法跨域调用 29 | config.addAllowedMethod("*"); 30 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 31 | source.registerCorsConfiguration("/**", config); 32 | return new CorsFilter(source); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/TermTaxonomyParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.NotNull; 10 | import java.io.Serializable; 11 | 12 | /** 13 | *

14 | * 栏目 15 | *

16 | * 17 | * @author 石磊 18 | * @since 2021-09-21 19 | */ 20 | @Data 21 | @EqualsAndHashCode(callSuper = false) 22 | @ApiModel(value="TermTaxonomy对象", description="栏目") 23 | public class TermTaxonomyParam implements Serializable { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | @ApiModelProperty(value = "ID") 28 | 29 | private Long termTaxonomyId; 30 | 31 | @ApiModelProperty(value = "说明") 32 | private String description; 33 | 34 | @ApiModelProperty(value = "名称") 35 | @NotBlank(message="名称不能为空") 36 | private String name; 37 | 38 | @ApiModelProperty(value = "父栏目id") 39 | private Long parentId; 40 | 41 | @ApiModelProperty("属性") 42 | private String attribute; 43 | 44 | private String type; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/TermTaxonomyMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | term_taxonomy_id, description, name, parent_id,create_user_id,create_time,update_time,attribute 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/IPostsService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import java.util.List; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | 7 | import com.baomidou.mybatisplus.core.metadata.IPage; 8 | import com.codingmore.dto.PostsPageQueryParam; 9 | import com.codingmore.model.Posts; 10 | import com.baomidou.mybatisplus.extension.service.IService; 11 | import com.codingmore.vo.PostsVo; 12 | 13 | /** 14 | *

15 | * 文章 服务类 16 | *

17 | * 18 | * @author 石磊 19 | * @since 2021-09-12 20 | */ 21 | public interface IPostsService extends IService { 22 | 23 | IPage findByPageWithTag(PostsPageQueryParam postsPageQueryParam); 24 | 25 | List findByPageWithTagPaged(PostsPageQueryParam postsPageQueryParam); 26 | 27 | List listByTermTaxonomyId(Long termTaxonomyId); 28 | 29 | PostsVo getPostsById(Long id); 30 | 31 | void increasePageView(Long id, HttpServletRequest request); 32 | 33 | void increaseLikeCount(Long id, HttpServletRequest request); 34 | 35 | int getPageView(Long id); 36 | 37 | int getLikeCount(Long id); 38 | 39 | Boolean hasClickedLike(Long id, HttpServletRequest request); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/config/WebConfigBeans.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.config; 2 | 3 | import com.codingmore.util.DateConverter; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.core.convert.support.GenericConversionService; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; 8 | import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; 9 | 10 | import javax.annotation.PostConstruct; 11 | 12 | 13 | @Component 14 | public class WebConfigBeans { 15 | 16 | @Autowired 17 | private RequestMappingHandlerAdapter handlerAdapter; 18 | 19 | @PostConstruct 20 | public void initEditableAvlidation() { 21 | 22 | ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer)handlerAdapter.getWebBindingInitializer(); 23 | if(initializer.getConversionService()!=null) { 24 | GenericConversionService genericConversionService = (GenericConversionService)initializer.getConversionService(); 25 | 26 | genericConversionService.addConverter(new DateConverter()); 27 | 28 | } 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/config/WebConfigBeans.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.config; 2 | 3 | import com.codingmore.component.DateConverter; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.core.convert.support.GenericConversionService; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; 8 | import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; 9 | 10 | import javax.annotation.PostConstruct; 11 | 12 | 13 | @Component 14 | public class WebConfigBeans { 15 | 16 | @Autowired 17 | private RequestMappingHandlerAdapter handlerAdapter; 18 | 19 | @PostConstruct 20 | public void initEditableAvlidation() { 21 | 22 | ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer)handlerAdapter.getWebBindingInitializer(); 23 | if(initializer.getConversionService()!=null) { 24 | GenericConversionService genericConversionService = (GenericConversionService)initializer.getConversionService(); 25 | 26 | genericConversionService.addConverter(new DateConverter()); 27 | 28 | } 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/SiteParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableField; 4 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | 10 | import javax.validation.constraints.NotBlank; 11 | import java.io.Serializable; 12 | import java.util.Date; 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | 16 | /** 17 | *

18 | * 站点 19 | *

20 | * 21 | * @author 石磊 22 | * @since 2021-05-22 23 | */ 24 | @Data 25 | @EqualsAndHashCode(callSuper = false) 26 | @ApiModel(value="Site对象", description="站点") 27 | public class SiteParam implements Serializable { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | @ApiModelProperty("站点名称") 32 | @NotBlank(message = "站点名称不能为空") 33 | private String siteName; 34 | 35 | @ApiModelProperty("站点介绍") 36 | private String siteDesc; 37 | 38 | @NotBlank(message = "关键字不能为空") 39 | @ApiModelProperty("关键字") 40 | private String keywords; 41 | 42 | @ApiModelProperty("属性") 43 | private String attribute; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /codingmore-security/src/main/java/com/codingmore/component/RestAuthenticationEntryPoint.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.component; 2 | 3 | import cn.hutool.json.JSONUtil; 4 | import com.codingmore.webapi.ResultObject; 5 | import org.springframework.security.core.AuthenticationException; 6 | import org.springframework.security.web.AuthenticationEntryPoint; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | /** 14 | * 自定义返回结果:未登录或登录过期 15 | * on 2018/5/14. 16 | */ 17 | public class RestAuthenticationEntryPoint implements AuthenticationEntryPoint { 18 | @Override 19 | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { 20 | response.setHeader("Access-Control-Allow-Origin", "*"); 21 | response.setHeader("Cache-Control","no-cache"); 22 | response.setCharacterEncoding("UTF-8"); 23 | response.setContentType("application/json"); 24 | response.getWriter().println(JSONUtil.parse(ResultObject.unauthorized(authException.getMessage()))); 25 | response.getWriter().flush(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/Resource.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import java.util.Date; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import java.io.Serializable; 7 | import io.swagger.annotations.ApiModel; 8 | import io.swagger.annotations.ApiModelProperty; 9 | import lombok.Data; 10 | import lombok.EqualsAndHashCode; 11 | 12 | /** 13 | *

14 | * 后台资源表 15 | *

16 | * 17 | * @author 石磊 18 | * @since 2022-03-03 19 | */ 20 | @Data 21 | @EqualsAndHashCode(callSuper = false) 22 | @ApiModel(value="Resource对象", description="后台资源表") 23 | public class Resource implements Serializable { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | @TableId(value = "resource_id", type = IdType.AUTO) 28 | private Long resourceId; 29 | 30 | @ApiModelProperty(value = "资源分类ID") 31 | private Long categoryId; 32 | 33 | @ApiModelProperty(value = "创建时间") 34 | private Date createTime; 35 | 36 | @ApiModelProperty(value = "资源名称") 37 | private String name; 38 | 39 | @ApiModelProperty(value = "资源URL") 40 | private String url; 41 | 42 | @ApiModelProperty(value = "描述") 43 | private String description; 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /codingmore-security/src/main/java/com/codingmore/component/RestfulAccessDeniedHandler.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.component; 2 | 3 | import cn.hutool.json.JSONUtil; 4 | import com.codingmore.webapi.ResultObject; 5 | import org.springframework.security.access.AccessDeniedException; 6 | import org.springframework.security.web.access.AccessDeniedHandler; 7 | 8 | 9 | import javax.servlet.ServletException; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import java.io.IOException; 13 | 14 | /** 15 | * 自定义返回结果:没有权限访问时 16 | * on 2018/4/26. 17 | */ 18 | public class RestfulAccessDeniedHandler implements AccessDeniedHandler{ 19 | @Override 20 | public void handle(HttpServletRequest request, 21 | HttpServletResponse response, 22 | AccessDeniedException e) throws IOException, ServletException { 23 | response.setHeader("Access-Control-Allow-Origin", "*"); 24 | response.setHeader("Cache-Control","no-cache"); 25 | response.setCharacterEncoding("UTF-8"); 26 | response.setContentType("application/json"); 27 | response.getWriter().println(JSONUtil.parse(ResultObject.forbidden(e.getMessage()))); 28 | response.getWriter().flush(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/vo/SiteVo.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.vo; 2 | 3 | import java.util.Date; 4 | import java.util.Map; 5 | 6 | import com.fasterxml.jackson.core.JsonProcessingException; 7 | import com.fasterxml.jackson.databind.ObjectMapper; 8 | 9 | import io.swagger.annotations.ApiModelProperty; 10 | import lombok.Data; 11 | 12 | @Data 13 | public class SiteVo { 14 | 15 | private Long siteId; 16 | 17 | @ApiModelProperty("站点名称") 18 | private String siteName; 19 | 20 | @ApiModelProperty("站点介绍") 21 | private String siteDesc; 22 | 23 | @ApiModelProperty("关键字") 24 | private String keywords; 25 | 26 | @ApiModelProperty("修改时间") 27 | private Date updateTime; 28 | 29 | @ApiModelProperty("属性") 30 | private Map attribute; 31 | private String attributeStr; 32 | 33 | public String getAttributeStr() { 34 | if(attribute != null) { 35 | ObjectMapper objectMapper = new ObjectMapper(); 36 | try { 37 | return objectMapper.writeValueAsString(attribute); 38 | } catch (JsonProcessingException e) { 39 | // TODO Auto-generated catch block 40 | e.printStackTrace(); 41 | } 42 | } 43 | return attributeStr; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IUsersCacheService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import java.util.List; 4 | 5 | import com.codingmore.model.Resource; 6 | import com.codingmore.model.Users; 7 | 8 | /** 9 | * 用户缓存 10 | */ 11 | public interface IUsersCacheService { 12 | /** 13 | * 删除后台用户缓存 14 | */ 15 | void delAdminUserByUserId(Long usersId); 16 | 17 | /** 18 | * 删除后台用户资源列表缓存 19 | */ 20 | void delResourceListByUserId(Long usersId); 21 | 22 | /** 23 | * 当角色相关资源信息改变时删除相关后台用户缓存 24 | */ 25 | void delResourceListByRoleId(Long roleId); 26 | 27 | /** 28 | * 当角色相关资源信息改变时删除相关后台用户缓存 29 | */ 30 | void delResourceListByRoleIds(List roleIds); 31 | 32 | /** 33 | * 当资源信息改变时,删除资源项目后台用户缓存 34 | */ 35 | void delResourceListByResourceId(Long resourceId); 36 | 37 | /** 38 | * 获取缓存后台用户信息 39 | */ 40 | Users getAdminUserByUsername(String username); 41 | 42 | /** 43 | * 设置缓存后台用户信息 44 | */ 45 | void setAdminUser(Users users); 46 | 47 | /** 48 | * 获取缓存后台用户资源列表 49 | */ 50 | List getResourceListByUserId(Long usersId); 51 | 52 | /** 53 | * 设置后台后台用户资源列表 54 | */ 55 | void setResourceList(Long adminId, List resourceList); 56 | } 57 | -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/assist/RedisConstants.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.assist; 2 | 3 | /** 4 | * 微信搜索「沉默王二」,回复 Java 5 | * 6 | * @author 沉默王二 7 | * @date 6/6/22 8 | */ 9 | public class RedisConstants { 10 | private static String REDIS_WEB_DATABASE = "codingmore-web-redis"; 11 | private static String PAGE_VIEW = "pageView"; 12 | private static String POST_LIKE_COUNT = "likeCount"; 13 | 14 | private static String REDIS_ADMIN_DATABASE = "codingmore-admin-redis"; 15 | private static String REDIS_KEY_USER = "user"; 16 | private static String REDIS_KEY_RESOURCE_LIST = "resource"; 17 | public static Long REDIS_EXPIRE = 86400L; 18 | 19 | public static String getAdminUserKey(String lastKey) { 20 | return REDIS_ADMIN_DATABASE + ":" + REDIS_KEY_USER + ":" + lastKey; 21 | } 22 | 23 | public static String getAdminResourceKey(Long lastKey) { 24 | return REDIS_ADMIN_DATABASE + ":" + REDIS_KEY_RESOURCE_LIST + ":" + lastKey; 25 | } 26 | 27 | public static String getWebPageViewKey(String lastKey) { 28 | return REDIS_WEB_DATABASE + ":" + PAGE_VIEW + ":" + lastKey; 29 | } 30 | 31 | public static String getWebPostLikeKey(String lastKey) { 32 | return REDIS_WEB_DATABASE + ":" + POST_LIKE_COUNT + ":" + lastKey; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/ResourceParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.NotNull; 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | /** 14 | *

15 | * 后台资源表 16 | *

17 | * 18 | * @author 石磊 19 | * @since 2022-03-03 20 | */ 21 | @Data 22 | @EqualsAndHashCode(callSuper = false) 23 | @ApiModel(value="Resource对象", description="后台资源表") 24 | public class ResourceParam implements Serializable { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | private Long resourceId; 29 | 30 | @ApiModelProperty(value = "资源分类ID") 31 | @NotNull(message="资源分类ID不能为空") 32 | private Long categoryId; 33 | 34 | @ApiModelProperty(value = "创建时间") 35 | private Date createTime; 36 | 37 | @ApiModelProperty(value = "资源名称") 38 | @NotBlank(message = "资源名称不能为空") 39 | private String name; 40 | 41 | @ApiModelProperty(value = "资源URL") 42 | @NotBlank(message = "资源URL不能为空") 43 | private String url; 44 | 45 | @ApiModelProperty(value = "描述") 46 | private String description; 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/RoleParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | 10 | import javax.validation.constraints.NotBlank; 11 | import javax.validation.constraints.NotNull; 12 | 13 | import java.io.Serializable; 14 | import java.util.Date; 15 | 16 | /** 17 | *

18 | * 后台用户角色表 19 | *

20 | * 21 | * @author 石磊 22 | * @since 2022-03-03 23 | */ 24 | @Data 25 | @EqualsAndHashCode(callSuper = false) 26 | @ApiModel(value="Role对象", description="后台用户角色表") 27 | public class RoleParam implements Serializable { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | 32 | private Long roleId; 33 | 34 | @ApiModelProperty(value = "名称") 35 | @NotBlank(message="名称不能为空") 36 | private String name; 37 | 38 | @ApiModelProperty(value = "描述") 39 | private String description; 40 | 41 | 42 | @ApiModelProperty(value = "创建时间") 43 | private Date createTime; 44 | 45 | @ApiModelProperty(value = "启用状态:0->禁用;1->启用") 46 | @NotNull(message="启用状态不能为空") 47 | private Integer status; 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /codingmore-admin/src/test/java/com/codingmore/CodingmoreRedisApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.codingmore; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.cache.Cache; 7 | import org.springframework.data.redis.cache.RedisCacheManager; 8 | import org.springframework.data.redis.core.RedisTemplate; 9 | import org.springframework.data.redis.core.StringRedisTemplate; 10 | 11 | import javax.annotation.Resource; 12 | 13 | /** 14 | * 微信搜索「沉默王二」,回复 Java 15 | * 16 | * @author 沉默王二 17 | * @date 6/16/22 18 | */ 19 | @SpringBootTest 20 | class CodingmoreRedisApplicationTests { 21 | @Resource 22 | private RedisTemplate redisTemplate; 23 | 24 | @Resource 25 | private StringRedisTemplate stringRedisTemplate; 26 | 27 | @Autowired 28 | private CacheDemoService cacheDemoService; 29 | 30 | @Autowired 31 | private RedisCacheManager cacheManager; 32 | 33 | @Test 34 | public void testRedis() { 35 | cacheDemoService.getFromDB(3); 36 | 37 | System.out.println("----------验证缓存是否生效----------"); 38 | Cache cache = cacheManager.getCache("demoCache"); 39 | System.out.println(cache.get(1, String.class)); 40 | 41 | } 42 | 43 | } 44 | 45 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/mapper/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.mapper; 2 | 3 | import com.codingmore.dto.RolePageQueryParam; 4 | import com.codingmore.model.Menu; 5 | import com.codingmore.model.Resource; 6 | import com.codingmore.model.Role; 7 | import com.codingmore.vo.RoleVo; 8 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 9 | import com.baomidou.mybatisplus.core.metadata.IPage; 10 | import com.baomidou.mybatisplus.core.toolkit.Constants; 11 | import org.apache.ibatis.annotations.Param; 12 | import com.baomidou.mybatisplus.core.conditions.Wrapper; 13 | import java.util.List; 14 | 15 | /** 16 | *

17 | * 后台用户角色表 Mapper 接口 18 | *

19 | * 20 | * @author 石磊 21 | * @since 2022-03-03 22 | */ 23 | public interface RoleMapper extends BaseMapper { 24 | /** 25 | * 根据后台用户ID获取菜单 26 | */ 27 | List getMenuList(@Param("usersId") Long usersId); 28 | /** 29 | * 根据角色ID获取菜单 30 | */ 31 | List getMenuListByRoleId(@Param("roleId") Long roleId); 32 | /** 33 | * 根据角色ID获取资源 34 | */ 35 | List getResourceListByRoleId(@Param("roleId") Long roleId); 36 | /** 37 | * 38 | * @param page 39 | * @param wrapper 40 | * @return 41 | */ 42 | IPage findByPage(IPage page, @Param(Constants.WRAPPER) Wrapper wrapper); 43 | } 44 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/controller/OssController.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.controller; 2 | 3 | import com.codingmore.service.IOssService; 4 | import com.codingmore.webapi.ResultObject; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiOperation; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.RequestParam; 13 | import org.springframework.web.bind.annotation.ResponseBody; 14 | import org.springframework.web.multipart.MultipartFile; 15 | 16 | import javax.servlet.http.HttpServletRequest; 17 | 18 | 19 | /** 20 | *

21 | * 上传 控制器 22 | *

23 | * 24 | * @author 石磊 25 | * @since 2021-09-12 26 | */ 27 | @Controller 28 | @Api(tags = "上传") 29 | @RequestMapping("/ossController") 30 | public class OssController { 31 | @Autowired 32 | private IOssService ossService; 33 | 34 | @RequestMapping(value = "/upload",method=RequestMethod.POST) 35 | @ResponseBody 36 | @ApiOperation("上传") 37 | public ResultObject upload(@RequestParam("file") MultipartFile file, HttpServletRequest req) { 38 | return ResultObject.success(ossService.upload(file)); 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/Links.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import java.io.Serializable; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | 11 | /** 12 | *

13 | * 链接信息表 14 | *

15 | * 16 | * @author 石磊 17 | * @since 2021-09-12 18 | */ 19 | @Data 20 | @EqualsAndHashCode(callSuper = false) 21 | @ApiModel(value="Links对象", description="链接信息表") 22 | public class Links implements Serializable { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | @TableId(value = "link_id", type = IdType.AUTO) 27 | private Long linkId; 28 | 29 | @ApiModelProperty(value = "链接URL") 30 | private String linkUrl; 31 | 32 | @ApiModelProperty(value = "链接标题") 33 | private String linkName; 34 | 35 | @ApiModelProperty(value = "链接图片") 36 | private String linkImage; 37 | 38 | @ApiModelProperty(value = "链接打开方式") 39 | private String linkTarget; 40 | 41 | @ApiModelProperty(value = "链接描述") 42 | private String linkDescription; 43 | 44 | @ApiModelProperty(value = "是否可见(Y/N)") 45 | private String linkVisible; 46 | 47 | @ApiModelProperty(value = "添加者用户ID") 48 | private Long linkOwner; 49 | 50 | 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /codingmore-security/src/main/java/com/codingmore/util/SpringUtil.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.util; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Spring工具类 10 | * on 2020/3/3. 11 | */ 12 | @Component 13 | public class SpringUtil implements ApplicationContextAware { 14 | 15 | private static ApplicationContext applicationContext; 16 | 17 | // 获取applicationContext 18 | public static ApplicationContext getApplicationContext() { 19 | return applicationContext; 20 | } 21 | 22 | @Override 23 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 24 | if (SpringUtil.applicationContext == null) { 25 | SpringUtil.applicationContext = applicationContext; 26 | } 27 | } 28 | 29 | // 通过name获取Bean 30 | public static Object getBean(String name) { 31 | return getApplicationContext().getBean(name); 32 | } 33 | 34 | // 通过class获取Bean 35 | public static T getBean(Class clazz) { 36 | return getApplicationContext().getBean(clazz); 37 | } 38 | 39 | // 通过name,以及Clazz返回指定的Bean 40 | public static T getBean(String name, Class clazz) { 41 | return getApplicationContext().getBean(name, clazz); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IRoleService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.dto.RolePageQueryParam; 4 | import com.codingmore.model.Menu; 5 | import com.codingmore.model.Resource; 6 | import com.codingmore.model.Role; 7 | import com.codingmore.vo.RoleVo; 8 | import com.baomidou.mybatisplus.core.metadata.IPage; 9 | import com.baomidou.mybatisplus.extension.service.IService; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | *

16 | * 后台用户角色表 服务类 17 | *

18 | * 19 | * @author 石磊 20 | * @since 2022-03-03 21 | */ 22 | public interface IRoleService extends IService { 23 | 24 | 25 | 26 | /** 27 | * 根据管理员ID获取对应菜单 28 | */ 29 | List getMenuList(Long userId); 30 | 31 | /** 32 | * 获取角色相关菜单 33 | */ 34 | List listMenu(Long roleId); 35 | 36 | /** 37 | * 获取角色相关资源 38 | */ 39 | List listResource(Long roleId); 40 | 41 | /** 42 | * 给角色分配菜单 43 | */ 44 | @Transactional 45 | int allocMenu(Long roleId, List menuIds); 46 | 47 | /** 48 | * 给角色分配资源 49 | */ 50 | @Transactional 51 | int allocResource(Long roleId, List resourceIds); 52 | 53 | /** 54 | * 自定义分页查询 55 | * 56 | */ 57 | IPage findByPage(RolePageQueryParam param); 58 | 59 | boolean batchRemove(List roleIds); 60 | 61 | } 62 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/Menu.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import java.util.Date; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import java.io.Serializable; 7 | import io.swagger.annotations.ApiModel; 8 | import io.swagger.annotations.ApiModelProperty; 9 | import lombok.Data; 10 | import lombok.EqualsAndHashCode; 11 | 12 | /** 13 | *

14 | * 后台菜单表 15 | *

16 | * 17 | * @author 石磊 18 | * @since 2022-03-03 19 | */ 20 | @Data 21 | @EqualsAndHashCode(callSuper = false) 22 | @ApiModel(value="Menu对象", description="后台菜单表") 23 | public class Menu implements Serializable { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | @TableId(value = "menu_id", type = IdType.AUTO) 28 | private Long menuId; 29 | 30 | @ApiModelProperty(value = "父级ID") 31 | private Long parentId; 32 | 33 | @ApiModelProperty(value = "创建时间") 34 | private Date createTime; 35 | 36 | @ApiModelProperty(value = "菜单名称") 37 | private String title; 38 | 39 | @ApiModelProperty(value = "菜单级数") 40 | private Integer level; 41 | 42 | @ApiModelProperty(value = "菜单排序") 43 | private Integer sort; 44 | 45 | @ApiModelProperty(value = "前端名称") 46 | private String name; 47 | 48 | @ApiModelProperty(value = "前端图标") 49 | private String icon; 50 | 51 | @ApiModelProperty(value = "前端隐藏") 52 | private Integer hidden; 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/util/CusAccessObjectUtil.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.util; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | public class CusAccessObjectUtil { 6 | /** 7 | * 获取用户真实IP地址,不使用request.getRemoteAddr();的原因是有可能用户使用了代理软件方式避免真实IP地址, 8 | * 参考文章: http://developer.51cto.com/art/201111/305181.htm 9 | * 10 | * 可是,如果通过了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP值,究竟哪个才是真正的用户端的真实IP呢? 11 | * 答案是取X-Forwarded-For中第一个非unknown的有效IP字符串。 12 | * 13 | * 如:X-Forwarded-For:192.168.1.110, 192.168.1.120, 192.168.1.130, 14 | * 192.168.1.100 15 | * 16 | * 用户真实IP为: 192.168.1.110 17 | * 18 | * @param request 19 | * @return 20 | */ 21 | public static String getIpAddress(HttpServletRequest request) { 22 | String ip = request.getHeader("x-forwarded-for"); 23 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 24 | ip = request.getHeader("Proxy-Client-IP"); 25 | } 26 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 27 | ip = request.getHeader("WL-Proxy-Client-IP"); 28 | } 29 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 30 | ip = request.getHeader("HTTP_CLIENT_IP"); 31 | } 32 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 33 | ip = request.getHeader("HTTP_X_FORWARDED_FOR"); 34 | } 35 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 36 | ip = request.getRemoteAddr(); 37 | } 38 | return ip; 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /codingmore-security/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | top.codingmore 6 | codingmore-security 7 | 1.0-SNAPSHOT 8 | jar 9 | 10 | codingmore-security 11 | codingmore-security project for codingmoresite 12 | 13 | 14 | top.codingmore 15 | codingmore 16 | 1.0-SNAPSHOT 17 | ../pom.xml 18 | 19 | 20 | 21 | 22 | top.codingmore 23 | codingmore-common 24 | 1.0-SNAPSHOT 25 | 26 | 27 | top.codingmore 28 | codingmore-mbg 29 | 1.0-SNAPSHOT 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-security 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IPostsService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.baomidou.mybatisplus.core.metadata.IPage; 4 | import com.codingmore.dto.PostsPageQueryParam; 5 | import com.codingmore.dto.PostsParam; 6 | import com.codingmore.model.Posts; 7 | import com.baomidou.mybatisplus.extension.service.IService; 8 | import com.codingmore.vo.PostsVo; 9 | 10 | import org.springframework.web.multipart.MultipartFile; 11 | 12 | /** 13 | *

14 | * 文章 服务类 15 | *

16 | * 17 | * @author 石磊 18 | * @since 2021-09-12 19 | */ 20 | public interface IPostsService extends IService { 21 | /** 22 | * 保存内容 23 | * @param postsParam 24 | * @return 25 | */ 26 | void savePosts(PostsParam postsParam); 27 | 28 | /** 29 | * 修改内容 30 | * @param postsParam 31 | * @return 32 | */ 33 | void updatePosts(PostsParam postsParam); 34 | 35 | /** 36 | * 定时发布文章后调用 37 | * 38 | * @param postId 39 | */ 40 | boolean updatePostByScheduler(Long postId); 41 | 42 | boolean removePostsById(Long id); 43 | 44 | 45 | IPage findByPage(PostsPageQueryParam postsPageQueryParam); 46 | 47 | PostsVo getPostsById(Long id); 48 | 49 | int insertPostTermTaxonomy(Long[] postsIds, Long[] termTaxonomyIds); 50 | 51 | String uploadMd(MultipartFile file); 52 | 53 | /** 54 | * 置顶/取消置顶方法 55 | * @param postsId 文章id 56 | * @param flag 标志位:0-不置顶;1-置顶 57 | */ 58 | void setOnTop(Long postsId, Integer flag); 59 | } 60 | -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/js/article.js: -------------------------------------------------------------------------------- 1 | $(() => { 2 | bindEvents() 3 | }) 4 | 5 | // 绑定页面事件 6 | const bindEvents = () => { 7 | // 根据情况判断是否绑定点赞方法 8 | let btnLike = $('.btn-like') 9 | if(!btnLike.hasClass('clicked')) { 10 | btnLike.one('click', () => { 11 | likeArticleClick() 12 | }) 13 | } 14 | 15 | // 绑定滚动条事件,以合理显示返回顶部按钮 16 | $('body').scroll(function () { 17 | let scrollTop = $(this).scrollTop(); 18 | 19 | if (scrollTop > 900) { 20 | $('.btn-back-top').removeClass('noshow') 21 | } else { 22 | $('.btn-back-top').addClass('noshow') 23 | } 24 | }); 25 | } 26 | // 文章点赞方法 27 | const likeArticleClick = () => { 28 | let postsId = $('#article_id').val() 29 | let reqData = { postsId } 30 | ajax_post('/rest/clickLike', reqData, (retData) => { 31 | if(retData.code === 0) { 32 | $('.btn-like').addClass('clicked') 33 | $('.thanks-note').removeClass('noshow') 34 | } 35 | }) 36 | } 37 | // 文章点击标签跳转标签文章列表方法 38 | const jumpToSearchTag = (tagId, tagName) => { 39 | localStorage.setItem('search_tag_id', tagId) 40 | localStorage.setItem('search_tag_name', tagName) 41 | openNewPage('/') 42 | } 43 | 44 | // 文章点击标签跳转标签文章列表方法 45 | const searchByText = () => { 46 | let paramText = $('#txtSearch').val().trim() 47 | if(!paramText) { 48 | alert('请输入搜索内容再搜索') 49 | return 50 | } 51 | localStorage.setItem('search_text', paramText) 52 | openNewPage('/') 53 | } 54 | 55 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.oas.annotations.EnableOpenApi; 9 | import springfox.documentation.service.ApiInfo; 10 | import springfox.documentation.service.Contact; 11 | import springfox.documentation.spi.DocumentationType; 12 | import springfox.documentation.spring.web.plugins.Docket; 13 | 14 | @Configuration 15 | @EnableOpenApi 16 | public class SwaggerConfig { 17 | @Bean 18 | public Docket docket(){ 19 | return new Docket(DocumentationType.OAS_30) 20 | .apiInfo(apiInfo()).enable(true) 21 | .select() 22 | //apis: 添加swagger接口提取范围 23 | .apis(RequestHandlerSelectors.basePackage("com.codingmore")) 24 | //.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) 25 | .paths(PathSelectors.any()) 26 | .build(); 27 | } 28 | 29 | private ApiInfo apiInfo(){ 30 | return new ApiInfoBuilder() 31 | .title("学习网站前台接口") 32 | .description("学习网站") 33 | .contact(new Contact("沉默王二&程序员石磊", "作者URL", "作者Email")) 34 | .version("1.0") 35 | .build(); 36 | } 37 | } -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | ${LOG_FILE} 13 | 14 | ${FILE_LOG_PATTERN} 15 | 16 | 17 | ${LOG_FILE}.%d{yyyy-MM-dd}.%i.log 18 | 7 19 | 50MB 20 | 20GB 21 | 22 | 23 | 24 | 25 | 26 | ${CONSOLE_LOG_PATTERN} 27 | utf8 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/component/PublishPostJob.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.component; 2 | 3 | import com.codingmore.service.IPostsService; 4 | import com.codingmore.service.IScheduleService; 5 | import com.codingmore.service.IUsersService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.quartz.*; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.scheduling.quartz.QuartzJobBean; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * 14 | * 定时发布文章 15 | * 微信搜索「沉默王二」,回复 Java 16 | * 17 | * @author 沉默王二 18 | * @date 4/25/22 19 | */ 20 | @Slf4j 21 | @Component 22 | public class PublishPostJob extends QuartzJobBean { 23 | @Autowired 24 | private IScheduleService scheduleService; 25 | @Autowired 26 | private IPostsService postsService; 27 | 28 | @Override 29 | protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException { 30 | Trigger trigger = jobExecutionContext.getTrigger(); 31 | JobDetail jobDetail = jobExecutionContext.getJobDetail(); 32 | JobDataMap jobDataMap = jobDetail.getJobDataMap(); 33 | Long data = jobDataMap.getLong("data"); 34 | log.info("定时发布文章操作:{}",data); 35 | 36 | // 获取文章的 ID后获取文章,更新文章为发布的状态,还有发布的时间 37 | boolean success = postsService.updatePostByScheduler(data); 38 | 39 | //完成后删除触发器和任务 40 | if (success) { 41 | log.info("定时任务执行成功,开始清除定时任务"); 42 | scheduleService.cancelScheduleJob(trigger.getKey().getName()); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/UsersParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; 7 | import io.swagger.annotations.ApiModel; 8 | import io.swagger.annotations.ApiModelProperty; 9 | import lombok.Data; 10 | import lombok.EqualsAndHashCode; 11 | 12 | import javax.validation.constraints.NotBlank; 13 | import java.io.Serializable; 14 | import java.util.Map; 15 | 16 | /** 17 | *

18 | * 用户表 19 | *

20 | * 21 | * @author 石磊 22 | * @since 2021-09-12 23 | */ 24 | @Data 25 | @ApiModel(value="Users对象", description="用户表") 26 | public class UsersParam implements Serializable { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | 31 | @ApiModelProperty(value = "登录名") 32 | @NotBlank(message="登录名不能为空") 33 | private String userLogin; 34 | 35 | @ApiModelProperty(value = "密码") 36 | @NotBlank(message="密码不能为空") 37 | private String userPass; 38 | 39 | @ApiModelProperty(value = "昵称") 40 | @NotBlank(message="昵称不能为空") 41 | private String userNicename; 42 | 43 | @ApiModelProperty(value = "Email") 44 | private String userEmail; 45 | 46 | @ApiModelProperty("属性") 47 | private String attribute; 48 | 49 | @ApiModelProperty(value = "网址") 50 | private String userUrl; 51 | 52 | @ApiModelProperty(value = "图像") 53 | private String displayName; 54 | 55 | 56 | 57 | 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/CommentsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | comment_ID, comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved, comment_agent, comment_type, comment_parent, user_id 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/util/DateConverter.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.util; 2 | 3 | import org.springframework.core.convert.converter.Converter; 4 | import org.springframework.util.StringUtils; 5 | 6 | import java.text.SimpleDateFormat; 7 | import java.util.Date; 8 | 9 | /** 10 | * 日期转换类 11 | * 将标准日期、标准日期时间、时间戳转换成Date类型 12 | */ 13 | public class DateConverter implements Converter { 14 | private static final String dateFormat = "yyyy-MM-dd HH:mm:ss"; 15 | private static final String shortDateFormat = "yyyy-MM-dd"; 16 | private static final String timeStampFormat = "^\\d+$"; 17 | 18 | @Override 19 | public Date convert(String value) { 20 | 21 | if(StringUtils.isEmpty(value)) { 22 | return null; 23 | } 24 | 25 | value = value.trim(); 26 | 27 | try { 28 | if (value.contains("-")) { 29 | SimpleDateFormat formatter; 30 | if (value.contains(":")) { 31 | formatter = new SimpleDateFormat(dateFormat); 32 | } else { 33 | formatter = new SimpleDateFormat(shortDateFormat); 34 | } 35 | return formatter.parse(value); 36 | } else if (value.matches(timeStampFormat)) { 37 | Long lDate = new Long(value); 38 | return new Date(lDate); 39 | } 40 | } catch (Exception e) { 41 | throw new RuntimeException(String.format("parser %s to Date fail", value)); 42 | } 43 | throw new RuntimeException(String.format("parser %s to Date fail", value)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/component/DateConverter.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.component; 2 | 3 | import org.springframework.core.convert.converter.Converter; 4 | import org.springframework.util.StringUtils; 5 | 6 | import java.text.SimpleDateFormat; 7 | import java.util.Date; 8 | 9 | /** 10 | * 日期转换类 11 | * 将标准日期、标准日期时间、时间戳转换成Date类型 12 | */ 13 | public class DateConverter implements Converter { 14 | private static final String dateFormat = "yyyy-MM-dd HH:mm:ss"; 15 | private static final String shortDateFormat = "yyyy-MM-dd"; 16 | private static final String timeStampFormat = "^\\d+$"; 17 | 18 | @Override 19 | public Date convert(String value) { 20 | 21 | if(StringUtils.isEmpty(value)) { 22 | return null; 23 | } 24 | 25 | value = value.trim(); 26 | 27 | try { 28 | if (value.contains("-")) { 29 | SimpleDateFormat formatter; 30 | if (value.contains(":")) { 31 | formatter = new SimpleDateFormat(dateFormat); 32 | } else { 33 | formatter = new SimpleDateFormat(shortDateFormat); 34 | } 35 | return formatter.parse(value); 36 | } else if (value.matches(timeStampFormat)) { 37 | Long lDate = new Long(value); 38 | return new Date(lDate); 39 | } 40 | } catch (Exception e) { 41 | throw new RuntimeException(String.format("parser %s to Date fail", value)); 42 | } 43 | throw new RuntimeException(String.format("parser %s to Date fail", value)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /codingmore-common/src/main/java/com/codingmore/component/BindingResultAspect.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.component; 2 | 3 | import com.codingmore.webapi.ResultObject; 4 | import org.aspectj.lang.ProceedingJoinPoint; 5 | import org.aspectj.lang.annotation.Around; 6 | import org.aspectj.lang.annotation.Aspect; 7 | import org.aspectj.lang.annotation.Pointcut; 8 | import org.springframework.core.annotation.Order; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.validation.BindingResult; 11 | import org.springframework.validation.FieldError; 12 | 13 | /** 14 | * HibernateValidator错误结果处理切面 15 | * Created by zhanglei on 2018/4/26. 16 | */ 17 | @Aspect 18 | @Component 19 | @Order(2) 20 | public class BindingResultAspect { 21 | @Pointcut("execution(public * com.codingmore.controller.*.*(..))") 22 | public void BindingResult() { 23 | } 24 | 25 | @Around("BindingResult()") 26 | public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable { 27 | Object[] args = joinPoint.getArgs(); 28 | for (Object arg : args) { 29 | if (arg instanceof BindingResult) { 30 | BindingResult result = (BindingResult) arg; 31 | if (result.hasErrors()) { 32 | FieldError fieldError = result.getFieldError(); 33 | if(fieldError!=null){ 34 | return ResultObject.validateFailed(fieldError.getDefaultMessage()); 35 | }else{ 36 | return ResultObject.validateFailed(); 37 | } 38 | } 39 | } 40 | } 41 | return joinPoint.proceed(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/impl/MenuServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.codingmore.dto.MenuNode; 4 | import com.codingmore.model.Menu; 5 | import com.codingmore.mapper.MenuMapper; 6 | import com.codingmore.service.IMenuService; 7 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 8 | 9 | import org.springframework.beans.BeanUtils; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.List; 13 | import java.util.stream.Collectors; 14 | 15 | /** 16 | *

17 | * 后台菜单表 服务实现类 18 | *

19 | * 20 | * @author 石磊 21 | * @since 2022-03-03 22 | */ 23 | @Service 24 | public class MenuServiceImpl extends ServiceImpl implements IMenuService { 25 | 26 | @Override 27 | public List treeList() { 28 | List menuList = this.list(); 29 | List result = menuList.stream() 30 | .filter(menu -> menu.getParentId().equals(0L)) 31 | .map(menu -> covertMenuNode(menu, menuList)).collect(Collectors.toList()); 32 | return result; 33 | } 34 | 35 | /** 36 | * 将Menu转化为MenuNode并设置children属性 37 | */ 38 | private MenuNode covertMenuNode(Menu menu, List menuList) { 39 | MenuNode node = new MenuNode(); 40 | BeanUtils.copyProperties(menu, node); 41 | List children = menuList.stream() 42 | .filter(subMenu -> subMenu.getParentId().equals(menu.getMenuId())) 43 | .map(subMenu -> covertMenuNode(subMenu, menuList)).collect(Collectors.toList()); 44 | node.setChildren(children); 45 | return node; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/MenuParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | 10 | import javax.validation.constraints.NotBlank; 11 | import javax.validation.constraints.NotNull; 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | 15 | /** 16 | *

17 | * 后台菜单表 18 | *

19 | * 20 | * @author 石磊 21 | * @since 2022-03-03 22 | */ 23 | @Data 24 | @EqualsAndHashCode(callSuper = false) 25 | @ApiModel(value="Menu对象", description="后台菜单表") 26 | public class MenuParam implements Serializable { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | 31 | private Long menuId; 32 | 33 | @ApiModelProperty(value = "父级ID") 34 | private Long parentId; 35 | 36 | @ApiModelProperty(value = "创建时间") 37 | private Date createTime; 38 | 39 | @ApiModelProperty(value = "菜单名称") 40 | @NotBlank(message = "菜单名称不能为空") 41 | private String title; 42 | 43 | @ApiModelProperty(value = "菜单级数") 44 | private Integer level; 45 | 46 | @ApiModelProperty(value = "菜单排序") 47 | private Integer sort; 48 | 49 | @ApiModelProperty(value = "前端名称") 50 | @NotBlank(message = "前端名称不能为空") 51 | private String name; 52 | 53 | @ApiModelProperty(value = "前端图标") 54 | @NotBlank(message = "前端图标不能为空") 55 | private String icon; 56 | 57 | @ApiModelProperty(value = "前端隐藏") 58 | @NotNull(message = "前端隐藏不能为空") 59 | private Integer hidden; 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/impl/PostTagServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.codingmore.model.PostTag; 5 | import com.codingmore.mapper.PostTagMapper; 6 | import com.codingmore.model.PostTagRelation; 7 | import com.codingmore.service.IPostTagRelationService; 8 | import com.codingmore.service.IPostTagService; 9 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.List; 14 | import java.util.stream.Collectors; 15 | 16 | /** 17 | *

18 | * 标签表 服务实现类 19 | *

20 | * 21 | * @author 石磊 22 | * @since 2021-09-12 23 | */ 24 | @Service 25 | public class PostTagServiceImpl extends ServiceImpl implements IPostTagService { 26 | @Autowired 27 | private IPostTagRelationService postTagRelationService; 28 | 29 | 30 | 31 | @Override 32 | public List getByPostId(Long postId) { 33 | QueryWrapper postTagRelationQueryWrapper = new QueryWrapper<>(); 34 | postTagRelationQueryWrapper.eq("post_id",postId); 35 | List postTagRelationList = postTagRelationService.list(postTagRelationQueryWrapper); 36 | List postTagIdList = postTagRelationList.stream().map(PostTagRelation::getPostTagId).collect(Collectors.toList()); 37 | QueryWrapper postTagQueryWrapper = new QueryWrapper(); 38 | postTagQueryWrapper.in("post_tag_id",postTagIdList); 39 | return this.list(postTagQueryWrapper); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /codingmore-web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | codingmore-web 6 | jar 7 | codingmore-web 8 | 1.0-SNAPSHOT 9 | 10 | 11 | top.codingmore 12 | codingmore 13 | 1.0-SNAPSHOT 14 | ../pom.xml 15 | 16 | 17 | 18 | 19 | top.codingmore 20 | codingmore-mbg 21 | 1.0-SNAPSHOT 22 | 23 | 24 | junit 25 | junit 26 | 27 | 28 | 29 | org.apache.commons 30 | commons-pool2 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-maven-plugin 40 | 41 | 42 | true 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/PostsParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.NotNull; 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | /** 14 | *

15 | * 文章 16 | *

17 | * 18 | * @author 石磊 19 | * @since 2021-09-12 20 | */ 21 | @Data 22 | @EqualsAndHashCode(callSuper = false) 23 | @ApiModel(value="Posts对象", description="文章") 24 | public class PostsParam implements Serializable { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | @ApiModelProperty(value = "posts_id") 29 | private Long postsId; 30 | 31 | @ApiModelProperty(value = "发布时间") 32 | private Date postDate; 33 | 34 | @ApiModelProperty(value = "正文") 35 | @NotBlank(message = "文章内容不能为空") 36 | private String postContent; 37 | 38 | @ApiModelProperty(value = "正文html") 39 | private String htmlContent; 40 | 41 | @ApiModelProperty(value = "标题") 42 | @NotBlank(message = "标题不能为空") 43 | private String postTitle; 44 | 45 | @ApiModelProperty(value = "摘要") 46 | private String postExcerpt; 47 | 48 | @ApiModelProperty(value = "文章状态:PUBLISHED,DELETED,DRAFT") 49 | @NotBlank(message = "文章状态不能为空") 50 | private String postStatus; 51 | 52 | @ApiModelProperty(value = "排序ID") 53 | private Integer menuOrder; 54 | 55 | @ApiModelProperty(value = "栏目ID") 56 | private Long termTaxonomyId; 57 | 58 | @ApiModelProperty(value = "标签") 59 | private String tags; 60 | 61 | @ApiModelProperty("属性") 62 | private String attribute; 63 | } 64 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/config/TreadPoolConfig.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.config; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.scheduling.annotation.AsyncConfigurer; 7 | import org.springframework.scheduling.annotation.EnableAsync; 8 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 9 | 10 | import java.util.concurrent.ThreadPoolExecutor; 11 | 12 | @Configuration 13 | @EnableAsync 14 | 15 | public class TreadPoolConfig implements AsyncConfigurer { 16 | @Value("${async.executor.corePoolSize}") 17 | private Integer corePoolSize; 18 | @Value("${async.executor.maxPoolSize}") 19 | private Integer maxPoolSize; 20 | @Value("${async.executor.queueCapacity}") 21 | private Integer queueCapacity; 22 | @Value("${async.executor.keepAliveSeconds}") 23 | private Integer keepAliveSeconds; 24 | @Value("${async.executor.threadNamePrefix}") 25 | private String threadNamePrefix; 26 | 27 | @Bean(name = "ossUploadImageExecutor") 28 | public ThreadPoolTaskExecutor getMetricsExecutor() { 29 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); 30 | executor.setCorePoolSize(corePoolSize); 31 | executor.setMaxPoolSize(maxPoolSize); 32 | executor.setQueueCapacity(queueCapacity); 33 | 34 | executor.setKeepAliveSeconds(keepAliveSeconds); 35 | executor.setThreadNamePrefix(threadNamePrefix); 36 | executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); 37 | executor.setWaitForTasksToCompleteOnShutdown(true); 38 | return executor; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/Site.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableField; 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | import java.util.Map; 9 | 10 | import javax.validation.constraints.NotBlank; 11 | 12 | import com.baomidou.mybatisplus.annotation.TableName; 13 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; 14 | 15 | import io.swagger.annotations.ApiModel; 16 | import io.swagger.annotations.ApiModelProperty; 17 | import lombok.Data; 18 | import lombok.EqualsAndHashCode; 19 | 20 | /** 21 | *

22 | * 站点 23 | *

24 | * 25 | * @author 石磊 26 | * @since 2021-05-22 27 | */ 28 | @Data 29 | @EqualsAndHashCode(callSuper = false) 30 | @ApiModel(value="Site对象", description="站点") 31 | @TableName(autoResultMap = true) 32 | public class Site implements Serializable { 33 | 34 | private static final long serialVersionUID = 1L; 35 | 36 | @TableId(value = "site_id", type = IdType.AUTO) 37 | private Long siteId; 38 | 39 | @TableField("site_name") 40 | @ApiModelProperty("站点名称") 41 | @NotBlank(message = "站点名称不能为空") 42 | private String siteName; 43 | 44 | @TableField("site_desc") 45 | @ApiModelProperty("站点介绍") 46 | private String siteDesc; 47 | 48 | @TableField("keywords") 49 | @NotBlank(message = "关键字不能为空") 50 | @ApiModelProperty("关键字") 51 | private String keywords; 52 | 53 | @TableField("update_time") 54 | @ApiModelProperty("修改时间") 55 | private Date updateTime; 56 | 57 | @TableField(typeHandler = JacksonTypeHandler.class) 58 | @ApiModelProperty("属性") 59 | private Map attribute; 60 | } 61 | -------------------------------------------------------------------------------- /codingmore-security/src/main/java/com/codingmore/aspect/RedisCacheAspect.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.aspect; 2 | 3 | import com.codingmore.annotation.CacheException; 4 | import org.aspectj.lang.ProceedingJoinPoint; 5 | import org.aspectj.lang.Signature; 6 | import org.aspectj.lang.annotation.Around; 7 | import org.aspectj.lang.annotation.Aspect; 8 | import org.aspectj.lang.annotation.Pointcut; 9 | import org.aspectj.lang.reflect.MethodSignature; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.core.annotation.Order; 13 | import org.springframework.stereotype.Component; 14 | 15 | import java.lang.reflect.Method; 16 | 17 | /** 18 | * Redis缓存切面,防止Redis宕机影响正常业务逻辑 19 | * on 2020/3/17. 20 | */ 21 | @Aspect 22 | @Component 23 | @Order(2) 24 | public class RedisCacheAspect { 25 | private static Logger LOGGER = LoggerFactory.getLogger(RedisCacheAspect.class); 26 | 27 | @Pointcut("execution(public * com.codingmore.*CacheService.*(..)) ") 28 | public void cacheAspect() { 29 | } 30 | 31 | @Around("cacheAspect()") 32 | public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable { 33 | Signature signature = joinPoint.getSignature(); 34 | MethodSignature methodSignature = (MethodSignature) signature; 35 | Method method = methodSignature.getMethod(); 36 | Object result = null; 37 | try { 38 | result = joinPoint.proceed(); 39 | } catch (Throwable throwable) { 40 | //有CacheException注解的方法需要抛出异常 41 | if (method.isAnnotationPresent(CacheException.class)) { 42 | throw throwable; 43 | } else { 44 | LOGGER.error(throwable.getMessage()); 45 | } 46 | } 47 | return result; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # Spring Boot 配置 2 | spring: 3 | profiles: 4 | active: dev #默认为开发环境 5 | servlet: 6 | multipart: 7 | enabled: true #开启文件上传 8 | max-file-size: 10MB #限制文件上传大小为10M 9 | jackson: 10 | date-format: yyyy-MM-dd HH:mm:ss 11 | time-zone: GMT+8 12 | 13 | # 端口号 14 | server: 15 | port: 9002 16 | 17 | # MyBatis plus 的配置查询后写注释 18 | mybatis-plus: 19 | mapper-locations: 20 | - classpath:dao/*.xml 21 | - classpath*:com/**/mapper/*.xml 22 | global-config: 23 | db-config: 24 | table-underline: true 25 | configuration: 26 | map-underscore-to-camel-case: true 27 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 28 | 29 | # 自定义类 ignoreConfig,URL 的白名单 30 | secure: 31 | ignored: 32 | urls: #安全路径白名单 33 | - /doc.html 34 | - /swagger-ui/** 35 | - /swagger/** 36 | - /swagger-resources/** 37 | - /**/v3/api-docs 38 | - /**/*.js 39 | - /**/*.css 40 | - /**/*.png 41 | - /**/*.ico 42 | - /webjars/springfox-swagger-ui/** 43 | - /actuator/** 44 | - /druid/** 45 | - /users/login 46 | - /users/register 47 | - /users/info 48 | - /users/logout 49 | - /minio/upload 50 | 51 | # 登录认证 token filter 52 | jwt: 53 | tokenHeader: Authorization #JWT存储的请求头 54 | secret: codingmore-admin-secret #JWT加解密使用的密钥 55 | expiration: 604800 #JWT的超期限时间(60*60*24*7) 56 | tokenHead: 'Bearer ' #JWT负载中拿到开头 57 | 58 | #异步线程配置 59 | async: 60 | executor: 61 | #设置核心线程数 62 | corePoolSize: 10 63 | #设置最大线程数 64 | maxPoolSize: 100 65 | #设置队列容量 66 | queueCapacity: 500 67 | #设置线程活跃时间(秒) 68 | keepAliveSeconds: 360 69 | #设置默认线程名称 70 | threadNamePrefix: sync-thread- 71 | 72 | # 文章定时发布的最小间隔 73 | post: 74 | schedule: 75 | minInterval: 10 -------------------------------------------------------------------------------- /codingmore-admin/src/test/resources/application.yml: -------------------------------------------------------------------------------- 1 | # Spring Boot 配置 2 | spring: 3 | profiles: 4 | active: dev #默认为开发环境 5 | servlet: 6 | multipart: 7 | enabled: true #开启文件上传 8 | max-file-size: 10MB #限制文件上传大小为10M 9 | jackson: 10 | date-format: yyyy-MM-dd HH:mm:ss 11 | time-zone: GMT+8 12 | 13 | # 端口号 14 | server: 15 | port: 9002 16 | 17 | # MyBatis plus 的配置查询后写注释 18 | mybatis-plus: 19 | mapper-locations: 20 | - classpath:dao/*.xml 21 | - classpath*:com/**/mapper/*.xml 22 | global-config: 23 | db-config: 24 | table-underline: true 25 | configuration: 26 | map-underscore-to-camel-case: true 27 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 28 | 29 | # 自定义类 ignoreConfig,URL 的白名单 30 | secure: 31 | ignored: 32 | urls: #安全路径白名单 33 | - /doc.html 34 | - /swagger-ui/** 35 | - /swagger/** 36 | - /swagger-resources/** 37 | - /**/v3/api-docs 38 | - /**/*.js 39 | - /**/*.css 40 | - /**/*.png 41 | - /**/*.ico 42 | - /webjars/springfox-swagger-ui/** 43 | - /actuator/** 44 | - /druid/** 45 | - /users/login 46 | - /users/register 47 | - /users/info 48 | - /users/logout 49 | - /minio/upload 50 | 51 | # 登录认证 token filter 52 | jwt: 53 | tokenHeader: Authorization #JWT存储的请求头 54 | secret: codingmore-admin-secret #JWT加解密使用的密钥 55 | expiration: 604800 #JWT的超期限时间(60*60*24*7) 56 | tokenHead: 'Bearer ' #JWT负载中拿到开头 57 | 58 | #异步线程配置 59 | async: 60 | executor: 61 | #设置核心线程数 62 | corePoolSize: 10 63 | #设置最大线程数 64 | maxPoolSize: 100 65 | #设置队列容量 66 | queueCapacity: 500 67 | #设置线程活跃时间(秒) 68 | keepAliveSeconds: 360 69 | #设置默认线程名称 70 | threadNamePrefix: sync-thread- 71 | 72 | # 文章定时发布的最小间隔 73 | post: 74 | schedule: 75 | minInterval: 10 -------------------------------------------------------------------------------- /codingmore-web/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | ${LOG_FILE} 13 | 14 | ${FILE_LOG_PATTERN} 15 | 16 | 17 | ${LOG_FILE}.%d{yyyy-MM-dd}.%i.log 18 | 7 19 | 50MB 20 | 20GB 21 | 22 | 23 | 24 | 25 | 26 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n 27 | utf8 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /codingmore-admin/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | ${LOG_FILE} 13 | 14 | ${FILE_LOG_PATTERN} 15 | 16 | 17 | ${LOG_FILE}.%d{yyyy-MM-dd}.%i.log 18 | 7 19 | 50MB 20 | 20GB 21 | 22 | 23 | 24 | 25 | 26 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{30} - %msg%n 27 | utf8 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/plugins/nprogress/nprogress.css: -------------------------------------------------------------------------------- 1 | /* Make clicks pass-through */ 2 | #nprogress { 3 | pointer-events: none; 4 | } 5 | 6 | #nprogress .bar { 7 | background: #29d; 8 | 9 | position: fixed; 10 | z-index: 1031; 11 | top: 0; 12 | left: 0; 13 | 14 | width: 100%; 15 | height: 2px; 16 | } 17 | 18 | /* Fancy blur effect */ 19 | #nprogress .peg { 20 | display: block; 21 | position: absolute; 22 | right: 0px; 23 | width: 100px; 24 | height: 100%; 25 | box-shadow: 0 0 10px #29d, 0 0 5px #29d; 26 | opacity: 1.0; 27 | 28 | -webkit-transform: rotate(3deg) translate(0px, -4px); 29 | -ms-transform: rotate(3deg) translate(0px, -4px); 30 | transform: rotate(3deg) translate(0px, -4px); 31 | } 32 | 33 | /* Remove these to get rid of the spinner */ 34 | #nprogress .spinner { 35 | display: block; 36 | position: fixed; 37 | z-index: 1031; 38 | top: 15px; 39 | right: 15px; 40 | } 41 | 42 | #nprogress .spinner-icon { 43 | width: 18px; 44 | height: 18px; 45 | box-sizing: border-box; 46 | 47 | border: solid 2px transparent; 48 | border-top-color: #29d; 49 | border-left-color: #29d; 50 | border-radius: 50%; 51 | 52 | -webkit-animation: nprogress-spinner 400ms linear infinite; 53 | animation: nprogress-spinner 400ms linear infinite; 54 | } 55 | 56 | .nprogress-custom-parent { 57 | overflow: hidden; 58 | position: relative; 59 | } 60 | 61 | .nprogress-custom-parent #nprogress .spinner, 62 | .nprogress-custom-parent #nprogress .bar { 63 | position: absolute; 64 | } 65 | 66 | @-webkit-keyframes nprogress-spinner { 67 | 0% { -webkit-transform: rotate(0deg); } 68 | 100% { -webkit-transform: rotate(360deg); } 69 | } 70 | @keyframes nprogress-spinner { 71 | 0% { transform: rotate(0deg); } 72 | 100% { transform: rotate(360deg); } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/TermTaxonomy.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | import java.util.Map; 9 | 10 | import com.baomidou.mybatisplus.annotation.TableName; 11 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; 12 | import io.swagger.annotations.ApiModel; 13 | import io.swagger.annotations.ApiModelProperty; 14 | import lombok.Data; 15 | import lombok.EqualsAndHashCode; 16 | 17 | /** 18 | *

19 | * 栏目 20 | *

21 | * 22 | * @author 石磊 23 | * @since 2021-09-21 24 | */ 25 | @Data 26 | @EqualsAndHashCode(callSuper = false) 27 | @ApiModel(value="TermTaxonomy对象", description="栏目") 28 | @TableName(autoResultMap = true) 29 | public class TermTaxonomy implements Serializable { 30 | 31 | private static final long serialVersionUID = 1L; 32 | 33 | @ApiModelProperty(value = "ID") 34 | @TableId(value = "term_taxonomy_id", type = IdType.AUTO) 35 | private Long termTaxonomyId; 36 | 37 | @ApiModelProperty(value = "栏目名称") 38 | private String name; 39 | 40 | @ApiModelProperty(value = "说明") 41 | private String description; 42 | 43 | @ApiModelProperty(value = "父栏目id") 44 | private Long parentId; 45 | 46 | @TableField("create_user_id") 47 | @ApiModelProperty("创建用户id") 48 | private Long createUserId; 49 | 50 | @TableField("create_time") 51 | @ApiModelProperty("创建时间") 52 | private Date createTime; 53 | 54 | @TableField("update_time") 55 | @ApiModelProperty("修改时间") 56 | private Date updateTime; 57 | 58 | @TableField(typeHandler = JacksonTypeHandler.class) 59 | @ApiModelProperty("属性") 60 | private Map attribute; 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/css/github.min.css: -------------------------------------------------------------------------------- 1 | pre code.hljs { 2 | display:block; 3 | overflow-x:auto; 4 | padding:1em 5 | } 6 | code.hljs { 7 | padding:3px 5px 8 | } 9 | /*! 10 | Theme: GitHub 11 | Description: Light theme as seen on github.com 12 | Author: github.com 13 | Maintainer: @Hirse 14 | Updated: 2021-05-15 15 | 16 | Outdated base version: https://github.com/primer/github-syntax-light 17 | Current colors taken from GitHub's CSS 18 | */.hljs { 19 | color:#24292e; 20 | background:#fff 21 | } 22 | .hljs-doctag, 23 | .hljs-keyword, 24 | .hljs-meta .hljs-keyword, 25 | .hljs-template-tag, 26 | .hljs-template-variable, 27 | .hljs-type, 28 | .hljs-variable.language_ { 29 | color:#d73a49 30 | } 31 | .hljs-title, 32 | .hljs-title.class_, 33 | .hljs-title.class_.inherited__, 34 | .hljs-title.function_ { 35 | color:#6f42c1 36 | } 37 | .hljs-attr, 38 | .hljs-attribute, 39 | .hljs-literal, 40 | .hljs-meta, 41 | .hljs-number, 42 | .hljs-operator, 43 | .hljs-selector-attr, 44 | .hljs-selector-class, 45 | .hljs-selector-id, 46 | .hljs-variable { 47 | color:#005cc5 48 | } 49 | .hljs-meta .hljs-string, 50 | .hljs-regexp, 51 | .hljs-string { 52 | color:#032f62 53 | } 54 | .hljs-built_in, 55 | .hljs-symbol { 56 | color:#e36209 57 | } 58 | .hljs-code, 59 | .hljs-comment, 60 | .hljs-formula { 61 | color:#6a737d 62 | } 63 | .hljs-name, 64 | .hljs-quote, 65 | .hljs-selector-pseudo, 66 | .hljs-selector-tag { 67 | color:#22863a 68 | } 69 | .hljs-subst { 70 | color:#24292e 71 | } 72 | .hljs-section { 73 | color:#005cc5; 74 | font-weight:700 75 | } 76 | .hljs-bullet { 77 | color:#735c0f 78 | } 79 | .hljs-emphasis { 80 | color:#24292e; 81 | font-style:italic 82 | } 83 | .hljs-strong { 84 | color:#24292e; 85 | font-weight:700 86 | } 87 | .hljs-addition { 88 | color:#22863a; 89 | background-color:#f0fff4 90 | } 91 | .hljs-deletion { 92 | color:#b31d28; 93 | background-color:#ffeef0 94 | } 95 | -------------------------------------------------------------------------------- /codingmore-admin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | codingmore-admin 6 | codingmore-admin 7 | 1.0-SNAPSHOT 8 | jar 9 | 10 | 11 | top.codingmore 12 | codingmore 13 | 1.0-SNAPSHOT 14 | ../pom.xml 15 | 16 | 17 | 18 | 19 | top.codingmore 20 | codingmore-common 21 | 1.0-SNAPSHOT 22 | 23 | 24 | top.codingmore 25 | codingmore-mbg 26 | 1.0-SNAPSHOT 27 | 28 | 29 | top.codingmore 30 | codingmore-security 31 | 1.0-SNAPSHOT 32 | 33 | 34 | com.aliyun.oss 35 | aliyun-sdk-oss 36 | 3.8.0 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-maven-plugin 46 | 47 | true 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /codingmore-security/src/main/java/com/codingmore/model/AdminUserDetails.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.codingmore.state.UserStatus; 4 | import org.springframework.security.core.GrantedAuthority; 5 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 6 | import org.springframework.security.core.userdetails.UserDetails; 7 | 8 | import java.util.Collection; 9 | import java.util.List; 10 | import java.util.stream.Collectors; 11 | 12 | /** 13 | * SpringSecurity需要的用户详情 14 | * Created by 石磊 on 2018/4/26. 15 | */ 16 | public class AdminUserDetails implements UserDetails { 17 | //后台用户 18 | private Users users; 19 | //拥有资源列表 20 | private List resourceList; 21 | public AdminUserDetails(Users users,List resourceList) { 22 | this.users = users; 23 | this.resourceList = resourceList; 24 | } 25 | 26 | @Override 27 | public Collection getAuthorities() { 28 | //返回当前用户的角色 29 | return resourceList.stream() 30 | .map(role ->new SimpleGrantedAuthority(role.getResourceId()+":"+role.getName())) 31 | .collect(Collectors.toList()); 32 | } 33 | 34 | @Override 35 | public String getPassword() { 36 | return users.getUserPass(); 37 | } 38 | 39 | @Override 40 | public String getUsername() { 41 | return users.getUserLogin(); 42 | } 43 | 44 | @Override 45 | public boolean isAccountNonExpired() { 46 | return true; 47 | } 48 | 49 | @Override 50 | public boolean isAccountNonLocked() { 51 | return true; 52 | } 53 | 54 | @Override 55 | public boolean isCredentialsNonExpired() { 56 | return true; 57 | } 58 | 59 | @Override 60 | public boolean isEnabled() { 61 | return users.getUserStatus().equals(UserStatus.ENABLE.getStatus()); 62 | } 63 | 64 | public Users getUsers(){ 65 | return this.users; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /codingmore-security/src/main/java/com/codingmore/component/DynamicAccessDecisionManager.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.component; 2 | 3 | import cn.hutool.core.collection.CollUtil; 4 | import org.springframework.security.access.AccessDecisionManager; 5 | import org.springframework.security.access.AccessDeniedException; 6 | import org.springframework.security.access.ConfigAttribute; 7 | import org.springframework.security.authentication.InsufficientAuthenticationException; 8 | import org.springframework.security.core.Authentication; 9 | import org.springframework.security.core.GrantedAuthority; 10 | 11 | import java.util.Collection; 12 | import java.util.Iterator; 13 | 14 | /** 15 | * 动态权限决策管理器,用于判断用户是否有访问权限 16 | * on 2020/2/7. 17 | */ 18 | public class DynamicAccessDecisionManager implements AccessDecisionManager { 19 | 20 | @Override 21 | public void decide(Authentication authentication, Object object, 22 | Collection configAttributes) throws AccessDeniedException, InsufficientAuthenticationException { 23 | // 当接口未被配置资源时直接放行 24 | if (CollUtil.isEmpty(configAttributes)) { 25 | return; 26 | } 27 | Iterator iterator = configAttributes.iterator(); 28 | while (iterator.hasNext()) { 29 | ConfigAttribute configAttribute = iterator.next(); 30 | //将访问所需资源或用户拥有资源进行比对 31 | String needAuthority = configAttribute.getAttribute(); 32 | for (GrantedAuthority grantedAuthority : authentication.getAuthorities()) { 33 | if (needAuthority.trim().equals(grantedAuthority.getAuthority())) { 34 | return; 35 | } 36 | } 37 | } 38 | throw new AccessDeniedException("抱歉,您没有访问权限"); 39 | } 40 | 41 | @Override 42 | public boolean supports(ConfigAttribute configAttribute) { 43 | return true; 44 | } 45 | 46 | @Override 47 | public boolean supports(Class aClass) { 48 | return true; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/Comments.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import java.util.Date; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableField; 7 | import java.io.Serializable; 8 | import io.swagger.annotations.ApiModel; 9 | import io.swagger.annotations.ApiModelProperty; 10 | import lombok.Data; 11 | import lombok.EqualsAndHashCode; 12 | 13 | /** 14 | *

15 | * 评论表 16 | *

17 | * 18 | * @author 石磊 19 | * @since 2021-09-12 20 | */ 21 | @Data 22 | @EqualsAndHashCode(callSuper = false) 23 | @ApiModel(value="Comments对象", description="评论表") 24 | public class Comments implements Serializable { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | @TableId(value = "comment_ID", type = IdType.AUTO) 29 | private Long commentId; 30 | 31 | @ApiModelProperty(value = "对应文章ID") 32 | @TableField("comment_post_ID") 33 | private Long commentPostId; 34 | 35 | @ApiModelProperty(value = "评论者") 36 | private String commentAuthor; 37 | 38 | @ApiModelProperty(value = "评论者邮箱") 39 | private String commentAuthorEmail; 40 | 41 | @ApiModelProperty(value = "评论者网址") 42 | private String commentAuthorUrl; 43 | 44 | @ApiModelProperty(value = "评论者IP") 45 | @TableField("comment_author_IP") 46 | private String commentAuthorIp; 47 | 48 | @ApiModelProperty(value = "评论时间") 49 | private Date commentDate; 50 | 51 | @ApiModelProperty(value = "评论正文") 52 | private String commentContent; 53 | 54 | @ApiModelProperty(value = "评论是否被批准") 55 | private String commentApproved; 56 | 57 | @ApiModelProperty(value = "评论者的USER AGENT") 58 | private String commentAgent; 59 | 60 | @ApiModelProperty(value = "评论类型(pingback/普通)") 61 | private String commentType; 62 | 63 | @ApiModelProperty(value = "父评论ID") 64 | private Long commentParent; 65 | 66 | @ApiModelProperty(value = "评论者用户ID(不一定存在)") 67 | private Long userId; 68 | 69 | 70 | 71 | } 72 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/UsersMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | users_id, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status, display_name, user_type,open_id,attribute 25 | 26 | 27 | 28 | c.users_id, user_login, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status, display_name, user_type,open_id,attribute 29 | 30 | 31 | 34 | 35 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/service/IUsersService.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service; 2 | 3 | import com.codingmore.model.Resource; 4 | import com.codingmore.model.Role; 5 | import com.codingmore.model.Users; 6 | import com.baomidou.mybatisplus.core.metadata.IPage; 7 | import com.baomidou.mybatisplus.extension.service.IService; 8 | import com.codingmore.dto.UpdateAdminPasswordParam; 9 | import com.codingmore.dto.UsersPageQueryParam; 10 | 11 | import org.springframework.security.core.userdetails.UserDetails; 12 | import org.springframework.transaction.annotation.Transactional; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | *

18 | * 用户表 服务类 19 | *

20 | * 21 | * @author 石磊 22 | * @since 2021-09-12 23 | */ 24 | public interface IUsersService extends IService { 25 | /** 26 | * 根据用户名获取后台管理员 27 | */ 28 | Users getAdminByUsername(String username); 29 | 30 | /** 31 | * 注册功能 32 | */ 33 | boolean register(Users users); 34 | 35 | /** 36 | * 登录功能 37 | * @param username 用户名 38 | * @param password 密码 39 | * @return 生成的JWT的token 40 | */ 41 | String login(String username,String password); 42 | 43 | /** 44 | * 刷新token的功能 45 | * @param oldToken 旧的token 46 | */ 47 | String refreshToken(String oldToken); 48 | 49 | /** 50 | * 修改密码 51 | */ 52 | int updatePassword(UpdateAdminPasswordParam updatePasswordParam); 53 | 54 | /** 55 | * 获取用户信息 56 | */ 57 | UserDetails loadUserByUsername(String username); 58 | 59 | /** 60 | * 获取当前登录用户 61 | * @return 62 | */ 63 | Users getCurrentLoginUser(); 64 | 65 | /** 66 | * 获取当前登录用户id 67 | * @return 68 | */ 69 | Long getCurrentUserId(); 70 | 71 | 72 | List getResourceList(Long adminId); 73 | 74 | /** 75 | * 获取用户对于角色 76 | */ 77 | List getRoleList(Long adminId); 78 | 79 | /** 80 | * 修改用户角色关系 81 | */ 82 | @Transactional 83 | int updateRole(Long adminId, List roleIds); 84 | 85 | 86 | /** 87 | * 自定义分页查询 88 | * 89 | */ 90 | IPage findByPage(UsersPageQueryParam param); 91 | 92 | boolean removeUser(Long usersId); 93 | } 94 | -------------------------------------------------------------------------------- /codingmore-admin/src/main/java/com/codingmore/config/CodingmoreSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.config; 2 | 3 | import com.codingmore.component.DynamicSecurityService; 4 | import com.codingmore.model.Resource; 5 | import com.codingmore.service.IResourceService; 6 | import com.codingmore.service.IUsersService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.security.access.ConfigAttribute; 11 | import org.springframework.security.access.SecurityConfig; 12 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 13 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 14 | import org.springframework.security.core.userdetails.UserDetailsService; 15 | 16 | import java.util.List; 17 | import java.util.Map; 18 | import java.util.concurrent.ConcurrentHashMap; 19 | 20 | /** 21 | * learn-admin-security模块相关配置 22 | * Created by zhanglei on 2019/11/9. 23 | */ 24 | @Configuration 25 | @EnableWebSecurity 26 | @EnableGlobalMethodSecurity(prePostEnabled = true) 27 | public class CodingmoreSecurityConfig extends CustomSecurityConfig { 28 | 29 | @Autowired 30 | private IUsersService usersService; 31 | @Autowired 32 | private IResourceService resourceService; 33 | 34 | @Bean 35 | public UserDetailsService userDetailsService() { 36 | //获取登录用户信息 37 | return username -> usersService.loadUserByUsername(username); 38 | } 39 | 40 | @Bean 41 | public DynamicSecurityService dynamicSecurityService() { 42 | return new DynamicSecurityService() { 43 | @Override 44 | public Map loadDataSource() { 45 | Map map = new ConcurrentHashMap<>(); 46 | List resources = resourceService.list(); 47 | resources.forEach(item->{ 48 | map.put(item.getUrl(), new SecurityConfig(item.getResourceId() + ":" + item.getName())); 49 | }); 50 | return map; 51 | } 52 | }; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /codingmore-admin/src/test/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | # 删减后的 DB 4 | username: codingmoretiny02 5 | password: Xw5y8bGFzb86DyGy 6 | driver-class-name: com.mysql.cj.jdbc.Driver 7 | url: jdbc:mysql://118.190.99.232:3306/codingmoretiny02?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false 8 | type: com.alibaba.druid.pool.DruidDataSource 9 | druid: 10 | #初始化连接池大小 11 | initial-size: 5 12 | #配置最小连接数 13 | min-idle: 5 14 | #配置最大连接数 15 | max-active: 200 16 | #配置连接等待超时时间 17 | max-wait: 60000 18 | #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 19 | time-between-eviction-runs-millis: 60000 20 | #配置一个连接在池中最小生存的时间,单位是毫秒 21 | min-evictable-idle-time-millis: 300000 22 | #测试连接 23 | validation-query: SELECT 1 FROM DUAL 24 | #申请连接的时候检测,建议配置为true,不影响性能,并且保证安全 25 | test-while-idle: true 26 | #获取连接时执行检测,建议关闭,影响性能 27 | test-on-borrow: false 28 | #归还连接时执行检测,建议关闭,影响性能 29 | test-on-return: false 30 | #是否开启PSCache,PSCache对支持游标的数据库性能提升巨大,oracle建议开启,mysql下建议关闭 31 | pool-prepared-statements: false 32 | #开启poolPreparedStatements后生效 33 | max-pool-prepared-statement-per-connection-size: 20 34 | #配置扩展插件,常用的插件有=>stat:监控统计 log4j:日志 wall:防御sql注入 35 | filters: stat,wall,slf4j 36 | #打开mergeSql功能;慢SQL记录 37 | connection-properties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 38 | #配置DruidStatFilter 39 | web-stat-filter: 40 | enabled: true 41 | url-pattern: "/*" 42 | exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*" 43 | #配置DruidStatViewServlet 44 | stat-view-servlet: 45 | url-pattern: "/druid/*" 46 | #登录名 47 | login-username: root 48 | #登录密码 49 | login-password: root 50 | 51 | 52 | redis: 53 | host: 118.190.99.232 # Redis服务器地址 54 | database: 0 # Redis数据库索引(默认为0) 55 | port: 6379 # Redis服务器连接端口 56 | password: learnsuccess # Redis服务器连接密码(默认为空) 57 | timeout: 300ms # 连接超时时间(毫秒) 58 | lettuce: 59 | pool: 60 | max-active: 1000 61 | min-idle: 0 62 | max-idle: 8 63 | max-wait: 3000 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/Users.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import java.util.Date; 5 | 6 | import com.baomidou.mybatisplus.annotation.TableField; 7 | import com.baomidou.mybatisplus.annotation.TableId; 8 | import java.io.Serializable; 9 | import java.util.Map; 10 | 11 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; 12 | import io.swagger.annotations.ApiModel; 13 | import io.swagger.annotations.ApiModelProperty; 14 | import lombok.Data; 15 | import lombok.EqualsAndHashCode; 16 | 17 | import javax.validation.constraints.NotBlank; 18 | 19 | /** 20 | *

21 | * 用户表 22 | *

23 | * 24 | * @author 石磊 25 | * @since 2021-09-12 26 | */ 27 | @Data 28 | @EqualsAndHashCode(callSuper = false) 29 | @ApiModel(value="Users对象", description="用户表") 30 | public class Users implements Serializable { 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | @ApiModelProperty(value = "ID") 35 | @TableId(value = "users_id", type = IdType.AUTO) 36 | private Long usersId; 37 | 38 | @ApiModelProperty(value = "登录名") 39 | @NotBlank(message="登录名不能为空") 40 | private String userLogin; 41 | 42 | @ApiModelProperty(value = "密码") 43 | @NotBlank(message="密码不能为空") 44 | private String userPass; 45 | 46 | @ApiModelProperty(value = "昵称") 47 | @NotBlank(message="昵称不能为空") 48 | private String userNicename; 49 | 50 | @ApiModelProperty(value = "Email") 51 | private String userEmail; 52 | 53 | @ApiModelProperty(value = "网址") 54 | private String userUrl; 55 | 56 | @ApiModelProperty(value = "注册时间") 57 | private Date userRegistered; 58 | 59 | @ApiModelProperty(value = "激活码") 60 | private String userActivationKey; 61 | 62 | @ApiModelProperty(value = "用户状态") 63 | private Integer userStatus; 64 | 65 | @ApiModelProperty(value = "图像") 66 | private String displayName; 67 | 68 | @ApiModelProperty(value = "用户类型 0 :后台 1:前端") 69 | private Integer userType; 70 | 71 | @ApiModelProperty(value = "openid") 72 | private String openId; 73 | 74 | @TableField(typeHandler = JacksonTypeHandler.class) 75 | @ApiModelProperty("属性") 76 | private Map attribute; 77 | 78 | } 79 | -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | username: root 4 | password: Codingmore123 5 | driver-class-name: com.mysql.cj.jdbc.Driver 6 | url: jdbc:mysql://127.0.0.1:3306/codingmore?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false 7 | type: com.alibaba.druid.pool.DruidDataSource 8 | druid: 9 | #初始化连接池大小 10 | initial-size: 5 11 | #配置最小连接数 12 | min-idle: 5 13 | #配置最大连接数 14 | max-active: 200 15 | #配置连接等待超时时间 16 | max-wait: 60000 17 | #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 18 | time-between-eviction-runs-millis: 60000 19 | #配置一个连接在池中最小生存的时间,单位是毫秒 20 | min-evictable-idle-time-millis: 300000 21 | #测试连接 22 | validation-query: SELECT 1 FROM DUAL 23 | #申请连接的时候检测,建议配置为true,不影响性能,并且保证安全 24 | test-while-idle: true 25 | #获取连接时执行检测,建议关闭,影响性能 26 | test-on-borrow: false 27 | #归还连接时执行检测,建议关闭,影响性能 28 | test-on-return: false 29 | #是否开启PSCache,PSCache对支持游标的数据库性能提升巨大,oracle建议开启,mysql下建议关闭 30 | pool-prepared-statements: false 31 | #开启poolPreparedStatements后生效 32 | max-pool-prepared-statement-per-connection-size: 20 33 | #配置扩展插件,常用的插件有=>stat:监控统计 log4j:日志 wall:防御sql注入 34 | filters: stat,wall,slf4j 35 | #打开mergeSql功能;慢SQL记录 36 | connection-properties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 37 | #配置DruidStatFilter 38 | web-stat-filter: 39 | enabled: true 40 | url-pattern: "/*" 41 | exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*" 42 | #配置DruidStatViewServlet 43 | stat-view-servlet: 44 | url-pattern: "/druid/*" 45 | #登录名 46 | login-username: root 47 | #登录密码 48 | login-password: 123456 49 | redis: 50 | host: 127.0.0.1 # Redis服务器地址 51 | database: 0 # Redis数据库索引(默认为0) 52 | port: 6379 # Redis服务器连接端口 53 | password: # Redis服务器连接密码(默认为空) 54 | # https://support.huaweicloud.com/usermanual-dcs/dcs-ug-0312024.html 55 | timeout: 0ms # 连接超时时间(毫秒)参数设为0表示连接永不断开。 56 | jedis: 57 | pool: 58 | max-active: 8 # 连接池最大连接数 59 | max-idle: 8 # 连接池最大空闲连接数 60 | min-idle: 0 # 连接池最小空闲连接数 61 | max-wait: -1ms # 连接池最大阻塞等待时间,负值表示没有限制 62 | 63 | 64 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/model/Posts.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import java.util.Date; 5 | 6 | import com.baomidou.mybatisplus.annotation.TableField; 7 | import com.baomidou.mybatisplus.annotation.TableId; 8 | import java.io.Serializable; 9 | import java.util.Map; 10 | 11 | import com.baomidou.mybatisplus.annotation.TableName; 12 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; 13 | import io.swagger.annotations.ApiModel; 14 | import io.swagger.annotations.ApiModelProperty; 15 | import lombok.Data; 16 | import lombok.EqualsAndHashCode; 17 | 18 | /** 19 | *

20 | * 文章 21 | *

22 | * 23 | * @author 石磊 24 | * @since 2021-09-12 25 | */ 26 | @Data 27 | @EqualsAndHashCode(callSuper = false) 28 | @ApiModel(value="Posts对象", description="文章") 29 | @TableName(autoResultMap = true) 30 | public class Posts implements Serializable { 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | @ApiModelProperty(value = "posts_id") 35 | @TableId(value = "posts_id", type = IdType.AUTO) 36 | private Long postsId; 37 | 38 | @ApiModelProperty(value = "对应作者ID") 39 | private Long postAuthor; 40 | 41 | @ApiModelProperty(value = "发布时间") 42 | private Date postDate; 43 | 44 | @ApiModelProperty(value = "正文") 45 | private String postContent; 46 | 47 | @ApiModelProperty(value = "标题") 48 | private String postTitle; 49 | 50 | @ApiModelProperty(value = "摘录") 51 | private String postExcerpt; 52 | 53 | @ApiModelProperty(value = "文章状态") 54 | private String postStatus; 55 | 56 | @ApiModelProperty(value = "评论状态") 57 | private String commentStatus; 58 | 59 | @ApiModelProperty(value = "修改时间") 60 | private Date postModified; 61 | 62 | @ApiModelProperty(value = "排序ID") 63 | private Integer menuOrder; 64 | 65 | @ApiModelProperty(value = "文章类型(post/page等)") 66 | private String postType; 67 | 68 | @ApiModelProperty(value = "评论总数") 69 | private Long commentCount; 70 | 71 | @ApiModelProperty(value = "浏览量") 72 | private Long pageView; 73 | 74 | @ApiModelProperty(value = "正文html") 75 | private String htmlContent; 76 | 77 | @TableField(typeHandler = JacksonTypeHandler.class) 78 | @ApiModelProperty("属性") 79 | private Map attribute; 80 | 81 | } 82 | -------------------------------------------------------------------------------- /codingmore-security/src/main/java/com/codingmore/component/DynamicSecurityMetadataSource.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.component; 2 | 3 | import cn.hutool.core.util.URLUtil; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.security.access.ConfigAttribute; 6 | import org.springframework.security.web.FilterInvocation; 7 | import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource; 8 | import org.springframework.util.AntPathMatcher; 9 | import org.springframework.util.PathMatcher; 10 | 11 | import javax.annotation.PostConstruct; 12 | import java.util.*; 13 | 14 | /** 15 | * 动态权限数据源,用于获取动态权限规则 16 | * on 2020/2/7. 17 | */ 18 | public class DynamicSecurityMetadataSource implements FilterInvocationSecurityMetadataSource { 19 | 20 | private static Map configAttributeMap = null; 21 | @Autowired 22 | private DynamicSecurityService dynamicSecurityService; 23 | 24 | @PostConstruct 25 | public void loadDataSource() { 26 | configAttributeMap = dynamicSecurityService.loadDataSource(); 27 | } 28 | 29 | public void clearDataSource() { 30 | configAttributeMap.clear(); 31 | configAttributeMap = null; 32 | } 33 | 34 | @Override 35 | public Collection getAttributes(Object o) throws IllegalArgumentException { 36 | if (configAttributeMap == null) this.loadDataSource(); 37 | List configAttributes = new ArrayList<>(); 38 | //获取当前访问的路径 39 | String url = ((FilterInvocation) o).getRequestUrl(); 40 | String path = URLUtil.getPath(url); 41 | PathMatcher pathMatcher = new AntPathMatcher(); 42 | Iterator iterator = configAttributeMap.keySet().iterator(); 43 | //获取访问该路径所需资源 44 | while (iterator.hasNext()) { 45 | String pattern = iterator.next(); 46 | if (pathMatcher.match(pattern, path)) { 47 | configAttributes.add(configAttributeMap.get(pattern)); 48 | } 49 | } 50 | // 未设置操作请求权限,返回空集合 51 | return configAttributes; 52 | } 53 | 54 | @Override 55 | public Collection getAllConfigAttributes() { 56 | return null; 57 | } 58 | 59 | @Override 60 | public boolean supports(Class aClass) { 61 | return true; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/resources/com/codingmore/mapper/AdminRoleRelationMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | admin_role_relation_id, users_id, role_id 15 | 16 | 17 | 18 | INSERT INTO admin_role_relation (users_id, role_id) VALUES 19 | 20 | (#{item.usersId,jdbcType=BIGINT}, 21 | #{item.roleId,jdbcType=BIGINT}) 22 | 23 | 24 | 29 | 30 | 31 | 50 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/dto/PostsPageQueryParam.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | @Data 9 | @EqualsAndHashCode(callSuper = false) 10 | @ApiModel(value="文章分页对象", description="文章") 11 | 12 | public class PostsPageQueryParam { 13 | long pageSize; 14 | long page; 15 | 16 | @ApiModelProperty(value = "排序字段,按数据库字段:menu_order,post_date,post_modified,page_view;多个以逗号间隔") 17 | private String orderBy; 18 | @ApiModelProperty(value = "是否升序,boolean类型") 19 | private boolean isAsc; 20 | @ApiModelProperty(value = "栏目id非必填") 21 | private Long termTaxonomyId; 22 | @ApiModelProperty(value = "标题关键字") 23 | private String postTitleKeyword; 24 | @ApiModelProperty(value = "要查询的标签id") 25 | private Long searchTagId; 26 | 27 | @ApiModelProperty(value = "文章状态PUBLISHED,DELETED,DRAFT") 28 | private String postStatus; 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /codingmore-web/src/main/java/com/codingmore/service/impl/ContentPageRequestStrategy.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.service.impl; 2 | 3 | import java.util.List; 4 | 5 | import com.codingmore.model.Site; 6 | import com.codingmore.service.ILearnWebRequestStrategy; 7 | import com.codingmore.service.IPostsService; 8 | import com.codingmore.service.ISiteService; 9 | import com.codingmore.util.WebRequestParam; 10 | import com.codingmore.vo.PostsVo; 11 | import com.codingmore.vo.SiteVo; 12 | 13 | import org.apache.commons.lang3.StringUtils; 14 | import org.springframework.beans.BeanUtils; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Service; 17 | import org.springframework.util.CollectionUtils; 18 | 19 | /** 20 | * 内容请求处理策略 21 | */ 22 | @Service("contentPageRequestStrategy") 23 | public class ContentPageRequestStrategy implements ILearnWebRequestStrategy { 24 | private static final String CONTENT_PAGE = "article.html"; 25 | private static final String POSTS_VO = "postsVo"; 26 | private static final String CLICKED_LIKE = "hasClickedLike"; 27 | /** 28 | * 站点信息 29 | */ 30 | private static final String SITE_CONFIG = "siteConfig"; 31 | 32 | private static final String TAG_LIST = "tagList"; 33 | @Autowired 34 | private ISiteService siteService; 35 | @Autowired 36 | private IPostsService iPostsService; 37 | 38 | @Override 39 | public String handleRequest(WebRequestParam webRequestParam) { 40 | iPostsService.increasePageView(webRequestParam.getPostId(),webRequestParam.getRequest()); 41 | 42 | Boolean hasClickedLike = iPostsService.hasClickedLike(webRequestParam.getPostId(),webRequestParam.getRequest()); 43 | webRequestParam.getRequest().setAttribute(CLICKED_LIKE, hasClickedLike); 44 | PostsVo postsVo = iPostsService.getPostsById(webRequestParam.getPostId()); 45 | webRequestParam.getRequest().setAttribute(POSTS_VO, postsVo); 46 | if(StringUtils.isNotBlank(postsVo.getTagsName())){ 47 | webRequestParam.getRequest().setAttribute(TAG_LIST, CollectionUtils.arrayToList(postsVo.getTagsName().split(","))); 48 | } 49 | List siteList = siteService.list(); 50 | //处理站点配置 51 | if(siteList.size() > 0) { 52 | Site site = siteList.get(0); 53 | SiteVo siteVo = new SiteVo(); 54 | BeanUtils.copyProperties(site, siteVo); 55 | webRequestParam.getRequest().setAttribute(SITE_CONFIG, siteVo); 56 | } 57 | return CONTENT_PAGE; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /codingmore-mbg/src/main/java/com/codingmore/vo/PostsVo.java: -------------------------------------------------------------------------------- 1 | package com.codingmore.vo; 2 | import com.baomidou.mybatisplus.annotation.TableField; 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; 5 | 6 | import com.codingmore.model.PostTag; 7 | import com.codingmore.util.DateUtil; 8 | import io.swagger.annotations.ApiModel; 9 | import io.swagger.annotations.ApiModelProperty; 10 | import lombok.Data; 11 | import lombok.EqualsAndHashCode; 12 | 13 | import java.util.Date; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | @Data 18 | @EqualsAndHashCode(callSuper = false) 19 | @ApiModel(value = "PostsVo", description = "文章Vo") 20 | @TableName(autoResultMap = true) 21 | public class PostsVo extends BaseVO { 22 | @ApiModelProperty(value = "postsId") 23 | private Long postsId; 24 | 25 | @ApiModelProperty(value = "对应作者ID") 26 | private Long postAuthor; 27 | 28 | @ApiModelProperty(value = "发布时间") 29 | private Date postDate; 30 | 31 | @ApiModelProperty(value = "正文") 32 | private String postContent; 33 | 34 | @ApiModelProperty(value = "标题") 35 | private String postTitle; 36 | 37 | @ApiModelProperty(value = "摘录") 38 | private String postExcerpt; 39 | 40 | @ApiModelProperty(value = "文章状态") 41 | private String postStatus; 42 | 43 | @ApiModelProperty(value = "评论状态") 44 | private String commentStatus; 45 | 46 | @ApiModelProperty(value = "修改时间") 47 | private Date postModified; 48 | 49 | @ApiModelProperty(value = "排序ID") 50 | private Integer menuOrder; 51 | 52 | 53 | @ApiModelProperty(value = "评论总数") 54 | private Long commentCount; 55 | 56 | @ApiModelProperty(value = "发布人") 57 | private String userNiceName; 58 | 59 | @ApiModelProperty(value = "栏目ID") 60 | private Long termTaxonomyId; 61 | 62 | @ApiModelProperty(value = "标签") 63 | private String tagsName; 64 | 65 | @ApiModelProperty(value = "标签带 ID 带名字") 66 | private List tags; 67 | 68 | @ApiModelProperty(value = "正文html") 69 | private String htmlContent; 70 | 71 | @TableField(typeHandler = JacksonTypeHandler.class) 72 | @ApiModelProperty("属性") 73 | private Map attribute; 74 | 75 | @ApiModelProperty("浏览量") 76 | private Long pageView; 77 | 78 | @ApiModelProperty("点赞") 79 | private Long likeCount; 80 | 81 | @ApiModelProperty("格式化修改时间") 82 | private String postModifiedShortTime; 83 | 84 | public String getPostModifiedShortTime() { 85 | return DateUtil.getShortTime(getPostModified()); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /codingmore-web/src/main/resources/static/css/index.css: -------------------------------------------------------------------------------- 1 | /* PC端样式 */ 2 | @media screen and (min-width: 751px) { 3 | 4 | /* 文章模块样式 */ 5 | .cloumn-item { 6 | width: 360px; 7 | } 8 | 9 | .cloumn-item .column-img-container { 10 | width: 360px; 11 | } 12 | 13 | .cloumn-item .column-img-container img { 14 | max-width: 360px; 15 | } 16 | 17 | .cloumn-item .title { 18 | font-size: 22px; 19 | margin-bottom: 15px; 20 | } 21 | 22 | .cloumn-item .link-item { 23 | display: flex; 24 | align-items: center; 25 | justify-content: space-between; 26 | padding-top: 12px; 27 | padding-bottom: 12px; 28 | border-top: 1px solid #dadada; 29 | } 30 | 31 | /* 文章标题样式 */ 32 | .cloumn-item .link-item a.link, 33 | .cloumn-item .link-item a.link:active, 34 | .cloumn-item .link-item a.link:visited { 35 | font-size: 18px; 36 | color: #333; 37 | } 38 | .cloumn-item .link-item a.link.bold{ 39 | font-weight: bold; 40 | } 41 | .cloumn-item .link-item a.link.green{ 42 | color: #63b175; 43 | } 44 | .cloumn-item .link-item a.link.blue{ 45 | color: #4976cb; 46 | } 47 | 48 | .cloumn-item .link-item a.text:hover { 49 | text-decoration: underline; 50 | } 51 | } 52 | 53 | /* 移动端样式 */ 54 | @media screen and (max-width: 750px) { 55 | /* 文章模块样式 */ 56 | 57 | .cloumn-item{ 58 | margin-top: 3vw; 59 | margin-bottom: 3vw; 60 | } 61 | 62 | .cloumn-item, 63 | .cloumn-item .column-img-container { 64 | width: auto; 65 | } 66 | 67 | .cloumn-item .column-img-container img { 68 | width: 100%; 69 | } 70 | 71 | .cloumn-item .title { 72 | font-size: 6vw; 73 | margin-bottom: 2vw; 74 | font-weight: bold; 75 | /* text-shadow: 0.5px 0.5px #000; */ 76 | } 77 | 78 | .cloumn-item .link-item { 79 | display: flex; 80 | align-items: center; 81 | justify-content: space-between; 82 | padding-top: 3vw; 83 | padding-bottom: 3vw; 84 | border-top: 1px solid #dadada; 85 | } 86 | 87 | /* 文章标题样式 */ 88 | .cloumn-item .link-item a.link, 89 | .cloumn-item .link-item a.link:active, 90 | .cloumn-item .link-item a.link:visited { 91 | font-size: 5vw; 92 | color: #333; 93 | } 94 | .cloumn-item .link-item a.link.bold{ 95 | font-weight: bold; 96 | } 97 | .cloumn-item .link-item a.link.green{ 98 | color: #63b175; 99 | } 100 | .cloumn-item .link-item a.link.blue{ 101 | color: #4976cb; 102 | } 103 | 104 | .cloumn-item .link-item a.text:hover { 105 | text-decoration: underline; 106 | } 107 | } --------------------------------------------------------------------------------