新增药品订单详情
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type OrderProductLogisticsDao struct {
|
||||
}
|
||||
|
||||
// GetOrderProductLogisticsById 获取药品订单物流数据-药品订单物流id
|
||||
func (r *OrderProductLogisticsDao) GetOrderProductLogisticsById(LogisticsId int64) (m *model.OrderProductLogistics, err error) {
|
||||
err = global.Db.First(&m, LogisticsId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOrderProductLogisticsPreloadById 获取药品订单物流数据-加载全部关联-药品订单物流id
|
||||
func (r *OrderProductLogisticsDao) GetOrderProductLogisticsPreloadById(LogisticsId int64) (m *model.OrderProductLogistics, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, LogisticsId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOrderProductLogisticsByOrderProductId 获取药品订单物流数据-药品订单id
|
||||
func (r *OrderProductLogisticsDao) GetOrderProductLogisticsByOrderProductId(orderProductId int64) (m *model.OrderProductLogistics, err error) {
|
||||
err = global.Db.Where("order_product_id = ?", orderProductId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteOrderProductLogistics 删除药品订单物流
|
||||
func (r *OrderProductLogisticsDao) DeleteOrderProductLogistics(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.OrderProductLogistics{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderProductLogistics 修改药品订单物流
|
||||
func (r *OrderProductLogisticsDao) EditOrderProductLogistics(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.OrderProductLogistics{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderProductLogisticsById 修改药品订单物流-药品订单物流id
|
||||
func (r *OrderProductLogisticsDao) EditOrderProductLogisticsById(tx *gorm.DB, orderProductId int64, data interface{}) error {
|
||||
err := tx.Model(&model.OrderProductLogistics{}).Where("order_product_id = ?", orderProductId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetOrderProductLogisticsList 获取药品订单物流列表
|
||||
func (r *OrderProductLogisticsDao) GetOrderProductLogisticsList(maps interface{}) (m []*model.OrderProductLogistics, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddOrderProductLogistics 新增药品订单物流
|
||||
func (r *OrderProductLogisticsDao) AddOrderProductLogistics(tx *gorm.DB, model *model.OrderProductLogistics) (*model.OrderProductLogistics, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
Reference in New Issue
Block a user