From 2b72ee5736445aab3aa2b4ba6b862d7c660be9ce Mon Sep 17 00:00:00 2001 From: zhanghl <253316343@qq.com> Date: 星期二, 13 五月 2025 09:56:48 +0800 Subject: [PATCH] Merge branch 'dev_mp' into dev --- aps-common/aps-common-core/src/main/java/com/aps/common/core/config/MyBatisPlusConfig.java | 45 +++++++++ aps-modules/aps-core/pom.xml | 12 ++ aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsPlantController.java | 9 + aps-modules/aps-core/src/main/resources/bootstrap.yml | 2 aps-modules/aps-core/src/main/resources/application.yml | 96 +++++++++++++++++++ aps-modules/aps-core/src/main/java/com/aps/core/service/IApsPlantService.java | 3 aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlantMapper.java | 3 pom.xml | 35 +++++- aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlantServiceImpl.java | 3 aps-modules/aps-core/src/main/resources/mapper/core/ApsPlantMapper.xml | 2 aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlant.java | 30 +---- aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsShopController.java | 2 aps-common/aps-common-core/pom.xml | 19 ++- 13 files changed, 217 insertions(+), 44 deletions(-) diff --git a/aps-common/aps-common-core/pom.xml b/aps-common/aps-common-core/pom.xml index 0288d5c..ab5807c 100644 --- a/aps-common/aps-common-core/pom.xml +++ b/aps-common/aps-common-core/pom.xml @@ -53,11 +53,6 @@ <artifactId>pagehelper-spring-boot-starter</artifactId> </dependency> - <!-- Mybatis Spring --> - <dependency> - <groupId>org.mybatis</groupId> - <artifactId>mybatis-spring</artifactId> - </dependency> <!-- Hibernate Validator --> <dependency> @@ -125,6 +120,20 @@ <artifactId>hutool-all</artifactId> <version>5.8.16</version> </dependency> +<!-- Mybatis Spring --> + <dependency> + <groupId>org.mybatis</groupId> + <artifactId>mybatis-spring</artifactId> + </dependency> + + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-spring-boot3-starter</artifactId> + </dependency> + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-jsqlparser</artifactId> + </dependency> </dependencies> </project> diff --git a/aps-common/aps-common-core/src/main/java/com/aps/common/core/config/MyBatisPlusConfig.java b/aps-common/aps-common-core/src/main/java/com/aps/common/core/config/MyBatisPlusConfig.java new file mode 100644 index 0000000..282d753 --- /dev/null +++ b/aps-common/aps-common-core/src/main/java/com/aps/common/core/config/MyBatisPlusConfig.java @@ -0,0 +1,45 @@ +package com.aps.common.core.config; + + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MyBatisPlusConfig { + + /** + * 鍒嗛〉鎻掍欢 + */ + @Bean + public PaginationInnerInterceptor paginationInterceptor() { + PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(); + // 璁剧疆璇锋眰鐨勯〉闈㈠ぇ浜庢渶澶ч〉鍚庢槸鍚﹁繘琛屽洖婊�, true鍥炴粴, false缁х画 + paginationInterceptor.setOverflow(false); + // 璁剧疆鏈�澶у崟椤甸檺鍒舵暟閲�, 榛樿 500 鏉�, -1 涓嶅彈闄愬埗 + paginationInterceptor.setDbType(DbType.MYSQL); + paginationInterceptor.setMaxLimit(-1L); + return paginationInterceptor; + } + + /** + * 涔愯閿佹彃浠� + */ + @Bean + public OptimisticLockerInnerInterceptor optimisticLockerInterceptor() { + return new OptimisticLockerInnerInterceptor(); + } + + + /** + * 濡傛灉鏄鍏ㄨ〃鐨勫垹闄ゆ垨鏇存柊鎿嶄綔锛屽氨浼氱粓姝㈣鎿嶄綔 https://baomidou.com/guide/interceptor-block-attack.html + */ + public BlockAttackInnerInterceptor blockAttackInnerInterceptor() { + return new BlockAttackInnerInterceptor(); + } + + +} \ No newline at end of file diff --git a/aps-modules/aps-core/pom.xml b/aps-modules/aps-core/pom.xml index 94e3d67..e2d78e3 100644 --- a/aps-modules/aps-core/pom.xml +++ b/aps-modules/aps-core/pom.xml @@ -95,6 +95,18 @@ <artifactId>lombok</artifactId> <scope>provided</scope> </dependency> + <dependency> + <groupId>org.mybatis</groupId> + <artifactId>mybatis-spring</artifactId> + </dependency> + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-spring-boot3-starter</artifactId> + </dependency> + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-jsqlparser</artifactId> + </dependency> </dependencies> <build> diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsPlantController.java b/aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsPlantController.java index e3c2453..7728ec0 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsPlantController.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsPlantController.java @@ -31,13 +31,14 @@ /** * 鏌ヨ宸ュ巶绠$悊鍒楄〃 */ - @RequiresPermissions("plant:list") + //@RequiresPermissions("plant:list") @GetMapping("/list") public TableDataInfo list(ApsPlant apsPlant) { - startPage(); - List<ApsPlant> list = apsPlantService.selectApsPlantList(apsPlant); - return getDataTable(list); + //startPage(); + //List<ApsPlant> list = apsPlantService.selectApsPlantList(apsPlant); + List<ApsPlant> list1 = apsPlantService.list(); + return getDataTable(list1); } /** diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsShopController.java b/aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsShopController.java index e7f7f87..29d3ec6 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsShopController.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/controller/basicData/ApsShopController.java @@ -31,7 +31,7 @@ /** * 鏌ヨ杞﹂棿鍒楄〃 */ - @RequiresPermissions("shop:list") + // @RequiresPermissions("shop:list") @GetMapping("/list") public TableDataInfo list(ApsShop apsShop) { diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlant.java b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlant.java index 338ac7c..d2257fc 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlant.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlant.java @@ -1,5 +1,7 @@ package com.aps.core.domain; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Getter; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.aps.common.core.annotation.Excel; @@ -11,6 +13,8 @@ * @author ruoyi * @date 2025-04-14 */ +@Getter +@TableName(value = "aps_plant") public class ApsPlant extends BaseEntity { private static final long serialVersionUID = 1L; @@ -35,39 +39,19 @@ this.id = id; } - public String getId() - { - return id; - } - - public void setPlantName(String plantName) + public void setPlantName(String plantName) { this.plantName = plantName; } - public String getPlantName() - { - return plantName; - } - - public void setPlantCode(String plantCode) + public void setPlantCode(String plantCode) { this.plantCode = plantCode; } - public String getPlantCode() - { - return plantCode; - } - - public void setStatus(String status) + public void setStatus(String status) { this.status = status; - } - - public String getStatus() - { - return status; } @Override diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlantMapper.java b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlantMapper.java index 3103b2f..7646d3b 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlantMapper.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlantMapper.java @@ -2,6 +2,7 @@ import java.util.List; import com.aps.core.domain.ApsPlant; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** @@ -11,7 +12,7 @@ * @date 2025-04-14 */ @Mapper -public interface ApsPlantMapper +public interface ApsPlantMapper extends BaseMapper<ApsPlant> { /** * 鏌ヨ宸ュ巶绠$悊 diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/IApsPlantService.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/IApsPlantService.java index bfcec65..a500136 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/service/IApsPlantService.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/IApsPlantService.java @@ -2,6 +2,7 @@ import java.util.List; import com.aps.core.domain.ApsPlant; +import com.baomidou.mybatisplus.extension.service.IService; /** * 宸ュ巶绠$悊Service鎺ュ彛 @@ -9,7 +10,7 @@ * @author ruoyi * @date 2025-04-14 */ -public interface IApsPlantService +public interface IApsPlantService extends IService<ApsPlant> { /** * 鏌ヨ宸ュ巶绠$悊 diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlantServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlantServiceImpl.java index 04520f7..7386c80 100644 --- a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlantServiceImpl.java +++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlantServiceImpl.java @@ -4,6 +4,7 @@ import com.aps.common.core.utils.DateUtils; import com.aps.common.core.utils.uuid.IdUtils; import com.aps.common.security.utils.SecurityUtils; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.aps.core.mapper.ApsPlantMapper; @@ -17,7 +18,7 @@ * @date 2025-04-14 */ @Service -public class ApsPlantServiceImpl implements IApsPlantService +public class ApsPlantServiceImpl extends ServiceImpl<ApsPlantMapper, ApsPlant> implements IApsPlantService { @Autowired private ApsPlantMapper apsPlantMapper; diff --git a/aps-modules/aps-core/src/main/resources/application.yml b/aps-modules/aps-core/src/main/resources/application.yml new file mode 100644 index 0000000..6e614a3 --- /dev/null +++ b/aps-modules/aps-core/src/main/resources/application.yml @@ -0,0 +1,96 @@ +server: + port: 9205 +spring: + application: + # 搴旂敤鍚嶇О + name: aps-core + cloud: + nacos: + discovery: + # 鏈嶅姟娉ㄥ唽鍦板潃 + server-addr: 192.168.50.160:8848 + namespace: aafcd57a-d0f7-43e3-a77d-1dc85aec1f0e + metadata: + local: int + config: + # 閰嶇疆涓績鍦板潃 + server-addr: 192.168.50.160:8848 + # 閰嶇疆鏂囦欢鏍煎紡 + file-extension: yml + namespace: aafcd57a-d0f7-43e3-a77d-1dc85aec1f0e + # 鍏变韩閰嶇疆 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # spring閰嶇疆 + data: + redis: + host: 192.168.50.160 + port: 6379 + password: + datasource: + druid: + stat-view-servlet: + enabled: true + loginUsername: ruoyi + loginPassword: 123456 + dynamic: + druid: + initial-size: 5 + min-idle: 5 + maxActive: 20 + maxWait: 60000 + connectTimeout: 30000 + socketTimeout: 60000 + timeBetweenEvictionRunsMillis: 60000 + minEvictableIdleTimeMillis: 300000 + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + poolPreparedStatements: true + maxPoolPreparedStatementPerConnectionSize: 20 + filters: stat,slf4j + datasource: + # 涓诲簱鏁版嵁婧� + master: + driver-class-name: org.postgresql.Driver + url: jdbc:postgresql://192.168.50.160:5432/postgres?stringtype=unspecified + username: postgres + password: pwd@aps + # 浠庡簱鏁版嵁婧� + # slave: + # username: + # password: + # url: + # driver-class-name: + +## mybatis閰嶇疆 +#mybatis: +# # 鎼滅储鎸囧畾鍖呭埆鍚� +# typeAliasesPackage: com.aps.core +# # 閰嶇疆mapper鐨勬壂鎻忥紝鎵惧埌鎵�鏈夌殑mapper.xml鏄犲皠鏂囦欢 +# mapperLocations: classpath:mapper/**/*.xml +# mp閰嶇疆 +mybatis-plus: + mapper-locations: classpath:mapper/**/*.xml + type-aliases-package: com.aps.core + global-config: + db-config: + id-type: ASSIGN_ID + logic-delete-value: 1 + logic-not-delete-value: 0 + configuration: + map-underscore-to-camel-case: true + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + + +# springdoc閰嶇疆 +springdoc: + gatewayUrl: http://localhost:8080/${spring.application.name} + api-docs: + # 鏄惁寮�鍚帴鍙f枃妗� + enabled: true + info: + # 鏍囬 + title: '绯荤粺妯″潡鎺ュ彛鏂囨。' + # 鎻忚堪 + description: '绯荤粺妯″潡鎺ュ彛鎻忚堪' \ No newline at end of file diff --git a/aps-modules/aps-core/src/main/resources/bootstrap.yml b/aps-modules/aps-core/src/main/resources/bootstrap.yml index 0df0b3e..662ab5d 100644 --- a/aps-modules/aps-core/src/main/resources/bootstrap.yml +++ b/aps-modules/aps-core/src/main/resources/bootstrap.yml @@ -9,4 +9,4 @@ name: aps-core profiles: # 鐜閰嶇疆 - active: dev \ No newline at end of file + active: int \ No newline at end of file diff --git a/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlantMapper.xml b/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlantMapper.xml index 0d24654..bfb3a43 100644 --- a/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlantMapper.xml +++ b/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlantMapper.xml @@ -4,7 +4,7 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.aps.core.mapper.ApsPlantMapper"> - <resultMap type="ApsPlant" id="ApsPlantResult"> + <resultMap type="com.aps.core.domain.ApsPlant" id="ApsPlantResult"> <result property="id" column="id" /> <result property="plantName" column="plant_name" /> <result property="plantCode" column="plant_code" /> diff --git a/pom.xml b/pom.xml index d8dacaf..ec5f3c5 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,7 @@ <poi.version>4.1.2</poi.version> <springdoc.version>2.6.0</springdoc.version> <transmittable-thread-local.version>2.14.4</transmittable-thread-local.version> + <mybatis-plus-version>3.5.1</mybatis-plus-version> </properties> <!-- 渚濊禆澹版槑 --> @@ -92,12 +93,6 @@ <groupId>org.mybatis</groupId> </exclusion> </exclusions> - </dependency> - - <dependency> - <groupId>org.mybatis</groupId> - <artifactId>mybatis-spring</artifactId> - <version>${mybatis-spring.version}</version> </dependency> <!-- io甯哥敤宸ュ叿绫� --> @@ -212,6 +207,34 @@ <version>${aps.version}</version> </dependency> + <dependency> + <groupId>org.mybatis</groupId> + <artifactId>mybatis-spring</artifactId> + <version>${mybatis-spring.version}</version> + </dependency> + + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-spring-boot3-starter</artifactId> + <version>3.5.10</version> + <exclusions> + <exclusion> + <artifactId>mybatis-spring</artifactId> + <groupId>org.mybatis</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-jsqlparser</artifactId> + <version>3.5.10</version> + <exclusions> + <exclusion> + <artifactId>mybatis-spring</artifactId> + <groupId>org.mybatis</groupId> + </exclusion> + </exclusions> + </dependency> </dependencies> </dependencyManagement> -- Gitblit v1.9.3