整合 mybatis-plus knife4j 完善代码生成器
This commit is contained in:
parent
aa27bef61a
commit
da0ad38004
@ -33,31 +33,43 @@
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 代码生成器临时用-->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>1.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- <!– 集成mybatis–>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.mybatis.spring.boot</groupId>-->
|
||||
<!-- <artifactId>mybatis-spring-boot-starter</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– 集成mysql连接 –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>mysql</groupId>-->
|
||||
<!-- <artifactId>mysql-connector-java</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-validation</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.pagehelper</groupId>-->
|
||||
<!-- <artifactId>pagehelper-spring-boot-starter</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -68,9 +68,7 @@ public class LogAspect {
|
||||
// 排除特殊类型的参数,如文件类型
|
||||
Object[] arguments = new Object[args.length];
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i] instanceof ServletRequest
|
||||
|| args[i] instanceof ServletResponse
|
||||
|| args[i] instanceof MultipartFile) {
|
||||
if (args[i] instanceof ServletRequest || args[i] instanceof ServletResponse || args[i] instanceof MultipartFile) {
|
||||
continue;
|
||||
}
|
||||
arguments[i] = args[i];
|
||||
|
@ -0,0 +1,29 @@
|
||||
package com.yovinchen.train.common.config;
|
||||
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
/**
|
||||
* ClassName: SwaggerConfig
|
||||
* Package: com.yovinchen.train.member.config
|
||||
*
|
||||
* @author yovinchen
|
||||
* @Create 2024/1/19 16:38
|
||||
*/
|
||||
@Configuration
|
||||
public class SwaggerConfig {
|
||||
@Bean
|
||||
public OpenAPI TrainOpenAPI() {
|
||||
return new OpenAPI().info(new Info().title("tarin-backend")
|
||||
.description("train文档")
|
||||
.version("v1")
|
||||
.license(new License().name("Apache 2.0")))
|
||||
.externalDocs(new ExternalDocumentation().description("外部文档")
|
||||
.url("https://springshop.wiki.github.org/docs"));
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
|
@ -1,2 +1,22 @@
|
||||
server:
|
||||
port: 8000
|
||||
spring:
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: member
|
||||
uri: http://127.0.0.1:8001
|
||||
predicates:
|
||||
- Path=/member/**
|
||||
- id: product
|
||||
uri: http://127.0.0.1:8002
|
||||
predicates:
|
||||
- Path=/product/**
|
||||
- id: order
|
||||
uri: http://127.0.0.1:8003
|
||||
predicates:
|
||||
- Path=/order/**
|
||||
- id: user
|
||||
uri: http://127.0.0.1:8004
|
||||
predicates:
|
||||
- Path=/user/**
|
||||
|
@ -21,17 +21,7 @@
|
||||
<dependency>
|
||||
<groupId>com.yovinchen</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.yovinchen.train.member.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会员 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author yovinchen
|
||||
* @since 2024-01-19 04:10:59
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/member")
|
||||
public class MemberController {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.yovinchen.train.member.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 乘车人 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author yovinchen
|
||||
* @since 2024-01-19 04:10:59
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/passenger")
|
||||
public class PassengerController {
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.yovinchen.train.member.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会员
|
||||
* </p>
|
||||
*
|
||||
* @author yovinchen
|
||||
* @since 2024-01-19 04:36:29
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("member")
|
||||
@ApiModel(value = "Member对象", description = "会员")
|
||||
public class Member {
|
||||
|
||||
@ApiModelProperty("id")
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("手机号")
|
||||
@TableField("mobile")
|
||||
private String mobile;
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.yovinchen.train.member.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 乘车人
|
||||
* </p>
|
||||
*
|
||||
* @author yovinchen
|
||||
* @since 2024-01-19 04:36:29
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("passenger")
|
||||
@ApiModel(value = "Passenger对象", description = "乘车人")
|
||||
public class Passenger {
|
||||
|
||||
@ApiModelProperty("id")
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("会员id")
|
||||
@TableField("member_id")
|
||||
private Long memberId;
|
||||
|
||||
@ApiModelProperty("姓名")
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("身份证")
|
||||
@TableField("id_card")
|
||||
private String idCard;
|
||||
|
||||
@ApiModelProperty("旅客类型|枚举[PassengerTypeEnum]")
|
||||
@TableField("type")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty("新增时间")
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("修改时间")
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.yovinchen.train.member.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yovinchen.train.member.entity.Member;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会员 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author yovinchen
|
||||
* @since 2024-01-19 04:10:59
|
||||
*/
|
||||
@Mapper
|
||||
public interface MemberMapper extends BaseMapper<Member> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.yovinchen.train.member.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yovinchen.train.member.entity.Passenger;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 乘车人 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author yovinchen
|
||||
* @since 2024-01-19 04:10:59
|
||||
*/
|
||||
@Mapper
|
||||
public interface PassengerMapper extends BaseMapper<Passenger> {
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.yovinchen.train.member.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yovinchen.train.member.entity.Member;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会员 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author yovinchen
|
||||
* @since 2024-01-19 04:10:59
|
||||
*/
|
||||
public interface MemberService extends IService<Member> {
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.yovinchen.train.member.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yovinchen.train.member.entity.Passenger;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 乘车人 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author yovinchen
|
||||
* @since 2024-01-19 04:10:59
|
||||
*/
|
||||
public interface PassengerService extends IService<Passenger> {
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.yovinchen.train.member.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yovinchen.train.member.entity.Member;
|
||||
import com.yovinchen.train.member.mapper.MemberMapper;
|
||||
import com.yovinchen.train.member.service.MemberService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会员 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author yovinchen
|
||||
* @since 2024-01-19 04:10:59
|
||||
*/
|
||||
@Service
|
||||
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements MemberService {
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.yovinchen.train.member.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yovinchen.train.member.entity.Passenger;
|
||||
import com.yovinchen.train.member.mapper.PassengerMapper;
|
||||
import com.yovinchen.train.member.service.PassengerService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 乘车人 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author yovinchen
|
||||
* @since 2024-01-19 04:10:59
|
||||
*/
|
||||
@Service
|
||||
public class PassengerServiceImpl extends ServiceImpl<PassengerMapper, Passenger> implements PassengerService {
|
||||
|
||||
}
|
@ -1,7 +1,29 @@
|
||||
server:
|
||||
port: 8081
|
||||
port: 8001
|
||||
servlet:
|
||||
context-path: /member
|
||||
spring:
|
||||
application:
|
||||
name: member
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://82.157.68.223:3306/train?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
|
||||
name: train
|
||||
password: train
|
||||
# springdoc-openapi项目配置
|
||||
springdoc:
|
||||
swagger-ui:
|
||||
path: /swagger-ui.html
|
||||
tags-sorter: alpha
|
||||
operations-sorter: alpha
|
||||
api-docs:
|
||||
path: /v3/api-docs
|
||||
group-configs:
|
||||
- group: 'default'
|
||||
paths-to-match: '/**'
|
||||
packages-to-scan: com.yovinchen.train.member
|
||||
# knife4j的增强配置,不需要增强可以不配
|
||||
knife4j:
|
||||
enable: true
|
||||
setting:
|
||||
language: zh_cn
|
||||
|
5
member/src/main/resources/mapper/MemberXml.xml
Normal file
5
member/src/main/resources/mapper/MemberXml.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yovinchen.train.member.mapper.MemberMapper">
|
||||
|
||||
</mapper>
|
5
member/src/main/resources/mapper/PassengerXml.xml
Normal file
5
member/src/main/resources/mapper/PassengerXml.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yovinchen.train.member.mapper.PassengerMapper">
|
||||
|
||||
</mapper>
|
72
pom.xml
72
pom.xml
@ -22,6 +22,17 @@
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<spring-cloud.version>2022.0.0</spring-cloud.version>
|
||||
<fastjson.version>1.2.70</fastjson.version>
|
||||
<mybatis-plus.version>3.5.3.1</mybatis-plus.version>
|
||||
<mybatis-plus-generator.version>3.5.3.1</mybatis-plus-generator.version>
|
||||
<freemarker.version>2.3.31</freemarker.version>
|
||||
<hutool.version>5.8.25</hutool.version>
|
||||
<mysql.version>8.0.28</mysql.version>
|
||||
<pagehelper.version>1.4.6</pagehelper.version>
|
||||
<common.version>0.0.1-SNAPSHOT</common.version>
|
||||
<knife4j.version>4.2.0</knife4j.version>
|
||||
<lombok.version>1.18.30</lombok.version>
|
||||
<springfox.version>3.0.0</springfox.version>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
@ -36,44 +47,59 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.70</version>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.10</version>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.yovinchen</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.yovinchen</groupId>-->
|
||||
<!-- <artifactId>common</artifactId>-->
|
||||
<!-- <version>${common.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- 集成mybatis-->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<!-- 集成mysql连接 -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.22</version>
|
||||
<version>${mysql.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--MyBaitsPlus-->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.6</version>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<version>${mybatis-plus-generator.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
<version>${freemarker.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.github.xiaoymin/knife4j-openapi3-jakarta-spring-boot-starter -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
<version>${knife4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-common</artifactId>
|
||||
<version>${springfox.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.projectlombok</groupId>-->
|
||||
<!-- <artifactId>lombok</artifactId>-->
|
||||
<!-- <optional>true</optional>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<build>
|
||||
|
Loading…
Reference in New Issue
Block a user