release: 集成mybatis-plus

release-2024-08-08
huangyw 6 months ago
parent 476e5b8dd2
commit 710ae46e99

@ -134,6 +134,19 @@
<artifactId>core</artifactId>
<version>3.5.1</version>
</dependency>
<!-- mybatis-plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
<version>${mybatis-plus.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>app</finalName>

@ -0,0 +1,49 @@
package com.luoo.user.controller;
import api.Result;
import com.luoo.user.pojo.WithdrawMybatis;
import com.luoo.user.service.WithdrawService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import util.IdWorker;
import java.math.BigDecimal;
import java.util.List;
/**
* @program: luoo_parent
* @description: test
* @author: yawei.huang
* @create: 2024-08-06 11:15
**/
@RestController
@CrossOrigin
@Slf4j
public class TestController {
@Autowired
private WithdrawService withdrawService;
@Autowired
private IdWorker idWorker;
@GetMapping("/test")
public Result<List<WithdrawMybatis>> test() {
return Result.success(withdrawService.list());
}
@GetMapping("/test2")
public Result<Void> test2() {
WithdrawMybatis build = WithdrawMybatis.builder()
.id(String.valueOf(idWorker.nextId()))
.state(1)
.userId("111")
.amount(BigDecimal.valueOf(10.0))
.build();
boolean save = withdrawService.save(build);
return Result.success();
}
}

@ -0,0 +1,19 @@
package com.luoo.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.luoo.user.pojo.WithdrawMybatis;
import org.mapstruct.Mapper;
/**
* @author ASUS
* @description tb_withdraw()Mapper
* @createDate 2024-08-06 11:11:52
* @Entity generator.domain.Withdraw
*/
public interface WithdrawMapper extends BaseMapper<WithdrawMybatis> {
}

@ -0,0 +1,120 @@
package com.luoo.user.pojo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
*
* @TableName tb_withdraw
*/
@TableName(value ="tb_withdraw")
@Data
@Builder
public class WithdrawMybatis implements Serializable {
/**
*
*/
@TableId
private String id;
/**
* 1- 2- 3-
*/
private Integer state;
/**
*
*/
private BigDecimal amount;
/**
* id
*/
private String userId;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
*
*/
private String createUser;
/**
*
*/
private String updateUser;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
Withdraw other = (Withdraw) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
&& (this.getAmount() == null ? other.getAmount() == null : this.getAmount().equals(other.getAmount()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getCreateUser() == null ? other.getCreateUser() == null : this.getCreateUser().equals(other.getCreateUser()))
&& (this.getUpdateUser() == null ? other.getUpdateUser() == null : this.getUpdateUser().equals(other.getUpdateUser()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
result = prime * result + ((getAmount() == null) ? 0 : getAmount().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getCreateUser() == null) ? 0 : getCreateUser().hashCode());
result = prime * result + ((getUpdateUser() == null) ? 0 : getUpdateUser().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", state=").append(state);
sb.append(", amount=").append(amount);
sb.append(", userId=").append(userId);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", createUser=").append(createUser);
sb.append(", updateUser=").append(updateUser);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

@ -0,0 +1,13 @@
package com.luoo.user.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.luoo.user.pojo.WithdrawMybatis;
/**
* @author ASUS
* @description tb_withdraw()Service
* @createDate 2024-08-06 11:11:52
*/
public interface WithdrawService extends IService<WithdrawMybatis> {
}

@ -0,0 +1,22 @@
package com.luoo.user.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.luoo.user.mapper.WithdrawMapper;
import com.luoo.user.pojo.WithdrawMybatis;
import com.luoo.user.service.WithdrawService;
import org.springframework.stereotype.Service;
/**
* @author ASUS
* @description tb_withdraw()Service
* @createDate 2024-08-06 11:11:52
*/
@Service
public class WithdrawServiceImpl extends ServiceImpl<WithdrawMapper, WithdrawMybatis>
implements WithdrawService {
}

@ -14,4 +14,31 @@ oauth2:
appid: wxae6fb76efa147314
secret: 741727f12d1b262ac855b905bf2e60e2
appidShare: wx667f580d1605650b
secretShare: 4bb42de98cb422d733ac7d50e7cade3b
secretShare: 4bb42de98cb422d733ac7d50e7cade3b
#mybatis-plus
mybatis-plus:
## 这个可以不用配置,因其默认就是这个路径
mapper-locations: classpath:/mapper/*Mapper.xml
#实体扫描多个package用逗号或者分号分隔
typeAliasesPackage: com.luoo.user.pojo
global-config:
# 数据库相关配置
db-config:
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID",ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
id-type: ASSIGN_ID
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
field-strategy: not_empty
#驼峰下划线转换
column-underline: true
#数据库大写下划线转换
#capital-mode: true
#逻辑删除配置
logic-delete-value: 2
logic-not-delete-value: 0
db-type: h2
#刷新mapper 调试神器
refresh: true
# 原生配置
configuration:
map-underscore-to-camel-case: true
cache-enabled: false

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.luoo.user.mapper.WithdrawMapper">
<resultMap id="BaseResultMap" type="com.luoo.user.pojo.WithdrawMybatis">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="state" column="state" jdbcType="INTEGER"/>
<result property="amount" column="amount" jdbcType="DECIMAL"/>
<result property="userId" column="user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="createUser" column="create_user" jdbcType="VARCHAR"/>
<result property="updateUser" column="update_user" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,state,amount,
user_id,create_time,update_time,
create_user,update_user
</sql>
</mapper>

@ -41,6 +41,7 @@
<swagger-bootstrap-ui.version>1.9.3</swagger-bootstrap-ui.version>
<poi.version>4.1.2</poi.version>
<commons.io.version>2.13.0</commons.io.version>
<mybatis-plus.version>3.5.3.1</mybatis-plus.version>
</properties>
<dependencyManagement>

Loading…
Cancel
Save