整合 orm, 简单测试
This commit is contained in:
parent
9fa6af4679
commit
d387cbb235
64
dependencies/pom.xml
vendored
64
dependencies/pom.xml
vendored
@ -14,11 +14,43 @@
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<hutool.version>5.8.34</hutool.version>
|
||||
<wx-java.version>4.6.0</wx-java.version>
|
||||
<mybatis-plus.version>3.5.9</mybatis-plus.version>
|
||||
<pagehelper-starter.version>2.1.0</pagehelper-starter.version>
|
||||
<pagehelper.version>6.1.0</pagehelper.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.velocity/velocity-engine-core -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>2.4.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>4.5.0-M2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.17.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-bom</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
<type>pom</type>
|
||||
<!-- 注意这里是import -->
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>weixin-java-mp</artifactId>
|
||||
@ -36,6 +68,38 @@
|
||||
<artifactId>weixin-java-open</artifactId>
|
||||
<version>${wx-java.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-bom</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>${pagehelper-starter.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
<version>${pagehelper.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</project>
|
||||
|
369
platform-orm/design/wx-docking-platform.ndm2
Normal file
369
platform-orm/design/wx-docking-platform.ndm2
Normal file
@ -0,0 +1,369 @@
|
||||
{
|
||||
"paper": {
|
||||
"name": "A4",
|
||||
"leftMargin": 0.5,
|
||||
"rightMargin": 0.5,
|
||||
"topMargin": 0.5,
|
||||
"bottomMargin": 0.5,
|
||||
"isPortriat": true
|
||||
},
|
||||
"modelVersion": 2.01,
|
||||
"defaultSchema": "Default",
|
||||
"server": {
|
||||
"objectType": "Server_MYSQL",
|
||||
"name": "Default",
|
||||
"serverVersion": 80099,
|
||||
"edition": "Default",
|
||||
"lowerCaseTableNames": 0,
|
||||
"schemas": [
|
||||
{
|
||||
"objectType": "Schema_MYSQL",
|
||||
"name": "Default",
|
||||
"tables": [
|
||||
{
|
||||
"objectType": "Table_MYSQL",
|
||||
"name": "mp_app",
|
||||
"comment": "微信公众号记录表",
|
||||
"engine": "",
|
||||
"characterSet": "",
|
||||
"collation": "",
|
||||
"autoIncrement": 0,
|
||||
"tablespace": "",
|
||||
"storage": "",
|
||||
"insertMethod": "",
|
||||
"connection": "",
|
||||
"checksum": false,
|
||||
"rowFormat": "",
|
||||
"avgRowLength": 0,
|
||||
"maxRows": 0,
|
||||
"minRows": 0,
|
||||
"keyBlockSize": 0,
|
||||
"packKeys": "",
|
||||
"delayKeyWrite": false,
|
||||
"dataDirectory": "",
|
||||
"indexDirectory": "",
|
||||
"statsAutoRecalc": "",
|
||||
"statsPersistent": "",
|
||||
"statsSamplePages": 0,
|
||||
"union": "",
|
||||
"pageCheckSum": false,
|
||||
"transactional": false,
|
||||
"compression": "",
|
||||
"oldName": "",
|
||||
"encryption": false,
|
||||
"createOptions": "",
|
||||
"createTime": "",
|
||||
"checkTime": "",
|
||||
"dataFree": 0,
|
||||
"dataLength": 0,
|
||||
"indexLength": 0,
|
||||
"maxDataLength": 0,
|
||||
"rows": 0,
|
||||
"updateTime": "",
|
||||
"DDL": "",
|
||||
"partitionBy": "",
|
||||
"partitionByExpr": "",
|
||||
"partitions": 0,
|
||||
"partitionKeyAlgorithm": "",
|
||||
"subPartitionBy": "",
|
||||
"subPartitionByExpr": "",
|
||||
"subPartitions": 0,
|
||||
"subPartitionKeyAlgorithm": "",
|
||||
"fields": [
|
||||
{
|
||||
"objectType": "TableField_MYSQL",
|
||||
"name": "id",
|
||||
"type": "varchar",
|
||||
"length": 255,
|
||||
"decimals": -2147483648,
|
||||
"isUnsigned": false,
|
||||
"isZeroFill": false,
|
||||
"setEnumValues": "",
|
||||
"isBinary": false,
|
||||
"charset": "",
|
||||
"collation": "",
|
||||
"isNullable": false,
|
||||
"defaultType": "None",
|
||||
"defaultValue": "",
|
||||
"isOnUpdateCurrentTimestamp": false,
|
||||
"isAutoInc": false,
|
||||
"comment": "公众号id",
|
||||
"columnFormat": "",
|
||||
"storage": "",
|
||||
"isVirtual": false,
|
||||
"isGeneratedAlways": false,
|
||||
"virtualExpr": "",
|
||||
"virtualType": "",
|
||||
"oldName": "id"
|
||||
},
|
||||
{
|
||||
"objectType": "TableField_MYSQL",
|
||||
"name": "app_id",
|
||||
"type": "varchar",
|
||||
"length": 255,
|
||||
"decimals": -2147483648,
|
||||
"isUnsigned": false,
|
||||
"isZeroFill": false,
|
||||
"setEnumValues": "",
|
||||
"isBinary": false,
|
||||
"charset": "",
|
||||
"collation": "",
|
||||
"isNullable": false,
|
||||
"defaultType": "Others",
|
||||
"defaultValue": "",
|
||||
"isOnUpdateCurrentTimestamp": false,
|
||||
"isAutoInc": false,
|
||||
"comment": "开发者id",
|
||||
"columnFormat": "",
|
||||
"storage": "",
|
||||
"isVirtual": false,
|
||||
"isGeneratedAlways": false,
|
||||
"virtualExpr": "",
|
||||
"virtualType": "",
|
||||
"oldName": "app_id"
|
||||
},
|
||||
{
|
||||
"objectType": "TableField_MYSQL",
|
||||
"name": "app_name",
|
||||
"type": "varchar",
|
||||
"length": 255,
|
||||
"decimals": -2147483648,
|
||||
"isUnsigned": false,
|
||||
"isZeroFill": false,
|
||||
"setEnumValues": "",
|
||||
"isBinary": false,
|
||||
"charset": "",
|
||||
"collation": "",
|
||||
"isNullable": true,
|
||||
"defaultType": "Others",
|
||||
"defaultValue": "",
|
||||
"isOnUpdateCurrentTimestamp": false,
|
||||
"isAutoInc": false,
|
||||
"comment": "名称",
|
||||
"columnFormat": "",
|
||||
"storage": "",
|
||||
"isVirtual": false,
|
||||
"isGeneratedAlways": false,
|
||||
"virtualExpr": "",
|
||||
"virtualType": "",
|
||||
"oldName": "app_name"
|
||||
},
|
||||
{
|
||||
"objectType": "TableField_MYSQL",
|
||||
"name": "app_secret",
|
||||
"type": "varchar",
|
||||
"length": 255,
|
||||
"decimals": -2147483648,
|
||||
"isUnsigned": false,
|
||||
"isZeroFill": false,
|
||||
"setEnumValues": "",
|
||||
"isBinary": false,
|
||||
"charset": "",
|
||||
"collation": "",
|
||||
"isNullable": false,
|
||||
"defaultType": "Others",
|
||||
"defaultValue": "",
|
||||
"isOnUpdateCurrentTimestamp": false,
|
||||
"isAutoInc": false,
|
||||
"comment": "开发者密钥",
|
||||
"columnFormat": "",
|
||||
"storage": "",
|
||||
"isVirtual": false,
|
||||
"isGeneratedAlways": false,
|
||||
"virtualExpr": "",
|
||||
"virtualType": "",
|
||||
"oldName": "app_secret"
|
||||
},
|
||||
{
|
||||
"objectType": "TableField_MYSQL",
|
||||
"name": "token",
|
||||
"type": "varchar",
|
||||
"length": 255,
|
||||
"decimals": -2147483648,
|
||||
"isUnsigned": false,
|
||||
"isZeroFill": false,
|
||||
"setEnumValues": "",
|
||||
"isBinary": false,
|
||||
"charset": "",
|
||||
"collation": "",
|
||||
"isNullable": false,
|
||||
"defaultType": "Others",
|
||||
"defaultValue": "",
|
||||
"isOnUpdateCurrentTimestamp": false,
|
||||
"isAutoInc": false,
|
||||
"comment": "令牌",
|
||||
"columnFormat": "",
|
||||
"storage": "",
|
||||
"isVirtual": false,
|
||||
"isGeneratedAlways": false,
|
||||
"virtualExpr": "",
|
||||
"virtualType": "",
|
||||
"oldName": "token"
|
||||
},
|
||||
{
|
||||
"objectType": "TableField_MYSQL",
|
||||
"name": "encoding_aes_key",
|
||||
"type": "varchar",
|
||||
"length": 43,
|
||||
"decimals": -2147483648,
|
||||
"isUnsigned": false,
|
||||
"isZeroFill": false,
|
||||
"setEnumValues": "",
|
||||
"isBinary": false,
|
||||
"charset": "",
|
||||
"collation": "",
|
||||
"isNullable": true,
|
||||
"defaultType": "Others",
|
||||
"defaultValue": "",
|
||||
"isOnUpdateCurrentTimestamp": false,
|
||||
"isAutoInc": false,
|
||||
"comment": "消息加密密钥",
|
||||
"columnFormat": "",
|
||||
"storage": "",
|
||||
"isVirtual": false,
|
||||
"isGeneratedAlways": false,
|
||||
"virtualExpr": "",
|
||||
"virtualType": "",
|
||||
"oldName": "encoding_aes_key"
|
||||
},
|
||||
{
|
||||
"objectType": "TableField_MYSQL",
|
||||
"name": "enable",
|
||||
"type": "tinyint",
|
||||
"length": 1,
|
||||
"decimals": -2147483648,
|
||||
"isUnsigned": false,
|
||||
"isZeroFill": false,
|
||||
"setEnumValues": "",
|
||||
"isBinary": false,
|
||||
"charset": "",
|
||||
"collation": "",
|
||||
"isNullable": false,
|
||||
"defaultType": "Others",
|
||||
"defaultValue": "1",
|
||||
"isOnUpdateCurrentTimestamp": false,
|
||||
"isAutoInc": false,
|
||||
"comment": "是否启用",
|
||||
"columnFormat": "",
|
||||
"storage": "",
|
||||
"isVirtual": false,
|
||||
"isGeneratedAlways": false,
|
||||
"virtualExpr": "",
|
||||
"virtualType": "",
|
||||
"oldName": "enable"
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
{
|
||||
"objectType": "Index_MYSQL",
|
||||
"name": "",
|
||||
"type": "",
|
||||
"method": "",
|
||||
"comment": "",
|
||||
"oldName": "",
|
||||
"online": false,
|
||||
"keyBlockSize": 0,
|
||||
"parser": "",
|
||||
"algorithm": "",
|
||||
"lock": "",
|
||||
"collation": "",
|
||||
"cardinality": "",
|
||||
"packed": "",
|
||||
"fields": [
|
||||
{
|
||||
"objectType": "IndexField_MYSQL",
|
||||
"name": "app_id",
|
||||
"keyLength": 0,
|
||||
"order": "",
|
||||
"oldName": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"objectType": "Index_MYSQL",
|
||||
"name": "",
|
||||
"type": "",
|
||||
"method": "",
|
||||
"comment": "",
|
||||
"oldName": "",
|
||||
"online": false,
|
||||
"keyBlockSize": 0,
|
||||
"parser": "",
|
||||
"algorithm": "",
|
||||
"lock": "",
|
||||
"collation": "",
|
||||
"cardinality": "",
|
||||
"packed": "",
|
||||
"fields": [
|
||||
{
|
||||
"objectType": "IndexField_MYSQL",
|
||||
"name": "app_name",
|
||||
"keyLength": 0,
|
||||
"order": "",
|
||||
"oldName": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"objectType": "PrimaryKey_MYSQL",
|
||||
"name": "",
|
||||
"fields": [
|
||||
{
|
||||
"objectType": "IndexField_MYSQL",
|
||||
"name": "id",
|
||||
"keyLength": 0,
|
||||
"order": "",
|
||||
"oldName": ""
|
||||
}
|
||||
],
|
||||
"oldName": "",
|
||||
"indexMethod": "",
|
||||
"comment": ""
|
||||
},
|
||||
"foreignKeys": [],
|
||||
"triggers": [],
|
||||
"tablePartitions": []
|
||||
}
|
||||
],
|
||||
"views": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"diagrams": [
|
||||
{
|
||||
"name": "Diagram 1",
|
||||
"paperWidth": 1,
|
||||
"paperHeight": 1,
|
||||
"tableFont": "Arial Unicode MS",
|
||||
"tableFontSize": 14,
|
||||
"isBalckWhite": false,
|
||||
"showDBSchemaName": false,
|
||||
"showViewRelations": true,
|
||||
"notation": "default",
|
||||
"showFieldComment": true,
|
||||
"showTableComment": true,
|
||||
"shapes": [
|
||||
{
|
||||
"type": "table",
|
||||
"schemaName": "Default",
|
||||
"tableName": "mp_app",
|
||||
"x": 30,
|
||||
"y": 30,
|
||||
"width": 340,
|
||||
"height": 220,
|
||||
"isBold": false,
|
||||
"titleColor": {
|
||||
"r": 55,
|
||||
"g": 131,
|
||||
"b": 192,
|
||||
"a": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"layers": [],
|
||||
"relations": [],
|
||||
"viewRelations": []
|
||||
}
|
||||
]
|
||||
}
|
75
platform-orm/pom.xml
Normal file
75
platform-orm/pom.xml
Normal file
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cn.skcks.docking.wx</groupId>
|
||||
<artifactId>wx-docking-platform</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>platform-orm</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- jdk 11+ 引入可选模块 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-jsqlparser</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--liquibase-->
|
||||
<dependency>
|
||||
<groupId>org.liquibase</groupId>
|
||||
<artifactId>liquibase-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,27 @@
|
||||
package cn.skcks.docking.wx.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.mybatis.spring.annotation.MapperScans;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@MapperScans({
|
||||
@MapperScan("cn.skcks.docking.wx.orm")
|
||||
})
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 添加分页插件
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); // 如果配置多个插件, 切记分页最后添加
|
||||
// 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType
|
||||
return interceptor;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package cn.skcks.docking.wx.orm.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import java.io.Serializable;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 微信公众号记录表
|
||||
* </p>
|
||||
*
|
||||
* @author shikong
|
||||
* @since 2024-12-07
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("mp_app")
|
||||
public class MpApp extends Model<MpApp> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 公众号id
|
||||
*/
|
||||
@TableId("id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 开发者id
|
||||
*/
|
||||
@TableField("app_id")
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField("app_name")
|
||||
private String appName;
|
||||
|
||||
/**
|
||||
* 开发者密钥
|
||||
*/
|
||||
@TableField("app_secret")
|
||||
private String appSecret;
|
||||
|
||||
/**
|
||||
* 令牌
|
||||
*/
|
||||
@TableField("token")
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 消息加密密钥
|
||||
*/
|
||||
@TableField("encoding_aes_key")
|
||||
private String encodingAesKey;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@TableField("enable")
|
||||
private Boolean enable;
|
||||
|
||||
@Override
|
||||
public Serializable pkVal() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cn.skcks.docking.wx.orm.mapper;
|
||||
|
||||
import cn.skcks.docking.wx.orm.entity.MpApp;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 微信公众号记录表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author shikong
|
||||
* @since 2024-12-07
|
||||
*/
|
||||
public interface MpAppMapper extends BaseMapper<MpApp> {
|
||||
|
||||
}
|
@ -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="cn.skcks.docking.wx.orm.mapper.MpAppMapper">
|
||||
|
||||
</mapper>
|
9
platform-orm/src/main/resources/application.yaml
Normal file
9
platform-orm/src/main/resources/application.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
spring:
|
||||
liquibase:
|
||||
enabled: true
|
||||
change-log: classpath:db/changelog-master.xml
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: 12341234
|
||||
url: jdbc:mysql://10.10.10.200:3306/wx-docking-platform?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
|
11
platform-orm/src/main/resources/db/changelog-master.xml
Normal file
11
platform-orm/src/main/resources/db/changelog-master.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||
|
||||
<changeSet id="1733576524057-1" author="shikong">
|
||||
<sqlFile path="schema/0.init.sql"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,15 @@
|
||||
package cn.skcks.docking.wx;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
|
||||
@SpringBootApplication
|
||||
public class OrmGeneratorTest {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication app = new SpringApplicationBuilder(OrmGeneratorTest.class)
|
||||
.profiles("generator")
|
||||
.build();
|
||||
app.run(args);
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package cn.skcks.docking.wx.orm.generator;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@Slf4j
|
||||
@Profile("generator")
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class OrmGenerator implements SmartLifecycle {
|
||||
private final DataSourceProperties dataSourceProperties;
|
||||
private final ConfigurableApplicationContext context;
|
||||
private boolean isRunning;
|
||||
|
||||
private final static String sourceDir = Paths.get(System.getProperty("user.dir")) + "/platform-orm/src/main/java";
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
isRunning = true;
|
||||
|
||||
generate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return isRunning;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private static String getGitUserName(){
|
||||
BufferedReader bufferedReader = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
Runtime.getRuntime().exec("git config user.name")
|
||||
.getInputStream()));
|
||||
return bufferedReader.readLine();
|
||||
}
|
||||
|
||||
private void generate(){
|
||||
log.info("[+] 开始从数据库生成实体类");
|
||||
FastAutoGenerator.create(dataSourceProperties.getUrl(), dataSourceProperties.getUsername(), dataSourceProperties.getPassword())
|
||||
.globalConfig(builder -> {
|
||||
builder.author(getGitUserName())
|
||||
.outputDir(sourceDir)
|
||||
.commentDate(DatePattern.NORM_DATE_PATTERN);
|
||||
})
|
||||
.packageConfig(builder -> {
|
||||
builder.parent("cn.skcks.docking.wx.orm")
|
||||
.entity("entity")
|
||||
.mapper("mapper")
|
||||
.service("service")
|
||||
.serviceImpl("service.impl")
|
||||
.xml("mapper.xml");
|
||||
}).strategyConfig(builder -> builder
|
||||
.enableSkipView()
|
||||
.addInclude("^mp_.*")
|
||||
.entityBuilder()
|
||||
//开启文件覆盖
|
||||
// .enableFileOverride()
|
||||
//开启链式模型
|
||||
.enableChainModel()
|
||||
//开启Lombok
|
||||
.enableLombok()
|
||||
.enableTableFieldAnnotation()//开启生成实体时生成字段注解
|
||||
//开启 ActiveRecord 模型(封装了实体一些简单持久化操作,必须有对应的BaseMapper实现)
|
||||
.enableActiveRecord()
|
||||
.controllerBuilder().disable()
|
||||
.serviceBuilder().disable()
|
||||
)
|
||||
.templateEngine(new VelocityTemplateEngine())
|
||||
.execute();
|
||||
System.exit(SpringApplication.exit(context, () -> 0));
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
spring:
|
||||
liquibase:
|
||||
enabled: true
|
||||
change-log: classpath:db/changelog-master.xml
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: 12341234
|
||||
url: jdbc:mysql://10.10.10.200:3306/wx-docking-platform?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
|
@ -36,6 +36,16 @@
|
||||
<artifactId>wx-docking-platform-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.skcks.docking.wx</groupId>
|
||||
<artifactId>platform-orm</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.skcks.docking.wx.annotation</groupId>
|
||||
<artifactId>wx-docking-platform-annotation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -1,9 +1,11 @@
|
||||
package cn.skcks.docking.wx.services.mp;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.mybatis.spring.annotation.MapperScans;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(scanBasePackages = "cn.skcks.docking.wx")
|
||||
public class WxMpServiceStarter {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(WxMpServiceStarter.class, args);
|
||||
|
@ -0,0 +1,48 @@
|
||||
package cn.skcks.docking.wx.services.mp.config;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import lombok.Data;
|
||||
import org.springdoc.core.customizers.OpenApiCustomizer;
|
||||
import org.springdoc.core.models.GroupedOpenApi;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.springdoc.core.utils.Constants.ALL_PATTERN;
|
||||
|
||||
@Configuration
|
||||
@Data
|
||||
public class SwaggerConfig {
|
||||
public static final Info INFO;
|
||||
private static final License LICENSE;
|
||||
|
||||
static {
|
||||
INFO = new Info()
|
||||
.contact(new Contact()
|
||||
.name("shikong")
|
||||
.url("https://skon.top")
|
||||
.email("skon@duck.com"))
|
||||
.title("MpApp API")
|
||||
.description("MpApp API description")
|
||||
.version("2.0");
|
||||
LICENSE = new License()
|
||||
.name("Apache 2.0")
|
||||
.url("http://www.apache.org/licenses/LICENSE-2.0.html");
|
||||
INFO.license(LICENSE);
|
||||
}
|
||||
|
||||
public static GroupedOpenApi api(String group, String path) {
|
||||
return GroupedOpenApi.builder()
|
||||
.group(group)
|
||||
.pathsToMatch(path + ALL_PATTERN)
|
||||
.addOpenApiCustomizer(openApi -> openApi.info(SwaggerConfig.INFO))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi mpApi(){
|
||||
return api("mp-app", "/");
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package cn.skcks.docking.wx.services.mp.controller;
|
||||
|
||||
import cn.skcks.docking.wx.annotation.web.methods.GetJson;
|
||||
import cn.skcks.docking.wx.common.json.JsonResponse;
|
||||
import cn.skcks.docking.wx.common.page.PageWrapper;
|
||||
import cn.skcks.docking.wx.orm.entity.MpApp;
|
||||
import cn.skcks.docking.wx.services.mp.service.MpAppService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "微信公众号")
|
||||
@RequestMapping("/mp-app")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class MpAppController {
|
||||
private final MpAppService mpAppService;
|
||||
|
||||
|
||||
@Operation(summary = "公众号列表")
|
||||
@GetJson("/list")
|
||||
public JsonResponse<List<MpApp>> getMpAppList() {
|
||||
List<MpApp> mpAppList = mpAppService.getMpAppList();
|
||||
return JsonResponse.success(mpAppList);
|
||||
}
|
||||
|
||||
@Operation(summary = "公众号分页列表")
|
||||
@GetJson("/page")
|
||||
@Parameters({
|
||||
@Parameter(name = "pageNo", description = "页数", example = "1"),
|
||||
@Parameter(name = "pageSize", description = "条数", example = "10")
|
||||
})
|
||||
public JsonResponse<PageWrapper<MpApp>> getMpAppListPage(@RequestParam Integer pageNo, @RequestParam Integer pageSize) {
|
||||
return JsonResponse.success(mpAppService.getMpAppPageList(pageNo,pageSize));
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cn.skcks.docking.wx.services.mp.service;
|
||||
|
||||
import cn.skcks.docking.wx.common.page.PageWrapper;
|
||||
import cn.skcks.docking.wx.orm.entity.MpApp;
|
||||
import cn.skcks.docking.wx.orm.mapper.MpAppMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MpAppService {
|
||||
private final MpAppMapper mpAppMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有公众号列表
|
||||
*
|
||||
* @author shikong
|
||||
* @since 2024-12-07
|
||||
*/
|
||||
public List<MpApp> getMpAppList(){
|
||||
return mpAppMapper.selectList(null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询公众号列表
|
||||
*
|
||||
* @author shikong
|
||||
* @since 2024-12-07
|
||||
*/
|
||||
public PageWrapper<MpApp> getMpAppPageList(Integer pageNum, Integer pageSize){
|
||||
// try(Page<Object> ignored = PageHelper.startPage(pageNum, pageSize)){
|
||||
// return new PageInfo<>(mpAppMapper.selectList(null));
|
||||
// }
|
||||
|
||||
Page<MpApp> mpAppPage = mpAppMapper.selectPage(new Page<>(pageNum, pageSize), null);
|
||||
return PageWrapper.of(mpAppPage);
|
||||
}
|
||||
}
|
7
pom.xml
7
pom.xml
@ -36,6 +36,7 @@
|
||||
<module>wx-docking-platform-annotation</module>
|
||||
<module>platform-services</module>
|
||||
<module>dependencies</module>
|
||||
<module>platform-orm</module>
|
||||
</modules>
|
||||
|
||||
<scm>
|
||||
@ -71,6 +72,12 @@
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.skcks.docking.wx</groupId>
|
||||
<artifactId>platform-orm</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.skcks.docking.wx.annotation</groupId>
|
||||
<artifactId>wx-docking-platform-annotation</artifactId>
|
||||
|
@ -24,6 +24,20 @@
|
||||
<artifactId>springdoc-openapi-starter-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
@ -48,5 +62,15 @@
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-extension</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.skcks.docking.wx.common.page;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -27,4 +29,20 @@ public class PageWrapper<T> {
|
||||
public static <T> PageWrapper<T> of(Collection<T> data, long page, long pageSize, long pageTotal, long total) {
|
||||
return new PageWrapper<>(data, page, pageSize, pageTotal, total);
|
||||
}
|
||||
|
||||
public static <T> PageWrapper<T> of(PageInfo<T> pageInfo) {
|
||||
return new PageWrapper<>(pageInfo.getList(),
|
||||
pageInfo.getPageNum(),
|
||||
pageInfo.getPageSize(),
|
||||
pageInfo.getPages(),
|
||||
pageInfo.getTotal());
|
||||
}
|
||||
|
||||
public static <T> PageWrapper<T> of(Page<T> page) {
|
||||
return new PageWrapper<>(page.getRecords(),
|
||||
page.getCurrent(),
|
||||
page.getSize(),
|
||||
page.getPages(),
|
||||
page.getTotal());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
# 日志文件配置
|
||||
#logging:
|
||||
# config: classpath:logback.xml
|
||||
|
||||
spring:
|
||||
# json 配置
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
deserialization:
|
||||
# 忽略没有的字段
|
||||
fail_on_unknown_properties: false
|
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!--输出到控制台-->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">-->
|
||||
<!-- <level>INFO</level>-->
|
||||
<!-- </filter>-->
|
||||
<!-- <withJansi>true</withJansi>-->
|
||||
<encoder>
|
||||
<!--<pattern>%d %p (%file:%line\)- %m%n</pattern>-->
|
||||
<!--格式化输出:%d:表示日期 %thread:表示线程名 %-5level:级别从左显示5个字符宽度 %msg:日志消息 %n:是换行符-->
|
||||
<pattern>%red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%thread]) %highlight(%-5level) %yellow(at %class.%method) (%file:%line\) - %cyan(%msg%n)</pattern>
|
||||
<!--<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %magenta(%-5level) %green([%-50.50class]) >>> %cyan(%msg) %n</pattern>-->
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<Loggers>
|
||||
|
||||
<Root level="INFO">
|
||||
<AppenderRef ref="console"/>
|
||||
</Root>
|
||||
|
||||
<Logger name="cn.skcks" level="DEBUG"/>
|
||||
|
||||
</Loggers>
|
||||
</Configuration>
|
Loading…
Reference in New Issue
Block a user