fix
This commit is contained in:
@@ -6,10 +6,7 @@ import (
|
||||
|
||||
func (od *FsOrderDetailModel) GetOrderDetailsByOrderId(ctx context.Context, orderId int64) (resp []FsOrderDetail, err error) {
|
||||
err = od.db.WithContext(ctx).Model(&FsOrderDetail{}).Where("`order_id` = ?", orderId).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
return resp, err
|
||||
}
|
||||
func (od *FsOrderDetailModel) FindOneByOrderDetailTemplateId(ctx context.Context, templateId int64) (resp *FsOrderDetail, err error) {
|
||||
err = od.db.WithContext(ctx).Model(&FsOrderDetail{}).Where("`order_detail_template_id` = ?", templateId).Take(&resp).Error
|
||||
@@ -18,3 +15,12 @@ func (od *FsOrderDetailModel) FindOneByOrderDetailTemplateId(ctx context.Context
|
||||
func (od *FsOrderDetailModel) Create(ctx context.Context, data *FsOrderDetail) error {
|
||||
return od.db.WithContext(ctx).Model(&FsOrderDetail{}).Create(&data).Error
|
||||
}
|
||||
|
||||
func (od *FsOrderDetailModel) GetOneOrderDetailByOrderId(ctx context.Context, orderId int64) (resp *FsOrderDetail, err error) {
|
||||
err = od.db.WithContext(ctx).Model(&FsOrderDetail{}).Where("`order_id` = ?", orderId).Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (d *FsProductDesignModel) FindOne(ctx context.Context, id int64, userId int64) (resp *FsProductDesign, err error) {
|
||||
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`id` = ? and `user_id` = ? and `status` = ?", id, userId, 1).First(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -21,3 +21,7 @@ func (dt *FsOrderDetailTemplateModel) FindOneBySn(ctx context.Context, sn string
|
||||
func (dt *FsOrderDetailTemplateModel) Create(ctx context.Context, data *FsOrderDetailTemplate) error {
|
||||
return dt.db.WithContext(ctx).Model(&FsOrderDetailTemplate{}).Create(&data).Error
|
||||
}
|
||||
func (dt *FsOrderDetailTemplateModel) FindOne(ctx context.Context, id int64) (resp *FsOrderDetailTemplate, err error) {
|
||||
err = dt.db.WithContext(ctx).Model(&FsOrderDetailTemplate{}).Where("`id` = ?", id).Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -45,3 +45,9 @@ func (o *FsOrderModel) FindOneAndCreateServiceContact(ctx context.Context, userI
|
||||
})
|
||||
return order, err
|
||||
}
|
||||
|
||||
// 获取用户最近下单成功的订单
|
||||
func (o *FsOrderModel) FindLastSuccessOneOrder(ctx context.Context, userId int64, statusGt int64) (order *FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where("`user_id` = ? and `status` > ?", userId, statusGt).Order("id DESC").Find(&order).Error
|
||||
return order, err
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func (d *FsProductModel3dModel) GetAllBySizeIdsTag(ctx context.Context, sizeIds
|
||||
if len(sizeIds) == 0 {
|
||||
return
|
||||
}
|
||||
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`size_id` in (?) and `tag` = ?", sizeIds, 1, tag).Find(&resp).Error
|
||||
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`size_id` in (?) and `tag` = ?", sizeIds, tag).Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (d *FsProductModel3dModel) GetAll(ctx context.Context) (resp []FsProductModel3d, err error) {
|
||||
|
||||
@@ -102,14 +102,14 @@ func (c *FsProductPriceModel) GetAllSelectBySizeId(ctx context.Context, sizeIds
|
||||
}
|
||||
return prices, err
|
||||
}
|
||||
func (p *FsProductPriceModel) GetPriceListByIds(ctx context.Context, Ids []int64) (resp []FsProductPrice, err error) {
|
||||
func (p *FsProductPriceModel) GetAllByIdsWithoutStatus(ctx context.Context, Ids []int64) (resp []FsProductPrice, err error) {
|
||||
if len(Ids) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
db := p.db.WithContext(ctx).Model(&FsProductPrice{}).
|
||||
Where("`id` in (?)", Ids)
|
||||
if err = db.Find(&resp).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
err = p.db.WithContext(ctx).Model(&FsProductPrice{}).Where("`id` in (?)", Ids).Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (p *FsProductPriceModel) GetAllByProductIdStatus(ctx context.Context, productId int64, status int64) (resp []FsProductPrice, err error) {
|
||||
err = p.db.WithContext(ctx).Model(&FsProductPrice{}).Where("`product_id` = ? and `status` = ?", productId, status).Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -1,2 +1,37 @@
|
||||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
||||
|
||||
import "context"
|
||||
|
||||
// TODO: 使用model的属性做你想做的
|
||||
|
||||
type FindOneRenderDesignByParamsReq struct {
|
||||
ClientNo *string
|
||||
UserId *int64
|
||||
SortType int
|
||||
Fields string
|
||||
Id *int
|
||||
}
|
||||
|
||||
func (r *FsProductRenderDesignModel) FindOneRenderDesignByParams(ctx context.Context, req FindOneRenderDesignByParamsReq) (resp *FsProductRenderDesign, err error) {
|
||||
db := r.db.WithContext(ctx).Model(&FsProductRenderDesign{})
|
||||
if req.ClientNo != nil {
|
||||
db = db.Where("`client_no` = ?", *req.ClientNo)
|
||||
}
|
||||
if req.Id != nil {
|
||||
db = db.Where("`id` = ?", *req.Id)
|
||||
}
|
||||
if req.UserId != nil {
|
||||
db = db.Where("`user_id` = ?", *req.UserId)
|
||||
}
|
||||
if req.Fields != "" {
|
||||
db = db.Select(req.Fields)
|
||||
}
|
||||
switch req.SortType {
|
||||
case 1: //id asc
|
||||
db = db.Order("`id` ASC")
|
||||
case 2: //id desc
|
||||
db = db.Order("`id` DESC")
|
||||
}
|
||||
err = db.Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@@ -61,10 +61,14 @@ func (t *FsProductTemplateV2Model) FindAllByModelIds(ctx context.Context, modelI
|
||||
}
|
||||
return
|
||||
}
|
||||
func (t *FsProductTemplateV2Model) FindAllByProductIdModelIds(ctx context.Context, ids []int64, productId int64) (resp []FsProductTemplateV2, err error) {
|
||||
if len(ids) == 0 {
|
||||
func (t *FsProductTemplateV2Model) FindAllByProductIdModelIds(ctx context.Context, modelIds []int64, productId int64) (resp []FsProductTemplateV2, err error) {
|
||||
if len(modelIds) == 0 {
|
||||
return
|
||||
}
|
||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` in (?) and `product_id` ", ids, productId).Find(&resp).Error
|
||||
err = t.db.WithContext(ctx).Debug().Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `product_id` = ? ", modelIds, productId).Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (t *FsProductTemplateV2Model) FindOneByModelId(ctx context.Context, modelId int64) (resp *FsProductTemplateV2, err error) {
|
||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` = ? ", modelId).Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user