diff --git a/mybatis-flex-test/mybatis-flex-seata-test/mybatis-flex.config b/mybatis-flex-test/mybatis-flex-seata-test/mybatis-flex.config new file mode 100644 index 00000000..f6050f8b --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-seata-test/mybatis-flex.config @@ -0,0 +1 @@ +processor.mapper.generateEnable=true diff --git a/mybatis-flex-test/mybatis-flex-seata-test/pom.xml b/mybatis-flex-test/mybatis-flex-seata-test/pom.xml new file mode 100644 index 00000000..af3998bc --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-seata-test/pom.xml @@ -0,0 +1,67 @@ + + + + mybatis-flex-test + com.mybatis-flex + 1.5.6 + + 4.0.0 + + mybatis-flex-seata-test + jar + + + 8 + 8 + + + + + com.mybatis-flex + mybatis-flex-spring-boot-starter + ${mybatis-flex.version} + + + + org.springframework.boot + spring-boot-starter-web + + + + com.alibaba.fastjson2 + fastjson2 + 2.0.32 + + + + com.alibaba + druid-spring-boot-starter + 1.2.18 + + + + org.springframework.boot + spring-boot-starter-data-jdbc + + + + com.mysql + mysql-connector-j + + + + io.seata + seata-spring-boot-starter + 1.7.0 + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + diff --git a/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/MybatisFlexSpringBootSeataApplication.java b/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/MybatisFlexSpringBootSeataApplication.java new file mode 100644 index 00000000..6a60a118 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/MybatisFlexSpringBootSeataApplication.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@MapperScan("com.mybatisflex.test.mapper") +public class MybatisFlexSpringBootSeataApplication { + + public static void main(String[] args) { + SpringApplication.run(MybatisFlexSpringBootSeataApplication.class, args); + } + +} diff --git a/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/controller/TestController.java b/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/controller/TestController.java new file mode 100644 index 00000000..77b093d1 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/controller/TestController.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test.controller; + +import com.mybatisflex.core.audit.AuditManager; +import com.mybatisflex.core.audit.ConsoleMessageCollector; +import com.mybatisflex.core.audit.MessageCollector; +import com.mybatisflex.test.service.TestService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +public class TestController { + + + @Autowired + TestService testService; + + @RequestMapping("buy") + public String buy() { + //开启审计功能 + AuditManager.setAuditEnable(true); + //设置 SQL 审计收集器 + MessageCollector collector = new ConsoleMessageCollector(); + AuditManager.setMessageCollector(collector); + return String.valueOf(testService.buy()); + } + +} diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/AccountTbl.java b/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/entity/AccountTbl.java similarity index 54% rename from mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/AccountTbl.java rename to mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/entity/AccountTbl.java index ee716d42..d2629d81 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/AccountTbl.java +++ b/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/entity/AccountTbl.java @@ -1,13 +1,26 @@ -package com.mybatisfle.test.mybatisflexspringbootseata.entity; +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test.entity; import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; + import java.io.Serializable; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; /** * 实体类。 diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/OrderTbl.java b/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/entity/OrderTbl.java similarity index 63% rename from mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/OrderTbl.java rename to mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/entity/OrderTbl.java index 8f5b7c2f..d9f32725 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/OrderTbl.java +++ b/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/entity/OrderTbl.java @@ -1,13 +1,26 @@ -package com.mybatisfle.test.mybatisflexspringbootseata.entity; +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test.entity; import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; + import java.io.Serializable; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; /** * 实体类。 diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/StockTbl.java b/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/entity/StockTbl.java similarity index 56% rename from mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/StockTbl.java rename to mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/entity/StockTbl.java index f452cdec..e38e090f 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/StockTbl.java +++ b/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/entity/StockTbl.java @@ -1,13 +1,26 @@ -package com.mybatisfle.test.mybatisflexspringbootseata.entity; +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test.entity; import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; + import java.io.Serializable; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; /** * 实体类。 diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/service/TestService.java b/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/service/TestService.java similarity index 58% rename from mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/service/TestService.java rename to mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/service/TestService.java index 77a811e5..15acd016 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/service/TestService.java +++ b/mybatis-flex-test/mybatis-flex-seata-test/src/main/java/com/mybatisflex/test/service/TestService.java @@ -1,23 +1,37 @@ -package com.mybatisfle.test.mybatisflexspringbootseata.service; +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test.service; -import com.mybatisfle.test.mybatisflexspringbootseata.entity.AccountTbl; -import com.mybatisfle.test.mybatisflexspringbootseata.entity.OrderTbl; -import com.mybatisfle.test.mybatisflexspringbootseata.entity.StockTbl; -import com.mybatisfle.test.mybatisflexspringbootseata.entity.table.AccountTblTableDef; -import com.mybatisfle.test.mybatisflexspringbootseata.mapper.AccountTblMapper; -import com.mybatisfle.test.mybatisflexspringbootseata.mapper.OrderTblMapper; -import com.mybatisfle.test.mybatisflexspringbootseata.mapper.StockTblMapper; import com.mybatisflex.core.datasource.DataSourceKey; import com.mybatisflex.core.query.QueryWrapper; +import com.mybatisflex.test.entity.AccountTbl; +import com.mybatisflex.test.entity.OrderTbl; +import com.mybatisflex.test.entity.StockTbl; +import com.mybatisflex.test.entity.table.AccountTblTableDef; +import com.mybatisflex.test.mapper.AccountTblMapper; +import com.mybatisflex.test.mapper.OrderTblMapper; +import com.mybatisflex.test.mapper.StockTblMapper; import io.seata.core.context.RootContext; import io.seata.spring.annotation.GlobalTransactional; import org.mybatis.logging.Logger; import org.mybatis.logging.LoggerFactory; -import org.mybatis.spring.SqlSessionFactoryBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service public class TestService { @@ -33,12 +47,12 @@ public class TestService { @Autowired StockTblMapper stockTblMapper; -// @Transactional + // @Transactional @GlobalTransactional public boolean buy() { // DataSourceKey.use("accountdb"); - LOGGER.warn(() -> "xid:"+RootContext.getXID()); - QueryWrapper account =new QueryWrapper(); + LOGGER.warn(() -> "xid:" + RootContext.getXID()); + QueryWrapper account = new QueryWrapper(); account.where(AccountTblTableDef.ACCOUNT_TBL.USER_ID.eq("1001")); AccountTbl accountTbl = accountTblMapper.selectOneByQuery(account); accountTbl.setMoney(accountTbl.getMoney() - 5); @@ -59,4 +73,5 @@ public class TestService { orderTblMapper.insert(orderTbl); return true; } + } diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/resources/application.yml b/mybatis-flex-test/mybatis-flex-seata-test/src/main/resources/application.yml similarity index 99% rename from mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/resources/application.yml rename to mybatis-flex-test/mybatis-flex-seata-test/src/main/resources/application.yml index 2000304f..97c7b42c 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/resources/application.yml +++ b/mybatis-flex-test/mybatis-flex-seata-test/src/main/resources/application.yml @@ -1,4 +1,3 @@ - mybatis-flex: seata-config: enable: true #启动seata diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/resources/db/all_in_one.sql b/mybatis-flex-test/mybatis-flex-seata-test/src/main/resources/db/all_in_one.sql similarity index 100% rename from mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/resources/db/all_in_one.sql rename to mybatis-flex-test/mybatis-flex-seata-test/src/main/resources/db/all_in_one.sql diff --git a/mybatis-flex-test/mybatis-flex-seata-test/src/test/java/com/mybatisflex/test/MybatisFlexSpringBootSeataApplicationTests.java b/mybatis-flex-test/mybatis-flex-seata-test/src/test/java/com/mybatisflex/test/MybatisFlexSpringBootSeataApplicationTests.java new file mode 100644 index 00000000..812410b1 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-seata-test/src/test/java/com/mybatisflex/test/MybatisFlexSpringBootSeataApplicationTests.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class MybatisFlexSpringBootSeataApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/pom.xml b/mybatis-flex-test/mybatis-flex-spring-boot-seata/pom.xml deleted file mode 100644 index e7fd6f34..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-boot-seata/pom.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - 4.0.0 - - mybatis-flex-test - com.mybatis-flex - 1.5.6 - - com.mybatisfle.test - mybatis-flex-spring-boot-seata - 0.0.1-SNAPSHOT - mybatis-flex-spring-boot-seata - mybatis-flex-spring-boot-seata - - 1.8 - - - - com.mybatis-flex - mybatis-flex-spring-boot-starter - ${mybatis-flex.version} - - - - com.mybatis-flex - mybatis-flex-codegen - ${mybatis-flex.version} - - - - org.springframework.boot - spring-boot-starter-web - - - - com.alibaba.fastjson2 - fastjson2 - 2.0.32 - - - - com.alibaba - druid-spring-boot-starter - 1.2.18 - - - - - - - - - - - - - - - org.springframework.boot - spring-boot-starter-data-jdbc - - - - com.mysql - mysql-connector-j - - - - io.seata - seata-spring-boot-starter - 1.7.0 - - - - - - - - - - - - - - - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.projectlombok - lombok - RELEASE - compile - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.projectlombok - lombok - - - - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - false - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - false - - - - - diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/MybatisFlexSpringBootSeataApplication.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/MybatisFlexSpringBootSeataApplication.java deleted file mode 100644 index 142a5773..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/MybatisFlexSpringBootSeataApplication.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mybatisfle.test.mybatisflexspringbootseata; - -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@MapperScan("com.mybatisfle.test.mybatisflexspringbootseata") -@SpringBootApplication -public class MybatisFlexSpringBootSeataApplication { - - public static void main(String[] args) { - SpringApplication.run(MybatisFlexSpringBootSeataApplication.class, args); - } - -} diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/controller/TestController.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/controller/TestController.java deleted file mode 100644 index b32d80b5..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/controller/TestController.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mybatisfle.test.mybatisflexspringbootseata.controller; - -import com.mybatisfle.test.mybatisflexspringbootseata.service.TestService; -import com.mybatisflex.core.audit.AuditManager; -import com.mybatisflex.core.audit.ConsoleMessageCollector; -import com.mybatisflex.core.audit.MessageCollector; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -@Controller -public class TestController { - - - @Autowired - TestService testService; - - @RequestMapping("buy") - public String buy(){ - //开启审计功能 - AuditManager.setAuditEnable(true); -//设置 SQL 审计收集器 - MessageCollector collector = new ConsoleMessageCollector(); - AuditManager.setMessageCollector(collector); - String flag =String.valueOf(testService.buy()); - return flag; - } -} diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/AccountTblMapper.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/AccountTblMapper.java deleted file mode 100644 index f6a9cdd5..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/AccountTblMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mybatisfle.test.mybatisflexspringbootseata.mapper; - - -import com.mybatisfle.test.mybatisflexspringbootseata.entity.AccountTbl; -import com.mybatisflex.core.BaseMapper; - -/** - * 映射层。 - * - * @author life - * @since 2023-08-03 - */ -public interface AccountTblMapper extends BaseMapper { - -} diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/OrderTblMapper.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/OrderTblMapper.java deleted file mode 100644 index 56983337..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/OrderTblMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mybatisfle.test.mybatisflexspringbootseata.mapper; - - -import com.mybatisfle.test.mybatisflexspringbootseata.entity.OrderTbl; -import com.mybatisflex.core.BaseMapper; - -/** - * 映射层。 - * - * @author life - * @since 2023-08-03 - */ -public interface OrderTblMapper extends BaseMapper { - -} diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/StockTblMapper.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/StockTblMapper.java deleted file mode 100644 index ef6abe50..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/StockTblMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mybatisfle.test.mybatisflexspringbootseata.mapper; - - -import com.mybatisfle.test.mybatisflexspringbootseata.entity.StockTbl; -import com.mybatisflex.core.BaseMapper; - -/** - * 映射层。 - * - * @author life - * @since 2023-08-03 - */ -public interface StockTblMapper extends BaseMapper { - -} diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/utils/Codegen.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/utils/Codegen.java deleted file mode 100644 index a1dd2649..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/utils/Codegen.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.mybatisfle.test.mybatisflexspringbootseata.utils; - -import com.mybatisflex.codegen.Generator; -import com.mybatisflex.codegen.config.ColumnConfig; -import com.mybatisflex.codegen.config.GlobalConfig; -import com.zaxxer.hikari.HikariDataSource; - -public class Codegen { - - public static void main(String[] args) { - //配置数据源 - HikariDataSource dataSource = new HikariDataSource(); - dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/db_stock?characterEncoding=utf-8"); - dataSource.setUsername("root"); - dataSource.setPassword("131496"); - - //创建配置内容,两种风格都可以。 - GlobalConfig globalConfig = createGlobalConfigUseStyle1(); - //GlobalConfig globalConfig = createGlobalConfigUseStyle2(); - - //通过 datasource 和 globalConfig 创建代码生成器 - Generator generator = new Generator(dataSource, globalConfig); - - //生成代码 - generator.generate(); - } - - public static GlobalConfig createGlobalConfigUseStyle1() { - //创建配置内容 - GlobalConfig globalConfig = new GlobalConfig(); - - //设置根包 - globalConfig.setBasePackage("com.mybatisfle.test.mybatisflexspringbootseata"); - - //设置表前缀和只生成哪些表 - globalConfig.setGenerateSchema("db_stock"); -// globalConfig.setTablePrefix("tb_"); - globalConfig.setGenerateTable("stock_tbl"); - - //设置生成 entity 并启用 Lombok - globalConfig.setEntityGenerateEnable(true); - globalConfig.setEntityWithLombok(true); - - //设置生成 mapper - globalConfig.setMapperGenerateEnable(true); - - //可以单独配置某个列 -// ColumnConfig columnConfig = new ColumnConfig(); -// columnConfig.setColumnName("tenant_id"); -// columnConfig.setLarge(true); -// columnConfig.setVersion(true); -// globalConfig.setColumnConfig("account", columnConfig); - - return globalConfig; - } - - public static GlobalConfig createGlobalConfigUseStyle2() { - //创建配置内容 - GlobalConfig globalConfig = new GlobalConfig(); - - //设置根包 - globalConfig.getPackageConfig() - .setBasePackage("com.test"); - - //设置表前缀和只生成哪些表,setGenerateTable 未配置时,生成所有表 - globalConfig.getStrategyConfig() - .setGenerateSchema("schema") - .setTablePrefix("tb_") - .setGenerateTable("account", "account_session"); - - //设置生成 entity 并启用 Lombok - globalConfig.enableEntity() - .setWithLombok(true); - - //设置生成 mapper - globalConfig.enableMapper(); - - //可以单独配置某个列 - ColumnConfig columnConfig = new ColumnConfig(); - columnConfig.setColumnName("tenant_id"); - columnConfig.setLarge(true); - columnConfig.setVersion(true); - globalConfig.getStrategyConfig() - .setColumnConfig("account", columnConfig); - - return globalConfig; - } -} diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/test/java/com/mybatisfle/test/mybatisflexspringbootseata/MybatisFlexSpringBootSeataApplicationTests.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/test/java/com/mybatisfle/test/mybatisflexspringbootseata/MybatisFlexSpringBootSeataApplicationTests.java deleted file mode 100644 index f763ac31..00000000 --- a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/test/java/com/mybatisfle/test/mybatisflexspringbootseata/MybatisFlexSpringBootSeataApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.mybatisfle.test.mybatisflexspringbootseata; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class MybatisFlexSpringBootSeataApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/mybatis-flex-test/pom.xml b/mybatis-flex-test/pom.xml index af9c75ff..0643868e 100644 --- a/mybatis-flex-test/pom.xml +++ b/mybatis-flex-test/pom.xml @@ -15,10 +15,10 @@ mybatis-flex-native-test + mybatis-flex-seata-test mybatis-flex-spring-test mybatis-flex-spring-boot-test mybatis-flex-spring-cloud-test - mybatis-flex-spring-boot-seata