diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java index 38c46d43..9ddca909 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java @@ -68,17 +68,6 @@ class AccountMapperTest { accountMapper.selectListByQuery(QueryWrapper.create()).forEach(System.err::println); } - @Test - void testListString() { - QueryWrapper queryWrapper = QueryWrapper.create() - .select(ACCOUNT.ALL_COLUMNS, ROLE.ROLE_NAME.as("roles")) - .from(ACCOUNT) - .leftJoin(USER_ROLE).on(USER_ROLE.USER_ID.eq(ACCOUNT.ID)) - .leftJoin(ROLE).on(USER_ROLE.ROLE_ID.eq(ROLE.ROLE_ID)); - accountMapper.selectListByQuery(queryWrapper).forEach(System.err::println); - accountMapper.selectListByQueryAs(queryWrapper, AccountVO.class).forEach(System.err::println); - } - @Test void testGenericEntity() { QueryWrapper queryWrapper = QueryWrapper.create() diff --git a/mybatis-flex-test/mybatis-flex-spring-cloud-test/pom.xml b/mybatis-flex-test/mybatis-flex-spring-cloud-test/pom.xml new file mode 100644 index 00000000..b928b6b8 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-cloud-test/pom.xml @@ -0,0 +1,93 @@ + + + + mybatis-flex-test + com.mybatis-flex + 1.3.9 + + 4.0.0 + + mybatis-flex-spring-cloud-test + jar + + + 1.8 + 8 + 8 + 2.6.13 + 2021.0.5 + 2021.0.5.0 + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + ${spring-cloud-alibaba.version} + pom + import + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-web + + + + com.mybatis-flex + mybatis-flex-spring-boot-starter + 1.3.9 + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + com.zaxxer + HikariCP + compile + + + + mysql + mysql-connector-java + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/java/com/mybatisflex/test/MybatisFlexSpringCloudTestApplication.java b/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/java/com/mybatisflex/test/MybatisFlexSpringCloudTestApplication.java new file mode 100644 index 00000000..b874af69 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/java/com/mybatisflex/test/MybatisFlexSpringCloudTestApplication.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 MybatisFlexSpringCloudTestApplication { + + public static void main(String[] args) { + SpringApplication.run(MybatisFlexSpringCloudTestApplication.class, args); + } + +} diff --git a/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/java/com/mybatisflex/test/controller/AccountController.java b/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/java/com/mybatisflex/test/controller/AccountController.java new file mode 100644 index 00000000..611cc9db --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/java/com/mybatisflex/test/controller/AccountController.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.test.entity.Account; +import com.mybatisflex.test.mapper.AccountMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author 王帅 + * @since 2023-06-18 + */ +@RestController +@RequestMapping("/account") +public class AccountController { + + @Autowired + private AccountMapper accountMapper; + + @GetMapping("getAll") + public List getAll() { + return accountMapper.selectAll(); + } + +} \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/java/com/mybatisflex/test/entity/Account.java b/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/java/com/mybatisflex/test/entity/Account.java new file mode 100644 index 00000000..571bd153 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/java/com/mybatisflex/test/entity/Account.java @@ -0,0 +1,79 @@ +/* + * 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.util.Date; + +/** + * @author 王帅 + * @since 2023-06-18 + */ +@Table("tb_account") +public class Account { + + @Id(keyType = KeyType.Auto) + private Long id; + private String userName; + private Integer age; + private Date birthday; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public Date getBirthday() { + return birthday; + } + + public void setBirthday(Date birthday) { + this.birthday = birthday; + } + + @Override + public String toString() { + return "Account{" + + "id=" + id + + ", userName='" + userName + '\'' + + ", age=" + age + + ", birthday=" + birthday + + '}'; + } +} \ No newline at end of file diff --git a/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/resources/application.yml b/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/resources/application.yml new file mode 100644 index 00000000..4b62f470 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/resources/application.yml @@ -0,0 +1,7 @@ +spring: + cloud: + nacos: + config: + server-addr: localhost:8848 + config: + import: nacos:application-datasource.yml diff --git a/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/resources/mybatis-flex.properties b/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/resources/mybatis-flex.properties new file mode 100644 index 00000000..812235c5 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/main/resources/mybatis-flex.properties @@ -0,0 +1,2 @@ +processor.mappersGenerateEnable=true + diff --git a/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/test/java/com/mybatisflex/test/MybatisFlexSpringCloudTestApplicationTests.java b/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/test/java/com/mybatisflex/test/MybatisFlexSpringCloudTestApplicationTests.java new file mode 100644 index 00000000..9fb46caf --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-spring-cloud-test/src/test/java/com/mybatisflex/test/MybatisFlexSpringCloudTestApplicationTests.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 MybatisFlexSpringCloudTestApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/mybatis-flex-test/pom.xml b/mybatis-flex-test/pom.xml index 786015b6..93038d8f 100644 --- a/mybatis-flex-test/pom.xml +++ b/mybatis-flex-test/pom.xml @@ -16,6 +16,7 @@ mybatis-flex-native-test mybatis-flex-spring-test mybatis-flex-spring-boot-test + mybatis-flex-spring-cloud-test