fix
This commit is contained in:
parent
d6c43e3e94
commit
b7882ef06f
|
@ -2,8 +2,12 @@ package gmodel
|
|||
|
||||
import "context"
|
||||
|
||||
func (p *FsProductModel) FindOne(ctx context.Context, id int64) (resp *FsProduct, err error) {
|
||||
err = p.db.WithContext(ctx).Model(&FsProduct{}).Where("`id` = ? ", id).First(&resp).Error
|
||||
func (p *FsProductModel) FindOne(ctx context.Context, id int64, fields ...string) (resp *FsProduct, err error) {
|
||||
db := p.db.WithContext(ctx).Model(&FsProduct{}).Where("`id` = ? ", id)
|
||||
if len(fields) != 0 {
|
||||
db = db.Select(fields[0])
|
||||
}
|
||||
err = db.Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (p *FsProductModel) FindOneBySn(ctx context.Context, sn string, fields ...string) (resp *FsProduct, err error) {
|
||||
|
|
|
@ -94,8 +94,8 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
|||
logx.Error("invalid format of websocket render image message", err)
|
||||
return
|
||||
}
|
||||
//获取产品信息
|
||||
productInfo, err := w.logic.svcCtx.AllModels.FsProduct.FindOne(w.logic.ctx, renderImageData.RenderData.ProductId)
|
||||
//获取产品信息(部分字段)
|
||||
productInfo, err := w.logic.svcCtx.AllModels.FsProduct.FindOne(w.logic.ctx, renderImageData.RenderData.ProductId, "id,is_customization")
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "该产品不存在", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||
|
|
Loading…
Reference in New Issue
Block a user