Explorar o código

1:集成mybatis_plus框架

wangming %!s(int64=2) %!d(string=hai) anos
pai
achega
ecb47f65ac

+ 15 - 3
pom.xml

@@ -96,10 +96,15 @@
             </dependency>
 
             <!-- SpringBoot集成mybatis框架 -->
+<!--            <dependency>-->
+<!--                <groupId>org.mybatis.spring.boot</groupId>-->
+<!--                <artifactId>mybatis-spring-boot-starter</artifactId>-->
+<!--                <version>${mybatis-spring-boot.version}</version>-->
+<!--            </dependency>-->
             <dependency>
-                <groupId>org.mybatis.spring.boot</groupId>
-                <artifactId>mybatis-spring-boot-starter</artifactId>
-                <version>${mybatis-spring-boot.version}</version>
+                <groupId>com.baomidou</groupId>
+                <artifactId>mybatis-plus-boot-starter</artifactId>
+                <version>3.0.5</version>
             </dependency>
 
             <!-- pagehelper 分页插件 -->
@@ -107,6 +112,13 @@
                 <groupId>com.github.pagehelper</groupId>
                 <artifactId>pagehelper-spring-boot-starter</artifactId>
                 <version>${pagehelper.boot.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.mybatis</groupId>
+                        <artifactId>mybatis</artifactId>
+                    </exclusion>
+                </exclusions>
+
             </dependency>
 
             <!-- 获取系统信息 -->

+ 2 - 0
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java

@@ -1,5 +1,6 @@
 package com.ruoyi;
 
+import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@@ -10,6 +11,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
  * @author ruoyi
  */
 @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
+@MapperScan("com.ruoyi.opt.mapper.**")
 public class RuoYiApplication
 {
     public static void main(String[] args)

+ 11 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/opt/OptController.java

@@ -35,10 +35,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
+import java.util.*;
 
 /**
  * @Author : wangming
@@ -195,5 +192,15 @@ public class OptController {
         }
     }
 
+    @ResponseBody
+    @PostMapping("/test")
+    public List<ProcessInfo> getaaa(){
+        LambdaQueryWrapper<ProcessInfo> queryWrapper = new QueryWrapper<ProcessInfo>().lambda();
+        queryWrapper.eq(ProcessInfo::getProcessId, "12423302203");
+        List<ProcessInfo> list = processInfoService.list(queryWrapper);
+        return list;
+    }
+
+
 
 }

+ 17 - 7
ruoyi-admin/src/main/resources/application.yml

@@ -57,18 +57,28 @@ spring:
     ignore-future-migrations:
 
 # MyBatis
-mybatis:
-    # 搜索指定包别名
-    typeAliasesPackage: com.ruoyi.**.domain
-    # 配置mapper的扫描,找到所有的mapper.xml映射文件
-    mapperLocations: classpath*:mapper/**/*Mapper.xml
-    # 加载全局的配置文件
-    configLocation: classpath:mybatis/mybatis-config.xml
+#mybatis:
+#    # 搜索指定包别名
+#    typeAliasesPackage: com.ruoyi.**.domain
+#    # 配置mapper的扫描,找到所有的mapper.xml映射文件
+#    mapperLocations: classpath*:mapper/**/*Mapper.xml
+#    # 加载全局的配置文件
+#    configLocation: classpath:mybatis/mybatis-config.xml
 
 # Mybatis-plus
 mybatis-plus:
     mapper-locations: classpath*:mapper/**/*Mapper.xml
     type-aliases-package: com.ruoyi.**.domain
+    global-config:
+      db-config:
+        id-type: auto
+        field-strategy: 2
+        table-prefix: true
+        db-type: mysql
+    configuration:
+      map-underscore-to-camel-case: true
+      cache-enabled: false
+      log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 # PageHelper分页插件
 pagehelper: 
   helperDialect: mysql

+ 4 - 1
ruoyi-common/pom.xml

@@ -40,7 +40,10 @@
             <groupId>org.apache.shiro</groupId>
             <artifactId>shiro-ehcache</artifactId>
         </dependency>
-
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+        </dependency>
         <!-- pagehelper 分页插件 -->
         <dependency>
             <groupId>com.github.pagehelper</groupId>

+ 5 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java

@@ -4,6 +4,8 @@ import java.io.Serializable;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
+
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 
 /**
@@ -16,6 +18,7 @@ public class BaseEntity implements Serializable
     private static final long serialVersionUID = 1L;
 
     /** 搜索值 */
+    @TableField(exist = false)
     private String searchValue;
 
     /** 创建者 */
@@ -33,9 +36,11 @@ public class BaseEntity implements Serializable
     private Date updateTime;
 
     /** 备注 */
+    @TableField(exist = false)
     private String remark;
 
     /** 请求参数 */
+    @TableField(exist = false)
     private Map<String, Object> params;
 
     public String getSearchValue()

+ 2 - 2
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java

@@ -113,7 +113,7 @@ public class MyBatisConfig
         return resources.toArray(new Resource[resources.size()]);
     }
 
-    @Bean
+    /*@Bean
     public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
     {
         String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage");
@@ -128,5 +128,5 @@ public class MyBatisConfig
         sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
         sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
         return sessionFactory.getObject();
-    }
+    }*/
 }

+ 27 - 0
ruoyi-system/src/main/java/com/ruoyi/opt/domain/ProcessInfo.java

@@ -2,6 +2,7 @@ package com.ruoyi.opt.domain;
 
 import java.util.Date;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -27,90 +28,116 @@ public class ProcessInfo extends BaseEntity
 
     /** 订单编号 */
     @Excel(name = "订单编号")
+    @TableField("process_id")
     private String processId;
 
     /** 订单状态 */
     @Excel(name = "订单状态")
+    @TableField("process_sts_cd")
     private String processStsCd;
 
     /** 保费金额 */
     @Excel(name = "保费金额")
+    @TableField("premium_amt")
     private String premiumAmt;
 
     /** 保函编号 **/
     @Excel(name = "保函编号")
+    @TableField("policy_no")
     private String policyNo;
 
     /** 申请保额 */
     @Excel(name = "申请保额")
+    @TableField("loan_amt")
     private String loanAmt;
 
     /** 保函签署地址 */
     @Excel(name = "保函签署地址")
+    @TableField("policy_sign_url")
     private String policySignUrl;
 
     /** 保函下载地址 */
     @Excel(name = "保函下载地址")
+    @TableField("policy_dl_url")
     private String policyDlUrl;
 
     /** 电子发票地址 */
     @Excel(name = "电子发票地址")
+    @TableField("e_invoice_url")
     private String eInvoiceUrl;
 
     /** 项目编号 */
     @Excel(name = "项目编号")
+    @TableField("project_id")
     private Long projectId;
 
     /** 企业编号 */
     @Excel(name = "企业编号")
+    @TableField("company_id")
     private Long companyId;
 
     /** 保函有效期 */
     @Excel(name = "保函有效期")
+    @TableField("expire_time")
     private Long expireTime;
 
     /** 审批通过时间 */
     @JsonFormat(pattern = "yyyy-MM-dd")
     @Excel(name = "审批通过时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @TableField("approved_time")
     private Date approvedTime;
 
     /** 打款附言 */
     @Excel(name = "打款附言")
+    @TableField("postscript")
     private String postscript;
 
     /** 拒绝原因 */
     @Excel(name = "拒绝原因")
+    @TableField("reject_reason")
     private String rejectReason;
 
     /** 申请时间 */
     @JsonFormat(pattern = "yyyy-MM-dd")
     @Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @TableField("apply_time")
     private Date applyTime;
 
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @TableField(exist = false)
+    private Date createTime;
+
     // --项目的部分字段
     /** 项目名称 */
     @Excel(name = "项目名称")
+    @TableField(exist = false)
     private String projectNm;
 
     /** 标段编号 */
     @Excel(name = "标段编号")
+    @TableField(exist = false)
     private String tenderNo;
 
     /** 开标日期 */
     @Excel(name = "开标日期")
+    @TableField(exist = false)
     private String bidOpenTime;
 
     // 企业部分信息
     /** 公司名称 */
     @Excel(name = "公司名称")
+    @TableField(exist = false)
     private String companyNm;
 
     /** 联系人 */
     @Excel(name = "联系人")
+    @TableField(exist = false)
     private String applyNm;
 
     /** 申请人电话 */
     @Excel(name = "申请人电话")
+    @TableField(exist = false)
     private String applyTel;
 
     public void setpId(Long pId) 

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/opt/mapper/ProcessInfoMapper.java

@@ -13,7 +13,7 @@ import org.apache.ibatis.annotations.Update;
  * @author chengpan
  * @date 2022-09-06
  */
-public interface ProcessInfoMapper /*extends BaseMapper<ProcessInfo>*/
+public interface ProcessInfoMapper extends BaseMapper<ProcessInfo>
 {
     /**
      * 查询保函订单

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/opt/service/IProcessInfoService.java

@@ -12,7 +12,7 @@ import com.ruoyi.opt.domain.ProcessInfo;
  * @author chengpan
  * @date 2022-09-06
  */
-public interface IProcessInfoService /*extends IService<ProcessInfo>*/
+public interface IProcessInfoService extends IService<ProcessInfo>
 {
 
 

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/opt/service/impl/ProcessInfoServiceImpl.java

@@ -37,7 +37,7 @@ import org.springframework.util.ObjectUtils;
  */
 @Service
 @Slf4j
-public class ProcessInfoServiceImpl /*extends ServiceImpl<ProcessInfoMapper, ProcessInfo>*/ implements IProcessInfoService
+public class ProcessInfoServiceImpl extends ServiceImpl<ProcessInfoMapper, ProcessInfo> implements IProcessInfoService
 {
     @Autowired
     private ProcessInfoMapper processInfoMapper;