新增数据库主键处理
This commit is contained in:
parent
593ea49554
commit
c9efce7bb6
@ -153,7 +153,7 @@ func (r *UserDoctor) AddUserDoctor(c *gin.Context) {
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// GetUserDoctorPendingPage 审核-获取医生列表-分页
|
||||
// GetUserDoctorPendingPage 身份审核-获取医生列表-分页
|
||||
func (r *UserDoctor) GetUserDoctorPendingPage(c *gin.Context) {
|
||||
userDoctorRequest := requests.UserDoctorRequest{}
|
||||
if err := c.ShouldBind(&userDoctorRequest.GetUserDoctorPendingPage); err != nil {
|
||||
@ -194,7 +194,7 @@ func (r *UserDoctor) GetUserDoctorPendingPage(c *gin.Context) {
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// GetUserDoctorPending 审核-医生详情
|
||||
// GetUserDoctorPending 身份审核-医生详情
|
||||
func (r *UserDoctor) GetUserDoctorPending(c *gin.Context) {
|
||||
id := c.Param("doctor_id")
|
||||
if id == "" {
|
||||
@ -220,7 +220,7 @@ func (r *UserDoctor) GetUserDoctorPending(c *gin.Context) {
|
||||
responses.OkWithData(g, c)
|
||||
}
|
||||
|
||||
// PutUserDoctorPending 审核-审核医生
|
||||
// PutUserDoctorPending 身份审核-审核医生
|
||||
func (r *UserDoctor) PutUserDoctorPending(c *gin.Context) {
|
||||
userDoctorRequest := requests.UserDoctorRequest{}
|
||||
if err := c.ShouldBind(&userDoctorRequest.PutUserDoctorPending); err != nil {
|
||||
@ -257,3 +257,70 @@ func (r *UserDoctor) PutUserDoctorPending(c *gin.Context) {
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// GetMultiPage 多点-获取医生列表-分页
|
||||
func (r *UserDoctor) GetMultiPage(c *gin.Context) {
|
||||
userDoctorRequest := requests.UserDoctorRequest{}
|
||||
if err := c.ShouldBind(&userDoctorRequest.GetMultiPage); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(userDoctorRequest.GetMultiPage); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
if userDoctorRequest.GetMultiPage.Page == 0 {
|
||||
userDoctorRequest.GetMultiPage.Page = 1
|
||||
}
|
||||
|
||||
if userDoctorRequest.GetMultiPage.PageSize == 0 {
|
||||
userDoctorRequest.GetMultiPage.PageSize = 20
|
||||
}
|
||||
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, total, err := userDoctorDao.GetUserDoctorMultiPageSearch(userDoctorRequest.GetMultiPage, userDoctorRequest.GetMultiPage.Page, userDoctorRequest.GetMultiPage.PageSize)
|
||||
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
res := userDoctorResponse.GetMultiPageResponse(userDoctor)
|
||||
|
||||
result := make(map[string]interface{})
|
||||
result["page"] = userDoctorRequest.GetMultiPage.Page
|
||||
result["page_size"] = userDoctorRequest.GetMultiPage.PageSize
|
||||
result["total"] = total
|
||||
result["data"] = res
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// GetMulti 多点-医生详情
|
||||
func (r *UserDoctor) GetMulti(c *gin.Context) {
|
||||
id := c.Param("doctor_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 将 id 转换为 int64 类型
|
||||
doctorId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
userDoctorService := service.UserDoctorService{}
|
||||
g, err := userDoctorService.GetUserDoctorPending(doctorId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(g, c)
|
||||
}
|
||||
|
||||
@ -71,6 +71,14 @@ func (r *DoctorExpertiseDao) AddDoctorExpertise(tx *gorm.DB, model *model.Doctor
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// AddDoctorExpertises 新增医生专长-多
|
||||
func (r *DoctorExpertiseDao) AddDoctorExpertises(tx *gorm.DB, models []model.DoctorExpertise) error {
|
||||
if err := tx.Create(&models).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddDoctorExpertiseByMap 新增医生专长-map
|
||||
func (r *DoctorExpertiseDao) AddDoctorExpertiseByMap(tx *gorm.DB, data map[string]interface{}) (*model.DoctorExpertise, error) {
|
||||
userDoctorInfo := &model.DoctorExpertise{}
|
||||
|
||||
@ -212,7 +212,7 @@ func (r *UserDoctorDao) AddUserDoctor(tx *gorm.DB, model *model.UserDoctor) (*mo
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// GetUserDoctorPendingPageSearch 审核-获取医生列表-分页
|
||||
// GetUserDoctorPendingPageSearch 身份审核-获取医生列表-分页
|
||||
func (r *UserDoctorDao) GetUserDoctorPendingPageSearch(p requests.GetUserDoctorPendingPage, page, pageSize int) (m []*model.UserDoctor, total int64, err error) {
|
||||
var totalRecords int64
|
||||
|
||||
@ -270,3 +270,62 @@ func (r *UserDoctorDao) GetUserDoctorPendingPageSearch(p requests.GetUserDoctorP
|
||||
}
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
// GetUserDoctorMultiPageSearch 多点-获取医生列表-分页
|
||||
func (r *UserDoctorDao) GetUserDoctorMultiPageSearch(p requests.GetMultiPage, page, pageSize int) (m []*model.UserDoctor, total int64, err error) {
|
||||
var totalRecords int64
|
||||
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.UserDoctor{}).Omit("open_id", "union_id", "wx_session_key")
|
||||
|
||||
// 用户
|
||||
query = query.Preload("User", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("user_password", "salt")
|
||||
})
|
||||
|
||||
// 医院
|
||||
query = query.Preload("Hospital", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("hospital_id,hospital_name,hospital_level_name")
|
||||
})
|
||||
|
||||
// 手机号
|
||||
if p.Mobile != "" {
|
||||
subQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile LIKE ?", "%"+p.Mobile+"%")
|
||||
|
||||
query = query.Where(gorm.Expr("user_id IN (?)", subQuery))
|
||||
}
|
||||
|
||||
// 用户名称
|
||||
if p.UserName != "" {
|
||||
query = query.Where("user_name LIKE ?", "%"+p.UserName+"%")
|
||||
}
|
||||
|
||||
// 身份认证状态
|
||||
if p.MultiPointStatus != nil {
|
||||
query = query.Where("multi_point_status = ?", p.MultiPointStatus)
|
||||
} else {
|
||||
query = query.Where("multi_point_status IN ?", []string{"2", "3"})
|
||||
}
|
||||
|
||||
// 医院名称
|
||||
if p.HospitalName != "" {
|
||||
subQuery := global.Db.Model(&model.Hospital{}).
|
||||
Select("hospital_id").
|
||||
Where("hospital_name LIKE ?", "%"+p.HospitalName+"%")
|
||||
|
||||
query = query.Where(gorm.Expr("hospital_id IN (?)", subQuery))
|
||||
}
|
||||
|
||||
// 查询总数量
|
||||
if err := query.Count(&totalRecords).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
err = query.Scopes(model.Paginate(page, pageSize)).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// AdminAPI 后台-接口表
|
||||
type AdminAPI struct {
|
||||
Model
|
||||
@ -13,3 +19,17 @@ type AdminAPI struct {
|
||||
func (m *AdminAPI) TableName() string {
|
||||
return "gdxz_admin_api"
|
||||
}
|
||||
|
||||
func (m *AdminAPI) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.APIID == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.APIID = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// AdminDept 后台-部门表
|
||||
type AdminDept struct {
|
||||
DeptId int64 `gorm:"column:dept_id;type:bigint(19);primary_key;comment:主键id" json:"dept_id"`
|
||||
@ -12,3 +18,17 @@ type AdminDept struct {
|
||||
func (m *AdminDept) TableName() string {
|
||||
return "gdxz_admin_dept"
|
||||
}
|
||||
|
||||
func (m *AdminDept) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.DeptId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.DeptId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// AdminMenu 后台-菜单表
|
||||
type AdminMenu struct {
|
||||
Model
|
||||
@ -19,3 +25,17 @@ type AdminMenu struct {
|
||||
func (m *AdminMenu) TableName() string {
|
||||
return "gdxz_admin_menu"
|
||||
}
|
||||
|
||||
func (m *AdminMenu) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.MenuId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.MenuId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// AdminPost 后台-岗位表
|
||||
type AdminPost struct {
|
||||
PostId int64 `gorm:"column:post_id;type:bigint(19);primary_key;comment:主键id" json:"post_id"`
|
||||
@ -11,3 +17,17 @@ type AdminPost struct {
|
||||
func (m *AdminPost) TableName() string {
|
||||
return "gdxz_admin_post"
|
||||
}
|
||||
|
||||
func (m *AdminPost) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.PostId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.PostId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// AdminRole 后台-角色表
|
||||
type AdminRole struct {
|
||||
RoleId int64 `gorm:"column:role_id;type:bigint(19);primary_key;comment:主键id" json:"role_id"`
|
||||
@ -12,3 +18,17 @@ type AdminRole struct {
|
||||
func (m *AdminRole) TableName() string {
|
||||
return "gdxz_admin_role"
|
||||
}
|
||||
|
||||
func (m *AdminRole) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.RoleId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.RoleId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// AdminUser 后台-用户表
|
||||
type AdminUser struct {
|
||||
Model
|
||||
@ -28,3 +34,17 @@ type AdminUser struct {
|
||||
func (m *AdminUser) TableName() string {
|
||||
return "gdxz_admin_user"
|
||||
}
|
||||
|
||||
func (m *AdminUser) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.UserID == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.UserID = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// Area 地区表
|
||||
type Area struct {
|
||||
AreaId int64 `gorm:"column:area_id;type:bigint(19);primary_key;comment:地区编号" json:"area_id"`
|
||||
@ -12,3 +18,17 @@ type Area struct {
|
||||
func (m *Area) TableName() string {
|
||||
return "gdxz_area"
|
||||
}
|
||||
|
||||
func (m *Area) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.AreaId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.AreaId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
type BasicBank struct {
|
||||
BankId int64 `gorm:"column:bank_id;type:bigint(19);primary_key;comment:主键id" json:"bank_id"`
|
||||
BankCode string `gorm:"column:bank_code;type:varchar(255);comment:银行编码" json:"bank_code"`
|
||||
@ -12,3 +18,17 @@ type BasicBank struct {
|
||||
func (m *BasicBank) TableName() string {
|
||||
return "gdxz_basic_bank"
|
||||
}
|
||||
|
||||
func (m *BasicBank) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.BankId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.BankId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// DiseaseClassExpertise 疾病分类表-医生专长
|
||||
type DiseaseClassExpertise struct {
|
||||
ExpertiseId int64 `gorm:"column:expertise_id;type:bigint(19);primary_key;comment:主键id" json:"expertise_id"`
|
||||
@ -11,3 +17,17 @@ type DiseaseClassExpertise struct {
|
||||
func (m *DiseaseClassExpertise) TableName() string {
|
||||
return "gdxz_disease_class_expertise"
|
||||
}
|
||||
|
||||
func (m *DiseaseClassExpertise) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.ExpertiseId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.ExpertiseId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// DoctorBankCard 医生银行卡
|
||||
type DoctorBankCard struct {
|
||||
BankCardId int64 `gorm:"column:bank_card_id;type:bigint(19);primary_key;comment:主键id" json:"bank_card_id"`
|
||||
@ -19,3 +25,17 @@ type DoctorBankCard struct {
|
||||
func (m *DoctorBankCard) TableName() string {
|
||||
return "gdxz_doctor_bank_card"
|
||||
}
|
||||
|
||||
func (m *DoctorBankCard) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.BankCardId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.BankCardId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// DoctorExpertise 医生专长表
|
||||
type DoctorExpertise struct {
|
||||
DoctorExpertiseId int64 `gorm:"column:doctor_expertise_id;type:bigint(19);primary_key;comment:主键id" json:"doctor_expertise_id"`
|
||||
@ -11,3 +17,17 @@ type DoctorExpertise struct {
|
||||
func (m *DoctorExpertise) TableName() string {
|
||||
return "gdxz_doctor_expertise"
|
||||
}
|
||||
|
||||
func (m *DoctorExpertise) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.DoctorExpertiseId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.DoctorExpertiseId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// DoctorIdenFail 医生身份审核失败原因表
|
||||
type DoctorIdenFail struct {
|
||||
IdenFailId int64 `gorm:"column:iden_fail_id;type:bigint(19);primary_key;comment:主键id" json:"iden_fail_id"`
|
||||
@ -12,3 +18,17 @@ type DoctorIdenFail struct {
|
||||
func (m *DoctorIdenFail) TableName() string {
|
||||
return "gdxz_doctor_iden_fail"
|
||||
}
|
||||
|
||||
func (m *DoctorIdenFail) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.IdenFailId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.IdenFailId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// Hospital 医院表
|
||||
type Hospital struct {
|
||||
HospitalID int64 `gorm:"column:hospital_id;type:bigint(19);primary_key;comment:主键id" json:"hospital_id"`
|
||||
@ -24,3 +30,17 @@ type Hospital struct {
|
||||
func (m *Hospital) TableName() string {
|
||||
return "gdxz_hospital"
|
||||
}
|
||||
|
||||
func (m *Hospital) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.HospitalID == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.HospitalID = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// HospitalDepartmentCustom 医院科室表-自定义
|
||||
type HospitalDepartmentCustom struct {
|
||||
DepartmentCustomId int64 `gorm:"column:department_custom_id;type:bigint(19);primary_key;comment:主键id" json:"department_custom_id"`
|
||||
@ -14,3 +20,17 @@ type HospitalDepartmentCustom struct {
|
||||
func (m *HospitalDepartmentCustom) TableName() string {
|
||||
return "gdxz_hospital_department_custom"
|
||||
}
|
||||
|
||||
func (m *HospitalDepartmentCustom) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.DepartmentCustomId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.DepartmentCustomId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,10 +4,7 @@ import (
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@ -69,28 +66,6 @@ func (m *Model) BeforeUpdate(tx *gorm.DB) (err error) {
|
||||
|
||||
// BeforeCreate 注册 BeforeCreate 回调函数
|
||||
func (m *Model) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
// 动态添加表主键
|
||||
primaryName := ""
|
||||
field := tx.Statement.Schema.Fields
|
||||
for _, v := range field {
|
||||
if v.PrimaryKey {
|
||||
primaryName = v.Name
|
||||
}
|
||||
}
|
||||
|
||||
if primaryName != "" {
|
||||
// 动态访问 YourModel 结构体本身
|
||||
model := tx.Statement.Dest
|
||||
primaryValue := reflect.ValueOf(model).Elem().FieldByName(primaryName)
|
||||
if primaryValue.IsZero() {
|
||||
node, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return errors.New("服务器错误")
|
||||
}
|
||||
tx.Statement.SetColumn(primaryName, node.Generate().Int64())
|
||||
}
|
||||
}
|
||||
|
||||
m.CreatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderPrescription 订单-处方表
|
||||
type OrderPrescription struct {
|
||||
@ -34,3 +39,17 @@ type OrderPrescription struct {
|
||||
func (m *OrderPrescription) TableName() string {
|
||||
return "gdxz_order_prescription"
|
||||
}
|
||||
|
||||
func (m *OrderPrescription) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.OrderPrescriptionId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.OrderPrescriptionId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// PatientFamily 患者家庭成员信息表-基本信息
|
||||
type PatientFamily struct {
|
||||
FamilyId int64 `gorm:"column:family_id;type:bigint(19);primary_key;comment:主键id" json:"family_id"`
|
||||
@ -35,3 +41,17 @@ type PatientFamily struct {
|
||||
func (m *PatientFamily) TableName() string {
|
||||
return "gdxz_patient_family"
|
||||
}
|
||||
|
||||
func (m *PatientFamily) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.FamilyId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.FamilyId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// User 用户主表
|
||||
type User struct {
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);primary_key;comment:主键" json:"user_id"`
|
||||
@ -24,3 +30,17 @@ type User struct {
|
||||
func (m *User) TableName() string {
|
||||
return "gdxz_user"
|
||||
}
|
||||
|
||||
func (m *User) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.UserId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.UserId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// UserCaCert 医师/药师ca监管证书表
|
||||
type UserCaCert struct {
|
||||
CertId int64 `gorm:"column:cert_id;type:bigint(19);primary_key;comment:主键id" json:"cert_id"`
|
||||
@ -18,3 +24,17 @@ type UserCaCert struct {
|
||||
func (m *UserCaCert) TableName() string {
|
||||
return "gdxz_user_ca_cert"
|
||||
}
|
||||
|
||||
func (m *UserCaCert) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.CertId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.CertId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// UserDoctor 用户-医生表
|
||||
type UserDoctor struct {
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);primary_key;comment:主键" json:"doctor_id"`
|
||||
@ -47,3 +53,17 @@ type UserDoctor struct {
|
||||
func (m *UserDoctor) TableName() string {
|
||||
return "gdxz_user_doctor"
|
||||
}
|
||||
|
||||
func (m *UserDoctor) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.DoctorId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.DoctorId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
)
|
||||
|
||||
// UserDoctorInfo 用户-医生详情表
|
||||
type UserDoctorInfo struct {
|
||||
DoctorInfoId int64 `gorm:"column:doctor_info_id;type:bigint(19);primary_key;comment:主键" json:"doctor_info_id"`
|
||||
@ -24,3 +30,17 @@ type UserDoctorInfo struct {
|
||||
func (m *UserDoctorInfo) TableName() string {
|
||||
return "gdxz_user_doctor_info"
|
||||
}
|
||||
|
||||
func (m *UserDoctorInfo) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.DoctorInfoId == 0 {
|
||||
// 创建雪花算法实例
|
||||
sf, err := snowflake.NewNode(config.C.Snowflake)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 生成新的雪花算法 ID
|
||||
m.DoctorInfoId = sf.Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,8 +4,9 @@ type UserDoctorRequest struct {
|
||||
GetUserDoctorPage // 获取医生列表-分页
|
||||
PutUserDoctor // 修改医生
|
||||
AddUserDoctor // 新增医生
|
||||
GetUserDoctorPendingPage // 审核-获取医生列表-分页
|
||||
PutUserDoctorPending // 审核-审核医生
|
||||
GetUserDoctorPendingPage // 身份审核-获取医生列表-分页
|
||||
PutUserDoctorPending // 身份审核-审核医生
|
||||
GetMultiPage // 多点-获取医生列表-分页
|
||||
}
|
||||
|
||||
// GetUserDoctorPage 获取医生列表-分页
|
||||
@ -74,7 +75,7 @@ type AddUserDoctor struct {
|
||||
DoctorExpertise []string `json:"doctor_expertise" form:"doctor_expertise" label:"专长"`
|
||||
}
|
||||
|
||||
// GetUserDoctorPendingPage 审核-获取医生列表-分页
|
||||
// GetUserDoctorPendingPage 身份审核-获取医生列表-分页
|
||||
type GetUserDoctorPendingPage struct {
|
||||
Page int `json:"page" form:"page" label:"页码"`
|
||||
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
||||
@ -84,7 +85,7 @@ type GetUserDoctorPendingPage struct {
|
||||
IdenAuthStatus *int `json:"iden_auth_status" form:"iden_auth_status" label:"认证状态"` // (0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
}
|
||||
|
||||
// PutUserDoctorPending 审核-审核医生
|
||||
// PutUserDoctorPending 身份审核-审核医生
|
||||
type PutUserDoctorPending struct {
|
||||
IdenAuthStatus int `json:"iden_auth_status" form:"iden_auth_status" validate:"required,oneof=1 3" label:"认证状态"` // (0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
QualificationCertNum string `json:"qualification_cert_num" form:"qualification_cert_num" label:"医师资格证号"`
|
||||
@ -97,3 +98,13 @@ type PutUserDoctorPending struct {
|
||||
QualificationCertReason string `json:"qualification_cert_reason" form:"qualification_cert_reason" label:"医师资格证失败原因"`
|
||||
WorkCertReason string `json:"work_cert_reason" form:"work_cert_reason" label:"医师工作证失败原因"`
|
||||
}
|
||||
|
||||
// GetMultiPage 多点-获取医生列表-分页
|
||||
type GetMultiPage struct {
|
||||
Page int `json:"page" form:"page" label:"页码"`
|
||||
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
||||
Mobile string `json:"mobile" form:"mobile" label:"手机号"`
|
||||
UserName string `json:"user_name" form:"user_name" label:"用户名"`
|
||||
HospitalName string `json:"hospital_name" form:"hospital_name" label:"医院名称"`
|
||||
MultiPointStatus *int `json:"multi_point_status" form:"multi_point_status" label:"医生多点执业认证状态"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ type GetUserDoctor struct {
|
||||
DoctorBankCard *doctorBankCardResponse.DoctorBankCard `json:"doctor_bank_card"` // 医生银行卡
|
||||
}
|
||||
|
||||
// getUserDoctorPendingPage 审核-获取医生列表-分页
|
||||
// getUserDoctorPendingPage 身份审核-获取医生列表-分页
|
||||
type getUserDoctorPendingPage struct {
|
||||
DoctorID string `json:"doctor_id"` // 主键id
|
||||
UserID string `json:"user_id"` // 用户id
|
||||
@ -115,7 +115,30 @@ type getUserDoctorPendingPage struct {
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetUserDoctorPending 审核-医生详情
|
||||
// GetMultiPage 多点-获取医生列表-分页
|
||||
type GetMultiPage struct {
|
||||
DoctorID string `json:"doctor_id"` // 主键id
|
||||
UserID string `json:"user_id"` // 用户id
|
||||
UserName string `json:"user_name"` // 用户名称
|
||||
Status int `json:"status"` // 状态(0:禁用 1:正常 2:删除)
|
||||
IDCardStatus int `json:"idcard_status"` // 实名认证状态(0:未认证 1:认证通过 2:认证失败)
|
||||
MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
MultiPointTime model.LocalTime `json:"multi_point_time"` // 审核时间
|
||||
MultiPointFailReason string `json:"multi_point_fail_reason"` // 多点执业认证失败原因
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
DoctorTitle int `json:"doctor_title"` // 医生职称(1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)
|
||||
DepartmentCustomName string `json:"department_custom_name"` // 科室名称(如未自己输入,填入标准科室名称)
|
||||
DepartmentCustomMobile string `json:"department_custom_mobile"` // 科室电话
|
||||
HospitalID string `json:"hospital_id"` // 所属医院id
|
||||
HospitalName string `json:"hospital_name"` // 医院名称
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
Age uint `json:"age"` // 年龄
|
||||
Sex int `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetUserDoctorPending 身份审核-医生详情
|
||||
type GetUserDoctorPending struct {
|
||||
DoctorID string `json:"doctor_id"` // 主键id
|
||||
UserID string `json:"user_id"` // 用户id
|
||||
@ -153,6 +176,32 @@ type IdenAuthFailReason struct {
|
||||
WorkCertReason string `json:"work_cert_reason"` // 医师工作证失败原因
|
||||
}
|
||||
|
||||
// GetMulti 多点-医生详情
|
||||
type GetMulti struct {
|
||||
DoctorID string `json:"doctor_id"` // 主键id
|
||||
UserID string `json:"user_id"` // 用户id
|
||||
UserName string `json:"user_name"` // 用户名称
|
||||
Status int `json:"status"` // 状态(0:禁用 1:正常 2:删除)
|
||||
IDCardStatus int `json:"idcard_status"` // 实名认证状态(0:未认证 1:认证通过 2:认证失败)
|
||||
MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
MultiPointTime model.LocalTime `json:"multi_point_time"` // 审核时间
|
||||
MultiPointFailReason string `json:"multi_point_fail_reason"` // 多点执业认证失败原因
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
DoctorTitle int `json:"doctor_title"` // 医生职称(1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)
|
||||
DepartmentCustomID string `json:"department_custom_id"` // 科室id-自定义
|
||||
DepartmentCustomName string `json:"department_custom_name"` // 科室名称(如未自己输入,填入标准科室名称)
|
||||
DepartmentCustomMobile string `json:"department_custom_mobile"` // 科室电话
|
||||
HospitalID string `json:"hospital_id"` // 所属医院id
|
||||
BeGoodAt string `json:"be_good_at"` // 擅长
|
||||
BriefIntroduction string `json:"brief_introduction"` // 医生简介
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
User *userResponse.User `json:"user"` // 用户
|
||||
Hospital *hospitalResponse.Hospital `json:"hospital"` // 医院
|
||||
UserDoctorInfo *userDoctorInfoResponse.UserDoctorInfo `json:"user_doctor_info"` // 医生详情
|
||||
DoctorExpertise []*doctorExpertiseResponse.DoctorExpertise `json:"doctor_expertise"` // 医生专长
|
||||
}
|
||||
|
||||
// GetUserDoctorPageResponse 获取用户列表-分页
|
||||
func GetUserDoctorPageResponse(userDoctor []*model.UserDoctor) []getUserDoctorPage {
|
||||
// 处理返回值
|
||||
@ -211,7 +260,7 @@ func GetUserDoctorPageResponse(userDoctor []*model.UserDoctor) []getUserDoctorPa
|
||||
return getUserPageResponses
|
||||
}
|
||||
|
||||
// GetUserDoctorPendingPageResponse 审核-获取医生列表-分页
|
||||
// GetUserDoctorPendingPageResponse 身份审核-获取医生列表-分页
|
||||
func GetUserDoctorPendingPageResponse(userDoctor []*model.UserDoctor) []getUserDoctorPendingPage {
|
||||
// 处理返回值
|
||||
getUserDoctorPendingPageResponses := make([]getUserDoctorPendingPage, len(userDoctor))
|
||||
@ -254,3 +303,47 @@ func GetUserDoctorPendingPageResponse(userDoctor []*model.UserDoctor) []getUserD
|
||||
|
||||
return getUserDoctorPendingPageResponses
|
||||
}
|
||||
|
||||
// GetMultiPageResponse 多点-获取医生列表-分页
|
||||
func GetMultiPageResponse(userDoctor []*model.UserDoctor) []GetMultiPage {
|
||||
// 处理返回值
|
||||
r := make([]GetMultiPage, len(userDoctor))
|
||||
|
||||
if len(userDoctor) > 0 {
|
||||
for i, v := range userDoctor {
|
||||
// 将原始结构体转换为新结构体
|
||||
g := GetMultiPage{
|
||||
DoctorID: strconv.Itoa(int(v.DoctorId)),
|
||||
UserID: strconv.Itoa(int(v.UserId)),
|
||||
UserName: v.UserName,
|
||||
Status: v.Status,
|
||||
IDCardStatus: v.Status,
|
||||
MultiPointStatus: v.MultiPointStatus,
|
||||
MultiPointTime: v.MultiPointTime,
|
||||
MultiPointFailReason: v.MultiPointFailReason,
|
||||
Avatar: config.C.Oss.OssCustomDomainName + "/" + v.Avatar,
|
||||
DoctorTitle: v.DoctorTitle,
|
||||
DepartmentCustomName: v.DepartmentCustomName,
|
||||
DepartmentCustomMobile: v.DepartmentCustomMobile,
|
||||
HospitalID: strconv.Itoa(int(v.HospitalID)),
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
if v.User != nil {
|
||||
g.Mobile = v.User.Mobile
|
||||
g.Age = v.User.Age
|
||||
g.Sex = v.User.Sex
|
||||
}
|
||||
|
||||
if v.Hospital != nil {
|
||||
g.HospitalName = v.Hospital.HospitalName
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
r[i] = g
|
||||
}
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
@ -328,28 +328,31 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
// 新增医生
|
||||
doctorGroup.POST("", api.UserDoctor.AddUserDoctor)
|
||||
|
||||
// 待审核列表
|
||||
// 身份审核列表
|
||||
doctorPendingGroup := doctorGroup.Group("/pending")
|
||||
{
|
||||
// 审核-获取医生列表-分页
|
||||
// 身份审核-获取医生列表-分页
|
||||
doctorPendingGroup.GET("", api.UserDoctor.GetUserDoctorPendingPage)
|
||||
|
||||
// 审核-医生详情
|
||||
// 身份审核-医生详情
|
||||
doctorPendingGroup.GET("/:doctor_id", api.UserDoctor.GetUserDoctorPending)
|
||||
|
||||
// 审核-审核医生
|
||||
// 身份审核-审核医生
|
||||
doctorPendingGroup.PUT("/:doctor_id", api.UserDoctor.PutUserDoctorPending)
|
||||
}
|
||||
|
||||
//
|
||||
// // 医生详情
|
||||
// doctorGroup.GET("/:post_id", api.Post.GetPost)
|
||||
//
|
||||
// // 删除医生-批量
|
||||
// doctorGroup.DELETE("", api.Post.DeletePost)
|
||||
//
|
||||
// // 修改医生
|
||||
// doctorGroup.PUT("/:post_id", api.Post.PutPost)
|
||||
// 多点列表
|
||||
doctorMultiGroup := doctorGroup.Group("/multi")
|
||||
{
|
||||
// 多点-获取医生列表-分页
|
||||
doctorMultiGroup.GET("", api.UserDoctor.GetMultiPage)
|
||||
|
||||
// 多点-医生详情
|
||||
doctorMultiGroup.GET("/:doctor_id", api.UserDoctor.GetMulti)
|
||||
|
||||
// 多点-审核医生
|
||||
doctorMultiGroup.PUT("/:doctor_id", api.UserDoctor.GetMultiPage)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -957,7 +957,7 @@ func (r *UserDoctorService) GetDoctorIdenFailReasonByDoctorId(doctorId int64) (*
|
||||
return &idenAuthFailReason, nil
|
||||
}
|
||||
|
||||
// GetUserDoctorPending 审核-医生详情
|
||||
// GetUserDoctorPending 身份审核-医生详情
|
||||
func (r *UserDoctorService) GetUserDoctorPending(doctorId int64) (g *userDoctorResponse.GetUserDoctorPending, err error) {
|
||||
// 获取医生数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
@ -1028,7 +1028,7 @@ func (r *UserDoctorService) GetUserDoctorPending(doctorId int64) (g *userDoctorR
|
||||
return g, nil
|
||||
}
|
||||
|
||||
// PutUserDoctorPending 审核-审核医生
|
||||
// PutUserDoctorPending 身份审核-审核医生
|
||||
func (r *UserDoctorService) PutUserDoctorPending(doctorId int64, req requests.PutUserDoctorPending) (bool, error) {
|
||||
// 获取医生数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
@ -1247,3 +1247,66 @@ func (r *UserDoctorService) PutUserDoctorPending(doctorId int64, req requests.Pu
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetMulti 多点-医生详情
|
||||
func (r *UserDoctorService) GetMulti(doctorId int64) (g *userDoctorResponse.GetMulti, err error) {
|
||||
// 获取医生数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctorPreloadById(doctorId)
|
||||
if err != nil || userDoctor == nil {
|
||||
return nil, errors.New("用户数据错误")
|
||||
}
|
||||
|
||||
userDoctorService := UserDoctorService{}
|
||||
|
||||
// 获取医生专长
|
||||
doctorExpertise, err := userDoctorService.GetUserDoctorExpertiseByDoctorId(doctorId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
var userDoctorInfo *userDoctorInfoResponse.UserDoctorInfo
|
||||
if userDoctor.UserDoctorInfo != nil {
|
||||
userDoctorInfo = userDoctorInfoResponse.UserDoctorInfoResponse(userDoctor.UserDoctorInfo)
|
||||
}
|
||||
|
||||
// 医院
|
||||
var hospital *hospitalResponse.Hospital
|
||||
if userDoctor.Hospital != nil {
|
||||
hospital = hospitalResponse.HospitalResponse(userDoctor.Hospital)
|
||||
}
|
||||
|
||||
// 用户
|
||||
var user *userResponse.User
|
||||
if userDoctor.User != nil {
|
||||
user = userResponse.UserResponse(userDoctor.User)
|
||||
}
|
||||
|
||||
g = &userDoctorResponse.GetMulti{
|
||||
DoctorID: strconv.Itoa(int(userDoctor.DoctorId)),
|
||||
UserID: strconv.Itoa(int(userDoctor.UserId)),
|
||||
UserName: userDoctor.UserName,
|
||||
Status: userDoctor.Status,
|
||||
IDCardStatus: userDoctor.Status,
|
||||
MultiPointStatus: userDoctor.MultiPointStatus,
|
||||
MultiPointTime: userDoctor.MultiPointTime,
|
||||
MultiPointFailReason: userDoctor.MultiPointFailReason,
|
||||
Avatar: config.C.Oss.OssCustomDomainName + userDoctor.Avatar,
|
||||
DoctorTitle: userDoctor.DoctorTitle,
|
||||
DepartmentCustomID: strconv.Itoa(int(userDoctor.DepartmentCustomId)),
|
||||
DepartmentCustomName: userDoctor.DepartmentCustomName,
|
||||
DepartmentCustomMobile: userDoctor.DepartmentCustomMobile,
|
||||
HospitalID: strconv.Itoa(int(userDoctor.HospitalID)),
|
||||
BeGoodAt: userDoctor.BeGoodAt,
|
||||
BriefIntroduction: userDoctor.BriefIntroduction,
|
||||
CreatedAt: userDoctor.CreatedAt,
|
||||
UpdatedAt: userDoctor.UpdatedAt,
|
||||
User: user,
|
||||
Hospital: hospital,
|
||||
UserDoctorInfo: userDoctorInfo,
|
||||
DoctorExpertise: doctorExpertise, // 专长
|
||||
}
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user