新增了:发放系统优惠卷
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type CouponGrantDao struct {
|
||||
}
|
||||
|
||||
// GetCouponGrantById 获取数据-id
|
||||
func (r *CouponGrantDao) GetCouponGrantById(orderServiceId int64) (m *model.CouponGrant, err error) {
|
||||
err = global.Db.First(&m, orderServiceId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetCouponGrantPreloadById 获取数据-加载全部关联-id
|
||||
func (r *CouponGrantDao) GetCouponGrantPreloadById(orderServiceId int64) (m *model.CouponGrant, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, orderServiceId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetCouponGrantByCouponId 获取数据-id
|
||||
func (r *CouponGrantDao) GetCouponGrantByCouponId(couponId int64) (m *model.CouponGrant, err error) {
|
||||
err = global.Db.Where("coupon_id = ?", couponId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetCouponGrantList 获取列表
|
||||
func (r *CouponGrantDao) GetCouponGrantList(maps interface{}) (m []*model.CouponGrant, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddCouponGrant 新增
|
||||
func (r *CouponGrantDao) AddCouponGrant(tx *gorm.DB, model *model.CouponGrant) (*model.CouponGrant, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
Reference in New Issue
Block a user