Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into feature/auth
This commit is contained in:
@@ -25,3 +25,7 @@ func (dt *FsOrderDetailTemplateModel) FindOne(ctx context.Context, id int64) (re
|
||||
err = dt.db.WithContext(ctx).Model(&FsOrderDetailTemplate{}).Where("`id` = ?", id).Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (m *FsOrderDetailTemplateModel) TableName() string {
|
||||
return m.name
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func (o *FsOrderModel) FindPageListByPage(ctx context.Context, rowBuilder *gorm.
|
||||
rowBuilder = rowBuilder.Scopes(handler.Paginate(page, pageSize))
|
||||
|
||||
// 结果
|
||||
result := rowBuilder.WithContext(ctx).Find(&resp)
|
||||
result := rowBuilder.Debug().WithContext(ctx).Find(&resp)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
} else {
|
||||
@@ -93,8 +93,20 @@ type FsOrderRel struct {
|
||||
|
||||
type FsOrderDetails struct {
|
||||
FsOrderDetail
|
||||
FsOrderDetailTemplateInfo FsOrderDetailTemplate `gorm:"foreignKey:id;references:order_detail_template_id"`
|
||||
FsProductInfo FsProduct `gorm:"foreignKey:id;references:product_id"`
|
||||
FsOrderDetailTemplateInfo FsOrderDetailTemplateInfo `gorm:"foreignKey:id;references:order_detail_template_id"`
|
||||
FsProductInfo FsProduct `gorm:"foreignKey:id;references:product_id"`
|
||||
}
|
||||
|
||||
type FsOrderDetailTemplateInfo struct {
|
||||
FsOrderDetailTemplate
|
||||
FsProductDesignInfo FsProductDesignInfo `gorm:"foreignKey:id;references:design_id"` //获取设计数据
|
||||
FsProductSizeInfo FsProductSize `gorm:"foreignKey:id;references:size_id"`
|
||||
}
|
||||
|
||||
type FsProductDesignInfo struct {
|
||||
FsProductDesign
|
||||
OptionData FsProduct `gorm:"foreignKey:id;references:optional_id"` //获取配件信息
|
||||
TemplateData FsProductTemplateV2 `gorm:"foreignKey:id;references:template_id"` //获取模板信息
|
||||
}
|
||||
|
||||
func (m *FsOrderModel) RowSelectBuilder(selectData []string) *gorm.DB {
|
||||
@@ -124,6 +136,27 @@ func (m *FsOrderModel) FindCount(ctx context.Context, countBuilder *gorm.DB, fil
|
||||
}
|
||||
}
|
||||
|
||||
// 事务
|
||||
func (m *FsOrderModel) Trans(ctx context.Context, fn func(ctx context.Context, connGorm *gorm.DB) error) error {
|
||||
tx := m.db.Table(m.name).WithContext(ctx).Begin()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
if err := tx.Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := fn(ctx, tx); err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.Commit().Error
|
||||
}
|
||||
|
||||
func (m *FsOrderModel) TableName() string {
|
||||
return m.name
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
// fs_pay 支付记录
|
||||
type FsPay struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
PayNo *string `gorm:"default:'';" json:"pay_no"` // 支付编号
|
||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户id
|
||||
OrderNumber *string `gorm:"default:'';" json:"order_number"` // 订单编号
|
||||
TradeNo *string `gorm:"index;default:'';" json:"trade_no"` // 第三方支付编号
|
||||
|
||||
@@ -14,3 +14,25 @@ func (p *FsPayModel) GetOrderPayList(ctx context.Context, sn string, payStatus i
|
||||
err = p.db.WithContext(ctx).Model(&FsPay{}).Where("`order_number` = ? and `pay_status` = ? and `is_refund` = ?", sn, payStatus, isRefund).Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (p *FsPayModel) GetListByOrderNumberStage(ctx context.Context, sn string, stage int64) (resp *FsPay, err error) {
|
||||
err = p.db.Table(p.name).WithContext(ctx).Model(&FsPay{}).Where("`order_number` = ? ", sn).Where("`pay_stage` = ? ", stage).Take(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (p *FsPayModel) CreateOrUpdate(ctx context.Context, req *FsPay) (resp *FsPay, err error) {
|
||||
rowBuilder := p.db.Table(p.name).WithContext(ctx)
|
||||
if req.Id > 0 {
|
||||
err = rowBuilder.Save(req).Error
|
||||
} else {
|
||||
err = rowBuilder.Create(req).Error
|
||||
}
|
||||
return req, err
|
||||
}
|
||||
|
||||
func (m *FsPayModel) TableName() string {
|
||||
return m.name
|
||||
}
|
||||
|
||||
@@ -34,3 +34,7 @@ func (d *FsProductDesignModel) Create(ctx context.Context, data *FsProductDesign
|
||||
func (d *FsProductDesignModel) UpdateBySn(ctx context.Context, sn string, data *FsProductDesign) error {
|
||||
return d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`sn` = ?", sn).Updates(&data).Error
|
||||
}
|
||||
|
||||
func (m *FsProductDesignModel) TableName() string {
|
||||
return m.name
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
type FsProductTemplateTags struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||
Title *string `gorm:"default:'';" json:"title"` // 标题
|
||||
CoverImg *string `gorm:"default:'';" json:"cover_img"` // 封面图
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态 1:可用
|
||||
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间
|
||||
}
|
||||
|
||||
@@ -23,3 +23,12 @@ func (pt *FsProductTemplateTagsModel) FindOne(ctx context.Context, id int64, fie
|
||||
err = db.Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (pt *FsProductTemplateTagsModel) GetList(ctx context.Context, page, limit int, orderBy string) (resp []FsProductTemplateTags, err error) {
|
||||
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`status` = ?", 1)
|
||||
if orderBy != "" {
|
||||
db = db.Order(orderBy)
|
||||
}
|
||||
offset := (page - 1) * limit
|
||||
err = db.Offset(offset).Limit(limit).Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
26
model/gmodel/fs_resources_gen.go
Normal file
26
model/gmodel/fs_resources_gen.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// fs_resources 资源表
|
||||
type FsResources struct {
|
||||
ResourceId string `gorm:"primary_key;default:'';" json:"resource_id"` // 资源 ID
|
||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户 ID
|
||||
GuestId *int64 `gorm:"index;default:0;" json:"guest_id"` // 访客 ID
|
||||
ResourceType *string `gorm:"index;default:'';" json:"resource_type"` // 资源类型
|
||||
ResourceUrl *string `gorm:"default:'';" json:"resource_url"` // 资源 URL
|
||||
UploadedAt *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"uploaded_at"` // 上传时间
|
||||
Metadata *string `gorm:"default:'';" json:"metadata"` // 元数据,json格式,存储图像分率
|
||||
MetaKey1 *string `gorm:"index;default:'';" json:"meta_key1"` // 需要关键信息查询的自定义属性1,可以动态增加
|
||||
}
|
||||
type FsResourcesModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsResourcesModel(db *gorm.DB) *FsResourcesModel {
|
||||
return &FsResourcesModel{db: db, name: "fs_resources"}
|
||||
}
|
||||
2
model/gmodel/fs_resources_logic.go
Normal file
2
model/gmodel/fs_resources_logic.go
Normal file
@@ -0,0 +1,2 @@
|
||||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
||||
@@ -30,7 +30,7 @@ type FsUser struct {
|
||||
IsPhoneAdvertisement *int64 `gorm:"default:0;" json:"is_phone_advertisement"` // 是否接收短信广告
|
||||
IsOpenRender *int64 `gorm:"default:0;" json:"is_open_render"` // 是否打开个性化渲染(1:开启,0:关闭)
|
||||
IsThousandFace *int64 `gorm:"default:0;" json:"is_thousand_face"` // 是否已经存在千人千面(1:存在,0:不存在)
|
||||
IsLowRendering *int64 `gorm:"default:0;" json:"is_low_rendering"` //
|
||||
IsLowRendering *int64 `gorm:"default:0;" json:"is_low_rendering"` // 是否开启低渲染模型渲染
|
||||
IsRemoveBg *int64 `gorm:"default:1;" json:"is_remove_bg"` // 用户上传logo是否去除背景
|
||||
}
|
||||
type FsUserModel struct {
|
||||
|
||||
@@ -79,6 +79,7 @@ type AllModelsGen struct {
|
||||
FsQuotationRemarkTemplate *FsQuotationRemarkTemplateModel // fs_quotation_remark_template 报价单备注模板
|
||||
FsQuotationSaler *FsQuotationSalerModel // fs_quotation_saler 报价单业务员表
|
||||
FsRefundReason *FsRefundReasonModel // fs_refund_reason
|
||||
FsResources *FsResourcesModel // fs_resources 资源表
|
||||
FsStandardLogo *FsStandardLogoModel // fs_standard_logo 标准logo
|
||||
FsTags *FsTagsModel // fs_tags 产品分类表
|
||||
FsToolLogs *FsToolLogsModel // fs_tool_logs 3d设计工具日志表
|
||||
@@ -169,6 +170,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
||||
FsQuotationRemarkTemplate: NewFsQuotationRemarkTemplateModel(gdb),
|
||||
FsQuotationSaler: NewFsQuotationSalerModel(gdb),
|
||||
FsRefundReason: NewFsRefundReasonModel(gdb),
|
||||
FsResources: NewFsResourcesModel(gdb),
|
||||
FsStandardLogo: NewFsStandardLogoModel(gdb),
|
||||
FsTags: NewFsTagsModel(gdb),
|
||||
FsToolLogs: NewFsToolLogsModel(gdb),
|
||||
|
||||
Reference in New Issue
Block a user