SpringBoot open source blog project based on Fly community template

Posted by chiefmonkey on Mon, 25 May 2020 16:15:07 +0200

1. Official website address

2. Technology stack

  • Development tool Idea
  • Database design
  • JDK version Java8
  • Database MySQL v5.7
  • Back end development language SpringBoot2.2.6.RELEASE
  • Data access layer mybatis plus 3.3.1
  • Front end related HTML5, LayUI, jQuery, LayUI_fly community template, etc
  • Middleware Redis cache, RabbitMQ message, Nginx, etc
  • File service FastDFS distributed file storage, qinniu cloud, etc
  • Rich text editor, WangEditor Editor.md
  • Three party login QQ, wechat, Weibo, gitee, etc
  • Message sending email sending, nail message sending, SMS sending
  • Integration of three-party api post content review (Baidu review), baidu push, etc

3. Table structure design pd diagram

4. Frame building

4.1. Integrated mybatis plus operation database

  • Introduce maven dependency

      <dependency>
      		 <groupId>mysql</groupId>
      		 <artifactId>mysql-connector-java</artifactId>
      </dependency>
      <dependency>
      		<groupId>com.baomidou</groupId>
      		<artifactId>mybatis-plus-boot-starter</artifactId>
      		<version>3.3.1</version>
      </dependency>
    
  •   application.yml Configure database connection
    
      		spring:
      			datasource:
      				driver-class-name: com.mysql.cj.jdbc.Driver
      				url: jdbc:mysql://127.0.0.1:3306/sunny-fly?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true&useAffectedRows=true
      				username: root
      				password: admin1009
      				type: com.zaxxer.hikari.HikariDataSource
      				hikari:
      					maximum-pool-size: 50 # Maximum number of connections in connection pool, default is 10
      					minimum-idle: 5 #Minimum number of idle connections
      					idle-timeout: 18000 #Maximum idle connection lifetime, 600000 by default (10 minutes)
      					pool-name: sunnyHikariCP  #Connection pool name
      					connection-test-query: SELECT 1
    
  •   mybatis-plus Basic configuration class:MybatisPlusConfig.java
    
      		@EnableTransactionManagement
      		@Configuration
      		@MapperScan("com.sunny.fly.mapper")
      		public class MybatisPlusConfig {
    
      				@Bean
      				public PaginationInterceptor paginationInterceptor() {
      						PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
      						paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
      						return paginationInterceptor;
      				}
      		}
    
  • Test to operate the database through mybatis plus

  1. Create test script

     CREATE TABLE `test` (
     	`NAME` varchar(255) DEFAULT NULL,
     	`AGE` int(11) DEFAULT NULL,
     	`BIRTHDAY` datetime DEFAULT NULL
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
  2. Create pojo,mapper,service,controller

     @Data
     @EqualsAndHashCode(callSuper = false)
     @Accessors(chain = true)
     @TableName("TEST")
     public class TestBean implements Serializable {
    
     		private static final long serialVersionUID = 1L;
    
     		/**
     		 * full name
     		 */
     		private String name;
    
     		/**
     		 * Age
     		 */
     		private int age;
    
     		/**
     		 * Age
     		 */
     		private Date birthday;
    
     }
    

mapper

@Repository
public interface TestMapper extends BaseMapper<TestBean> {
}

service

public List<TestBean> queryAll() {
				return testMapper.selectList(null);
		}

controller

@GetMapping("queryAll")
		@ResponseBody
		public ResponseResult<List<TestBean>> queryAll() {
				List<TestBean> testList = testService.queryAll();
				return ResponseUtil.makeOKRsp(testList);
		}
  1. Page access

4.2. Integrated Redis cache

5. Homepage development

6. Detail page development

7. Login registration and personal center development documents

Source code download address

Source download address

Detailed development technical documents Click here to view the technical documents ; more technical articles: https://www.sunnyblog.top ; any questions plus QQ group consultation: 534073451

Topics: Java Database MySQL Mybatis Redis