新增上报处方平台接口
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type UserPharmacistDao struct {
|
||||
}
|
||||
|
||||
// GetUserPharmacistById 获取药师数据-药师id
|
||||
func (r *UserPharmacistDao) GetUserPharmacistById(pharmacistId int64) (m *model.UserPharmacist, err error) {
|
||||
err = global.Db.First(&m, pharmacistId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (r *UserPharmacistDao) GetUserPharmacistByUserId(userId int64) (m *model.UserPharmacist, err error) {
|
||||
err = global.Db.Where("user_id = ?", userId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetUserPharmacistPreloadById 获取药师数据-加载全部关联-药师id
|
||||
func (r *UserPharmacistDao) GetUserPharmacistPreloadById(pharmacistId int64) (m *model.UserPharmacist, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, pharmacistId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteUserPharmacist 删除药师
|
||||
func (r *UserPharmacistDao) DeleteUserPharmacist(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.UserPharmacist{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditUserPharmacist 修改药师
|
||||
func (r *UserPharmacistDao) EditUserPharmacist(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.UserPharmacist{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditUserPharmacistByUserId 修改药师-药师id
|
||||
func (r *UserPharmacistDao) EditUserPharmacistByUserId(tx *gorm.DB, userId int64, data interface{}) error {
|
||||
err := tx.Model(&model.UserPharmacist{}).Where("user_id = ?", userId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetUserPharmacistList 获取药师列表
|
||||
func (r *UserPharmacistDao) GetUserPharmacistList(maps interface{}) (m []*model.UserPharmacist, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddUserPharmacist 新增药师
|
||||
func (r *UserPharmacistDao) AddUserPharmacist(tx *gorm.DB, model *model.UserPharmacist) (*model.UserPharmacist, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
Reference in New Issue
Block a user