框架集成 MyBatis-Flex 以真强编码的便捷性

pull/371/head
wuyibo 2 years ago
parent 5af654258b
commit 6acd8d4271

@ -18,17 +18,19 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-boot.version>2.7.2</spring-boot.version>
<mybatis-flex.version>1.5.3</mybatis-flex.version>
<spring-cloud.version>2021.0.3</spring-cloud.version>
<spring-cloud-alibaba.version>2021.0.1.0</spring-cloud-alibaba.version>
<alibaba.nacos.version>2.0.4</alibaba.nacos.version>
<alibaba.seata.version>1.5.1</alibaba.seata.version>
<spring-boot-admin.version>2.7.3</spring-boot-admin.version>
<spring-boot.mybatis>2.2.2</spring-boot.mybatis>
<spring-boot.mybatis>3.0.2</spring-boot.mybatis>
<swagger.fox.version>3.0.0</swagger.fox.version>
<swagger.core.version>1.6.2</swagger.core.version>
<tobato.version>1.27.2</tobato.version>
<kaptcha.version>2.3.2</kaptcha.version>
<pagehelper.boot.version>1.4.3</pagehelper.boot.version>
<pagehelper.version>5.3.3</pagehelper.version>
<druid.version>1.2.11</druid.version>
<dynamic-ds.version>3.5.1</dynamic-ds.version>
<commons.io.version>2.11.0</commons.io.version>
@ -95,12 +97,11 @@
</dependency>
<!-- Mybatis 依赖配置 -->
<dependency>
<!-- <dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${spring-boot.mybatis}</version>
</dependency>
</dependency>-->
<!-- Swagger 依赖配置 -->
<dependency>
<groupId>io.swagger</groupId>
@ -121,10 +122,16 @@
</dependency>
<!-- pagehelper 分页插件 -->
<dependency>
<!-- <dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.boot.version}</version>
</dependency>-->
<!-- pagehelper 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>${pagehelper.version}</version>
</dependency>
<!-- io常用工具类 -->
@ -239,7 +246,12 @@
<artifactId>ruoyi-common-datascope</artifactId>
<version>${ruoyi.version}</version>
</dependency>
<!-- mybatis-flex -->
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
<version>${mybatis-flex.version}</version>
</dependency>
<!-- 多数据源 -->
<dependency>
<groupId>com.ruoyi</groupId>

@ -48,9 +48,13 @@
</dependency>
<!-- Pagehelper -->
<dependency>
<!-- <dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
</dependency>-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
</dependency>
<!-- Hibernate Validator -->
@ -112,7 +116,11 @@
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<!-- mybatis-flex -->
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
</dependency>
<!-- Swagger -->
<dependency>
<groupId>io.swagger</groupId>

@ -5,6 +5,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mybatisflex.annotation.Column;
/**
* Entity
@ -16,6 +17,7 @@ public class BaseEntity implements Serializable
private static final long serialVersionUID = 1L;
/** 搜索值 */
@Column(ignore = true)
private String searchValue;
/** 创建者 */
@ -23,6 +25,7 @@ public class BaseEntity implements Serializable
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(onInsertValue = "now()")
private Date createTime;
/** 更新者 */
@ -30,12 +33,14 @@ public class BaseEntity implements Serializable
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(onUpdateValue = "now()", onInsertValue = "now()")
private Date updateTime;
/** 备注 */
private String remark;
/** 请求参数 */
@Column(ignore = true)
private Map<String, Object> params;
public String getSearchValue()

@ -33,7 +33,11 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-redis</artifactId>
</dependency>
<!-- mybatis-flex -->
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
</dependency>
</dependencies>
</project>

@ -59,7 +59,11 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datasource</artifactId>
</dependency>
<!-- mybatis-flex -->
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
</dependency>
<!-- RuoYi Common DataScope -->
<dependency>
<groupId>com.ruoyi</groupId>

@ -1,5 +1,6 @@
package com.ruoyi.system;
import com.github.pagehelper.PageInterceptor;
import lombok.var;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.ruoyi.common.security.annotation.EnableCustomConfig;
@ -39,4 +40,14 @@ public class RuoYiSystemApplication
public RestTemplate restTemplate(RestTemplateBuilder builder) {
// Do any additional configuration here
return builder.build(); }
//使用自动配置无效,
//需要手动注入bean以让
//com.mybatisflex.spring.boot.MybatisFlexAutoConfiguration#MybatisFlexAutoConfiguration
//正常获取到com.github.pagehelper.PageInterceptor
@Bean public PageInterceptor pageInterceptor(){
var i = new PageInterceptor();
//转小驼峰用 var i = new MyPageInterceptor();
//i.setProperties(null);
return i;
}
}

@ -78,7 +78,7 @@ public class FollowUpController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody FollowUp followUp)
{
return toAjax(followUpService.insertFollowUp(followUp));
return toAjax(followUpService.save(followUp));
}
/**

@ -2,6 +2,8 @@ package com.ruoyi.system.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mybatisflex.annotation.Table;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
@ -13,6 +15,8 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
* @author ruoyi
* @date 2023-07-04
*/
@Data
@Table("building_team_rel")
public class BuildingTeamRel extends BaseEntity
{
private static final long serialVersionUID = 1L;
@ -21,23 +25,23 @@ public class BuildingTeamRel extends BaseEntity
private Long id;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String isDeleted;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Date createdTime;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String createdBy;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String modifiedBy;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Date lastUpdatedTime;
/** 场馆id */
@ -48,90 +52,4 @@ public class BuildingTeamRel extends BaseEntity
@Excel(name = "球队场馆关联表")
private Long teamId;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setIsDeleted(String isDeleted)
{
this.isDeleted = isDeleted;
}
public String getIsDeleted()
{
return isDeleted;
}
public void setCreatedTime(Date createdTime)
{
this.createdTime = createdTime;
}
public Date getCreatedTime()
{
return createdTime;
}
public void setCreatedBy(String createdBy)
{
this.createdBy = createdBy;
}
public String getCreatedBy()
{
return createdBy;
}
public void setModifiedBy(String modifiedBy)
{
this.modifiedBy = modifiedBy;
}
public String getModifiedBy()
{
return modifiedBy;
}
public void setLastUpdatedTime(Date lastUpdatedTime)
{
this.lastUpdatedTime = lastUpdatedTime;
}
public Date getLastUpdatedTime()
{
return lastUpdatedTime;
}
public void setBuildingId(Long buildingId)
{
this.buildingId = buildingId;
}
public Long getBuildingId()
{
return buildingId;
}
public void setTeamId(Long teamId)
{
this.teamId = teamId;
}
public Long getTeamId()
{
return teamId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("isDeleted", getIsDeleted())
.append("createdTime", getCreatedTime())
.append("createdBy", getCreatedBy())
.append("modifiedBy", getModifiedBy())
.append("lastUpdatedTime", getLastUpdatedTime())
.append("buildingId", getBuildingId())
.append("teamId", getTeamId())
.toString();
}
}

@ -2,6 +2,9 @@ package com.ruoyi.system.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -15,11 +18,13 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
* @date 2023-05-07
*/
@Data
@Table("f_follow_up")
public class FollowUp extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
@Id(keyType = KeyType.Auto)
private Integer id;
/** 客户id */

@ -1,6 +1,8 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.mybatisflex.core.BaseMapper;
import com.ruoyi.system.domain.FollowUp;
/**
@ -9,7 +11,7 @@ import com.ruoyi.system.domain.FollowUp;
* @author ruoyi
* @date 2023-05-07
*/
public interface FollowUpMapper
public interface FollowUpMapper extends BaseMapper<FollowUp>
{
/**
* -

@ -1,6 +1,8 @@
package com.ruoyi.system.service;
import java.util.List;
import com.mybatisflex.core.service.IService;
import com.ruoyi.system.domain.FollowUp;
/**
@ -9,7 +11,7 @@ import com.ruoyi.system.domain.FollowUp;
* @author ruoyi
* @date 2023-05-07
*/
public interface IFollowUpService
public interface IFollowUpService extends IService<FollowUp>
{
/**
* -

@ -1,6 +1,8 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.domain.Customer;
import com.ruoyi.system.mapper.CustomerMapper;
@ -17,7 +19,7 @@ import com.ruoyi.system.service.IFollowUpService;
* @date 2023-05-07
*/
@Service
public class FollowUpServiceImpl implements IFollowUpService
public class FollowUpServiceImpl extends ServiceImpl<FollowUpMapper, FollowUp> implements IFollowUpService
{
@Autowired
private FollowUpMapper followUpMapper;

@ -5,6 +5,25 @@ server:
mybatis:
configuration:
mapUnderscoreToCamelCase: true
# MyBatis配置
mybatis-flex:
# 搜索指定包别名
typeAliasesPackage: com.ruoyi.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapper-locations: classpath*:mapper/**/*Mapper.xml
cacheEnabled: true
useGeneratedKeys: true
defaultExecutorType: SIMPLE
configuration:
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
# 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
logImpl: org.apache.ibatis.logging.slf4j.Slf4jImpl
# PageHelper分页插件
pagehelper:
helperDialect: mysql
supportMethodsArguments: true
params: count=countSql
# Spring
spring:
servlet:

Loading…
Cancel
Save