From 505d744bf55cc4f3fdc03e172b2040b927564af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Mon, 3 Mar 2025 16:30:40 +0800 Subject: [PATCH] init dev --- internal/biz/bo/order.go | 4 --- internal/biz/bo/order_bo.go | 18 ++++++++++++++ internal/biz/repo/order_repo.go | 13 ++++++++++ internal/data/model/order.gen.go | 31 ++++++++++++++++++++++++ internal/data/repoimpl/order_repoImpl.go | 30 +++++++++++++++++++++++ 5 files changed, 92 insertions(+), 4 deletions(-) delete mode 100644 internal/biz/bo/order.go create mode 100644 internal/biz/bo/order_bo.go create mode 100644 internal/biz/repo/order_repo.go create mode 100644 internal/data/model/order.gen.go create mode 100644 internal/data/repoimpl/order_repoImpl.go diff --git a/internal/biz/bo/order.go b/internal/biz/bo/order.go deleted file mode 100644 index d9b5948..0000000 --- a/internal/biz/bo/order.go +++ /dev/null @@ -1,4 +0,0 @@ -package bo - -type OrderBo struct { -} diff --git a/internal/biz/bo/order_bo.go b/internal/biz/bo/order_bo.go new file mode 100644 index 0000000..d46632c --- /dev/null +++ b/internal/biz/bo/order_bo.go @@ -0,0 +1,18 @@ +package bo + +import "time" + +// OrderBo 领域实体Bo结构,字段和模型字段保持一致 +type OrderBo struct { + ID int32 + OrderNo string + OutBizNo string + ProductNo string + Account string + AccountType bool + Status bool + AppID string + MerchantNo string + Channel bool + CreateTime time.Time +} diff --git a/internal/biz/repo/order_repo.go b/internal/biz/repo/order_repo.go new file mode 100644 index 0000000..501150a --- /dev/null +++ b/internal/biz/repo/order_repo.go @@ -0,0 +1,13 @@ +package repo + +import ( + "context" + "voucher/internal/biz/bo" +) + +type OrderRepo interface { + // Create 创建 Order + Create(ctx context.Context, req *bo.OrderBo) (*bo.OrderBo, error) + // GetByID 根据 ID 获取 Order + GetByID(ctx context.Context, id int32) (*bo.OrderBo, error) +} diff --git a/internal/data/model/order.gen.go b/internal/data/model/order.gen.go new file mode 100644 index 0000000..4d84e10 --- /dev/null +++ b/internal/data/model/order.gen.go @@ -0,0 +1,31 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package model + +import ( + "time" +) + +const TableNameOrder = "order" + +// Order mapped from table +type Order struct { + ID int64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` + OrderNo string `gorm:"column:order_no;not null" json:"order_no"` + OutBizNo string `gorm:"column:out_biz_no;not null;comment:外部交易号" json:"out_biz_no"` // 外部交易号 + ProductNo string `gorm:"column:product_no;not null;comment:商品编号" json:"product_no"` // 商品编号 + Account string `gorm:"column:account;not null;comment:充值账号" json:"account"` // 充值账号 + AccountType uint8 `gorm:"column:account_type;not null;comment:1:oepnid/userid 2:手机号" json:"account_type"` // 1:oepnid/userid 2:手机号 + Status uint8 `gorm:"column:status;not null;comment:1:待发放 2:发放中 3:发放成功 4:发放失败" json:"status"` // 1:待发放 2:发放中 3:发放成功 4:发放失败 + AppID string `gorm:"column:app_id;not null;comment:批次所属应用" json:"app_id"` // 批次所属应用 + MerchantNo string `gorm:"column:merchant_no;not null;comment:创建批次号的商户号" json:"merchant_no"` // 创建批次号的商户号 + Channel uint8 `gorm:"column:channel;not null;comment:1:微信 2:支付宝" json:"channel"` // 1:微信 2:支付宝 + CreateTime *time.Time `gorm:"column:create_time" json:"create_time"` +} + +// TableName Order's table name +func (*Order) TableName() string { + return TableNameOrder +} diff --git a/internal/data/repoimpl/order_repoImpl.go b/internal/data/repoimpl/order_repoImpl.go new file mode 100644 index 0000000..a5df071 --- /dev/null +++ b/internal/data/repoimpl/order_repoImpl.go @@ -0,0 +1,30 @@ +package repoimpl + +import ( + "context" + "voucher/internal/biz/bo" + "voucher/internal/biz/repository" + "voucher/internal/data/model" +) + +// OrderRepoImpl 定义了针对 Order 表的 CRUD 操作 +type OrderRepoImpl struct { + Base[model.Order, bo.OrderBo] +} + +// NewOrderRepoImpl 创建一个新的 OrderRepoImpl 实例 +func NewOrderRepoImpl() repository.OrderRepo { + return &OrderRepoImpl{} +} + +func (r *OrderRepoImpl) Create(ctx context.Context, req *bo.OrderBo) (*bo.OrderBo, error) { + // todo 待实现 + return nil, nil +} + +// GetByID 根据 ID 获取 Order +func (r *OrderRepoImpl) GetByID(ctx context.Context, id int32) (*bo.OrderBo, error) { + var item model.Order + // todo 待实现 + return r.ToBo(&item), nil +}