From cec43302c886f417fe7e7c6f0ea1c8c823d9bd0d Mon Sep 17 00:00:00 2001 From: whaifree Date: Sat, 2 Nov 2024 13:09:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(SpringDemo):=20=E6=B7=BB=E5=8A=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=9B=B8=E5=85=B3=E5=AE=9E=E4=BD=93=E7=B1=BB=E5=92=8C?= =?UTF-8?q?=20Mapper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 Orders 实体类,用于订单相关操作 - 添加 OrdersMapper 接口和对应的 XML 文件,实现订单数据的持久化 - 创建 OrdersService 接口和 OrdersServiceImpl 实现类,提供订单业务逻辑支持- 在 pom.xml 中添加 packaging标签,指定项目打包方式为 pom --- SpringCloud/pom.xml | 1 + .../springdemo/mybatis/domain/Orders.java | 111 ++++++++++++++++++ .../mybatis/mapper/OrdersMapper.java | 26 ++++ .../mybatis/service/OrdersService.java | 13 ++ .../service/impl/OrdersServiceImpl.java | 22 ++++ .../main/resources/mapper/OrdersMapper.xml | 22 ++++ 6 files changed, 195 insertions(+) create mode 100644 SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/domain/Orders.java create mode 100644 SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/mapper/OrdersMapper.java create mode 100644 SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/service/OrdersService.java create mode 100644 SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/service/impl/OrdersServiceImpl.java create mode 100644 SpringDemo/src/main/resources/mapper/OrdersMapper.xml diff --git a/SpringCloud/pom.xml b/SpringCloud/pom.xml index 254e478..a10cf82 100644 --- a/SpringCloud/pom.xml +++ b/SpringCloud/pom.xml @@ -13,6 +13,7 @@ 0.0.1-SNAPSHOT SpringCloud SpringCloud + pom diff --git a/SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/domain/Orders.java b/SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/domain/Orders.java new file mode 100644 index 0000000..98ab6bf --- /dev/null +++ b/SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/domain/Orders.java @@ -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(); + } +} diff --git a/SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/mapper/OrdersMapper.java b/SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/mapper/OrdersMapper.java new file mode 100644 index 0000000..75eff77 --- /dev/null +++ b/SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/mapper/OrdersMapper.java @@ -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 { + + @Select("SELECT * FROM orders") + List selectByExample(); + +} + + + + diff --git a/SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/service/OrdersService.java b/SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/service/OrdersService.java new file mode 100644 index 0000000..ed1f4f0 --- /dev/null +++ b/SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/service/OrdersService.java @@ -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 { + +} diff --git a/SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/service/impl/OrdersServiceImpl.java b/SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/service/impl/OrdersServiceImpl.java new file mode 100644 index 0000000..53159d7 --- /dev/null +++ b/SpringDemo/src/main/java/cn/whaifree/springdemo/mybatis/service/impl/OrdersServiceImpl.java @@ -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 + implements OrdersService{ + +} + + + + diff --git a/SpringDemo/src/main/resources/mapper/OrdersMapper.xml b/SpringDemo/src/main/resources/mapper/OrdersMapper.xml new file mode 100644 index 0000000..57f3789 --- /dev/null +++ b/SpringDemo/src/main/resources/mapper/OrdersMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + id,order_no,user_id, + total_amount,status,create_time, + version + +