This commit is contained in:
whai 2024-11-04 10:21:04 +08:00
commit 9bd8701ed1
6 changed files with 195 additions and 0 deletions

View File

@ -13,6 +13,7 @@
<version>0.0.1-SNAPSHOT</version>
<name>SpringCloud</name>
<description>SpringCloud</description>
<packaging>pom</packaging>
<url/>
<licenses>
<license/>

View File

@ -0,0 +1,111 @@
package cn.whaifree.springdemo.mybatis.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
*
* @TableName orders
*/
@TableName(value ="orders")
@Data
public class Orders implements Serializable {
/**
*
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 订单号
*/
private String orderNo;
/**
* 用户ID
*/
private Integer userId;
/**
* 订单总金额
*/
private BigDecimal totalAmount;
/**
* 订单状态: 0-未支付, 1-已支付
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
*
*/
private Integer version;
@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;
}
Orders other = (Orders) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getOrderNo() == null ? other.getOrderNo() == null : this.getOrderNo().equals(other.getOrderNo()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getTotalAmount() == null ? other.getTotalAmount() == null : this.getTotalAmount().equals(other.getTotalAmount()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getOrderNo() == null) ? 0 : getOrderNo().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getTotalAmount() == null) ? 0 : getTotalAmount().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getVersion() == null) ? 0 : getVersion().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(", orderNo=").append(orderNo);
sb.append(", userId=").append(userId);
sb.append(", totalAmount=").append(totalAmount);
sb.append(", status=").append(status);
sb.append(", createTime=").append(createTime);
sb.append(", version=").append(version);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,26 @@
package cn.whaifree.springdemo.mybatis.mapper;
import cn.whaifree.springdemo.mybatis.domain.Orders;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* @author wenhai
* @description 针对表orders的数据库操作Mapper
* @createDate 2024-11-01 12:45:47
* @Entity generator.domain.Orders
*/
@Mapper
public interface OrdersMapper extends BaseMapper<Orders> {
@Select("SELECT * FROM orders")
List<Orders> selectByExample();
}

View File

@ -0,0 +1,13 @@
package cn.whaifree.springdemo.mybatis.service;
import cn.whaifree.springdemo.mybatis.domain.Orders;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author wenhai
* @description 针对表orders的数据库操作Service
* @createDate 2024-11-01 12:45:47
*/
public interface OrdersService extends IService<Orders> {
}

View File

@ -0,0 +1,22 @@
package cn.whaifree.springdemo.mybatis.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.whaifree.springdemo.mybatis.domain.Orders;
import cn.whaifree.springdemo.mybatis.service.OrdersService;
import cn.whaifree.springdemo.mybatis.mapper.OrdersMapper;
import org.springframework.stereotype.Service;
/**
* @author wenhai
* @description 针对表orders的数据库操作Service实现
* @createDate 2024-11-01 12:45:47
*/
@Service
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders>
implements OrdersService{
}

View File

@ -0,0 +1,22 @@
<?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="cn.whaifree.springdemo.mybatis.mapper.OrdersMapper">
<resultMap id="BaseResultMap" type="cn.whaifree.springdemo.mybatis.domain.Orders">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="orderNo" column="order_no" jdbcType="VARCHAR"/>
<result property="userId" column="user_id" jdbcType="INTEGER"/>
<result property="totalAmount" column="total_amount" jdbcType="DECIMAL"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="version" column="version" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id,order_no,user_id,
total_amount,status,create_time,
version
</sql>
</mapper>