├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ └── bug_report.md ├── .gitignore ├── .idea └── uiDesigner.xml ├── LICENSE ├── README.md ├── pom.xml └── src ├── main ├── java │ └── springboot │ │ ├── StartApplication.java │ │ ├── client │ │ ├── HttpClient.java │ │ ├── SocketClient.java │ │ ├── codec │ │ │ ├── HttpJsonRequestEncoder.java │ │ │ └── HttpJsonResponseDecoder.java │ │ └── handler │ │ │ ├── ClientHandler.java │ │ │ └── HttpClientInitializer.java │ │ ├── config │ │ ├── HttpPortCfg.java │ │ ├── NettyServerConfig.java │ │ └── RedisConfig.java │ │ ├── constant │ │ └── WebConst.java │ │ ├── controller │ │ ├── AbstractController.java │ │ ├── GlobalExceptionHandler.java │ │ ├── admin │ │ │ ├── ArticleController.java │ │ │ ├── AttachController.java │ │ │ ├── AuthController.java │ │ │ ├── CategoryController.java │ │ │ ├── CommentController.java │ │ │ ├── IndexController.java │ │ │ ├── LinkController.java │ │ │ ├── PageController.java │ │ │ └── SettingController.java │ │ ├── helper │ │ │ └── ExceptionHelper.java │ │ └── home │ │ │ └── IndexController.java │ │ ├── dao │ │ ├── AttachVoMapper.java │ │ ├── CommentVoMapper.java │ │ ├── ContentVoMapper.java │ │ ├── LogVoMapper.java │ │ ├── MetaVoMapper.java │ │ ├── OptionVoMapper.java │ │ ├── RelationshipVoMapper.java │ │ └── UserVoMapper.java │ │ ├── dto │ │ ├── LogActions.java │ │ ├── MetaDto.java │ │ └── Types.java │ │ ├── exception │ │ └── TipException.java │ │ ├── interceptor │ │ ├── BaseInterceptor.java │ │ └── WebMvcConfig.java │ │ ├── modal │ │ ├── bo │ │ │ ├── ArchiveBo.java │ │ │ ├── BackResponseBo.java │ │ │ ├── CommentBo.java │ │ │ ├── RestResponseBo.java │ │ │ └── StaticticsBo.java │ │ ├── redisKey │ │ │ └── ContentKey.java │ │ └── vo │ │ │ ├── AttachVo.java │ │ │ ├── AttachVoExample.java │ │ │ ├── CommentVo.java │ │ │ ├── CommentVoExample.java │ │ │ ├── ContentVo.java │ │ │ ├── ContentVoExample.java │ │ │ ├── LogVo.java │ │ │ ├── LogVoExample.java │ │ │ ├── MetaVo.java │ │ │ ├── MetaVoExample.java │ │ │ ├── OptionVo.java │ │ │ ├── OptionVoExample.java │ │ │ ├── RedisModel.java │ │ │ ├── RelationshipVo.java │ │ │ ├── RelationshipVoExample.java │ │ │ ├── RelationshipVoKey.java │ │ │ ├── UserVo.java │ │ │ └── UserVoExample.java │ │ ├── scheduletask │ │ └── ScheduleTask.java │ │ ├── server │ │ ├── HttpNettyServer.java │ │ ├── codec │ │ │ ├── AbstractHttpJsonDecoder.java │ │ │ ├── AbstractHttpJsonEncoder.java │ │ │ ├── HttpJsonRequest.java │ │ │ ├── HttpJsonRequestDecoder.java │ │ │ ├── HttpJsonResponse.java │ │ │ └── HttpJsonResponseEncoder.java │ │ └── handler │ │ │ ├── HttpNettyServerInitializer.java │ │ │ └── HttpServerHandler.java │ │ ├── service │ │ ├── IAttachService.java │ │ ├── ICommentService.java │ │ ├── IContentService.java │ │ ├── ILogService.java │ │ ├── IMailService.java │ │ ├── IMetaService.java │ │ ├── IOptionService.java │ │ ├── IRelationshipService.java │ │ ├── ISiteService.java │ │ ├── IUserService.java │ │ └── impl │ │ │ ├── AttachServiceImpl.java │ │ │ ├── CommentService.java │ │ │ ├── ContentServcieImpl.java │ │ │ ├── LogServiceImpl.java │ │ │ ├── MailServiceImpl.java │ │ │ ├── MetaServiceImpl.java │ │ │ ├── OptionServiceImpl.java │ │ │ ├── RedisService.java │ │ │ ├── RelationshipServiceImpl.java │ │ │ ├── SiteServiceImpl.java │ │ │ └── UserServiceImpl.java │ │ └── util │ │ ├── AdminCommons.java │ │ ├── Commons.java │ │ ├── DateKit.java │ │ ├── GsonUtils.java │ │ ├── IpUtil.java │ │ ├── LogAspect.java │ │ ├── MapCache.java │ │ ├── MyUtils.java │ │ ├── PatternKit.java │ │ ├── PortChecker.java │ │ ├── RedisKeyUtil.java │ │ ├── Tools.java │ │ ├── UUID.java │ │ ├── ZipUtils.java │ │ └── backup │ │ ├── Backup.java │ │ ├── Column.java │ │ ├── ColumnCollection.java │ │ ├── FK.java │ │ ├── FKCollection.java │ │ ├── Table.java │ │ ├── TableCollection.java │ │ └── db │ │ ├── Column.java │ │ ├── ColumnCollection.java │ │ ├── DataTable.java │ │ └── Row.java └── resources │ ├── application-jdbc.properties │ ├── application-log.properties │ ├── application-mail.properties │ ├── application-redis.properties │ ├── application.yml │ ├── banner.txt │ ├── keystore.jks │ ├── mapper │ ├── AttachVoMapper.xml │ ├── CommentVoMapper.xml │ ├── ContentVoMapper.xml │ ├── LogVoMapper.xml │ ├── MetaVoMapper.xml │ ├── OptionVoMapper.xml │ ├── RelationshipVoMapper.xml │ └── UserVoMapper.xml │ ├── sql │ └── jantent.sql │ ├── static │ ├── admin │ │ ├── css │ │ │ └── style.min.css │ │ ├── images │ │ │ ├── attach.png │ │ │ ├── bg │ │ │ │ ├── 1.png │ │ │ │ ├── 2.png │ │ │ │ ├── 3.png │ │ │ │ ├── 4.png │ │ │ │ └── 5.png │ │ │ ├── favicon.png │ │ │ ├── loading.gif │ │ │ └── small │ │ │ │ └── bg.jpg │ │ ├── js │ │ │ ├── article.js │ │ │ ├── base.js │ │ │ ├── bootstrap.js │ │ │ ├── install.js │ │ │ └── jquery.app.js │ │ └── plugins │ │ │ ├── dropzone │ │ │ └── 4.3.0 │ │ │ │ └── min │ │ │ │ ├── basic.min.css │ │ │ │ ├── dropzone.min.css │ │ │ │ └── dropzone.min.js │ │ │ ├── jquery-multi-select │ │ │ ├── img │ │ │ │ └── switch.png │ │ │ └── jquery.quicksearch.js │ │ │ ├── jquery.steps │ │ │ └── demo │ │ │ │ └── css │ │ │ │ └── jquery.steps.css │ │ │ ├── md │ │ │ ├── css │ │ │ │ └── style.css │ │ │ ├── img │ │ │ │ └── editor.png │ │ │ └── js │ │ │ │ ├── diff.js │ │ │ │ ├── jquery.js │ │ │ │ ├── jquery.scrollto.js │ │ │ │ ├── md.js │ │ │ │ ├── pagedown-extra.js │ │ │ │ └── pagedown.js │ │ │ ├── mditor │ │ │ ├── css │ │ │ │ ├── mditor.css │ │ │ │ ├── mditor.css.map │ │ │ │ └── mditor.min.css │ │ │ ├── font │ │ │ │ ├── 674f50d287a8c48dc19ba404d20fe713.eot │ │ │ │ ├── 912ec66d7572ff821749319396470bde.svg │ │ │ │ ├── a48ac41620cd818c5020d0f4302489ff.ttf │ │ │ │ ├── af7ae505a9eed503f8b8e6982036873e.woff2 │ │ │ │ ├── b06871f281fee6b241d60582ae9369b9.ttf │ │ │ │ └── fee66e712a8a08eef5805a46892932ad.woff │ │ │ └── js │ │ │ │ ├── mditor.js │ │ │ │ ├── mditor.js.map │ │ │ │ ├── mditor.min.js │ │ │ │ └── mditor.min.js.map │ │ │ ├── multi-select │ │ │ └── 0.9.12 │ │ │ │ ├── css │ │ │ │ └── multi-select.min.css │ │ │ │ ├── img │ │ │ │ └── switch.png │ │ │ │ └── js │ │ │ │ └── jquery.multi-select.min.js │ │ │ ├── select2.dist.css │ │ │ ├── select2-bootstrap.css │ │ │ ├── select2-spinner.gif │ │ │ ├── select2.css │ │ │ ├── select2.png │ │ │ └── select2x2.png │ │ │ ├── select2 │ │ │ ├── 3.4.8 │ │ │ │ ├── select2-bootstrap.min.css │ │ │ │ ├── select2-spinner.gif │ │ │ │ ├── select2.min.css │ │ │ │ ├── select2.min.js │ │ │ │ ├── select2.png │ │ │ │ ├── select2_locale_zh-CN.min.js │ │ │ │ └── select2x2.png │ │ │ └── dist │ │ │ │ └── css │ │ │ │ ├── select2-bootstrap.css │ │ │ │ ├── select2-spinner.gif │ │ │ │ ├── select2.css │ │ │ │ ├── select2.png │ │ │ │ └── select2x2.png │ │ │ ├── tagsinput │ │ │ ├── jquery.tagsinput.css │ │ │ └── jquery.tagsinput.min.js │ │ │ ├── to-markdown │ │ │ └── 3.1.0 │ │ │ │ └── to-markdown.min.js │ │ │ └── toggles │ │ │ └── toggles.css │ ├── jantent │ │ └── assets │ │ │ ├── css │ │ │ ├── admin.css │ │ │ ├── amazeui.css │ │ │ ├── amazeui.flat.css │ │ │ ├── amazeui.flat.min.css │ │ │ ├── amazeui.min.css │ │ │ └── app.css │ │ │ ├── fonts │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ └── fontawesome-webfont.woff2 │ │ │ ├── img │ │ │ ├── f10.jpg │ │ │ ├── f14.jpg │ │ │ ├── f15.jpg │ │ │ └── f161.jpg │ │ │ └── js │ │ │ ├── amazeui.js │ │ │ └── amazeui.min.js │ └── user │ │ ├── css │ │ └── style.min.css │ │ └── img │ │ ├── apple-touch-icon.png │ │ ├── bg-ico.png │ │ ├── logo.png │ │ └── rand │ │ ├── 1.jpg │ │ ├── 10.jpg │ │ ├── 11.jpg │ │ ├── 12.jpg │ │ ├── 13.jpg │ │ ├── 14.jpg │ │ ├── 15.jpg │ │ ├── 16.jpg │ │ ├── 17.jpg │ │ ├── 18.jpg │ │ ├── 19.jpg │ │ ├── 2.jpg │ │ ├── 20.jpg │ │ ├── 21.jpg │ │ ├── 22.jpg │ │ ├── 23.jpg │ │ ├── 24.jpg │ │ ├── 25.jpg │ │ ├── 3.jpg │ │ ├── 4.jpg │ │ ├── 5.jpg │ │ ├── 6.jpg │ │ ├── 7.jpg │ │ ├── 8.jpg │ │ └── 9.jpg │ └── templates │ ├── admin │ ├── article_edit.html │ ├── article_list.html │ ├── attach.html │ ├── category.html │ ├── comment_list.html │ ├── footer.html │ ├── header.html │ ├── index.html │ ├── links.html │ ├── login.html │ ├── page_edit.html │ ├── page_list.html │ ├── profile.html │ └── setting.html │ ├── comm │ ├── error_404.html │ ├── error_500.html │ ├── ipban.html │ ├── macros.html │ └── tale_comment.html │ └── themes │ └── jantent │ ├── archives.html │ ├── comments.html │ ├── footer.html │ ├── header.html │ ├── index.html │ ├── links.html │ ├── page-category.html │ ├── page.html │ └── post.html └── test └── java └── springboot ├── scheduletask └── ScheduleTaskTest.java └── service └── impl ├── ContentServcieImplTest.java ├── OptionServiceImplTest.java └── RedisServiceTest.java /.gitattributes: -------------------------------------------------------------------------------- 1 | *.css linguist-language=java 2 | *.less linguist-language=java 3 | *.js linguist-language=java 4 | *.html linguist-language=java -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. iOS] 25 | - Browser [e.g. chrome, safari] 26 | - Version [e.g. 22] 27 | 28 | **Smartphone (please complete the following information):** 29 | - Device: [e.g. iPhone6] 30 | - OS: [e.g. iOS8.1] 31 | - Browser [e.g. stock browser, safari] 32 | - Version [e.g. 22] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Java template 3 | # Compiled class file 4 | *.class 5 | 6 | # Log file 7 | *.log 8 | 9 | # BlueJ files 10 | *.ctxt 11 | 12 | # Mobile Tools for Java (J2ME) 13 | .mtj.tmp/ 14 | 15 | # Package Files # 16 | *.jar 17 | *.war 18 | *.nar 19 | *.ear 20 | *.zip 21 | *.tar.gz 22 | *.rar 23 | 24 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 25 | hs_err_pid* 26 | .idea 27 | *.iml 28 | 29 | 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 JayTange 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/springboot/client/HttpClient.java: -------------------------------------------------------------------------------- 1 | package springboot.client; 2 | 3 | import io.netty.bootstrap.Bootstrap; 4 | import io.netty.channel.ChannelFuture; 5 | import io.netty.channel.ChannelOption; 6 | import io.netty.channel.EventLoopGroup; 7 | import io.netty.channel.nio.NioEventLoopGroup; 8 | import io.netty.channel.socket.nio.NioSocketChannel; 9 | import springboot.client.handler.HttpClientInitializer; 10 | 11 | import java.net.InetSocketAddress; 12 | 13 | public class HttpClient { 14 | public void start() throws Exception{ 15 | EventLoopGroup group = new NioEventLoopGroup(); 16 | try { 17 | Bootstrap bootstrap = new Bootstrap(); 18 | bootstrap.group(group) 19 | .channel(NioSocketChannel.class) 20 | .option(ChannelOption.TCP_NODELAY, true) 21 | .handler(new HttpClientInitializer()); 22 | 23 | // 发起异步连接 24 | ChannelFuture future = bootstrap.connect(new InetSocketAddress("127.0.0.1", 3560)); 25 | // 当客户端链路关闭 26 | future.channel().closeFuture().sync(); 27 | }finally { 28 | // 优雅退出,释放NIO线程组 29 | group.shutdownGracefully(); 30 | } 31 | } 32 | 33 | public static void main(String args[])throws Exception{ 34 | new HttpClient().start(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/springboot/client/SocketClient.java: -------------------------------------------------------------------------------- 1 | package springboot.client; 2 | 3 | import java.io.*; 4 | import java.net.Socket; 5 | 6 | public class SocketClient { 7 | public static void start() throws Exception { 8 | Socket socket = new Socket("127.0.0.1", 3480); 9 | // 获取一个输出流,向服务端发送消息 10 | OutputStream outputStream = socket.getOutputStream(); 11 | // 将输出流包装成打印流 12 | PrintWriter printWriter = new PrintWriter(outputStream); 13 | printWriter.print("hello"); 14 | printWriter.flush(); 15 | socket.shutdownOutput(); 16 | 17 | // 获取一个输入流,接受服务端的消息 18 | InputStream inputStream = socket.getInputStream(); 19 | // 包装成字符流 提高效率 20 | InputStreamReader inputStreamReader = new InputStreamReader(inputStream); 21 | // 增加缓冲区 22 | BufferedReader bufferedReader = new BufferedReader(inputStreamReader); 23 | String acceptString; 24 | while ((acceptString = bufferedReader.readLine()) != null) { 25 | System.out.println("客户端接受到返回消息" + acceptString); 26 | } 27 | //关闭相对应的资源 28 | bufferedReader.close(); 29 | inputStream.close(); 30 | printWriter.close(); 31 | outputStream.close(); 32 | socket.close(); 33 | } 34 | 35 | public static void main(String args[]) throws Exception { 36 | start(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/springboot/client/codec/HttpJsonRequestEncoder.java: -------------------------------------------------------------------------------- 1 | package springboot.client.codec; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.channel.ChannelHandlerContext; 5 | import io.netty.handler.codec.http.*; 6 | import springboot.server.codec.AbstractHttpJsonEncoder; 7 | import springboot.server.codec.HttpJsonRequest; 8 | 9 | import java.net.InetAddress; 10 | import java.util.List; 11 | 12 | /** 13 | * @author tangj 14 | * @date 2018/4/15 21:46 15 | */ 16 | public class HttpJsonRequestEncoder extends AbstractHttpJsonEncoder { 17 | 18 | @Override 19 | protected void encode(ChannelHandlerContext ctx, HttpJsonRequest msg, List out) throws Exception { 20 | //(1)调用父类的encode0,将业务需要发送的对象转换为Json 21 | ByteBuf body = jsonEncode(ctx, msg.getBody()); 22 | //(2) 如果业务自定义了HTTP消息头,则使用业务的消息头,否则在这里构造HTTP消息头 23 | // 这里使用硬编码的方式来写消息头,实际中可以写入配置文件 24 | FullHttpRequest request = msg.getRequest(); 25 | if (request == null) { 26 | request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, 27 | HttpMethod.GET, "/do", body); 28 | HttpHeaders headers = request.headers(); 29 | headers.set(HttpHeaderNames.HOST, InetAddress.getLocalHost() 30 | .getHostAddress()); 31 | headers.set(HttpHeaderNames.CONNECTION, HttpHeaders.Values.CLOSE); 32 | headers.set(HttpHeaderNames.ACCEPT_ENCODING, 33 | HttpHeaderValues.GZIP.toString() + ',' 34 | + HttpHeaderValues.DEFLATE.toString()); 35 | headers.set(HttpHeaderNames.ACCEPT_CHARSET, 36 | "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); 37 | headers.set(HttpHeaderNames.ACCEPT_LANGUAGE, "zh"); 38 | headers.set(HttpHeaderNames.USER_AGENT, 39 | "Netty json Http Client side"); 40 | headers.set(HttpHeaderNames.ACCEPT, 41 | "text/html,application/json;q=0.9,*/*;q=0.8"); 42 | } 43 | HttpUtil.setContentLength(request, body.readableBytes()); 44 | // (3) 编码后的对象 45 | out.add(request); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/springboot/client/codec/HttpJsonResponseDecoder.java: -------------------------------------------------------------------------------- 1 | package springboot.client.codec; 2 | 3 | import io.netty.channel.ChannelHandlerContext; 4 | import io.netty.handler.codec.http.FullHttpResponse; 5 | import springboot.server.codec.AbstractHttpJsonDecoder; 6 | import springboot.server.codec.HttpJsonResponse; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author tangj 12 | * @date 2018/4/15 21:48 13 | */ 14 | public class HttpJsonResponseDecoder extends AbstractHttpJsonDecoder { 15 | 16 | public HttpJsonResponseDecoder(Class clazz) { 17 | super(clazz); 18 | } 19 | 20 | public HttpJsonResponseDecoder(Class clazz, boolean isPrint) { 21 | super(clazz, false); 22 | } 23 | 24 | @Override 25 | protected void decode(ChannelHandlerContext ctx, FullHttpResponse msg, List out) throws Exception { 26 | out.add(new HttpJsonResponse(msg,jsonDecode(ctx,msg.content()))); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/springboot/client/handler/ClientHandler.java: -------------------------------------------------------------------------------- 1 | package springboot.client.handler; 2 | 3 | import io.netty.channel.ChannelHandlerContext; 4 | import io.netty.channel.ChannelInboundHandlerAdapter; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import springboot.modal.vo.UserVo; 8 | import springboot.server.codec.HttpJsonRequest; 9 | 10 | public class ClientHandler extends ChannelInboundHandlerAdapter{ 11 | 12 | private static final Logger logger = LoggerFactory.getLogger(ClientHandler.class); 13 | 14 | @Override 15 | public void channelActive(ChannelHandlerContext ctx) throws Exception { 16 | UserVo userVo = new UserVo(); 17 | userVo.setPassword("23456"); 18 | logger.info("发送的User为"+userVo.toString()); 19 | HttpJsonRequest request = new HttpJsonRequest(null,userVo); 20 | ctx.writeAndFlush(request); 21 | } 22 | 23 | @Override 24 | public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { 25 | logger.info(msg.getClass().getName()); 26 | logger.info("接受到的User对象为:"+msg.toString()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/springboot/client/handler/HttpClientInitializer.java: -------------------------------------------------------------------------------- 1 | package springboot.client.handler; 2 | 3 | import io.netty.channel.ChannelInitializer; 4 | import io.netty.channel.socket.SocketChannel; 5 | import io.netty.handler.codec.http.HttpObjectAggregator; 6 | import io.netty.handler.codec.http.HttpRequestEncoder; 7 | import io.netty.handler.codec.http.HttpResponseDecoder; 8 | import springboot.client.codec.HttpJsonRequestEncoder; 9 | import springboot.client.codec.HttpJsonResponseDecoder; 10 | import springboot.client.handler.ClientHandler; 11 | import springboot.modal.vo.UserVo; 12 | 13 | 14 | public class HttpClientInitializer extends ChannelInitializer{ 15 | @Override 16 | protected void initChannel(SocketChannel ch) throws Exception { 17 | ch.pipeline().addLast("http-decoder",new HttpResponseDecoder()); 18 | ch.pipeline().addLast("http-aggregator",new HttpObjectAggregator(65536)); 19 | ch.pipeline().addLast("json-decoder",new HttpJsonResponseDecoder(UserVo.class)); 20 | 21 | ch.pipeline().addLast("http-encoder",new HttpRequestEncoder()); 22 | ch.pipeline().addLast("json-encoder",new HttpJsonRequestEncoder()); 23 | ch.pipeline().addLast("handler",new ClientHandler()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/springboot/config/HttpPortCfg.java: -------------------------------------------------------------------------------- 1 | package springboot.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "httpportcfg") 8 | public class HttpPortCfg { 9 | private String http_port; 10 | 11 | private String https_port; 12 | 13 | public String getHttp_port() { 14 | return http_port; 15 | } 16 | 17 | public void setHttp_port(String http_port) { 18 | this.http_port = http_port; 19 | } 20 | 21 | public String getHttps_port() { 22 | return https_port; 23 | } 24 | 25 | public void setHttps_port(String https_port) { 26 | this.https_port = https_port; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/springboot/config/NettyServerConfig.java: -------------------------------------------------------------------------------- 1 | package springboot.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | /** 7 | * @author tangj 8 | * @date 2018/4/12 22:36 9 | */ 10 | @Component 11 | @ConfigurationProperties(prefix = "nettyserver") 12 | public class NettyServerConfig { 13 | private String serviceIp; 14 | private String servicePort; 15 | 16 | public String getServiceIp() { 17 | return serviceIp; 18 | } 19 | 20 | public void setServiceIp(String serviceIp) { 21 | this.serviceIp = serviceIp; 22 | } 23 | 24 | public String getServicePort() { 25 | return servicePort; 26 | } 27 | 28 | public void setServicePort(String servicePort) { 29 | this.servicePort = servicePort; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/springboot/constant/WebConst.java: -------------------------------------------------------------------------------- 1 | package springboot.constant; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import java.util.HashMap; 6 | import java.util.HashSet; 7 | import java.util.Map; 8 | import java.util.Set; 9 | 10 | /** 11 | * web常量 12 | * 13 | * @author tangj 14 | */ 15 | @Component 16 | public class WebConst { 17 | public static Map initConfig = new HashMap<>(); 18 | 19 | 20 | public static String LOGIN_SESSION_KEY = "login_user"; 21 | 22 | public static final String USER_IN_COOKIE = "S_L_ID"; 23 | 24 | /** 25 | * aes加密加盐 26 | */ 27 | public static String AES_SALT = "0123456789abcdef"; 28 | 29 | /** 30 | * 最大获取文章条数 31 | */ 32 | public static final int MAX_POSTS = 9999; 33 | 34 | /** 35 | * 最大页码 36 | */ 37 | public static final int MAX_PAGE = 100; 38 | 39 | /** 40 | * 文章最多可以输入的文字数 41 | */ 42 | public static final int MAX_TEXT_COUNT = 200000; 43 | 44 | /** 45 | * 文章标题最多可以输入的文字个数 46 | */ 47 | public static final int MAX_TITLE_COUNT = 200; 48 | 49 | /** 50 | * 点击次数超过多少更新到数据库 51 | */ 52 | public static final int HIT_EXCEED = 10; 53 | 54 | /** 55 | * 上传文件最大1M 56 | */ 57 | public static Integer MAX_FILE_SIZE = 1048576; 58 | /** 59 | * 首页缓存rediskey 60 | */ 61 | public static final String INDEX_PAGE_KEY = "indexPageHtml"; 62 | 63 | /** 64 | * 要过滤的ip列表 65 | */ 66 | public static final Set BLOCK_IPS = new HashSet<>(16); 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/springboot/controller/AbstractController.java: -------------------------------------------------------------------------------- 1 | package springboot.controller; 2 | 3 | import springboot.modal.vo.UserVo; 4 | import springboot.util.MapCache; 5 | import springboot.util.MyUtils; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | /** 10 | * 抽象类controller 11 | * 用于统一渲染页面url,页面名称,获取session中的用户 12 | * @author tangj 13 | * @date 2018/1/21 11:25 14 | */ 15 | public abstract class AbstractController { 16 | public static String THEME = "themes/jantent"; 17 | 18 | protected MapCache cache = MapCache.single(); 19 | 20 | /** 21 | * 主页的页面主题 22 | * 23 | * @param viewName 24 | * @return 25 | */ 26 | public String render(String viewName) { 27 | return THEME + "/" + viewName; 28 | } 29 | 30 | public AbstractController title(HttpServletRequest request, String title) { 31 | request.setAttribute("title", title); 32 | return this; 33 | } 34 | 35 | public AbstractController keywords(HttpServletRequest request, String keywords) { 36 | request.setAttribute("keywords", keywords); 37 | return this; 38 | } 39 | 40 | public UserVo user(HttpServletRequest request){ 41 | return MyUtils.getLoginUser(request); 42 | } 43 | 44 | public Integer getUid(HttpServletRequest request){ 45 | return this.user(request).getUid(); 46 | } 47 | 48 | public String render_404() { 49 | return "comm/error_404"; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/springboot/controller/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package springboot.controller; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.web.bind.annotation.ControllerAdvice; 6 | import org.springframework.web.bind.annotation.ExceptionHandler; 7 | import springboot.exception.TipException; 8 | 9 | @ControllerAdvice 10 | public class GlobalExceptionHandler { 11 | 12 | private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class); 13 | 14 | @ExceptionHandler(value = TipException.class) 15 | public String tipException(Exception e){ 16 | logger.error("find exception:e+{}",e.getMessage()); 17 | return "comm/error_500"; 18 | } 19 | 20 | @ExceptionHandler(value = Exception.class) 21 | public String exceptionHandler(Exception e){ 22 | logger.error("find exception:e+{}",e.getMessage()); 23 | return "comm/error_404"; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/springboot/controller/admin/AuthController.java: -------------------------------------------------------------------------------- 1 | package springboot.controller.admin; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.transaction.annotation.Transactional; 7 | import org.springframework.web.bind.annotation.*; 8 | import springboot.constant.WebConst; 9 | import springboot.controller.AbstractController; 10 | import springboot.controller.helper.ExceptionHelper; 11 | import springboot.dto.LogActions; 12 | import springboot.exception.TipException; 13 | import springboot.modal.bo.RestResponseBo; 14 | import springboot.modal.vo.UserVo; 15 | import springboot.service.ILogService; 16 | import springboot.service.IUserService; 17 | import springboot.util.Commons; 18 | import springboot.util.MyUtils; 19 | 20 | import javax.annotation.Resource; 21 | import javax.servlet.http.Cookie; 22 | import javax.servlet.http.HttpServletRequest; 23 | import javax.servlet.http.HttpServletResponse; 24 | import javax.servlet.http.HttpSession; 25 | import java.io.IOException; 26 | 27 | /** 28 | * 登录控制 29 | * 30 | * @author tangj 31 | * @date 2018/1/21 14:07 32 | */ 33 | @Controller 34 | @RequestMapping("/admin") 35 | @Transactional(rollbackFor = TipException.class) 36 | public class AuthController extends AbstractController { 37 | private static final Logger logger = LoggerFactory.getLogger(AuthController.class); 38 | 39 | @Resource 40 | private IUserService userService; 41 | 42 | @Resource 43 | private ILogService logService; 44 | 45 | @GetMapping(value = "/login") 46 | public String login() { 47 | return "admin/login"; 48 | } 49 | 50 | @PostMapping(value = "login") 51 | @ResponseBody 52 | public RestResponseBo doLogin(@RequestParam String username, 53 | @RequestParam String password, 54 | HttpServletRequest request, 55 | HttpServletResponse response) { 56 | Integer error_count = cache.get("login_error_count"); 57 | try { 58 | UserVo userVo = userService.login(username, password); 59 | request.getSession().setAttribute(WebConst.LOGIN_SESSION_KEY, userVo); 60 | // 设置12小时的cookie 61 | MyUtils.setCookie(response, userVo.getUid()); 62 | logService.insertLog(LogActions.LOGIN.getAction(), null, request.getRemoteAddr(), userVo.getUid()); 63 | } catch (Exception e) { 64 | error_count = null == error_count ? 1 : error_count + 1; 65 | if (error_count > 3) { 66 | return RestResponseBo.fail("您输入密码已经错误超过3次,请10分钟后尝试"); 67 | } 68 | cache.set("login_error_count", error_count, 10 * 60); 69 | String msg = "登录失败"; 70 | return ExceptionHelper.handlerException(logger, msg, e); 71 | } 72 | return RestResponseBo.ok(); 73 | } 74 | 75 | @RequestMapping("/logout") 76 | public void logout(HttpSession session, HttpServletResponse response, HttpServletRequest request) { 77 | session.removeAttribute(WebConst.LOGIN_SESSION_KEY); 78 | Cookie cookie = new Cookie(WebConst.USER_IN_COOKIE, ""); 79 | cookie.setMaxAge(0); 80 | response.addCookie(cookie); 81 | try { 82 | response.sendRedirect(Commons.site_login()); 83 | } catch (IOException e) { 84 | e.printStackTrace(); 85 | logger.error("注销失败", e); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/springboot/controller/admin/CategoryController.java: -------------------------------------------------------------------------------- 1 | package springboot.controller.admin; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.transaction.annotation.Transactional; 7 | import org.springframework.web.bind.annotation.*; 8 | import springboot.constant.WebConst; 9 | import springboot.controller.AbstractController; 10 | import springboot.controller.helper.ExceptionHelper; 11 | import springboot.dto.MetaDto; 12 | import springboot.dto.Types; 13 | import springboot.exception.TipException; 14 | import springboot.modal.bo.RestResponseBo; 15 | import springboot.service.IMetaService; 16 | 17 | import javax.annotation.Resource; 18 | import javax.servlet.http.HttpServletRequest; 19 | import java.util.List; 20 | 21 | /** 22 | * 分类标签管理 23 | * 24 | * @author tangj 25 | * @date 2018/1/31 22:56 26 | */ 27 | @Controller 28 | @RequestMapping("admin/category") 29 | public class CategoryController extends AbstractController { 30 | 31 | private static final Logger logger = LoggerFactory.getLogger(CategoryController.class); 32 | 33 | @Resource 34 | private IMetaService metaService; 35 | 36 | @GetMapping(value = "") 37 | public String index(HttpServletRequest request) { 38 | List categories = metaService.getMetaList(Types.CATEGORY.getType(), null, WebConst.MAX_POSTS); 39 | List tags = metaService.getMetaList(Types.TAG.getType(), null, WebConst.MAX_POSTS); 40 | request.setAttribute("categories", categories); 41 | request.setAttribute("tags", tags); 42 | return "admin/category"; 43 | } 44 | 45 | @PostMapping(value = "save") 46 | @ResponseBody 47 | @Transactional(rollbackFor = TipException.class) 48 | public RestResponseBo saveCategory(@RequestParam String cname, @RequestParam Integer mid) { 49 | try { 50 | metaService.saveMeta(Types.CATEGORY.getType(), cname, mid); 51 | } catch (Exception e) { 52 | String msg = "分类保存失败"; 53 | return ExceptionHelper.handlerException(logger, msg, e); 54 | } 55 | return RestResponseBo.ok(); 56 | } 57 | 58 | @RequestMapping(value = "delete") 59 | @ResponseBody 60 | @Transactional(rollbackFor = TipException.class) 61 | public RestResponseBo delete(@RequestParam int mid) { 62 | try { 63 | metaService.delete(mid); 64 | } catch (Exception e) { 65 | String msg = "删除失败"; 66 | return ExceptionHelper.handlerException(logger, msg, e); 67 | } 68 | return RestResponseBo.ok(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/springboot/controller/admin/LinkController.java: -------------------------------------------------------------------------------- 1 | package springboot.controller.admin; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.transaction.annotation.Transactional; 7 | import org.springframework.web.bind.annotation.*; 8 | import springboot.controller.AbstractController; 9 | import springboot.controller.helper.ExceptionHelper; 10 | import springboot.dto.Types; 11 | import springboot.exception.TipException; 12 | import springboot.modal.bo.RestResponseBo; 13 | import springboot.modal.vo.MetaVo; 14 | import springboot.service.IMetaService; 15 | 16 | import javax.annotation.Resource; 17 | import javax.servlet.http.HttpServletRequest; 18 | import java.util.List; 19 | 20 | /** 21 | * @author tangj 22 | * @date 2018/2/1 21:32 23 | */ 24 | @Controller 25 | @RequestMapping("admin/links") 26 | public class LinkController extends AbstractController { 27 | private static final Logger logger = LoggerFactory.getLogger(LinkController.class); 28 | 29 | @Resource 30 | private IMetaService metaService; 31 | 32 | @GetMapping(value = "") 33 | public String index(HttpServletRequest request) { 34 | List metas = metaService.getMetas(Types.LINK.getType()); 35 | request.setAttribute("links", metas); 36 | return "admin/links"; 37 | 38 | } 39 | 40 | @PostMapping(value = "save") 41 | @ResponseBody 42 | @Transactional(rollbackFor = TipException.class) 43 | public RestResponseBo saveLink(@RequestParam String title, @RequestParam String url, 44 | @RequestParam String logo, @RequestParam Integer mid, 45 | @RequestParam(value = "sort", defaultValue = "0") int sort) { 46 | try { 47 | MetaVo metas = new MetaVo(); 48 | metas.setName(title); 49 | metas.setSlug(url); 50 | metas.setDescription(logo); 51 | metas.setSort(sort); 52 | metas.setType(Types.LINK.getType()); 53 | if (null != mid) { 54 | metas.setMid(mid); 55 | metaService.update(metas); 56 | } else { 57 | metaService.saveMeta(metas); 58 | } 59 | } catch (Exception e) { 60 | String msg = "友链保存失败"; 61 | return ExceptionHelper.handlerException(logger, msg, e); 62 | } 63 | return RestResponseBo.ok(); 64 | } 65 | 66 | @RequestMapping(value = "delete") 67 | @ResponseBody 68 | @Transactional(rollbackFor = TipException.class) 69 | public RestResponseBo delete(@RequestParam int mid) { 70 | try { 71 | metaService.delete(mid); 72 | } catch (Exception e) { 73 | String msg = "友链删除失败"; 74 | return ExceptionHelper.handlerException(logger, msg, e); 75 | } 76 | return RestResponseBo.ok(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/springboot/controller/helper/ExceptionHelper.java: -------------------------------------------------------------------------------- 1 | package springboot.controller.helper; 2 | 3 | import org.slf4j.Logger; 4 | import springboot.exception.TipException; 5 | import springboot.modal.bo.RestResponseBo; 6 | 7 | /** 8 | * @author janti 9 | */ 10 | public class ExceptionHelper { 11 | /** 12 | * 统一处理异常 13 | * 14 | * @param logger 15 | * @param msg 16 | * @param e 17 | * @return 18 | */ 19 | public static RestResponseBo handlerException(Logger logger, String msg, Exception e) { 20 | if (e instanceof TipException) { 21 | msg = e.getMessage(); 22 | } else { 23 | logger.error(msg, e); 24 | } 25 | return RestResponseBo.fail(msg); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/springboot/dao/AttachVoMapper.java: -------------------------------------------------------------------------------- 1 | package springboot.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.springframework.stereotype.Component; 5 | import springboot.modal.vo.AttachVo; 6 | import springboot.modal.vo.AttachVoExample; 7 | 8 | import java.util.List; 9 | 10 | @Component 11 | public interface AttachVoMapper { 12 | long countByExample(AttachVoExample example); 13 | 14 | int deleteByExample(AttachVoExample example); 15 | 16 | int deleteByPrimaryKey(Integer id); 17 | 18 | int insert(AttachVo record); 19 | 20 | int insertSelective(AttachVo record); 21 | 22 | List selectByExample(AttachVoExample example); 23 | 24 | AttachVo selectByPrimaryKey(Integer id); 25 | 26 | int updateByExampleSelective(@Param("record") AttachVo record, @Param("example") AttachVoExample example); 27 | 28 | int updateByExample(@Param("record") AttachVo record, @Param("example") AttachVoExample example); 29 | 30 | int updateByPrimaryKeySelective(AttachVo record); 31 | 32 | int updateByPrimaryKey(AttachVo record); 33 | } -------------------------------------------------------------------------------- /src/main/java/springboot/dao/CommentVoMapper.java: -------------------------------------------------------------------------------- 1 | package springboot.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.springframework.stereotype.Component; 5 | import springboot.modal.vo.CommentVo; 6 | import springboot.modal.vo.CommentVoExample; 7 | 8 | import java.util.List; 9 | 10 | @Component 11 | public interface CommentVoMapper { 12 | long countByExample(CommentVoExample example); 13 | 14 | int deleteByExample(CommentVoExample example); 15 | 16 | int deleteByPrimaryKey(Integer coid); 17 | 18 | int insert(CommentVo record); 19 | 20 | int insertSelective(CommentVo record); 21 | 22 | List selectByExampleWithBLOBs(CommentVoExample example); 23 | 24 | List selectByExample(CommentVoExample example); 25 | 26 | CommentVo selectByPrimaryKey(Integer coid); 27 | 28 | int updateByExampleSelective(@Param("record") CommentVo record, @Param("example") CommentVoExample example); 29 | 30 | int updateByExampleWithBLOBs(@Param("record") CommentVo record, @Param("example") CommentVoExample example); 31 | 32 | int updateByExample(@Param("record") CommentVo record, @Param("example") CommentVoExample example); 33 | 34 | int updateByPrimaryKeySelective(CommentVo record); 35 | 36 | int updateByPrimaryKeyWithBLOBs(CommentVo record); 37 | 38 | int updateByPrimaryKey(CommentVo record); 39 | } -------------------------------------------------------------------------------- /src/main/java/springboot/dao/ContentVoMapper.java: -------------------------------------------------------------------------------- 1 | package springboot.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.springframework.stereotype.Component; 5 | import springboot.modal.bo.ArchiveBo; 6 | import springboot.modal.vo.ContentVo; 7 | import springboot.modal.vo.ContentVoExample; 8 | 9 | import java.util.List; 10 | 11 | @Component 12 | public interface ContentVoMapper { 13 | long countByExample(ContentVoExample example); 14 | 15 | int deleteByExample(ContentVoExample example); 16 | 17 | int deleteByPrimaryKey(Integer cid); 18 | 19 | int insert(ContentVo record); 20 | 21 | int insertSelective(ContentVo record); 22 | 23 | List selectByExampleWithBLOBs(ContentVoExample example); 24 | 25 | List selectByExample(ContentVoExample example); 26 | 27 | ContentVo selectByPrimaryKey(Integer cid); 28 | 29 | int updateByExampleSelective(@Param("record") ContentVo record, @Param("example") ContentVoExample example); 30 | 31 | int updateByExampleWithBLOBs(@Param("record") ContentVo record, @Param("example") ContentVoExample example); 32 | 33 | int updateByExample(@Param("record") ContentVo record, @Param("example") ContentVoExample example); 34 | 35 | int updateByPrimaryKeySelective(ContentVo record); 36 | 37 | int updateByPrimaryKeyWithBLOBs(ContentVo record); 38 | 39 | int updateByPrimaryKey(ContentVo record); 40 | 41 | List findReturnArchiveBo(); 42 | 43 | List findByCatalog(Integer mid); 44 | } -------------------------------------------------------------------------------- /src/main/java/springboot/dao/LogVoMapper.java: -------------------------------------------------------------------------------- 1 | package springboot.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.springframework.stereotype.Component; 5 | import springboot.modal.vo.LogVo; 6 | import springboot.modal.vo.LogVoExample; 7 | 8 | import java.util.List; 9 | 10 | @Component 11 | public interface LogVoMapper { 12 | long countByExample(LogVoExample example); 13 | 14 | int deleteByExample(LogVoExample example); 15 | 16 | int deleteByPrimaryKey(Integer id); 17 | 18 | int insert(LogVo record); 19 | 20 | int insertSelective(LogVo record); 21 | 22 | List selectByExample(LogVoExample example); 23 | 24 | LogVo selectByPrimaryKey(Integer id); 25 | 26 | int updateByExampleSelective(@Param("record") LogVo record, @Param("example") LogVoExample example); 27 | 28 | int updateByExample(@Param("record") LogVo record, @Param("example") LogVoExample example); 29 | 30 | int updateByPrimaryKeySelective(LogVo record); 31 | 32 | int updateByPrimaryKey(LogVo record); 33 | } -------------------------------------------------------------------------------- /src/main/java/springboot/dao/MetaVoMapper.java: -------------------------------------------------------------------------------- 1 | package springboot.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.springframework.stereotype.Component; 5 | import springboot.dto.MetaDto; 6 | import springboot.modal.vo.MetaVo; 7 | import springboot.modal.vo.MetaVoExample; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | @Component 13 | public interface MetaVoMapper { 14 | long countByExample(MetaVoExample example); 15 | 16 | int deleteByExample(MetaVoExample example); 17 | 18 | int deleteByPrimaryKey(Integer mid); 19 | 20 | int insert(MetaVo record); 21 | 22 | int insertSelective(MetaVo record); 23 | 24 | List selectByExample(MetaVoExample example); 25 | 26 | MetaVo selectByPrimaryKey(Integer mid); 27 | 28 | int updateByExampleSelective(@Param("record") MetaVo record, @Param("example") MetaVoExample example); 29 | 30 | int updateByExample(@Param("record") MetaVo record, @Param("example") MetaVoExample example); 31 | 32 | int updateByPrimaryKeySelective(MetaVo record); 33 | 34 | int updateByPrimaryKey(MetaVo record); 35 | 36 | List selectFromSql(Map paraMap); 37 | 38 | MetaDto selectDtoByNameAndType(@Param("name") String name, @Param("type") String type); 39 | 40 | Integer countWithSql(Integer mid); 41 | } -------------------------------------------------------------------------------- /src/main/java/springboot/dao/OptionVoMapper.java: -------------------------------------------------------------------------------- 1 | package springboot.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.springframework.stereotype.Component; 5 | import springboot.modal.vo.OptionVo; 6 | import springboot.modal.vo.OptionVoExample; 7 | 8 | import java.util.List; 9 | 10 | @Component 11 | public interface OptionVoMapper { 12 | long countByExample(OptionVoExample example); 13 | 14 | int deleteByExample(OptionVoExample example); 15 | 16 | int deleteByPrimaryKey(String name); 17 | 18 | int insert(OptionVo record); 19 | 20 | int insertSelective(OptionVo record); 21 | 22 | List selectByExample(OptionVoExample example); 23 | 24 | OptionVo selectByPrimaryKey(String name); 25 | 26 | int updateByExampleSelective(@Param("record") OptionVo record, @Param("example") OptionVoExample example); 27 | 28 | int updateByExample(@Param("record") OptionVo record, @Param("example") OptionVoExample example); 29 | 30 | int updateByPrimaryKeySelective(OptionVo record); 31 | 32 | int updateByPrimaryKey(OptionVo record); 33 | 34 | /** 35 | * 批量保存 36 | * @param optionVos list 37 | * @return 保存的个数 38 | */ 39 | int insertOptions(List optionVos); 40 | } -------------------------------------------------------------------------------- /src/main/java/springboot/dao/RelationshipVoMapper.java: -------------------------------------------------------------------------------- 1 | package springboot.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.springframework.stereotype.Component; 5 | import springboot.modal.vo.RelationshipVoExample; 6 | import springboot.modal.vo.RelationshipVoKey; 7 | 8 | import java.util.List; 9 | 10 | @Component 11 | public interface RelationshipVoMapper { 12 | long countByExample(RelationshipVoExample example); 13 | 14 | int deleteByExample(RelationshipVoExample example); 15 | 16 | int deleteByPrimaryKey(RelationshipVoKey key); 17 | 18 | int insert(RelationshipVoKey record); 19 | 20 | int insertSelective(RelationshipVoKey record); 21 | 22 | List selectByExample(RelationshipVoExample example); 23 | 24 | int updateByExampleSelective(@Param("record") RelationshipVoKey record, @Param("example") RelationshipVoExample example); 25 | 26 | int updateByExample(@Param("record") RelationshipVoKey record, @Param("example") RelationshipVoExample example); 27 | } -------------------------------------------------------------------------------- /src/main/java/springboot/dao/UserVoMapper.java: -------------------------------------------------------------------------------- 1 | package springboot.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import org.springframework.stereotype.Component; 5 | import springboot.modal.vo.UserVo; 6 | import springboot.modal.vo.UserVoExample; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author tangj 12 | * @date 2018/1/21 14:59 13 | */ 14 | @Component 15 | public interface UserVoMapper { 16 | long countByExample(UserVoExample example); 17 | 18 | int deleteByExample(UserVoExample example); 19 | 20 | int deleteByPrimaryKey(Integer uid); 21 | 22 | int insert(UserVo record); 23 | 24 | int insertSelective(UserVo record); 25 | 26 | List selectByExample(UserVoExample example); 27 | 28 | UserVo selectByPrimaryKey(Integer uid); 29 | 30 | int updateByExampleSelective(@Param("record") UserVo record, @Param("example") UserVoExample example); 31 | 32 | int updateByExample(@Param("record") UserVo record, @Param("example") UserVoExample example); 33 | 34 | int updateByPrimaryKeySelective(UserVo record); 35 | 36 | int updateByPrimaryKey(UserVo record); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/springboot/dto/LogActions.java: -------------------------------------------------------------------------------- 1 | package springboot.dto; 2 | 3 | /** 4 | * 日志表的action字段 5 | * Created by tangj on 2017/3/4. 6 | */ 7 | public enum LogActions { 8 | 9 | LOGIN("登录后台"), UP_PWD("修改密码"), UP_INFO("修改个人信息"), 10 | DEL_ARTICLE("删除文章"), DEL_PAGE("删除页面"), SYS_BACKUP("系统备份"), 11 | SYS_SETTING("保存系统设置"), INIT_SITE("初始化站点"),DEL_ATTACH("删除附件"); 12 | 13 | private String action; 14 | 15 | public String getAction() { 16 | return action; 17 | } 18 | 19 | public void setAction(String action) { 20 | this.action = action; 21 | } 22 | 23 | LogActions(String action) { 24 | this.action = action; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/springboot/dto/MetaDto.java: -------------------------------------------------------------------------------- 1 | package springboot.dto; 2 | 3 | 4 | import springboot.modal.vo.MetaVo; 5 | 6 | public class MetaDto extends MetaVo { 7 | 8 | private int count; 9 | 10 | public int getCount() { 11 | return count; 12 | } 13 | 14 | public void setCount(int count) { 15 | this.count = count; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/springboot/dto/Types.java: -------------------------------------------------------------------------------- 1 | package springboot.dto; 2 | 3 | public enum Types { 4 | TAG("tag"), 5 | CATEGORY("category"), 6 | ARTICLE("post"), 7 | PUBLISH("publish"), 8 | PAGE("page"), 9 | DRAFT("draft"), 10 | LINK("link"), 11 | IMAGE("image"), 12 | FILE("file"), 13 | CSRF_TOKEN("csrf_token"), 14 | COMMENTS_FREQUENCY("comments:frequency"), 15 | 16 | /** 17 | * 附件存放的URL,默认为网站地址,如集成第三方则为第三方CDN域名 18 | */ 19 | ATTACH_URL("attach_url"), 20 | 21 | /** 22 | * 网站要过滤,禁止访问的ip列表 23 | */ 24 | BLOCK_IPS("site_block_ips"); 25 | 26 | 27 | private String type; 28 | 29 | public java.lang.String getType() { 30 | return type; 31 | } 32 | 33 | public void setType(java.lang.String type) { 34 | this.type = type; 35 | } 36 | 37 | Types(java.lang.String type) { 38 | this.type = type; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/springboot/exception/TipException.java: -------------------------------------------------------------------------------- 1 | package springboot.exception; 2 | 3 | /** 4 | * @author tangj 5 | * @date 2018/1/21 14:05 6 | */ 7 | public class TipException extends RuntimeException { 8 | public TipException() { 9 | } 10 | 11 | public TipException(String message) { 12 | super(message); 13 | } 14 | 15 | public TipException(String message, Throwable cause) { 16 | super(message, cause); 17 | } 18 | 19 | public TipException(Throwable cause) { 20 | super(cause); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/springboot/interceptor/BaseInterceptor.java: -------------------------------------------------------------------------------- 1 | package springboot.interceptor; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.web.servlet.HandlerInterceptor; 8 | import org.springframework.web.servlet.ModelAndView; 9 | import springboot.constant.WebConst; 10 | import springboot.dto.Types; 11 | import springboot.modal.vo.UserVo; 12 | import springboot.service.IUserService; 13 | import springboot.util.*; 14 | 15 | import javax.annotation.Resource; 16 | import javax.servlet.http.HttpServletRequest; 17 | import javax.servlet.http.HttpServletResponse; 18 | 19 | /** 20 | * @author tangj 21 | * @date 2018/1/21 22:27 22 | */ 23 | @Component 24 | public class BaseInterceptor implements HandlerInterceptor { 25 | private static final Logger logger = LoggerFactory.getLogger(BaseInterceptor.class); 26 | private static final String USER_AGENT = "user-agent"; 27 | 28 | @Resource 29 | private IUserService userService; 30 | 31 | private MapCache cache = MapCache.single(); 32 | 33 | @Autowired 34 | private Commons commons; 35 | 36 | @Autowired 37 | private AdminCommons adminCommons; 38 | 39 | 40 | @Override 41 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 42 | String uri = request.getRequestURI(); 43 | String ip = IpUtil.getIpAddrByRequest(request); 44 | logger.info("UserAgent: {}", request.getHeader(USER_AGENT)); 45 | logger.info("用户访问地址: {}, 来路地址: {}", uri, ip); 46 | 47 | //请求拦截处理 48 | UserVo user = MyUtils.getLoginUser(request); 49 | if (null == user) { 50 | Integer uid = MyUtils.getCooKieUid(request); 51 | request.getSession().setAttribute(WebConst.LOGIN_SESSION_KEY, user); 52 | } 53 | // 处理uri 54 | if (uri.startsWith("/admin") && !uri.startsWith("/admin/login") && null == user) { 55 | response.sendRedirect(request.getContextPath() + "/admin/login"); 56 | return false; 57 | } 58 | 59 | // 设置get请求的token 60 | if (request.getMethod().equals("GET")) { 61 | String csrf_token = UUID.UU64(); 62 | // 默认存储30分钟 63 | cache.hset(Types.CSRF_TOKEN.getType(), csrf_token, uri, 30 * 60); 64 | request.setAttribute("_csrf_token", csrf_token); 65 | } 66 | return true; 67 | } 68 | 69 | @Override 70 | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { 71 | String ip = IpUtil.getIpAddrByRequest(request); 72 | // 禁止该ip访问 73 | if (WebConst.BLOCK_IPS.contains(ip)) { 74 | // 强制跳转 75 | modelAndView.setViewName("comm/ipban"); 76 | } 77 | 78 | request.setAttribute("commons",commons); 79 | request.setAttribute("adminCommons",adminCommons); 80 | } 81 | 82 | @Override 83 | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { 84 | 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/springboot/interceptor/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package springboot.interceptor; 2 | 3 | import org.springframework.stereotype.Component; 4 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 5 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 7 | import springboot.util.MyUtils; 8 | 9 | import javax.annotation.Resource; 10 | 11 | /** 12 | * @author tangj 13 | * @date 2018/1/22 20:50 14 | */ 15 | @Component 16 | public class WebMvcConfig extends WebMvcConfigurerAdapter{ 17 | @Resource 18 | private BaseInterceptor baseInterceptor; 19 | 20 | @Override 21 | public void addInterceptors(InterceptorRegistry registry) { 22 | registry.addInterceptor(baseInterceptor); 23 | } 24 | 25 | @Override 26 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 27 | registry.addResourceHandler("/upload/**").addResourceLocations("file:"+ MyUtils.getUploadFilePath()+"upload/"); 28 | super.addResourceHandlers(registry); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/springboot/modal/bo/ArchiveBo.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.bo; 2 | 3 | 4 | import springboot.modal.vo.ContentVo; 5 | 6 | import java.io.Serializable; 7 | import java.util.List; 8 | 9 | /** 10 | * 文章 11 | * @author tangj 12 | */ 13 | public class ArchiveBo implements Serializable { 14 | 15 | private String date; 16 | private String count; 17 | private List articles; 18 | 19 | public String getDate() { 20 | return date; 21 | } 22 | 23 | public void setDate(String date) { 24 | this.date = date; 25 | } 26 | 27 | public String getCount() { 28 | return count; 29 | } 30 | 31 | public void setCount(String count) { 32 | this.count = count; 33 | } 34 | 35 | public List getArticles() { 36 | return articles; 37 | } 38 | 39 | public void setArticles(List articles) { 40 | this.articles = articles; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "Archive [" + 46 | "date='" + date + '\'' + 47 | ", count='" + count + '\'' + 48 | ", articles=" + articles + 49 | ']'; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/springboot/modal/bo/BackResponseBo.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.bo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/1/23 11:49 8 | */ 9 | public class BackResponseBo implements Serializable { 10 | private String attachPath; 11 | private String themePath; 12 | private String sqlPath; 13 | 14 | public String getAttachPath() { 15 | return attachPath; 16 | } 17 | 18 | public void setAttachPath(String attachPath) { 19 | this.attachPath = attachPath; 20 | } 21 | 22 | public String getThemePath() { 23 | return themePath; 24 | } 25 | 26 | public void setThemePath(String themePath) { 27 | this.themePath = themePath; 28 | } 29 | 30 | public String getSqlPath() { 31 | return sqlPath; 32 | } 33 | 34 | public void setSqlPath(String sqlPath) { 35 | this.sqlPath = sqlPath; 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/springboot/modal/bo/CommentBo.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.bo; 2 | 3 | import springboot.modal.vo.CommentVo; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 返回页面的评论,包含父子评论内容 9 | * 10 | * @author tangj 11 | * @date 2018/1/28 15:48 12 | */ 13 | public class CommentBo extends CommentVo { 14 | private int levels; 15 | private List children; 16 | 17 | public CommentBo(CommentVo comments) { 18 | setAuthor(comments.getAuthor()); 19 | setMail(comments.getMail()); 20 | setCoid(comments.getCoid()); 21 | setAuthorId(comments.getAuthorId()); 22 | setUrl(comments.getUrl()); 23 | setCreated(comments.getCreated()); 24 | setAgent(comments.getAgent()); 25 | setIp(comments.getIp()); 26 | setContent(comments.getContent()); 27 | setOwnerId(comments.getOwnerId()); 28 | setCid(comments.getCid()); 29 | } 30 | 31 | public int getLevels() { 32 | return levels; 33 | } 34 | 35 | public void setLevels(int levels) { 36 | this.levels = levels; 37 | } 38 | 39 | public List getChildren() { 40 | return children; 41 | } 42 | 43 | public void setChildren(List children) { 44 | this.children = children; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/springboot/modal/bo/RestResponseBo.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.bo; 2 | 3 | /** 4 | * rest返回对象 5 | * 6 | * @author tangj 7 | * @date 2018/1/21 14:10 8 | */ 9 | public class RestResponseBo { 10 | /** 11 | * 服务器响应数据 12 | */ 13 | private T payload; 14 | 15 | /** 16 | * 请求是否成功 17 | */ 18 | private boolean success; 19 | 20 | /** 21 | * 错误信息 22 | */ 23 | private String msg; 24 | 25 | /** 26 | * 状态码 27 | */ 28 | private int code = -1; 29 | 30 | /** 31 | * 服务器响应时间 32 | */ 33 | private long timestamp; 34 | 35 | public RestResponseBo() { 36 | this.timestamp = System.currentTimeMillis() / 1000; 37 | } 38 | 39 | public RestResponseBo(boolean success) { 40 | this.timestamp = System.currentTimeMillis() / 1000; 41 | this.success = success; 42 | } 43 | 44 | public RestResponseBo(boolean success, T payload) { 45 | this.timestamp = System.currentTimeMillis() / 1000; 46 | this.success = success; 47 | this.payload = payload; 48 | } 49 | 50 | public RestResponseBo(boolean success, T payload, int code) { 51 | this.timestamp = System.currentTimeMillis() / 1000; 52 | this.success = success; 53 | this.payload = payload; 54 | this.code = code; 55 | } 56 | 57 | public RestResponseBo(boolean success, String msg) { 58 | this.timestamp = System.currentTimeMillis() / 1000; 59 | this.success = success; 60 | this.msg = msg; 61 | } 62 | 63 | public RestResponseBo(boolean success, String msg, int code) { 64 | this.timestamp = System.currentTimeMillis() / 1000; 65 | this.success = success; 66 | this.msg = msg; 67 | this.code = code; 68 | } 69 | 70 | public T getPayload() { 71 | return payload; 72 | } 73 | 74 | public void setPayload(T payload) { 75 | this.payload = payload; 76 | } 77 | 78 | public boolean isSuccess() { 79 | return success; 80 | } 81 | 82 | public void setSuccess(boolean success) { 83 | this.success = success; 84 | } 85 | 86 | public String getMsg() { 87 | return msg; 88 | } 89 | 90 | public void setMsg(String msg) { 91 | this.msg = msg; 92 | } 93 | 94 | public int getCode() { 95 | return code; 96 | } 97 | 98 | public void setCode(int code) { 99 | this.code = code; 100 | } 101 | 102 | public long getTimestamp() { 103 | return timestamp; 104 | } 105 | 106 | public void setTimestamp(long timestamp) { 107 | this.timestamp = timestamp; 108 | } 109 | 110 | public static RestResponseBo ok() { 111 | return new RestResponseBo(true); 112 | } 113 | 114 | public static RestResponseBo ok(T payload) { 115 | return new RestResponseBo(true, payload); 116 | } 117 | 118 | public static RestResponseBo ok(int code) { 119 | return new RestResponseBo(true, null, code); 120 | } 121 | 122 | public static RestResponseBo ok(T payload, int code) { 123 | return new RestResponseBo(true, payload, code); 124 | } 125 | 126 | public static RestResponseBo fail() { 127 | return new RestResponseBo(false); 128 | } 129 | 130 | public static RestResponseBo fail(String msg) { 131 | return new RestResponseBo(false, msg); 132 | } 133 | 134 | public static RestResponseBo fail(int code) { 135 | return new RestResponseBo(false, null, code); 136 | } 137 | 138 | public static RestResponseBo fail(int code, String msg) { 139 | return new RestResponseBo(false, msg, code); 140 | } 141 | 142 | } 143 | -------------------------------------------------------------------------------- /src/main/java/springboot/modal/bo/StaticticsBo.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.bo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/1/23 11:55 8 | */ 9 | public class StaticticsBo implements Serializable{ 10 | private Long articles; 11 | private Long comments; 12 | private Long links; 13 | private Long attachs; 14 | 15 | public Long getArticles() { 16 | return articles; 17 | } 18 | 19 | public void setArticles(Long articles) { 20 | this.articles = articles; 21 | } 22 | 23 | public Long getComments() { 24 | return comments; 25 | } 26 | 27 | public void setComments(Long comments) { 28 | this.comments = comments; 29 | } 30 | 31 | public Long getLinks() { 32 | return links; 33 | } 34 | 35 | public void setLinks(Long links) { 36 | this.links = links; 37 | } 38 | 39 | public Long getAttachs() { 40 | return attachs; 41 | } 42 | 43 | public void setAttachs(Long attachs) { 44 | this.attachs = attachs; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "StaticticsBo{" + 50 | "articles=" + articles + 51 | ", comments=" + comments + 52 | ", links=" + links + 53 | ", attachs=" + attachs + 54 | '}'; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/springboot/modal/redisKey/ContentKey.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.redisKey; 2 | 3 | /** 4 | * @author tangj 5 | * @date 2018/5/13 17:45 6 | */ 7 | public class ContentKey { 8 | // 表名 9 | public static final String TABLE_NAME = "t_contents"; 10 | 11 | // 主键名 12 | public static final String MAJOR_KEY = "cid"; 13 | 14 | // 默认主键值 15 | public static final String DEFAULT_VALUE = "all"; 16 | 17 | // 生存周期 18 | public static final int LIVE_TIME = 6; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/springboot/modal/vo/AttachVo.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.vo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/1/21 11:08 8 | */ 9 | public class AttachVo implements Serializable { 10 | private Integer id; 11 | 12 | private String fname; 13 | 14 | private String ftype; 15 | 16 | private String fkey; 17 | 18 | private Integer authorId; 19 | 20 | private Integer created; 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | public Integer getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Integer id) { 29 | this.id = id; 30 | } 31 | 32 | public String getFname() { 33 | return fname; 34 | } 35 | 36 | public void setFname(String fname) { 37 | this.fname = fname; 38 | } 39 | 40 | public String getFtype() { 41 | return ftype; 42 | } 43 | 44 | public void setFtype(String ftype) { 45 | this.ftype = ftype; 46 | } 47 | 48 | public String getFkey() { 49 | return fkey; 50 | } 51 | 52 | public void setFkey(String fkey) { 53 | this.fkey = fkey; 54 | } 55 | 56 | public Integer getAuthorId() { 57 | return authorId; 58 | } 59 | 60 | public void setAuthorId(Integer authorId) { 61 | this.authorId = authorId; 62 | } 63 | 64 | public Integer getCreated() { 65 | return created; 66 | } 67 | 68 | public void setCreated(Integer created) { 69 | this.created = created; 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | return "AttachVo{" + 75 | "id=" + id + 76 | ", fname='" + fname + '\'' + 77 | ", ftype='" + ftype + '\'' + 78 | ", fkey='" + fkey + '\'' + 79 | ", authorId=" + authorId + 80 | ", created=" + created + 81 | '}'; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/springboot/modal/vo/ContentVo.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.vo; 2 | 3 | public class ContentVo { 4 | private Integer cid; 5 | 6 | private String title; 7 | 8 | private String slug; 9 | 10 | private Integer created; 11 | 12 | private Integer modified; 13 | 14 | private Integer authorId; 15 | 16 | private String type; 17 | 18 | private String status; 19 | 20 | private String tags; 21 | 22 | private String categories; 23 | 24 | private Integer hits; 25 | 26 | private Integer commentsNum; 27 | 28 | private Boolean allowComment; 29 | 30 | private Boolean allowPing; 31 | 32 | private Boolean allowFeed; 33 | 34 | private String thumbimg; 35 | 36 | private String content; 37 | 38 | public Integer getCid() { 39 | return cid; 40 | } 41 | 42 | public void setCid(Integer cid) { 43 | this.cid = cid; 44 | } 45 | 46 | public String getTitle() { 47 | return title; 48 | } 49 | 50 | public void setTitle(String title) { 51 | this.title = title == null ? null : title.trim(); 52 | } 53 | 54 | public String getSlug() { 55 | return slug; 56 | } 57 | 58 | public void setSlug(String slug) { 59 | this.slug = slug == null ? null : slug.trim(); 60 | } 61 | 62 | public Integer getCreated() { 63 | return created; 64 | } 65 | 66 | public void setCreated(Integer created) { 67 | this.created = created; 68 | } 69 | 70 | public Integer getModified() { 71 | return modified; 72 | } 73 | 74 | public void setModified(Integer modified) { 75 | this.modified = modified; 76 | } 77 | 78 | public Integer getAuthorId() { 79 | return authorId; 80 | } 81 | 82 | public void setAuthorId(Integer authorId) { 83 | this.authorId = authorId; 84 | } 85 | 86 | public String getType() { 87 | return type; 88 | } 89 | 90 | public void setType(String type) { 91 | this.type = type == null ? null : type.trim(); 92 | } 93 | 94 | public String getStatus() { 95 | return status; 96 | } 97 | 98 | public void setStatus(String status) { 99 | this.status = status == null ? null : status.trim(); 100 | } 101 | 102 | public String getTags() { 103 | return tags; 104 | } 105 | 106 | public void setTags(String tags) { 107 | this.tags = tags == null ? null : tags.trim(); 108 | } 109 | 110 | public String getCategories() { 111 | return categories; 112 | } 113 | 114 | public void setCategories(String categories) { 115 | this.categories = categories == null ? null : categories.trim(); 116 | } 117 | 118 | public Integer getHits() { 119 | return hits; 120 | } 121 | 122 | public void setHits(Integer hits) { 123 | this.hits = hits; 124 | } 125 | 126 | public Integer getCommentsNum() { 127 | return commentsNum; 128 | } 129 | 130 | public void setCommentsNum(Integer commentsNum) { 131 | this.commentsNum = commentsNum; 132 | } 133 | 134 | public Boolean getAllowComment() { 135 | return allowComment; 136 | } 137 | 138 | public void setAllowComment(Boolean allowComment) { 139 | this.allowComment = allowComment; 140 | } 141 | 142 | public Boolean getAllowPing() { 143 | return allowPing; 144 | } 145 | 146 | public void setAllowPing(Boolean allowPing) { 147 | this.allowPing = allowPing; 148 | } 149 | 150 | public Boolean getAllowFeed() { 151 | return allowFeed; 152 | } 153 | 154 | public void setAllowFeed(Boolean allowFeed) { 155 | this.allowFeed = allowFeed; 156 | } 157 | 158 | public String getThumbimg() { 159 | return thumbimg; 160 | } 161 | 162 | public void setThumbimg(String thumbimg) { 163 | this.thumbimg = thumbimg == null ? null : thumbimg.trim(); 164 | } 165 | 166 | public String getContent() { 167 | return content; 168 | } 169 | 170 | public void setContent(String content) { 171 | this.content = content == null ? null : content.trim(); 172 | } 173 | } -------------------------------------------------------------------------------- /src/main/java/springboot/modal/vo/LogVo.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.vo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/1/21 11:14 8 | */ 9 | public class LogVo implements Serializable{ 10 | /** 11 | * 日志主键 12 | */ 13 | private Integer id; 14 | 15 | /** 16 | * 产生的动作 17 | */ 18 | private String action; 19 | 20 | /** 21 | * 产生的数据 22 | */ 23 | private String data; 24 | 25 | /** 26 | * 发生人id 27 | */ 28 | private Integer authorId; 29 | 30 | /** 31 | * 日志产生的ip 32 | */ 33 | private String ip; 34 | 35 | /** 36 | * 日志创建时间 37 | */ 38 | private Integer created; 39 | 40 | 41 | private static final long serialVersionUID = 1L; 42 | 43 | public Integer getId() { 44 | return id; 45 | } 46 | 47 | public void setId(Integer id) { 48 | this.id = id; 49 | } 50 | 51 | public String getAction() { 52 | return action; 53 | } 54 | 55 | public void setAction(String action) { 56 | this.action = action; 57 | } 58 | 59 | public String getData() { 60 | return data; 61 | } 62 | 63 | public void setData(String data) { 64 | this.data = data; 65 | } 66 | 67 | public Integer getAuthorId() { 68 | return authorId; 69 | } 70 | 71 | public void setAuthorId(Integer authorId) { 72 | this.authorId = authorId; 73 | } 74 | 75 | public String getIp() { 76 | return ip; 77 | } 78 | 79 | public void setIp(String ip) { 80 | this.ip = ip; 81 | } 82 | 83 | public Integer getCreated() { 84 | return created; 85 | } 86 | 87 | public void setCreated(Integer created) { 88 | this.created = created; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/springboot/modal/vo/MetaVo.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.vo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/1/21 11:15 8 | */ 9 | public class MetaVo implements Serializable{ 10 | 11 | /** 12 | * 项目主键 13 | */ 14 | private Integer mid; 15 | 16 | /** 17 | * 名称 18 | */ 19 | private String name; 20 | 21 | /** 22 | * 项目缩略名 23 | */ 24 | private String slug; 25 | 26 | /** 27 | * 项目类型 28 | */ 29 | private String type; 30 | 31 | /** 32 | * 选项描述 33 | */ 34 | private String description; 35 | 36 | /** 37 | * 项目排序 38 | */ 39 | private Integer sort; 40 | 41 | private Integer parent; 42 | 43 | private static final long serialVersionUID = 1L; 44 | 45 | public Integer getMid() { 46 | return mid; 47 | } 48 | 49 | public void setMid(Integer mid) { 50 | this.mid = mid; 51 | } 52 | 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | public void setName(String name) { 58 | this.name = name; 59 | } 60 | 61 | public String getSlug() { 62 | return slug; 63 | } 64 | 65 | public void setSlug(String slug) { 66 | this.slug = slug; 67 | } 68 | 69 | public String getType() { 70 | return type; 71 | } 72 | 73 | public void setType(String type) { 74 | this.type = type; 75 | } 76 | 77 | public String getDescription() { 78 | return description; 79 | } 80 | 81 | public void setDescription(String description) { 82 | this.description = description; 83 | } 84 | 85 | public Integer getSort() { 86 | return sort; 87 | } 88 | 89 | public void setSort(Integer sort) { 90 | this.sort = sort; 91 | } 92 | 93 | public Integer getParent() { 94 | return parent; 95 | } 96 | 97 | public void setParent(Integer parent) { 98 | this.parent = parent; 99 | } 100 | 101 | @Override 102 | public String toString() { 103 | return "MetaVo{" + 104 | "mid=" + mid + 105 | ", name='" + name + '\'' + 106 | ", slug='" + slug + '\'' + 107 | ", type='" + type + '\'' + 108 | ", description='" + description + '\'' + 109 | ", sort=" + sort + 110 | ", parent=" + parent + 111 | '}'; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/springboot/modal/vo/OptionVo.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.vo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/1/21 11:16 8 | */ 9 | public class OptionVo implements Serializable { 10 | /** 11 | * 配置名称 12 | */ 13 | private String name; 14 | 15 | /** 16 | * 配置值 17 | */ 18 | private String value; 19 | 20 | private String description; 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | public void setValue(String value) { 37 | this.value = value; 38 | } 39 | 40 | public String getDescription() { 41 | return description; 42 | } 43 | 44 | public void setDescription(String description) { 45 | this.description = description; 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/springboot/modal/vo/RedisModel.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.vo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * redis 模型 7 | */ 8 | public class RedisModel implements Serializable { 9 | private static final long serialVersionUID = 1L; 10 | 11 | private String id; 12 | private String name; 13 | private Integer age; 14 | 15 | public RedisModel() { 16 | super(); 17 | } 18 | 19 | public RedisModel(String id, String name, Integer age) { 20 | super(); 21 | this.id = id; 22 | this.name = name; 23 | this.age = age; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "RedisModel{" + 29 | "id='" + id + '\'' + 30 | ", name='" + name + '\'' + 31 | ", age=" + age + 32 | '}'; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/springboot/modal/vo/RelationshipVo.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.vo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/1/21 11:17 8 | */ 9 | public class RelationshipVo implements Serializable{ 10 | /** 11 | * 内容主键 12 | */ 13 | private Integer cid; 14 | 15 | /** 16 | * 项目主键 17 | */ 18 | private Integer mid; 19 | 20 | private static final long serialVersionUID = 1L; 21 | 22 | public Integer getCid() { 23 | return cid; 24 | } 25 | 26 | public void setCid(Integer cid) { 27 | this.cid = cid; 28 | } 29 | 30 | public Integer getMid() { 31 | return mid; 32 | } 33 | 34 | public void setMid(Integer mid) { 35 | this.mid = mid; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/springboot/modal/vo/RelationshipVoKey.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.vo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author 7 | */ 8 | public class RelationshipVoKey implements Serializable { 9 | /** 10 | * 内容主键 11 | */ 12 | private Integer cid; 13 | 14 | /** 15 | * 项目主键 16 | */ 17 | private Integer mid; 18 | 19 | private static final long serialVersionUID = 1L; 20 | 21 | public Integer getCid() { 22 | return cid; 23 | } 24 | 25 | public void setCid(Integer cid) { 26 | this.cid = cid; 27 | } 28 | 29 | public Integer getMid() { 30 | return mid; 31 | } 32 | 33 | public void setMid(Integer mid) { 34 | this.mid = mid; 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/springboot/modal/vo/UserVo.java: -------------------------------------------------------------------------------- 1 | package springboot.modal.vo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/1/21 11:18 8 | */ 9 | public class UserVo implements Serializable{ 10 | /** 11 | * user表主键 12 | */ 13 | private Integer uid; 14 | 15 | /** 16 | * 用户名称 17 | */ 18 | private String username; 19 | 20 | /** 21 | * 用户密码 22 | */ 23 | private String password; 24 | 25 | /** 26 | * 用户的邮箱 27 | */ 28 | private String email; 29 | 30 | /** 31 | * 用户的主页 32 | */ 33 | private String homeUrl; 34 | 35 | /** 36 | * 用户显示的名称 37 | */ 38 | private String screenName; 39 | 40 | /** 41 | * 用户注册时的GMT unix时间戳 42 | */ 43 | private Integer created; 44 | 45 | /** 46 | * 最后活动时间 47 | */ 48 | private Integer activated; 49 | 50 | /** 51 | * 上次登录最后活跃时间 52 | */ 53 | private Integer logged; 54 | 55 | /** 56 | * 用户组 57 | */ 58 | private String groupName; 59 | 60 | private static final long serialVersionUID = 1L; 61 | 62 | public Integer getUid() { 63 | return uid; 64 | } 65 | 66 | public void setUid(Integer uid) { 67 | this.uid = uid; 68 | } 69 | 70 | public String getUsername() { 71 | return username; 72 | } 73 | 74 | public void setUsername(String username) { 75 | this.username = username; 76 | } 77 | 78 | public String getPassword() { 79 | return password; 80 | } 81 | 82 | public void setPassword(String password) { 83 | this.password = password; 84 | } 85 | 86 | public String getEmail() { 87 | return email; 88 | } 89 | 90 | public void setEmail(String email) { 91 | this.email = email; 92 | } 93 | 94 | public String getHomeUrl() { 95 | return homeUrl; 96 | } 97 | 98 | public void setHomeUrl(String homeUrl) { 99 | this.homeUrl = homeUrl; 100 | } 101 | 102 | public String getScreenName() { 103 | return screenName; 104 | } 105 | 106 | public void setScreenName(String screenName) { 107 | this.screenName = screenName; 108 | } 109 | 110 | public Integer getCreated() { 111 | return created; 112 | } 113 | 114 | public void setCreated(Integer created) { 115 | this.created = created; 116 | } 117 | 118 | public Integer getActivated() { 119 | return activated; 120 | } 121 | 122 | public void setActivated(Integer activated) { 123 | this.activated = activated; 124 | } 125 | 126 | public Integer getLogged() { 127 | return logged; 128 | } 129 | 130 | public void setLogged(Integer logged) { 131 | this.logged = logged; 132 | } 133 | 134 | public String getGroupName() { 135 | return groupName; 136 | } 137 | 138 | public void setGroupName(String groupName) { 139 | this.groupName = groupName; 140 | } 141 | 142 | @Override 143 | public String toString() { 144 | return "UserVo{" + 145 | "uid=" + uid + 146 | ", username='" + username + '\'' + 147 | ", password='" + password + '\'' + 148 | ", email='" + email + '\'' + 149 | ", homeUrl='" + homeUrl + '\'' + 150 | ", screenName='" + screenName + '\'' + 151 | ", created=" + created + 152 | ", activated=" + activated + 153 | ", logged=" + logged + 154 | ", groupName='" + groupName + '\'' + 155 | '}'; 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/main/java/springboot/scheduletask/ScheduleTask.java: -------------------------------------------------------------------------------- 1 | package springboot.scheduletask; 2 | 3 | import com.sun.management.OperatingSystemMXBean; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.scheduling.annotation.Scheduled; 6 | import org.springframework.stereotype.Component; 7 | import springboot.modal.vo.LogVo; 8 | import springboot.service.ILogService; 9 | import springboot.service.IMailService; 10 | import springboot.service.IMetaService; 11 | import springboot.util.DateKit; 12 | 13 | import javax.annotation.Resource; 14 | import java.lang.management.ManagementFactory; 15 | import java.util.List; 16 | 17 | 18 | /** 19 | * @author tangj 20 | * @date 2018/5/2 22:59 21 | */ 22 | @Component 23 | public class ScheduleTask { 24 | 25 | @Resource 26 | ILogService logService; 27 | 28 | @Resource 29 | IMailService mailService; 30 | 31 | @Value("${spring.mail.username}") 32 | private String mailTo; 33 | 34 | @Scheduled(fixedRate = 86400000) 35 | public void process(){ 36 | StringBuffer result = new StringBuffer(); 37 | long totalMemory = Runtime.getRuntime().totalMemory(); 38 | result.append("使用的总内存为:"+totalMemory/(1024*1024)+"MB").append("\n"); 39 | result.append("内存使用率为:"+getMemery()).append("\n"); 40 | List logVoList = logService.getLogs(0,5); 41 | for (LogVo logVo:logVoList){ 42 | result.append(" 时间: ").append(DateKit.formatDateByUnixTime(logVo.getCreated())); 43 | result.append(" 操作: ").append(logVo.getAction()); 44 | result.append(" IP: ").append(logVo.getIp()).append("\n"); 45 | } 46 | mailService.sendSimpleEmail(mailTo,"博客系统运行情况",result.toString()); 47 | } 48 | 49 | public static String getMemery() { 50 | 51 | OperatingSystemMXBean osmxb = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class); 52 | long totalvirtualMemory = osmxb.getTotalSwapSpaceSize(); // 剩余的物理内存 53 | long freePhysicalMemorySize = osmxb.getFreePhysicalMemorySize(); 54 | Double compare = (Double) (1 - freePhysicalMemorySize * 1.0 / totalvirtualMemory) * 100; 55 | String str = compare.intValue() + "%"; 56 | return str; 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/springboot/server/HttpNettyServer.java: -------------------------------------------------------------------------------- 1 | package springboot.server; 2 | 3 | import io.netty.bootstrap.ServerBootstrap; 4 | import io.netty.channel.ChannelFuture; 5 | import io.netty.channel.EventLoopGroup; 6 | import io.netty.channel.nio.NioEventLoopGroup; 7 | import io.netty.channel.socket.nio.NioServerSocketChannel; 8 | import io.netty.handler.logging.LogLevel; 9 | import io.netty.handler.logging.LoggingHandler; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import springboot.server.handler.HttpNettyServerInitializer; 13 | import springboot.util.PortChecker; 14 | 15 | import java.net.InetSocketAddress; 16 | 17 | /** 18 | * @author tangj 19 | * @date 2018/4/15 15:27 20 | */ 21 | public class HttpNettyServer { 22 | private static final Logger logger = LoggerFactory.getLogger(HttpNettyServer.class); 23 | 24 | private Thread startThread = null; 25 | 26 | EventLoopGroup bossGroup = new NioEventLoopGroup(); 27 | EventLoopGroup wokerGroup = new NioEventLoopGroup(); 28 | 29 | private String ip = "0.0.0.0"; 30 | private int port = 3560; 31 | 32 | private HttpNettyServer(){ 33 | } 34 | 35 | private static class Inner{ 36 | private static HttpNettyServer instance = new HttpNettyServer(); 37 | } 38 | 39 | public static HttpNettyServer getInstance(){ 40 | return Inner.instance; 41 | } 42 | 43 | public void start() throws Exception{ 44 | if (!PortChecker.checkPort(null, port)) { 45 | throw new Exception("请确保所需要内部管理端口" + port + "没有被占用"); 46 | } 47 | 48 | InetSocketAddress addr = new InetSocketAddress(ip,port); 49 | // 启动ip和端口 50 | final String adInfo = ip + ":" + port; 51 | 52 | startThread = new Thread(){ 53 | @Override 54 | public void run(){ 55 | try { 56 | ServerBootstrap serverBootstrap = new ServerBootstrap(); 57 | serverBootstrap.group(bossGroup,wokerGroup) 58 | .channel(NioServerSocketChannel.class) 59 | .handler(new LoggingHandler(LogLevel.INFO)) 60 | .childHandler(new HttpNettyServerInitializer()); 61 | ChannelFuture future = serverBootstrap.bind(new InetSocketAddress(port)).sync(); 62 | logger.info("HTTP service start success ---"+adInfo); 63 | future.channel().closeFuture().sync(); 64 | }catch (Exception e){ 65 | logger.error("HTTP Service start fail ---"+adInfo+e.getMessage()); 66 | }finally { 67 | bossGroup.shutdownGracefully(); 68 | wokerGroup.shutdownGracefully(); 69 | } 70 | } 71 | }; 72 | startThread.start(); 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/springboot/server/codec/AbstractHttpJsonDecoder.java: -------------------------------------------------------------------------------- 1 | package springboot.server.codec; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.channel.ChannelHandlerContext; 5 | import io.netty.handler.codec.MessageToMessageDecoder; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import springboot.util.GsonUtils; 9 | 10 | import java.nio.charset.Charset; 11 | 12 | /** 13 | * @author tangj 14 | * @date 2018/4/15 19:23 15 | */ 16 | public abstract class AbstractHttpJsonDecoder extends MessageToMessageDecoder{ 17 | 18 | private static final Logger logger = LoggerFactory.getLogger(AbstractHttpJsonDecoder.class); 19 | 20 | private Class clazz; 21 | private boolean isPrint; 22 | private final static Charset UTF_8 = Charset.forName("UTF-8"); 23 | 24 | protected AbstractHttpJsonDecoder(Class clazz){ 25 | this(clazz,false); 26 | } 27 | 28 | protected AbstractHttpJsonDecoder(Class clazz,boolean isPrint){ 29 | this.clazz = clazz; 30 | this.isPrint = isPrint; 31 | } 32 | 33 | public Object jsonDecode(ChannelHandlerContext ctx, ByteBuf body){ 34 | String content = body.toString(UTF_8); 35 | if (isPrint){ 36 | logger.info("the receive body is"+content); 37 | } 38 | Object result = GsonUtils.jsonToObject(content,clazz); 39 | return result; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/springboot/server/codec/AbstractHttpJsonEncoder.java: -------------------------------------------------------------------------------- 1 | package springboot.server.codec; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.buffer.Unpooled; 5 | import io.netty.channel.ChannelHandlerContext; 6 | import io.netty.handler.codec.MessageToMessageEncoder; 7 | import springboot.util.GsonUtils; 8 | 9 | import java.nio.charset.Charset; 10 | 11 | /** 12 | * @author tangj 13 | * @date 2018/4/15 18:02 14 | */ 15 | public abstract class AbstractHttpJsonEncoder extends MessageToMessageEncoder{ 16 | final static Charset utf8 = Charset.forName("utf-8"); 17 | 18 | protected ByteBuf jsonEncode(ChannelHandlerContext ctx,Object body){ 19 | String jsonStr = GsonUtils.toJsonString(body); 20 | ByteBuf encodeBuf = Unpooled.copiedBuffer(jsonStr,utf8); 21 | return encodeBuf; 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/main/java/springboot/server/codec/HttpJsonRequest.java: -------------------------------------------------------------------------------- 1 | package springboot.server.codec; 2 | 3 | import io.netty.handler.codec.http.FullHttpRequest; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/4/15 17:52 8 | */ 9 | public class HttpJsonRequest { 10 | private FullHttpRequest request; 11 | private Object body; 12 | 13 | public HttpJsonRequest(FullHttpRequest request, Object body) { 14 | this.request = request; 15 | this.body = body; 16 | } 17 | 18 | public FullHttpRequest getRequest() { 19 | return request; 20 | } 21 | 22 | public void setRequest(FullHttpRequest request) { 23 | this.request = request; 24 | } 25 | 26 | public Object getBody() { 27 | return body; 28 | } 29 | 30 | public void setBody(Object body) { 31 | this.body = body; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return "HttpJsonRequest{" + 37 | "request=" + request + 38 | ", body=" + body + 39 | '}'; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/springboot/server/codec/HttpJsonRequestDecoder.java: -------------------------------------------------------------------------------- 1 | package springboot.server.codec; 2 | 3 | import io.netty.buffer.Unpooled; 4 | import io.netty.channel.ChannelFutureListener; 5 | import io.netty.channel.ChannelHandlerContext; 6 | import io.netty.handler.codec.http.*; 7 | 8 | import java.nio.charset.Charset; 9 | import java.util.List; 10 | 11 | /** 12 | * @author tangj 13 | * @date 2018/4/15 20:52 14 | */ 15 | public class HttpJsonRequestDecoder extends AbstractHttpJsonDecoder{ 16 | 17 | public HttpJsonRequestDecoder(Class clazz) { 18 | super(clazz); 19 | } 20 | 21 | protected HttpJsonRequestDecoder(Class clazz, boolean isPrint) { 22 | super(clazz, isPrint); 23 | } 24 | 25 | @Override 26 | protected void decode(ChannelHandlerContext ctx, FullHttpRequest msg, List out) throws Exception { 27 | if (msg.decoderResult().isFailure()){ 28 | sendError(ctx,HttpResponseStatus.BAD_REQUEST); 29 | } 30 | HttpJsonRequest request = new HttpJsonRequest(msg,jsonDecode(ctx,msg.content())); 31 | out.add(request); 32 | } 33 | 34 | private static void sendError(ChannelHandlerContext ctx, HttpResponseStatus status){ 35 | FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,status, Unpooled.copiedBuffer("Failure: " + status.toString() 36 | + "\r\n", Charset.forName("utf-8"))); 37 | response.headers().set(HttpHeaderNames.CONTENT_TYPE,"text/plain; charset=UTF-8"); 38 | ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/springboot/server/codec/HttpJsonResponse.java: -------------------------------------------------------------------------------- 1 | package springboot.server.codec; 2 | 3 | import io.netty.handler.codec.http.FullHttpResponse; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/4/15 17:53 8 | */ 9 | public class HttpJsonResponse { 10 | private FullHttpResponse httpResponse; 11 | private Object result; 12 | 13 | public HttpJsonResponse(FullHttpResponse httpResponse, Object result) { 14 | this.httpResponse = httpResponse; 15 | this.result = result; 16 | } 17 | 18 | public FullHttpResponse getHttpResponse() { 19 | return httpResponse; 20 | } 21 | 22 | public void setHttpResponse(FullHttpResponse httpResponse) { 23 | this.httpResponse = httpResponse; 24 | } 25 | 26 | public Object getResult() { 27 | return result; 28 | } 29 | 30 | public void setResult(Object result) { 31 | this.result = result; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return "HttpJsonResponse{" + 37 | "httpResponse=" + httpResponse + 38 | ", result=" + result + 39 | '}'; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/springboot/server/codec/HttpJsonResponseEncoder.java: -------------------------------------------------------------------------------- 1 | package springboot.server.codec; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.channel.ChannelHandlerContext; 5 | import io.netty.handler.codec.http.*; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author tangj 11 | * @date 2018/4/15 21:12 12 | */ 13 | public class HttpJsonResponseEncoder extends AbstractHttpJsonEncoder{ 14 | 15 | @Override 16 | protected void encode(ChannelHandlerContext ctx, HttpJsonResponse msg, List out) throws Exception { 17 | // 编码 18 | ByteBuf body = jsonEncode(ctx,msg.getResult()); 19 | FullHttpResponse response = msg.getHttpResponse(); 20 | if (response == null){ 21 | response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK,body); 22 | } else { 23 | response = new DefaultFullHttpResponse(msg.getHttpResponse().protocolVersion(),msg.getHttpResponse().status(),body); 24 | } 25 | 26 | response.headers().set(HttpHeaderNames.CONTENT_TYPE,"text/json"); 27 | HttpUtil.setContentLength(response,body.readableBytes()); 28 | out.add(response); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/springboot/server/handler/HttpNettyServerInitializer.java: -------------------------------------------------------------------------------- 1 | package springboot.server.handler; 2 | 3 | import io.netty.channel.ChannelInitializer; 4 | import io.netty.channel.socket.SocketChannel; 5 | import io.netty.handler.codec.http.HttpObjectAggregator; 6 | import io.netty.handler.codec.http.HttpRequestDecoder; 7 | import io.netty.handler.codec.http.HttpResponseEncoder; 8 | import springboot.modal.vo.UserVo; 9 | import springboot.server.handler.HttpServerHandler; 10 | import springboot.server.codec.HttpJsonRequestDecoder; 11 | import springboot.server.codec.HttpJsonResponseEncoder; 12 | 13 | /** 14 | * @author tangj 15 | * @date 2018/4/15 15:27 16 | */ 17 | public class HttpNettyServerInitializer extends ChannelInitializer{ 18 | 19 | /** 20 | * 服务端编解码器: 获取请求,最终解码为自定义的HttpJsonRequest对象 21 | 22 | (1) HttpRequestDecoder:请求消息解码器,转换为消息对象。 23 | 24 | (2) HttpObjectAggregator: 目的是将多个消息转换为单一的request或者response对象,最终得到的是FullHttpRequest对象 25 | 26 | (3) 需要自定义的解码器HttpJsonRequestDecoder,将FullHttpRequest转换为HttpJsonRequest对象 27 | * @param ch 28 | * @throws Exception 29 | */ 30 | @Override 31 | protected void initChannel(SocketChannel ch) throws Exception { 32 | ch.pipeline().addLast("http-decoder",new HttpRequestDecoder()); 33 | ch.pipeline().addLast("http-aggregator",new HttpObjectAggregator(65336)); 34 | ch.pipeline().addLast("json-decoder",new HttpJsonRequestDecoder(UserVo.class)); 35 | 36 | ch.pipeline().addLast("http-encoder",new HttpResponseEncoder()); 37 | ch.pipeline().addLast("json-encoder",new HttpJsonResponseEncoder()); 38 | ch.pipeline().addLast("handler",new HttpServerHandler()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/springboot/server/handler/HttpServerHandler.java: -------------------------------------------------------------------------------- 1 | package springboot.server.handler; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.channel.ChannelFuture; 5 | import io.netty.channel.ChannelHandlerContext; 6 | import io.netty.channel.SimpleChannelInboundHandler; 7 | import io.netty.handler.codec.http.HttpObject; 8 | import io.netty.handler.codec.http.HttpRequest; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Component; 13 | import org.springframework.stereotype.Service; 14 | import springboot.dao.UserVoMapper; 15 | import springboot.modal.vo.UserVo; 16 | import springboot.server.codec.HttpJsonRequest; 17 | import springboot.server.codec.HttpJsonResponse; 18 | 19 | import javax.annotation.Resource; 20 | 21 | /** 22 | * @author tangj 23 | * @date 2018/4/15 16:46 24 | */ 25 | public class HttpServerHandler extends SimpleChannelInboundHandler{ 26 | 27 | @Resource 28 | private UserVoMapper userDao; 29 | 30 | private static final Logger logger = LoggerFactory.getLogger(HttpServerHandler.class); 31 | @Override 32 | protected void channelRead0(ChannelHandlerContext ctx, HttpJsonRequest msg) throws Exception { 33 | HttpRequest request = msg.getRequest(); 34 | UserVo user = (UserVo)msg.getBody(); 35 | userDao.insert(user); 36 | logger.info("服务端收到消息"+user); 37 | ctx.writeAndFlush(new HttpJsonResponse(null,user)); 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/IAttachService.java: -------------------------------------------------------------------------------- 1 | package springboot.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import springboot.modal.vo.AttachVo; 5 | 6 | public interface IAttachService { 7 | /** 8 | * 分页查询附件 9 | * 10 | * @param page 11 | * @param limit 12 | * @return 13 | */ 14 | PageInfo getAttachs(Integer page, Integer limit); 15 | 16 | /** 17 | * 保存附件 18 | * 19 | * @param fname 20 | * @param fkey 21 | * @param ftype 22 | * @param author 23 | */ 24 | void save(String fname, String fkey, String ftype, Integer author); 25 | 26 | /** 27 | * 根据附件Id,查询附件 28 | * 29 | * @param id 30 | * @return 31 | */ 32 | AttachVo selectById(Integer id); 33 | 34 | /** 35 | * 删除附件 36 | * 37 | * @param id 38 | */ 39 | void deleteById(Integer id); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/ICommentService.java: -------------------------------------------------------------------------------- 1 | package springboot.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import springboot.modal.bo.CommentBo; 5 | import springboot.modal.vo.CommentVo; 6 | import springboot.modal.vo.CommentVoExample; 7 | 8 | /** 9 | * @author tangj 10 | * @date 2018/1/28 15:46 11 | */ 12 | public interface ICommentService { 13 | 14 | /** 15 | * 保存对象 16 | * 17 | * @param commentVo 18 | */ 19 | void insertComment(CommentVo commentVo); 20 | 21 | /** 22 | * 获取文章下的评论 23 | * 24 | * @param cid 25 | * @param page 26 | * @param limit 27 | * @return CommentBo 28 | */ 29 | PageInfo getComments(Integer cid, int page, int limit); 30 | 31 | /** 32 | * 获取文章下的评论 33 | * 34 | * @param commentVoExample 35 | * @param page 36 | * @param limit 37 | * @return CommentVo 38 | */ 39 | PageInfo getCommentsWithPage(CommentVoExample commentVoExample, int page, int limit); 40 | 41 | 42 | /** 43 | * 根据主键查询评论 44 | * 45 | * @param coid 46 | * @return 47 | */ 48 | CommentVo getCommentById(Integer coid); 49 | 50 | 51 | /** 52 | * 删除评论,暂时没用 53 | * 54 | * @param coid 55 | * @param cid 56 | * @throws Exception 57 | */ 58 | void delete(Integer coid, Integer cid); 59 | 60 | /** 61 | * 更新评论状态 62 | * 63 | * @param comments 64 | */ 65 | void update(CommentVo comments); 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/IContentService.java: -------------------------------------------------------------------------------- 1 | package springboot.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import springboot.modal.vo.ContentVo; 5 | import springboot.modal.vo.ContentVoExample; 6 | 7 | /** 8 | * @author tangj 9 | * @date 2018/1/24 21:04 10 | */ 11 | public interface IContentService { 12 | /** 13 | * 发布文章 14 | * 15 | * @param contents 16 | */ 17 | void publish(ContentVo contents); 18 | 19 | /** 20 | * 查询文章返回对跳数据 21 | * 22 | * @param p 23 | * @param limit 24 | * @return 25 | */ 26 | PageInfo getContents(Integer p, Integer limit); 27 | 28 | 29 | /** 30 | * 根据id或slug获取文章 31 | * 32 | * @param id id 33 | * @return ContentVo 34 | */ 35 | ContentVo getContents(String id); 36 | 37 | /** 38 | * 根据主键更新 39 | * 40 | * @param contentVo contentVo 41 | */ 42 | void updateContentByCid(ContentVo contentVo); 43 | 44 | /** 45 | * 查询分类/标签下的文章归档 46 | * 47 | * @param mid mid 48 | * @param page page 49 | * @param limit limit 50 | * @return ContentVo 51 | */ 52 | PageInfo getArticles(Integer mid, int page, int limit); 53 | 54 | /** 55 | * 搜索、分页 56 | * 57 | * @param keyword keyword 58 | * @param page page 59 | * @param limit limit 60 | * @return ContentVo 61 | */ 62 | PageInfo getArticles(String keyword, Integer page, Integer limit); 63 | 64 | /** 65 | * @param commentVoExample 66 | * @param page 67 | * @param limit 68 | * @return 69 | */ 70 | PageInfo getArticlesWithpage(ContentVoExample commentVoExample, Integer page, Integer limit); 71 | 72 | /** 73 | * 根据文章id删除 74 | * 75 | * @param cid 76 | */ 77 | void deleteByCid(Integer cid); 78 | 79 | /** 80 | * 编辑文章 81 | * 82 | * @param contents 83 | */ 84 | void updateArticle(ContentVo contents); 85 | 86 | 87 | /** 88 | * 更新原有文章的category 89 | * 90 | * @param ordinal 91 | * @param newCatefory 92 | */ 93 | void updateCategory(String ordinal, String newCatefory); 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/ILogService.java: -------------------------------------------------------------------------------- 1 | package springboot.service; 2 | 3 | import springboot.modal.vo.LogVo; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author tangj 9 | * @date 2018/1/21 20:50 10 | */ 11 | public interface ILogService { 12 | /** 13 | * 保存操作日志 14 | * 15 | * @param logVo 16 | */ 17 | void insertLog(LogVo logVo); 18 | 19 | /** 20 | * 保存 21 | * @param action 22 | * @param data 23 | * @param ip 24 | * @param authorId 25 | */ 26 | void insertLog(String action, String data, String ip, Integer authorId); 27 | 28 | /** 29 | * 获取日志分页 30 | * @param page 当前页 31 | * @param limit 每页条数 32 | * @return 日志 33 | */ 34 | List getLogs(int page, int limit); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/IMailService.java: -------------------------------------------------------------------------------- 1 | package springboot.service; 2 | 3 | /** 4 | * @author tangj 5 | * @date 2018/5/3 22:06 6 | */ 7 | public interface IMailService { 8 | /** 9 | * 发送简单邮件 10 | * 11 | * @param to 12 | * @param subject 13 | * @param content 14 | */ 15 | void sendSimpleEmail(String to, String subject, String content); 16 | 17 | /** 18 | * 发送html邮件 19 | * 20 | * @param to 21 | * @param subject 22 | * @param content 23 | */ 24 | void sendHtmlMail(String to, String subject, String content); 25 | 26 | /** 27 | * 发送带附件的邮件 28 | * 29 | * @param to 30 | * @param subject 31 | * @param content 32 | * @param filepath 33 | */ 34 | void sendFileMail(String to, String subject, String content, String filepath); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/IMetaService.java: -------------------------------------------------------------------------------- 1 | package springboot.service; 2 | 3 | import springboot.dto.MetaDto; 4 | import springboot.modal.vo.MetaVo; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author tangj 10 | * @date 2018/1/24 21:56 11 | */ 12 | public interface IMetaService { 13 | /** 14 | * 根据类型和名字查询项 15 | * 16 | * @param type 17 | * @param name 18 | * @return 19 | */ 20 | MetaDto getMeta(String type, String name); 21 | 22 | /** 23 | * 根据文章id获取项目个数 24 | * @param mid 25 | * @return 26 | */ 27 | Integer countMeta(Integer mid); 28 | 29 | /** 30 | * 根据类型查询项目列表 31 | * @param types 32 | * @return 33 | */ 34 | List getMetas(String types); 35 | 36 | 37 | /** 38 | * 保存多个项目 39 | * @param cid 40 | * @param names 41 | * @param type 42 | */ 43 | void saveMetas(Integer cid, String names, String type); 44 | 45 | /** 46 | * 保存项目 47 | * @param type 48 | * @param name 49 | * @param mid 50 | */ 51 | void saveMeta(String type, String name, Integer mid); 52 | 53 | /** 54 | * 根据类型查询项目列表,带项目下面的文章数 55 | * @return 56 | */ 57 | List getMetaList(String type, String orderby, int limit); 58 | 59 | /** 60 | * 删除项目 61 | * @param mid 62 | */ 63 | void delete(int mid); 64 | 65 | /** 66 | * 保存项目 67 | * @param metas 68 | */ 69 | void saveMeta(MetaVo metas); 70 | 71 | /** 72 | * 更新项目 73 | * @param metas 74 | */ 75 | void update(MetaVo metas); 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/IOptionService.java: -------------------------------------------------------------------------------- 1 | package springboot.service; 2 | 3 | import springboot.modal.vo.OptionVo; 4 | 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | public interface IOptionService { 9 | void insertOption(OptionVo optionVo); 10 | 11 | void insertOption(String name, String value); 12 | 13 | List getOptions(); 14 | 15 | 16 | /** 17 | * 保存一组配置 18 | * 19 | * @param options 20 | */ 21 | void saveOptions(Map options); 22 | 23 | OptionVo getOptionByName(String name); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/IRelationshipService.java: -------------------------------------------------------------------------------- 1 | package springboot.service; 2 | 3 | import springboot.modal.vo.RelationshipVoKey; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author tangj 9 | * @date 2018/1/24 21:28 10 | */ 11 | public interface IRelationshipService { 12 | /** 13 | * 按主键删除 14 | * 15 | * @param cid 16 | * @param mid 17 | */ 18 | void deleteById(Integer cid, Integer mid); 19 | 20 | /** 21 | * 按主键统计条数 22 | * 23 | * @param cid 24 | * @param mid 25 | * @return 26 | */ 27 | Long countById(Integer cid, Integer mid); 28 | 29 | /** 30 | * 保存对象 31 | * 32 | * @param relationshipVoKey 33 | */ 34 | void insertVo(RelationshipVoKey relationshipVoKey); 35 | 36 | /** 37 | * 根据id搜索 38 | * 39 | * @param cid 40 | * @param mid 41 | * @return 42 | */ 43 | List getRelationshipById(Integer cid, Integer mid); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/ISiteService.java: -------------------------------------------------------------------------------- 1 | package springboot.service; 2 | 3 | import springboot.dto.MetaDto; 4 | import springboot.modal.bo.ArchiveBo; 5 | import springboot.modal.bo.BackResponseBo; 6 | import springboot.modal.bo.StaticticsBo; 7 | import springboot.modal.vo.CommentVo; 8 | import springboot.modal.vo.ContentVo; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * 站点服务 14 | * 15 | * @author tangj 16 | * @date 2018/1/23 11:43 17 | */ 18 | public interface ISiteService { 19 | /** 20 | * 最新收到的评论 21 | * 22 | * @param limit 23 | * @return 24 | */ 25 | List recentComments(int limit); 26 | 27 | /** 28 | * 最新发表的文章 29 | * 30 | * @param limit 31 | * @return 32 | */ 33 | List recentContents(int limit); 34 | 35 | /** 36 | * 查询一条评论 37 | * 38 | * @param coid 39 | * @return 40 | */ 41 | CommentVo getComment(Integer coid); 42 | 43 | /** 44 | * 系统备份 45 | * 46 | * @param bk_type 47 | * @param bk_path 48 | * @param fmt 49 | * @return 50 | * @throws Exception 51 | */ 52 | BackResponseBo backup(String bk_type, String bk_path, String fmt) throws Exception; 53 | 54 | /** 55 | * 获取后台统计数据 56 | * 57 | * @return 58 | */ 59 | StaticticsBo getStatistics(); 60 | 61 | /** 62 | * 查看文章归档 63 | * 64 | * @return 65 | */ 66 | List getArchives(); 67 | 68 | /** 69 | * 获取分类 标签列表 70 | * 71 | * @param type 72 | * @param orderBy 73 | * @param limit 74 | * @return 75 | */ 76 | List metas(String type, String orderBy, int limit); 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/IUserService.java: -------------------------------------------------------------------------------- 1 | package springboot.service; 2 | 3 | import springboot.modal.vo.UserVo; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/1/21 14:22 8 | */ 9 | public interface IUserService { 10 | /** 11 | * 保存用户数据 12 | * 13 | * @param userVo 用户数据 14 | * @return 主键 15 | */ 16 | 17 | Integer insertUser(UserVo userVo); 18 | 19 | /** 20 | * 通过uid查找对象 21 | * @param uid 22 | * @return 23 | */ 24 | UserVo queryUserById(Integer uid); 25 | 26 | /** 27 | * 用戶登录 28 | * @param username 29 | * @param password 30 | * @return 31 | */ 32 | UserVo login(String username, String password); 33 | 34 | /** 35 | * 根据主键更新user对象 36 | * @param userVo 37 | * @return 38 | */ 39 | void updateByUid(UserVo userVo); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/impl/AttachServiceImpl.java: -------------------------------------------------------------------------------- 1 | package springboot.service.impl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import org.springframework.stereotype.Service; 6 | import springboot.dao.AttachVoMapper; 7 | import springboot.modal.vo.AttachVo; 8 | import springboot.modal.vo.AttachVoExample; 9 | import springboot.service.IAttachService; 10 | import springboot.util.DateKit; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | 15 | @Service 16 | public class AttachServiceImpl implements IAttachService { 17 | 18 | @Resource 19 | private AttachVoMapper attachDao; 20 | 21 | @Override 22 | public PageInfo getAttachs(Integer page, Integer limit) { 23 | PageHelper.startPage(page, limit); 24 | AttachVoExample attachVoExample = new AttachVoExample(); 25 | attachVoExample.setOrderByClause("id desc"); 26 | List attachVos = attachDao.selectByExample(attachVoExample); 27 | return new PageInfo<>(attachVos); 28 | } 29 | 30 | @Override 31 | public void save(String fname, String fkey, String ftype, Integer author) { 32 | AttachVo attach = new AttachVo(); 33 | attach.setFname(fname); 34 | attach.setAuthorId(author); 35 | attach.setFkey(fkey); 36 | attach.setFtype(ftype); 37 | attach.setCreated(DateKit.getCurrentUnixTime()); 38 | attachDao.insertSelective(attach); 39 | } 40 | 41 | @Override 42 | public AttachVo selectById(Integer id) { 43 | if (null != id) { 44 | return attachDao.selectByPrimaryKey(id); 45 | } 46 | return null; 47 | } 48 | 49 | @Override 50 | public void deleteById(Integer id) { 51 | if (null != id) { 52 | attachDao.deleteByPrimaryKey(id); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/impl/LogServiceImpl.java: -------------------------------------------------------------------------------- 1 | package springboot.service.impl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import org.springframework.stereotype.Service; 5 | import springboot.constant.WebConst; 6 | import springboot.dao.LogVoMapper; 7 | import springboot.modal.vo.LogVo; 8 | import springboot.modal.vo.LogVoExample; 9 | import springboot.service.ILogService; 10 | import springboot.util.DateKit; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | 15 | /** 16 | * @author tangj 17 | * @date 2018/1/21 20:52 18 | */ 19 | @Service 20 | public class LogServiceImpl implements ILogService{ 21 | 22 | @Resource 23 | private LogVoMapper logDao; 24 | 25 | @Override 26 | public void insertLog(LogVo logVo) { 27 | logDao.insert(logVo); 28 | } 29 | 30 | @Override 31 | public void insertLog(String action, String data, String ip, Integer authorId) { 32 | LogVo logs = new LogVo(); 33 | logs.setAction(action); 34 | logs.setData(data); 35 | logs.setIp(ip); 36 | logs.setAuthorId(authorId); 37 | logs.setCreated(DateKit.getCurrentUnixTime()); 38 | logDao.insert(logs); 39 | } 40 | 41 | @Override 42 | public List getLogs(int page, int limit) { 43 | if (page <= 0) { 44 | page = 1; 45 | } 46 | if (limit < 1 || limit > WebConst.MAX_POSTS) { 47 | limit = 10; 48 | } 49 | LogVoExample logVoExample = new LogVoExample(); 50 | logVoExample.setOrderByClause("id desc"); 51 | PageHelper.startPage((page - 1) * limit, limit); 52 | List logVos = logDao.selectByExample(logVoExample); 53 | return logVos; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/impl/MailServiceImpl.java: -------------------------------------------------------------------------------- 1 | package springboot.service.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.core.io.FileSystemResource; 6 | import org.springframework.mail.SimpleMailMessage; 7 | import org.springframework.mail.javamail.JavaMailSender; 8 | import org.springframework.mail.javamail.MimeMessageHelper; 9 | import org.springframework.stereotype.Component; 10 | import org.thymeleaf.TemplateEngine; 11 | import org.thymeleaf.context.Context; 12 | import springboot.service.IMailService; 13 | 14 | import javax.annotation.Resource; 15 | import javax.mail.MessagingException; 16 | import javax.mail.internet.MimeMessage; 17 | import java.io.File; 18 | 19 | /** 20 | * @author janti 21 | * @date 2018/5/3 22:07 22 | */ 23 | @Component 24 | public class MailServiceImpl implements IMailService { 25 | 26 | @Autowired 27 | private JavaMailSender mailSender; 28 | 29 | 30 | @Resource 31 | private TemplateEngine templateEngine; 32 | 33 | @Value("${spring.mail.username}") 34 | private String mailFrom; 35 | 36 | /** 37 | * 发送简单邮件 38 | * 39 | * @param to 40 | * @param subject 41 | * @param content 42 | */ 43 | @Override 44 | public void sendSimpleEmail(String to,String subject,String content) { 45 | SimpleMailMessage message = new SimpleMailMessage(); 46 | message.setFrom(mailFrom); 47 | message.setTo(to); 48 | message.setSubject(subject); 49 | message.setText(content); 50 | mailSender.send(message); 51 | } 52 | 53 | /** 54 | * 发送html邮件 55 | * 56 | * @param to 57 | * @param subject 58 | * @param content 59 | */ 60 | @Override 61 | public void sendHtmlMail(String to, String subject, String content) { 62 | MimeMessage mimeMessage = mailSender.createMimeMessage(); 63 | try { 64 | //true表示需要创建一个multipart message 65 | MimeMessageHelper helper = new MimeMessageHelper(mimeMessage,true); 66 | helper.setFrom(mailFrom); 67 | helper.setTo(to); 68 | helper.setSubject(subject); 69 | helper.setText(content,true); 70 | mailSender.send(mimeMessage); 71 | } catch (MessagingException e) { 72 | e.printStackTrace(); 73 | } 74 | } 75 | /** 76 | * 发送带附件的邮件 77 | * 78 | * @param to 79 | * @param subject 80 | * @param content 81 | * @param filepath 82 | */ 83 | @Override 84 | public void sendFileMail(String to, String subject, String content, String filepath) { 85 | MimeMessage mimeMessage = mailSender.createMimeMessage(); 86 | try { 87 | MimeMessageHelper helper = new MimeMessageHelper(mimeMessage,true); 88 | helper.setFrom(mailFrom); 89 | helper.setTo(to); 90 | helper.setSubject(subject); 91 | helper.setText(content,true); 92 | 93 | FileSystemResource file = new FileSystemResource(new File(filepath)); 94 | String fileName = filepath.substring(filepath.lastIndexOf(File.separator)); 95 | helper.addAttachment(fileName,file); 96 | 97 | mailSender.send(mimeMessage); 98 | 99 | }catch (Exception e){ 100 | e.printStackTrace(); 101 | } 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/impl/OptionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package springboot.service.impl; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.stereotype.Service; 6 | import springboot.dao.OptionVoMapper; 7 | import springboot.modal.vo.OptionVo; 8 | import springboot.modal.vo.OptionVoExample; 9 | import springboot.service.IOptionService; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | import java.util.Map; 14 | 15 | @Service 16 | public class OptionServiceImpl implements IOptionService { 17 | 18 | private static final Logger LOGGER = LoggerFactory.getLogger(OptionServiceImpl.class); 19 | 20 | @Resource 21 | private OptionVoMapper optionalDao; 22 | 23 | @Override 24 | public void insertOption(OptionVo optionVo) { 25 | optionalDao.insertSelective(optionVo); 26 | } 27 | 28 | @Override 29 | public void insertOption(String name, String value) { 30 | LOGGER.debug("Enter insertOption method:name={},value={}", name, value); 31 | OptionVo optionVo = new OptionVo(); 32 | 33 | optionVo.setName(name); 34 | optionVo.setValue(value); 35 | optionVo = optionalDao.selectByPrimaryKey(name); 36 | if ( optionVo == null) { 37 | optionVo = new OptionVo(); 38 | optionVo.setName(name); 39 | optionVo.setValue(value); 40 | optionalDao.insertSelective(optionVo); 41 | } else { 42 | optionVo = new OptionVo(); 43 | optionVo.setName(name); 44 | optionVo.setValue(value); 45 | optionalDao.updateByPrimaryKeySelective(optionVo); 46 | } 47 | LOGGER.debug("Exit insertOption method."); 48 | } 49 | 50 | @Override 51 | public List getOptions() { 52 | return optionalDao.selectByExample(new OptionVoExample()); 53 | } 54 | 55 | @Override 56 | public void saveOptions(Map options) { 57 | if (null != options && !options.isEmpty()) { 58 | options.forEach(this::insertOption); 59 | } 60 | } 61 | 62 | @Override 63 | public OptionVo getOptionByName(String name) { 64 | return null; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/impl/RedisService.java: -------------------------------------------------------------------------------- 1 | package springboot.service.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.data.redis.core.RedisTemplate; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.Collection; 8 | import java.util.Date; 9 | import java.util.Set; 10 | import java.util.concurrent.TimeUnit; 11 | import java.util.stream.Collectors; 12 | import java.util.stream.Stream; 13 | 14 | @Component 15 | public class RedisService { 16 | @Autowired 17 | private RedisTemplate redisTemplate; 18 | 19 | /** 20 | * 默认过期时长,单位:秒 21 | */ 22 | public static final long DEFAULT_EXPIRE = 60 * 60 * 24; 23 | 24 | /** 25 | * 不设置过期时长 26 | */ 27 | public static final long NOT_EXPIRE = -1; 28 | 29 | 30 | 31 | 32 | public boolean existsKey(String key) { 33 | return redisTemplate.hasKey(key); 34 | } 35 | 36 | /** 37 | * 重名名key,如果newKey已经存在,则newKey的原值被覆盖 38 | * 39 | * @param oldKey 40 | * @param newKey 41 | */ 42 | public void renameKey(String oldKey, String newKey) { 43 | redisTemplate.rename(oldKey, newKey); 44 | } 45 | 46 | /** 47 | * newKey不存在时才重命名 48 | * 49 | * @param oldKey 50 | * @param newKey 51 | * @return 修改成功返回true 52 | */ 53 | public boolean renameKeyNotExist(String oldKey, String newKey) { 54 | return redisTemplate.renameIfAbsent(oldKey, newKey); 55 | } 56 | 57 | /** 58 | * 删除key 59 | * 60 | * @param key 61 | */ 62 | public void deleteKey(String key) { 63 | redisTemplate.delete(key); 64 | } 65 | 66 | /** 67 | * 删除多个key 68 | * 69 | * @param keys 70 | */ 71 | public void deleteKey(String... keys) { 72 | Set kSet = Stream.of(keys).map(k -> k).collect(Collectors.toSet()); 73 | redisTemplate.delete(kSet); 74 | } 75 | 76 | /** 77 | * 删除Key的集合 78 | * 79 | * @param keys 80 | */ 81 | public void deleteKey(Collection keys) { 82 | Set kSet = keys.stream().map(k -> k).collect(Collectors.toSet()); 83 | redisTemplate.delete(kSet); 84 | } 85 | 86 | /** 87 | * 设置key的生命周期 88 | * 89 | * @param key 90 | * @param time 91 | * @param timeUnit 92 | */ 93 | public void expireKey(String key, long time, TimeUnit timeUnit) { 94 | redisTemplate.expire(key, time, timeUnit); 95 | } 96 | 97 | /** 98 | * 指定key在指定的日期过期 99 | * 100 | * @param key 101 | * @param date 102 | */ 103 | public void expireKeyAt(String key, Date date) { 104 | redisTemplate.expireAt(key, date); 105 | } 106 | 107 | /** 108 | * 查询key的生命周期 109 | * 110 | * @param key 111 | * @param timeUnit 112 | * @return 113 | */ 114 | public long getKeyExpire(String key, TimeUnit timeUnit) { 115 | return redisTemplate.getExpire(key, timeUnit); 116 | } 117 | 118 | /** 119 | * 将key设置为永久有效 120 | * 121 | * @param key 122 | */ 123 | public void persistKey(String key) { 124 | redisTemplate.persist(key); 125 | } 126 | 127 | 128 | } 129 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/impl/RelationshipServiceImpl.java: -------------------------------------------------------------------------------- 1 | package springboot.service.impl; 2 | 3 | import org.springframework.stereotype.Service; 4 | import springboot.dao.RelationshipVoMapper; 5 | import springboot.modal.vo.RelationshipVoExample; 6 | import springboot.modal.vo.RelationshipVoKey; 7 | import springboot.service.IRelationshipService; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | /** 13 | * @author tangj 14 | * @date 2018/1/24 21:33 15 | */ 16 | @Service 17 | public class RelationshipServiceImpl implements IRelationshipService { 18 | 19 | @Resource 20 | private RelationshipVoMapper relationshipVoDao; 21 | 22 | @Override 23 | public void deleteById(Integer cid, Integer mid) { 24 | RelationshipVoExample relationshipVoExample = new RelationshipVoExample(); 25 | RelationshipVoExample.Criteria criteria = relationshipVoExample.createCriteria(); 26 | if (cid != null) { 27 | criteria.andCidEqualTo(cid); 28 | } 29 | if (mid != null) { 30 | criteria.andMidEqualTo(mid); 31 | } 32 | relationshipVoDao.deleteByExample(relationshipVoExample); 33 | } 34 | 35 | @Override 36 | public Long countById(Integer cid, Integer mid) { 37 | RelationshipVoExample relationshipVoExample = new RelationshipVoExample(); 38 | RelationshipVoExample.Criteria criteria = relationshipVoExample.createCriteria(); 39 | if (cid != null) { 40 | criteria.andCidEqualTo(cid); 41 | } 42 | if (mid != null) { 43 | criteria.andMidEqualTo(mid); 44 | } 45 | long num = relationshipVoDao.countByExample(relationshipVoExample); 46 | return num; 47 | } 48 | 49 | @Override 50 | public void insertVo(RelationshipVoKey relationshipVoKey) { 51 | relationshipVoDao.insert(relationshipVoKey); 52 | } 53 | 54 | @Override 55 | public List getRelationshipById(Integer cid, Integer mid) { 56 | RelationshipVoExample relationshipVoExample = new RelationshipVoExample(); 57 | RelationshipVoExample.Criteria criteria = relationshipVoExample.createCriteria(); 58 | if (cid != null) { 59 | criteria.andCidEqualTo(cid); 60 | } 61 | if (mid != null) { 62 | criteria.andMidEqualTo(mid); 63 | } 64 | return relationshipVoDao.selectByExample(relationshipVoExample); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/springboot/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package springboot.service.impl; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.springframework.stereotype.Service; 5 | import springboot.dao.UserVoMapper; 6 | import springboot.exception.TipException; 7 | import springboot.modal.vo.UserVo; 8 | import springboot.modal.vo.UserVoExample; 9 | import springboot.service.IUserService; 10 | import springboot.util.MyUtils; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | 15 | /** 16 | * @author tangj 17 | * @date 2018/1/21 14:31 18 | */ 19 | @Service 20 | public class UserServiceImpl implements IUserService { 21 | 22 | @Resource 23 | private UserVoMapper userDao; 24 | 25 | @Override 26 | public Integer insertUser(UserVo userVo) { 27 | Integer uid = null; 28 | if (StringUtils.isNotBlank(userVo.getUsername()) && StringUtils.isNotBlank(userVo.getEmail())) { 29 | //用户密码摘要 30 | String encodePwd = MyUtils.MD5encode(userVo.getUsername() + userVo.getPassword()); 31 | userVo.setPassword(encodePwd); 32 | userDao.insertSelective(userVo); 33 | } 34 | return userVo.getUid(); 35 | } 36 | 37 | @Override 38 | public UserVo queryUserById(Integer uid) { 39 | UserVo userVo = null; 40 | if (uid != null) { 41 | userVo = userDao.selectByPrimaryKey(uid); 42 | } 43 | return userVo; 44 | } 45 | 46 | @Override 47 | public UserVo login(String username, String password) { 48 | if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) { 49 | throw new TipException("用户名和密码为空"); 50 | } 51 | UserVoExample example = new UserVoExample(); 52 | UserVoExample.Criteria criteria = example.createCriteria(); 53 | criteria.andUsernameEqualTo(username); 54 | long count = userDao.countByExample(example); 55 | if (count < 1) { 56 | throw new TipException("不存在该用户"); 57 | } 58 | String pwd = MyUtils.MD5encode(username + password); 59 | criteria.andPasswordEqualTo(pwd); 60 | List userVoList = userDao.selectByExample(example); 61 | if (userVoList.size() != 1) { 62 | throw new TipException("用户名或者密码错误"); 63 | } 64 | return userVoList.get(0); 65 | } 66 | 67 | @Override 68 | public void updateByUid(UserVo userVo) { 69 | if (null == userVo || null == userVo.getUid()) { 70 | throw new TipException("userVo is null"); 71 | } 72 | int i = userDao.updateByPrimaryKeySelective(userVo); 73 | if (i != 1) { 74 | throw new TipException("update user by uid and retrun is not one"); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/AdminCommons.java: -------------------------------------------------------------------------------- 1 | package springboot.util; 2 | 3 | 4 | import org.apache.commons.lang3.StringUtils; 5 | import org.springframework.stereotype.Component; 6 | import springboot.modal.vo.MetaVo; 7 | 8 | /** 9 | * 后台公共函数 10 | *

11 | * 12 | */ 13 | @Component 14 | public final class AdminCommons { 15 | 16 | /** 17 | * 判断category和cat的交集 18 | * 19 | * @param cats 20 | * @return 21 | */ 22 | public static boolean exist_cat(MetaVo category, String cats) { 23 | String[] arr = StringUtils.split(cats, ","); 24 | if (null != arr && arr.length > 0) { 25 | for (String c : arr) { 26 | if (c.trim().equals(category.getName())) { 27 | return true; 28 | } 29 | } 30 | } 31 | return false; 32 | } 33 | 34 | private static final String[] COLORS = {"jantent", "primary", "success", "info", "warning", "danger", "inverse", "purple", "pink"}; 35 | 36 | public static String rand_color() { 37 | int r = Tools.rand(0, COLORS.length - 1); 38 | return COLORS[r]; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/GsonUtils.java: -------------------------------------------------------------------------------- 1 | package springboot.util; 2 | 3 | import com.google.gson.Gson; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | /** 7 | * Gson转换工具 8 | * 9 | * @author tangj 10 | * @date 2018/1/23 22:48 11 | */ 12 | public class GsonUtils { 13 | private static final Gson gson = new Gson(); 14 | 15 | public static String toJsonString(Object object) { 16 | 17 | return object == null ? null : gson.toJson(object); 18 | } 19 | 20 | /** 21 | * 将json字符串转成对象 22 | * 23 | * @param jstr 24 | * @param clazz 25 | * @return 26 | */ 27 | public static Object jsonToObject(String jstr, Class clazz) { 28 | Object object = null; 29 | 30 | if (StringUtils.isNotBlank(jstr)) { 31 | object = gson.fromJson(jstr, clazz); 32 | } 33 | return object; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/IpUtil.java: -------------------------------------------------------------------------------- 1 | package springboot.util; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import java.net.InetAddress; 5 | import java.net.NetworkInterface; 6 | import java.net.SocketException; 7 | import java.util.Enumeration; 8 | 9 | public class IpUtil { 10 | /** 11 | * 获取IP信息 12 | * 13 | * @param request 14 | * @return 15 | */ 16 | public static String getIpAddrByRequest(HttpServletRequest request) { 17 | String ip = request.getHeader("x-forwarded-for"); 18 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 19 | ip = request.getHeader("Proxy-Client-IP"); 20 | } 21 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 22 | ip = request.getHeader("WL-Proxy-Client-IP"); 23 | } 24 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 25 | ip = request.getRemoteAddr(); 26 | } 27 | return ip; 28 | } 29 | 30 | /** 31 | * @return 本机IPSocketException 32 | * @throws SocketException 33 | */ 34 | public static String getRealIp() throws SocketException { 35 | String localip = null;// 本地IP,如果没有配置外网IP则返回它 36 | String netip = null;// 外网IP 37 | 38 | Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces(); 39 | InetAddress ip = null; 40 | boolean finded = false;// 是否找到外网IP 41 | while (netInterfaces.hasMoreElements() && !finded) { 42 | NetworkInterface ni = netInterfaces.nextElement(); 43 | Enumeration address = ni.getInetAddresses(); 44 | while (address.hasMoreElements()) { 45 | ip = address.nextElement(); 46 | if (!ip.isSiteLocalAddress() && !ip.isLoopbackAddress() && !ip.getHostAddress().contains(":")) {// 外网IP 47 | netip = ip.getHostAddress(); 48 | finded = true; 49 | break; 50 | } else if (ip.isSiteLocalAddress() && !ip.isLoopbackAddress() && !ip.getHostAddress().contains(":")) {// 内网IP 51 | localip = ip.getHostAddress(); 52 | } 53 | } 54 | } 55 | 56 | if (netip != null && !"".equals(netip)) { 57 | return netip; 58 | } else { 59 | return localip; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/LogAspect.java: -------------------------------------------------------------------------------- 1 | package springboot.util; 2 | 3 | import org.aspectj.lang.JoinPoint; 4 | import org.aspectj.lang.annotation.AfterReturning; 5 | import org.aspectj.lang.annotation.Before; 6 | import org.aspectj.lang.annotation.Pointcut; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.stereotype.Component; 10 | import org.aspectj.lang.annotation.Aspect; 11 | import org.springframework.web.context.request.RequestContextHolder; 12 | import org.springframework.web.context.request.ServletRequestAttributes; 13 | 14 | import javax.servlet.http.HttpServletRequest; 15 | import java.util.Arrays; 16 | 17 | /** 18 | * 接口AOP 19 | */ 20 | @Aspect 21 | @Component 22 | public class LogAspect { 23 | 24 | private static final Logger logger = LoggerFactory.getLogger(LogAspect.class); 25 | 26 | @Pointcut("execution(public * springboot.controller..*.*(..))") 27 | public void webLog() { 28 | } 29 | 30 | @Before("webLog()") 31 | public void doBefore(JoinPoint joinPoint) throws Throwable { 32 | // 接收到请求,记录请求内容 33 | ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); 34 | HttpServletRequest request = attributes.getRequest(); 35 | // 记录下请求内容 36 | logger.info("URL : " + request.getRequestURL().toString() + ",IP : " + request.getRemoteAddr() + ",CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName() + ",ARGS : " + Arrays.toString(joinPoint.getArgs())); 37 | } 38 | 39 | @AfterReturning(returning = "object", pointcut = "webLog()") 40 | public void doAfterReturning(Object object) throws Throwable { 41 | // 处理完毕,返回内容 42 | logger.info("RESPONSE:" + object); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/PortChecker.java: -------------------------------------------------------------------------------- 1 | package springboot.util; 2 | 3 | 4 | import java.net.InetSocketAddress; 5 | import java.net.Socket; 6 | 7 | /** 8 | * 检查端口是否开放 9 | * 10 | * @author tangj 11 | * @date 2018/4/15 15:33 12 | */ 13 | public class PortChecker { 14 | public static boolean checkPort(String ip,int port){ 15 | return checkPort(ip,port,1000); 16 | } 17 | 18 | public static boolean checkPort(String ip,int port,int timeout){ 19 | if (port<0){ 20 | // 通常端口小于0时,该端口对应的服务应小于0 21 | return true; 22 | } 23 | String ipAddr = "127.0.0.1"; 24 | if (null != ip){ 25 | ipAddr = ip; 26 | } 27 | boolean invaild = false; 28 | try { 29 | Socket socket = new Socket(); 30 | InetSocketAddress address = new InetSocketAddress(ipAddr,port); 31 | socket.connect(address,timeout); 32 | socket.close(); 33 | }catch (Exception e){ 34 | invaild = true; 35 | } 36 | return invaild; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/RedisKeyUtil.java: -------------------------------------------------------------------------------- 1 | package springboot.util; 2 | 3 | /** 4 | * redisKey设计 5 | */ 6 | public class RedisKeyUtil { 7 | 8 | /** 9 | * redis的key 10 | * 形式为: 11 | * 表名:主键名:主键值:列名 12 | * 13 | * @param tableName 表名 14 | * @param majorKey 主键名 15 | * @param majorKeyValue 主键值 16 | * @param column 列名 17 | * @return 18 | */ 19 | public static String getKeyWithColumn(String tableName,String majorKey,String majorKeyValue,String column){ 20 | StringBuffer buffer = new StringBuffer(); 21 | buffer.append(tableName).append(":"); 22 | buffer.append(majorKey).append(":"); 23 | buffer.append(majorKeyValue).append(":"); 24 | buffer.append(column); 25 | return buffer.toString(); 26 | } 27 | /** 28 | * redis的key 29 | * 形式为: 30 | * 表名:主键名:主键值 31 | * 32 | * @param tableName 表名 33 | * @param majorKey 主键名 34 | * @param majorKeyValue 主键值 35 | * @return 36 | */ 37 | public static String getKey(String tableName,String majorKey,String majorKeyValue){ 38 | StringBuffer buffer = new StringBuffer(); 39 | buffer.append(tableName).append(":"); 40 | buffer.append(majorKey).append(":"); 41 | buffer.append(majorKeyValue); 42 | return buffer.toString(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/Tools.java: -------------------------------------------------------------------------------- 1 | package springboot.util; 2 | 3 | import sun.misc.BASE64Decoder; 4 | import sun.misc.BASE64Encoder; 5 | 6 | import javax.crypto.Cipher; 7 | import javax.crypto.spec.SecretKeySpec; 8 | import java.io.File; 9 | import java.io.FileInputStream; 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.nio.channels.FileChannel; 13 | import java.util.Random; 14 | 15 | /** 16 | * @author tangj 17 | * @date 2018/1/21 20:40 18 | */ 19 | public class Tools { 20 | private static final Random random = new Random(); 21 | 22 | public static void copyFileUsingFileChannels(File source, File dest) throws IOException { 23 | FileChannel inputChannel = null; 24 | FileChannel outputChannel = null; 25 | try { 26 | inputChannel = new FileInputStream(source).getChannel(); 27 | outputChannel = new FileOutputStream(dest).getChannel(); 28 | outputChannel.transferFrom(inputChannel, 0, inputChannel.size()); 29 | } finally { 30 | assert inputChannel != null; 31 | inputChannel.close(); 32 | assert outputChannel != null; 33 | outputChannel.close(); 34 | } 35 | } 36 | 37 | public static int rand(int min, int max) { 38 | return random.nextInt(max) % (max - min + 1) + min; 39 | } 40 | 41 | public static String flowAutoShow(int value) { 42 | int kb = 1024; 43 | int mb = 1048576; 44 | int gb = 1073741824; 45 | if (Math.abs(value) > gb) { 46 | return Math.round(value / gb) + "GB"; 47 | } else if (Math.abs(value) > mb) { 48 | return Math.round(value / mb) + "MB"; 49 | } else if (Math.abs(value) > kb) { 50 | return Math.round(value / kb) + "KB"; 51 | } 52 | return Math.round(value) + ""; 53 | } 54 | 55 | public static String enAes(String data, String key) throws Exception { 56 | Cipher cipher = Cipher.getInstance("AES"); 57 | SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); 58 | cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); 59 | byte[] encryptedBytes = cipher.doFinal(data.getBytes()); 60 | return new BASE64Encoder().encode(encryptedBytes); 61 | } 62 | 63 | public static String deAes(String data, String key) throws Exception { 64 | Cipher cipher = Cipher.getInstance("AES"); 65 | SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); 66 | cipher.init(Cipher.DECRYPT_MODE, secretKeySpec); 67 | byte[] cipherTextBytes = new BASE64Decoder().decodeBuffer(data); 68 | byte[] decValue = cipher.doFinal(cipherTextBytes); 69 | return new String(decValue); 70 | } 71 | 72 | /** 73 | * 判断字符串是否为数字和有正确的值 74 | * 75 | * @param str 76 | * @return 77 | */ 78 | public static boolean isNumber(String str) { 79 | // Pattern pattern=Pattern.compile("[0-9]*"); 80 | // return pattern.matcher(str).matches(); 81 | if (null != str && 0 != str.trim().length() && str.matches("\\d*")) { 82 | return true; 83 | } 84 | 85 | return false; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/ZipUtils.java: -------------------------------------------------------------------------------- 1 | package springboot.util; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileOutputStream; 6 | import java.util.zip.ZipEntry; 7 | import java.util.zip.ZipOutputStream; 8 | 9 | /** 10 | * @author tangj 11 | * @date 2018/1/23 14:03 12 | */ 13 | public class ZipUtils { 14 | public static void zipFolder(String srcFolder, String destZipFile) throws Exception { 15 | FileOutputStream fileWriter = new FileOutputStream(destZipFile); 16 | ZipOutputStream zip = new ZipOutputStream(fileWriter); 17 | 18 | addFolderToZip("", srcFolder, zip); 19 | zip.flush(); 20 | zip.close(); 21 | } 22 | 23 | public static void addFileToZip(String path, String srcFile, ZipOutputStream zip) 24 | throws Exception { 25 | 26 | File folder = new File(srcFile); 27 | if (folder.isDirectory()) { 28 | addFolderToZip(path, srcFile, zip); 29 | } else { 30 | byte[] buf = new byte[1024]; 31 | int len; 32 | FileInputStream in = new FileInputStream(srcFile); 33 | zip.putNextEntry(new ZipEntry(path + "/" + folder.getName())); 34 | while ((len = in.read(buf)) > 0) { 35 | zip.write(buf, 0, len); 36 | } 37 | } 38 | } 39 | 40 | public static void addFolderToZip(String path, String srcFolder, ZipOutputStream zip) throws Exception { 41 | File folder = new File(srcFolder); 42 | if (null != path && folder.isDirectory()) { 43 | for (String fileName : folder.list()) { 44 | if (path.equals("")) { 45 | addFileToZip(folder.getName(), srcFolder + "/" + fileName, zip); 46 | } else { 47 | addFileToZip(path + "/" + folder.getName(), srcFolder + "/" + fileName, zip); 48 | } 49 | } 50 | } 51 | } 52 | 53 | public static void zipFile(String filePath, String zipPath) throws Exception{ 54 | byte[] buffer = new byte[1024]; 55 | FileOutputStream fos = new FileOutputStream(zipPath); 56 | ZipOutputStream zos = new ZipOutputStream(fos); 57 | ZipEntry ze= new ZipEntry("spy.log"); 58 | zos.putNextEntry(ze); 59 | FileInputStream in = new FileInputStream(filePath); 60 | int len; 61 | while ((len = in.read(buffer)) > 0) { 62 | zos.write(buffer, 0, len); 63 | } 64 | in.close(); 65 | zos.closeEntry(); 66 | //remember close it 67 | zos.close(); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/backup/Column.java: -------------------------------------------------------------------------------- 1 | package springboot.util.backup; 2 | 3 | /** 4 | * @author tangj 5 | * @date 2018/1/23 20:51 6 | */ 7 | public class Column { 8 | private String name; 9 | private String typeName; 10 | private int dataType; 11 | 12 | public Column(String name, String typeName, int dataType) { 13 | this.name = name; 14 | this.typeName = typeName; 15 | this.dataType = dataType; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public String getTypeName() { 23 | return typeName; 24 | } 25 | 26 | public int getDataType() { 27 | return dataType; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return "Column{" + 33 | "name='" + name + '\'' + 34 | ", typeName='" + typeName + '\'' + 35 | ", dataType=" + dataType + 36 | '}'; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/backup/ColumnCollection.java: -------------------------------------------------------------------------------- 1 | package springboot.util.backup; 2 | 3 | import java.util.ArrayList; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/1/23 20:57 8 | */ 9 | public class ColumnCollection extends ArrayList{ 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/backup/FK.java: -------------------------------------------------------------------------------- 1 | package springboot.util.backup; 2 | 3 | /** 4 | * @author tangj 5 | * @date 2018/1/23 20:58 6 | */ 7 | public class FK { 8 | private String column; 9 | private Table referenceTable; 10 | private String referencePK; 11 | 12 | public Table getReferenceTable() { 13 | return referenceTable; 14 | } 15 | 16 | public FK(String column, Table referenceTable, String referencePK) { 17 | this.column = column; 18 | this.referenceTable = referenceTable; 19 | this.referencePK = referencePK; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return "FK [column=" + column + ", referenceTable=" + referenceTable 25 | + ", referencePK=" + referencePK + "]"; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/backup/FKCollection.java: -------------------------------------------------------------------------------- 1 | package springboot.util.backup; 2 | 3 | import java.util.ArrayList; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/1/23 20:59 8 | */ 9 | public class FKCollection extends ArrayList { 10 | private static final long serialVersionUID = -972085209611643212L; 11 | 12 | public boolean isReferenced(Table referenceTable) { 13 | for (FK fk : this) { 14 | if (fk.getReferenceTable().equals(referenceTable)) { 15 | return true; 16 | } 17 | } 18 | return false; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/backup/Table.java: -------------------------------------------------------------------------------- 1 | package springboot.util.backup; 2 | 3 | /** 4 | * @author tangj 5 | * @date 2018/1/23 20:59 6 | */ 7 | public class Table { 8 | private String name; 9 | private ColumnCollection columns; 10 | private FKCollection constraints; 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public Table(String name) { 17 | this.name = name; 18 | this.columns = new ColumnCollection(); 19 | this.constraints = new FKCollection(); 20 | } 21 | 22 | public ColumnCollection getColumns() { 23 | return columns; 24 | } 25 | 26 | public FKCollection getConstraints() { 27 | return constraints; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return "Table [name=" + name + "]"; 33 | } 34 | 35 | public boolean isReferenced(Table referenceTable){ 36 | return constraints.isReferenced(referenceTable); 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/backup/TableCollection.java: -------------------------------------------------------------------------------- 1 | package springboot.util.backup; 2 | 3 | import java.util.ArrayList; 4 | 5 | /** 6 | * @author tangj 7 | * @date 2018/1/23 21:02 8 | */ 9 | public class TableCollection extends ArrayList{ 10 | /** 11 | * Sort tables according to constraints 12 | */ 13 | public void sort(){ 14 | for(int i = 0 ; i < size(); ){ 15 | boolean corrupted = false; 16 | for(int j = i + 1; j < size(); j++){ 17 | if(get(i).isReferenced(get(j))){ 18 | Table table = get(i); 19 | remove(table); 20 | add(table); 21 | corrupted = true; 22 | break; 23 | } 24 | } 25 | if(!corrupted){ 26 | i++; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/backup/db/Column.java: -------------------------------------------------------------------------------- 1 | package springboot.util.backup.db; 2 | 3 | public class Column { 4 | private String catalogName; 5 | private String schemaName; 6 | private String tableName; 7 | private String name; 8 | private String label; 9 | private int type; 10 | private String typeName; 11 | private String columnClassName; 12 | private int displaySize; 13 | private int precision; 14 | private int scale; 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public String getLabel() { 21 | return label; 22 | } 23 | 24 | public int getType() { 25 | return type; 26 | } 27 | 28 | public void setCatalogName(String catalogName) { 29 | this.catalogName = catalogName; 30 | } 31 | 32 | public void setSchemaName(String schemaName) { 33 | this.schemaName = schemaName; 34 | } 35 | 36 | public void setTableName(String tableName) { 37 | this.tableName = tableName; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | 44 | public void setLabel(String label) { 45 | this.label = label; 46 | } 47 | 48 | public void setType(int type) { 49 | this.type = type; 50 | } 51 | 52 | public void setTypeName(String typeName) { 53 | this.typeName = typeName; 54 | } 55 | 56 | public void setColumnClassName(String columnClassName) { 57 | this.columnClassName = columnClassName; 58 | } 59 | 60 | public void setDisplaySize(int displaySize) { 61 | this.displaySize = displaySize; 62 | } 63 | 64 | public void setPrecision(int precision) { 65 | this.precision = precision; 66 | } 67 | 68 | public void setScale(int scale) { 69 | this.scale = scale; 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | return "Column [catalogName=" + catalogName + ", schemaName=" 75 | + schemaName + ", tableName=" + tableName + ", name=" + name 76 | + ", label=" + label + ", type=" + type + ", typeName=" 77 | + typeName + ", columnClassName=" + columnClassName 78 | + ", displaySize=" + displaySize + ", precision=" + precision 79 | + ", scale=" + scale + "]"; 80 | } 81 | 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/backup/db/ColumnCollection.java: -------------------------------------------------------------------------------- 1 | package springboot.util.backup.db; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class ColumnCollection extends ArrayList{ 6 | 7 | private static final long serialVersionUID = -3399188477563370223L; 8 | 9 | public int indexByLabel(String label){ 10 | for(int i = 0; i < this.size(); i++){ 11 | if(get(i).getLabel().equals(label)){ 12 | return i; 13 | } 14 | } 15 | return -1; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | if(size() == 0){ 21 | return "Columns is empty"; 22 | } 23 | String s = "Columns : {" + String.valueOf(get(0).getLabel()); 24 | for(int i = 1; i < size(); i++){ 25 | s += ", " + String.valueOf(get(i).getLabel()); 26 | } 27 | s += "}"; 28 | return s; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/backup/db/DataTable.java: -------------------------------------------------------------------------------- 1 | package springboot.util.backup.db; 2 | 3 | import java.sql.Connection; 4 | import java.sql.ResultSet; 5 | import java.sql.ResultSetMetaData; 6 | import java.sql.SQLException; 7 | import java.util.ArrayList; 8 | 9 | public class DataTable extends ArrayList { 10 | /** 11 | * 12 | */ 13 | private static final long serialVersionUID = -3057968190529400383L; 14 | 15 | public static DataTable execute(Connection connection, String query) 16 | throws SQLException { 17 | return parse(connection.prepareStatement(query).executeQuery()); 18 | } 19 | 20 | public static DataTable parse(ResultSet resultSet) throws SQLException { 21 | ResultSetMetaData metaData = resultSet.getMetaData(); 22 | DataTable dataTable = new DataTable(); 23 | dataTable.columns = new ColumnCollection(); 24 | 25 | int colCount = metaData.getColumnCount(); 26 | for (int i = 1; i <= colCount; i++) { 27 | Column column = new Column(); 28 | column.setCatalogName(metaData.getCatalogName(i)); 29 | column.setColumnClassName(metaData.getColumnClassName(i)); 30 | column.setDisplaySize(metaData.getColumnDisplaySize(i)); 31 | column.setLabel(metaData.getColumnLabel(i)); 32 | column.setName(metaData.getColumnName(i)); 33 | column.setPrecision(metaData.getPrecision(i)); 34 | column.setScale(metaData.getScale(i)); 35 | column.setSchemaName(metaData.getSchemaName(i)); 36 | column.setTableName(metaData.getTableName(i)); 37 | column.setType(metaData.getColumnType(i)); 38 | column.setTypeName(metaData.getColumnTypeName(i)); 39 | dataTable.columns.add(column); 40 | } 41 | 42 | while (resultSet.next()) { 43 | Object[] data = new Object[colCount]; 44 | for (int i = 1; i <= data.length; i++) { 45 | data[i - 1] = resultSet.getObject(i); 46 | } 47 | dataTable.add(new Row(dataTable, data)); 48 | } 49 | resultSet.close(); 50 | return dataTable; 51 | } 52 | 53 | private ColumnCollection columns; 54 | 55 | public ColumnCollection getColumns() { 56 | return columns; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | String s = columns.toString() + "\n"; 62 | if (size() == 0) { 63 | s += "Rows is empty\n"; 64 | } else { 65 | s += "Rows : {" + String.valueOf(get(0)); 66 | for (int i = 1; i < size(); i++) { 67 | s += "\n" + String.valueOf(get(i)); 68 | } 69 | s += "}\n"; 70 | } 71 | return s; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/springboot/util/backup/db/Row.java: -------------------------------------------------------------------------------- 1 | package springboot.util.backup.db; 2 | 3 | import java.util.Date; 4 | 5 | public class Row { 6 | private Object[] data; 7 | private DataTable dataTable; 8 | 9 | public Row(DataTable dataTable, Object[] data) { 10 | this.dataTable = dataTable; 11 | this.data = data; 12 | } 13 | 14 | public Object get(String columnLabel) { 15 | return get(dataTable.getColumns().indexByLabel(columnLabel)); 16 | } 17 | 18 | public Object get(int index) { 19 | return data[index]; 20 | } 21 | 22 | public String getString(int index) { 23 | return String.valueOf(get(index)); 24 | } 25 | 26 | public String getString(String label) { 27 | return String.valueOf(get(label)); 28 | } 29 | 30 | public Integer getInteger(String label) { 31 | return (Integer) (get(label)); 32 | } 33 | 34 | public Date getDate(int index) { 35 | return (Date) get(index); 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | if (data == null || data.length == 0) { 41 | return "{}"; 42 | } 43 | String s = "{" + String.valueOf(data[0]); 44 | for (int i = 1; i < data.length; i++) { 45 | s += ", " + String.valueOf(data[i]); 46 | } 47 | s += "}"; 48 | return s; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/resources/application-jdbc.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource 2 | spring.datasource.driverClassName=com.mysql.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://127.0.0.1:3306/jantent?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true 4 | spring.datasource.username=root 5 | spring.datasource.password=xxxxx 6 | spring.datasource.initialSize=20 7 | spring.datasource.minIdle=10 8 | spring.datasource.maxActive=100 -------------------------------------------------------------------------------- /src/main/resources/application-log.properties: -------------------------------------------------------------------------------- 1 | logging.level.springboot.*=DEBUG -------------------------------------------------------------------------------- /src/main/resources/application-mail.properties: -------------------------------------------------------------------------------- 1 | spring.mail.host=smtp.qq.com 2 | spring.mail.port=587 3 | spring.mail.username=jantent@qq.com 4 | spring.mail.password=xxxxxxx -------------------------------------------------------------------------------- /src/main/resources/application-redis.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/application-redis.properties -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 80 3 | spring: 4 | profiles: 5 | # 外置jdbc和log配置文件 6 | active: jdbc,log,redis,mail 7 | 8 | thymeleaf: 9 | prefix: classpath:/templates/ 10 | check-template-location: true 11 | suffix: .html 12 | encoding: UTF-8 13 | content-type: text/html 14 | mode: HTML5 15 | cache: false 16 | 17 | 18 | mybatis: 19 | type-aliases-package: springboot.dao 20 | 21 | pagehelper: 22 | helper-dialect: mysql 23 | reasonable: true 24 | support-methods-arguments: true 25 | params: count=countSql 26 | 27 | httpportcfg: 28 | http_port: 8080 29 | https_port: 8443 30 | 31 | # Nettyserver 配置 32 | nettyserver: 33 | serviceIp: 0.0.0.0 34 | servicePort: 3460 35 | 36 | -------------------------------------------------------------------------------- /src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | .___ 2 | ____ ____ __| _/ 3 | / ___\ / _ \ / __ | 4 | / /_/ > <_> ) /_/ | 5 | \___ / \____/\____ | 6 | /_____/ \/ -------------------------------------------------------------------------------- /src/main/resources/keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/keystore.jks -------------------------------------------------------------------------------- /src/main/resources/static/admin/images/attach.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/images/attach.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/images/bg/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/images/bg/1.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/images/bg/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/images/bg/2.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/images/bg/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/images/bg/3.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/images/bg/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/images/bg/4.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/images/bg/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/images/bg/5.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/images/favicon.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/images/loading.gif -------------------------------------------------------------------------------- /src/main/resources/static/admin/images/small/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/images/small/bg.jpg -------------------------------------------------------------------------------- /src/main/resources/static/admin/js/install.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by 13 on 2017/2/23. 3 | */ 4 | !function ($) { 5 | "use strict"; 6 | var tale = new $.tale(); 7 | var FormWizard = function () { 8 | }; 9 | //creates form with validation 10 | FormWizard.prototype.init = function () { 11 | var $form_container = $("#wizard-validation-form"); 12 | $form_container.validate({ 13 | errorPlacement: function errorPlacement(error, element) { 14 | element.after(error); 15 | } 16 | }); 17 | $("#steps").steps({ 18 | headerTag: "h3", 19 | bodyTag: "section", 20 | transitionEffect: "fade", 21 | labels: { 22 | previous: "上一步", 23 | next: "下一步", 24 | finish: "登录后台", 25 | loading: '加载中...', 26 | current: '当前位置' 27 | }, 28 | onStepChanging: function (event, currentIndex, newIndex) { 29 | tale.showLoading(); 30 | $form_container.validate().settings.ignore = ":disabled,:hidden"; 31 | var isValid=true; 32 | if(newIndex!=0){ 33 | isValid = $form_container.valid(); 34 | if(!isValid){ 35 | tale.hideLoading(); 36 | } 37 | } 38 | if (isValid && currentIndex == 1&&newIndex==2) { 39 | isValid = false; 40 | var params = $form_container.serialize(); 41 | tale.post({ 42 | url: '/install/testCon', 43 | data: params, 44 | success: function (result) { 45 | if (result && result.success) { 46 | tale.showLoading(); 47 | tale.post({ 48 | url: '/install', 49 | data: params, 50 | success: function (result) { 51 | if (result && result.success) { 52 | isValid = true; 53 | } else { 54 | if (result.msg) { 55 | tale.alertError(result.msg || '安装失败'); 56 | } 57 | } 58 | } 59 | }); 60 | } else { 61 | tale.alertError(result.msg || '测试连接失败'); 62 | } 63 | } 64 | }); 65 | return isValid; 66 | } else { 67 | tale.hideLoading(); 68 | return isValid; 69 | } 70 | }, 71 | onStepChanged: function (event, currentIndex) { 72 | tale.hideLoading(); 73 | }, 74 | onFinishing: function (event, currentIndex) { 75 | $form_container.validate().settings.ignore = ":disabled"; 76 | var isValid = $form_container.valid(); 77 | window.location.href = "/admin/login"; 78 | return isValid; 79 | }, 80 | onFinished: function (event, currentIndex) { 81 | window.location.href = "/admin/login"; 82 | } 83 | }); 84 | return $form_container; 85 | }, 86 | //init 87 | $.FormWizard = new FormWizard, $.FormWizard.Constructor = FormWizard 88 | }(window.jQuery), $.FormWizard.init(); -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/dropzone/4.3.0/min/basic.min.css: -------------------------------------------------------------------------------- 1 | .dropzone,.dropzone *{box-sizing:border-box}.dropzone{position:relative}.dropzone .dz-preview{position:relative;display:inline-block;width:120px;margin:0.5em}.dropzone .dz-preview .dz-progress{display:block;height:15px;border:1px solid #aaa}.dropzone .dz-preview .dz-progress .dz-upload{display:block;height:100%;width:0;background:green}.dropzone .dz-preview .dz-error-message{color:red;display:none}.dropzone .dz-preview.dz-error .dz-error-message,.dropzone .dz-preview.dz-error .dz-error-mark{display:block}.dropzone .dz-preview.dz-success .dz-success-mark{display:block}.dropzone .dz-preview .dz-error-mark,.dropzone .dz-preview .dz-success-mark{position:absolute;display:none;left:30px;top:30px;width:54px;height:58px;left:50%;margin-left:-27px} 2 | -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/jquery-multi-select/img/switch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/jquery-multi-select/img/switch.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/md/img/editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/md/img/editor.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/md/js/jquery.scrollto.js: -------------------------------------------------------------------------------- 1 | (function(c){var a=c.scrollTo=function(f,e,d){c(window).scrollTo(f,e,d)};a.defaults={axis:"xy",duration:parseFloat(c.fn.jquery)>=1.3?0:1,limit:true};a.window=function(d){return c(window)._scrollable()};c.fn._scrollable=function(){return this.map(function(){var e=this,d=!e.nodeName||c.inArray(e.nodeName.toLowerCase(),["iframe","#document","html","body"])!=-1;if(!d){return e}var f=(e.contentWindow||e).document||e.ownerDocument||e;return/webkit/i.test(navigator.userAgent)||f.compatMode=="BackCompat"?f.body:f.documentElement})};c.fn.scrollTo=function(f,e,d){if(typeof e=="object"){d=e;e=0}if(typeof d=="function"){d={onAfter:d}}if(f=="max"){f=9000000000}d=c.extend({},a.defaults,d);e=e||d.duration;d.queue=d.queue&&d.axis.length>1;if(d.queue){e/=2}d.offset=b(d.offset);d.over=b(d.over);return this._scrollable().each(function(){if(f==null){return}var l=this,j=c(l),k=f,i,g={},m=j.is("html,body");switch(typeof k){case"number":case"string":if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(k)){k=b(k);break}k=c(k,this);if(!k.length){return}case"object":if(k.is||k.style){i=(k=c(k)).offset()}}c.each(d.axis.split(""),function(q,r){var s=r=="x"?"Left":"Top",u=s.toLowerCase(),p="scroll"+s,o=l[p],n=a.max(l,r);if(i){g[p]=i[u]+(m?0:o-j.offset()[u]);if(d.margin){g[p]-=parseInt(k.css("margin"+s))||0;g[p]-=parseInt(k.css("border"+s+"Width"))||0}g[p]+=d.offset[u]||0;if(d.over[u]){g[p]+=k[r=="x"?"width":"height"]()*d.over[u]}}else{var t=k[u];g[p]=t.slice&&t.slice(-1)=="%"?parseFloat(t)/100*n:t}if(d.limit&&/^\d+$/.test(g[p])){g[p]=g[p]<=0?0:Math.min(g[p],n)}if(!q&&d.queue){if(o!=g[p]){h(d.onAfterFirst)}delete g[p]}});h(d.onAfter);function h(n){j.animate(g,e,d.easing,n&&function(){n.call(this,f,d)})}}).end()};a.max=function(j,i){var h=i=="x"?"Width":"Height",e="scroll"+h;if(!c(j).is("html,body")){return j[e]-c(j)[h.toLowerCase()]()}var g="client"+h,f=j.ownerDocument.documentElement,d=j.ownerDocument.body;return Math.max(f[e],d[e])-Math.min(f[g],d[g])};function b(d){return typeof d=="object"?d:{top:d,left:d}}})(jQuery); -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/mditor/css/mditor.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":[],"names":[],"mappings":"","file":"css/mditor.css","sourceRoot":""} -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/mditor/font/674f50d287a8c48dc19ba404d20fe713.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/mditor/font/674f50d287a8c48dc19ba404d20fe713.eot -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/mditor/font/a48ac41620cd818c5020d0f4302489ff.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/mditor/font/a48ac41620cd818c5020d0f4302489ff.ttf -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/mditor/font/af7ae505a9eed503f8b8e6982036873e.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/mditor/font/af7ae505a9eed503f8b8e6982036873e.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/mditor/font/b06871f281fee6b241d60582ae9369b9.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/mditor/font/b06871f281fee6b241d60582ae9369b9.ttf -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/mditor/font/fee66e712a8a08eef5805a46892932ad.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/mditor/font/fee66e712a8a08eef5805a46892932ad.woff -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/multi-select/0.9.12/css/multi-select.min.css: -------------------------------------------------------------------------------- 1 | .ms-container{background:url(../img/switch.png) 50% 50% no-repeat;width:370px}.ms-container:after{content:".";display:block;height:0;line-height:0;font-size:0;clear:both;min-height:0;visibility:hidden}.ms-container .ms-selectable,.ms-container .ms-selection{background:#fff;color:#555;float:left;width:45%}.ms-container .ms-selection{float:right}.ms-container .ms-list{-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075);-webkit-transition:border linear .2s,box-shadow linear .2s;-moz-transition:border linear .2s,box-shadow linear .2s;-ms-transition:border linear .2s,box-shadow linear .2s;-o-transition:border linear .2s,box-shadow linear .2s;transition:border linear .2s,box-shadow linear .2s;border:1px solid #ccc;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;position:relative;height:200px;padding:0;overflow-y:auto}.ms-container .ms-list.ms-focus{border-color:rgba(82,168,236,.8);-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(82,168,236,.6);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(82,168,236,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(82,168,236,.6);outline:0;outline:dotted thin\9}.ms-container ul{margin:0;list-style-type:none;padding:0}.ms-container .ms-optgroup-container{width:100%}.ms-container .ms-optgroup-label{margin:0;padding:5px 0 0 5px;cursor:pointer;color:#999}.ms-container .ms-selectable li.ms-elem-selectable,.ms-container .ms-selection li.ms-elem-selection{border-bottom:1px #eee solid;padding:2px 10px;color:#555;font-size:14px}.ms-container .ms-selectable li.ms-hover,.ms-container .ms-selection li.ms-hover{cursor:pointer;color:#fff;text-decoration:none;background-color:#08c}.ms-container .ms-selectable li.disabled,.ms-container .ms-selection li.disabled{background-color:#eee;color:#aaa;cursor:text} -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/multi-select/0.9.12/img/switch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/multi-select/0.9.12/img/switch.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/select2.dist.css/select2-bootstrap.css: -------------------------------------------------------------------------------- 1 | .form-control .select2-choice { 2 | border: 0; 3 | border-radius: 2px; 4 | } 5 | 6 | .form-control .select2-choice .select2-arrow { 7 | border-radius: 0 2px 2px 0; 8 | } 9 | 10 | .form-control.select2-container { 11 | height: auto !important; 12 | padding: 0; 13 | } 14 | 15 | .form-control.select2-container.select2-dropdown-open { 16 | border-color: #5897FB; 17 | border-radius: 3px 3px 0 0; 18 | } 19 | 20 | .form-control .select2-container.select2-dropdown-open .select2-choices { 21 | border-radius: 3px 3px 0 0; 22 | } 23 | 24 | .form-control.select2-container .select2-choices { 25 | border: 0 !important; 26 | border-radius: 3px; 27 | } 28 | 29 | .control-group.warning .select2-container .select2-choice, 30 | .control-group.warning .select2-container .select2-choices, 31 | .control-group.warning .select2-container-active .select2-choice, 32 | .control-group.warning .select2-container-active .select2-choices, 33 | .control-group.warning .select2-dropdown-open.select2-drop-above .select2-choice, 34 | .control-group.warning .select2-dropdown-open.select2-drop-above .select2-choices, 35 | .control-group.warning .select2-container-multi.select2-container-active .select2-choices { 36 | border: 1px solid #C09853 !important; 37 | } 38 | 39 | .control-group.warning .select2-container .select2-choice div { 40 | border-left: 1px solid #C09853 !important; 41 | background: #FCF8E3 !important; 42 | } 43 | 44 | .control-group.error .select2-container .select2-choice, 45 | .control-group.error .select2-container .select2-choices, 46 | .control-group.error .select2-container-active .select2-choice, 47 | .control-group.error .select2-container-active .select2-choices, 48 | .control-group.error .select2-dropdown-open.select2-drop-above .select2-choice, 49 | .control-group.error .select2-dropdown-open.select2-drop-above .select2-choices, 50 | .control-group.error .select2-container-multi.select2-container-active .select2-choices { 51 | border: 1px solid #B94A48 !important; 52 | } 53 | 54 | .control-group.error .select2-container .select2-choice div { 55 | border-left: 1px solid #B94A48 !important; 56 | background: #F2DEDE !important; 57 | } 58 | 59 | .control-group.info .select2-container .select2-choice, 60 | .control-group.info .select2-container .select2-choices, 61 | .control-group.info .select2-container-active .select2-choice, 62 | .control-group.info .select2-container-active .select2-choices, 63 | .control-group.info .select2-dropdown-open.select2-drop-above .select2-choice, 64 | .control-group.info .select2-dropdown-open.select2-drop-above .select2-choices, 65 | .control-group.info .select2-container-multi.select2-container-active .select2-choices { 66 | border: 1px solid #3A87AD !important; 67 | } 68 | 69 | .control-group.info .select2-container .select2-choice div { 70 | border-left: 1px solid #3A87AD !important; 71 | background: #D9EDF7 !important; 72 | } 73 | 74 | .control-group.success .select2-container .select2-choice, 75 | .control-group.success .select2-container .select2-choices, 76 | .control-group.success .select2-container-active .select2-choice, 77 | .control-group.success .select2-container-active .select2-choices, 78 | .control-group.success .select2-dropdown-open.select2-drop-above .select2-choice, 79 | .control-group.success .select2-dropdown-open.select2-drop-above .select2-choices, 80 | .control-group.success .select2-container-multi.select2-container-active .select2-choices { 81 | border: 1px solid #468847 !important; 82 | } 83 | 84 | .control-group.success .select2-container .select2-choice div { 85 | border-left: 1px solid #468847 !important; 86 | background: #DFF0D8 !important; 87 | } 88 | -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/select2.dist.css/select2-spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/select2.dist.css/select2-spinner.gif -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/select2.dist.css/select2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/select2.dist.css/select2.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/select2.dist.css/select2x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/select2.dist.css/select2x2.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/select2/3.4.8/select2-bootstrap.min.css: -------------------------------------------------------------------------------- 1 | .form-control .select2-choice{border:0;border-radius:2px}.form-control .select2-choice .select2-arrow{border-radius:0 2px 2px 0}.form-control.select2-container{height:auto!important;padding:0}.form-control.select2-container.select2-dropdown-open{border-color:#5897fb;border-radius:3px 3px 0 0}.form-control .select2-container.select2-dropdown-open .select2-choices{border-radius:3px 3px 0 0}.form-control.select2-container .select2-choices{border:0!important;border-radius:3px}.control-group.warning .select2-container .select2-choice,.control-group.warning .select2-container .select2-choices,.control-group.warning .select2-container-active .select2-choice,.control-group.warning .select2-container-active .select2-choices,.control-group.warning .select2-dropdown-open.select2-drop-above .select2-choice,.control-group.warning .select2-dropdown-open.select2-drop-above .select2-choices,.control-group.warning .select2-container-multi.select2-container-active .select2-choices{border:1px solid #c09853!important}.control-group.warning .select2-container .select2-choice div{border-left:1px solid #c09853!important;background:#fcf8e3!important}.control-group.error .select2-container .select2-choice,.control-group.error .select2-container .select2-choices,.control-group.error .select2-container-active .select2-choice,.control-group.error .select2-container-active .select2-choices,.control-group.error .select2-dropdown-open.select2-drop-above .select2-choice,.control-group.error .select2-dropdown-open.select2-drop-above .select2-choices,.control-group.error .select2-container-multi.select2-container-active .select2-choices{border:1px solid #b94a48!important}.control-group.error .select2-container .select2-choice div{border-left:1px solid #b94a48!important;background:#f2dede!important}.control-group.info .select2-container .select2-choice,.control-group.info .select2-container .select2-choices,.control-group.info .select2-container-active .select2-choice,.control-group.info .select2-container-active .select2-choices,.control-group.info .select2-dropdown-open.select2-drop-above .select2-choice,.control-group.info .select2-dropdown-open.select2-drop-above .select2-choices,.control-group.info .select2-container-multi.select2-container-active .select2-choices{border:1px solid #3a87ad!important}.control-group.info .select2-container .select2-choice div{border-left:1px solid #3a87ad!important;background:#d9edf7!important}.control-group.success .select2-container .select2-choice,.control-group.success .select2-container .select2-choices,.control-group.success .select2-container-active .select2-choice,.control-group.success .select2-container-active .select2-choices,.control-group.success .select2-dropdown-open.select2-drop-above .select2-choice,.control-group.success .select2-dropdown-open.select2-drop-above .select2-choices,.control-group.success .select2-container-multi.select2-container-active .select2-choices{border:1px solid #468847!important}.control-group.success .select2-container .select2-choice div{border-left:1px solid #468847!important;background:#dff0d8!important} -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/select2/3.4.8/select2-spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/select2/3.4.8/select2-spinner.gif -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/select2/3.4.8/select2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/select2/3.4.8/select2.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/select2/3.4.8/select2_locale_zh-CN.min.js: -------------------------------------------------------------------------------- 1 | (function(a){a.extend(a.fn.select2.defaults,{formatNoMatches:function(){return"没有找到匹配项"},formatInputTooShort:function(b,c){var d=c-b.length;return"请再输入"+d+"个字符"},formatInputTooLong:function(c,b){var d=c.length-b;return"请删掉"+d+"个字符"},formatSelectionTooBig:function(b){return"你只能选择最多"+b+"项"},formatLoadMore:function(b){return"加载结果中…"},formatSearching:function(){return"搜索中…"}})})(jQuery); -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/select2/3.4.8/select2x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/select2/3.4.8/select2x2.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/select2/dist/css/select2-bootstrap.css: -------------------------------------------------------------------------------- 1 | .form-control .select2-choice { 2 | border: 0; 3 | border-radius: 2px; 4 | } 5 | 6 | .form-control .select2-choice .select2-arrow { 7 | border-radius: 0 2px 2px 0; 8 | } 9 | 10 | .form-control.select2-container { 11 | height: auto !important; 12 | padding: 0; 13 | } 14 | 15 | .form-control.select2-container.select2-dropdown-open { 16 | border-color: #5897FB; 17 | border-radius: 3px 3px 0 0; 18 | } 19 | 20 | .form-control .select2-container.select2-dropdown-open .select2-choices { 21 | border-radius: 3px 3px 0 0; 22 | } 23 | 24 | .form-control.select2-container .select2-choices { 25 | border: 0 !important; 26 | border-radius: 3px; 27 | } 28 | 29 | .control-group.warning .select2-container .select2-choice, 30 | .control-group.warning .select2-container .select2-choices, 31 | .control-group.warning .select2-container-active .select2-choice, 32 | .control-group.warning .select2-container-active .select2-choices, 33 | .control-group.warning .select2-dropdown-open.select2-drop-above .select2-choice, 34 | .control-group.warning .select2-dropdown-open.select2-drop-above .select2-choices, 35 | .control-group.warning .select2-container-multi.select2-container-active .select2-choices { 36 | border: 1px solid #C09853 !important; 37 | } 38 | 39 | .control-group.warning .select2-container .select2-choice div { 40 | border-left: 1px solid #C09853 !important; 41 | background: #FCF8E3 !important; 42 | } 43 | 44 | .control-group.error .select2-container .select2-choice, 45 | .control-group.error .select2-container .select2-choices, 46 | .control-group.error .select2-container-active .select2-choice, 47 | .control-group.error .select2-container-active .select2-choices, 48 | .control-group.error .select2-dropdown-open.select2-drop-above .select2-choice, 49 | .control-group.error .select2-dropdown-open.select2-drop-above .select2-choices, 50 | .control-group.error .select2-container-multi.select2-container-active .select2-choices { 51 | border: 1px solid #B94A48 !important; 52 | } 53 | 54 | .control-group.error .select2-container .select2-choice div { 55 | border-left: 1px solid #B94A48 !important; 56 | background: #F2DEDE !important; 57 | } 58 | 59 | .control-group.info .select2-container .select2-choice, 60 | .control-group.info .select2-container .select2-choices, 61 | .control-group.info .select2-container-active .select2-choice, 62 | .control-group.info .select2-container-active .select2-choices, 63 | .control-group.info .select2-dropdown-open.select2-drop-above .select2-choice, 64 | .control-group.info .select2-dropdown-open.select2-drop-above .select2-choices, 65 | .control-group.info .select2-container-multi.select2-container-active .select2-choices { 66 | border: 1px solid #3A87AD !important; 67 | } 68 | 69 | .control-group.info .select2-container .select2-choice div { 70 | border-left: 1px solid #3A87AD !important; 71 | background: #D9EDF7 !important; 72 | } 73 | 74 | .control-group.success .select2-container .select2-choice, 75 | .control-group.success .select2-container .select2-choices, 76 | .control-group.success .select2-container-active .select2-choice, 77 | .control-group.success .select2-container-active .select2-choices, 78 | .control-group.success .select2-dropdown-open.select2-drop-above .select2-choice, 79 | .control-group.success .select2-dropdown-open.select2-drop-above .select2-choices, 80 | .control-group.success .select2-container-multi.select2-container-active .select2-choices { 81 | border: 1px solid #468847 !important; 82 | } 83 | 84 | .control-group.success .select2-container .select2-choice div { 85 | border-left: 1px solid #468847 !important; 86 | background: #DFF0D8 !important; 87 | } 88 | -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/select2/dist/css/select2-spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/select2/dist/css/select2-spinner.gif -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/select2/dist/css/select2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/select2/dist/css/select2.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/select2/dist/css/select2x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/admin/plugins/select2/dist/css/select2x2.png -------------------------------------------------------------------------------- /src/main/resources/static/admin/plugins/tagsinput/jquery.tagsinput.css: -------------------------------------------------------------------------------- 1 | div.tagsinput { 2 | border:1px solid #ccc; 3 | background: #FFF; 4 | padding:5px; 5 | width:300px; 6 | height:100px; 7 | overflow-y: auto; 8 | -moz-border-radius: 2px; 9 | -webkit-border-radius: 2px; 10 | border-radius: 2px; 11 | } 12 | 13 | div.tagsinput span.tag { 14 | display: block; 15 | float: left; 16 | padding: 2px 5px; 17 | text-decoration:none; 18 | background: #317eeb; 19 | color: #fff; 20 | margin-right: 5px; 21 | margin-bottom:5px; 22 | font-size:13px; 23 | -moz-border-radius: 2px; 24 | -webkit-border-radius: 2px; 25 | border-radius: 2px; 26 | } 27 | 28 | div.tagsinput span.tag a { 29 | font-weight: bold; 30 | color: #fff; 31 | opacity: 0.5; 32 | text-decoration: none; 33 | font-size: 11px; 34 | } 35 | 36 | div.tagsinput span.tag a:hover { 37 | opacity: 1; 38 | } 39 | 40 | div.tagsinput input { 41 | width: 80px; 42 | margin: 0px; 43 | font-size: 13px; 44 | border: 1px solid transparent; 45 | padding: 5px; 46 | background: transparent; 47 | color: #000; 48 | outline: 0px; 49 | margin-right: 5px; 50 | margin-bottom: 5px; 51 | } 52 | 53 | div.tagsinput div { 54 | display: block; 55 | float: left; 56 | } 57 | 58 | .tags_clear { 59 | clear: both; 60 | width: 100%; 61 | height: 0px; 62 | } 63 | 64 | .not_valid { 65 | background: #FBD8DB !important; 66 | color: #90111A !important; 67 | } 68 | -------------------------------------------------------------------------------- /src/main/resources/static/jantent/assets/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/jantent/assets/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /src/main/resources/static/jantent/assets/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/jantent/assets/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /src/main/resources/static/jantent/assets/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/jantent/assets/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /src/main/resources/static/jantent/assets/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/jantent/assets/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /src/main/resources/static/jantent/assets/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/jantent/assets/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/jantent/assets/img/f10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/jantent/assets/img/f10.jpg -------------------------------------------------------------------------------- /src/main/resources/static/jantent/assets/img/f14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/jantent/assets/img/f14.jpg -------------------------------------------------------------------------------- /src/main/resources/static/jantent/assets/img/f15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/jantent/assets/img/f15.jpg -------------------------------------------------------------------------------- /src/main/resources/static/jantent/assets/img/f161.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/jantent/assets/img/f161.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/apple-touch-icon.png -------------------------------------------------------------------------------- /src/main/resources/static/user/img/bg-ico.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/bg-ico.png -------------------------------------------------------------------------------- /src/main/resources/static/user/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/logo.png -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/1.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/10.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/11.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/12.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/13.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/14.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/15.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/16.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/17.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/18.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/19.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/2.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/20.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/21.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/22.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/23.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/24.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/25.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/3.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/4.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/5.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/6.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/7.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/8.jpg -------------------------------------------------------------------------------- /src/main/resources/static/user/img/rand/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantent/Jantent/0aece86e1495a10e518efeeeccb721c25193bc37/src/main/resources/static/user/img/rand/9.jpg -------------------------------------------------------------------------------- /src/main/resources/templates/admin/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/resources/templates/admin/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 登录博客后台 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |
23 |
24 |

登录Jantent

25 |
26 |
27 | 28 |
29 | 30 | 32 |
33 |
34 |
35 | 36 | 38 |
39 |
40 | 45 | 46 |
47 |
48 | 49 |
50 | © 2018 Jantent 51 |
52 |
53 | 54 | 73 | 74 | -------------------------------------------------------------------------------- /src/main/resources/templates/comm/error_404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 404(找不到页面)- My Blog 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 |

404!

24 |

很抱歉,没有找到这个页面!

25 |

26 | 返回首页 27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /src/main/resources/templates/comm/error_500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 500(服务器出差错了)- My Blog 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 |

500

24 |

服务器出了点差错.



25 |

可以尝试向社区发出求助 New Issues

26 | 返回首页 27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /src/main/resources/templates/comm/ipban.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | You have been banned, brother 9 | 10 | -------------------------------------------------------------------------------- /src/main/resources/templates/comm/macros.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
    5 | 6 |
  1. 7 |
    8 | 9 | 10 | 11 |
  2. 13 |
    14 | 15 | 16 | 17 |
  3. 18 |
    19 | 20 |
21 | 22 |
23 |
24 | 46 |
47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /src/main/resources/templates/comm/tale_comment.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 61 | 62 | -------------------------------------------------------------------------------- /src/main/resources/templates/themes/jantent/archives.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 |

-- 存档 --

7 |
8 | 9 |
    10 |

    11 | 12 |
  • 13 | 14 | 15 | 16 | 17 | 19 | 20 |
  • 21 |
    22 |
23 |
24 |
25 |
26 | 27 | 28 |
29 | -------------------------------------------------------------------------------- /src/main/resources/templates/themes/jantent/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | <th:block th:text="${title ?: '首页'}+' - '+${commons.site_option('site_title','Janti Blog')}"></th:block> 15 | 16 | 17 | 18 | 19 | 20 | 21 | 25 | 26 | 28 | 33 | 60 | 61 | -------------------------------------------------------------------------------- /src/main/resources/templates/themes/jantent/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 |
7 |
8 | 9 |
10 |
11 | 12 |
13 |
14 | 15 | 16 |     17 | 18 | 19 |

20 |
22 |
23 |

24 | 25 |
26 |
27 |
28 | 29 |
30 | 31 |
32 |
33 |
34 |
35 | 36 | 37 |
38 |
39 |

About ME

40 | about me 41 |

42 | Java后台开发 43 |

44 |

个人博客小站,主要发表关于Java,springboot,springcloud,thrift等相关文章

45 |
46 |
47 |

Contact ME

48 |

49 | 50 | 51 |

52 |
53 |
54 |

TAG cloud

55 |
56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 |
73 |
74 |
75 |
76 | 77 |
78 | 79 | -------------------------------------------------------------------------------- /src/main/resources/templates/themes/jantent/links.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 |
7 |

友情链接

8 | 13 |

链接须知

14 |
15 |
    16 |
  • 请确定贵站可以稳定运营

  • 17 |
  • 原创博客优先,技术类博客优先

  • 18 |
  • 经常过来访问和评论,眼熟的

  • 19 |
20 |
21 |

基本信息

22 | 23 |

我的邮箱:jantent@qq.com

24 |

同时欢迎互换友链 ^_^

25 |
26 |
27 | 28 |
29 | -------------------------------------------------------------------------------- /src/main/resources/templates/themes/jantent/page-category.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 |
7 |
8 | : 9 |
10 | 11 |
12 |

抱歉,还没有相关文章.

13 |
14 |
15 | 16 |
17 |
18 | 19 |
20 |
21 |
22 |
23 |

24 |
25 |
26 |
28 |
发布于
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | 38 |
39 |
40 | 41 |
42 | -------------------------------------------------------------------------------- /src/main/resources/templates/themes/jantent/page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 |
7 |

8 |
9 | 10 |
11 |
12 |
13 |
14 |
15 |
16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/templates/themes/jantent/post.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 |
7 |

8 | 9 |

10 |
11 | 12 | / / / 13 | 浏览 14 |
15 |
16 |
17 | 18 | 19 | 20 | 24 |
25 |
26 |
27 |
28 | 29 | -------------------------------------------------------------------------------- /src/test/java/springboot/scheduletask/ScheduleTaskTest.java: -------------------------------------------------------------------------------- 1 | package springboot.scheduletask; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | import javax.annotation.Resource; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | @RunWith(SpringRunner.class) 13 | @SpringBootTest 14 | public class ScheduleTaskTest { 15 | 16 | @Resource 17 | private ScheduleTask scheduleTask; 18 | 19 | @Test 20 | public void testSendString(){ 21 | scheduleTask.process(); 22 | } 23 | } -------------------------------------------------------------------------------- /src/test/java/springboot/service/impl/ContentServcieImplTest.java: -------------------------------------------------------------------------------- 1 | package springboot.service.impl; 2 | 3 | import com.github.pagehelper.PageInfo; 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.test.context.junit4.SpringRunner; 9 | import springboot.modal.vo.ContentVo; 10 | import springboot.service.IContentService; 11 | 12 | import static org.junit.Assert.*; 13 | 14 | /** 15 | * @author tangj 16 | * @date 2018/5/13 17:12 17 | */ 18 | @RunWith(SpringRunner.class) 19 | @SpringBootTest 20 | public class ContentServcieImplTest { 21 | 22 | @Autowired 23 | private IContentService contentService; 24 | 25 | 26 | @Test 27 | public void testConten(){ 28 | PageInfo contentVoPageInfo = contentService.getContents(1,5); 29 | System.out.println(contentVoPageInfo); 30 | } 31 | } -------------------------------------------------------------------------------- /src/test/java/springboot/service/impl/OptionServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package springboot.service.impl; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | import springboot.dto.Types; 8 | import springboot.service.IOptionService; 9 | 10 | import javax.annotation.Resource; 11 | 12 | import static org.junit.Assert.*; 13 | 14 | @RunWith(SpringRunner.class) 15 | @SpringBootTest 16 | public class OptionServiceImplTest { 17 | 18 | @Resource 19 | IOptionService optionService; 20 | 21 | @Test 22 | public void testInsertOption(){ 23 | optionService.insertOption(Types.BLOCK_IPS.getType(),"123"); 24 | } 25 | } -------------------------------------------------------------------------------- /src/test/java/springboot/service/impl/RedisServiceTest.java: -------------------------------------------------------------------------------- 1 | package springboot.service.impl; 2 | 3 | import com.github.pagehelper.PageInfo; 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.data.redis.core.RedisTemplate; 9 | import org.springframework.data.redis.core.StringRedisTemplate; 10 | import org.springframework.data.redis.core.ValueOperations; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | import org.thymeleaf.TemplateEngine; 13 | import org.thymeleaf.context.Context; 14 | import springboot.constant.WebConst; 15 | import springboot.dto.MetaDto; 16 | import springboot.dto.Types; 17 | import springboot.modal.vo.ContentVo; 18 | import springboot.service.ICommentService; 19 | import springboot.service.IContentService; 20 | import springboot.service.IMetaService; 21 | 22 | import javax.annotation.Resource; 23 | 24 | import java.util.List; 25 | 26 | import static org.junit.Assert.*; 27 | 28 | /** 29 | * @author tangj 30 | * @date 2018/5/12 19:57 31 | */ 32 | @RunWith(SpringRunner.class) 33 | @SpringBootTest 34 | public class RedisServiceTest { 35 | @Autowired 36 | private RedisTemplate redisTemplate; 37 | 38 | @Resource 39 | private ValueOperations valueOperations; 40 | 41 | @Resource 42 | private TemplateEngine templateEngine; 43 | 44 | @Autowired 45 | private IContentService contentService; 46 | 47 | @Autowired 48 | private ICommentService commentService; 49 | 50 | @Resource 51 | private IMetaService metaService; 52 | 53 | @Test 54 | public void test(){ 55 | Context context = new Context(); 56 | PageInfo articles = contentService.getContents(1, 10); 57 | List categories = metaService.getMetaList(Types.CATEGORY.getType(), null, WebConst.MAX_POSTS); 58 | context.setVariable("categories", categories); 59 | context.setVariable("articles", articles); 60 | String html = templateEngine.process("themes/jantent/index",context); 61 | System.out.println(html); 62 | } 63 | } --------------------------------------------------------------------------------