├── .editorconfig ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── README.md ├── build.gradle ├── doc ├── chinesereadme.md ├── sql │ ├── AboutPo.sql │ ├── CommentPO.sql │ ├── ContentTagRelation.sql │ ├── Content_update_2017-01-03.sql │ ├── ExecutionTimeLog.sql │ ├── TagPo.sql │ └── newAddDDL.sql └── todo.md ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── prod.bat ├── screencut ├── add_content.png ├── archive.png ├── gif │ ├── add.gif │ └── base.gif ├── index.png ├── register.png └── search.png ├── settings.gradle ├── sh ├── publish.sh ├── serverbuildjarpublish.sh ├── serverbuildjarstop.sh └── stop.sh └── src ├── main ├── docker │ ├── DockerFile │ └── Dockerfile ├── java │ └── com │ │ ├── App.java │ │ ├── generator │ │ ├── ProdTemplateGenerator.java │ │ └── ReplacePair.java │ │ └── rest │ │ ├── Request │ │ ├── AddContentRequest.java │ │ ├── AddTagRequest.java │ │ ├── CommentRequest.java │ │ ├── DeleteTagRequest.java │ │ ├── EditAboutRequest.java │ │ ├── EditContentRequest.java │ │ ├── EditTagRequest.java │ │ ├── LoginRequest.java │ │ ├── MyBatisLogRequest.java │ │ ├── RegisterRequest.java │ │ └── ReplyCommentRequest.java │ │ ├── annotation │ │ ├── AuthEnum.java │ │ ├── ExecutionTime.java │ │ ├── NeedAuth.java │ │ └── SwaggerIgnore.java │ │ ├── aop │ │ └── ExecutionTimeAspect.java │ │ ├── bean │ │ └── User.java │ │ ├── config │ │ ├── BlogProperty.java │ │ ├── Constants.java │ │ ├── MyWebAppConfigurer.java │ │ ├── SwaggerConfig.java │ │ └── dev │ │ │ └── DevDbConfig.java │ │ ├── constant │ │ ├── CookieConstants.java │ │ ├── LuceneFieldConstant.java │ │ ├── MarkDownConstant.java │ │ └── SessionConstants.java │ │ ├── controller │ │ ├── AboutController.java │ │ ├── ArchivesController.java │ │ ├── ArticleController.java │ │ ├── ChangeLanguageController.java │ │ ├── CommentController.java │ │ ├── LoginController.java │ │ ├── LogoutController.java │ │ ├── MyBatisLoggerController.java │ │ ├── PageListController.java │ │ ├── RegisterController.java │ │ ├── SearchController.java │ │ ├── TagController.java │ │ ├── TestController.java │ │ ├── admin │ │ │ ├── AdminController.java │ │ │ ├── ContentAddController.java │ │ │ ├── EditAboutController.java │ │ │ ├── EditController.java │ │ │ ├── ExecutionTimeController.java │ │ │ └── UploadImageController.java │ │ ├── customException │ │ │ ├── RegisterValidateException.java │ │ │ ├── TransactionException.java │ │ │ ├── UserAlreadyExistException.java │ │ │ ├── UserNotAuthRestException.java │ │ │ ├── UserNotExistException.java │ │ │ └── UserSessionTimeOutException.java │ │ ├── errors │ │ │ ├── CustomParameterizedException.java │ │ │ ├── ErrorConstants.java │ │ │ ├── ErrorVM.java │ │ │ ├── ExceptionTranslator.java │ │ │ ├── FieldErrorVM.java │ │ │ └── ParameterizedErrorVM.java │ │ └── response │ │ │ ├── LoginResponse.java │ │ │ ├── MyBatisLogResponse.java │ │ │ └── TextAndValue.java │ │ ├── converter │ │ ├── AriveConverter.java │ │ ├── CommentConvert.java │ │ ├── ContentConverter.java │ │ └── UserConverter.java │ │ ├── domain │ │ ├── AboutPo.java │ │ ├── AboutPo_update_2017-02-15.sql │ │ ├── Archives.java │ │ ├── CommentPO.java │ │ ├── Content.java │ │ ├── ContentTagRelation.java │ │ ├── ContentTime.java │ │ ├── ExecutionTimeLog.java │ │ ├── MyBatisLog.java │ │ ├── MyBatisLog.sql │ │ ├── TagPo.java │ │ └── UserPO.java │ │ ├── dto │ │ └── SearchResult.java │ │ ├── enums │ │ └── StatusEnum.java │ │ ├── event │ │ ├── DatabaseEventListener.java │ │ └── ExecutionTimeLogEvent.java │ │ ├── exception │ │ └── UserNotLoginException.java │ │ ├── intercetors │ │ ├── AccessInterceptor.java │ │ ├── AuthInterceptor.java │ │ └── ExecutionInterceptor.java │ │ ├── local │ │ └── MyLocaleCookieLocaleResolver.java │ │ ├── mapper │ │ ├── AboutPoDao.java │ │ ├── CommentPODao.java │ │ ├── ContentMapper.java │ │ ├── ContentTagRelationDao.java │ │ ├── ContentTimeMapper.java │ │ ├── ExecutionTimeLogDao.java │ │ ├── MyBatisLogDao.java │ │ ├── TagPoDao.java │ │ └── UserPODao.java │ │ ├── response │ │ ├── BaseResponse.java │ │ ├── CodeConstants.java │ │ ├── CodeEnum.java │ │ └── MsgConstants.java │ │ ├── scheduled │ │ ├── DumpMysql.java │ │ ├── ScheduledTask.java │ │ └── upload │ │ │ └── UploadDemo.java │ │ ├── service │ │ ├── AboutService.java │ │ ├── ContentService.java │ │ ├── LoginService.java │ │ ├── MessageSourceService.java │ │ ├── MyBatisLogService.java │ │ ├── SearchService.java │ │ ├── TagPoService.java │ │ └── disposer │ │ │ └── StaticResourceDisposaber.java │ │ ├── storage │ │ ├── FileSystemStorageService.java │ │ ├── StorageExceptioin.java │ │ ├── StorageFileNotFoundException.java │ │ ├── StorageProperties.java │ │ └── StorageService.java │ │ ├── utils │ │ ├── AntiSamyUtils.java │ │ ├── DbUtils.java │ │ ├── GsonUtils.java │ │ ├── HttpHeaderUtil.java │ │ ├── IpUtils.java │ │ ├── MarkDownUtil.java │ │ ├── MarkdownRequest.java │ │ ├── ScriptRunner.java │ │ └── SessionUtils.java │ │ └── vo │ │ ├── ArchiveVo.java │ │ ├── CommentVo.java │ │ ├── ContentForTagVo.java │ │ ├── ContentVo.java │ │ ├── MyBatisLogVo.java │ │ ├── PageContentVo.java │ │ ├── QueryResultVo.java │ │ └── TagVo.java └── resources │ ├── MessagesBundle.properties │ ├── MessagesBundle_en_US.properties │ ├── MessagesBundle_zh_CN.properties │ ├── MessagesBundle_zh_TW.properties │ ├── antisamy-myspace-1.4.4.xml │ ├── application-dev.yml │ ├── application-prod.yml │ ├── application.yml │ ├── ddl.sql │ ├── favicon.ico │ ├── liquibase.properties │ ├── logback-spring.xml │ ├── mapper │ ├── AboutPoDao.xml │ ├── CommentPODao.xml │ ├── ContentMapper.xml │ ├── ContentTagRelationDao.xml │ ├── ContentTimeMapper.xml │ ├── ExecutionTimeLogDao.xml │ ├── MyBatisLogDao.xml │ ├── TagPoDao.xml │ └── UserPODao.xml │ ├── mybatis-config.xml │ ├── public │ └── error │ │ └── 404.html │ ├── static │ ├── css │ │ ├── admin.css │ │ ├── blog.css │ │ ├── bootstrap-markdown.min.css │ │ ├── bootstrap-tagsinput.css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap-theme.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ ├── bootstrap.min.css.map │ │ ├── comment.css │ │ ├── fastselect.css │ │ ├── font-awesome.css │ │ ├── jquery-comments.css │ │ ├── login.css │ │ ├── markdown.css │ │ └── search.css │ ├── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ ├── fontawesome-webfont.woff2 │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ ├── img │ │ ├── add_content.png │ │ ├── anonymous.gif │ │ ├── article-marketing-black.png │ │ ├── article-marketing.png │ │ ├── calendar (1).png │ │ ├── calendar.png │ │ ├── dashboard.png │ │ ├── edit-content.png │ │ ├── email.png │ │ ├── folded-newspaper (1).png │ │ ├── folded-newspaper.png │ │ ├── home.png │ │ ├── logout.png │ │ ├── message-closed-envelope.png │ │ ├── mypic.jpg │ │ ├── price-tag.png │ │ ├── reply.png │ │ ├── rubbish-bin.png │ │ ├── tag.png │ │ └── user.png │ └── js │ │ ├── admin │ │ └── markdown.js │ │ ├── autosize.min.js │ │ ├── bootbox.min.js │ │ ├── bootstrap-tagsinput.js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ ├── bootstrap3-typeahead.js │ │ ├── esprima.js │ │ ├── fastsearch.js │ │ ├── fastselect.js │ │ ├── fastselect.standalone.js │ │ ├── i18n │ │ ├── en_US.js │ │ ├── zh_CN.js │ │ └── zh_TW.js │ │ ├── jquery-3.1.1.min.js │ │ ├── jquery-comments.min.js │ │ ├── jquery-ui.min.js │ │ ├── jquery.validate.min.js │ │ ├── mymarkdown.js │ │ ├── npm.js │ │ ├── showdown.js │ │ ├── showdown.min.js │ │ └── xss.js │ └── templates │ ├── about.ftl │ ├── add.ftl │ ├── admin.ftl │ ├── archive.ftl │ ├── article.ftl │ ├── edit.ftl │ ├── footerjs.ftl │ ├── head_header.ftl │ ├── header.ftl │ ├── header_admin.ftl │ ├── index.ftl │ ├── login.ftl │ ├── markdown.ftl │ ├── markdown_btngroup.ftl │ ├── markdown_modal.ftl │ ├── mybatisLogView.ftl │ ├── searchPage.ftl │ ├── tag.ftl │ ├── tagContent.ftl │ ├── test.ftl │ ├── test_verticle.ftl │ └── uploadForm.ftl └── test └── java ├── basic └── AbstractTest.java └── com ├── MarkDownTest.java ├── MybatisApplicationTest.java ├── PropertyTest.java ├── RestApplicationTest.java └── rest ├── FileTest.java ├── exception └── ExceptionTest.java ├── i18n └── I18NSample.java ├── jsoup └── XssTest.java ├── mapper ├── ContentMapperTest.java ├── ContentTimeMapperTest.java ├── ExecutionTimeLogDaoTest.java └── TagMapperTest.java ├── markdown ├── ExtractLinkTest.java └── MarkDownMatcherTest.java ├── service └── UserPOServiceTest.java ├── utils ├── GuavaTest.java ├── JoinerTest.java ├── RandomStringUtilsTest.java ├── SearchServiceTest.java └── StringUtilsTest.java └── xss └── AntiSamyTest.java /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = space 9 | 10 | [*.{java,xml}] 11 | indent_size = 4 12 | trim_trailing_whitespace = true 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | /.gradle/ 3 | /logs/ 4 | /out/ 5 | /.idea/ 6 | /build/ 7 | *.log 8 | *.iml 9 | /node_modules/ 10 | /src/main/resources/prod-templates/ 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: oraclejdk8 3 | install: true 4 | before_install: 5 | - chmod +x gradlew 6 | script: 7 | - ./gradlew build -x test 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | v1.0 2 | ----------------------- 3 | * 使用gradle来部署 4 | * 基本功能都可以工作 5 | 6 | 7 | v1.1 (UNRELEASED) 8 | --------------------------- 9 | * 使用shiro来进行权限管理 10 | * 改善markdown遇到xss的显示 11 | * 改善界面 12 | * 可以在界面上更改语言 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [bootstrap-java-blog](https://brucege.com) 2 | 3 | [![Build Status](https://travis-ci.org/gejun123456/bootstrap-java-blog.svg?branch=master)](https://travis-ci.org/gejun123456/bootstrap-java-blog) 4 |

base on bootstrap and java

5 | 6 | [中文说明](https://github.com/gejun123456/bootstrap-java-blog/blob/master/doc/chinesereadme.md) 7 | 8 | feature 9 | ------------ 10 | - bootstrap simple style, good device compatibility 11 | - just in time support for markdown to add or edit. 12 | - full search ability. 13 | - nice for mobile add or edit. 14 | 15 | Requirements 16 | ------------ 17 | - git 18 | - jdk8 19 | - mysql 20 | 21 | That's all, base package of java web environment! 22 | 23 | Installation 24 | ------------ 25 | - get your mysql installed. 26 | - git clone https://github.com/gejun123456/bootstrap-java-blog.git 27 | - config your database `src\main\resources\application.properties` 28 | - cd bootstrap-java-blog 29 | - gradlew clean build -x test 30 | - java -jar build/libs/bootstrap.javablog.jar 31 | - open localhost:8080 to see if works right. 32 | 33 | Quick Start 34 | ------------- 35 | - register a user (the first user you create will be admin) 36 | - do everything in the next. 37 | 38 | To Do List 39 | ---------- 40 | add admin page 41 | make page more beautiful 42 | 43 | Custom 44 | -------- 45 | - you can use a different port like java -jar target/attchment.jar --server.port=9090 46 | - edit your own about in `src\main\resources\templates\about.ftl` 47 | 48 | Screenshots 49 | ----------- 50 | ![base](https://github.com/gejun123456/bootstrap-java-blog/blob/master/screencut/gif/base.gif) 51 | ![add](https://github.com/gejun123456/bootstrap-java-blog/blob/master/screencut/gif/add.gif) 52 | 53 | 54 | 55 | 56 | Discussion 57 | ----------- 58 | email:gejun123456@gmail.com 59 | qq:1098632410@qq.com -------------------------------------------------------------------------------- /doc/chinesereadme.md: -------------------------------------------------------------------------------- 1 | # [bootstrap-java-blog](https://brucege.com) 2 | 3 | [![Build Status](https://travis-ci.org/gejun123456/bootstrap-java-blog.svg?branch=master)](https://travis-ci.org/gejun123456/bootstrap-java-blog) 4 |

基于 bootstrap + java + lucene

5 | 6 | 特点 7 | --- 8 | - bootstrap简单的风格,拥有良好的设备兼容性 9 | - 实时预览markdown 10 | - 完整的搜索功能 11 | 12 | 运行要求 13 | ---- 14 | - git 15 | - jdk8 16 | - mysql 17 | 18 | 安装 19 | --- 20 | - 安装mysql 21 | - 运行 git clone https://github.com/gejun123456/bootstrap-java-blog.git 22 | - 在 `src\main\resources\application.properties` 配置数据库 23 | - cd bootstrap-java-blog 24 | - gradlew clean build -x test 25 | - java -jar build/libs/bootstrap.javablog.jar 26 | - 打开localhost:8080 查看是否运行正确 27 | 28 | 快速开始 29 | ---- 30 | - 注册一个用户(第一个注册的用户将会是管理员) 31 | - 随意进行操作吧! 32 | 33 | To Do list 34 | ---------- 35 | - 美化页面 36 | - 加上tag 37 | 38 | 自定义 39 | --- 40 | - 可以部署在不同的端口 例如 java -jar target/attchment.jar --server.port=9090 41 | - 在文件 `src\main\resources\templates\about.ftl` 编辑自己的关于 42 | 43 | 截图 44 | --- 45 | ![base](https://github.com/gejun123456/bootstrap-java-blog/blob/master/screencut/gif/base.gif) 46 | ![add](https://github.com/gejun123456/bootstrap-java-blog/blob/master/screencut/gif/add.gif) 47 | 48 | 49 | 讨论 50 | --- 51 | email:gejun123456@gmail.com 52 | qq:1098632410@qq.com -------------------------------------------------------------------------------- /doc/sql/AboutPo.sql: -------------------------------------------------------------------------------- 1 | -- auto Generated on 2017-01-08 22:37:34 2 | -- DROP TABLE IF EXISTS `about_po`; 3 | CREATE TABLE `about_po`( 4 | `id` INT (11) NOT NULL AUTO_INCREMENT COMMENT 'id', 5 | `source_content` TEXT NOT NULL COMMENT 'sourceContent', 6 | `create_time` DATETIME NOT NULL DEFAULT '1000-01-01 00:00:00' COMMENT 'createTime', 7 | `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'updateTime', 8 | `user_id` INT (11) NOT NULL DEFAULT -1 COMMENT 'userId', 9 | PRIMARY KEY (`id`) 10 | )ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '`about_po`'; 11 | -------------------------------------------------------------------------------- /doc/sql/CommentPO.sql: -------------------------------------------------------------------------------- 1 | -- auto Generated on 2016-12-07 17:14:03 2 | -- DROP TABLE IF EXISTS `comment_p_o`; 3 | CREATE TABLE comment_p_o( 4 | `id` INTEGER(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'id', 5 | `article_id` INTEGER(12) NOT NULL DEFAULT -1 COMMENT 'article_id', 6 | `reply_id` INTEGER(12) NOT NULL DEFAULT -1 COMMENT 'reply_id', 7 | `username` VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'username', 8 | `content` VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'content', 9 | `addtime` DATETIME NOT NULL DEFAULT '1000-01-01 00:00:00' COMMENT 'addtime', 10 | `updatetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'updatetime', 11 | `viewed` tinyint NOT NULL DEFAULT -1 COMMENT 'viewed', 12 | `comment_ip` VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'comment_ip', 13 | PRIMARY KEY (`id`) 14 | )ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'comment_p_o'; 15 | -------------------------------------------------------------------------------- /doc/sql/ContentTagRelation.sql: -------------------------------------------------------------------------------- 1 | -- auto Generated on 2017-01-25 14:47:06 2 | -- DROP TABLE IF EXISTS `content_tag_relation`; 3 | CREATE TABLE `content_tag_relation`( 4 | `id` INT (11) NOT NULL AUTO_INCREMENT COMMENT 'id', 5 | `content_id` INT (11) NOT NULL DEFAULT -1 COMMENT 'contentId', 6 | `tag_id` INT (11) NOT NULL DEFAULT -1 COMMENT 'tagId', 7 | `create_time` DATETIME NOT NULL DEFAULT '1000-01-01 00:00:00' COMMENT 'createTime', 8 | `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'updateTime', 9 | PRIMARY KEY (`id`), 10 | key(`content_id`), 11 | key(`tag_id`) 12 | )ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '`content_tag_relation`'; 13 | -------------------------------------------------------------------------------- /doc/sql/Content_update_2017-01-03.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE content ADD user_id int(11) NOT NULL DEFAULT '' COMMENT 'userId'; 2 | ALTER TABLE content ADD status int(11) NOT NULL DEFAULT -1 COMMENT 'status'; 3 | -------------------------------------------------------------------------------- /doc/sql/ExecutionTimeLog.sql: -------------------------------------------------------------------------------- 1 | -- auto Generated on 2017-01-08 04:21:20 2 | -- DROP TABLE IF EXISTS `execution_time_log`; 3 | CREATE TABLE `execution_time_log`( 4 | `id` INT (11) NOT NULL AUTO_INCREMENT COMMENT 'id', 5 | `class_name` VARCHAR (50) NOT NULL DEFAULT '' COMMENT 'className', 6 | `method_name` VARCHAR (50) NOT NULL DEFAULT '' COMMENT 'methodName', 7 | `execution_time` BIGINT (15) NOT NULL DEFAULT -1 COMMENT 'executionTime', 8 | `args_value` TEXT NOT NULL COMMENT 'argsValue', 9 | `create_time` DATETIME NOT NULL DEFAULT '1000-01-01 00:00:00' COMMENT 'createTime', 10 | PRIMARY KEY (`id`) 11 | )ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '`execution_time_log`'; 12 | -------------------------------------------------------------------------------- /doc/sql/TagPo.sql: -------------------------------------------------------------------------------- 1 | -- auto Generated on 2017-01-25 14:44:48 2 | -- DROP TABLE IF EXISTS `tag_po`; 3 | CREATE TABLE `tag_po`( 4 | `id` INT (11) NOT NULL AUTO_INCREMENT COMMENT 'id', 5 | `tag_name` VARCHAR (50) NOT NULL DEFAULT '' COMMENT 'tagName', 6 | `create_time` DATETIME NOT NULL DEFAULT '1000-01-01 00:00:00' COMMENT 'createTime', 7 | `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'updateTime', 8 | PRIMARY KEY (`id`) 9 | )ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '`tag_po`'; 10 | -------------------------------------------------------------------------------- /doc/sql/newAddDDL.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE user_p_o ADD verified tinyint(1) NOT NULL DEFAULT 0 COMMENT 'verified'; 2 | ALTER TABLE user_p_o ADD create_time DATETIME NOT NULL DEFAULT '1000-01-01 00:00:00' COMMENT 'createTime'; 3 | -------------------------------------------------------------------------------- /doc/todo.md: -------------------------------------------------------------------------------- 1 | # unreleased 2 | 3 | * 添加service 增加事务支持 对出错情况进行控制 4 | * jquery添加多语言支持 5 | * 界面可更改语言 6 | * 使用开源的markdown编辑器 7 | * 增加后台 8 | * 能够支持换皮肤 9 | * mybatis添加cache支持 10 | * 評論使用jquery validator -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Dec 24 16:47:43 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-all.zip 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /prod.bat: -------------------------------------------------------------------------------- 1 | call gradlew updateProd 2 | call gradlew build -x test 3 | call java -Xms128m -Xmx512m -Dspring.profiles.active=prod -Djava.security.egd=file:/dev/./urandom -jar build/libs/bootstrap.javablog-1.0.jar 4 | -------------------------------------------------------------------------------- /screencut/add_content.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/screencut/add_content.png -------------------------------------------------------------------------------- /screencut/archive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/screencut/archive.png -------------------------------------------------------------------------------- /screencut/gif/add.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/screencut/gif/add.gif -------------------------------------------------------------------------------- /screencut/gif/base.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/screencut/gif/base.gif -------------------------------------------------------------------------------- /screencut/index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/screencut/index.png -------------------------------------------------------------------------------- /screencut/register.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/screencut/register.png -------------------------------------------------------------------------------- /screencut/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/screencut/search.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'bootstrap.javablog' 2 | -------------------------------------------------------------------------------- /sh/publish.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | serverPort=$1 3 | projectName=$2 4 | configFile=$3 5 | 6 | configFolder=resources 7 | 8 | #Constans 9 | logFile=initServer.log 10 | dstLogFile=$logFile 11 | 12 | destFile=attchment-1.0.jar 13 | 14 | whatToFind="Tomcat started" 15 | msgLogFileCreated="$logFile created" 16 | msgAppStarted="Application Started... exiting buffer!" 17 | 18 | ### Functions 19 | ####### 20 | 21 | function deleteFiles(){ 22 | echo "Deleting files" 23 | rm -rf * 24 | echo "" 25 | } 26 | 27 | #function copyFiles(){ 28 | # echo "Copying files from $sourFile" 29 | # cp $sourFile $destFile 30 | # 31 | # echo "Copying files from $sourConfigFolder" 32 | # cp -r $sourConfigFolder $destConfigFolder 33 | # 34 | # echo " " 35 | #} 36 | function movefile(){ 37 | echo "move from deploy to the source" 38 | mv todeploy/$destFile $destFile 39 | echo "file moved" 40 | } 41 | function run(){ 42 | rm -r $dstLogFile 43 | touch $dstLogFile 44 | nohup nice java -Xms128m -Xmx512m -Dspring.profiles.active=production -Djava.security.egd=file:/dev/./urandom -jar $destFile --server.port=$serverPort >> $dstLogFile 2>&1 & 45 | echo "COMMAND:nohup nice java -Xms128m -Xmx512m -Dspring.profiles.active=production -Djava.security.egd=file:/dev/./urandom -jar $destFile --server.port=$serverPort > $dstLogFile 2>&1 &" 46 | echo "" 47 | } 48 | 49 | function watch(){ 50 | tail -f $dstLogFile | 51 | while IFS= read line 52 | do 53 | echo "$msgBuffer" "$line" 54 | 55 | if [[ "$line" == *"$whatToFind"* ]]; 56 | then echo $msgAppstarted 57 | pkill tail 58 | fi 59 | done 60 | } 61 | 62 | movefile 63 | run 64 | watch 65 | -------------------------------------------------------------------------------- /sh/serverbuildjarpublish.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | serverPort=$1 3 | projectName=$2 4 | configFile=$3 5 | 6 | #Constans 7 | logFile=initServer.log 8 | dstLogFile=$logFile 9 | 10 | destFile=target/attchment-1.0.jar 11 | 12 | deployfilename=app.jar 13 | 14 | deployLoc=/opt/deploy/my-java-blog/ 15 | 16 | oldLoc=/opt/old/my-java-blog/ 17 | 18 | whatToFind="Tomcat started" 19 | msgLogFileCreated="$logFile created" 20 | msgAppStarted="Application Started... exiting buffer!" 21 | 22 | ### Functions 23 | 24 | ####### 25 | function deleteFiles(){ 26 | echo "Deleting files" 27 | rm -rf * 28 | echo "" 29 | } 30 | 31 | #function copyFiles(){ 32 | # echo "Copying files from $sourFile" 33 | # cp $sourFile $destFile 34 | # 35 | # echo "Copying files from $sourConfigFolder" 36 | # cp -r $sourConfigFolder $destConfigFolder 37 | # 38 | # echo " " 39 | #} 40 | movefile(){ 41 | 42 | #need first move old to to the old loc 43 | echo "move old jar to old directory" 44 | mkdir -p $oldLoc 45 | mv $deployLoc$deployfilename $oldLoc 46 | 47 | echo "move new jar to deploy folder" 48 | mkdir -p $deployLoc 49 | mv $destFile $deployLoc$deployfilename 50 | cd $deployLoc 51 | } 52 | function run(){ 53 | rm -r $dstLogFile 54 | touch $dstLogFile 55 | nohup nice java -Xms128m -Xmx512m -Dspring.profiles.active=production -Djava.security.egd=file:/dev/./urandom -jar $deployfilename --server.port=$serverPort >> $dstLogFile 2>&1 & 56 | echo "COMMAND:nohup nice java -Xms128m -Xmx512m -Dspring.profiles.active=production -Djava.security.egd=file:/dev/./urandom -jar $deployfilename --server.port=$serverPort > $dstLogFile 2>&1 &" 57 | echo "" 58 | } 59 | 60 | function watch(){ 61 | tail -f $dstLogFile | 62 | while IFS= read line 63 | do 64 | echo "$msgBuffer" "$line" 65 | 66 | if [[ "$line" == *"$whatToFind"* ]]; 67 | then echo $msgAppstarted 68 | pkill tail 69 | fi 70 | done 71 | } 72 | movefile 73 | run 74 | watch 75 | -------------------------------------------------------------------------------- /sh/serverbuildjarstop.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | serverPort=$1 3 | projectName=$2 4 | configFile=$3 5 | now=$(date +"%Y_%m_%d") 6 | echo $now 7 | 8 | configFolder=resources 9 | 10 | #Constans 11 | logFile=initServer.log 12 | dstLogFile=$logFile 13 | 14 | destFile=target/attchment-1.0.jar 15 | 16 | whatToFind="Tomcat started" 17 | msgLogFileCreated="$logFile created" 18 | msgAppStarted="Application Started... exiting buffer!" 19 | 20 | #first move data for archive and dothings. 21 | 22 | function stopServer(){ 23 | #first check if is alived 24 | echo "stop server started, first the check if it's alived now" 25 | curl localhost:$serverPort 26 | if [ "$?" = "0" ] 27 | then echo "the server alived go stop it" 28 | echo "Stopping process on port:$serverPort" 29 | mm=$(curl -X POST localhost:$serverPort/shutdown) 30 | #post ended" 31 | echo $mm 32 | fi 33 | echo "go to check the status of the server" 34 | 35 | # curl localhost:$serverPort 36 | ##check if 7 is exit status if is 7 means it's still alived. 37 | # while [ "$?" = "0" ] 38 | # do 39 | # echo "the server still lived" 40 | # curl localhost:$serverPort 41 | # done 42 | portlived=$(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".'"$serverPort"'"') 43 | while [[ $portlived = *"LISTEN"* ]] 44 | do 45 | echo "the port is still listen" 46 | portlived=$(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".'"$serverPort"'"') 47 | done 48 | echo "the server is stopped" 49 | } 50 | 51 | stopServer 52 | -------------------------------------------------------------------------------- /sh/stop.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | serverPort=$1 3 | projectName=$2 4 | configFile=$3 5 | now=$(date +"%Y_%m_%d") 6 | echo $now 7 | 8 | configFolder=resources 9 | 10 | #Constans 11 | logFile=initServer.log 12 | dstLogFile=$logFile 13 | 14 | destFile=attchment-1.0.jar 15 | 16 | whatToFind="Tomcat started" 17 | msgLogFileCreated="$logFile created" 18 | msgAppStarted="Application Started... exiting buffer!" 19 | 20 | #first move data for archive and dothings. 21 | moveold(){ 22 | if [ -d "old" ] 23 | then echo "old exist" 24 | else 25 | mkdir old 26 | fi 27 | if [ -f $destFile ] 28 | then 29 | echo "move file to old diretory" 30 | mv $destFile old/attchment_old${now}.jar 31 | fi 32 | } 33 | 34 | 35 | function stopServer(){ 36 | #first check if is alived 37 | echo "stop server started, first the check if it's alived now" 38 | curl localhost:$serverPort 39 | if [ "$?" = "0" ] 40 | then echo "the server alived go stop it" 41 | echo "Stopping process on port:$serverPort" 42 | mm=$(curl -X POST localhost:$serverPort/shutdown) 43 | #post ended" 44 | echo $mm 45 | fi 46 | echo "go to check the status of the server" 47 | 48 | # curl localhost:$serverPort 49 | ##check if 7 is exit status if is 7 means it's still alived. 50 | # while [ "$?" = "0" ] 51 | # do 52 | # echo "the server still lived" 53 | # curl localhost:$serverPort 54 | # done 55 | portlived=$(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".'"$serverPort"'"') 56 | while [[ $portlived = *"LISTEN"* ]] 57 | do 58 | echo "the port is still listen" 59 | portlived=$(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".'"$serverPort"'"') 60 | done 61 | echo "the server is stopped" 62 | } 63 | 64 | stopServer 65 | moveold -------------------------------------------------------------------------------- /src/main/docker/DockerFile: -------------------------------------------------------------------------------- 1 | FROM frolvlad/alpine-oraclejdk8:slim 2 | VOLUME /tmp 3 | ADD attchment-1.0.jar app.jar 4 | RUN sh -c 'touch /app.jar' 5 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] -------------------------------------------------------------------------------- /src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM frolvlad/alpine-oraclejdk8:slim 2 | VOLUME /tmp 3 | ADD attchment-1.0.jar app.jar 4 | RUN sh -c 'touch /app.jar' 5 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] -------------------------------------------------------------------------------- /src/main/java/com/App.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import com.rest.storage.StorageService; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.ComponentScan; 10 | import org.springframework.context.annotation.Configuration; 11 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 12 | import org.springframework.core.env.Environment; 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | 16 | import javax.inject.Inject; 17 | 18 | /** 19 | * Created by bruce.ge on 2016/10/23. 20 | */ 21 | @Controller 22 | @EnableAutoConfiguration 23 | @Configuration 24 | //@ComponentScan(basePackages = {"com.rest.config", "com.rest.controller", "com.rest.service", 25 | // "com.rest.aop", "com.rest.mapper", "com.rest.service", "com.rest.storage", 26 | // "com.rest.intercetors" 27 | //}) 28 | @ComponentScan 29 | @EnableAspectJAutoProxy 30 | @Slf4j 31 | public class App { 32 | 33 | @Inject 34 | private Environment env; 35 | 36 | @RequestMapping("/") 37 | String home() { 38 | return "forward:/page/1"; 39 | } 40 | 41 | public static void main(String[] args) { 42 | SpringApplication.run(App.class, args); 43 | } 44 | 45 | @Bean 46 | CommandLineRunner init(final StorageService storageService) { 47 | return new CommandLineRunner() { 48 | @Override 49 | public void run(String... args) throws Exception { 50 | // no need to delete file. 51 | log.info("start to init storage service"); 52 | storageService.init(); 53 | log.info("storage service inited"); 54 | } 55 | }; 56 | } 57 | 58 | 59 | // the bean name shall be this. 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/generator/ReplacePair.java: -------------------------------------------------------------------------------- 1 | package com.generator; 2 | 3 | /** 4 | * @Author bruce.ge 5 | * @Date 2017/1/23 6 | * @Description 7 | */ 8 | public class ReplacePair { 9 | String devPath; 10 | 11 | String cdnPath; 12 | 13 | 14 | public ReplacePair(String devPath, String cdnPath) { 15 | this.devPath = devPath; 16 | this.cdnPath = cdnPath; 17 | } 18 | 19 | public String getDevPath() { 20 | return devPath; 21 | } 22 | 23 | public void setDevPath(String devPath) { 24 | this.devPath = devPath; 25 | } 26 | 27 | public String getCdnPath() { 28 | return cdnPath; 29 | } 30 | 31 | public void setCdnPath(String cdnPath) { 32 | this.cdnPath = cdnPath; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/rest/Request/AddContentRequest.java: -------------------------------------------------------------------------------- 1 | package com.rest.Request; 2 | 3 | import lombok.Data; 4 | import org.hibernate.validator.constraints.Length; 5 | import org.hibernate.validator.constraints.NotEmpty; 6 | import org.hibernate.validator.constraints.SafeHtml; 7 | 8 | /** 9 | * Created by bruce.ge on 2016/11/6. 10 | */ 11 | @Data 12 | public class AddContentRequest { 13 | @NotEmpty 14 | @Length(max = 100) 15 | @SafeHtml 16 | private String title; 17 | 18 | @NotEmpty 19 | @Length(max = 5000) 20 | private String sourceContent; 21 | 22 | @NotEmpty 23 | @SafeHtml 24 | @Length(max = 6000) 25 | private String sourceHtml; 26 | 27 | @NotEmpty 28 | @SafeHtml 29 | @Length(max = 2000) 30 | private String indexHtml; 31 | 32 | 33 | private String tagValue; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/rest/Request/AddTagRequest.java: -------------------------------------------------------------------------------- 1 | package com.rest.Request; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.hibernate.validator.constraints.NotEmpty; 6 | 7 | /** 8 | * @Author bruce.ge 9 | * @Date 2017/1/25 10 | * @Description 11 | */ 12 | @Getter 13 | @Setter 14 | public class AddTagRequest { 15 | @NotEmpty 16 | private String name; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/rest/Request/CommentRequest.java: -------------------------------------------------------------------------------- 1 | package com.rest.Request; 2 | 3 | import org.hibernate.validator.constraints.Length; 4 | import org.hibernate.validator.constraints.SafeHtml; 5 | 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * Created by bruce.ge on 2016/11/18. 10 | */ 11 | public class CommentRequest { 12 | 13 | @NotNull 14 | @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE) 15 | @Length(max = 50) 16 | private String name; 17 | 18 | @NotNull 19 | @Length(max = 500) 20 | @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE) 21 | private String content; 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | 31 | public String getContent() { 32 | return content; 33 | } 34 | 35 | public void setContent(String content) { 36 | this.content = content; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "CommentRequest{" + 42 | "name='" + name + '\'' + 43 | ", content='" + content + '\'' + 44 | '}'; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/rest/Request/DeleteTagRequest.java: -------------------------------------------------------------------------------- 1 | package com.rest.Request; 2 | 3 | 4 | import javax.validation.constraints.NotNull; 5 | 6 | /** 7 | * @Author bruce.ge 8 | * @Date 2017/2/1 9 | * @Description 10 | */ 11 | public class DeleteTagRequest { 12 | @NotNull 13 | private Integer tagId; 14 | 15 | public Integer getTagId() { 16 | return tagId; 17 | } 18 | 19 | public void setTagId(Integer tagId) { 20 | this.tagId = tagId; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/rest/Request/EditAboutRequest.java: -------------------------------------------------------------------------------- 1 | package com.rest.Request; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.hibernate.validator.constraints.NotEmpty; 6 | 7 | /** 8 | * @Author bruce.ge 9 | * @Date 2017/2/15 10 | * @Description 11 | */ 12 | @Getter 13 | @Setter 14 | public class EditAboutRequest { 15 | 16 | @NotEmpty 17 | private String sourceContent; 18 | 19 | @NotEmpty 20 | private String sourceHtml; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/rest/Request/EditContentRequest.java: -------------------------------------------------------------------------------- 1 | package com.rest.Request; 2 | 3 | /** 4 | * Created by bruce.ge on 2016/11/13. 5 | */ 6 | public class EditContentRequest { 7 | private String title; 8 | 9 | private String sourceContent; 10 | 11 | private Integer id; 12 | 13 | 14 | public String getTitle() { 15 | return title; 16 | } 17 | 18 | public void setTitle(String title) { 19 | this.title = title; 20 | } 21 | 22 | public String getSourceContent() { 23 | return sourceContent; 24 | } 25 | 26 | public void setSourceContent(String sourceContent) { 27 | this.sourceContent = sourceContent; 28 | } 29 | 30 | public Integer getId() { 31 | return id; 32 | } 33 | 34 | public void setId(Integer id) { 35 | this.id = id; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/rest/Request/EditTagRequest.java: -------------------------------------------------------------------------------- 1 | package com.rest.Request; 2 | 3 | import org.hibernate.validator.constraints.NotBlank; 4 | 5 | import javax.validation.constraints.NotNull; 6 | 7 | /** 8 | * @Author bruce.ge 9 | * @Date 2017/2/1 10 | * @Description 11 | */ 12 | public class EditTagRequest { 13 | 14 | @NotNull 15 | private Integer tagId; 16 | 17 | @NotBlank 18 | private String newTagName; 19 | 20 | public Integer getTagId() { 21 | return tagId; 22 | } 23 | 24 | public void setTagId(Integer tagId) { 25 | this.tagId = tagId; 26 | } 27 | 28 | public String getNewTagName() { 29 | return newTagName; 30 | } 31 | 32 | public void setNewTagName(String newTagName) { 33 | this.newTagName = newTagName; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/rest/Request/LoginRequest.java: -------------------------------------------------------------------------------- 1 | package com.rest.Request; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | import org.hibernate.validator.constraints.Length; 7 | import org.hibernate.validator.constraints.NotEmpty; 8 | 9 | /** 10 | * @Author bruce.ge 11 | * @Date 2017/1/24 12 | * @Description 13 | */ 14 | @Getter 15 | @Setter 16 | @ToString 17 | public class LoginRequest { 18 | @NotEmpty 19 | @Length(max = 50) 20 | private String username; 21 | 22 | @NotEmpty 23 | @Length(max = 50) 24 | private String password; 25 | 26 | private Boolean remember; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rest/Request/MyBatisLogRequest.java: -------------------------------------------------------------------------------- 1 | package com.rest.Request; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | 7 | /** 8 | * @Author bruce.ge 9 | * @Date 2017/2/27 10 | * @Description 11 | */ 12 | @Getter 13 | @Setter 14 | @ToString 15 | public class MyBatisLogRequest { 16 | private String className; 17 | 18 | private String messages; 19 | 20 | 21 | private String loggerLevel; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/rest/Request/RegisterRequest.java: -------------------------------------------------------------------------------- 1 | package com.rest.Request; 2 | 3 | import io.swagger.annotations.ApiParam; 4 | import lombok.Data; 5 | import org.hibernate.validator.constraints.Email; 6 | import org.hibernate.validator.constraints.NotEmpty; 7 | 8 | import javax.validation.constraints.Size; 9 | 10 | /** 11 | * Created by bruce.ge on 2016/11/14. 12 | */ 13 | @Data 14 | public class RegisterRequest { 15 | 16 | @NotEmpty 17 | @Size(max = 30) 18 | @ApiParam(value = "用户名", required = true) 19 | private String username; 20 | 21 | @NotEmpty 22 | @Size(min = 5, max = 30) 23 | @ApiParam(value = "密码", required = true) 24 | private String password; 25 | 26 | @Email 27 | @Size(min = 5, max = 50) 28 | @ApiParam(value = "邮箱,最小长度5 最大长度50", required = true) 29 | private String email; 30 | 31 | private String mobile; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/rest/Request/ReplyCommentRequest.java: -------------------------------------------------------------------------------- 1 | package com.rest.Request; 2 | 3 | import lombok.Data; 4 | import org.hibernate.validator.constraints.SafeHtml; 5 | 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * Created by bruce.ge on 2016/11/18. 10 | */ 11 | 12 | @Data 13 | public class ReplyCommentRequest { 14 | @NotNull 15 | public Integer replyCommentId; 16 | 17 | @NotNull 18 | @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE) 19 | public String content; 20 | 21 | @NotNull 22 | @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE) 23 | public String name; 24 | 25 | @NotNull 26 | public Integer articleId; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rest/annotation/AuthEnum.java: -------------------------------------------------------------------------------- 1 | package com.rest.annotation; 2 | 3 | /** 4 | * Created by bruce.ge on 2016/11/13. 5 | */ 6 | //todo could become flexble like a[b]. for role and auth 7 | public enum AuthEnum { 8 | LOGIN,ADMIN 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/rest/annotation/ExecutionTime.java: -------------------------------------------------------------------------------- 1 | package com.rest.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * Created by bruce.ge on 2017/1/8. 7 | */ 8 | @Retention(RetentionPolicy.RUNTIME) 9 | // TODO: 2017/1/8 consider if i shall support with type 10 | @Target({ElementType.METHOD}) 11 | @Inherited 12 | @Documented 13 | public @interface ExecutionTime { 14 | 15 | boolean logToDatabase() default false; 16 | /*log args when time are over the time unit is ms*/ 17 | int logArgsTime() default 1000; 18 | 19 | boolean onlyLogOverTime() default false; 20 | 21 | int logOverTime() default 1000; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/rest/annotation/NeedAuth.java: -------------------------------------------------------------------------------- 1 | package com.rest.annotation; 2 | 3 | 4 | import org.springframework.core.annotation.AliasFor; 5 | 6 | import java.lang.annotation.*; 7 | 8 | /** 9 | * Created by bruce.ge on 2016/11/13. 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target({ElementType.METHOD, ElementType.TYPE}) 13 | @Inherited 14 | @Documented 15 | public @interface NeedAuth { 16 | String redirectPage() default "/loginPage"; 17 | 18 | @AliasFor("auth") 19 | AuthEnum value() default AuthEnum.LOGIN; 20 | 21 | @AliasFor("value") 22 | AuthEnum auth() default AuthEnum.LOGIN; 23 | 24 | //是否认证完成后要返回原来的页面 25 | boolean redirectBack() default false; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/rest/annotation/SwaggerIgnore.java: -------------------------------------------------------------------------------- 1 | package com.rest.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by bruce.ge on 2016/12/24. 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target({ElementType.METHOD, ElementType.TYPE}) 13 | public @interface SwaggerIgnore { 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/rest/aop/ExecutionTimeAspect.java: -------------------------------------------------------------------------------- 1 | package com.rest.aop; 2 | 3 | import com.google.common.base.Joiner; 4 | import com.rest.annotation.ExecutionTime; 5 | import com.rest.event.ExecutionTimeLogEvent; 6 | import org.aspectj.lang.ProceedingJoinPoint; 7 | import org.aspectj.lang.annotation.Around; 8 | import org.aspectj.lang.annotation.Aspect; 9 | import org.aspectj.lang.annotation.Pointcut; 10 | import org.aspectj.lang.reflect.MethodSignature; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.context.ApplicationEventPublisher; 15 | import org.springframework.stereotype.Component; 16 | 17 | import java.util.Date; 18 | 19 | /** 20 | * Created by bruce.ge on 2017/1/8. 21 | */ 22 | @Aspect 23 | @Component 24 | public class ExecutionTimeAspect { 25 | 26 | private static Logger logger = LoggerFactory.getLogger("executionTime"); 27 | 28 | @Autowired 29 | private ApplicationEventPublisher applicationEventPublisher; 30 | 31 | @Pointcut("@annotation(com.rest.annotation.ExecutionTime)") 32 | public void annotatedWithExecutionTime() { 33 | } 34 | 35 | @Around("annotatedWithExecutionTime()") 36 | public Object around(ProceedingJoinPoint pjp) throws Throwable { 37 | MethodSignature signature = (MethodSignature) pjp.getSignature(); 38 | long start = System.currentTimeMillis(); 39 | Object proceed = pjp.proceed(); 40 | long end = System.currentTimeMillis(); 41 | Object[] args = pjp.getArgs(); 42 | StringBuilder builder = new StringBuilder(); 43 | builder.append(signature.getDeclaringTypeName()); 44 | builder.append("." + signature.getName() + "("); 45 | if (args.length > 0) { 46 | for (int i = 0; i < args.length; i++) { 47 | builder.append(args[i].getClass().getName()); 48 | if (i != args.length - 1) { 49 | builder.append(", "); 50 | } 51 | } 52 | } 53 | builder.append(")"); 54 | builder.append(" cost time " + (end - start) + "ms"); 55 | ExecutionTime annotation = signature.getMethod().getAnnotation(ExecutionTime.class); 56 | if (end - start > annotation.logArgsTime()) { 57 | builder.append("\n the execution time over " + annotation.logArgsTime()); 58 | if (args.length > 0) { 59 | for (int i = 0; i < args.length; i++) { 60 | builder.append(args[i].toString()); 61 | if (i != args.length - 1) { 62 | builder.append("\n"); 63 | } 64 | } 65 | } 66 | } 67 | logger.info(builder.toString()); 68 | if (annotation.logToDatabase()) { 69 | ExecutionTimeLogEvent executionTimeLogEvent = ExecutionTimeLogEvent.builder() 70 | .className(signature.getDeclaringTypeName()) 71 | .methodName(signature.getName()) 72 | .argsValue(Joiner.on(",").join(args)) 73 | .executionTime(end - start) 74 | .createTime(new Date()) 75 | .build(); 76 | applicationEventPublisher.publishEvent(executionTimeLogEvent); 77 | } 78 | return proceed; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/rest/bean/User.java: -------------------------------------------------------------------------------- 1 | package com.rest.bean; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * Created by bruce.ge on 2016/11/13. 10 | */ 11 | @Data 12 | @Builder 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | public class User { 16 | private boolean login = false; 17 | 18 | private int userId; 19 | 20 | private String userName; 21 | 22 | private boolean admin = false; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/rest/config/BlogProperty.java: -------------------------------------------------------------------------------- 1 | package com.rest.config; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Created by bruce.ge on 2016/11/18. 10 | */ 11 | @Component 12 | public class BlogProperty { 13 | 14 | private static Logger logger = LoggerFactory.getLogger(BlogProperty.class); 15 | @Value("${blog.comment}") 16 | private boolean comment; 17 | 18 | 19 | public boolean isComment() { 20 | return comment; 21 | } 22 | 23 | public void setComment(boolean comment) { 24 | this.comment = comment; 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/com/rest/config/Constants.java: -------------------------------------------------------------------------------- 1 | package com.rest.config; 2 | 3 | /** 4 | * @Author bruce.ge 5 | * @Date 2017/1/21 6 | * @Description 7 | */ 8 | public class Constants { 9 | public static final String SPRING_PROFILE_DEV="dev"; 10 | 11 | public static final String SPRING_PROFILE_PRODUCTION = "prod"; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/rest/config/dev/DevDbConfig.java: -------------------------------------------------------------------------------- 1 | package com.rest.config.dev; 2 | 3 | import com.alibaba.druid.pool.DruidDataSource; 4 | import com.rest.utils.DbUtils; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import javax.sql.DataSource; 10 | 11 | /** 12 | * Created by bruce.ge on 2016/10/23. 13 | */ 14 | @Configuration 15 | public class DevDbConfig { 16 | @Value("${db.url}") 17 | private String dbUrl; 18 | 19 | @Value("${db.username}") 20 | private String dbUsername; 21 | 22 | @Value("${db.password}") 23 | private String password; 24 | 25 | @Bean(initMethod = "init", destroyMethod = "close") 26 | public DataSource createDateSource() { 27 | DruidDataSource druidDataSource = new DruidDataSource(); 28 | druidDataSource.setUrl(dbUrl); 29 | druidDataSource.setUsername(dbUsername); 30 | druidDataSource.setPassword(password); 31 | DbUtils.checkOrCreateTables(dbUrl, dbUsername, password); 32 | druidDataSource.setInitialSize(3); 33 | druidDataSource.setMinIdle(1); 34 | druidDataSource.setMaxActive(20); 35 | druidDataSource.setMaxWait(6000); 36 | druidDataSource.setTimeBetweenEvictionRunsMillis(6000); 37 | druidDataSource.setMinEvictableIdleTimeMillis(30000); 38 | druidDataSource.setValidationQuery("SELECT 1 from dual"); 39 | druidDataSource.setTestWhileIdle(true); 40 | druidDataSource.setTestOnBorrow(true); 41 | druidDataSource.setTestOnReturn(true); 42 | druidDataSource.setPoolPreparedStatements(true); 43 | druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(20); 44 | return druidDataSource; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/rest/constant/CookieConstants.java: -------------------------------------------------------------------------------- 1 | package com.rest.constant; 2 | 3 | /** 4 | * Created by bruce.ge on 2016/11/13. 5 | */ 6 | public class CookieConstants { 7 | public static final String USERNAME = "username"; 8 | 9 | public static final String PASSWORD="bfgesseaaedd_llwjskk"; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/rest/constant/LuceneFieldConstant.java: -------------------------------------------------------------------------------- 1 | package com.rest.constant; 2 | 3 | /** 4 | * Created by bruce.ge on 2016/11/7. 5 | */ 6 | public class LuceneFieldConstant { 7 | public static String CONTENT = "content"; 8 | 9 | public static String ID = "id"; 10 | 11 | public static String STOREDID = "storeid"; 12 | 13 | public static String TITLE = "title"; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/rest/constant/MarkDownConstant.java: -------------------------------------------------------------------------------- 1 | package com.rest.constant; 2 | 3 | /** 4 | * Created by bruce.ge on 2016/11/14. 5 | */ 6 | public class MarkDownConstant { 7 | public static final String MORE =""; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/rest/constant/SessionConstants.java: -------------------------------------------------------------------------------- 1 | package com.rest.constant; 2 | 3 | /** 4 | * Created by bruce.ge on 2016/11/13. 5 | */ 6 | public class SessionConstants { 7 | public static final String USER = "user"; 8 | 9 | public static final String AUTHBACKPAGE="backpage"; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/AboutController.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller; 2 | 3 | import com.rest.Request.EditAboutRequest; 4 | import com.rest.annotation.AuthEnum; 5 | import com.rest.annotation.ExecutionTime; 6 | import com.rest.annotation.NeedAuth; 7 | import com.rest.domain.AboutPo; 8 | import com.rest.service.AboutService; 9 | import com.rest.utils.SessionUtils; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.GetMapping; 14 | import org.springframework.web.bind.annotation.PostMapping; 15 | import org.springframework.web.bind.annotation.RequestBody; 16 | import org.springframework.web.bind.annotation.ResponseBody; 17 | import org.springframework.web.servlet.ModelAndView; 18 | 19 | import javax.validation.Valid; 20 | import java.util.Date; 21 | import java.util.Optional; 22 | 23 | /** 24 | * Created by bruce.ge on 2016/11/7. 25 | */ 26 | @Controller 27 | public class AboutController { 28 | 29 | @Autowired 30 | private AboutService aboutService; 31 | 32 | @GetMapping("/about") 33 | @ExecutionTime(logToDatabase = true) 34 | public ModelAndView getAbout() { 35 | ModelAndView view = new ModelAndView("about"); 36 | return aboutService.getAbout() 37 | .map(about -> { 38 | if (about.getSourceContent() != null) {// 39 | view.addObject("aboutContent", about.getMarkdownHtml()); 40 | return view; 41 | } 42 | return null; 43 | }) 44 | .orElseGet(() -> { 45 | view.addObject("aboutContent", ""); 46 | return view; 47 | }); 48 | } 49 | 50 | 51 | @GetMapping("/loadUserAbout") 52 | @ResponseBody 53 | public String getUserAbout() { 54 | Optional about = aboutService.getAbout(); 55 | return about.map((aboutPo -> aboutPo.getSourceContent())) 56 | .orElse(""); 57 | } 58 | 59 | 60 | @PostMapping("/editAbout") 61 | @ResponseBody 62 | @NeedAuth(AuthEnum.ADMIN) 63 | public ResponseEntity editAbout(@Valid @RequestBody EditAboutRequest request) { 64 | AboutPo aboutPo = convertToAboutPo(request); 65 | aboutService.insert(aboutPo); 66 | return ResponseEntity.ok().build(); 67 | } 68 | 69 | private AboutPo convertToAboutPo(EditAboutRequest request) { 70 | AboutPo aboutPo = new AboutPo(); 71 | aboutPo.setSourceContent(request.getSourceContent()); 72 | aboutPo.setMarkdownHtml(request.getSourceHtml()); 73 | aboutPo.setCreateTime(new Date()); 74 | aboutPo.setUpdateTime(new Date()); 75 | aboutPo.setUserId(SessionUtils.getCurrentUser().getUserId()); 76 | return aboutPo; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/ArchivesController.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.google.common.collect.Maps; 5 | import com.rest.annotation.ExecutionTime; 6 | import com.rest.converter.AriveConverter; 7 | import com.rest.domain.Archives; 8 | import com.rest.domain.Content; 9 | import com.rest.mapper.ContentMapper; 10 | import com.rest.mapper.ContentTimeMapper; 11 | import com.rest.vo.ArchiveVo; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.web.bind.annotation.GetMapping; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | import org.springframework.web.servlet.ModelAndView; 17 | 18 | import java.util.List; 19 | import java.util.Map; 20 | 21 | /** 22 | * Created by bruce.ge on 2016/11/6. 23 | */ 24 | @Controller 25 | public class ArchivesController { 26 | @Autowired 27 | private ContentTimeMapper contentTimeMapper; 28 | 29 | @Autowired 30 | private ContentMapper contentMapper; 31 | 32 | @GetMapping("/archive") 33 | @ExecutionTime(logToDatabase = true) 34 | public ModelAndView getArchive() { 35 | List years = contentTimeMapper.getDistinctYears(); 36 | List yearStrings = Lists.newArrayList(); 37 | 38 | Map> archiveMap = Maps.newHashMap(); 39 | for (Integer year : years) { 40 | List byYear = 41 | contentTimeMapper.findByYear(year); 42 | String a = String.valueOf(year); 43 | yearStrings.add(a); 44 | archiveMap.put(a, AriveConverter.converetToVo(byYear)); 45 | } 46 | ModelAndView archive = new ModelAndView("archive"); 47 | archive.addObject("years", yearStrings); 48 | archive.addObject("archiveMap", archiveMap); 49 | return archive; 50 | } 51 | 52 | 53 | @GetMapping("/getEditArchives") 54 | @ResponseBody 55 | public List getEditArchives() { 56 | List orderByIdDesc = contentMapper.findOrderByIdDesc(); 57 | return orderByIdDesc; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/ChangeLanguageController.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | 6 | /** 7 | * @Author bruce.ge 8 | * @Date 2017/1/15 9 | * @Description 10 | */ 11 | @Controller 12 | public class ChangeLanguageController { 13 | 14 | @GetMapping("/changeLanguage") 15 | public String changeLanguage() { 16 | return "redirect:/"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/LogoutController.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller; 2 | 3 | import com.rest.constant.SessionConstants; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | 7 | import javax.servlet.http.Cookie; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | 12 | /** 13 | * Created by bruce.ge on 2016/11/17. 14 | */ 15 | @Controller 16 | public class LogoutController { 17 | @GetMapping("/logout") 18 | public String logout(HttpSession session, HttpServletRequest request, HttpServletResponse response) { 19 | session.removeAttribute(SessionConstants.USER); 20 | session.removeAttribute(SessionConstants.AUTHBACKPAGE); 21 | Cookie[] cookies = 22 | request.getCookies(); 23 | if (cookies != null) { 24 | for (int i = 0; i < cookies.length; i++) { 25 | cookies[i].setValue(""); 26 | cookies[i].setPath("/"); 27 | cookies[i].setMaxAge(0); 28 | response.addCookie(cookies[i]); 29 | } 30 | } 31 | return "/"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/SearchController.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.rest.dto.SearchResult; 5 | import com.rest.service.SearchService; 6 | import com.rest.utils.AntiSamyUtils; 7 | import com.rest.vo.QueryResultVo; 8 | import org.owasp.validator.html.PolicyException; 9 | import org.owasp.validator.html.ScanException; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.util.CollectionUtils; 13 | import org.springframework.web.bind.annotation.GetMapping; 14 | import org.springframework.web.bind.annotation.RequestParam; 15 | import org.springframework.web.servlet.ModelAndView; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | * Created by bruce.ge on 2016/11/8. 21 | */ 22 | @Controller 23 | public class SearchController { 24 | 25 | @Autowired 26 | private SearchService searchService; 27 | 28 | @GetMapping("/search") 29 | public ModelAndView search(@RequestParam("query") String query) throws ScanException, PolicyException { 30 | query = AntiSamyUtils.getCleanHtml(query); 31 | //totally get data from lucene need to control if the file not in database. 32 | List searchResults = searchService.query(query); 33 | List resultVos = buildResultVo(searchResults); 34 | ModelAndView s = new ModelAndView("searchPage"); 35 | boolean hasContent = false; 36 | if (!CollectionUtils.isEmpty(resultVos)) { 37 | hasContent = true; 38 | } 39 | s.addObject("hasContent", hasContent); 40 | s.addObject("result", resultVos); 41 | s.addObject("resultlen", resultVos.size()); 42 | return s; 43 | } 44 | 45 | private static List buildResultVo(List searchResults) { 46 | List resultVos = Lists.newArrayList(); 47 | for (SearchResult result : searchResults) { 48 | resultVos.add(buildResultVo(result)); 49 | } 50 | return resultVos; 51 | } 52 | 53 | private static QueryResultVo buildResultVo(SearchResult result) { 54 | QueryResultVo vo = new QueryResultVo(); 55 | vo.setLink(buildLink(result.getId())); 56 | vo.setMarktitle(result.getTitle()); 57 | vo.setMarkContent(result.getMarkText()); 58 | return vo; 59 | } 60 | 61 | private static String buildLink(int id) { 62 | return "/getArticle/" + id; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | /** 7 | * Created by bruce.ge on 2016/11/20. 8 | */ 9 | @Controller 10 | public class TestController { 11 | 12 | @RequestMapping("/test") 13 | public String test(){ 14 | return "test"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/admin/AdminController.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.admin; 2 | 3 | import com.rest.annotation.AuthEnum; 4 | import com.rest.annotation.NeedAuth; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.servlet.ModelAndView; 8 | 9 | /** 10 | * Created by bruce.ge on 2017/1/8. 11 | */ 12 | @Controller 13 | @NeedAuth(AuthEnum.ADMIN) 14 | public class AdminController { 15 | @GetMapping("/admin") 16 | public ModelAndView admin() { 17 | ModelAndView adminView = new ModelAndView("admin"); 18 | return adminView; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/admin/EditAboutController.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.admin; 2 | 3 | import com.rest.annotation.AuthEnum; 4 | import com.rest.annotation.NeedAuth; 5 | import org.springframework.stereotype.Controller; 6 | 7 | /** 8 | * Created by bruce.ge on 2017/1/8. 9 | */ 10 | @Controller 11 | @NeedAuth(AuthEnum.ADMIN) 12 | public class EditAboutController { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/admin/EditController.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.admin; 2 | 3 | import com.rest.Request.EditContentRequest; 4 | import com.rest.annotation.AuthEnum; 5 | import com.rest.annotation.NeedAuth; 6 | import com.rest.converter.ContentConverter; 7 | import com.rest.domain.Content; 8 | import com.rest.enums.StatusEnum; 9 | import com.rest.mapper.ContentMapper; 10 | import com.rest.mapper.ContentTimeMapper; 11 | import com.rest.service.SearchService; 12 | import com.rest.utils.AntiSamyUtils; 13 | import com.rest.utils.MarkDownUtil; 14 | import org.owasp.validator.html.PolicyException; 15 | import org.owasp.validator.html.ScanException; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.stereotype.Controller; 18 | import org.springframework.web.bind.annotation.GetMapping; 19 | import org.springframework.web.bind.annotation.PathVariable; 20 | import org.springframework.web.bind.annotation.PostMapping; 21 | import org.springframework.web.bind.annotation.ResponseBody; 22 | import org.springframework.web.servlet.ModelAndView; 23 | 24 | /** 25 | * Created by bruce.ge on 2016/11/13. 26 | */ 27 | @Controller 28 | public class EditController { 29 | @Autowired 30 | private ContentMapper contentMapper; 31 | 32 | @Autowired 33 | private ContentTimeMapper contentTimeMapper; 34 | 35 | @Autowired 36 | private SearchService searchService; 37 | 38 | @GetMapping("/edit/{id}") 39 | @NeedAuth(AuthEnum.ADMIN) 40 | //todo. when two people edit the same article, how to inform each other. add lock to database? 41 | public ModelAndView edit(@PathVariable("id") int id) { 42 | return contentMapper.findById(id).map(content -> { 43 | ModelAndView edit = new ModelAndView("edit"); 44 | edit.addObject("title", content.getTitle()); 45 | edit.addObject("source_content", content.getSource_content()); 46 | edit.addObject("source_id", id); 47 | return edit; 48 | }).orElseGet(() -> { 49 | return new ModelAndView("articleNotFound"); 50 | }); 51 | //get the source content. 52 | 53 | } 54 | 55 | 56 | @PostMapping("editContent") 57 | @NeedAuth(AuthEnum.ADMIN) 58 | @ResponseBody 59 | public boolean editContent(EditContentRequest request) throws ScanException, PolicyException { 60 | request.setTitle(AntiSamyUtils.getCleanHtml(request.getTitle())); 61 | Content content = ContentConverter.convertToContent(request); 62 | contentMapper.updateContent(content); 63 | //add data to lucene. 64 | //shall using new thread to do the thing. 65 | new Thread(() -> searchService.update(request.getTitle(), MarkDownUtil.removeMark(request.getSourceContent()), content.getId())).start(); 66 | return true; 67 | } 68 | 69 | @GetMapping("/delete/{id}") 70 | @NeedAuth(AuthEnum.ADMIN) 71 | public String delete(@PathVariable("id") int id) { 72 | //shall not delete it. 73 | contentMapper.updateStatusById(StatusEnum.INVALID.getValue(), id); 74 | contentTimeMapper.deleteByContentId(id); 75 | searchService.delete(id); 76 | return "redirect:/"; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/admin/ExecutionTimeController.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.admin; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | 6 | /** 7 | * Created by bruce.ge on 2017/1/8. 8 | */ 9 | @Controller 10 | public class ExecutionTimeController { 11 | 12 | 13 | @GetMapping("/viewExecutionTime") 14 | public String viewExecutionTime() { 15 | return ""; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/admin/UploadImageController.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.admin; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.rest.storage.StorageFileNotFoundException; 5 | import com.rest.storage.StorageService; 6 | import org.apache.catalina.servlet4preview.http.HttpServletRequest; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.core.io.Resource; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.ui.Model; 12 | import org.springframework.web.bind.annotation.*; 13 | import org.springframework.web.multipart.MultipartFile; 14 | import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder; 15 | import org.springframework.web.servlet.mvc.support.RedirectAttributes; 16 | 17 | import java.io.IOException; 18 | import java.util.List; 19 | 20 | /** 21 | * Created by bruce.ge on 2016/11/9. 22 | */ 23 | @Controller 24 | public class UploadImageController { 25 | private final StorageService storageService; 26 | 27 | @Autowired 28 | public UploadImageController(StorageService storageService){ 29 | this.storageService = storageService; 30 | } 31 | 32 | @GetMapping("/listFile") 33 | public String listuploadFile(Model model) throws IOException{ 34 | List urls = Lists.newArrayList(); 35 | for(String file: storageService.loadAll()){ 36 | urls.add(MvcUriComponentsBuilder.fromMethodName(UploadImageController.class,"serveFile",file).build().toString()); 37 | } 38 | model.addAttribute("files",urls); 39 | 40 | return "uploadForm"; 41 | } 42 | 43 | 44 | @GetMapping("/files/{fileName:.+}") 45 | @ResponseBody 46 | public ResponseEntity serveFile(@PathVariable String fileName){ 47 | Resource resource = storageService.loadAsResource(fileName); 48 | //remove the header let browser view it. 49 | return ResponseEntity.ok().body(resource); 50 | // header(HttpHeaders.CONTENT_DISPOSITION,"attachment; filename=\""+resource.getFilename()+"\"") 51 | } 52 | 53 | 54 | @PostMapping("/upload") 55 | public String handleFileUpload(@RequestParam("file")MultipartFile file, RedirectAttributes redirectAttributes){ 56 | storageService.store(file); 57 | redirectAttributes.addFlashAttribute("message","You successfully uploaded "+file.getOriginalFilename() + "!"); 58 | return "redirect:/listFile"; 59 | } 60 | 61 | 62 | @PostMapping("/uploadImage") 63 | @ResponseBody 64 | public String uploadImage(@RequestParam("image_file")MultipartFile file, HttpServletRequest request){ 65 | String newName = String.valueOf(System.currentTimeMillis())+file.getOriginalFilename(); 66 | storageService.storeFileWithName(file,newName); 67 | return "/files/"+newName; 68 | } 69 | 70 | @ExceptionHandler(StorageFileNotFoundException.class) 71 | public ResponseEntity handleStorageFileNotFound(StorageFileNotFoundException e){ 72 | return ResponseEntity.notFound().build(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/customException/RegisterValidateException.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.customException; 2 | 3 | import org.jetbrains.annotations.NonNls; 4 | 5 | /** 6 | * @Author bruce.ge 7 | * @Date 2017/1/20 8 | * @Description 9 | */ 10 | public class RegisterValidateException extends RuntimeException { 11 | public RegisterValidateException() { 12 | super(); 13 | } 14 | 15 | public RegisterValidateException(@NonNls String message) { 16 | super(message); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/customException/TransactionException.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.customException; 2 | 3 | /** 4 | * @Author bruce.ge 5 | * @Date 2017/1/20 6 | * @Description 7 | */ 8 | public class TransactionException extends RuntimeException{ 9 | public TransactionException(Throwable e) { 10 | super(e); 11 | } 12 | 13 | 14 | public TransactionException(String message, Throwable cause) { 15 | super(message, cause); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/customException/UserAlreadyExistException.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.customException; 2 | 3 | import org.jetbrains.annotations.NonNls; 4 | 5 | /** 6 | * @Author bruce.ge 7 | * @Date 2017/1/23 8 | * @Description 9 | */ 10 | public class UserAlreadyExistException extends RuntimeException { 11 | public UserAlreadyExistException() { 12 | super(); 13 | } 14 | 15 | public UserAlreadyExistException(@NonNls String message) { 16 | super(message); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/customException/UserNotAuthRestException.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.customException; 2 | 3 | import org.jetbrains.annotations.NonNls; 4 | 5 | /** 6 | * @Author bruce.ge 7 | * @Date 2017/1/27 8 | * @Description 9 | */ 10 | public class UserNotAuthRestException extends RuntimeException{ 11 | public UserNotAuthRestException() { 12 | super(); 13 | } 14 | 15 | public UserNotAuthRestException(@NonNls String message) { 16 | super(message); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/customException/UserNotExistException.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.customException; 2 | 3 | import org.jetbrains.annotations.NonNls; 4 | 5 | /** 6 | * @Author bruce.ge 7 | * @Date 2017/1/24 8 | * @Description 9 | */ 10 | public class UserNotExistException extends RuntimeException{ 11 | public UserNotExistException() { 12 | super(); 13 | } 14 | 15 | public UserNotExistException(@NonNls String message) { 16 | super(message); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/customException/UserSessionTimeOutException.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.customException; 2 | 3 | import org.jetbrains.annotations.NonNls; 4 | 5 | /** 6 | * @Author bruce.ge 7 | * @Date 2017/1/20 8 | * @Description 9 | */ 10 | public class UserSessionTimeOutException extends RuntimeException{ 11 | public UserSessionTimeOutException() { 12 | super(); 13 | } 14 | 15 | public UserSessionTimeOutException(@NonNls String message) { 16 | super(message); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/errors/CustomParameterizedException.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.errors; 2 | 3 | /** 4 | * Custom, parameterized exception, which can be translated on the client side. 5 | * For example: 6 | * 7 | *
 8 |  * throw new CustomParameterizedException("myCustomError", "hello", "world");
 9 |  * 
10 | * 11 | * Can be translated with: 12 | * 13 | *
14 |  * "error.myCustomError" :  "The server says {{params[0]}} to {{params[1]}}"
15 |  * 
16 | */ 17 | public class CustomParameterizedException extends RuntimeException { 18 | 19 | private static final long serialVersionUID = 1L; 20 | 21 | private final String message; 22 | private final String[] params; 23 | 24 | public CustomParameterizedException(String message, String... params) { 25 | super(message); 26 | this.message = message; 27 | this.params = params; 28 | } 29 | 30 | public ParameterizedErrorVM getErrorVM() { 31 | return new ParameterizedErrorVM(message, params); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/errors/ErrorConstants.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.errors; 2 | 3 | public final class ErrorConstants { 4 | 5 | public static final String ERR_CONCURRENCY_FAILURE = "error.concurrencyFailure"; 6 | public static final String ERR_ACCESS_DENIED = "error.accessDenied"; 7 | public static final String ERR_VALIDATION = "error.validation"; 8 | public static final String ERR_METHOD_NOT_SUPPORTED = "error.methodNotSupported"; 9 | public static final String ERR_INTERNAL_SERVER_ERROR = "error.internalServerError"; 10 | public static final String ERR_ALREADYEXIST = "error.userAlreadyExist"; 11 | public static final String ERR_NOTRESTAUTH = "error.notrestauth"; 12 | 13 | public static final String ERR_USERNOTEXIST = "error.userNotExist"; 14 | 15 | private ErrorConstants() { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/errors/ErrorVM.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.errors; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | /** 8 | * View Model for transferring error message with a list of field errors. 9 | */ 10 | public class ErrorVM implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | private final String message; 15 | private final String description; 16 | 17 | private List fieldErrors; 18 | 19 | public ErrorVM(String message) { 20 | this(message, null); 21 | } 22 | 23 | public ErrorVM(String message, String description) { 24 | this.message = message; 25 | this.description = description; 26 | } 27 | 28 | 29 | 30 | public ErrorVM(String message, String description, List fieldErrors) { 31 | this.message = message; 32 | this.description = description; 33 | this.fieldErrors = fieldErrors; 34 | } 35 | 36 | public void add(String objectName, String field, String message,String defaultMessage) { 37 | if (fieldErrors == null) { 38 | fieldErrors = new ArrayList<>(); 39 | } 40 | fieldErrors.add(new FieldErrorVM(objectName, field, message,defaultMessage)); 41 | } 42 | 43 | public String getMessage() { 44 | return message; 45 | } 46 | 47 | public String getDescription() { 48 | return description; 49 | } 50 | 51 | public List getFieldErrors() { 52 | return fieldErrors; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/errors/FieldErrorVM.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.errors; 2 | 3 | import java.io.Serializable; 4 | 5 | public class FieldErrorVM implements Serializable { 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private final String objectName; 10 | 11 | private final String field; 12 | 13 | private final String message; 14 | 15 | private final String defaultMessage; 16 | 17 | public FieldErrorVM(String dto, String field, String message,String defaultMessage) { 18 | this.objectName = dto; 19 | this.field = field; 20 | this.message = message; 21 | this.defaultMessage = defaultMessage; 22 | } 23 | 24 | 25 | public String getDefaultMessage() { 26 | return defaultMessage; 27 | } 28 | 29 | public String getObjectName() { 30 | return objectName; 31 | } 32 | 33 | public String getField() { 34 | return field; 35 | } 36 | 37 | public String getMessage() { 38 | return message; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/errors/ParameterizedErrorVM.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.errors; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * View Model for sending a parameterized error message. 7 | */ 8 | public class ParameterizedErrorVM implements Serializable { 9 | 10 | private static final long serialVersionUID = 1L; 11 | private final String message; 12 | private final String[] params; 13 | 14 | public ParameterizedErrorVM(String message, String... params) { 15 | this.message = message; 16 | this.params = params; 17 | } 18 | 19 | public String getMessage() { 20 | return message; 21 | } 22 | 23 | public String[] getParams() { 24 | return params; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/response/LoginResponse.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.response; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | /** 7 | * @Author bruce.ge 8 | * @Date 2017/1/24 9 | * @Description 10 | */ 11 | @Getter 12 | @Setter 13 | public class LoginResponse { 14 | private String redirectUrl; 15 | 16 | public LoginResponse(String redirectUrl) { 17 | this.redirectUrl = redirectUrl; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/response/MyBatisLogResponse.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.response; 2 | 3 | /** 4 | * @Author bruce.ge 5 | * @Date 2017/2/27 6 | * @Description 7 | */ 8 | public class MyBatisLogResponse { 9 | private Boolean success; 10 | 11 | public Boolean getSuccess() { 12 | return success; 13 | } 14 | 15 | public void setSuccess(Boolean success) { 16 | this.success = success; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/rest/controller/response/TextAndValue.java: -------------------------------------------------------------------------------- 1 | package com.rest.controller.response; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | /** 7 | * @Author bruce.ge 8 | * @Date 2017/2/9 9 | * @Description 10 | */ 11 | @Getter 12 | @Setter 13 | public class TextAndValue { 14 | private String text; 15 | 16 | private String value; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/rest/converter/AriveConverter.java: -------------------------------------------------------------------------------- 1 | package com.rest.converter; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.rest.domain.Archives; 5 | import com.rest.vo.ArchiveVo; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by bruce.ge on 2016/11/7. 12 | */ 13 | public class AriveConverter { 14 | private static SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd"); 15 | 16 | public static List converetToVo(List byYear) { 17 | List archiveVos = Lists.newArrayList(); 18 | for(Archives archives : byYear){ 19 | ArchiveVo vo = convertToVo(archives); 20 | archiveVos.add(vo); 21 | } 22 | return archiveVos; 23 | } 24 | 25 | private static ArchiveVo convertToVo(Archives archives) { 26 | ArchiveVo vo = new ArchiveVo(); 27 | vo.setAdddate(dateFormat.format(archives.getAddtime())); 28 | vo.setTitle(archives.getTitle()); 29 | vo.setLink(buildLink(archives.getId())); 30 | vo.setId(archives.getId()); 31 | return vo; 32 | } 33 | 34 | private static String buildLink(int id) { 35 | return "/getArticle/"+id; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/rest/converter/CommentConvert.java: -------------------------------------------------------------------------------- 1 | package com.rest.converter; 2 | 3 | import com.rest.Request.CommentRequest; 4 | import com.rest.domain.CommentPO; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Created by bruce.ge on 2016/11/18. 10 | */ 11 | public class CommentConvert { 12 | public static CommentPO createPo(CommentRequest commentRequest, int id,String remoteAddr) { 13 | CommentPO po = new CommentPO(); 14 | po.setArticle_id(id); 15 | po.setAddtime(new Date()); 16 | po.setContent(commentRequest.getContent()); 17 | po.setUsername(commentRequest.getName()); 18 | po.setUpdatetime(new Date()); 19 | po.setComment_ip(remoteAddr); 20 | return po; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/rest/converter/UserConverter.java: -------------------------------------------------------------------------------- 1 | package com.rest.converter; 2 | 3 | import com.rest.bean.User; 4 | import com.rest.domain.UserPO; 5 | 6 | /** 7 | * Created by bruce.ge on 2016/11/13. 8 | */ 9 | public class UserConverter { 10 | public static User convertToUser(UserPO userPO) { 11 | User user = new User(); 12 | user.setLogin(true); 13 | user.setUserId(userPO.getId()); 14 | user.setUserName(userPO.getUsername()); 15 | user.setAdmin(userPO.getAuth() == 1); 16 | return user; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/rest/domain/AboutPo.java: -------------------------------------------------------------------------------- 1 | package com.rest.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * Created by bruce.ge on 2017/1/8. 12 | */ 13 | @Data 14 | @Builder 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class AboutPo { 18 | 19 | private Integer id; 20 | //use markdown to diplay all the info for it. 21 | private String sourceContent; 22 | 23 | 24 | private String markdownHtml; 25 | 26 | private Date createTime; 27 | 28 | private Date updateTime; 29 | 30 | private Integer userId; 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/rest/domain/AboutPo_update_2017-02-15.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `about_po` ADD markdown_html TEXT NOT NULL COMMENT 'markdownHtml'; 2 | -------------------------------------------------------------------------------- /src/main/java/com/rest/domain/Archives.java: -------------------------------------------------------------------------------- 1 | package com.rest.domain; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * Created by bruce.ge on 2016/11/6. 9 | */ 10 | @Data 11 | public class Archives { 12 | private Integer id; 13 | 14 | private Date addtime; 15 | 16 | private String title; 17 | 18 | } -------------------------------------------------------------------------------- /src/main/java/com/rest/domain/CommentPO.java: -------------------------------------------------------------------------------- 1 | package com.rest.domain; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * Created by bruce.ge on 2016/11/18. 9 | */ 10 | @Data 11 | public class CommentPO { 12 | private Integer id; 13 | private Integer article_id; 14 | private Integer reply_id; 15 | private String username; 16 | private String content; 17 | private Date addtime; 18 | private Date updatetime; 19 | private Short viewed; 20 | private String comment_ip; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/rest/domain/Content.java: -------------------------------------------------------------------------------- 1 | package com.rest.domain; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * Created by bruce.ge on 2016/11/6. 9 | */ 10 | @Data 11 | public class Content { 12 | private Integer id; 13 | 14 | private String title; 15 | 16 | private String source_content; 17 | 18 | private String html_content; 19 | 20 | private Date updatetime; 21 | 22 | private Date addtime; 23 | 24 | private String index_content; 25 | 26 | 27 | // the use who wrote the article 28 | private Integer userId; 29 | 30 | //the article status. 31 | private Integer status; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/rest/domain/ContentTagRelation.java: -------------------------------------------------------------------------------- 1 | package com.rest.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * @Author bruce.ge 12 | * @Date 2017/1/25 13 | * @Description 14 | */ 15 | @Data 16 | @Builder 17 | @NoArgsConstructor 18 | @AllArgsConstructor 19 | public class ContentTagRelation { 20 | private Integer id; 21 | 22 | private Integer contentId; 23 | 24 | private Integer tagId; 25 | 26 | private Date createTime; 27 | 28 | 29 | private Date updateTime; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/rest/domain/ContentTime.java: -------------------------------------------------------------------------------- 1 | package com.rest.domain; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Created by bruce.ge on 2016/11/6. 7 | */ 8 | @Data 9 | public class ContentTime { 10 | private Integer id; 11 | private Integer year; 12 | private Integer month; 13 | private Integer day; 14 | private Integer content_id; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/rest/domain/ExecutionTimeLog.java: -------------------------------------------------------------------------------- 1 | package com.rest.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * Created by bruce.ge on 2017/1/8. 12 | */ 13 | @Data 14 | @Builder 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | public class ExecutionTimeLog { 18 | private Integer id; 19 | 20 | private String className; 21 | 22 | private String methodName; 23 | 24 | private Long executionTime; 25 | 26 | private String argsValue; 27 | 28 | private Date createTime; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/rest/domain/MyBatisLog.java: -------------------------------------------------------------------------------- 1 | package com.rest.domain; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * @Author bruce.ge 10 | * @Date 2017/2/27 11 | * @Description 12 | */ 13 | @Getter 14 | @Setter 15 | public class MyBatisLog { 16 | 17 | private Integer id; 18 | 19 | private String className; 20 | 21 | private String userIp; 22 | 23 | private String messages; 24 | 25 | private Date createTime; 26 | 27 | private String loggerLevel; 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/rest/domain/MyBatisLog.sql: -------------------------------------------------------------------------------- 1 | -- auto Generated on 2017-02-27 19:56:38 2 | -- DROP TABLE IF EXISTS `my_batis_log`; 3 | CREATE TABLE `my_batis_log`( 4 | `id` INT (11) NOT NULL AUTO_INCREMENT COMMENT 'id', 5 | `class_name` VARCHAR (100) NOT NULL DEFAULT '' COMMENT 'className', 6 | `user_ip` VARCHAR (20) NOT NULL DEFAULT '' COMMENT 'userIp', 7 | `messages` TEXT NOT NULL COMMENT 'messages', 8 | `create_time` DATETIME NOT NULL DEFAULT '1000-01-01 00:00:00' COMMENT 'createTime', 9 | `logger_level` VARCHAR (50) NOT NULL DEFAULT '' COMMENT 'loggerLevel', 10 | INDEX(create_time), 11 | PRIMARY KEY (`id`) 12 | )ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '`my_batis_log`'; 13 | -------------------------------------------------------------------------------- /src/main/java/com/rest/domain/TagPo.java: -------------------------------------------------------------------------------- 1 | package com.rest.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * @Author bruce.ge 12 | * @Date 2017/1/25 13 | * @Description 14 | */ 15 | @Data 16 | @Builder 17 | @NoArgsConstructor 18 | @AllArgsConstructor 19 | public class TagPo { 20 | private Integer id; 21 | 22 | private String tagName; 23 | 24 | private Date createTime; 25 | 26 | private Date updateTime; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/rest/domain/UserPO.java: -------------------------------------------------------------------------------- 1 | package com.rest.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * Created by bruce.ge on 2016/11/13. 12 | */ 13 | @Data 14 | @Builder 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class UserPO { 18 | 19 | private Integer id; 20 | 21 | private Integer auth; 22 | 23 | private String username; 24 | 25 | private String mobile; 26 | 27 | private String email; 28 | 29 | private String cryptpasswod; 30 | 31 | private String passwordcookie; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/rest/dto/SearchResult.java: -------------------------------------------------------------------------------- 1 | package com.rest.dto; 2 | 3 | /** 4 | * Created by bruce.ge on 2016/11/7. 5 | */ 6 | public class SearchResult { 7 | private int id; 8 | 9 | private String markText=""; 10 | 11 | private String title; 12 | 13 | public int getId() { 14 | return id; 15 | } 16 | 17 | public void setId(int id) { 18 | this.id = id; 19 | } 20 | 21 | public String getMarkText() { 22 | return markText; 23 | } 24 | 25 | public void setMarkText(String markText) { 26 | this.markText = markText; 27 | } 28 | 29 | public String getTitle() { 30 | return title; 31 | } 32 | 33 | public void setTitle(String title) { 34 | this.title = title; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/rest/enums/StatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.rest.enums; 2 | 3 | /** 4 | * Created by bruce.ge on 2017/1/3. 5 | */ 6 | public enum StatusEnum { 7 | ACTIVE(10), 8 | INVALID(20); 9 | 10 | private int value; 11 | 12 | StatusEnum(int value) { 13 | this.value = value; 14 | } 15 | 16 | 17 | public int getValue() { 18 | return this.value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/rest/event/DatabaseEventListener.java: -------------------------------------------------------------------------------- 1 | package com.rest.event; 2 | 3 | import com.rest.domain.ExecutionTimeLog; 4 | import com.rest.mapper.ExecutionTimeLogDao; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.context.event.EventListener; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.concurrent.ExecutorService; 10 | import java.util.concurrent.Executors; 11 | 12 | /** 13 | * Created by bruce.ge on 2017/1/8. 14 | */ 15 | @Component 16 | public class DatabaseEventListener { 17 | 18 | public static ExecutorService executorService = Executors.newSingleThreadExecutor(); 19 | 20 | @Autowired 21 | private ExecutionTimeLogDao executionTimeLogDao; 22 | 23 | @EventListener 24 | public void handleDataBaseLogEvent(ExecutionTimeLogEvent event) { 25 | executorService.submit(() -> { 26 | ExecutionTimeLog build = ExecutionTimeLog.builder() 27 | .className(event.getClassName()) 28 | .methodName(event.getMethodName()) 29 | .argsValue(event.getArgsValue()) 30 | .createTime(event.getCreateTime()) 31 | .executionTime(event.getExecutionTime()) 32 | .build(); 33 | executionTimeLogDao.insert(build); 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/rest/event/ExecutionTimeLogEvent.java: -------------------------------------------------------------------------------- 1 | package com.rest.event; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * Created by bruce.ge on 2017/1/8. 12 | */ 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @Builder 17 | public class ExecutionTimeLogEvent { 18 | private String className; 19 | 20 | private String methodName; 21 | 22 | private String argsValue; 23 | 24 | private long executionTime; 25 | 26 | private Date createTime; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rest/exception/UserNotLoginException.java: -------------------------------------------------------------------------------- 1 | package com.rest.exception; 2 | 3 | /** 4 | * Created by bruce.ge on 2016/11/13. 5 | */ 6 | public class UserNotLoginException extends Exception{ 7 | 8 | public UserNotLoginException(){ 9 | super(); 10 | } 11 | public UserNotLoginException(String message){ 12 | super(message); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/rest/intercetors/AccessInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.rest.intercetors; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.web.servlet.HandlerInterceptor; 6 | import org.springframework.web.servlet.ModelAndView; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | /** 12 | * Created by bruce.ge on 2016/11/16. 13 | */ 14 | @Deprecated 15 | public class AccessInterceptor implements HandlerInterceptor { 16 | private static Logger logger = LoggerFactory.getLogger("access"); 17 | 18 | @Override 19 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 20 | String remoteAddr = request.getHeader("X-Forwarded-For"); 21 | String requestURI = request.getRequestURI(); 22 | logger.info("the client ip is {} the requestURI is {}", remoteAddr, requestURI); 23 | return true; 24 | } 25 | 26 | @Override 27 | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { 28 | 29 | } 30 | 31 | @Override 32 | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/rest/intercetors/ExecutionInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.rest.intercetors; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.web.servlet.HandlerInterceptor; 6 | import org.springframework.web.servlet.ModelAndView; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | /** 12 | * Created by bruce.ge on 2016/11/10. 13 | */ 14 | public class ExecutionInterceptor implements HandlerInterceptor { 15 | 16 | private static Logger logger = LoggerFactory.getLogger("access"); 17 | 18 | @Override 19 | public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception { 20 | httpServletRequest.setAttribute("startTime", System.currentTimeMillis()); 21 | return true; 22 | } 23 | 24 | @Override 25 | public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception { 26 | } 27 | 28 | @Override 29 | public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception { 30 | String remoteAddr = httpServletRequest.getRemoteAddr(); 31 | String requestURI = httpServletRequest.getRequestURI(); 32 | long endTime = System.currentTimeMillis(); 33 | //the controller might riderect so there is nothing. 34 | if (httpServletRequest.getAttribute("startTime") != null) { 35 | long useTime = endTime - (Long) httpServletRequest.getAttribute("startTime"); 36 | //ajax request has no modelAndView 37 | logger.info("the client ip is {} the requestURI is {},the use time is {}", remoteAddr, requestURI, useTime); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/rest/mapper/AboutPoDao.java: -------------------------------------------------------------------------------- 1 | package com.rest.mapper; 2 | 3 | import com.rest.domain.AboutPo; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | import java.util.Optional; 9 | 10 | 11 | @Mapper 12 | public interface AboutPoDao { 13 | 14 | int insert(@Param("pojo") AboutPo pojo); 15 | 16 | int insertList(@Param("pojos") List pojo); 17 | 18 | int update(@Param("pojo") AboutPo pojo); 19 | 20 | Optional findFirstOrderByCreateTimeDesc(); 21 | 22 | Optional findFirst(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/rest/mapper/CommentPODao.java: -------------------------------------------------------------------------------- 1 | package com.rest.mapper; 2 | 3 | import com.rest.domain.CommentPO; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | import java.util.Optional; 9 | 10 | @Mapper 11 | public interface CommentPODao { 12 | 13 | int insert(@Param("pojo") CommentPO pojo); 14 | 15 | int insertList(@Param("pojos") List< CommentPO> pojo); 16 | 17 | Optional findById(@Param("id")Integer id); 18 | 19 | List findByArticleId(@Param("article_id")Integer article_id); 20 | 21 | int delete(int id); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/rest/mapper/ContentMapper.java: -------------------------------------------------------------------------------- 1 | package com.rest.mapper; 2 | 3 | import com.rest.domain.Content; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | import java.util.Optional; 9 | 10 | /** 11 | * Created by bruce.ge on 2016/11/6. 12 | */ 13 | @Mapper 14 | public interface ContentMapper { 15 | 16 | int insert(Content content); 17 | 18 | List getPageWithStatus(@Param("status") int status, @Param("start") int start, @Param("limit") int limit); 19 | 20 | int getCount(); 21 | 22 | Optional findById(int id); 23 | 24 | int updateContent(@Param("pojo") Content content); 25 | 26 | int deletebyId(@Param("pojo") Content content); 27 | 28 | int updateStatusById(@Param("updatedStatus") Integer updatedStatus, @Param("id") Integer id); 29 | 30 | Optional findUserIdById(@Param("id") Integer id); 31 | 32 | List findByUserId(@Param("userId") Integer userId); 33 | 34 | 35 | List findByStatusOrderByAddtimeDesc(@Param("status") Integer status); 36 | 37 | 38 | List findOrderByIdDesc(); 39 | 40 | String findTitleById(@Param("id")Integer id); 41 | 42 | 43 | Content findTitleAndAddtimeById(@Param("id")Integer id); 44 | 45 | 46 | List findTitleAndAddtimeByIdInAndStatus(@Param("idList")List idList,@Param("status")Integer status); 47 | 48 | 49 | List findByIdInAndStatus(@Param("idList")List idList,@Param("status")Integer status); 50 | 51 | 52 | Integer countByIdInAndStatus(@Param("idList")List idList,@Param("status")Integer status); 53 | 54 | 55 | List findIdAndTitleAndAddtimeByIdInAndStatus(@Param("idList")List idList,@Param("status")Integer status); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/rest/mapper/ContentTagRelationDao.java: -------------------------------------------------------------------------------- 1 | package com.rest.mapper; 2 | 3 | import com.rest.domain.ContentTagRelation; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface ContentTagRelationDao { 11 | 12 | int insert(@Param("pojo") ContentTagRelation pojo); 13 | 14 | int insertList(@Param("pojos") List< ContentTagRelation> pojo); 15 | 16 | int update(@Param("pojo") ContentTagRelation pojo); 17 | 18 | int delete(); 19 | 20 | int deleteById(@Param("id")Integer id); 21 | 22 | List findTagIdByContentId(@Param("contentId")Integer contentId); 23 | 24 | 25 | List findContentIdByTagId(@Param("tagId")Integer tagId); 26 | 27 | 28 | List findByTagIdIn(@Param("tagIdList")List tagIdList); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/rest/mapper/ContentTimeMapper.java: -------------------------------------------------------------------------------- 1 | package com.rest.mapper; 2 | 3 | import com.rest.annotation.ExecutionTime; 4 | import com.rest.domain.Archives; 5 | import com.rest.domain.ContentTime; 6 | import org.apache.ibatis.annotations.Mapper; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by bruce.ge on 2016/11/6. 12 | */ 13 | @Mapper 14 | public interface ContentTimeMapper { 15 | int insert(ContentTime time); 16 | 17 | List getDistinctYears(); 18 | 19 | List findByYear(int year); 20 | 21 | int deleteByContentId(int id); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/rest/mapper/ExecutionTimeLogDao.java: -------------------------------------------------------------------------------- 1 | package com.rest.mapper; 2 | 3 | import com.rest.domain.ExecutionTimeLog; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface ExecutionTimeLogDao { 11 | 12 | int insert(@Param("pojo") ExecutionTimeLog pojo); 13 | 14 | int insertList(@Param("pojos") List pojo); 15 | 16 | int update(@Param("pojo") ExecutionTimeLog pojo); 17 | 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/main/java/com/rest/mapper/MyBatisLogDao.java: -------------------------------------------------------------------------------- 1 | package com.rest.mapper; 2 | 3 | import com.rest.domain.MyBatisLog; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface MyBatisLogDao { 11 | int insert(@Param("pojo") MyBatisLog pojo); 12 | 13 | int insertSelective(@Param("pojo") MyBatisLog pojo); 14 | 15 | int insertList(@Param("pojos") List pojo); 16 | 17 | int update(@Param("pojo") MyBatisLog pojo); 18 | 19 | List find(); 20 | 21 | 22 | List findOrderByCreateTimeDesc(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/rest/mapper/TagPoDao.java: -------------------------------------------------------------------------------- 1 | package com.rest.mapper; 2 | 3 | import com.rest.domain.TagPo; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | @Mapper 9 | public interface TagPoDao { 10 | 11 | int insert(@Param("pojo") TagPo pojo); 12 | 13 | int insertList(@Param("pojos") List< TagPo> pojo); 14 | 15 | int update(@Param("pojo") TagPo pojo); 16 | 17 | 18 | int deleteById(@Param("id")Integer id); 19 | 20 | 21 | TagPo findById(@Param("id")Integer id); 22 | 23 | 24 | int updateTagNameById(@Param("updatedTagName")String updatedTagName,@Param("id")Integer id); 25 | 26 | List findAll(); 27 | 28 | 29 | List findIdAndTagName(); 30 | 31 | int delete(); 32 | 33 | 34 | List findTagName(); 35 | 36 | 37 | List findTagNameByIdIn(@Param("idList")List idList); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/rest/mapper/UserPODao.java: -------------------------------------------------------------------------------- 1 | package com.rest.mapper; 2 | 3 | import com.rest.domain.UserPO; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | import java.util.Optional; 9 | 10 | @Mapper 11 | public interface UserPODao { 12 | 13 | int insert(@Param("pojo") UserPO pojo); 14 | 15 | int insertList(@Param("pojos") List pojo); 16 | 17 | Optional findFirstByUsername(@Param("username")String username); 18 | 19 | List findByUsernameAndCryptpasswod(@Param("username") String username, @Param("cryptpasswod") String cryptpasswod); 20 | 21 | int update(@Param("pojo") UserPO pojo); 22 | 23 | int updatePasswordcookieById(@Param("updatedPasswordcookie") String updatedPasswordcookie, @Param("id") Integer id); 24 | 25 | int delete(@Param("pojo") int id); 26 | 27 | int getCount(); 28 | 29 | List findByUsernameAndPasswordcookie(@Param("username") String username, @Param("passwordcookie") String passwordcookie); 30 | 31 | 32 | Optional findFirstByUsernameAndPasswordcookie(@Param("username") String username, @Param("passwordcookie") String passwordcookie); 33 | 34 | Optional findFirstByMobile(@Param("mobile")String mobile); 35 | 36 | Optional findFirstByEmail(@Param("email")String email); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/rest/response/BaseResponse.java: -------------------------------------------------------------------------------- 1 | package com.rest.response; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * @Author bruce.ge 10 | * @Date 2017/1/9 11 | * @Description base response 12 | */ 13 | @Data 14 | @Builder 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class BaseResponse { 18 | 19 | private int code; 20 | 21 | private Object data; 22 | 23 | private String msg; 24 | 25 | public static BaseResponse getFromCode(CodeEnum codeEnum) { 26 | return BaseResponse.builder() 27 | .code(codeEnum.getCode()) 28 | .msg(codeEnum.getMsg()) 29 | .build(); 30 | } 31 | 32 | 33 | public static BaseResponse success(Object data) { 34 | return BaseResponse.builder() 35 | .code(CodeEnum.success.getCode()) 36 | .msg(CodeEnum.success.getMsg()) 37 | .data(data) 38 | .build(); 39 | } 40 | 41 | 42 | public static BaseResponse success() { 43 | return BaseResponse.builder() 44 | .code(CodeEnum.success.getCode()) 45 | .msg(CodeEnum.success.getMsg()) 46 | .build(); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/rest/response/CodeConstants.java: -------------------------------------------------------------------------------- 1 | package com.rest.response; 2 | 3 | /** 4 | * @Author bruce.ge 5 | * @Date 2017/1/9 6 | * @Description 7 | */ 8 | public class CodeConstants { 9 | public static final int success = 200; 10 | public static final int username_already_exist = 10001; 11 | public static final int validate_fail = 10002; 12 | public static final int mobile_already_exist = 10003; 13 | public static final int email_already_exist = 10004; 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/rest/response/CodeEnum.java: -------------------------------------------------------------------------------- 1 | package com.rest.response; 2 | 3 | /** 4 | * Created by bruce.ge on 2017/1/9. 5 | */ 6 | public enum CodeEnum { 7 | success(CodeConstants.success, MsgConstants.success), 8 | username_already_exist(CodeConstants.username_already_exist, MsgConstants.username_already_exist), 9 | mobile_already_exist(CodeConstants.mobile_already_exist, MsgConstants.mobile_already_exist), 10 | email_already_exist(CodeConstants.email_already_exist, MsgConstants.email_already_exist), 11 | validate_fail(CodeConstants.validate_fail, MsgConstants.validate_fail); 12 | 13 | int code; 14 | String msg; 15 | 16 | CodeEnum(int value, String msg) { 17 | this.code = value; 18 | this.msg = msg; 19 | } 20 | 21 | public int getCode() { 22 | return this.code; 23 | } 24 | 25 | public String getMsg() { 26 | return this.msg; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/rest/response/MsgConstants.java: -------------------------------------------------------------------------------- 1 | package com.rest.response; 2 | 3 | /** 4 | * @Author bruce.ge 5 | * @Date 2017/1/9 6 | * @Description 7 | */ 8 | public class MsgConstants { 9 | public static final String success = "success"; 10 | 11 | public static final String username_already_exist = "userNameExist"; 12 | 13 | public static final String validate_fail = "validateFail"; 14 | 15 | public static final String mobile_already_exist = "mobileExist"; 16 | 17 | public static final String email_already_exist = "emailExist"; 18 | 19 | 20 | public static final String user_not_eixst = "userNotExist"; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/rest/scheduled/DumpMysql.java: -------------------------------------------------------------------------------- 1 | package com.rest.scheduled; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.File; 7 | import java.security.CodeSource; 8 | 9 | /** 10 | * Created by bruce.ge on 2016/11/21. 11 | */ 12 | public class DumpMysql { 13 | 14 | private static Logger logger = LoggerFactory.getLogger(DumpMysql.class); 15 | public static void BackupDbtosql() { 16 | try { 17 | CodeSource codeSource = DumpMysql.class.getProtectionDomain().getCodeSource(); 18 | File file = new File(codeSource.getLocation().toURI().getPath()); 19 | String jarDir = file.getParentFile().getPath(); 20 | 21 | String dbName = "world"; 22 | 23 | String dbUser = "root"; 24 | 25 | String dbPass = "root"; 26 | 27 | String folderPath = jarDir + "/backup"; 28 | 29 | File f1 = new File(folderPath); 30 | f1.mkdir(); 31 | 32 | String savePth = "/" + jarDir + "/backup/" + "backup.sql"; 33 | 34 | String executeCommand = "mysqldump -h 192.168.0.103 -u" + dbUser + " -p" + dbPass + " --database " + dbName + " -r " + savePth; 35 | 36 | Process exec = Runtime.getRuntime().exec(executeCommand); 37 | int processComplete = exec.waitFor(); 38 | if (processComplete == 0) { 39 | System.out.println("BackUp Complete"); 40 | } else { 41 | System.out.println("BackUp failure"); 42 | } 43 | 44 | } catch (Exception e) { 45 | logger.info("catch exception",e); 46 | } 47 | } 48 | // 49 | // public static void main(String[] args) { 50 | // BackupDbtosql(); 51 | // } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/rest/scheduled/ScheduledTask.java: -------------------------------------------------------------------------------- 1 | package com.rest.scheduled; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | /** 6 | * Created by bruce.ge on 2016/11/21. 7 | */ 8 | @Component 9 | public class ScheduledTask { 10 | 11 | // @Scheduled(fixedDelay = 5000) 12 | public void backUpDatabase(){ 13 | //try to dump the mysql database. 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/rest/scheduled/upload/UploadDemo.java: -------------------------------------------------------------------------------- 1 | package com.rest.scheduled.upload; 2 | 3 | import com.qiniu.common.QiniuException; 4 | import com.qiniu.common.Zone; 5 | import com.qiniu.http.Response; 6 | import com.qiniu.storage.Configuration; 7 | import com.qiniu.storage.UploadManager; 8 | import com.qiniu.util.Auth; 9 | 10 | import java.io.IOException; 11 | 12 | /** 13 | * Created by bruce.ge on 2016/11/21. 14 | */ 15 | public class UploadDemo { 16 | String ACCESS_KEY = "ES7baUBANzDwCSUT23nHBgoBZIy2zBWwjxYak9L3"; 17 | String SECRET_KEY = "*****************"; 18 | String bucketname = "brucegedatabasebackup"; 19 | Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY); 20 | Zone z = Zone.autoZone(); 21 | 22 | Configuration c = new Configuration(z); 23 | UploadManager uploadManager = new UploadManager(c); 24 | 25 | public String getUpToken() { 26 | return auth.uploadToken(bucketname); 27 | } 28 | 29 | public void upload(String path, String savedname) throws IOException { 30 | try { 31 | Response res = uploadManager.put(path, savedname, getUpToken()); 32 | System.out.println(res.bodyStream()); 33 | } catch (QiniuException e) { 34 | Response r = e.response; 35 | System.out.println(r.toString()); 36 | try { 37 | System.out.println(r.bodyString()); 38 | } catch (QiniuException f) { 39 | //do nothing. 40 | } 41 | } 42 | } 43 | 44 | // public static void main(String[] args) throws IOException { 45 | // String path = UploadDemo.class.getClassLoader().getResource("logback-spring.xml").getPath().toString(); 46 | // System.out.println(path); 47 | // new UploadDemo().upload(path, "a.xml"); 48 | // } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/rest/service/AboutService.java: -------------------------------------------------------------------------------- 1 | package com.rest.service; 2 | 3 | import com.rest.domain.AboutPo; 4 | import com.rest.mapper.AboutPoDao; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.transaction.annotation.Transactional; 8 | 9 | import java.util.Optional; 10 | 11 | /** 12 | * Created by bruce.ge on 2017/1/8. 13 | */ 14 | @Service 15 | public class AboutService { 16 | @Autowired 17 | private AboutPoDao aboutPoDao; 18 | 19 | @Transactional 20 | public Optional getAbout() { 21 | return aboutPoDao.findFirstOrderByCreateTimeDesc(); 22 | } 23 | 24 | @Transactional 25 | public int insert(AboutPo aboutPo){ 26 | return aboutPoDao.insert(aboutPo); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/rest/service/ContentService.java: -------------------------------------------------------------------------------- 1 | package com.rest.service; 2 | import com.rest.domain.Content; 3 | import com.rest.domain.ContentTagRelation; 4 | import com.rest.domain.ContentTime; 5 | import com.rest.mapper.ContentMapper; 6 | import com.rest.mapper.ContentTagRelationDao; 7 | import com.rest.mapper.ContentTimeMapper; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import java.util.Date; 13 | import java.util.List; 14 | 15 | /** 16 | * @Author bruce.ge 17 | * @Date 2017/1/20 18 | * @Description 19 | */ 20 | @Service 21 | public class ContentService { 22 | @Autowired 23 | private ContentMapper contentMapper; 24 | 25 | @Autowired 26 | private ContentTimeMapper contentTimeMapper; 27 | 28 | @Autowired 29 | private ContentTagRelationDao contentTagRelationDao; 30 | 31 | @Transactional 32 | public void saveContent(Content content, ContentTime contentTime, List tags) { 33 | contentMapper.insert(content); 34 | contentTime.setContent_id(content.getId()); 35 | contentTimeMapper.insert(contentTime); 36 | for (Integer tag : tags) { 37 | ContentTagRelation pojo = new ContentTagRelation(); 38 | pojo.setContentId(content.getId()); 39 | pojo.setTagId(tag); 40 | pojo.setCreateTime(new Date()); 41 | pojo.setUpdateTime(new Date()); 42 | contentTagRelationDao.insert(pojo); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/rest/service/LoginService.java: -------------------------------------------------------------------------------- 1 | package com.rest.service; 2 | 3 | import com.rest.domain.UserPO; 4 | import com.rest.mapper.UserPODao; 5 | import jodd.util.BCrypt; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.Optional; 10 | 11 | /** 12 | * Created by bruce.ge on 2016/11/13. 13 | */ 14 | @Service 15 | public class LoginService { 16 | @Autowired 17 | private UserPODao userPODao; 18 | 19 | public Optional login(String userName, String password) { 20 | //logged to system. 21 | return userPODao.findFirstByUsername(userName) 22 | .map((user -> { 23 | boolean checkpw = BCrypt.checkpw(password, user.getCryptpasswod()); 24 | if (checkpw) { 25 | return user; 26 | } else { 27 | return null; 28 | } 29 | })) 30 | ; 31 | } 32 | 33 | //todo the cookie shall alway stay the same, shall change base on time. store in database to check. 34 | // try store cookie value in database. then use it to check. 35 | 36 | public Optional loginByCookie(String userName, String passwordCookie) { 37 | return userPODao.findFirstByUsernameAndPasswordcookie(userName, passwordCookie); 38 | 39 | } 40 | 41 | //update cookie value in database. 42 | public void updateCookie(String random, Integer id) { 43 | userPODao.updatePasswordcookieById(random, id); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/rest/service/MessageSourceService.java: -------------------------------------------------------------------------------- 1 | package com.rest.service; 2 | 3 | import org.springframework.context.MessageSource; 4 | import org.springframework.context.MessageSourceAware; 5 | import org.springframework.context.i18n.LocaleContextHolder; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Created by bruce.ge on 2016/11/18. 10 | */ 11 | @Component 12 | public class MessageSourceService implements MessageSourceAware { 13 | private MessageSource messageSource; 14 | 15 | 16 | @Override 17 | public void setMessageSource(MessageSource messageSource) { 18 | this.messageSource = messageSource; 19 | } 20 | 21 | 22 | public String getMessage(String code) { 23 | return messageSource.getMessage(code, new Object[]{}, LocaleContextHolder.getLocale()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rest/service/MyBatisLogService.java: -------------------------------------------------------------------------------- 1 | package com.rest.service; 2 | 3 | import com.rest.domain.MyBatisLog; 4 | import com.rest.mapper.MyBatisLogDao; 5 | import org.springframework.stereotype.Service; 6 | 7 | import javax.annotation.Resource; 8 | import java.util.List; 9 | 10 | @Service 11 | public class MyBatisLogService{ 12 | 13 | @Resource 14 | private MyBatisLogDao myBatisLogDao; 15 | 16 | public int insert(MyBatisLog pojo){ 17 | return myBatisLogDao.insert(pojo); 18 | } 19 | 20 | public int insertSelective(MyBatisLog pojo){ 21 | return myBatisLogDao.insertSelective(pojo); 22 | } 23 | 24 | public int insertList(List pojos){ 25 | return myBatisLogDao.insertList(pojos); 26 | } 27 | 28 | public int update(MyBatisLog pojo){ 29 | return myBatisLogDao.update(pojo); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/rest/service/disposer/StaticResourceDisposaber.java: -------------------------------------------------------------------------------- 1 | package com.rest.service.disposer; 2 | 3 | import com.rest.utils.MarkDownUtil; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.DisposableBean; 7 | import org.springframework.stereotype.Component; 8 | 9 | /** 10 | * Created by bruce.ge on 2016/11/14. 11 | */ 12 | @Component 13 | public class StaticResourceDisposaber implements DisposableBean { 14 | private static Logger logger = LoggerFactory.getLogger(StaticResourceDisposaber.class); 15 | @Override 16 | public void destroy() throws Exception { 17 | logger.info("StaticResourceDisposaber destroy go on"); 18 | MarkDownUtil.destroy(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/rest/storage/StorageExceptioin.java: -------------------------------------------------------------------------------- 1 | package com.rest.storage; 2 | 3 | /** 4 | * Created by bruce.ge on 2016/11/9. 5 | */ 6 | public class StorageExceptioin extends RuntimeException { 7 | public StorageExceptioin(String message){ 8 | super(message); 9 | } 10 | 11 | public StorageExceptioin(String message,Throwable cause){ 12 | super(message,cause); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/rest/storage/StorageFileNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.rest.storage; 2 | 3 | /** 4 | * Created by bruce.ge on 2016/11/9. 5 | */ 6 | public class StorageFileNotFoundException extends RuntimeException { 7 | public StorageFileNotFoundException(String message){ 8 | super(message); 9 | } 10 | 11 | public StorageFileNotFoundException(String message,Throwable cause){ 12 | super(message,cause); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/rest/storage/StorageProperties.java: -------------------------------------------------------------------------------- 1 | package com.rest.storage; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | 5 | /** 6 | * Created by bruce.ge on 2016/11/9. 7 | */ 8 | @Configuration("storage") 9 | public class StorageProperties { 10 | private String location = "/opt/imageloc/"; 11 | 12 | public String getLocation() { 13 | return location; 14 | } 15 | 16 | public void setLocation(String location) { 17 | this.location = location; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rest/storage/StorageService.java: -------------------------------------------------------------------------------- 1 | package com.rest.storage; 2 | 3 | import org.springframework.core.io.Resource; 4 | import org.springframework.web.multipart.MultipartFile; 5 | 6 | import java.nio.file.Path; 7 | import java.util.List; 8 | import java.util.stream.Stream; 9 | 10 | /** 11 | * Created by bruce.ge on 2016/11/9. 12 | */ 13 | public interface StorageService { 14 | void init(); 15 | 16 | void store(MultipartFile file); 17 | 18 | void storeFileWithName(MultipartFile file,String name); 19 | 20 | List loadAll(); 21 | 22 | Path load(String fileName); 23 | 24 | Resource loadAsResource(String filename); 25 | 26 | void deleteAll(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rest/utils/AntiSamyUtils.java: -------------------------------------------------------------------------------- 1 | package com.rest.utils; 2 | 3 | import org.owasp.validator.html.*; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.util.Locale; 8 | 9 | /** 10 | * Created by bruce.ge on 2016/11/20. 11 | */ 12 | public class AntiSamyUtils { 13 | 14 | private static Logger logger = LoggerFactory.getLogger(AntiSamyUtils.class); 15 | 16 | private static AntiSamy antiSamy; 17 | 18 | public static String getCleanHtml(String sourceContent) { 19 | try { 20 | if (antiSamy == null) { 21 | synchronized (AntiSamyUtils.class) { 22 | if (antiSamy == null) { 23 | Policy policy = null; 24 | policy = Policy.getInstance(AntiSamyUtils.class.getClassLoader().getResourceAsStream("antisamy-myspace-1.4.4.xml")); 25 | antiSamy = new AntiSamy(policy); 26 | } 27 | } 28 | } 29 | CleanResults scan = antiSamy.scan(sourceContent); 30 | return scan.getCleanHTML(); 31 | }catch (Exception e){ 32 | logger.error("antisamy get clean html catch exception, the sourceContent is {}",sourceContent,e); 33 | return ""; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/rest/utils/DbUtils.java: -------------------------------------------------------------------------------- 1 | package com.rest.utils; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | import java.io.BufferedReader; 6 | import java.io.InputStreamReader; 7 | import java.sql.Connection; 8 | import java.sql.DriverManager; 9 | import java.sql.SQLException; 10 | 11 | /** 12 | * Created by bruce.ge on 2017/1/4. 13 | */ 14 | @Slf4j 15 | public class DbUtils { 16 | public static void checkOrCreateTables(String dbUrl, String userName, String password) { 17 | log.info("gonna check or create table"); 18 | try { 19 | Class.forName("com.mysql.jdbc.Driver"); 20 | } catch (ClassNotFoundException e) { 21 | throw new RuntimeException("com.mysql.jdbc.Driver class not fund", e); 22 | } 23 | Connection conn = null; 24 | try { 25 | conn = DriverManager.getConnection(dbUrl, userName, password); 26 | } catch (SQLException e) { 27 | throw new RuntimeException("can't connect to database ", e); 28 | } 29 | try { 30 | ScriptRunner runner = new ScriptRunner(conn, true, true); 31 | runner.runScript(new BufferedReader(new InputStreamReader(DbUtils.class 32 | .getClassLoader().getResourceAsStream("ddl.sql")))); 33 | } catch (Exception e) { 34 | throw new RuntimeException(e); 35 | } 36 | try { 37 | conn.close(); 38 | } catch (SQLException e) { 39 | throw new RuntimeException("connection close catch exception", e); 40 | } 41 | } 42 | // 43 | // public static void main(String[] args) { 44 | // DbUtils.checkOrCreateTables("jdbc:mysql://localhost/?serverTimezone=GMT%2b8", "root", ""); 45 | // } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/rest/utils/GsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.rest.utils; 2 | 3 | import com.google.gson.Gson; 4 | 5 | /** 6 | * Created by bruce.ge on 2016/10/23. 7 | */ 8 | public class GsonUtils { 9 | private static Gson gson =new Gson(); 10 | 11 | public static void printToGson(Object o){ 12 | System.out.println(gson.toJson(o)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/rest/utils/HttpHeaderUtil.java: -------------------------------------------------------------------------------- 1 | package com.rest.utils; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | /** 6 | * Created by bruce.ge on 2016/12/7. 7 | */ 8 | public class HttpHeaderUtil { 9 | public static String getRemoteAddr(HttpServletRequest request) { 10 | String remoteAddr = request.getRemoteAddr(); 11 | return remoteAddr; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/rest/utils/IpUtils.java: -------------------------------------------------------------------------------- 1 | package com.rest.utils; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | /** 6 | * @Author bruce.ge 7 | * @Date 2017/2/27 8 | * @Description 9 | */ 10 | public class IpUtils { 11 | public static String getUserIp(HttpServletRequest request) { 12 | String ip = request.getHeader("X-Forwarded-For"); 13 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 14 | ip = request.getHeader("Proxy-Client-IP"); 15 | } 16 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 17 | ip = request.getHeader("WL-Proxy-Client-IP"); 18 | } 19 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 20 | ip = request.getHeader("HTTP_CLIENT_IP"); 21 | } 22 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 23 | ip = request.getHeader("HTTP_X_FORWARDED_FOR"); 24 | } 25 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 26 | ip = request.getRemoteAddr(); 27 | } 28 | return ip; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/rest/utils/MarkdownRequest.java: -------------------------------------------------------------------------------- 1 | package com.rest.utils; 2 | 3 | /** 4 | * Created by bruce.ge on 2016/11/14. 5 | */ 6 | public class MarkdownRequest { 7 | private Long count; 8 | 9 | private String content; 10 | 11 | 12 | public Long getCount() { 13 | return count; 14 | } 15 | 16 | public void setCount(Long count) { 17 | this.count = count; 18 | } 19 | 20 | public String getContent() { 21 | return content; 22 | } 23 | 24 | public void setContent(String content) { 25 | this.content = content; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/rest/utils/SessionUtils.java: -------------------------------------------------------------------------------- 1 | package com.rest.utils; 2 | 3 | import com.rest.bean.User; 4 | import com.rest.constant.SessionConstants; 5 | import org.springframework.web.context.request.RequestContextHolder; 6 | import org.springframework.web.context.request.ServletRequestAttributes; 7 | 8 | import javax.servlet.http.HttpSession; 9 | 10 | /** 11 | * Created by bruce.ge on 2017/1/4. 12 | */ 13 | public class SessionUtils { 14 | public static User getCurrentUser() { 15 | ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes(); 16 | HttpSession session = attr.getRequest().getSession(true); 17 | Object attribute = session.getAttribute(SessionConstants.USER); 18 | if (attribute != null && attribute instanceof User) { 19 | return (User) attribute; 20 | } 21 | return null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/rest/vo/ArchiveVo.java: -------------------------------------------------------------------------------- 1 | package com.rest.vo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | /** 7 | * Created by bruce.ge on 2016/11/7. 8 | */ 9 | @Getter 10 | @Setter 11 | public class ArchiveVo { 12 | private String adddate; 13 | 14 | private String title; 15 | 16 | private String link; 17 | 18 | private int id; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rest/vo/CommentVo.java: -------------------------------------------------------------------------------- 1 | package com.rest.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * Created by bruce.ge on 2016/11/18. 12 | */ 13 | @Data 14 | @Builder 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class CommentVo { 18 | private String name; 19 | 20 | private String comment; 21 | 22 | private String ago; 23 | 24 | private Integer id; 25 | 26 | private Integer parentId; 27 | 28 | private Date addtime; 29 | 30 | // if viewed than is 1 else is 0. 31 | private Short viewed; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/rest/vo/ContentForTagVo.java: -------------------------------------------------------------------------------- 1 | package com.rest.vo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | /** 7 | * @Author bruce.ge 8 | * @Date 2017/2/9 9 | * @Description 10 | */ 11 | @Getter 12 | @Setter 13 | public class ContentForTagVo { 14 | private String contentTitle; 15 | 16 | private String contentUrl; 17 | 18 | private String addTime; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/rest/vo/ContentVo.java: -------------------------------------------------------------------------------- 1 | package com.rest.vo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | /** 7 | * Created by bruce.ge on 2016/11/7. 8 | */ 9 | @Getter 10 | @Setter 11 | public class ContentVo { 12 | 13 | private int id; 14 | private String addtime; 15 | 16 | private String title; 17 | 18 | private String content; 19 | 20 | private String tags; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/rest/vo/MyBatisLogVo.java: -------------------------------------------------------------------------------- 1 | package com.rest.vo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | /** 7 | * @Author bruce.ge 8 | * @Date 2017/2/27 9 | * @Description 10 | */ 11 | @Getter 12 | @Setter 13 | public class MyBatisLogVo { 14 | private Integer id; 15 | 16 | private String className; 17 | 18 | private String userIp; 19 | 20 | private String messages; 21 | 22 | private String createTime; 23 | 24 | private String loggerLevel; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/rest/vo/PageContentVo.java: -------------------------------------------------------------------------------- 1 | package com.rest.vo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | /** 7 | * Created by bruce.ge on 2016/11/6. 8 | */ 9 | @Getter 10 | @Setter 11 | public class PageContentVo { 12 | 13 | //文章的内容 14 | private int id; 15 | 16 | private String title; 17 | 18 | private String content; 19 | 20 | private String link; 21 | 22 | private String startDate; 23 | 24 | private String tags; 25 | 26 | private boolean addMore; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/rest/vo/QueryResultVo.java: -------------------------------------------------------------------------------- 1 | package com.rest.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Created by bruce.ge on 2016/11/8. 7 | */ 8 | @Data 9 | public class QueryResultVo { 10 | private String link; 11 | 12 | private String marktitle; 13 | 14 | private String markContent; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/rest/vo/TagVo.java: -------------------------------------------------------------------------------- 1 | package com.rest.vo; 2 | 3 | import lombok.*; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @Author bruce.ge 9 | * @Date 2017/1/25 10 | * @Description 11 | */ 12 | @Getter 13 | @Setter 14 | @ToString 15 | public class TagVo { 16 | private Integer id; 17 | 18 | private String tagName; 19 | 20 | private Date createTime; 21 | 22 | private Date updateTime; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/resources/MessagesBundle.properties: -------------------------------------------------------------------------------- 1 | greetings = Hello. 2 | farewell = Goodbye. 3 | inquiry = How are you? 4 | home=home 5 | archives=archives 6 | about=about 7 | login=login 8 | edit=edit 9 | delete=delete 10 | register=register 11 | remember=Remember Me 12 | logout=logout 13 | add=add 14 | Previous=Previous 15 | Next=Next 16 | title=title 17 | output=output 18 | save=save 19 | fileOrImageUrl=upload file or img url 20 | optionaltitile=title(optional) 21 | imageinput=image input 22 | optionaImagewidth=image width(optional) 23 | blogtitle=brucege's blog 24 | searchResultEmpty=Query result is empty 25 | presearch=There are 26 | suffixsearch=result 27 | daysbefore= days ago 28 | hoursbefore= hours ago 29 | minutesBefore= minutes ago 30 | Comment=Comment 31 | addCommentButton=add comment 32 | username=username 33 | password=password 34 | email=email 35 | commentname=name 36 | commentContent=please input comment 37 | commentReply=reply 38 | Search=Search 39 | .locale=en_US 40 | manage=manage 41 | emailPlaceHolder = email min length 5, max length 50 42 | admin = admin 43 | tag = tag 44 | -------------------------------------------------------------------------------- /src/main/resources/MessagesBundle_en_US.properties: -------------------------------------------------------------------------------- 1 | greetings = Hello. 2 | farewell = Goodbye. 3 | inquiry = How are you? 4 | home=home 5 | archives=archives 6 | about=about 7 | login=login 8 | edit=edit 9 | delete=delete 10 | register=register 11 | remember=Remember Me 12 | logout=logout 13 | add=add 14 | Previous=Previous 15 | Next=Next 16 | title=title 17 | output=output 18 | save=save 19 | fileOrImageUrl=upload file or img url 20 | optionaltitile=title(optional) 21 | imageinput=image input 22 | optionaImagewidth=image width(optional) 23 | blogtitle=brucege's blog 24 | searchResultEmpty=Query result is empty 25 | presearch=There are 26 | suffixsearch=result 27 | daysbefore= days ago 28 | hoursbefore= hours ago 29 | minutesBefore= minutes ago 30 | Comment=Comment 31 | addCommentButton=add comment 32 | username=username 33 | password=password 34 | email=email 35 | commentname=name 36 | commentContent=please input comment 37 | commentReply=reply 38 | Search=Search 39 | .locale=en_US 40 | manage=manage 41 | emailPlaceHolder=email min lenth 5, max lenth 50 42 | admin=admin 43 | tag=tag 44 | -------------------------------------------------------------------------------- /src/main/resources/MessagesBundle_zh_CN.properties: -------------------------------------------------------------------------------- 1 | greetings = \u4F60\u597D. 2 | farewell = \u518D\u89C1. 3 | inquiry = \u4F60\u597D\u5417? 4 | home=\u9996\u9875 5 | archives=\u5F52\u6863 6 | about=\u5173\u4E8E 7 | login=\u767B\u9646 8 | edit=\u7F16\u8F91 9 | delete=\u5220\u9664 10 | register=\u6CE8\u518C 11 | remember=\u8BB0\u4F4F\u6211 12 | logout=\u9000\u51FA 13 | add=\u53D1\u5E03 14 | Previous=\u4E0A\u4E00\u9875 15 | Next=\u4E0B\u4E00\u9875 16 | title=\u6807\u9898 17 | output=\u8F93\u51FA 18 | save=\u4FDD\u5B58 19 | fileOrImageUrl=\u4E0A\u4F20\u56FE\u7247\u6216\u8005url 20 | optionaltitile=\u6807\u9898(\u53EF\u9009) 21 | imageinput=\u4E0A\u4F20\u56FE\u7247 22 | optionaImagewidth=\u56FE\u7247\u5BBD\u5EA6 23 | blogtitle=brucege's blog 24 | searchResultEmpty=\u67E5\u8BE2\u7ED3\u679C\u4E3A\u7A7A 25 | presearch=\u603B\u5171\u6709 26 | suffixsearch=\u6761\u7ED3\u679C 27 | daysbefore=\u5929\u524D 28 | hoursbefore=\u5C0F\u65F6\u524D 29 | minutesBefore=\u5206\u949F\u524D 30 | Comment=\u8BC4\u8BBA 31 | addCommentButton=\u53D1\u5E03 32 | username=\u7528\u6237\u540D 33 | password=\u5BC6\u7801 34 | email=\u90AE\u7BB1 35 | commentname=\u540D\u5B57 36 | commentContent=\u5C11\u4FA0\uFF0C\u7559\u4E0B\u4F60\u5B9D\u8D35\u7684\u8BC4\u8BBA\u518D\u8D70\uFF01 37 | commentReply=\u56DE\u590D 38 | Search=\u641C\u7D22 39 | .locale=zh_CN 40 | manage=\u7BA1\u7406 41 | emailPlaceHolder=\u90AE\u7BB1\uFF0C5-50\u4F4D 42 | admin=\u7BA1\u7406\u5458 43 | tag=\u6807\u7B7E 44 | -------------------------------------------------------------------------------- /src/main/resources/MessagesBundle_zh_TW.properties: -------------------------------------------------------------------------------- 1 | greetings = \u59B3\u597D. 2 | farewell = \u518D\u898B. 3 | inquiry = \u59B3\u597D\u55CE? 4 | home=\u9996\u9801 5 | archives=\u6B78\u6A94 6 | about=\u95DC\u4E8E 7 | login=\u767B\u9678 8 | edit=\u7DE8\u8F2F 9 | delete=\u522A\u9664 10 | register=\u6CE8\u518A 11 | remember=\u8A18\u4F4F\u6211 12 | logout=\u9000\u51FA 13 | add=\u767C\u5E03 14 | Previous=\u4E0A\u58F9\u9801 15 | Next=\u4E0B\u58F9\u9801 16 | title=\u6A19\u984C 17 | output=\u8F38\u51FA 18 | save=\u4FDD\u5B58 19 | fileOrImageUrl=\u4E0A\u50B3\u5716\u7247\u6216\u8005url 20 | optionaltitile=\u6A19\u984C(\u53EF\u9078) 21 | imageinput=\u4E0A\u50B3\u5716\u7247 22 | optionaImagewidth=\u5716\u7247\u5BEC\u5EA6 23 | blogtitle=brucege's blog 24 | searchResultEmpty=\u67E5\u8A62\u7D50\u679C\u7232\u7A7A 25 | presearch=\u7E3D\u5171\u6709 26 | suffixsearch=\u689D\u7D50\u679C 27 | daysbefore=\u5929\u524D 28 | hoursbefore=\u5C0F\u6642\u524D 29 | minutesBefore=\u5206\u937E\u524D 30 | Comment=\u8A55\u8AD6 31 | addCommentButton=\u767C\u5E03 32 | username=\u7528\u6236\u540D 33 | password=\u5BC6\u78BC 34 | email=\u90F5\u7BB1 35 | commentname=\u540D\u5B57 36 | commentContent=\u5C11\u4FE0\uFF0C\u7559\u4E0B\u59B3\u5BF6\u8CB4\u7684\u8A55\u8AD6\u518D\u8D70\uFF01 37 | commentReply=\u56DE\u8907 38 | Search=\u641C\u7D22 39 | .locale=zh_TW 40 | manage=\u7BA1\u7406 41 | emailPlaceHolder=\u90AE\u7BB1\uFF0C5-50\u4F4D 42 | admin=\u7BA1\u7406\u5458 43 | tag=\u6807\u7B7E 44 | -------------------------------------------------------------------------------- /src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | mybatis: 2 | mapper-locations: classpath:/mapper/*.xml 3 | config-location: classpath:/mybatis-config.xml 4 | 5 | spring: 6 | freemarker: 7 | settings: 8 | auto_import: spring.ftl as spring 9 | charset: UTF-8 10 | cache: false 11 | 12 | 13 | 14 | logging: 15 | file: logs/app.log 16 | level: debug 17 | 18 | #No auth protected 19 | endpoints: 20 | shutdown: 21 | sensitive: false 22 | enabled: true 23 | 24 | 25 | 26 | #server.tomcat.remote_ip_header=x-forwarded-for 27 | server: 28 | tomcat: 29 | protocol_header: x-forwarded-proto 30 | use-forward-headers: true 31 | port: 9098 32 | 33 | # config your database config here. 数据库的配置 34 | db: 35 | url: jdbc:mysql://localhost/world?useUnicode=true&characterEncoding=utf8&useSSL=false 36 | username: root 37 | password: 38 | #set if comment is open. 39 | blog: 40 | comment: true 41 | -------------------------------------------------------------------------------- /src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | mybatis: 2 | mapper-locations: classpath:/mapper/*.xml 3 | config-location: classpath:/mybatis-config.xml 4 | 5 | logging: 6 | file: logs/app.log 7 | level: info 8 | 9 | #No auth protected 10 | endpoints: 11 | shutdown: 12 | sensitive: false 13 | enabled: true 14 | 15 | #server.tomcat.remote_ip_header=x-forwarded-for 16 | 17 | server: 18 | tomcat: 19 | protocol_header: x-forwarded-proto 20 | use-forward-headers: true 21 | port: 8080 22 | compression: 23 | enabled: true 24 | mime-types: text/html,text/xml,text/plain,text/css, application/javascript, application/json 25 | min-response-size: 1024 26 | 27 | 28 | 29 | spring: 30 | freemarker: 31 | settings: 32 | auto_import: spring.ftl as spring 33 | charset: UTF-8 34 | cache: true 35 | template-loader-path: ["classpath:/prod-templates/"] 36 | 37 | devtools: 38 | restart: 39 | enabled: false 40 | livereload: 41 | enabled: false 42 | # datasource: 43 | # type: com.zaxxer.hikari.HikariDataSource 44 | # url: jdbc:mysql://localhost:3306/my_blog?useUnicode=true&characterEncoding=utf8&useSSL=false 45 | # name: 46 | # username: root 47 | # password: 48 | # hikari: 49 | # data-source-properties: 50 | # cachePrepStmts: true 51 | # prepStmtCacheSize: 250 52 | # prepStmtCacheSqlLimit: 2048 53 | # useServerPrepStmts: true 54 | 55 | # config your database config here. 数据库的配置 56 | db: 57 | url: jdbc:mysql://localhost/world?useUnicode=true&characterEncoding=utf8&useSSL=false 58 | username: root 59 | password: 60 | #set if comment is open. 61 | blog: 62 | comment: true 63 | -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | 5 | -------------------------------------------------------------------------------- /src/main/resources/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/favicon.ico -------------------------------------------------------------------------------- /src/main/resources/liquibase.properties: -------------------------------------------------------------------------------- 1 | url:jdbc:mysql://localhost:3306/world?createDatabaseIfNotExist=true 2 | username bruce 3 | password root 4 | driver com.mysql.jdbc.Driver 5 | 6 | changeLogFile src/main/liquibase/all.xml 7 | 8 | databaseChangeLogTableName liquibase_change_log 9 | 10 | -------------------------------------------------------------------------------- /src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | ${FILE_LOG_PATTERN} 8 | 9 | logs/access.log 10 | 11 | logs/access.log.%i 12 | 13 | 15 | 10MB 16 | 17 | 18 | 19 | 21 | 22 | ${FILE_LOG_PATTERN} 23 | 24 | logs/executionTime.log 25 | 26 | logs/executionTime.log.%i 27 | 28 | 30 | 10MB 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ContentTimeMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | SELECT id,year,month,day,content_id 9 | FROM contenttime 10 | 11 | 12 | 13 | insert INTO contenttime(year,month,day,content_id) VALUES (#{year},#{month},#{day},#{content_id}) 14 | 15 | 16 | 17 | DELETE FROM contenttime where content_id =#{id} 18 | 19 | 20 | 23 | 24 | 27 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ExecutionTimeLogDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | `id`, 18 | `class_name`, 19 | `method_name`, 20 | `execution_time`, 21 | `args_value`, 22 | `create_time` 23 | 24 | 25 | 26 | 27 | 28 | INSERT INTO `execution_time_log` 29 | (`class_name`, `method_name`, `execution_time`, `args_value`, `create_time`) values 30 | (#{pojo.className},#{pojo.methodName}, #{pojo.executionTime}, #{pojo.argsValue}, #{pojo.createTime}) 31 | 32 | 33 | 34 | 35 | INSERT INTO `execution_time_log`( 36 | 37 | )VALUES 38 | 39 | ( 40 | #{pojo.id}, 41 | #{pojo.className}, 42 | #{pojo.methodName}, 43 | #{pojo.executionTime}, 44 | #{pojo.argsValue}, 45 | #{pojo.createTime} 46 | ) 47 | 48 | 49 | 50 | 51 | 52 | UPDATE `execution_time_log` 53 | 54 | `id` = #{pojo.id}, 55 | `class_name` = #{pojo.className}, 56 | `method_name` = #{pojo.methodName}, 57 | `execution_time` = #{pojo.executionTime}, 58 | `args_value` = #{pojo.argsValue}, 59 | `create_time` = #{pojo.createTime} 60 | 61 | WHERE `id` = #{pojo.id} 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/main/resources/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/main/resources/public/error/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Page Not Found 6 | 7 | 54 | 55 | 56 |

Page Not Found

57 |

Sorry, but the page you were trying to view does not exist.

58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/main/resources/static/css/admin.css: -------------------------------------------------------------------------------- 1 | 2 | * { 3 | margin: 0; 4 | padding: 0; 5 | } 6 | 7 | body { 8 | font-family: 'Roboto', sans-serif; 9 | font-size: 1.4em; 10 | } 11 | 12 | div#header { 13 | width: 100%; 14 | height: 50px;; 15 | background-color: #2c3e50; 16 | } 17 | 18 | .logo { 19 | float: left; 20 | margin-top: 4px;; 21 | font-size: 1.8em;; 22 | margin-left: 10px;; 23 | color: #ffffff; 24 | } 25 | 26 | .mypanel { 27 | margin-top: 5px;; 28 | font-size: 1.2em; 29 | color: #ffffff; 30 | margin-right: 20px;; 31 | float: right; 32 | } 33 | 34 | .mypanel button { 35 | padding: 0; 36 | padding-top: 4px; 37 | border: none; 38 | background: none; 39 | font-size: 1.0em;; 40 | vertical-align: top; 41 | /*height:100%;*/ 42 | } 43 | 44 | .mypanel button span { 45 | color: #ffffff;; 46 | font-size: 1.2em;; 47 | /*line-height: 0px;;*/ 48 | /*line-height: 30px;;*/ 49 | /*height: 31px;;*/ 50 | display: inline-block; 51 | vertical-align: top; 52 | margin-right: 10px;; 53 | margin-top: 5px;; 54 | /*padding-top:15px;*/ 55 | } 56 | 57 | /*.mypanel button img{*/ 58 | /*vertical-align: top;*/ 59 | /*}*/ 60 | 61 | .mypanel button:focus { 62 | outline: 0; 63 | } 64 | 65 | div#sidebar { 66 | float: left; 67 | width: 250px; 68 | height: 100%; 69 | background-color: #16a085; 70 | } 71 | 72 | div#sidebar ul li a span{ 73 | display: inline-block; 74 | /*vertical-align: top;*/ 75 | margin-top: 5px; 76 | } 77 | 78 | /*div#sidebar ul{*/ 79 | /**/ 80 | /*}*/ 81 | 82 | ul li { 83 | list-style: none; 84 | } 85 | 86 | ul li a { 87 | display: block; 88 | color: #ffffff;; 89 | font-size: 1.2em; 90 | padding: 10px; 91 | border-bottom: 1px solid; 92 | text-decoration: none; 93 | } 94 | 95 | ul li a img { 96 | vertical-align: top; 97 | } 98 | 99 | ul li a:hover { 100 | background-color: #000000; 101 | } 102 | 103 | #addContent { 104 | margin-left: 260px; 105 | } 106 | 107 | #editAboutLinkContent{ 108 | margin-left: 260px; 109 | } 110 | 111 | #sourceContent { 112 | width: 48%; 113 | float: left; 114 | /*border-right:solid;*/ 115 | } 116 | 117 | #aboutSourceContent{ 118 | width: 48%; 119 | float: left; 120 | } 121 | 122 | #aboutMarkDownContent{ 123 | margin-left: 50%; 124 | height: 80%; 125 | overflow-y: scroll; 126 | border:2px solid #eee; 127 | } 128 | #markdownContent { 129 | margin-left: 50%; 130 | height: 80%; 131 | overflow-y: scroll; 132 | border:2px solid #eee; 133 | } 134 | 135 | #sourceContentValue { 136 | width: 98%;; 137 | min-height: 65%; 138 | overflow-y: scroll; 139 | } 140 | 141 | #editAboutValue{ 142 | width: 98%;; 143 | min-height: 65%; 144 | overflow-y: scroll; 145 | } 146 | 147 | #sourceContentTitle{ 148 | width:98%;; 149 | } 150 | 151 | #addContentHeader { 152 | height: 30px;; 153 | font-size: 20px; 154 | color: #9b59b6; 155 | margin-bottom: 15px; 156 | text-align: center; 157 | } 158 | 159 | #addContentHeader span{ 160 | margin-left: 10px; 161 | } 162 | -------------------------------------------------------------------------------- /src/main/resources/static/css/bootstrap-markdown.min.css: -------------------------------------------------------------------------------- 1 | .md-editor{display:block;border:1px solid #ddd}.md-editor .md-footer,.md-editor>.md-header{display:block;padding:6px 4px;background:#f5f5f5}.md-editor>.md-header{margin:0}.md-editor>.md-preview{background:#fff;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;min-height:10px;overflow:auto}.md-editor>textarea{font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:14px;outline:0;margin:0;display:block;padding:0;width:100%;border:0;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;border-radius:0;box-shadow:none;background:#eee}.md-editor>textarea:focus{box-shadow:none;background:#fff}.md-editor.active{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.md-editor .md-controls{float:right;padding:3px}.md-editor .md-controls .md-control{right:5px;color:#bebebe;padding:3px 3px 3px 10px}.md-editor .md-controls .md-control:hover{color:#333}.md-editor.md-fullscreen-mode{width:100%;height:100%;position:fixed;top:0;left:0;z-index:99999;padding:60px 30px 15px;background:#fff!important;border:0!important}.md-editor.md-fullscreen-mode .md-footer{display:none}.md-editor.md-fullscreen-mode .md-input,.md-editor.md-fullscreen-mode .md-preview{margin:0 auto!important;height:100%!important;font-size:20px!important;padding:20px!important;color:#999;line-height:1.6em!important;resize:none!important;box-shadow:none!important;background:#fff!important;border:0!important}.md-editor.md-fullscreen-mode .md-preview{color:#333;overflow:auto}.md-editor.md-fullscreen-mode .md-input:focus,.md-editor.md-fullscreen-mode .md-input:hover{color:#333;background:#fff!important}.md-editor.md-fullscreen-mode .md-header{background:0 0;text-align:center;position:fixed;width:100%;top:20px}.md-editor.md-fullscreen-mode .btn-group{float:none}.md-editor.md-fullscreen-mode .btn{border:0;background:0 0;color:#b3b3b3}.md-editor.md-fullscreen-mode .btn.active,.md-editor.md-fullscreen-mode .btn:active,.md-editor.md-fullscreen-mode .btn:focus,.md-editor.md-fullscreen-mode .btn:hover{box-shadow:none;color:#333}.md-editor.md-fullscreen-mode .md-fullscreen-controls{position:absolute;top:20px;right:20px;text-align:right;z-index:1002;display:block}.md-editor.md-fullscreen-mode .md-fullscreen-controls a{color:#b3b3b3;clear:right;margin:10px;width:30px;height:30px;text-align:center}.md-editor.md-fullscreen-mode .md-fullscreen-controls a:hover{color:#333;text-decoration:none}.md-editor.md-fullscreen-mode .md-editor{height:100%!important;position:relative}.md-editor .md-fullscreen-controls{display:none}.md-nooverflow{overflow:hidden;position:fixed;width:100%} -------------------------------------------------------------------------------- /src/main/resources/static/css/bootstrap-tagsinput.css: -------------------------------------------------------------------------------- 1 | .bootstrap-tagsinput { 2 | background-color: #fff; 3 | border: 1px solid #ccc; 4 | box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); 5 | display: inline-block; 6 | padding: 4px 6px; 7 | color: #555; 8 | vertical-align: middle; 9 | border-radius: 4px; 10 | max-width: 100%; 11 | line-height: 22px; 12 | cursor: text; 13 | } 14 | .bootstrap-tagsinput input { 15 | border: none; 16 | box-shadow: none; 17 | outline: none; 18 | background-color: transparent; 19 | padding: 0 6px; 20 | margin: 0; 21 | width: auto; 22 | max-width: inherit; 23 | } 24 | .bootstrap-tagsinput.form-control input::-moz-placeholder { 25 | color: #777; 26 | opacity: 1; 27 | } 28 | .bootstrap-tagsinput.form-control input:-ms-input-placeholder { 29 | color: #777; 30 | } 31 | .bootstrap-tagsinput.form-control input::-webkit-input-placeholder { 32 | color: #777; 33 | } 34 | .bootstrap-tagsinput input:focus { 35 | border: none; 36 | box-shadow: none; 37 | } 38 | .bootstrap-tagsinput .tag { 39 | margin-right: 2px; 40 | color: white; 41 | } 42 | .bootstrap-tagsinput .tag [data-role="remove"] { 43 | margin-left: 8px; 44 | cursor: pointer; 45 | } 46 | .bootstrap-tagsinput .tag [data-role="remove"]:after { 47 | content: "x"; 48 | padding: 0px 2px; 49 | } 50 | .bootstrap-tagsinput .tag [data-role="remove"]:hover { 51 | box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 52 | } 53 | .bootstrap-tagsinput .tag [data-role="remove"]:hover:active { 54 | box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); 55 | } 56 | -------------------------------------------------------------------------------- /src/main/resources/static/css/comment.css: -------------------------------------------------------------------------------- 1 | .thumbnail { 2 | padding:0px; 3 | } 4 | .panel { 5 | position:relative; 6 | } 7 | .panel>.panel-heading:after,.panel>.panel-heading:before{ 8 | position:absolute; 9 | top:11px;left:-16px; 10 | right:100%; 11 | width:0; 12 | height:0; 13 | display:block; 14 | content:" "; 15 | border-color:transparent; 16 | border-style:solid solid outset; 17 | pointer-events:none; 18 | } 19 | .panel>.panel-heading:after{ 20 | border-width:7px; 21 | border-right-color:#f7f7f7; 22 | margin-top:1px; 23 | margin-left:2px; 24 | } 25 | .panel>.panel-heading:before{ 26 | border-right-color:#ddd; 27 | border-width:8px; 28 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/login.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 90px; 3 | background-color: #3498db; 4 | } 5 | .panel-login { 6 | border-color: #ccc; 7 | -webkit-box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.2); 8 | -moz-box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.2); 9 | box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.2); 10 | } 11 | .panel-login>.panel-heading { 12 | color: #00415d; 13 | background-color: #fff; 14 | border-color: #fff; 15 | text-align:center; 16 | } 17 | .panel-login>.panel-heading a{ 18 | text-decoration: none; 19 | color: #666; 20 | font-weight: bold; 21 | font-size: 15px; 22 | -webkit-transition: all 0.1s linear; 23 | -moz-transition: all 0.1s linear; 24 | transition: all 0.1s linear; 25 | } 26 | .panel-login>.panel-heading a.active{ 27 | color: #029f5b; 28 | font-size: 18px; 29 | } 30 | .panel-login>.panel-heading hr{ 31 | margin-top: 10px; 32 | margin-bottom: 0px; 33 | clear: both; 34 | border: 0; 35 | height: 1px; 36 | background-image: -webkit-linear-gradient(left,rgba(0, 0, 0, 0),rgba(0, 0, 0, 0.15),rgba(0, 0, 0, 0)); 37 | background-image: -moz-linear-gradient(left,rgba(0,0,0,0),rgba(0,0,0,0.15),rgba(0,0,0,0)); 38 | background-image: -ms-linear-gradient(left,rgba(0,0,0,0),rgba(0,0,0,0.15),rgba(0,0,0,0)); 39 | background-image: -o-linear-gradient(left,rgba(0,0,0,0),rgba(0,0,0,0.15),rgba(0,0,0,0)); 40 | } 41 | .panel-login input[type="text"],.panel-login input[type="email"],.panel-login input[type="password"] { 42 | height: 45px; 43 | border: 1px solid #ddd; 44 | font-size: 16px; 45 | -webkit-transition: all 0.1s linear; 46 | -moz-transition: all 0.1s linear; 47 | transition: all 0.1s linear; 48 | } 49 | .panel-login input:hover, 50 | .panel-login input:focus { 51 | outline:none; 52 | -webkit-box-shadow: none; 53 | -moz-box-shadow: none; 54 | box-shadow: none; 55 | border-color: #ccc; 56 | } 57 | .btn-login { 58 | background-color: #59B2E0; 59 | outline: none; 60 | color: #fff; 61 | font-size: 14px; 62 | height: auto; 63 | font-weight: normal; 64 | padding: 14px 0; 65 | text-transform: uppercase; 66 | border-color: #59B2E6; 67 | } 68 | .btn-login:hover, 69 | .btn-login:focus { 70 | color: #fff; 71 | background-color: #53A3CD; 72 | border-color: #53A3CD; 73 | } 74 | .forgot-password { 75 | text-decoration: underline; 76 | color: #888; 77 | } 78 | .forgot-password:hover, 79 | .forgot-password:focus { 80 | text-decoration: underline; 81 | color: #666; 82 | } 83 | 84 | .btn-register { 85 | background-color: #1CB94E; 86 | outline: none; 87 | color: #fff; 88 | font-size: 14px; 89 | height: auto; 90 | font-weight: normal; 91 | padding: 14px 0; 92 | text-transform: uppercase; 93 | border-color: #1CB94A; 94 | } 95 | .btn-register:hover, 96 | .btn-register:focus { 97 | color: #fff; 98 | background-color: #1CA347; 99 | border-color: #1CA347; 100 | } 101 | -------------------------------------------------------------------------------- /src/main/resources/static/css/search.css: -------------------------------------------------------------------------------- 1 | #search { 2 | float: right; 3 | margin-top: 9px; 4 | width: 250px; 5 | } 6 | 7 | .search { 8 | padding: 5px 0; 9 | width: 230px; 10 | height: 30px; 11 | position: relative; 12 | left: 10px; 13 | float: left; 14 | line-height: 22px; 15 | } 16 | 17 | .search input { 18 | position: absolute; 19 | width: 200px; 20 | float: Left; 21 | margin-left: 0px; 22 | -webkit-transition: all 0.7s ease-in-out; 23 | -moz-transition: all 0.7s ease-in-out; 24 | -o-transition: all 0.7s ease-in-out; 25 | transition: all 0.7s ease-in-out; 26 | height: 30px; 27 | line-height: 18px; 28 | padding: 0 2px 0 2px; 29 | border-radius:1px; 30 | } 31 | 32 | .btn { 33 | height: 30px; 34 | position: absolute; 35 | right: 0; 36 | top: 5px; 37 | border-radius:1px; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/resources/static/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /src/main/resources/static/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /src/main/resources/static/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/main/resources/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/main/resources/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/img/add_content.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/add_content.png -------------------------------------------------------------------------------- /src/main/resources/static/img/anonymous.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/anonymous.gif -------------------------------------------------------------------------------- /src/main/resources/static/img/article-marketing-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/article-marketing-black.png -------------------------------------------------------------------------------- /src/main/resources/static/img/article-marketing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/article-marketing.png -------------------------------------------------------------------------------- /src/main/resources/static/img/calendar (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/calendar (1).png -------------------------------------------------------------------------------- /src/main/resources/static/img/calendar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/calendar.png -------------------------------------------------------------------------------- /src/main/resources/static/img/dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/dashboard.png -------------------------------------------------------------------------------- /src/main/resources/static/img/edit-content.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/edit-content.png -------------------------------------------------------------------------------- /src/main/resources/static/img/email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/email.png -------------------------------------------------------------------------------- /src/main/resources/static/img/folded-newspaper (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/folded-newspaper (1).png -------------------------------------------------------------------------------- /src/main/resources/static/img/folded-newspaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/folded-newspaper.png -------------------------------------------------------------------------------- /src/main/resources/static/img/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/home.png -------------------------------------------------------------------------------- /src/main/resources/static/img/logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/logout.png -------------------------------------------------------------------------------- /src/main/resources/static/img/message-closed-envelope.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/message-closed-envelope.png -------------------------------------------------------------------------------- /src/main/resources/static/img/mypic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/mypic.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/price-tag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/price-tag.png -------------------------------------------------------------------------------- /src/main/resources/static/img/reply.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/reply.png -------------------------------------------------------------------------------- /src/main/resources/static/img/rubbish-bin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/rubbish-bin.png -------------------------------------------------------------------------------- /src/main/resources/static/img/tag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/tag.png -------------------------------------------------------------------------------- /src/main/resources/static/img/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gejun123456/bootstrap-java-blog/3d053ad8f85ed8faa24e4945064ea7c46aa4616c/src/main/resources/static/img/user.png -------------------------------------------------------------------------------- /src/main/resources/static/js/i18n/en_US.js: -------------------------------------------------------------------------------- 1 | var messageStrings = { 2 | userNameExist : 'userName already exist, please reinput', 3 | mobileExist : 'mobile alrady exist, please reinput', 4 | emailExist: 'email already exist, please reinput', 5 | validateFail:"validate fail, please reinput", 6 | systemError:"system error", 7 | userNotExist:"user not exist", 8 | success:"success" 9 | }; 10 | -------------------------------------------------------------------------------- /src/main/resources/static/js/i18n/zh_CN.js: -------------------------------------------------------------------------------- 1 | $.extend($.validator.messages, { 2 | required: "这是必填字段", 3 | remote: "请修正此字段", 4 | email: "请输入有效的电子邮件地址", 5 | url: "请输入有效的网址", 6 | date: "请输入有效的日期", 7 | dateISO: "请输入有效的日期 (YYYY-MM-DD)", 8 | number: "请输入有效的数字", 9 | digits: "只能输入数字", 10 | creditcard: "请输入有效的信用卡号码", 11 | equalTo: "你的输入不相同", 12 | extension: "请输入有效的后缀", 13 | maxlength: $.validator.format("最多可以输入 {0} 个字符"), 14 | minlength: $.validator.format("最少要输入 {0} 个字符"), 15 | rangelength: $.validator.format("请输入长度在 {0} 到 {1} 之间的字符串"), 16 | range: $.validator.format("请输入范围在 {0} 到 {1} 之间的数值"), 17 | max: $.validator.format("请输入不大于 {0} 的数值"), 18 | min: $.validator.format("请输入不小于 {0} 的数值") 19 | }); 20 | 21 | var messageStrings = { 22 | userNameExist: '用户名已经存在,请重新输入', 23 | mobileExist: '手机号已存在,请重新输入', 24 | emailExist: '邮箱已存在,请重新输入', 25 | validateFail: "验证失败,请重新输入", 26 | systemError:"系统错误", 27 | userNotExist:"用户不存在", 28 | success:"成功" 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /src/main/resources/static/js/i18n/zh_TW.js: -------------------------------------------------------------------------------- 1 | $.extend($.validator.messages, { 2 | required: "這是必填字段", 3 | remote: "請修正此字段", 4 | email: "請輸入有效的電子郵件地址", 5 | url: "請輸入有效的網址", 6 | date: "請輸入有效的日期", 7 | dateISO: "請輸入有效的日期 (YYYY-MM-DD)", 8 | number: "請輸入有效的數字", 9 | digits: "只能輸入數字", 10 | creditcard: "請輸入有效的信用卡號碼", 11 | equalTo: "妳的輸入不相同", 12 | extension: "請輸入有效的後綴", 13 | maxlength: $.validator.format("最多可以輸入 {0} 個字符"), 14 | minlength: $.validator.format("最少要輸入 {0} 個字符"), 15 | rangelength: $.validator.format("請輸入長度在 {0} 到 {1} 之間的字符串"), 16 | range: $.validator.format("請輸入範圍在 {0} 到 {1} 之間的數值"), 17 | max: $.validator.format("請輸入不大于 {0} 的數值"), 18 | min: $.validator.format("請輸入不小于 {0} 的數值") 19 | }); 20 | 21 | 22 | var messageStrings = { 23 | userNameExist: '用戶名已經存在,請重新輸入', 24 | mobileExist: '手機號已存在,請重新輸入', 25 | emailExist: '郵箱已存在,請重新輸入', 26 | validateFail: "驗證失敗,請重新輸入", 27 | userNotExist:"user not exist", 28 | success:"成功" 29 | }; 30 | -------------------------------------------------------------------------------- /src/main/resources/static/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /src/main/resources/templates/about.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | <#include "head_header.ftl"> 4 | 5 | 6 | <#include "header.ftl"> 7 |
8 |
9 |
10 |
11 | <#--adddata to this position--> 12 | ${aboutContent} 13 | <#--test build.--> 14 |
15 | 16 | <#include "footerjs.ftl"> 17 | 18 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/resources/templates/add.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | <#include "head_header.ftl"> 4 | 5 | 6 | 7 | 8 | <#include "header.ftl"> 9 | <#include "markdown.ftl"> 10 | 11 | <#include "footerjs.ftl"> 12 | 13 | <#----> 14 | 15 | 16 | 17 | 78 | -------------------------------------------------------------------------------- /src/main/resources/templates/archive.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | <#include "head_header.ftl"> 4 | 5 | 6 | <#include "header.ftl"> 7 |
8 |
9 |
10 | <#list years as year> 11 |
12 |

${year}

13 |
14 | <#list archiveMap[year] as yearac> 15 |
16 | ${yearac.adddate} >> ${yearac.title} 17 | <#if admin??> 18 | 19 | 20 | 21 |
22 | 23 | 24 |
25 |
26 |
27 | 28 | <#include "footerjs.ftl"> 29 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/templates/edit.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | <#include "head_header.ftl"> 4 | 5 | 6 | 7 | 8 | <#include "header.ftl"> 9 | 10 | <#include "markdown.ftl"> 11 | 12 | <#include "footerjs.ftl"> 13 | <#----> 14 | 15 | 16 | 17 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/main/resources/templates/footerjs.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 55 | 56 | 73 | 74 | <#----> 79 | 80 | -------------------------------------------------------------------------------- /src/main/resources/templates/head_header.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <@spring.message "blogtitle"/> 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/resources/templates/header_admin.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <@spring.message "blogtitle"/> 5 | -------------------------------------------------------------------------------- /src/main/resources/templates/index.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | <#include "head_header.ftl"> 4 | 5 | 6 | <#include "header.ftl"> 7 |
8 | 9 |
10 |
11 | <#--
--> 12 | <#--

<Bruce ge>

--> 13 | <#--
--> 14 | <#--adddata to this position--> 15 | <#list contents as co> 16 |
17 |
18 |

${co.title}

19 | Post By Bruce ${co.startDate} 20 | <#if co.tags ?has_content> 21 | ${co.tags} 22 | 23 |
24 | <#----> 30 |
31 | ${co.content} 32 |
33 |
34 | 35 | 45 |
46 | 47 | 48 |
49 |
50 | 51 | <#include "footerjs.ftl"> 52 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/main/resources/templates/markdown_btngroup.ftl: -------------------------------------------------------------------------------- 1 |
2 | 5 | 8 | 11 |
12 |
13 | 16 | <#--link button modal--> 17 | 18 | 19 | 22 | <#--modal for image--> 23 | 24 |
25 |
26 | 28 | 31 | 34 | 37 | 40 |
-------------------------------------------------------------------------------- /src/main/resources/templates/markdown_modal.ftl: -------------------------------------------------------------------------------- 1 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/resources/templates/mybatisLogView.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | nimeiya 4 | <#list contents as content> 5 |
  • className is:${content.className} messages are:${content.messages} userIp are:${content.userIp} createTime is:${content.createTime}
  • 6 | 7 | <#if previousLink??> 8 | 9 | 10 | 11 | <#if nextLink??> 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/templates/searchPage.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | <#include "head_header.ftl"> 4 | 5 | 6 | 7 | <#include "header.ftl"> 8 |
    9 |
    10 |
    11 | <#--
    --> 12 | <#--

    <Bruce ge>

    --> 13 | <#--
    --> 14 | <#--adddata to this position--> 15 |
    16 | <#if !hasContent> 17 |

    <@spring.message "searchResultEmpty"/>

    18 | <#else> 19 |

    <@spring.message "presearch"/> ${resultlen} <@spring.message "suffixsearch"/>

    20 |
    21 | <#list result as co> 22 |

    ${co.marktitle}

    23 |

    ${co.markContent}

    24 |
    25 | 26 | 27 | 28 |
    29 |
    30 |
    31 | 32 | 41 | 42 | <#include "footerjs.ftl"> 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/main/resources/templates/tag.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | <#include "head_header.ftl"> 4 | 5 | 6 | <#include "header.ftl"> 7 |
    8 |
    9 |
    10 |
    11 | <#--adddata to this position--> 12 | <#list tags as tag> 13 |
    14 | ${tag.tagName} 15 |
    16 | 17 | 18 | <#--test build.--> 19 |
    20 | 21 | <#include "footerjs.ftl"> 22 | 23 | 28 | 29 | -------------------------------------------------------------------------------- /src/main/resources/templates/tagContent.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | <#include "head_header.ftl"> 4 | 5 | 6 | <#include "header.ftl"> 7 |
    8 |
    9 |
    10 |
    11 | <#--adddata to this position--> 12 | <#list tagContentVos as tagVo> 13 |
    14 | ${tagVo.addTime} >> ${tagVo.contentTitle} 15 |
    16 | 17 | 18 | <#--test build.--> 19 |
    20 | 21 | <#include "footerjs.ftl"> 22 | 23 | 28 | 29 | -------------------------------------------------------------------------------- /src/main/resources/templates/test.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 |
    17 | "At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque 18 | corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa 19 | qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita 20 | 21 |
    22 | 23 |
    24 | "At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque 25 | corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa 26 | qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita 27 | distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime 28 | placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut 29 | officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non 30 | recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias 31 | consequatur aut perferendis doloribus asperiores repellat." 32 |
    33 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/templates/test_verticle.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 61 | 62 | 73 | 74 | -------------------------------------------------------------------------------- /src/main/resources/templates/uploadForm.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
    5 | <#if message??> 6 |

    7 | 8 |

    9 | 10 |
    11 |
    12 | 13 | 14 | 15 |
    File to upload:
    16 |
    17 |
    18 | 19 |
    20 |
      21 | <#list files as file> 22 |
    • 23 | ${file} 24 |
    • 25 | 26 |
    27 |
    28 | 29 | 30 | -------------------------------------------------------------------------------- /src/test/java/basic/AbstractTest.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | import com.App; 4 | import com.google.gson.Gson; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | /** 10 | * Created by bruce.ge on 2016/10/23. 11 | */ 12 | @RunWith(SpringRunner.class) 13 | @SpringBootTest(classes = App.class) 14 | public class AbstractTest { 15 | private static Gson gson = new Gson(); 16 | protected void printToGson(Object o){ 17 | System.out.println(gson.toJson(o)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/com/MybatisApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import basic.AbstractTest; 4 | import com.rest.domain.Content; 5 | import com.rest.domain.ContentTime; 6 | import com.rest.domain.UserPO; 7 | import com.rest.mapper.ContentMapper; 8 | import com.rest.mapper.ContentTimeMapper; 9 | import com.rest.mapper.UserPODao; 10 | import jodd.util.BCrypt; 11 | import org.junit.ClassRule; 12 | import org.junit.Test; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.test.rule.OutputCapture; 15 | 16 | /** 17 | * Created by bruce.ge on 2016/10/23. 18 | */ 19 | public class MybatisApplicationTest extends AbstractTest{ 20 | @ClassRule 21 | public static OutputCapture out = new OutputCapture(); 22 | 23 | 24 | @Autowired 25 | private ContentMapper contentMapper; 26 | 27 | @Autowired 28 | private ContentTimeMapper contentTimeMapper; 29 | 30 | @Autowired 31 | private UserPODao userPODao; 32 | 33 | 34 | @Test 35 | public void testInsert(){ 36 | Content content = new Content(); 37 | content.setTitle("nimei"); 38 | content.setSource_content("hehe"); 39 | content.setHtml_content("hehe"); 40 | int i = contentMapper.insert(content); 41 | System.out.println(content.getId()); 42 | } 43 | 44 | @Test 45 | public void testInsertContentTime(){ 46 | ContentTime time = new ContentTime(); 47 | time.setYear(2016); 48 | time.setMonth(11); 49 | time.setDay(6); 50 | time.setContent_id(6); 51 | int insert = contentTimeMapper.insert(time); 52 | System.out.println(insert); 53 | } 54 | 55 | @Test 56 | public void testApo(){ 57 | 58 | } 59 | 60 | 61 | @Test 62 | public void testInsertUserPo(){ 63 | UserPO po = new UserPO(); 64 | po.setAuth(1); 65 | po.setUsername("bruce"); 66 | po.setMobile("1233"); 67 | po.setEmail("xxx@163.com"); 68 | String hashpw = BCrypt.hashpw("123", BCrypt.gensalt()); 69 | System.out.println(hashpw); 70 | po.setCryptpasswod(hashpw); 71 | System.out.println(po.getId()); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/test/java/com/PropertyTest.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import org.junit.Test; 4 | 5 | import java.io.File; 6 | import java.io.FileInputStream; 7 | import java.io.IOException; 8 | import java.util.Properties; 9 | 10 | /** 11 | * Created by bruce.ge on 2016/11/6. 12 | */ 13 | public class PropertyTest { 14 | @Test 15 | public void testPropertis(){ 16 | File file = new File("\\env\\databaseconfig"); 17 | Properties prop = new Properties(); 18 | try { 19 | prop.load(new FileInputStream(file)); 20 | System.out.println(prop.getProperty("username")); 21 | } catch (IOException e) { 22 | e.printStackTrace(); 23 | } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/RestApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import org.assertj.core.api.Assertions; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.boot.test.web.client.TestRestTemplate; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | /** 12 | * Created by bruce.ge on 2016/10/23. 13 | */ 14 | @RunWith(SpringRunner.class) 15 | @SpringBootTest(classes = com.App.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 16 | public class RestApplicationTest { 17 | @Autowired 18 | private TestRestTemplate restTemplate; 19 | 20 | @Test 21 | public void exampleTest(){ 22 | String body = this.restTemplate.getForObject("/", String.class); 23 | Assertions.assertThat(body).isEqualTo("hello world"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/rest/FileTest.java: -------------------------------------------------------------------------------- 1 | package com.rest; 2 | 3 | import org.junit.Test; 4 | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; 5 | import org.springframework.util.FileSystemUtils; 6 | 7 | import java.io.IOException; 8 | import java.nio.file.FileSystem; 9 | import java.nio.file.Files; 10 | import java.nio.file.Paths; 11 | 12 | /** 13 | * Created by bruce.ge on 2016/11/9. 14 | */ 15 | public class FileTest { 16 | @Test 17 | public void test() throws IOException { 18 | Files.createDirectories(Paths.get("/inta/nimei")); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/com/rest/exception/ExceptionTest.java: -------------------------------------------------------------------------------- 1 | package com.rest.exception; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * Created by bruce.ge on 2017/1/4. 7 | */ 8 | public class ExceptionTest { 9 | @Test 10 | public void test() { 11 | nimei(); 12 | } 13 | 14 | 15 | public static void nimei() { 16 | System.out.println("start"); 17 | try { 18 | throw new RuntimeException("nima"); 19 | } catch (Exception e) { 20 | throw new RuntimeException(e); 21 | } finally { 22 | System.out.println("hehe"); 23 | //never use return in finally statement. 24 | return; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/com/rest/i18n/I18NSample.java: -------------------------------------------------------------------------------- 1 | package com.rest.i18n; 2 | 3 | import java.util.Locale; 4 | import java.util.ResourceBundle; 5 | 6 | /** 7 | * Created by bruce.ge on 2016/11/17. 8 | */ 9 | public class I18NSample { 10 | public static void main(String[] args) { 11 | String language; 12 | String country; 13 | if(args.length!=2){ 14 | language = new String("de"); 15 | country = new String("DE"); 16 | } else { 17 | language = new String(args[0]); 18 | country=new String(args[1]); 19 | } 20 | Locale currentLocal; 21 | ResourceBundle messages; 22 | currentLocal = new Locale(language,country); 23 | messages = ResourceBundle.getBundle("MessagesBundle",currentLocal); 24 | System.out.println(messages.getString("greetings")); 25 | System.out.println(messages.getString("inquiry")); 26 | System.out.println(messages.getString("farewell")); 27 | 28 | currentLocal = Locale.SIMPLIFIED_CHINESE; 29 | 30 | messages = ResourceBundle.getBundle("MessagesBundle",currentLocal); 31 | System.out.println(messages.getString("greetings")); 32 | System.out.println(messages.getString("inquiry")); 33 | System.out.println(messages.getString("farewell")); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/rest/jsoup/XssTest.java: -------------------------------------------------------------------------------- 1 | package com.rest.jsoup; 2 | 3 | import org.jsoup.Jsoup; 4 | import org.jsoup.safety.Whitelist; 5 | import org.junit.Test; 6 | 7 | /** 8 | * @Author bruce.ge 9 | * @Date 2017/1/20 10 | * @Description 11 | */ 12 | public class XssTest { 13 | @Test 14 | public void test(){ 15 | String clean = Jsoup.clean("", Whitelist.basic()); 16 | System.out.println(clean); 17 | 18 | 19 | String clean2 = Jsoup.clean("hello *you*", Whitelist.basic()); 20 | boolean valid = Jsoup.isValid("hello *you*", Whitelist.basic()); 21 | System.out.println(valid); 22 | System.out.println(clean2); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/com/rest/mapper/ContentMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.rest.mapper; 2 | 3 | import basic.AbstractTest; 4 | import com.rest.domain.Content; 5 | import org.junit.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * Created by bruce.ge on 2017/1/4. 12 | */ 13 | public class ContentMapperTest extends AbstractTest { 14 | @Autowired 15 | private ContentMapper contentMapper; 16 | 17 | 18 | @Test 19 | public void testAdd() { 20 | Content content = new Content(); 21 | content.setTitle("nima"); 22 | content.setSource_content("woca"); 23 | content.setHtml_content("

    wori

    "); 24 | content.setUpdatetime(new Date()); 25 | content.setAddtime(new Date()); 26 | content.setIndex_content("hehe bitch"); 27 | content.setUserId(1); 28 | content.setStatus(10); 29 | int i = contentMapper.insert(content); 30 | System.out.println(i); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/com/rest/mapper/ContentTimeMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.rest.mapper; 2 | 3 | import basic.AbstractTest; 4 | import com.rest.domain.Archives; 5 | import com.rest.domain.ContentTime; 6 | import org.junit.Test; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | 9 | import java.util.List; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Created by bruce.ge on 2016/11/7. 15 | */ 16 | public class ContentTimeMapperTest extends AbstractTest{ 17 | @Autowired 18 | private ContentTimeMapper contentTimeMapper; 19 | @Test 20 | public void insert() throws Exception { 21 | 22 | } 23 | 24 | @Test 25 | public void getDistinctYears() throws Exception { 26 | printToGson(contentTimeMapper.getDistinctYears()); 27 | } 28 | 29 | @Test 30 | public void findByYear() throws Exception { 31 | List byYear = 32 | contentTimeMapper.findByYear(2016); 33 | printToGson(byYear); 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /src/test/java/com/rest/mapper/ExecutionTimeLogDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.rest.mapper; 2 | import basic.AbstractTest; 3 | import com.rest.domain.ExecutionTimeLog; 4 | import org.junit.Test; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * Created by bruce.ge on 2017/1/8. 11 | */ 12 | public class ExecutionTimeLogDaoTest extends AbstractTest { 13 | 14 | @Autowired 15 | private ExecutionTimeLogDao executionTimeLogDao; 16 | 17 | @Test 18 | public void insert() throws Exception { 19 | ExecutionTimeLog executionTimeLog = new ExecutionTimeLog(); 20 | executionTimeLog.setClassName("com.rest.hehe"); 21 | executionTimeLog.setMethodName("getName"); 22 | executionTimeLog.setExecutionTime(12321l); 23 | executionTimeLog.setArgsValue("{cool:a,ooo:b}"); 24 | executionTimeLog.setCreateTime(new Date()); 25 | int insert = executionTimeLogDao.insert(executionTimeLog); 26 | System.out.println(insert); 27 | } 28 | 29 | @Test 30 | public void insertList() throws Exception { 31 | 32 | } 33 | 34 | @Test 35 | public void update() throws Exception { 36 | 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /src/test/java/com/rest/mapper/TagMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.rest.mapper; 2 | 3 | import basic.AbstractTest; 4 | import com.rest.domain.ContentTagRelation; 5 | import com.rest.domain.TagPo; 6 | import org.assertj.core.api.Assertions; 7 | import org.junit.After; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | 12 | import java.util.Date; 13 | import java.util.List; 14 | 15 | /** 16 | * @Author bruce.ge 17 | * @Date 2017/1/25 18 | * @Description 19 | */ 20 | 21 | public class TagMapperTest extends AbstractTest { 22 | @Autowired 23 | private TagPoDao tagPoDao; 24 | 25 | @Autowired 26 | private ContentTagRelationDao contentTagRelationDao; 27 | 28 | 29 | @Before 30 | public void setUp() { 31 | tagPoDao.delete(); 32 | contentTagRelationDao.delete(); 33 | for (int i = 0; i < 5; i++) { 34 | TagPo pojo = new TagPo(); 35 | pojo.setTagName("tag_" + i); 36 | pojo.setCreateTime(new Date()); 37 | pojo.setUpdateTime(new Date()); 38 | tagPoDao.insert(pojo); 39 | } 40 | 41 | for (int i = 0; i < 5; i++) { 42 | ContentTagRelation pojo = new ContentTagRelation(); 43 | pojo.setContentId(i); 44 | pojo.setTagId(i); 45 | pojo.setCreateTime(new Date()); 46 | pojo.setUpdateTime(new Date()); 47 | contentTagRelationDao.insert(pojo); 48 | } 49 | } 50 | 51 | 52 | @After 53 | public void tearDown() { 54 | tagPoDao.delete(); 55 | contentTagRelationDao.delete(); 56 | } 57 | 58 | @Test 59 | public void testFind() { 60 | List all = 61 | tagPoDao.findAll(); 62 | Assertions.assertThat(all.size()).isEqualTo(5); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/test/java/com/rest/markdown/MarkDownMatcherTest.java: -------------------------------------------------------------------------------- 1 | package com.rest.markdown; 2 | 3 | import org.junit.Test; 4 | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; 5 | 6 | import java.util.regex.Matcher; 7 | import java.util.regex.Pattern; 8 | 9 | /** 10 | * Created by bruce.ge on 2016/11/15. 11 | */ 12 | public class MarkDownMatcherTest { 13 | @Test 14 | public void testReplace(){ 15 | String m = "[a][b](cc)"; 16 | 17 | String m_a = "[htpp://]](www.aaa.com)"; 18 | 19 | //write the compiler of your own. check with it. 20 | 21 | Pattern pattern = Pattern.compile("\\[.*\\]\\(.*\\)"); 22 | Matcher matcher = pattern.matcher(m); 23 | String u = ""; 24 | int end =0; 25 | //先完成所有去除 26 | System.out.println(m.length()); 27 | while(matcher.find()){ 28 | int start = matcher.start(); 29 | u+=m.substring(end,start); 30 | end = matcher.end(); 31 | System.out.println("aa"+String.valueOf(start)+" "+end); 32 | } 33 | //去除了图片的效果。how to deal with better. 34 | u+=m.substring(end); 35 | System.out.println(u); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/com/rest/service/UserPOServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.rest.service; 2 | 3 | import com.App; 4 | import com.rest.mapper.UserPODao; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | /** 12 | * Created by bruce.ge on 2016/11/13. 13 | */ 14 | @RunWith(SpringRunner.class) 15 | @SpringBootTest(classes = App.class) 16 | public class UserPOServiceTest { 17 | 18 | @Autowired 19 | private UserPODao userPODao; 20 | @Test 21 | public void insert() throws Exception { 22 | 23 | } 24 | 25 | @Test 26 | public void insertList() throws Exception { 27 | 28 | } 29 | 30 | @Test 31 | public void select() throws Exception { 32 | 33 | } 34 | 35 | @Test 36 | public void update() throws Exception { 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/com/rest/utils/GuavaTest.java: -------------------------------------------------------------------------------- 1 | package com.rest.utils; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * Created by bruce.ge on 2017/1/4. 7 | */ 8 | public class GuavaTest { 9 | @Test 10 | public void test(){ 11 | // Preconditions 12 | // CharMatcher 13 | // Joiner 14 | // FluentIterable 15 | // BloomFilter default not exist or may exist. 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/rest/utils/JoinerTest.java: -------------------------------------------------------------------------------- 1 | package com.rest.utils; 2 | 3 | import com.google.common.base.Joiner; 4 | import org.junit.Test; 5 | 6 | /** 7 | * Created by bruce.ge on 2017/1/8. 8 | */ 9 | public class JoinerTest { 10 | @Test 11 | public void testJoiner(){ 12 | Object[] bb= new Object[0]; 13 | String join = Joiner.on(",").join(bb); 14 | System.out.println(join); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/rest/utils/RandomStringUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.rest.utils; 2 | 3 | import org.apache.commons.lang3.RandomStringUtils; 4 | import org.junit.Test; 5 | 6 | /** 7 | * Created by bruce.ge on 2016/11/15. 8 | */ 9 | public class RandomStringUtilsTest { 10 | @Test 11 | public void test(){ 12 | String random = RandomStringUtils.random(33, true, true); 13 | System.out.println(random); 14 | System.out.println(RandomStringUtils.random(33)); 15 | String m ="햽쬅員鄇䑓躲\uE1E9ඪ뚪❮䉘ퟏꉞ\uE5FC\uD854\uDC40봉ꨥ莪ὠᢕ\uD902\uDC42훽㚣⧚贃㋉\uE121꼷葂⥮뗱"; 16 | System.out.println(m.length()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/com/rest/utils/StringUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.rest.utils; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * Created by bruce.ge on 2016/11/16. 7 | */ 8 | public class StringUtilsTest { 9 | @Test 10 | public void test(){ 11 | System.out.println("nimei"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/com/rest/xss/AntiSamyTest.java: -------------------------------------------------------------------------------- 1 | package com.rest.xss; 2 | 3 | import org.junit.Test; 4 | import org.owasp.validator.html.*; 5 | 6 | /** 7 | * Created by bruce.ge on 2016/11/20. 8 | */ 9 | public class AntiSamyTest { 10 | @Test 11 | public void testCss() throws PolicyException, ScanException { 12 | 13 | } 14 | } 15 | --------------------------------------------------------------------------------