You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
package goods
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/jinzhu/gorm"
|
|
"recook/internal/v2/model/gys/goods"
|
|
)
|
|
|
|
var AuditLogic = &auditLogic{}
|
|
|
|
type auditLogic struct {
|
|
}
|
|
|
|
func (a *auditLogic) Audit(tx *gorm.DB, adminId, goodsId uint, auditType, auditStatus int, noInfo string) error {
|
|
gysGoodsAuditModel := &goods.GysGoodsAuditModel{}
|
|
gysGoodsAuditModel.SetDb(tx.New())
|
|
data := goods.GysGoodsAuditModel{
|
|
GoodsId: goodsId,
|
|
AuditType: auditType,
|
|
AuditStatus: auditStatus,
|
|
IsLast: goods.GysGoodsAuditIsLastTrue,
|
|
NoInfo: noInfo,
|
|
AdminId: adminId,
|
|
}
|
|
gysGoodsAuditModel.Create(&data)
|
|
if data.Id == 0 {
|
|
return errors.New("网络异常")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (a *auditLogic) AuditAll(tx *gorm.DB, adminId uint, goodsIds []uint, auditType, auditStatus int, noInfo string) error {
|
|
gysGoodsAuditModel := &goods.GysGoodsAuditModel{}
|
|
gysGoodsAuditModel.SetDb(tx)
|
|
datas := []goods.GysGoodsAuditModel{}
|
|
for _, goodsId := range goodsIds {
|
|
datas = append(datas, goods.GysGoodsAuditModel{
|
|
GoodsId: goodsId,
|
|
AuditType: auditType,
|
|
AuditStatus: auditStatus,
|
|
IsLast: goods.GysGoodsAuditIsLastTrue,
|
|
NoInfo: noInfo,
|
|
AdminId: adminId,
|
|
})
|
|
}
|
|
row := gysGoodsAuditModel.CreateAll(&datas)
|
|
if int(row) != len(goodsIds) {
|
|
return errors.New("网络异常")
|
|
}
|
|
return nil
|
|
}
|