🐛 fix bug
This commit is contained in:
parent
1212e999cc
commit
27daf68736
@ -1,6 +1,7 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"Lee-WineList/api"
|
||||||
"Lee-WineList/core"
|
"Lee-WineList/core"
|
||||||
"Lee-WineList/model/entity"
|
"Lee-WineList/model/entity"
|
||||||
"Lee-WineList/model/param"
|
"Lee-WineList/model/param"
|
||||||
@ -76,7 +77,12 @@ func (w *wineApi) Delete(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repository.Wine().Delete(p); err != nil {
|
var ue entity.User
|
||||||
|
if api.GetUser(ctx, &ue, false, true); ctx.IsAborted() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := repository.Wine().Delete(&p, &ue); err != nil {
|
||||||
core.R(ctx).FailWithMessage(err.Error())
|
core.R(ctx).FailWithMessage(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import "Lee-WineList/common/types"
|
|||||||
type Material struct {
|
type Material struct {
|
||||||
types.BaseDbModel
|
types.BaseDbModel
|
||||||
Name string `gorm:"column:name;type:varchar(255);comment:材料名;NOT NULL" json:"name"`
|
Name string `gorm:"column:name;type:varchar(255);comment:材料名;NOT NULL" json:"name"`
|
||||||
ML string `gorm:"column:ml;type:int(11) unsigned;comment:毫升" json:"ml"`
|
ML string `gorm:"column:ml;type:varchar(20) unsigned;comment:毫升" json:"ml"`
|
||||||
OtherUnit string `gorm:"column:other_unit;type:varchar(255);comment:其他单位" json:"other_unit"`
|
OtherUnit string `gorm:"column:other_unit;type:varchar(255);comment:其他单位" json:"other_unit"`
|
||||||
WindId int `gorm:"column:wine_id;type:int(11) unsigned;comment:酒ID;NOT NULL" json:"wine_id"`
|
WindId int `gorm:"column:wine_id;type:int(11) unsigned;comment:酒ID;NOT NULL" json:"wine_id"`
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,11 @@ func (w *wine) Update(p entity.Wine) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wine) Delete(p entity.Wine) (err error) {
|
func (w *wine) Delete(p *entity.Wine, ue *entity.User) (err error) {
|
||||||
err = client.MySQL.Delete(&p).Error
|
err = client.MySQL.Table(p.TableName()).Where("wine_id = ? and user_id = ?", p.WineId, ue.Id).Delete(&p).Error
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("删除酒单失败:%s", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user