Actual combat of multi terminal full stack project: the whole process of large-scale commercial driving agent business is implemented [Wan whole]

Link: https://pan.baidu.com/s/1d6YONkCi4u7T1ZBm1yZLYg Extraction code: iamh
Author - \ / 307570512

Microservice architecture of large commercial driving agent business

Microservice architecture (commonly referred to as microservice) is an architecture form used to develop applications. Through microservices, large-scale applications can be decomposed into multiple independent components, each of which has its own responsibility field. When processing a user request, microservice based applications may call many internal microservices to jointly generate their response. Containers are a great example of a microservice architecture because they allow you to focus on developing services without worrying about dependencies.

This monomer application is more suitable for small projects. Its advantages are:
Simple and direct development and centralized management
Basically no repeated development
All functions are local, without distributed management overhead and call overhead

Actual combat of spingboot multi terminal full stack project

Step 1: import the jar package
Import the jar package of mybatis plus into pom. Since code generation will be involved later, we also need to import the page template engine. Here we use freemaker.

<!--mp-->
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.2.0</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <scope>runtime</scope>
</dependency>
<!--mp Code generator -->
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-generator</artifactId>
    <version>3.2.0</version>
</dependency>

Step 2: then write the configuration file

# DataSource Config
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/vueblog?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai
    username: root
    password: admin
mybatis-plus:
  mapper-locations: classpath*:/mapper/**Mapper.xml

In addition to the information of the configuration database, the above also configures the scanning path of the xml file of the mapper of myabtis plus. Don't forget this step.
Step 3: start mapper interface scanning and add paging plug-in
Create a new package: specify the package where the interface to become the implementation class is located through the @ maperscan annotation, and then all interfaces under the package will generate corresponding implementation classes after compilation. PaginationInterceptor is a paging plug-in.

com.markerhub.config.MybatisPlusConfig

@Configuration
@EnableTransactionManagement
@MapperScan("com.markerhub.mapper")
public class MybatisPlusConfig {
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        return paginationInterceptor;
    }
}

Step 4: code generation
If you don't use other plug-ins, you can use mybatis plus now. The official provides us with a code generator. Then after I write my own parameters, I can directly generate entity, service, mapper and other interfaces and implementation classes according to the database table information.

com.markerhub.CodeGenerator

Because the code is relatively long, it will not be posted. Look at it in the code warehouse!
First, I created a new user table in the database:

CREATE TABLE `m_user` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `username` varchar(64) DEFAULT NULL,
  `avatar` varchar(255) DEFAULT NULL,
  `email` varchar(64) DEFAULT NULL,
  `password` varchar(64) DEFAULT NULL,
  `status` int(5) NOT NULL,
  `created` datetime DEFAULT NULL,
  `last_login` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `UK_USERNAME` (`username`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_blog` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) NOT NULL,
  `title` varchar(255) NOT NULL,
  `description` varchar(255) NOT NULL,
  `content` longtext,
  `created` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP,
  `status` tinyint(4) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4;
INSERT INTO `vueblog`.`m_user` (`id`, `username`, `avatar`, `email`, `password`, `status`, `created`, `last_login`) VALUES ('1', 'markerhub', 'https://image-1300566513.cos.ap-guangzhou.myqcloud.com/upload/images/5a9f48118166308daba8b6da7e466aab.jpg', NULL, '96e79218965eb72c92a549dd5a330112', '0', '2020-04-20 10:44:01', NULL);

Posted by ChrisMartino on Sun, 17 Apr 2022 19:36:09 +0930