diff --git a/api/controller/adminApi.go b/api/controller/adminApi.go index d8026a2..420f0a6 100644 --- a/api/controller/adminApi.go +++ b/api/controller/adminApi.go @@ -3,9 +3,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/apiResponse" "hospital-admin-api/api/service" "hospital-admin-api/global" "hospital-admin-api/utils" @@ -45,7 +45,7 @@ func (r *AdminApi) GetApiPage(c *gin.Context) { } // 处理返回值 - getApiPageResponses := apiResponse.GetApiPageResponse(adminApi) + getApiPageResponses := dto.GetAdminApiListDto(adminApi) result := make(map[string]interface{}) result["page"] = apiRequest.GetApiPage.Page @@ -87,7 +87,7 @@ func (r *AdminApi) GetApiList(c *gin.Context) { } // 处理返回值 - getApiPageResponses := apiResponse.GetApiListResponse(adminApis) + getApiPageResponses := dto.GetAdminApiListDto(adminApis) responses.OkWithData(getApiPageResponses, c) } @@ -153,7 +153,7 @@ func (r *AdminApi) GetApi(c *gin.Context) { } // 处理返回值 - getApiResponses := apiResponse.GetApiResponse(adminApi) + getApiResponses := dto.GetAdminApiDto(adminApi) responses.OkWithData(getApiResponses, c) } diff --git a/api/controller/adminDept.go b/api/controller/adminDept.go index 707bcac..d323bb2 100644 --- a/api/controller/adminDept.go +++ b/api/controller/adminDept.go @@ -3,9 +3,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/deptResponse" "hospital-admin-api/api/service" "hospital-admin-api/global" "hospital-admin-api/utils" @@ -88,7 +88,7 @@ func (r *Dept) GetDept(c *gin.Context) { } // 处理返回值 - getDeptResponses := deptResponse.GetDeptResponse(adminDept) + getDeptResponses := dto.GetAdminDeptDto(adminDept) responses.OkWithData(getDeptResponses, c) } diff --git a/api/controller/adminMenu.go b/api/controller/adminMenu.go index 9895a89..4036ada 100644 --- a/api/controller/adminMenu.go +++ b/api/controller/adminMenu.go @@ -2,9 +2,9 @@ package controller import ( "github.com/gin-gonic/gin" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/menuResponse" "hospital-admin-api/api/service" "hospital-admin-api/global" "hospital-admin-api/utils" @@ -243,11 +243,8 @@ func (r *Menu) GetMenu(c *gin.Context) { } // 处理返回值 - getMenuResponse, err := menuResponse.GetMenuResponse(adminMenu, getAdminMenuApis) - if err != nil { - responses.FailWithMessage(err.Error(), c) - return - } + getMenuResponse := dto.GetAdminMenuDto(adminMenu) + getMenuResponse.LoadAdminMenuApi(getAdminMenuApis) responses.OkWithData(getMenuResponse, c) } diff --git a/api/controller/adminPost.go b/api/controller/adminPost.go index 2b91908..8e69270 100644 --- a/api/controller/adminPost.go +++ b/api/controller/adminPost.go @@ -3,9 +3,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/postResponse" "hospital-admin-api/api/service" "hospital-admin-api/global" "hospital-admin-api/utils" @@ -45,7 +45,7 @@ func (r *Post) GetPostPage(c *gin.Context) { } // 处理返回值 - getPostPageResponses := postResponse.GetPostPageResponse(adminPost) + getPostPageResponses := dto.GetAdminPostListDto(adminPost) result := make(map[string]interface{}) result["page"] = postRequest.GetPostPage.Page @@ -116,7 +116,7 @@ func (r *Post) GetPost(c *gin.Context) { } // 处理返回值 - getPostResponses := postResponse.GetPostResponse(adminPost) + getPostResponses := dto.GetAdminPostDto(adminPost) responses.OkWithData(getPostResponses, c) } @@ -241,7 +241,7 @@ func (r *Post) GetPostList(c *gin.Context) { } // 处理返回值 - getPostListResponses := postResponse.GetPostListResponse(adminPosts) + getPostListResponses := dto.GetAdminPostListDto(adminPosts) responses.OkWithData(getPostListResponses, c) } diff --git a/api/controller/adminRole.go b/api/controller/adminRole.go index eb2f8f9..cc9a8d1 100644 --- a/api/controller/adminRole.go +++ b/api/controller/adminRole.go @@ -3,9 +3,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/roleResponse" "hospital-admin-api/api/service" "hospital-admin-api/global" "hospital-admin-api/utils" @@ -45,24 +45,7 @@ func (r *Role) GetRolePage(c *gin.Context) { } // 处理返回值 - getRolePageResponses := make([]roleResponse.GetRolePage, len(adminRole)) - - if len(adminRole) > 0 { - for i, v := range adminRole { - // 将原始结构体转换为新结构体 - getRolePageResponse := roleResponse.GetRolePage{ - RoleId: strconv.Itoa(int(v.RoleId)), - RoleName: v.RoleName, - RoleStatus: v.RoleStatus, - IsAdmin: v.IsAdmin, - CreatedAt: v.CreatedAt, - UpdatedAt: v.UpdatedAt, - } - - // 将转换后的结构体添加到新切片中 - getRolePageResponses[i] = getRolePageResponse - } - } + getRolePageResponses := dto.GetAdminRoleListDto(adminRole) result := make(map[string]interface{}) result["page"] = RoleRequest.GetRolePage.Page @@ -208,27 +191,10 @@ func (r *Role) GetRole(c *gin.Context) { } // 处理返回值 - // 转换int64为string - var menuIdsString []string - for _, menuId := range menuIds { - menuId := strconv.FormatInt(menuId, 10) - menuIdsString = append(menuIdsString, menuId) - } + GetRoleResponse := dto.GetAdminRoleDto(adminRole) - // 转换int64为string - RoleId := strconv.FormatInt(adminRole.RoleId, 10) - if err != nil { - responses.Fail(c) - return - } - - GetRoleResponse := &roleResponse.GetRole{ - MenuIds: menuIdsString, - RoleId: RoleId, - RoleName: adminRole.RoleName, - RoleStatus: adminRole.RoleStatus, - IsAdmin: adminRole.IsAdmin, - } + // 加载角色菜单id + GetRoleResponse.LoadRoleMenuIdsDto(menuIds) responses.OkWithData(GetRoleResponse, c) } @@ -344,7 +310,7 @@ func (r *Role) GetRoleList(c *gin.Context) { } // 处理返回值 - getRoleListResponses := roleResponse.GetRoleListResponse(adminRoles) + getRoleListResponses := dto.GetAdminRoleListDto(adminRoles) responses.OkWithData(getRoleListResponses, c) } diff --git a/api/controller/adminUser.go b/api/controller/adminUser.go index b6d60e7..25929ed 100644 --- a/api/controller/adminUser.go +++ b/api/controller/adminUser.go @@ -3,9 +3,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/adminUserResponse" "hospital-admin-api/api/service" "hospital-admin-api/global" "hospital-admin-api/utils" @@ -49,7 +49,7 @@ func (r *AdminUser) GetUserPage(c *gin.Context) { } // 处理返回值 - getUserPageResponses := adminUserResponse.GetUserPageResponse(adminUser) + getUserPageResponses := dto.GetAdminUserListDto(adminUser) result := make(map[string]interface{}) result["page"] = UserRequest.GetUserPage.Page @@ -120,9 +120,9 @@ func (r *AdminUser) GetUser(c *gin.Context) { } // 处理返回值 - getUserResponses := adminUserResponse.GetUserResponse(adminUser) + result := dto.GetAdminUserDto(adminUser) - responses.OkWithData(getUserResponses, c) + responses.OkWithData(result, c) } // DeleteUser 删除用户-批量 diff --git a/api/controller/area.go b/api/controller/area.go index 6da9387..78791c9 100644 --- a/api/controller/area.go +++ b/api/controller/area.go @@ -3,9 +3,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/areaResponse" "hospital-admin-api/global" "hospital-admin-api/utils" ) @@ -40,6 +40,6 @@ func (b *Area) GetAreaList(c *gin.Context) { } // 处理返回值 - r := areaResponse.GetAreaListResponse(area) + r := dto.GetAreaListDto(area) responses.OkWithData(r, c) } diff --git a/api/controller/bank.go b/api/controller/bank.go index 915b2dd..59ffc55 100644 --- a/api/controller/bank.go +++ b/api/controller/bank.go @@ -3,9 +3,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/basicBankResponse" "hospital-admin-api/global" "hospital-admin-api/utils" ) @@ -35,6 +35,6 @@ func (b *Bank) GetBankList(c *gin.Context) { } // 处理返回值 - getBasicBankListResponse := basicBankResponse.GetBasicBankListResponse(basicBank) + getBasicBankListResponse := dto.GetBasicBankListDto(basicBank) responses.OkWithData(getBasicBankListResponse, c) } diff --git a/api/controller/department.go b/api/controller/department.go index adb6408..2b07bf6 100644 --- a/api/controller/department.go +++ b/api/controller/department.go @@ -4,9 +4,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/hosDepCustomResponse" "hospital-admin-api/global" "hospital-admin-api/utils" ) @@ -36,6 +36,6 @@ func (b *Department) GetDepartmentCustomList(c *gin.Context) { } // 处理返回值 - getDepartmentListResponse := hosDepCustomResponse.GetHospitalDepartmentCustomListResponse(hospitalDepartmentCustom) + getDepartmentListResponse := dto.GetHospitalDepartmentCustomListDto(hospitalDepartmentCustom) responses.OkWithData(getDepartmentListResponse, c) } diff --git a/api/controller/diseaseClassExpertise.go b/api/controller/diseaseClassExpertise.go index a58a6d3..2143af5 100644 --- a/api/controller/diseaseClassExpertise.go +++ b/api/controller/diseaseClassExpertise.go @@ -4,9 +4,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/diseaseClassExpertiseResponse" "hospital-admin-api/global" "hospital-admin-api/utils" ) @@ -36,6 +36,6 @@ func (b *DiseaseClassExpertise) GetExpertiseList(c *gin.Context) { } // 处理返回值 - getExpertiseListResponse := diseaseClassExpertiseResponse.GetDiseaseClassExpertiseListResponse(diseaseClassExpertises) + getExpertiseListResponse := dto.GetDiseaseClassExpertiseListDto(diseaseClassExpertises) responses.OkWithData(getExpertiseListResponse, c) } diff --git a/api/controller/hospital.go b/api/controller/hospital.go index aec8abe..b33077d 100644 --- a/api/controller/hospital.go +++ b/api/controller/hospital.go @@ -4,9 +4,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/hospitalResponse" "hospital-admin-api/global" "hospital-admin-api/utils" ) @@ -35,6 +35,6 @@ func (b *Hospital) GetHospitalLimit(c *gin.Context) { } // 处理返回值 - getHospitalLimitResponse := hospitalResponse.GetHospitalLimitResponse(hospitals) + getHospitalLimitResponse := dto.GetHospitalListDto(hospitals) responses.OkWithData(getHospitalLimitResponse, c) } diff --git a/api/controller/orderInquiry.go b/api/controller/orderInquiry.go index e028284..2bc395d 100644 --- a/api/controller/orderInquiry.go +++ b/api/controller/orderInquiry.go @@ -3,9 +3,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/orderInquiryResponse" "hospital-admin-api/api/service" "hospital-admin-api/global" "hospital-admin-api/utils" @@ -44,7 +44,7 @@ func (r *OrderInquiry) GetOrderInquiryPage(c *gin.Context) { } // 处理返回值 - GetOrderInquiryPageResponses := orderInquiryResponse.GetOrderInquiryPageResponse(orderInquiry) + GetOrderInquiryPageResponses := dto.GetOrderInquiryListDto(orderInquiry) if err != nil { responses.FailWithMessage(err.Error(), c) return diff --git a/api/controller/orderPrescription.go b/api/controller/orderPrescription.go index 5cddb0a..ade6678 100644 --- a/api/controller/orderPrescription.go +++ b/api/controller/orderPrescription.go @@ -6,8 +6,10 @@ import ( "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" "hospital-admin-api/api/responses/orderPrescriptionResponse" + "hospital-admin-api/api/service" "hospital-admin-api/global" "hospital-admin-api/utils" + "strconv" ) type OrderPrescription struct{} @@ -52,28 +54,28 @@ func (r *OrderPrescription) GetOrderPrescriptionPage(c *gin.Context) { responses.OkWithData(result, c) } -// // GetOrderPrescription 处方详情 -// func (r *OrderPrescription) GetOrderPrescription(c *gin.Context) { -// id := c.Param("family_id") -// if id == "" { -// responses.FailWithMessage("缺少参数", c) -// return -// } -// -// // 将 id 转换为 int64 类型 -// familyId, err := strconv.ParseInt(id, 10, 64) -// if err != nil { -// responses.Fail(c) -// return -// } -// -// // 业务处理 -// patientFamilyService := service.PrescriptionService{} -// getPrescriptionResponse, err := patientFamilyService.GetPrescription(familyId) -// if err != nil { -// responses.FailWithMessage(err.Error(), c) -// return -// } -// -// responses.OkWithData(getPrescriptionResponse, c) -// } +// GetOrderPrescription 处方详情 +func (r *OrderPrescription) GetOrderPrescription(c *gin.Context) { + id := c.Param("order_prescription_id") + if id == "" { + responses.FailWithMessage("缺少参数", c) + return + } + + // 将 id 转换为 int64 类型 + orderPrescriptionId, err := strconv.ParseInt(id, 10, 64) + if err != nil { + responses.Fail(c) + return + } + + // 业务处理 + orderPrescriptionService := service.OrderPrescriptionService{} + getPrescriptionResponse, err := orderPrescriptionService.GetOrderPrescription(orderPrescriptionId) + if err != nil { + responses.FailWithMessage(err.Error(), c) + return + } + + responses.OkWithData(getPrescriptionResponse, c) +} diff --git a/api/controller/orderProduct.go b/api/controller/orderProduct.go index 88a9a8d..317689e 100644 --- a/api/controller/orderProduct.go +++ b/api/controller/orderProduct.go @@ -3,9 +3,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/orderProductResponse" "hospital-admin-api/api/service" "hospital-admin-api/global" "hospital-admin-api/utils" @@ -45,7 +45,7 @@ func (r *OrderProduct) GetOrderProductPage(c *gin.Context) { } // 处理返回值 - GetOrderProductPageResponses := orderProductResponse.GetOrderProductPageResponse(orderProduct) + GetOrderProductPageResponses := dto.GetOrderProductListDto(orderProduct) if err != nil { responses.FailWithMessage(err.Error(), c) return diff --git a/api/controller/patientFamily.go b/api/controller/patientFamily.go index aca1f21..d0799b7 100644 --- a/api/controller/patientFamily.go +++ b/api/controller/patientFamily.go @@ -3,9 +3,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/patientFamilyResponse" "hospital-admin-api/api/service" "hospital-admin-api/global" "hospital-admin-api/utils" @@ -44,7 +44,7 @@ func (r *PatientFamily) GetPatientFamilyPage(c *gin.Context) { } // 处理返回值 - GetPatientFamilyPage := patientFamilyResponse.GetPatientFamilyPageResponse(patientFamily) + GetPatientFamilyPage := dto.GetPatientFamilyListDto(patientFamily) result := make(map[string]interface{}) result["page"] = req.GetPatientFamilyPage.Page diff --git a/api/controller/userDoctor.go b/api/controller/userDoctor.go index ec678ef..1fe98ff 100644 --- a/api/controller/userDoctor.go +++ b/api/controller/userDoctor.go @@ -3,9 +3,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/userDoctorResponse" "hospital-admin-api/api/service" "hospital-admin-api/global" "hospital-admin-api/utils" @@ -45,7 +45,7 @@ func (r *UserDoctor) GetUserDoctorPage(c *gin.Context) { } // 处理返回值 - getUserDoctorPageResponses := userDoctorResponse.GetUserDoctorPageResponse(userDoctor) + getUserDoctorPageResponses := dto.GetUserDoctorListDto(userDoctor) result := make(map[string]interface{}) result["page"] = userDoctorRequest.GetUserDoctorPage.Page @@ -194,7 +194,7 @@ func (r *UserDoctor) GetUserDoctorPendingPage(c *gin.Context) { } // 处理返回值 - res := userDoctorResponse.GetUserDoctorPendingPageResponse(userDoctor) + res := dto.GetUserDoctorPendingListDto(userDoctor) result := make(map[string]interface{}) result["page"] = userDoctorRequest.GetUserDoctorPendingPage.Page @@ -299,7 +299,7 @@ func (r *UserDoctor) GetMultiPage(c *gin.Context) { } // 处理返回值 - res := userDoctorResponse.GetMultiPageResponse(userDoctor) + res := dto.GetUserDoctorListDto(userDoctor) result := make(map[string]interface{}) result["page"] = userDoctorRequest.GetMultiPage.Page diff --git a/api/controller/userPatient.go b/api/controller/userPatient.go index e514d9f..341d38f 100644 --- a/api/controller/userPatient.go +++ b/api/controller/userPatient.go @@ -3,9 +3,9 @@ package controller import ( "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" "hospital-admin-api/api/responses" - "hospital-admin-api/api/responses/userPatientResponse" "hospital-admin-api/api/service" "hospital-admin-api/global" "hospital-admin-api/utils" @@ -45,7 +45,7 @@ func (r *UserPatient) GetUserPatientPage(c *gin.Context) { } // 处理返回值 - getUserDoctorPageResponses := userPatientResponse.GetUserPatientPageResponse(userPatient) + getUserDoctorPageResponses := dto.GetUserPatientListDto(userPatient) result := make(map[string]interface{}) result["page"] = userPatientRequest.GetUserPatientPage.Page diff --git a/api/dao/orderPrescriptionProduct.go b/api/dao/orderPrescriptionProduct.go new file mode 100644 index 0000000..9d88e47 --- /dev/null +++ b/api/dao/orderPrescriptionProduct.go @@ -0,0 +1,89 @@ +package dao + +import ( + "gorm.io/gorm" + "gorm.io/gorm/clause" + "hospital-admin-api/api/model" + "hospital-admin-api/global" +) + +type OrderPrescriptionProductDao struct { +} + +// GetOrderPrescriptionProductById 获取处方关联药品数据-处方关联药品id +func (r *OrderPrescriptionProductDao) GetOrderPrescriptionProductById(PrescriptionProductId int64) (m *model.OrderPrescriptionProduct, err error) { + err = global.Db.First(&m, PrescriptionProductId).Error + if err != nil { + return nil, err + } + return m, nil +} + +func (r *OrderPrescriptionProductDao) GetOrderPrescriptionProductByOrderPrescriptionId(orderPrescriptionId int64) (m *model.OrderPrescriptionProduct, err error) { + err = global.Db.Where("order_prescription_id = ?", orderPrescriptionId).First(&m).Error + if err != nil { + return nil, err + } + return m, nil +} + +func (r *OrderPrescriptionProductDao) GetOrderPrescriptionProductListByOrderPrescriptionId(orderPrescriptionId int64) (m []*model.OrderPrescriptionProduct, err error) { + err = global.Db.Where("order_prescription_id = ?", orderPrescriptionId).Find(&m).Error + if err != nil { + return nil, err + } + return m, nil +} + +// GetOrderPrescriptionProductPreloadById 获取处方关联药品数据-加载全部关联-处方关联药品id +func (r *OrderPrescriptionProductDao) GetOrderPrescriptionProductPreloadById(PrescriptionProductId int64) (m *model.OrderPrescriptionProduct, err error) { + err = global.Db.Preload(clause.Associations).First(&m, PrescriptionProductId).Error + if err != nil { + return nil, err + } + return m, nil +} + +// DeleteOrderPrescriptionProduct 删除处方关联药品 +func (r *OrderPrescriptionProductDao) DeleteOrderPrescriptionProduct(tx *gorm.DB, maps interface{}) error { + err := tx.Where(maps).Delete(&model.OrderPrescriptionProduct{}).Error + if err != nil { + return err + } + return nil +} + +// EditOrderPrescriptionProduct 修改处方关联药品 +func (r *OrderPrescriptionProductDao) EditOrderPrescriptionProduct(tx *gorm.DB, maps interface{}, data interface{}) error { + err := tx.Model(&model.OrderPrescriptionProduct{}).Where(maps).Updates(data).Error + if err != nil { + return err + } + return nil +} + +// EditOrderPrescriptionProductByOrderPrescriptionId 修改处方关联药品-处方关联药品id +func (r *OrderPrescriptionProductDao) EditOrderPrescriptionProductByOrderPrescriptionId(tx *gorm.DB, PrescriptionProductId int64, data interface{}) error { + err := tx.Model(&model.OrderPrescriptionProduct{}).Where("prescription_product_id = ?", PrescriptionProductId).Updates(data).Error + if err != nil { + return err + } + return nil +} + +// GetOrderPrescriptionProductList 获取处方关联药品列表 +func (r *OrderPrescriptionProductDao) GetOrderPrescriptionProductList(maps interface{}) (m []*model.OrderPrescriptionProduct, err error) { + err = global.Db.Where(maps).Find(&m).Error + if err != nil { + return nil, err + } + return m, nil +} + +// AddOrderPrescriptionProduct 新增处方关联药品 +func (r *OrderPrescriptionProductDao) AddOrderPrescriptionProduct(tx *gorm.DB, model *model.OrderPrescriptionProduct) (*model.OrderPrescriptionProduct, error) { + if err := tx.Create(model).Error; err != nil { + return nil, err + } + return model, nil +} diff --git a/api/responses/adminResponse/admin.go b/api/dto/Admin.go similarity index 64% rename from api/responses/adminResponse/admin.go rename to api/dto/Admin.go index 8f58cd5..abe7eaf 100644 --- a/api/responses/adminResponse/admin.go +++ b/api/dto/Admin.go @@ -1,8 +1,6 @@ -package adminResponse +package dto -import ( - "hospital-admin-api/utils" -) +import "hospital-admin-api/utils" // Login 登陆 type Login struct { @@ -12,8 +10,8 @@ type Login struct { Token string `json:"token"` // 用户名 } -// GetFullAvatar 返回带有指定字符串的头像路径 -func (l *Login) GetFullAvatar() Login { +// GetLoginFullAvatar 返回带有指定字符串的头像路径 +func (l *Login) GetLoginFullAvatar() Login { l.Avatar = utils.AddOssDomain(l.Avatar) return Login{} } diff --git a/api/dto/AdminApi.go b/api/dto/AdminApi.go new file mode 100644 index 0000000..7611afd --- /dev/null +++ b/api/dto/AdminApi.go @@ -0,0 +1,52 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type AdminApiDto struct { + APIID string `json:"api_id"` // 主键id + APIName string `json:"api_name"` // api名称 + APIPath string `json:"api_path"` // 接口路径(全路径 id为:id) + APIMethod string `json:"api_method"` // 请求类型 + IsAuth int `json:"is_auth"` // 是否验证权限(0:否 1:是) + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetAdminApiDto(m *model.AdminAPI) *AdminApiDto { + return &AdminApiDto{ + APIID: fmt.Sprintf("%d", m.APIID), + APIName: m.APIName, + APIPath: m.APIPath, + APIMethod: m.APIMethod, + IsAuth: m.IsAuth, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetAdminApiListDto(m []*model.AdminAPI) []AdminApiDto { + // 处理返回值 + responses := make([]AdminApiDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := AdminApiDto{ + APIID: fmt.Sprintf("%d", v.APIID), + APIName: v.APIName, + APIPath: v.APIPath, + APIMethod: v.APIMethod, + IsAuth: v.IsAuth, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/AdminDept.go b/api/dto/AdminDept.go new file mode 100644 index 0000000..7edb934 --- /dev/null +++ b/api/dto/AdminDept.go @@ -0,0 +1,51 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +// AdminDeptDto 部门详情 +type AdminDeptDto struct { + DeptId string `json:"dept_id"` + ParentId string `json:"parent_id"` // 父菜单ID(0表示一级) + DeptName string `json:"dept_name"` // 部门名称 + DeptStatus int `json:"dept_status"` // 部门状态(1:正常 2:删除) + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 + Children []*AdminDeptDto `json:"children"` // 下级页面 +} + +func GetAdminDeptDto(m *model.AdminDept) *AdminDeptDto { + return &AdminDeptDto{ + DeptId: fmt.Sprintf("%d", m.DeptId), + ParentId: fmt.Sprintf("%d", m.ParentId), + DeptName: m.DeptName, + DeptStatus: m.DeptStatus, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetAdminDeptListDto(m []*model.AdminDept) []AdminDeptDto { + // 处理返回值 + responses := make([]AdminDeptDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := AdminDeptDto{ + DeptId: fmt.Sprintf("%d", v.DeptId), + ParentId: fmt.Sprintf("%d", v.ParentId), + DeptName: v.DeptName, + DeptStatus: v.DeptStatus, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/AdminMenu.go b/api/dto/AdminMenu.go new file mode 100644 index 0000000..f69c26f --- /dev/null +++ b/api/dto/AdminMenu.go @@ -0,0 +1,59 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type AdminMenuDto struct { + MenuId string `json:"menu_id"` + MenuName string `json:"menu_name"` // 菜单名称 + MenuTitle string `json:"menu_title"` // 菜单名称 + ParentId string `json:"parent_id"` // 父菜单ID(0表示一级) + MenuStatus int `json:"menu_status"` // 菜单状态(0:隐藏 1:正常)此优先级最高 + MenuType int `json:"menu_type"` // 菜单类型(1:模块 2:菜单 3:按钮) + Permission string `json:"permission"` // 标识 + OrderNum int `json:"order_num"` // 显示顺序 + Icon string `json:"icon"` // 图标地址 + Path string `json:"path"` // 页面地址(#表示当前页) + Component string `json:"component"` // 组件名称 + Api []*AdminMenuApiDto `json:"api"` // 接口数据 + Apis []string `json:"apis"` // 接口数据 + Children []*AdminMenuDto `json:"children"` // 下级页面 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetAdminMenuDto(m *model.AdminMenu) *AdminMenuDto { + return &AdminMenuDto{ + MenuId: fmt.Sprintf("%d", m.MenuId), + MenuName: m.MenuName, + MenuTitle: m.MenuTitle, + ParentId: fmt.Sprintf("%d", m.ParentId), + MenuStatus: m.MenuStatus, + MenuType: m.MenuType, + Permission: m.Permission, + OrderNum: m.OrderNum, + Icon: m.Icon, + Path: m.Path, + Component: m.Component, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +// LoadAdminMenuApi 加载菜单api +func (r *AdminMenuDto) LoadAdminMenuApi(m []*model.AdminMenuApi) *AdminMenuDto { + if len(m) > 0 { + r.Api = GetAdminMenuApiListDto(m) + + apis := make([]string, 0, len(r.Api)) + + for _, v := range r.Api { + apis = append(apis, v.ApiId) + } + + r.Apis = apis + } + return r +} diff --git a/api/dto/AdminMenuApiDto.go b/api/dto/AdminMenuApiDto.go new file mode 100644 index 0000000..3d99e27 --- /dev/null +++ b/api/dto/AdminMenuApiDto.go @@ -0,0 +1,37 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type AdminMenuApiDto struct { + ApiId string `json:"api_id"` // 接口id + ApiName string `json:"api_name"` // 接口名称 +} + +func GetAdminMenuApiDto(m *model.AdminMenuApi) *AdminMenuApiDto { + return &AdminMenuApiDto{ + ApiId: fmt.Sprintf("%d", m.ApiId), + ApiName: m.API.APIName, + } +} + +func GetAdminMenuApiListDto(m []*model.AdminMenuApi) []*AdminMenuApiDto { + // 处理返回值 + responses := make([]*AdminMenuApiDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := &AdminMenuApiDto{ + ApiId: fmt.Sprintf("%d", v.ApiId), + ApiName: v.API.APIName, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/AdminPost.go b/api/dto/AdminPost.go new file mode 100644 index 0000000..abd358f --- /dev/null +++ b/api/dto/AdminPost.go @@ -0,0 +1,46 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type AdminPostDto struct { + PostId string `json:"post_id"` // 主键id + PostName string `json:"post_name"` // 岗位名称 + PostStatus int `json:"post_status"` // 岗位状态(1:正常 2:删除) + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetAdminPostDto(m *model.AdminPost) *AdminPostDto { + return &AdminPostDto{ + PostId: fmt.Sprintf("%d", m.PostId), + PostName: m.PostName, + PostStatus: m.PostStatus, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetAdminPostListDto(m []*model.AdminPost) []AdminPostDto { + // 处理返回值 + responses := make([]AdminPostDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := AdminPostDto{ + PostId: fmt.Sprintf("%d", v.PostId), + PostName: v.PostName, + PostStatus: v.PostStatus, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/AdminRole.go b/api/dto/AdminRole.go new file mode 100644 index 0000000..dba75c0 --- /dev/null +++ b/api/dto/AdminRole.go @@ -0,0 +1,64 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" + "strconv" +) + +// AdminRoleDto 角色详情 +type AdminRoleDto struct { + RoleId string `json:"role_id"` // 角色id + RoleName string `json:"role_name"` // 角色名称 + RoleStatus int `json:"role_status"` // 角色状态(1:正常 2:禁用) + IsAdmin int `json:"is_admin"` // 是否管理员(0:否 1:是) + MenuIds []string `json:"menu_ids"` // 菜单id + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetAdminRoleDto(m *model.AdminRole) *AdminRoleDto { + return &AdminRoleDto{ + RoleId: fmt.Sprintf("%d", m.RoleId), + RoleName: m.RoleName, + RoleStatus: m.RoleStatus, + IsAdmin: m.IsAdmin, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetAdminRoleListDto(m []*model.AdminRole) []AdminRoleDto { + // 处理返回值 + responses := make([]AdminRoleDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := AdminRoleDto{ + RoleId: fmt.Sprintf("%d", v.RoleId), + RoleName: v.RoleName, + RoleStatus: v.RoleStatus, + IsAdmin: v.IsAdmin, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} + +// LoadRoleMenuIdsDto 加载角色菜单id +func (m *AdminRoleDto) LoadRoleMenuIdsDto(menuIds []int64) *AdminRoleDto { + var menuIdsString []string + for _, menuId := range menuIds { + menuId := strconv.FormatInt(menuId, 10) + menuIdsString = append(menuIdsString, menuId) + } + + m.MenuIds = menuIdsString + return m +} diff --git a/api/dto/AdminRoleMenu.go b/api/dto/AdminRoleMenu.go new file mode 100644 index 0000000..3b23f99 --- /dev/null +++ b/api/dto/AdminRoleMenu.go @@ -0,0 +1,16 @@ +package dto + +type AdminRoleMenuDto struct { + MenuId string `json:"menu_id"` // 主键id + MenuName string `json:"menu_name"` // 菜单名称 + MenuTitle string `json:"menu_title"` // 菜单名称 + ParentId string `json:"parent_id"` // 父菜单ID(0表示一级) + MenuStatus int `json:"menu_status"` // 菜单状态(0:隐藏 1:正常)此优先级最高 + MenuType int `json:"menu_type"` // 菜单类型(1:模块 2:菜单 3:按钮) + Permission string `json:"permission"` // 标识 + OrderNum int `json:"order_num"` // 显示顺序 + Icon string `json:"icon"` // 图标地址 + Path string `json:"path"` // 页面地址(#表示当前页) + Component string `json:"component"` // 组件名称 + Children []*AdminRoleMenuDto `json:"children"` // 下级页面 +} diff --git a/api/dto/AdminUser.go b/api/dto/AdminUser.go new file mode 100644 index 0000000..421787e --- /dev/null +++ b/api/dto/AdminUser.go @@ -0,0 +1,135 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" + "hospital-admin-api/utils" + "strconv" +) + +type AdminUserDto struct { + UserID string `json:"user_id"` // 主键id + Access string `json:"access"` // 账号 + Status int `json:"status"` // 状态(1:正常 2:审核中 3:审核失败) + IsDeleted int `json:"is_deleted"` // 是否被删除(0:否 1:是) + IsDisabled int `json:"is_disabled"` // 是否被禁用(0:否 1:是) + NickName string `json:"nick_name"` // 昵称 + Phone string `json:"phone"` // 手机号 + Avatar string `json:"avatar"` // 头像 + Sex int `json:"sex"` // 性别(1:男 2:女) + Email string `json:"email"` // 邮箱 + RoleID string `json:"role_id"` // 角色id + DeptID string `json:"dept_id"` // 部门id + PostID string `json:"post_id"` // 岗位id + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 + AdminRole *AdminRoleDto `json:"role"` // 角色 + AdminDept *AdminDeptDto `json:"dept"` // 部门 + AdminPost *AdminPostDto `json:"post"` // 岗位 +} + +func GetAdminUserDto(m *model.AdminUser) *AdminUserDto { + return &AdminUserDto{ + UserID: fmt.Sprintf("%d", m.UserID), + Access: m.Access, + Status: m.Status, + IsDeleted: m.IsDeleted, + IsDisabled: m.IsDisabled, + NickName: m.NickName, + Phone: m.Phone, + Avatar: utils.AddOssDomain(m.Avatar), + Sex: m.Sex, + Email: m.Email, + RoleID: fmt.Sprintf("%d", m.RoleID), + DeptID: fmt.Sprintf("%d", m.DeptID), + PostID: fmt.Sprintf("%d", m.PostID), + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetAdminUserListDto(m []*model.AdminUser) []*AdminUserDto { + // 处理返回值 + responses := make([]*AdminUserDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := &AdminUserDto{ + UserID: fmt.Sprintf("%d", v.UserID), + Access: v.Access, + Status: v.Status, + IsDeleted: v.IsDeleted, + IsDisabled: v.IsDisabled, + NickName: v.NickName, + Phone: v.Phone, + Avatar: utils.AddOssDomain(v.Avatar), + Sex: v.Sex, + Email: v.Email, + RoleID: fmt.Sprintf("%d", v.RoleID), + DeptID: fmt.Sprintf("%d", v.DeptID), + PostID: fmt.Sprintf("%d", v.PostID), + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 角色 + if v.Role != nil { + response = response.LoadAdminRole(v.Role) + } + + // 部门 + if v.Dept != nil { + response = response.LoadAdminDept(v.Dept) + } + + // 岗位 + if v.Post != nil { + response = response.LoadAdminPost(v.Post) + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} + +// LoadAdminRole 角色 +func (r *AdminUserDto) LoadAdminRole(m *model.AdminRole) *AdminUserDto { + if m != nil { + adminRoleDto := &AdminRoleDto{ + RoleId: strconv.FormatInt(m.RoleId, 10), + RoleName: m.RoleName, + } + + r.AdminRole = adminRoleDto + } + return r +} + +// LoadAdminDept 部门 +func (r *AdminUserDto) LoadAdminDept(m *model.AdminDept) *AdminUserDto { + if m != nil { + adminDeptDto := &AdminDeptDto{ + DeptId: fmt.Sprintf("%d", m.DeptId), // 部门id + DeptName: m.DeptName, // 部门名称 + } + + r.AdminDept = adminDeptDto + } + return r +} + +// LoadAdminPost 岗位 +func (r *AdminUserDto) LoadAdminPost(m *model.AdminPost) *AdminUserDto { + if m != nil { + adminPostDto := &AdminPostDto{ + PostId: fmt.Sprintf("%d", m.PostId), + PostName: m.PostName, + } + + r.AdminPost = adminPostDto + } + return r +} diff --git a/api/dto/Area.go b/api/dto/Area.go new file mode 100644 index 0000000..d2a3a14 --- /dev/null +++ b/api/dto/Area.go @@ -0,0 +1,46 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type AreaDto struct { + AreaId string `json:"area_id"` // 地区编号 + AreaName string `json:"area_name"` // 名称 + ParentId string `json:"parent_id"` // 上级编号 + Zip string `json:"zip"` // 邮编 + AreaType int `json:"area_type"` // 类型(1:国家,2:省,3:市,4:区县) +} + +func GetAreaDto(m *model.Area) *AreaDto { + return &AreaDto{ + AreaId: fmt.Sprintf("%d", m.AreaId), + AreaName: m.AreaName, + ParentId: fmt.Sprintf("%d", m.ParentId), + Zip: m.Zip, + AreaType: m.AreaType, + } +} + +func GetAreaListDto(m []*model.Area) []AreaDto { + // 处理返回值 + responses := make([]AreaDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := AreaDto{ + AreaId: fmt.Sprintf("%d", v.AreaId), + AreaName: v.AreaName, + ParentId: fmt.Sprintf("%d", v.ParentId), + Zip: v.Zip, + AreaType: v.AreaType, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/BasicBank.go b/api/dto/BasicBank.go new file mode 100644 index 0000000..7877e77 --- /dev/null +++ b/api/dto/BasicBank.go @@ -0,0 +1,53 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" + "hospital-admin-api/utils" +) + +type BasicBankDto struct { + BankId string `json:"bank_id"` // 主键 + BankCode string `json:"bank_code"` // 银行编码 + BankName string `json:"bank_name"` // 银行名称 + BankIconPath string `json:"bank_icon_path"` // 银行图标地址 + BankImgPath string `json:"bank_img_path"` // 银行图片地址 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetBasicBankDto(m *model.BasicBank) *BasicBankDto { + return &BasicBankDto{ + BankId: fmt.Sprintf("%d", m.BankId), + BankCode: m.BankCode, + BankName: m.BankName, + BankIconPath: utils.AddOssDomain(m.BankIconPath), + BankImgPath: utils.AddOssDomain(m.BankImgPath), + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetBasicBankListDto(m []*model.BasicBank) []BasicBankDto { + // 处理返回值 + responses := make([]BasicBankDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := BasicBankDto{ + BankId: fmt.Sprintf("%d", v.BankId), + BankCode: v.BankCode, + BankName: v.BankName, + BankIconPath: utils.AddOssDomain(v.BankIconPath), + BankImgPath: utils.AddOssDomain(v.BankImgPath), + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/DiseaseClassExpertise.go b/api/dto/DiseaseClassExpertise.go new file mode 100644 index 0000000..0e9a7c1 --- /dev/null +++ b/api/dto/DiseaseClassExpertise.go @@ -0,0 +1,46 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type DiseaseClassExpertiseDto struct { + ExpertiseId string `json:"expertise_id"` // 主键 + ExpertiseName string `json:"expertise_name"` // 专长名称 + ExpertiseSort int `json:"expertise_sort"` // 排序(越大排序越靠前) + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetDiseaseClassExpertiseDto(m *model.DiseaseClassExpertise) *DiseaseClassExpertiseDto { + return &DiseaseClassExpertiseDto{ + ExpertiseId: fmt.Sprintf("%d", m.ExpertiseId), + ExpertiseName: m.ExpertiseName, + ExpertiseSort: m.ExpertiseSort, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetDiseaseClassExpertiseListDto(m []*model.DiseaseClassExpertise) []DiseaseClassExpertiseDto { + // 处理返回值 + responses := make([]DiseaseClassExpertiseDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := DiseaseClassExpertiseDto{ + ExpertiseId: fmt.Sprintf("%d", v.ExpertiseId), + ExpertiseName: v.ExpertiseName, + ExpertiseSort: v.ExpertiseSort, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/DoctorBankCard.go b/api/dto/DoctorBankCard.go new file mode 100644 index 0000000..60ab35b --- /dev/null +++ b/api/dto/DoctorBankCard.go @@ -0,0 +1,61 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type DoctorBankCardDto struct { + BankCardId string `json:"bank_card_id"` // 主键id + DoctorId string `json:"doctor_id"` // 医生id + BankId string `json:"bank_id"` // 银行id + BankCardCodeMask string `json:"bank_card_code_mask"` // 银行卡号(掩码) + ProvinceId int `json:"province_id"` // 省份id + Province string `json:"province"` // 省份 + CityId int `json:"city_id"` // 城市id + City string `json:"city"` // 城市 + CountyId int `json:"county_id"` // 区县id + County string `json:"county"` // 区县 +} + +func GetDoctorBankCardDto(m *model.DoctorBankCard) *DoctorBankCardDto { + return &DoctorBankCardDto{ + BankCardId: fmt.Sprintf("%d", m.BankCardId), + DoctorId: fmt.Sprintf("%d", m.DoctorId), + BankId: fmt.Sprintf("%d", m.BankId), + BankCardCodeMask: m.BankCardCodeMask, + ProvinceId: m.ProvinceId, + Province: m.Province, + CityId: m.CityId, + City: m.City, + CountyId: m.CountyId, + County: m.County, + } +} + +func GetDoctorBankCardListDto(m []*model.DoctorBankCard) []DoctorBankCardDto { + // 处理返回值 + responses := make([]DoctorBankCardDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := DoctorBankCardDto{ + BankCardId: fmt.Sprintf("%d", v.BankCardId), + DoctorId: fmt.Sprintf("%d", v.DoctorId), + BankId: fmt.Sprintf("%d", v.BankId), + BankCardCodeMask: v.BankCardCodeMask, + ProvinceId: v.ProvinceId, + Province: v.Province, + CityId: v.CityId, + City: v.City, + CountyId: v.CountyId, + County: v.County, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/DoctorExpertise.go b/api/dto/DoctorExpertise.go new file mode 100644 index 0000000..0bae3cd --- /dev/null +++ b/api/dto/DoctorExpertise.go @@ -0,0 +1,46 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type DoctorExpertiseDto struct { + DoctorId string `json:"doctor_id"` // 医生id + ExpertiseId string `json:"expertise_id"` // 专长id + ExpertiseName string `json:"expertise_name"` // 专长名称 +} + +func GetDoctorExpertiseDto(m *model.DoctorExpertise) *DoctorExpertiseDto { + return &DoctorExpertiseDto{ + DoctorId: fmt.Sprintf("%d", m.DoctorId), + ExpertiseId: fmt.Sprintf("%d", m.ExpertiseId), + } +} + +func GetDoctorExpertiseListDto(m []*model.DoctorExpertise) []DoctorExpertiseDto { + // 处理返回值 + responses := make([]DoctorExpertiseDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := DoctorExpertiseDto{ + DoctorId: fmt.Sprintf("%d", v.DoctorId), + ExpertiseId: fmt.Sprintf("%d", v.ExpertiseId), + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} + +// LoadExpertiseName 加载专长名称 +func (r *DoctorExpertiseDto) LoadExpertiseName(m *model.DiseaseClassExpertise) *DoctorExpertiseDto { + if m != nil { + r.ExpertiseName = m.ExpertiseName + } + return r +} diff --git a/api/dto/DoctorIdenFail.go b/api/dto/DoctorIdenFail.go new file mode 100644 index 0000000..dc0acc9 --- /dev/null +++ b/api/dto/DoctorIdenFail.go @@ -0,0 +1,47 @@ +package dto + +import ( + "hospital-admin-api/api/model" +) + +type IdenAuthFailReasonDto struct { + AvatarReason string `json:"avatar_reason"` // 头像失败原因 + DepartmentCustomMobileReason string `json:"department_custom_mobile_reason"` // 科室电话失败原因 + DepartmentCustomNameReason string `json:"department_custom_name_reason"` // 科室名称失败原因 + BriefIntroductionReason string `json:"brief_introduction_reason"` // 医生简介失败原因 + BeGoodAtReason string `json:"be_good_at_reason"` // 医生简介失败原因 + LicenseCertReason string `json:"license_cert_reason"` // 医师执业证失败原因 + QualificationCertReason string `json:"qualification_cert_reason"` // 医师资格证失败原因 + WorkCertReason string `json:"work_cert_reason"` // 医师工作证失败原因 +} + +func GetIdenAuthFailReasonDto(m []*model.DoctorIdenFail) *IdenAuthFailReasonDto { + var idenAuthFailReason IdenAuthFailReasonDto + + if len(m) > 0 { + for _, v := range m { + switch v.FieldName { + case "avatar": + idenAuthFailReason.AvatarReason = v.FailReason + case "department_custom_mobile": + idenAuthFailReason.DepartmentCustomMobileReason = v.FailReason + case "department_custom_name": + idenAuthFailReason.DepartmentCustomNameReason = v.FailReason + case "brief_introduction": + idenAuthFailReason.BriefIntroductionReason = v.FailReason + case "be_good_at": + idenAuthFailReason.BeGoodAtReason = v.FailReason + case "license_cert": + idenAuthFailReason.LicenseCertReason = v.FailReason + case "qualification_cert": + idenAuthFailReason.QualificationCertReason = v.FailReason + case "work_cert": + idenAuthFailReason.WorkCertReason = v.FailReason + default: + + } + } + } + + return &idenAuthFailReason +} diff --git a/api/responses/hospitalResponse/hospital.go b/api/dto/Hospital.go similarity index 60% rename from api/responses/hospitalResponse/hospital.go rename to api/dto/Hospital.go index 874e279..07a7930 100644 --- a/api/responses/hospitalResponse/hospital.go +++ b/api/dto/Hospital.go @@ -1,11 +1,11 @@ -package hospitalResponse +package dto import ( + "fmt" "hospital-admin-api/api/model" - "strconv" ) -type Hospital struct { +type HospitalDto struct { HospitalID string `json:"hospital_id"` // 主键id HospitalName string `json:"hospital_name"` // 医院名称 HospitalStatus int `json:"hospital_status"` // 状态(0:禁用 1:正常 2:删除) @@ -26,40 +26,37 @@ type Hospital struct { UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 } -// HospitalResponse 医院 -func HospitalResponse(hospital *model.Hospital) *Hospital { - return &Hospital{ - HospitalID: strconv.FormatInt(hospital.HospitalID, 10), - HospitalName: hospital.HospitalName, - HospitalStatus: hospital.HospitalStatus, - HospitalLevelName: hospital.HospitalLevelName, - PostCode: hospital.PostCode, - Telephone: hospital.HospitalName, - ProvinceID: hospital.ProvinceId, - Province: hospital.Province, - CityID: hospital.CityId, - City: hospital.City, - CountyID: hospital.CountyId, - County: hospital.County, - Address: hospital.Address, - Latitude: hospital.Lat, - Longitude: hospital.HospitalName, - Description: hospital.Desc, - CreatedAt: hospital.CreatedAt, - UpdatedAt: hospital.UpdatedAt, +func GetHospitalDto(m *model.Hospital) *HospitalDto { + return &HospitalDto{ + HospitalID: fmt.Sprintf("%d", m.HospitalID), + HospitalName: m.HospitalName, + HospitalStatus: m.HospitalStatus, + HospitalLevelName: m.HospitalLevelName, + PostCode: m.PostCode, + Telephone: m.HospitalName, + ProvinceID: m.ProvinceId, + Province: m.Province, + CityID: m.CityId, + City: m.City, + CountyID: m.CountyId, + County: m.County, + Address: m.Address, + Latitude: m.Lat, + Longitude: m.HospitalName, + Description: m.Desc, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, } } -// GetHospitalLimitResponse 自定义列表 -func GetHospitalLimitResponse(hospitals []*model.Hospital) []Hospital { +func GetHospitalListDto(m []*model.Hospital) []HospitalDto { // 处理返回值 - getHospitalLimitResponses := make([]Hospital, len(hospitals)) + responses := make([]HospitalDto, len(m)) - if len(hospitals) > 0 { - for i, v := range hospitals { - // 将原始结构体转换为新结构体 - getHospitalLimitResponse := Hospital{ - HospitalID: strconv.FormatInt(v.HospitalID, 10), + if len(m) > 0 { + for i, v := range m { + response := HospitalDto{ + HospitalID: fmt.Sprintf("%d", v.HospitalID), HospitalName: v.HospitalName, HospitalStatus: v.HospitalStatus, HospitalLevelName: v.HospitalLevelName, @@ -80,9 +77,9 @@ func GetHospitalLimitResponse(hospitals []*model.Hospital) []Hospital { } // 将转换后的结构体添加到新切片中 - getHospitalLimitResponses[i] = getHospitalLimitResponse + responses[i] = response } } - return getHospitalLimitResponses + return responses } diff --git a/api/dto/HospitalDepartmentCustom.go b/api/dto/HospitalDepartmentCustom.go new file mode 100644 index 0000000..4da8f54 --- /dev/null +++ b/api/dto/HospitalDepartmentCustom.go @@ -0,0 +1,39 @@ +package dto + +import ( + "hospital-admin-api/api/model" + "strconv" +) + +type HospitalDepartmentCustomDto struct { + DepartmentCustomId string `json:"department_custom_id"` // 主键 + DepartmentId string `json:"department_id"` // 医院科室-标准id + DepartmentCustomName string `json:"department_custom_name"` // 科室名称-自定义 + DepartmentName string `json:"department_name"` // 科室名称-标准 + DepartmentCode string `json:"department_code"` // 科室编码-标准 + DepartmentStatus int `json:"department_status"` // 状态(1:正常 2:删除) +} + +func GetHospitalDepartmentCustomListDto(m []*model.HospitalDepartmentCustom) []HospitalDepartmentCustomDto { + // 处理返回值 + responses := make([]HospitalDepartmentCustomDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + // 将原始结构体转换为新结构体 + response := HospitalDepartmentCustomDto{ + DepartmentCustomId: strconv.FormatInt(v.DepartmentCustomId, 10), + DepartmentId: strconv.FormatInt(v.DepartmentId, 10), + DepartmentCustomName: v.DepartmentCustomName, + DepartmentName: v.DepartmentName, + DepartmentCode: v.DepartmentCode, + DepartmentStatus: v.DepartmentStatus, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/OrderEvaluation.go b/api/dto/OrderEvaluation.go new file mode 100644 index 0000000..e2bed4b --- /dev/null +++ b/api/dto/OrderEvaluation.go @@ -0,0 +1,70 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type OrderEvaluationDto struct { + EvaluationId string `json:"evaluation_id"` // 主键id + DoctorId string `json:"doctor_id"` // 医生id;NOT NULL + PatientId string `json:"patient_id"` // 患者id;NOT NULL + OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id;NOT NULL + NameMask string `json:"name_mask"` // 患者姓名(掩码) + ReplyQuality float64 `json:"reply_quality"` // 回复质量(百分制) + ServiceAttitude float64 `json:"service_attitude"` // 服务态度(百分制) + ReplyProgress float64 `json:"reply_progress"` // 回复速度(百分制) + AvgScore float64 `json:"avg_score"` // 平均得分(百分制,回复质量占4、服务态度占3、回复速度占3,计算公式:每个得分 * 占比 相加) + Type int `json:"type"` // 类型(1:默认评价 2:主动评价) + Content string `json:"content"` // 评价内容 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetOrderEvaluationDto(m *model.OrderEvaluation) *OrderEvaluationDto { + return &OrderEvaluationDto{ + EvaluationId: fmt.Sprintf("%d", m.EvaluationId), + DoctorId: fmt.Sprintf("%d", m.DoctorId), + PatientId: fmt.Sprintf("%d", m.PatientId), + OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId), + NameMask: m.NameMask, + ReplyQuality: m.ReplyQuality, + ServiceAttitude: m.ServiceAttitude, + ReplyProgress: m.ReplyProgress, + AvgScore: m.AvgScore, + Type: m.Type, + Content: m.Content, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetOrderEvaluationListDto(m []*model.OrderEvaluation) []OrderEvaluationDto { + // 处理返回值 + responses := make([]OrderEvaluationDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := OrderEvaluationDto{ + EvaluationId: fmt.Sprintf("%d", v.EvaluationId), + DoctorId: fmt.Sprintf("%d", v.DoctorId), + PatientId: fmt.Sprintf("%d", v.PatientId), + OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId), + NameMask: v.NameMask, + ReplyQuality: v.ReplyQuality, + ServiceAttitude: v.ServiceAttitude, + ReplyProgress: v.ReplyProgress, + AvgScore: v.AvgScore, + Type: v.Type, + Content: v.Content, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/OrderInquiry.go b/api/dto/OrderInquiry.go new file mode 100644 index 0000000..67b2ab2 --- /dev/null +++ b/api/dto/OrderInquiry.go @@ -0,0 +1,199 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type OrderInquiryDto struct { + OrderInquiryId string `json:"order_inquiry_id"` // 主键id + UserId string `json:"user_id"` // 用户id-患者 + PatientId string `json:"patient_id"` // 患者id + DoctorId string `json:"doctor_id"` // 医生id(未分配时为null) + FamilyId string `json:"family_id"` // 家庭成员id(就诊用户) + InquiryType int `json:"inquiry_type"` // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测) + InquiryMode int `json:"inquiry_mode"` // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员) + InquiryStatus int `json:"inquiry_status"` // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消) + IsDelete int `json:"is_delete"` // 删除状态(0:否 1:是) + InquiryRefundStatus int `json:"inquiry_refund_status"` // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常) + InquiryPayChannel int `json:"inquiry_pay_channel"` // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付) + InquiryPayStatus int `json:"inquiry_pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) + InquiryNo string `json:"inquiry_no"` // 系统订单编号 + EscrowTradeNo string `json:"escrow_trade_no"` // 第三方支付流水号 + AmountTotal float64 `json:"amount_total"` // 订单金额 + CouponAmountTotal float64 `json:"coupon_amount_total"` // 优惠卷总金额 + PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额 + PayTime model.LocalTime `json:"pay_time"` // 支付时间 + ReceptionTime model.LocalTime `json:"reception_time"` // 接诊时间(已接诊) + CompleteTime model.LocalTime `json:"complete_time"` // 订单完成时间(问诊完成时间) + FinishTime model.LocalTime `json:"finish_time"` // 订单结束时间 + StatisticsStatus int `json:"statistics_status"` // 订单统计状态(0:未统计 1:已统计 2:统计失败) + StatisticsTime model.LocalTime `json:"statistics_time"` // 订单统计时间 + IsWithdrawal int `json:"is_withdrawal"` // 是否提现(0:否 1:是 2:提现中) + WithdrawalTime model.LocalTime `json:"withdrawal_time"` // 提现时间 + CancelTime model.LocalTime `json:"cancel_time"` // 订单取消时间 + CancelReason int `json:"cancel_reason"` // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时) + CancelRemarks string `json:"cancel_remarks"` // 取消订单备注(自动添加) + PatientName string `json:"patient_name"` // 患者姓名-就诊人 + PatientNameMask string `json:"patient_name_mask"` // 患者姓名-就诊人(掩码) + PatientSex int `json:"patient_sex"` // 患者性别-就诊人(0:未知 1:男 2:女) + PatientAge int `json:"patient_age"` // 患者年龄-就诊人 + PatientMobile string `json:"patient_mobile"` // 患者电话 + DoctorName string `json:"doctor_name"` // 医生姓名 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 + OrderInquiryCoupon *OrderInquiryCouponDto `json:"order_inquiry_coupon"` // 订单优惠卷 + OrderInquiryCase *OrderInquiryCaseDto `json:"order_inquiry_case"` // 问诊病例 + OrderInquiryRefund *OrderInquiryRefundDto `json:"order_inquiry_refund"` // 退款数据 + OrderEvaluation *OrderEvaluationDto `json:"order_evaluation"` // 订单评价 + UserDoctor *UserDoctorDto `json:"user_doctor"` // 医生数据 +} + +func GetOrderInquiryDto(m *model.OrderInquiry) *OrderInquiryDto { + var doctorId string + if m.DoctorId != 0 { + doctorId = fmt.Sprintf("%v", m.DoctorId) + } + + return &OrderInquiryDto{ + OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId), + UserId: fmt.Sprintf("%d", m.UserId), + DoctorId: doctorId, + PatientId: fmt.Sprintf("%d", m.PatientId), + FamilyId: fmt.Sprintf("%d", m.FamilyId), + InquiryType: m.InquiryType, + InquiryMode: m.InquiryMode, + InquiryStatus: m.InquiryStatus, + IsDelete: m.IsDelete, + InquiryRefundStatus: m.InquiryRefundStatus, + InquiryPayChannel: m.InquiryPayChannel, + InquiryPayStatus: m.InquiryPayStatus, + InquiryNo: m.InquiryNo, + EscrowTradeNo: m.EscrowTradeNo, + AmountTotal: m.AmountTotal, + CouponAmountTotal: m.CouponAmountTotal, + PaymentAmountTotal: m.PaymentAmountTotal, + PayTime: m.PayTime, + ReceptionTime: m.ReceptionTime, + CompleteTime: m.CompleteTime, + FinishTime: m.FinishTime, + StatisticsStatus: m.StatisticsStatus, + StatisticsTime: m.StatisticsTime, + IsWithdrawal: m.IsWithdrawal, + WithdrawalTime: m.WithdrawalTime, + CancelTime: m.CancelTime, + CancelReason: m.CancelReason, + CancelRemarks: m.CancelRemarks, + PatientName: m.PatientName, + PatientNameMask: m.PatientNameMask, + PatientSex: m.PatientSex, + PatientAge: m.PatientAge, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetOrderInquiryListDto(m []*model.OrderInquiry) []*OrderInquiryDto { + // 处理返回值 + responses := make([]*OrderInquiryDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := &OrderInquiryDto{ + OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId), + UserId: fmt.Sprintf("%d", v.UserId), + PatientId: fmt.Sprintf("%d", v.PatientId), + DoctorId: fmt.Sprintf("%d", v.DoctorId), + FamilyId: fmt.Sprintf("%d", v.FamilyId), + InquiryType: v.InquiryType, + InquiryMode: v.InquiryMode, + InquiryStatus: v.InquiryStatus, + IsDelete: v.IsDelete, + InquiryRefundStatus: v.InquiryRefundStatus, + InquiryPayChannel: v.InquiryPayChannel, + InquiryPayStatus: v.InquiryPayStatus, + InquiryNo: v.InquiryNo, + EscrowTradeNo: v.EscrowTradeNo, + AmountTotal: v.AmountTotal, + CouponAmountTotal: v.CouponAmountTotal, + PaymentAmountTotal: v.PaymentAmountTotal, + PayTime: v.PayTime, + ReceptionTime: v.ReceptionTime, + CompleteTime: v.CompleteTime, + FinishTime: v.FinishTime, + StatisticsStatus: v.StatisticsStatus, + StatisticsTime: v.StatisticsTime, + IsWithdrawal: v.IsWithdrawal, + WithdrawalTime: v.WithdrawalTime, + CancelTime: v.CancelTime, + CancelReason: v.CancelReason, + CancelRemarks: v.CancelRemarks, + PatientName: v.PatientName, + PatientNameMask: v.PatientNameMask, + PatientSex: v.PatientSex, + PatientAge: v.PatientAge, + PatientMobile: v.User.Mobile, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 加载医生名称 + if v.UserDoctor != nil { + response = response.LoadDoctorName(v.UserDoctor) + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} + +// LoadDoctorName 加载医生名称 +func (r *OrderInquiryDto) LoadDoctorName(m *model.UserDoctor) *OrderInquiryDto { + if m != nil { + r.DoctorName = m.UserName + } + return r +} + +// LoadOrderInquiryRefund 加载订单退款数据 +func (r *OrderInquiryDto) LoadOrderInquiryRefund(m *model.OrderInquiryRefund) *OrderInquiryDto { + if m != nil { + d := GetOrderInquiryRefundBankDto(m) + + r.OrderInquiryRefund = d + } + return r +} + +// LoadOrderInquiryCoupon 加载问诊订单优惠卷 +func (r *OrderInquiryDto) LoadOrderInquiryCoupon(m *model.OrderInquiryCoupon) *OrderInquiryDto { + if m != nil { + d := GetOrderInquiryCouponDto(m) + + r.OrderInquiryCoupon = d + } + return r +} + +// LoadOrderInquiryCase 加载问诊病例 +func (r *OrderInquiryDto) LoadOrderInquiryCase(m *model.OrderInquiryCase) *OrderInquiryDto { + if m != nil { + d := GetOrderInquiryCaseDto(m) + + r.OrderInquiryCase = d + } + return r +} + +// LoadOrderEvaluation 加载订单评价 +func (r *OrderInquiryDto) LoadOrderEvaluation(m *model.OrderEvaluation) *OrderInquiryDto { + if m != nil { + d := GetOrderEvaluationDto(m) + + r.OrderEvaluation = d + } + return r +} diff --git a/api/dto/OrderInquiryCase.go b/api/dto/OrderInquiryCase.go new file mode 100644 index 0000000..4f80f58 --- /dev/null +++ b/api/dto/OrderInquiryCase.go @@ -0,0 +1,161 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/dao" + "hospital-admin-api/api/model" + "hospital-admin-api/utils" + "strings" +) + +type OrderInquiryCaseDto struct { + InquiryCaseId string `json:"inquiry_case_id"` // 主键id + UserId string `json:"user_id"` // 用户id + PatientId string `json:"patient_id"` // 患者id + OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id;NOT NULL + FamilyId string `json:"family_id"` // 家庭成员id + Relation *int `json:"relation"` // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他) + Status *int `json:"status"` // 状态(1:正常 2:删除) + Name string `json:"name"` // 患者名称 + Sex *int `json:"sex"` // 患者性别(0:未知 1:男 2:女) + Age *int `json:"age"` // 患者年龄 + Height string `json:"height"` // 身高(cm) + Weight string `json:"weight"` // 体重(kg) + DiseaseClassId string `json:"disease_class_id"` // 疾病分类id-系统 + DiseaseClassName string `json:"disease_class_name"` // 疾病名称-系统 + DiagnosisDate model.LocalTime `json:"diagnosis_date"` // 确诊日期 + DiseaseDesc string `json:"disease_desc"` // 病情描述(主诉) + DiagnoseImages []*string `json:"diagnose_images"` // 复诊凭证(多个使用逗号分隔) + IsAllergyHistory *int `json:"is_allergy_history"` // 是否存在过敏史(0:否 1:是) + AllergyHistory string `json:"allergy_history"` // 过敏史描述 + IsFamilyHistory *int `json:"is_family_history"` // 是否存在家族病史(0:否 1:是) + FamilyHistory string `json:"family_history"` // 家族病史描述 + IsPregnant *int `json:"is_pregnant"` // 是否备孕、妊娠、哺乳期(0:否 1:是) + Pregnant string `json:"pregnant"` // 备孕、妊娠、哺乳期描述 + IsTaboo *int `json:"is_taboo"` // 是否服用过禁忌药物,且无相关禁忌(0:否 1:是)问诊购药时存在 + DiagnosisHospital string `json:"diagnosis_hospital"` // 确诊医院 + IsTakeMedicine *int `json:"is_take_medicine"` // 正在服药(0:否 1:是) + DrugsName string `json:"drugs_name"` // 正在服药名称 + DrinkWineStatus *int `json:"drink_wine_status"` // 饮酒状态(1:从不 2:偶尔 3:经常 4:每天 5:已戒酒) + SmokeStatus *int `json:"smoke_status"` // 吸烟状态(1:从不 2:偶尔 3:经常 4:每天 5:已戒烟) + ChemicalCompoundStatus *int `json:"chemical_compound_status"` // 化合物状态(1:从不 2:偶尔 3:经常 4:每天) + ChemicalCompoundDescribe string `json:"chemical_compound_describe"` // 化合物描述 + IsOperation *int `json:"is_operation"` // 是否存在手术(0:否 1:是) + Operation string `json:"operation"` // 手术描述 + Product []*string `json:"product"` // 用药意向 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetOrderInquiryCaseDto(m *model.OrderInquiryCase) *OrderInquiryCaseDto { + // 复诊凭证 + var diagnoseImages []*string + if m.DiagnoseImages != "" { + diagnoseImages := strings.Split(m.DiagnoseImages, ",") + + for i, image := range diagnoseImages { + diagnoseImages[i] = utils.AddOssDomain(image) + } + } + + return &OrderInquiryCaseDto{ + InquiryCaseId: fmt.Sprintf("%d", m.InquiryCaseId), + UserId: fmt.Sprintf("%d", m.InquiryCaseId), + PatientId: fmt.Sprintf("%d", m.InquiryCaseId), + OrderInquiryId: fmt.Sprintf("%d", m.InquiryCaseId), + FamilyId: fmt.Sprintf("%d", m.InquiryCaseId), + Relation: m.Relation, + Status: m.Status, + Name: m.Name, + Sex: m.Sex, + Age: m.Age, + Height: m.Height, + Weight: m.Weight, + DiseaseClassId: fmt.Sprintf("%d", m.InquiryCaseId), + DiseaseClassName: m.DiseaseClassName, + DiagnosisDate: m.DiagnosisDate, + DiseaseDesc: m.DiseaseDesc, + DiagnoseImages: diagnoseImages, + IsAllergyHistory: m.IsAllergyHistory, + AllergyHistory: m.AllergyHistory, + IsFamilyHistory: m.IsFamilyHistory, + FamilyHistory: m.FamilyHistory, + IsPregnant: m.IsPregnant, + Pregnant: m.Pregnant, + IsTaboo: m.IsTaboo, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetOrderInquiryCaseListDto(m []*model.OrderInquiryCase) []OrderInquiryCaseDto { + // 处理返回值 + responses := make([]OrderInquiryCaseDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := OrderInquiryCaseDto{ + InquiryCaseId: fmt.Sprintf("%d", v.InquiryCaseId), + UserId: fmt.Sprintf("%d", v.UserId), + PatientId: fmt.Sprintf("%d", v.PatientId), + OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId), + FamilyId: fmt.Sprintf("%d", v.FamilyId), + Name: v.Name, + Sex: v.Sex, + Age: v.Age, + DiseaseClassName: v.DiseaseClassName, + DiseaseDesc: v.DiseaseDesc, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} + +// LoadPatientFamilyHealthAttr 加载健康属性 +func (r *OrderInquiryCaseDto) LoadPatientFamilyHealthAttr(m *model.PatientFamilyHealth) *OrderInquiryCaseDto { + if m != nil { + r.DiagnosisHospital = m.DiagnosisHospital + r.IsTakeMedicine = m.IsTakeMedicine + r.DrugsName = m.DrugsName + } + return r +} + +// LoadPatientFamilyPersonalAttr 加载个人情况属性 +func (r *OrderInquiryCaseDto) LoadPatientFamilyPersonalAttr(m *model.PatientFamilyPersonal) *OrderInquiryCaseDto { + if m != nil { + r.DrinkWineStatus = m.DrinkWineStatus + r.SmokeStatus = m.SmokeStatus + r.ChemicalCompoundStatus = m.ChemicalCompoundStatus + r.ChemicalCompoundDescribe = m.ChemicalCompoundDescribe + r.IsOperation = m.IsOperation + r.Operation = m.Operation + } + return r +} + +// LoadInquiryCaseProduct 加载用药意向 +func (r *OrderInquiryCaseDto) LoadInquiryCaseProduct(m []*model.InquiryCaseProduct) *OrderInquiryCaseDto { + if len(m) > 0 { + var product []*string + for _, inquiryCaseProduct := range m { + // 获取商品数据 + productDao := dao.ProductDao{} + productData, err := productDao.GetProductById(inquiryCaseProduct.ProductId) + if err != nil { + return r + } + + caseProductNum := fmt.Sprintf("%d", inquiryCaseProduct.CaseProductNum) + productName := productData.ProductName + productData.ProductSpec + "(" + caseProductNum + productData.PackagingUnit + ")" + + product = append(product, &productName) + } + r.Product = product + } + return r +} diff --git a/api/dto/OrderInquiryCoupon.go b/api/dto/OrderInquiryCoupon.go new file mode 100644 index 0000000..ba76e55 --- /dev/null +++ b/api/dto/OrderInquiryCoupon.go @@ -0,0 +1,52 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type OrderInquiryCouponDto struct { + OrderCouponId string `json:"order_coupon_id"` // 主键id + OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id + UserCouponId string `json:"user_coupon_id"` // 用户优惠卷表 + CouponName string `json:"coupon_name"` // 优惠卷名称 + CouponUsePrice float64 `json:"coupon_use_price"` // 优惠卷使用金额 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetOrderInquiryCouponDto(m *model.OrderInquiryCoupon) *OrderInquiryCouponDto { + return &OrderInquiryCouponDto{ + OrderCouponId: fmt.Sprintf("%d", m.OrderCouponId), + OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId), + UserCouponId: fmt.Sprintf("%d", m.UserCouponId), + CouponName: m.CouponName, + CouponUsePrice: m.CouponUsePrice, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetOrderInquiryCouponListDto(m []*model.OrderInquiryCoupon) []OrderInquiryCouponDto { + // 处理返回值 + responses := make([]OrderInquiryCouponDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := OrderInquiryCouponDto{ + OrderCouponId: fmt.Sprintf("%d", v.OrderCouponId), + OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId), + UserCouponId: fmt.Sprintf("%d", v.UserCouponId), + CouponName: v.CouponName, + CouponUsePrice: v.CouponUsePrice, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/OrderInquiryRefund.go b/api/dto/OrderInquiryRefund.go new file mode 100644 index 0000000..07069a1 --- /dev/null +++ b/api/dto/OrderInquiryRefund.go @@ -0,0 +1,67 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type OrderInquiryRefundDto struct { + InquiryRefundId string `json:"inquiry_refund_id"` // 主键id + PatientId string `json:"patient_id"` // 患者id + OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id + InquiryNo string `json:"inquiry_no"` // 系统订单编号 + InquiryRefundNo string `json:"inquiry_refund_no"` // 系统退款编号 + RefundId string `json:"refund_id"` // 第三方退款单号 + InquiryRefundStatus int `json:"inquiry_refund_status"` // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常) + RefundTotal float64 `json:"refund_total"` // 退款金额 + RefundReason string `json:"refund_reason"` // 退款原因 + SuccessTime model.LocalTime `json:"success_time"` // 退款成功时间 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetOrderInquiryRefundBankDto(m *model.OrderInquiryRefund) *OrderInquiryRefundDto { + return &OrderInquiryRefundDto{ + InquiryRefundId: fmt.Sprintf("%d", m.InquiryRefundId), + PatientId: fmt.Sprintf("%d", m.PatientId), + OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId), + InquiryNo: m.InquiryNo, + InquiryRefundNo: m.InquiryRefundNo, + RefundId: m.RefundId, + InquiryRefundStatus: m.InquiryRefundStatus, + RefundTotal: m.RefundTotal, + RefundReason: m.RefundReason, + SuccessTime: m.SuccessTime, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetOrderInquiryRefundListDto(m []*model.OrderInquiryRefund) []OrderInquiryRefundDto { + // 处理返回值 + responses := make([]OrderInquiryRefundDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := OrderInquiryRefundDto{ + InquiryRefundId: fmt.Sprintf("%d", v.InquiryRefundId), + PatientId: fmt.Sprintf("%d", v.PatientId), + OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId), + InquiryNo: v.InquiryNo, + InquiryRefundNo: v.InquiryRefundNo, + RefundId: v.RefundId, + InquiryRefundStatus: v.InquiryRefundStatus, + RefundTotal: v.RefundTotal, + RefundReason: v.RefundReason, + SuccessTime: v.SuccessTime, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/OrderPrescription.go b/api/dto/OrderPrescription.go new file mode 100644 index 0000000..f573165 --- /dev/null +++ b/api/dto/OrderPrescription.go @@ -0,0 +1,107 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type OrderPrescriptionDto struct { + OrderPrescriptionId string `json:"order_prescription_id"` // 主键id + OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id;NOT NULL + DoctorId string `json:"doctor_id"` // 医生id;NOT NULL + PatientId string `json:"patient_id"` // 患者id + FamilyId string `json:"family_id"` // 家庭成员id(就诊用户) + PharmacistId string `json:"pharmacist_id"` // 药师id + PrescriptionStatus int `json:"prescription_status"` // 处方状态(1:待审核 2:待使用 3:已失效 4:已使用) + PharmacistAuditStatus int `json:"pharmacist_audit_status"` // 药师审核状态(0:审核中 1:审核成功 2:审核驳回) + PharmacistVerifyTime model.LocalTime `json:"pharmacist_verify_time"` // 药师审核时间 + PharmacistFailReason string `json:"pharmacist_fail_reason"` // 药师审核驳回原因 + PlatformAuditStatus int `json:"platform_audit_status"` // 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回) + PlatformFailTime model.LocalTime `json:"platform_fail_time"` // 平台审核失败时间 + PlatformFailReason string `json:"platform_fail_reason"` // 处方平台驳回原因 + IsAutoPharVerify int `json:"is_auto_phar_verify"` // 是否药师自动审核(0:否 1:是) + DoctorCreatedTime model.LocalTime `json:"doctor_created_time"` // 医生开具处方时间 + ExpiredTime model.LocalTime `json:"expired_time"` // 处方过期时间 + VoidTime model.LocalTime `json:"void_time"` // 处方作废时间 + IsDelete int `json:"is_delete"` // 是否删除(0:否 1:是) + PrescriptionCode string `json:"prescription_code"` // 处方编号 + DoctorName string `json:"doctor_name"` // 医生名称 + PatientName string `json:"patient_name"` // 患者姓名-就诊人 + PatientSex int `json:"patient_sex"` // 患者性别-就诊人(1:男 2:女) + PatientAge int `json:"patient_age"` // 患者年龄-就诊人 + DoctorAdvice string `json:"doctor_advice"` // 医嘱 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetOrderPrescriptionDto(m *model.OrderPrescription) *OrderPrescriptionDto { + return &OrderPrescriptionDto{ + OrderPrescriptionId: fmt.Sprintf("%d", m.OrderPrescriptionId), + OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId), + DoctorId: fmt.Sprintf("%d", m.DoctorId), + PatientId: fmt.Sprintf("%d", m.PatientId), + FamilyId: fmt.Sprintf("%d", m.FamilyId), + PharmacistId: fmt.Sprintf("%d", m.PharmacistId), + PrescriptionStatus: m.PrescriptionStatus, + PharmacistAuditStatus: m.PharmacistAuditStatus, + PharmacistVerifyTime: m.PharmacistVerifyTime, + PharmacistFailReason: m.PharmacistFailReason, + PlatformAuditStatus: m.PlatformAuditStatus, + PlatformFailTime: m.PlatformFailTime, + PlatformFailReason: m.PlatformFailReason, + IsAutoPharVerify: m.IsAutoPharVerify, + DoctorCreatedTime: m.DoctorCreatedTime, + ExpiredTime: m.ExpiredTime, + IsDelete: m.IsDelete, + PrescriptionCode: m.PrescriptionCode, + DoctorName: m.DoctorName, + PatientName: m.PatientName, + PatientSex: m.PatientSex, + PatientAge: m.PatientAge, + DoctorAdvice: m.DoctorAdvice, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetOrderPrescriptionListDto(m []*model.OrderPrescription) []OrderPrescriptionDto { + // 处理返回值 + responses := make([]OrderPrescriptionDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := OrderPrescriptionDto{ + OrderPrescriptionId: fmt.Sprintf("%d", v.OrderPrescriptionId), + OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId), + DoctorId: fmt.Sprintf("%d", v.DoctorId), + PatientId: fmt.Sprintf("%d", v.PatientId), + FamilyId: fmt.Sprintf("%d", v.FamilyId), + PharmacistId: fmt.Sprintf("%d", v.PharmacistId), + PrescriptionStatus: v.PrescriptionStatus, + PharmacistAuditStatus: v.PharmacistAuditStatus, + PharmacistVerifyTime: v.PharmacistVerifyTime, + PharmacistFailReason: v.PharmacistFailReason, + PlatformAuditStatus: v.PlatformAuditStatus, + PlatformFailTime: v.PlatformFailTime, + PlatformFailReason: v.PlatformFailReason, + IsAutoPharVerify: v.IsAutoPharVerify, + DoctorCreatedTime: v.DoctorCreatedTime, + ExpiredTime: v.ExpiredTime, + IsDelete: v.IsDelete, + PrescriptionCode: v.PrescriptionCode, + DoctorName: v.DoctorName, + PatientName: v.PatientName, + PatientSex: v.PatientSex, + PatientAge: v.PatientAge, + DoctorAdvice: v.DoctorAdvice, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/OrderProduct.go b/api/dto/OrderProduct.go new file mode 100644 index 0000000..032017a --- /dev/null +++ b/api/dto/OrderProduct.go @@ -0,0 +1,264 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +// OrderProductDto 订单详情 +type OrderProductDto struct { + OrderProductId string `json:"order_product_id"` // 主键id + OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id;NOT NULL + OrderPrescriptionId string `json:"order_prescription_id"` // 订单-处方id;NOT NULL + DoctorId string `json:"doctor_id"` // 医生id + PatientId string `json:"patient_id"` // 患者id + FamilyId string `json:"family_id"` // 家庭成员id(就诊用户) + OrderProductNo string `json:"order_product_no"` // 订单编号 + EscrowTradeNo string `json:"escrow_trade_no"` // 第三方支付流水号 + OrderProductStatus int `json:"order_product_status"` // 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消) + PayChannel int `json:"pay_channel"` // 支付渠道(1:小程序支付 2:微信扫码支付);NOT NULL + PayStatus int `json:"pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) + CancelReason int `json:"cancel_reason"` // 订单取消原因(1:主动取消 2:复核失败/库存不足 3:支付超时 4:客服取消) + AmountTotal float64 `json:"amount_total"` // 订单金额 + PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额 + LogisticsFee float64 `json:"logistics_fee"` // 运费金额 + LogisticsNo string `json:"logistics_no"` // 物流编号 + LogisticsCompanyCode string `json:"logistics_company_code"` // 快递公司编码 + DeliveryTime model.LocalTime `json:"delivery_time"` // 发货时间 + PayTime model.LocalTime `json:"pay_time"` // 支付时间 + Remarks string `json:"remarks"` // 订单备注 + RefundStatus int `json:"refund_status"` // 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常) + CancelTime model.LocalTime `json:"cancel_time"` // 订单取消时间 + CancelRemarks string `json:"cancel_remarks"` // 订单取消备注(自动添加) + ReportPreStatus int `json:"report_pre_status"` // 上报处方平台状态(0:未上报 1:已上报 2:上报失败)) + ReportPreTime model.LocalTime `json:"report_pre_time"` // 上报处方平台时间 + ReportPreFailReason string `json:"report_pre_fail_reason"` // 上报失败原因 + ProvinceId int `json:"province_id"` // 省份id + Province string `json:"province"` // 省份 + CityId int `json:"city_id"` // 城市id + City string `json:"city"` // 城市 + CountyId int `json:"county_id"` // county_id + County string `json:"county"` // 区县 + AddressMask string `json:"address_mask"` // 详细地址(掩码) + ConsigneeNameMask string `json:"consignee_name_mask"` // 收货人姓名(掩码) + ConsigneeTelMask string `json:"consignee_tel_mask"` // 收货人电话(掩码) + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 + PrescriptionCode string `json:"prescription_code"` // 处方编号 + DoctorName string `json:"doctor_name"` // 医生姓名 + PatientNameMask string `json:"patient_name_mask"` // 患者姓名-就诊人(掩码) + PatientSex int `json:"patient_sex"` // 患者性别-就诊人(0:未知 1:男 2:女) + PatientAge int `json:"patient_age"` // 患者年龄-就诊人 + PatientMobile string `json:"patient_mobile"` // 患者电话 + OrderProductRefund *OrderProductRefundDto `json:"order_product_refund"` // 退款数据 + OrderProductItem []*OrderProductItemDto `json:"order_product_item"` // 商品数据 + OrderProductLogistics *OrderProductLogisticsDto `json:"order_product_logistics"` // 物流数据 + UserDoctor *UserDoctorDto `json:"user_doctor"` // 医生数据 + OrderPrescription *OrderPrescriptionDto `json:"order_prescription"` // 处方数据 + OrderInquiryCase *OrderInquiryCaseDto `json:"order_inquiry_case"` // 问诊病例 +} + +// OrderProductConsigneeDto 药品订单收货人数据 +type OrderProductConsigneeDto struct { + ProvinceId int `json:"province_id"` // 省份id + Province string `json:"province"` // 省份 + CityId int `json:"city_id"` // 城市id + City string `json:"city"` // 城市 + CountyId int `json:"county_id"` // county_id + County string `json:"county"` // 区县 + Address string `json:"address"` // 详细地址 + ConsigneeName string `json:"consignee_name"` // 收货人姓名 + ConsigneeTel string `json:"consignee_tel"` // 收货人电话 +} + +func GetOrderProductDto(m *model.OrderProduct) *OrderProductDto { + return &OrderProductDto{ + OrderProductId: fmt.Sprintf("%d", m.OrderProductId), + OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId), + OrderPrescriptionId: fmt.Sprintf("%d", m.OrderPrescriptionId), + DoctorId: fmt.Sprintf("%d", m.DoctorId), + PatientId: fmt.Sprintf("%d", m.PatientId), + FamilyId: fmt.Sprintf("%d", m.FamilyId), + OrderProductNo: m.OrderProductNo, + EscrowTradeNo: m.EscrowTradeNo, + OrderProductStatus: m.OrderProductStatus, + PayChannel: m.PayChannel, + PayStatus: m.PayStatus, + CancelReason: m.CancelReason, + AmountTotal: m.AmountTotal, + PaymentAmountTotal: m.PaymentAmountTotal, + LogisticsFee: m.LogisticsFee, + LogisticsNo: m.LogisticsNo, + LogisticsCompanyCode: m.LogisticsCompanyCode, + DeliveryTime: m.DeliveryTime, + PayTime: m.PayTime, + Remarks: m.Remarks, + RefundStatus: m.RefundStatus, + CancelTime: m.CancelTime, + CancelRemarks: m.CancelRemarks, + ReportPreStatus: m.ReportPreStatus, + ReportPreTime: m.ReportPreTime, + ReportPreFailReason: m.ReportPreFailReason, + ProvinceId: m.ProvinceId, + Province: m.Province, + CityId: m.CityId, + City: m.City, + CountyId: m.CountyId, + County: m.County, + AddressMask: m.AddressMask, + ConsigneeNameMask: m.ConsigneeNameMask, + ConsigneeTelMask: m.ConsigneeTelMask, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +// GetOrderProductConsigneeDtoDto 药品订单收货人数据 +func GetOrderProductConsigneeDtoDto(m *model.OrderProduct) *OrderProductConsigneeDto { + return &OrderProductConsigneeDto{ + ProvinceId: m.ProvinceId, + Province: m.Province, + CityId: m.CityId, + City: m.City, + CountyId: m.CountyId, + County: m.County, + Address: m.Address, + ConsigneeName: m.ConsigneeName, + ConsigneeTel: m.ConsigneeTel, + } +} + +func GetOrderProductListDto(m []*model.OrderProduct) []*OrderProductDto { + // 处理返回值 + responses := make([]*OrderProductDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := &OrderProductDto{ + OrderProductId: fmt.Sprintf("%d", v.OrderProductId), + OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId), + OrderPrescriptionId: fmt.Sprintf("%d", v.OrderPrescriptionId), + DoctorId: fmt.Sprintf("%d", v.DoctorId), + PatientId: fmt.Sprintf("%d", v.PatientId), + FamilyId: fmt.Sprintf("%d", v.FamilyId), + OrderProductNo: v.OrderProductNo, + EscrowTradeNo: v.OrderProductNo, + OrderProductStatus: v.OrderProductStatus, + PayChannel: v.PayChannel, + PayStatus: v.PayStatus, + CancelReason: v.CancelReason, + AmountTotal: v.AmountTotal, + PaymentAmountTotal: v.PaymentAmountTotal, + LogisticsFee: v.LogisticsFee, + LogisticsNo: v.LogisticsNo, + LogisticsCompanyCode: v.LogisticsCompanyCode, + DeliveryTime: v.DeliveryTime, + PayTime: v.PayTime, + Remarks: v.Remarks, + RefundStatus: v.RefundStatus, + ReportPreStatus: v.ReportPreStatus, + ConsigneeNameMask: v.ConsigneeNameMask, + ConsigneeTelMask: v.ConsigneeTelMask, + PatientMobile: v.UserPatient.User.Mobile, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 加载医生名称 + if v.UserDoctor != nil { + response = response.LoadDoctorName(v.UserDoctor) + } + + // 加载问诊属性 + if v.OrderInquiry != nil { + response = response.LoadOrderInquiryAttr(v.OrderInquiry) + } + + // 加载处方编号 + if v.OrderPrescription != nil { + response = response.LoadOrderPrescriptionCode(v.OrderPrescription) + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} + +// LoadDoctorName 加载医生名称 +func (r *OrderProductDto) LoadDoctorName(m *model.UserDoctor) *OrderProductDto { + if m != nil { + r.DoctorName = m.UserName + } + return r +} + +// LoadOrderInquiryAttr 加载问诊属性 +func (r *OrderProductDto) LoadOrderInquiryAttr(m *model.OrderInquiry) *OrderProductDto { + if m != nil { + r.PatientNameMask = m.PatientNameMask + r.PatientSex = m.PatientSex + r.PatientAge = m.PatientAge + } + return r +} + +// LoadOrderPrescriptionCode 加载处方编号 +func (r *OrderProductDto) LoadOrderPrescriptionCode(m *model.OrderPrescription) *OrderProductDto { + if m != nil { + r.PrescriptionCode = m.PrescriptionCode + } + return r +} + +// LoadOrderInquiryCase 加载问诊病例 +func (r *OrderProductDto) LoadOrderInquiryCase(m *model.OrderInquiryCase) *OrderProductDto { + if m != nil { + d := GetOrderInquiryCaseDto(m) + + r.OrderInquiryCase = d + } + return r +} + +// LoadOrderPrescription 加载处方数据 +func (r *OrderProductDto) LoadOrderPrescription(m *model.OrderPrescription) *OrderProductDto { + if m != nil { + d := GetOrderPrescriptionDto(m) + + r.OrderPrescription = d + } + return r +} + +// LoadOrderProductLogistics 加载物流数据 +func (r *OrderProductDto) LoadOrderProductLogistics(m *model.OrderProductLogistics) *OrderProductDto { + if m != nil { + d := GetOrderProductLogisticsDto(m) + + r.OrderProductLogistics = d + } + return r +} + +// LoadOrderProductItem 加载商品数据 +func (r *OrderProductDto) LoadOrderProductItem(m []*model.OrderProductItem) *OrderProductDto { + if m != nil { + d := GetOrderProductItemListDto(m) + + r.OrderProductItem = d + } + return r +} + +// LoadOrderProductRefund 加载退款数据 +func (r *OrderProductDto) LoadOrderProductRefund(m *model.OrderProductRefund) *OrderProductDto { + if m != nil { + d := GetOrderProductRefundDto(m) + + r.OrderProductRefund = d + } + return r +} diff --git a/api/dto/OrderProductItem.go b/api/dto/OrderProductItem.go new file mode 100644 index 0000000..11e4b7a --- /dev/null +++ b/api/dto/OrderProductItem.go @@ -0,0 +1,74 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" + "hospital-admin-api/utils" +) + +type OrderProductItemDto struct { + ProductItemId string `json:"product_item_id"` // 主键id + OrderProductId string `json:"order_product_id"` // 订单-商品订单id + OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id + OrderPrescriptionId string `json:"order_prescription_id"` // 订单-处方id + ProductId string `json:"product_id"` // 商品id + ProductName string `json:"product_name"` // 商品名称 + ProductPrice float64 `json:"product_price"` // 商品价格 + ProductPlatformCode string `json:"product_platform_code"` // 商品处方平台编码 + Amount int `json:"amount"` // 数量 + Manufacturer string `json:"manufacturer"` // 生产厂家 + ProductCoverImg string `json:"product_cover_img"` // 商品封面图 + ProductSpec string `json:"product_spec"` // 商品规格 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetOrderProductItemDto(m *model.OrderProductItem) *OrderProductItemDto { + return &OrderProductItemDto{ + ProductItemId: fmt.Sprintf("%d", m.ProductItemId), + OrderProductId: fmt.Sprintf("%d", m.OrderProductId), + OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId), + OrderPrescriptionId: fmt.Sprintf("%d", m.OrderPrescriptionId), + ProductId: fmt.Sprintf("%d", m.ProductId), + ProductName: m.ProductName, + ProductPrice: m.ProductPrice, + ProductPlatformCode: m.ProductPlatformCode, + Amount: m.Amount, + Manufacturer: m.Manufacturer, + ProductCoverImg: utils.AddOssDomain(m.ProductCoverImg), + ProductSpec: m.ProductSpec, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetOrderProductItemListDto(m []*model.OrderProductItem) []*OrderProductItemDto { + // 处理返回值 + responses := make([]*OrderProductItemDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := &OrderProductItemDto{ + ProductItemId: fmt.Sprintf("%d", v.ProductItemId), + OrderProductId: fmt.Sprintf("%d", v.OrderProductId), + OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId), + OrderPrescriptionId: fmt.Sprintf("%d", v.OrderPrescriptionId), + ProductId: fmt.Sprintf("%d", v.ProductId), + ProductName: v.ProductName, + ProductPrice: v.ProductPrice, + ProductPlatformCode: v.ProductPlatformCode, + Amount: v.Amount, + Manufacturer: v.Manufacturer, + ProductCoverImg: utils.AddOssDomain(v.ProductCoverImg), + ProductSpec: v.ProductSpec, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/OrderProductLogistics.go b/api/dto/OrderProductLogistics.go new file mode 100644 index 0000000..a82c03c --- /dev/null +++ b/api/dto/OrderProductLogistics.go @@ -0,0 +1,58 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type OrderProductLogisticsDto struct { + LogisticsId string `json:"logistics_id"` // 主键id + OrderProductId string `json:"order_product_id"` // 药品订单id;NOT NULL + LogisticsStatus int `json:"logistics_status"` // 运单签收状态(0在途 1揽收 2疑难 3签收 4退签 5派件 8清关 14拒签);NOT NULL + LogisticsNo string `json:"logistics_no"` // 物流编号 + CompanyName string `json:"company_name"` // 快递公司名称 + CompanyCode string `json:"company_code"` // 快递公司编码 + LogisticsContent string `json:"logistics_content"` // 内容 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetOrderProductLogisticsDto(m *model.OrderProductLogistics) *OrderProductLogisticsDto { + return &OrderProductLogisticsDto{ + LogisticsId: fmt.Sprintf("%d", m.LogisticsId), + OrderProductId: fmt.Sprintf("%d", m.OrderProductId), + LogisticsStatus: m.LogisticsStatus, + LogisticsNo: m.LogisticsNo, + CompanyName: m.CompanyName, + CompanyCode: m.CompanyCode, + LogisticsContent: m.LogisticsContent, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetOrderProductLogisticsListDto(m []*model.OrderProductLogistics) []OrderProductLogisticsDto { + // 处理返回值 + responses := make([]OrderProductLogisticsDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := OrderProductLogisticsDto{ + LogisticsId: fmt.Sprintf("%d", v.LogisticsId), + OrderProductId: fmt.Sprintf("%d", v.OrderProductId), + LogisticsStatus: v.LogisticsStatus, + LogisticsNo: v.LogisticsNo, + CompanyName: v.CompanyName, + CompanyCode: v.CompanyCode, + LogisticsContent: v.LogisticsContent, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/OrderProductRefund.go b/api/dto/OrderProductRefund.go new file mode 100644 index 0000000..2ed0cd5 --- /dev/null +++ b/api/dto/OrderProductRefund.go @@ -0,0 +1,67 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type OrderProductRefundDto struct { + ProductRefundId string `json:"product_refund_id"` // 主键id + PatientId string `json:"patient_id"` // 患者id + OrderProductId string `json:"order_product_id"` // 订单-药品订单id + OrderProductNo string `json:"order_product_no"` // 系统订单编号 + ProductRefundNo string `json:"product_refund_no"` // 系统退款编号 + RefundId string `json:"refund_id"` // 第三方退款单号 + ProductRefundStatus int `json:"product_refund_status"` // 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常) + RefundTotal float64 `json:"refund_total"` // 退款金额 + RefundReason string `json:"refund_reason"` // 退款原因 + SuccessTime model.LocalTime `json:"success_time"` // 退款成功时间 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetOrderProductRefundDto(m *model.OrderProductRefund) *OrderProductRefundDto { + return &OrderProductRefundDto{ + ProductRefundId: fmt.Sprintf("%d", m.ProductRefundId), + PatientId: fmt.Sprintf("%d", m.PatientId), + OrderProductId: fmt.Sprintf("%d", m.OrderProductId), + OrderProductNo: m.OrderProductNo, + ProductRefundNo: m.ProductRefundNo, + RefundId: m.RefundId, + ProductRefundStatus: m.ProductRefundStatus, + RefundTotal: m.RefundTotal, + RefundReason: m.RefundReason, + SuccessTime: m.SuccessTime, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetOrderProductRefundListDto(m []*model.OrderProductRefund) []OrderProductRefundDto { + // 处理返回值 + responses := make([]OrderProductRefundDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := OrderProductRefundDto{ + ProductRefundId: fmt.Sprintf("%d", v.ProductRefundId), + PatientId: fmt.Sprintf("%d", v.PatientId), + OrderProductId: fmt.Sprintf("%d", v.OrderProductId), + OrderProductNo: v.OrderProductNo, + ProductRefundNo: v.ProductRefundNo, + RefundId: v.RefundId, + ProductRefundStatus: v.ProductRefundStatus, + RefundTotal: v.RefundTotal, + RefundReason: v.RefundReason, + SuccessTime: v.SuccessTime, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/PatientFamily.go b/api/dto/PatientFamily.go new file mode 100644 index 0000000..0b0e969 --- /dev/null +++ b/api/dto/PatientFamily.go @@ -0,0 +1,168 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" + "hospital-admin-api/utils" +) + +type PatientFamilyDto struct { + FamilyId string `json:"family_id"` // 主键id + PatientId string `json:"patient_id"` // 患者id + Relation *int `json:"relation"` // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他) + Status *int `json:"status"` // 状态(1:正常 2:删除) + IsDefault *int `json:"is_default"` // 是否默认(0:否 1:是) + CardName string `json:"card_name"` // 姓名 + CardNameMask string `json:"card_name_mask"` // 姓名(掩码) + Mobile string `json:"mobile"` // 电话 + MobileMask string `json:"mobile_mask"` // 电话(掩码) + Type *int `json:"type"` // 身份类型(1:身份证 2:护照 3:港澳通行证 4:台胞证) + IdNumber string `json:"id_number"` // 证件号码 + IdNumberMask string `json:"id_number_mask"` // 证件号码(掩码) + Sex *int `json:"sex"` // 性别(0:未知 1:男 2:女) + Age int `json:"age"` // 年龄 + ProvinceId string `json:"province_id"` // 省份id + Province string `json:"province"` // 省份 + CityId string `json:"city_id"` // 城市id + City string `json:"city"` // 城市 + CountyId string `json:"county_id"` // 区县id + County string `json:"county"` // 区县 + Height string `json:"height"` // 身高(cm) + Weight string `json:"weight"` // 体重(kg) + MaritalStatus *int `json:"marital_status"` // 婚姻状况(0:未婚 1:已婚 2:离异) + NationId string `json:"nation_id"` // 民族 + NationName string `json:"nation_name"` // 民族名称 + JobId string `json:"job_id"` // 职业 + JobName string `json:"job_name"` // 职业名称 + UserName string `json:"user_name"` // 账号名称 + User *UserDto `json:"user"` // 用户 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 +} + +type PatientFamilyMaskDto struct { + FamilyId string `json:"family_id"` // 主键id + PatientId string `json:"patient_id"` // 患者id + Relation *int `json:"relation"` // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他) + Status *int `json:"status"` // 状态(1:正常 2:删除) + IsDefault *int `json:"is_default"` // 是否默认(0:否 1:是) + CardNameMask string `json:"card_name_mask"` // 姓名(掩码) + MobileMask string `json:"mobile_mask"` // 电话(掩码) + IdNumberMask string `json:"id_number_mask"` // 证件号码(掩码) + Sex *int `json:"sex"` // 性别(0:未知 1:男 2:女) + Age int `json:"age"` // 年龄 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 +} + +func GetPatientFamilyMaskDto(m *model.PatientFamily) *PatientFamilyMaskDto { + return &PatientFamilyMaskDto{ + FamilyId: fmt.Sprintf("%d", m.FamilyId), + PatientId: fmt.Sprintf("%d", m.PatientId), + Relation: m.Relation, + Status: &m.Status, + IsDefault: &m.IsDefault, + CardNameMask: m.CardNameMask, + IdNumberMask: m.IdNumberMask, + Sex: &m.Sex, + Age: m.Age, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetPatientFamilyMaskListDto(m []*model.PatientFamily) []*PatientFamilyMaskDto { + // 处理返回值 + responses := make([]*PatientFamilyMaskDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := &PatientFamilyMaskDto{ + FamilyId: fmt.Sprintf("%d", v.FamilyId), + PatientId: fmt.Sprintf("%d", v.PatientId), + Relation: v.Relation, + Status: &v.Status, + IsDefault: &v.IsDefault, + CardNameMask: v.CardNameMask, + IdNumberMask: v.IdNumberMask, + Sex: &v.Sex, + Age: v.Age, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} + +func GetPatientFamilyDto(m *model.PatientFamily) *PatientFamilyDto { + return &PatientFamilyDto{ + FamilyId: fmt.Sprintf("%d", m.FamilyId), + PatientId: fmt.Sprintf("%d", m.PatientId), + Relation: m.Relation, + Status: &m.Status, + IsDefault: &m.IsDefault, + CardName: m.CardName, + CardNameMask: m.CardNameMask, + MobileMask: m.MobileMask, + Type: &m.Type, + IdNumberMask: m.IdNumberMask, + Sex: &m.Sex, + Age: m.Age, + ProvinceId: fmt.Sprintf("%d", m.ProvinceId), + Province: m.Province, + CityId: fmt.Sprintf("%d", m.CityId), + City: m.City, + CountyId: fmt.Sprintf("%d", m.CountyId), + County: m.County, + Height: m.Height, + Weight: m.Weight, + MaritalStatus: &m.MaritalStatus, + NationId: fmt.Sprintf("%d", m.NationId), + NationName: m.NationName, + JobId: fmt.Sprintf("%d", m.JobId), + JobName: m.JobName, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetPatientFamilyListDto(m []*model.PatientFamily) []*PatientFamilyDto { + // 处理返回值 + responses := make([]*PatientFamilyDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := &PatientFamilyDto{ + FamilyId: fmt.Sprintf("%d", v.FamilyId), + PatientId: fmt.Sprintf("%d", v.PatientId), + Relation: v.Relation, + Status: &v.Status, + CardName: v.CardName, + MobileMask: utils.MaskPhoneStr(v.UserPatient.User.Mobile), + UserName: v.UserPatient.UserName, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} + +// LoadMaskUser 加载用户数据-加密 +func (r *PatientFamilyDto) LoadMaskUser(m *model.User) *PatientFamilyDto { + if m != nil { + userDto := GetMaskUserDto(m) + + r.User = userDto + } + return r +} diff --git a/api/dto/User.go b/api/dto/User.go new file mode 100644 index 0000000..f249ed4 --- /dev/null +++ b/api/dto/User.go @@ -0,0 +1,101 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" + "hospital-admin-api/utils" +) + +type UserDto struct { + UserID string `json:"user_id"` // 主键 + UserName string `json:"user_name"` // 用户名称 + UserAccount string `json:"user_account"` // 账号 + Mobile string `json:"mobile"` // 手机号 + WxMobile string `json:"wx_mobile"` // 微信手机号 + UserType int `json:"user_type"` // 用户类型(1:患者 2:医师 3:药师) + UserStatus int `json:"user_status"` // 状态(0:禁用 1:正常 2:删除) + RegisterMethod int `json:"register_method"` // 注册方式(1:微信小程序) + Age uint `json:"age"` // 年龄 + Sex int `json:"sex"` // 性别(0:未知 1:男 2:女) + Avatar string `json:"avatar"` // 头像 + LoginIP string `json:"login_ip"` // 登陆ip + LastLoginAt model.LocalTime `json:"last_login_at"` // 最后登陆时间 + CreatedBy string `json:"created_by"` // 创建者id(后台用户表id null:自己注册) + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetUserDto(m *model.User) *UserDto { + return &UserDto{ + UserID: fmt.Sprintf("%d", m.UserId), + UserName: m.UserName, + UserAccount: m.UserAccount, + Mobile: m.Mobile, + WxMobile: m.WxMobile, + UserType: m.UserType, + UserStatus: m.UserStatus, + RegisterMethod: m.RegisterMethod, + Age: m.Age, + Sex: m.Sex, + Avatar: utils.AddOssDomain(m.Avatar), + LoginIP: m.LoginIp, + LastLoginAt: m.LastLoginAt, + CreatedBy: m.CreatedBy, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetMaskUserDto(m *model.User) *UserDto { + return &UserDto{ + UserID: fmt.Sprintf("%d", m.UserId), + UserName: m.UserName, + UserAccount: m.UserAccount, + Mobile: utils.MaskPhoneStr(m.Mobile), + WxMobile: utils.MaskPhoneStr(m.WxMobile), + UserType: m.UserType, + UserStatus: m.UserStatus, + RegisterMethod: m.RegisterMethod, + Age: m.Age, + Sex: m.Sex, + Avatar: utils.AddOssDomain(m.Avatar), + LoginIP: m.LoginIp, + LastLoginAt: m.LastLoginAt, + CreatedBy: m.CreatedBy, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetUserListDto(m []*model.User) []UserDto { + // 处理返回值 + responses := make([]UserDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := UserDto{ + UserID: fmt.Sprintf("%d", v.UserId), + UserName: v.UserName, + UserAccount: v.UserAccount, + Mobile: v.Mobile, + WxMobile: v.WxMobile, + UserType: v.UserType, + UserStatus: v.UserStatus, + RegisterMethod: v.RegisterMethod, + Age: v.Age, + Sex: v.Sex, + Avatar: utils.AddOssDomain(v.Avatar), + LoginIP: v.LoginIp, + LastLoginAt: v.LastLoginAt, + CreatedBy: v.CreatedBy, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/UserDoctor.go b/api/dto/UserDoctor.go new file mode 100644 index 0000000..2750466 --- /dev/null +++ b/api/dto/UserDoctor.go @@ -0,0 +1,342 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" + "hospital-admin-api/utils" +) + +type UserDoctorDto 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:认证失败) + IdenAuthStatus int `json:"iden_auth_status"` // 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) + IdenAuthTime model.LocalTime `json:"iden_auth_time"` // 审核时间 + IdenAuthFailReason string `json:"iden_auth_fail_reason"` // 身份认证失败原因 + MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) + MultiPointTime model.LocalTime `json:"multi_point_time"` // 审核时间 + MultiPointFailReason string `json:"multi_point_fail_reason"` // 多点执业认证失败原因 + IsBindBank int `json:"is_bind_bank"` // 是否已绑定结算银行卡(0:否 1:是) + IsRecommend int `json:"is_recommend"` // 是否首页推荐(0:否 1:是) + 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 + HospitalName string `json:"hospital_name"` // 医院名称 + ServedPatientsNum int `json:"served_patients_num"` // 服务患者数量(订单结束时统计) + PraiseRate float64 `json:"praise_rate"` // 好评率(百分制。订单平均评价中超过4-5分的订单总数 / 总订单数 * 5) + AvgResponseTime float64 `json:"avg_response_time"` // 平均响应时间(分钟制) + NumberOfFans uint `json:"number_of_fans"` // 被关注数量 + IsOnline int `json:"is_online"` // 是否在线(0:不在线 1:在线) + IsImgExpertReception int `json:"is_img_expert_reception"` // 是否参加专家图文接诊(0:否 1:是) + IsImgWelfareReception int `json:"is_img_welfare_reception"` // 是否参加公益图文问诊(0:否 1:是) + IsImgQuickReception int `json:"is_img_quick_reception"` // 是否参加快速图文接诊(0:否 1:是) + IsPlatformDeepCooperation int `json:"is_platform_deep_cooperation"` // 是否平台深度合作医生(0:否 1:是) + IsEnterpriseDeepCooperation int `json:"is_enterprise_deep_cooperation"` // 是否企业深度合作医生(0:否 1:是) + IsSysDiagnoCooperation int `json:"is_sys_diagno_cooperation"` // 是否先思达合作医生(0:否 1:是) + QrCode string `json:"qr_code"` // 分享二维码 + BeGoodAt string `json:"be_good_at"` // 擅长 + BriefIntroduction string `json:"brief_introduction"` // 医生简介 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 + Mobile string `json:"mobile"` // 手机号 + Age uint `json:"age"` // 年龄 + Sex int `json:"sex"` // 性别(0:未知 1:男 2:女) + RegisterMethod int `json:"register_method"` // 注册方式(1:微信小程序 ) + User *UserDto `json:"user"` // 用户 + Hospital *HospitalDto `json:"hospital"` // 医院 + UserDoctorInfo *UserDoctorInfoDto `json:"user_doctor_info"` // 医生详情 + DoctorExpertise []*DoctorExpertiseDto `json:"doctor_expertise"` // 医生专长 + DoctorBankCard *DoctorBankCardDto `json:"doctor_bank_card"` // 医生银行卡 +} + +type UserDoctorPendingDto 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:认证失败) + IdenAuthStatus int `json:"iden_auth_status"` // 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) + IdenAuthTime model.LocalTime `json:"iden_auth_time"` // 审核时间 + IdenAuthFailReason *IdenAuthFailReasonDto `json:"iden_auth_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"` // 医生简介 + IsPlatformDeepCooperation int `json:"is_platform_deep_cooperation"` // 是否平台深度合作医生(0:否 1:是) + IsEnterpriseDeepCooperation int `json:"is_enterprise_deep_cooperation"` // 是否企业深度合作医生(0:否 1:是) + IsSysDiagnoCooperation int `json:"is_sys_diagno_cooperation"` // 是否先思达合作医生(0:否 1:是) + IsRecommend int `json:"is_recommend"` // 是否首页推荐(0:否 1:是) + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 + User *UserDto `json:"user"` // 用户 + Hospital *HospitalDto `json:"hospital"` // 医院 + UserDoctorInfo *UserDoctorInfoDto `json:"user_doctor_info"` // 医生详情 + DoctorExpertise []*DoctorExpertiseDto `json:"doctor_expertise"` // 医生专长 +} + +func GetUserDoctorDto(m *model.UserDoctor) *UserDoctorDto { + return &UserDoctorDto{ + DoctorID: fmt.Sprintf("%d", m.DoctorId), + UserID: fmt.Sprintf("%d", m.DoctorId), + UserName: m.UserName, + Status: m.Status, + IDCardStatus: m.Status, + IdenAuthStatus: m.IdenAuthStatus, + IdenAuthTime: m.IdenAuthTime, + IdenAuthFailReason: m.IdenAuthFailReason, + MultiPointStatus: m.MultiPointStatus, + MultiPointTime: m.MultiPointTime, + MultiPointFailReason: m.MultiPointFailReason, + IsBindBank: m.IsBindBank, + IsRecommend: m.IsRecommend, + Avatar: utils.AddOssDomain(m.Avatar), + DoctorTitle: m.DoctorTitle, + DepartmentCustomID: fmt.Sprintf("%d", m.DepartmentCustomId), + DepartmentCustomName: m.DepartmentCustomName, + DepartmentCustomMobile: m.DepartmentCustomMobile, + HospitalID: fmt.Sprintf("%d", m.HospitalID), + ServedPatientsNum: m.ServedPatientsNum, + PraiseRate: m.PraiseRate, + AvgResponseTime: m.AvgResponseTime, + NumberOfFans: m.NumberOfFans, + IsImgExpertReception: m.IsImgExpertReception, + IsImgWelfareReception: m.IsImgWelfareReception, + IsImgQuickReception: m.IsImgQuickReception, + IsPlatformDeepCooperation: m.IsPlatformDeepCooperation, + IsSysDiagnoCooperation: m.IsSysDiagnoCooperation, + QrCode: utils.AddOssDomain(m.QrCode), + BeGoodAt: m.BeGoodAt, + BriefIntroduction: m.BriefIntroduction, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetUserDoctorListDto(m []*model.UserDoctor) []*UserDoctorDto { + // 处理返回值 + responses := make([]*UserDoctorDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := &UserDoctorDto{ + DoctorID: fmt.Sprintf("%d", v.DoctorId), + UserID: fmt.Sprintf("%d", v.UserId), + UserName: v.UserName, + Status: v.Status, + IDCardStatus: v.Status, + IdenAuthStatus: v.IdenAuthStatus, + IdenAuthTime: v.IdenAuthTime, + IdenAuthFailReason: v.IdenAuthFailReason, + MultiPointStatus: v.MultiPointStatus, + MultiPointTime: v.MultiPointTime, + MultiPointFailReason: v.MultiPointFailReason, + IsBindBank: v.IsBindBank, + IsRecommend: v.IsRecommend, + Avatar: utils.AddOssDomain(v.Avatar), + DoctorTitle: v.DoctorTitle, + DepartmentCustomName: v.DepartmentCustomName, + DepartmentCustomMobile: v.DepartmentCustomMobile, + HospitalID: fmt.Sprintf("%d", v.HospitalID), + ServedPatientsNum: v.ServedPatientsNum, + PraiseRate: v.PraiseRate, + AvgResponseTime: v.AvgResponseTime, + NumberOfFans: v.NumberOfFans, + IsImgExpertReception: v.IsImgExpertReception, + IsImgWelfareReception: v.IsImgWelfareReception, + IsImgQuickReception: v.IsImgQuickReception, + IsPlatformDeepCooperation: v.IsPlatformDeepCooperation, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 加载用户属性 + if v.User != nil { + response = response.LoadUserAttr(v.User) + } + + // 加载医院名称 + if v.Hospital != nil { + response = response.LoadHospitalName(v.Hospital) + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} + +// GetUserDoctorPendingDto 审核详情 +func GetUserDoctorPendingDto(m *model.UserDoctor) *UserDoctorPendingDto { + return &UserDoctorPendingDto{ + DoctorID: fmt.Sprintf("%d", m.DoctorId), + UserID: fmt.Sprintf("%d", m.DoctorId), + UserName: m.UserName, + Status: m.Status, + IDCardStatus: m.Status, + IdenAuthStatus: m.IdenAuthStatus, + IdenAuthTime: m.IdenAuthTime, + Avatar: utils.AddOssDomain(m.Avatar), + DoctorTitle: m.DoctorTitle, + DepartmentCustomID: fmt.Sprintf("%d", m.DoctorId), + DepartmentCustomName: m.DepartmentCustomName, + DepartmentCustomMobile: m.DepartmentCustomMobile, + HospitalID: fmt.Sprintf("%d", m.DoctorId), + BeGoodAt: m.BeGoodAt, + BriefIntroduction: m.BriefIntroduction, + IsPlatformDeepCooperation: m.IsPlatformDeepCooperation, + IsEnterpriseDeepCooperation: m.IsEnterpriseDeepCooperation, + IsSysDiagnoCooperation: m.IsSysDiagnoCooperation, + IsRecommend: m.IsRecommend, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +// GetUserDoctorPendingListDto 审核列表 +func GetUserDoctorPendingListDto(m []*model.UserDoctor) []*UserDoctorDto { + // 处理返回值 + responses := make([]*UserDoctorDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := &UserDoctorDto{ + DoctorID: fmt.Sprintf("%d", v.DoctorId), + UserID: fmt.Sprintf("%d", v.UserId), + UserName: v.UserName, + Status: v.Status, + IDCardStatus: v.Status, + IdenAuthStatus: v.IdenAuthStatus, + IdenAuthTime: v.IdenAuthTime, + IdenAuthFailReason: v.IdenAuthFailReason, + Avatar: utils.AddOssDomain(v.Avatar), + DoctorTitle: v.DoctorTitle, + DepartmentCustomName: v.DepartmentCustomName, + DepartmentCustomMobile: v.DepartmentCustomMobile, + HospitalID: fmt.Sprintf("%d", v.HospitalID), + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 加载用户属性 + if v.User != nil { + response = response.LoadUserAttr(v.User) + } + + // 加载医院名称 + if v.Hospital != nil { + response = response.LoadHospitalName(v.Hospital) + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} + +// LoadUser 加载用户 +func (r *UserDoctorDto) LoadUser(m *model.User) *UserDoctorDto { + if m != nil { + userDto := GetUserDto(m) + + r.User = userDto + } + return r +} + +// LoadUser 加载用户 +func (r *UserDoctorPendingDto) LoadUser(m *model.User) *UserDoctorPendingDto { + if m != nil { + userDto := GetUserDto(m) + + r.User = userDto + } + return r +} + +// LoadUserAttr 加载用户属性 +func (r *UserDoctorDto) LoadUserAttr(m *model.User) *UserDoctorDto { + if m != nil { + r.Mobile = m.Mobile + r.RegisterMethod = m.RegisterMethod + r.Age = m.Age + r.Sex = m.Sex + } + return r +} + +// LoadHospitalName 加载医院名称 +func (r *UserDoctorDto) LoadHospitalName(m *model.Hospital) *UserDoctorDto { + if m != nil { + r.HospitalName = m.HospitalName + } + return r +} + +// LoadHospital 加载医院 +func (r *UserDoctorDto) LoadHospital(m *model.Hospital) *UserDoctorDto { + if m != nil { + r.Hospital = GetHospitalDto(m) + } + return r +} + +// LoadHospital 加载医院 +func (r *UserDoctorPendingDto) LoadHospital(m *model.Hospital) *UserDoctorPendingDto { + if m != nil { + r.Hospital = GetHospitalDto(m) + } + return r +} + +// LoadExpertise 加载医生专长 +func (r *UserDoctorDto) LoadExpertise(m *model.Hospital) *UserDoctorDto { + if m != nil { + r.Hospital = GetHospitalDto(m) + } + return r +} + +// LoadExpertise 加载医生专长 +func (r *UserDoctorPendingDto) LoadExpertise(m *model.Hospital) *UserDoctorPendingDto { + if m != nil { + r.Hospital = GetHospitalDto(m) + } + return r +} + +// LoadDoctorBankCard 加载医生银行卡 +func (r *UserDoctorDto) LoadDoctorBankCard(m *model.DoctorBankCard) *UserDoctorDto { + if m != nil { + r.DoctorBankCard = GetDoctorBankCardDto(m) + } + return r +} + +// LoadUserDoctorInfo 加载医生详情 +func (r *UserDoctorDto) LoadUserDoctorInfo(m *model.UserDoctorInfo) *UserDoctorDto { + if m != nil { + r.UserDoctorInfo = GetUserDoctorInfoDto(m) + } + return r +} + +// LoadUserDoctorInfo 加载医生详情 +func (r *UserDoctorPendingDto) LoadUserDoctorInfo(m *model.UserDoctorInfo) *UserDoctorPendingDto { + if m != nil { + r.UserDoctorInfo = GetUserDoctorInfoDto(m) + } + return r +} diff --git a/api/dto/UserDoctorInfo.go b/api/dto/UserDoctorInfo.go new file mode 100644 index 0000000..de6206f --- /dev/null +++ b/api/dto/UserDoctorInfo.go @@ -0,0 +1,166 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" + "hospital-admin-api/utils" + "strings" +) + +type UserDoctorInfoDto struct { + DoctorInfoId string `json:"doctor_info_id"` // 主键 + UserId string `json:"user_id"` // 用户id + DoctorId string `json:"doctor_id"` // 医生id + CardType int `json:"card_type"` // 类型(1:身份证 2:护照 3:港澳通行证 4:台胞证);NOT NULL + CardName string `json:"card_name"` // 证件姓名 + CardNameMask string `json:"card_name_mask"` // 证件姓名(掩码) + CardNumMask string `json:"card_num_mask"` // 证件号码(掩码) + LicenseCert []string `json:"license_cert"` // 医师执业证(逗号分隔) + QualificationCert []string `json:"qualification_cert"` // 医师资格证(逗号分隔) + QualificationCertNum string `json:"qualification_cert_num"` // 医师资格证号(逗号分隔) + WorkCert []string `json:"work_cert"` // 医师工作证(逗号分隔) + MultiPointImages []string `json:"multi_point_images"` // 多点执业备案信息(逗号分隔) + IdCardFront string `json:"id_card_front"` // 身份证正面图片 + IdCardBack string `json:"id_card_back"` // 身份证背面图片 + SignImage string `json:"sign_image"` // 签名图片 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 +} + +func GetUserDoctorInfoDto(m *model.UserDoctorInfo) *UserDoctorInfoDto { + var licenseCert []string + if m.LicenseCert != "" { + result := strings.Split(m.LicenseCert, ",") + if len(result) > 0 { + for _, v := range result { + v = utils.AddOssDomain(v) + licenseCert = append(licenseCert, v) + } + } + } + + var qualificationCert []string + if m.QualificationCert != "" { + result := strings.Split(m.QualificationCert, ",") + if len(result) > 0 { + for _, v := range result { + v = utils.AddOssDomain(v) + qualificationCert = append(qualificationCert, v) + } + } + } + + var workCert []string + if m.WorkCert != "" { + result := strings.Split(m.WorkCert, ",") + if len(result) > 0 { + for _, v := range result { + v = utils.AddOssDomain(v) + workCert = append(workCert, v) + } + } + } + + var multiPointImages []string + if m.MultiPointImages != "" { + result := strings.Split(m.MultiPointImages, ",") + if len(result) > 0 { + for _, v := range result { + multiPointImages = append(multiPointImages, v) + } + } + } + + return &UserDoctorInfoDto{ + DoctorInfoId: fmt.Sprintf("%d", m.DoctorInfoId), + UserId: fmt.Sprintf("%d", m.UserId), + DoctorId: fmt.Sprintf("%d", m.DoctorId), + CardType: m.CardType, + CardName: m.CardName, + CardNameMask: m.CardNameMask, + CardNumMask: m.CardNumMask, + LicenseCert: licenseCert, + QualificationCert: qualificationCert, + QualificationCertNum: m.QualificationCertNum, + WorkCert: workCert, + MultiPointImages: multiPointImages, + IdCardFront: utils.AddOssDomain(m.IdCardFront), + IdCardBack: utils.AddOssDomain(m.IdCardBack), + SignImage: utils.AddOssDomain(m.SignImage), + } +} + +func GetUserDoctorInfoListDto(m []*model.UserDoctorInfo) []UserDoctorInfoDto { + // 处理返回值 + responses := make([]UserDoctorInfoDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + var licenseCert []string + if v.LicenseCert != "" { + result := strings.Split(v.LicenseCert, ",") + if len(result) > 0 { + for _, v := range result { + v = utils.AddOssDomain(v) + licenseCert = append(licenseCert, v) + } + } + } + + var qualificationCert []string + if v.QualificationCert != "" { + result := strings.Split(v.QualificationCert, ",") + if len(result) > 0 { + for _, v := range result { + v = utils.AddOssDomain(v) + qualificationCert = append(qualificationCert, v) + } + } + } + + var workCert []string + if v.WorkCert != "" { + result := strings.Split(v.WorkCert, ",") + if len(result) > 0 { + for _, v := range result { + v = utils.AddOssDomain(v) + workCert = append(workCert, v) + } + } + } + + var multiPointImages []string + if v.MultiPointImages != "" { + result := strings.Split(v.MultiPointImages, ",") + if len(result) > 0 { + for _, v := range result { + multiPointImages = append(multiPointImages, v) + } + } + } + + response := UserDoctorInfoDto{ + DoctorInfoId: fmt.Sprintf("%d", v.DoctorInfoId), + UserId: fmt.Sprintf("%d", v.UserId), + DoctorId: fmt.Sprintf("%d", v.DoctorId), + CardType: v.CardType, + CardName: v.CardName, + CardNameMask: v.CardNameMask, + CardNumMask: v.CardNumMask, + LicenseCert: licenseCert, + QualificationCert: qualificationCert, + QualificationCertNum: v.QualificationCertNum, + WorkCert: workCert, + MultiPointImages: multiPointImages, + IdCardFront: utils.AddOssDomain(v.IdCardFront), + IdCardBack: utils.AddOssDomain(v.IdCardBack), + SignImage: utils.AddOssDomain(v.SignImage), + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/dto/UserPatient.go b/api/dto/UserPatient.go new file mode 100644 index 0000000..1f38d64 --- /dev/null +++ b/api/dto/UserPatient.go @@ -0,0 +1,110 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" + "hospital-admin-api/utils" +) + +type UserPatientDto struct { + PatientId string `json:"patient_id"` // 主键id + UserId string `json:"user_id"` // 用户id;NOT NULL + UserName string `json:"user_name"` // 用户名称 + Status *int `json:"status"` // 状态(0:禁用 1:正常 2:删除) + Avatar string `json:"avatar"` // 头像 + Mobile string `json:"mobile"` // 手机号 + DisableReason string `json:"disable_reason"` // 禁用理由 + PatientFamilyCount int `json:"patient_family_count"` // 家庭成员数量 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 + PatientFamily []*PatientFamilyMaskDto `json:"patient_family"` // 家庭成员 + UserShipAddress []*UserShipAddressDto `json:"user_ship_address"` // 收货地址 +} + +func GetUserPatientDto(m *model.UserPatient) *UserPatientDto { + return &UserPatientDto{ + PatientId: fmt.Sprintf("%d", m.PatientId), + UserId: fmt.Sprintf("%d", m.UserId), + UserName: m.UserName, + Status: &m.Status, + Avatar: utils.AddOssDomain(m.Avatar), + DisableReason: m.DisableReason, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} + +func GetUserPatientListDto(m []*model.UserPatient) []*UserPatientDto { + // 处理返回值 + responses := make([]*UserPatientDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := &UserPatientDto{ + PatientId: fmt.Sprintf("%d", v.PatientId), + UserId: fmt.Sprintf("%d", v.UserId), + UserName: v.UserName, + Status: &v.Status, + Avatar: utils.AddOssDomain(v.Avatar), + DisableReason: v.DisableReason, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 加载家庭成员数量 + response.LoadPatientFamilyCount(v.PatientFamily) + + // 加载患者手机号 + response.LoadPatientMaskMobile(v.User) + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} + +// LoadPatientFamilyCount 加载家庭成员数量 +func (r *UserPatientDto) LoadPatientFamilyCount(m []*model.PatientFamily) *UserPatientDto { + if len(m) > 0 { + r.PatientFamilyCount = len(m) + } + return r +} + +// LoadPatientMaskMobile 加载患者加密手机号 +func (r *UserPatientDto) LoadPatientMaskMobile(m *model.User) *UserPatientDto { + if m != nil { + r.Mobile = utils.MaskPhoneStr(m.Mobile) + } + return r +} + +// LoadPatientMobile 加载患者手机号 +func (r *UserPatientDto) LoadPatientMobile(m *model.User) *UserPatientDto { + if m != nil { + r.Mobile = m.Mobile + } + return r +} + +// LoadUserShipAddress 加载用户收货地址 +func (r *UserPatientDto) LoadUserShipAddress(m []*model.UserShipAddress) *UserPatientDto { + if len(m) > 0 { + d := GetUserShipAddressListDto(m) + + r.UserShipAddress = d + } + return r +} + +// LoadMaskPatientFamily 加载家庭成员数据-加密 +func (r *UserPatientDto) LoadMaskPatientFamily(m []*model.PatientFamily) *UserPatientDto { + if len(m) > 0 { + d := GetPatientFamilyMaskListDto(m) + + r.PatientFamily = d + } + return r +} diff --git a/api/dto/UserShipAddress.go b/api/dto/UserShipAddress.go new file mode 100644 index 0000000..e19715a --- /dev/null +++ b/api/dto/UserShipAddress.go @@ -0,0 +1,68 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type UserShipAddressDto struct { + AddressId string `json:"address_id"` // 主键id + UserId string `json:"user_id"` // 用户id;NOT NULL + ProvinceId string `json:"province_id"` // 省份id + Province string `json:"province"` // 省份 + CityId string `json:"city_id"` // 城市id + City string `json:"city"` // 城市 + CountyId string `json:"county_id"` // 区县id + County string `json:"county"` // 区县 + ConsigneeTownId string `json:"consignee_town_id"` // 镇id + ConsigneeTown string `json:"consignee_town"` // 镇 + Address string `json:"address"` // 详细地址 + AddressMask string `json:"address_mask"` // 详细地址(掩码) + ConsigneeName string `json:"consignee_name"` // 收货人姓名;NOT NULL + ConsigneeNameMask string `json:"consignee_name_mask"` // 收货人姓名(掩码) + ConsigneeTel string `json:"consignee_tel"` // 收货人电话;NOT NULL + ConsigneeTelMask string `json:"consignee_tel_mask"` // 收货人电话(掩码) + ConsigneeZipCode string `json:"consignee_zip_code"` // 收货邮编 + IsDefault *int `json:"is_default"` // 默认地址(0:否 1:是) + Tag *int `json:"tag"` // 地址标签(1:家 2:公司 3:学校 4:其他) + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetUserShipAddressListDto(m []*model.UserShipAddress) []*UserShipAddressDto { + // 处理返回值 + responses := make([]*UserShipAddressDto, len(m)) + + if len(m) > 0 { + for i, v := range m { + response := &UserShipAddressDto{ + AddressId: fmt.Sprintf("%d", v.AddressId), + UserId: fmt.Sprintf("%d", v.UserId), + ProvinceId: fmt.Sprintf("%d", v.ProvinceId), + Province: v.Province, + CityId: fmt.Sprintf("%d", v.CityId), + City: v.City, + CountyId: fmt.Sprintf("%d", v.CountyId), + County: v.County, + ConsigneeTownId: fmt.Sprintf("%d", v.ConsigneeTownId), + ConsigneeTown: v.ConsigneeTown, + Address: v.Address, + AddressMask: v.AddressMask, + ConsigneeName: v.ConsigneeName, + ConsigneeNameMask: v.ConsigneeNameMask, + ConsigneeTel: v.ConsigneeTel, + ConsigneeTelMask: v.ConsigneeTelMask, + ConsigneeZipCode: v.ConsigneeZipCode, + IsDefault: &v.IsDefault, + Tag: &v.Tag, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + responses[i] = response + } + } + + return responses +} diff --git a/api/model/orderPrescriptionProduct.go b/api/model/orderPrescriptionProduct.go new file mode 100644 index 0000000..7b3c85d --- /dev/null +++ b/api/model/orderPrescriptionProduct.go @@ -0,0 +1,44 @@ +package model + +import ( + "gorm.io/gorm" + "hospital-admin-api/global" + "time" +) + +// OrderPrescriptionProduct 订单-处方药品表 +type OrderPrescriptionProduct struct { + PrescriptionProductId int64 `gorm:"column:prescription_product_id;type:bigint(19);primary_key;comment:主键id" json:"prescription_product_id"` + OrderPrescriptionId int64 `gorm:"column:order_prescription_id;type:bigint(19);comment:订单-处方id;NOT NULL" json:"order_prescription_id"` + ProductId int64 `gorm:"column:product_id;type:bigint(19);comment:商品id;NOT NULL" json:"product_id"` + UseStatus int `gorm:"column:use_status;type:tinyint(1);default:0;comment:使用状态(1:已使用 0:未使用)" json:"use_status"` + PrescriptionProductNum int `gorm:"column:prescription_product_num;type:int(11);default:1;comment:商品数量" json:"prescription_product_num"` + ProductName string `gorm:"column:product_name;type:varchar(255);comment:商品名称" json:"product_name"` + ProductSpec string `gorm:"column:product_spec;type:varchar(255);comment:商品规格" json:"product_spec"` + LicenseNumber string `gorm:"column:license_number;type:varchar(30);comment:批准文号" json:"license_number"` + Manufacturer string `gorm:"column:manufacturer;type:varchar(255);comment:生产厂家" json:"manufacturer"` + SingleUnit string `gorm:"column:single_unit;type:varchar(50);comment:单次剂量(例:1次1包)" json:"single_unit"` + SingleUse string `gorm:"column:single_use;type:varchar(50);comment:单次用法(例:口服)" json:"single_use"` + PackagingUnit string `gorm:"column:packaging_unit;type:varchar(20);comment:基本包装单位(例:盒/瓶)" json:"packaging_unit"` + FrequencyUse string `gorm:"column:frequency_use;type:varchar(50);comment:使用频率(例:1天3次)" json:"frequency_use"` + AvailableDays int `gorm:"column:available_days;type:int(11);comment:可用天数(3)" json:"available_days"` + Model +} + +func (m *OrderPrescriptionProduct) TableName() string { + return "gdxz_order_prescription_product" +} + +func (m *OrderPrescriptionProduct) BeforeCreate(tx *gorm.DB) error { + if m.PrescriptionProductId == 0 { + m.PrescriptionProductId = global.Snowflake.Generate().Int64() + } + + m.CreatedAt = LocalTime(time.Now()) + tx.Statement.SetColumn("CreatedAt", m.CreatedAt) + + m.UpdatedAt = LocalTime(time.Now()) + tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt) + + return nil +} diff --git a/api/responses/adminUserResponse/user.go b/api/responses/adminUserResponse/user.go deleted file mode 100644 index 024f6a8..0000000 --- a/api/responses/adminUserResponse/user.go +++ /dev/null @@ -1,145 +0,0 @@ -package adminUserResponse - -import ( - "hospital-admin-api/api/model" - "hospital-admin-api/utils" - "strconv" -) - -// getUserPage 获取用户列表-分页 -type getUserPage struct { - UserID string `json:"user_id"` // 主键id - Access string `json:"access"` // 账号 - Status int `json:"status"` // 状态(1:正常 2:审核中 3:审核失败) - IsDeleted int `json:"is_deleted"` // 是否被删除(0:否 1:是) - IsDisabled int `json:"is_disabled"` // 是否被禁用(0:否 1:是) - NickName string `json:"nick_name"` // 昵称 - Phone string `json:"phone"` // 手机号 - Avatar string `json:"avatar"` // 头像 - Sex int `json:"sex"` // 性别(1:男 2:女) - Email string `json:"email"` // 邮箱 - RoleID string `json:"role_id"` // 角色id - DeptID string `json:"dept_id"` // 部门id - PostID string `json:"post_id"` // 岗位id - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 - Role *getUserPageRole `json:"role"` // 角色 - Dept *getUserPageDept `json:"dept"` // 部门 - Post *getUserPagePost `json:"post"` // 岗位 -} - -type getUserPageRole struct { - RoleId string `json:"role_id"` // 角色id - RoleName string `json:"role_name"` // 角色名称 -} - -type getUserPageDept struct { - DeptId string `json:"dept_id"` // 部门id - DeptName string `json:"dept_name"` // 部门名称 -} - -type getUserPagePost struct { - PostId string `json:"post_id"` // 岗位id - PostName string `json:"post_name"` // 岗位名称 -} - -// getUser 用户详情 -type getUser struct { - UserID string `json:"user_id"` - Access string `json:"access"` - Status int `json:"status"` - IsDeleted int `json:"is_deleted"` - IsDisabled int `json:"is_disabled"` - NickName string `json:"nick_name"` - Phone string `json:"phone"` - Avatar string `json:"avatar"` - Sex int `json:"sex"` - Email string `json:"email"` - RoleID string `json:"role_id"` - DeptID string `json:"dept_id"` - PostID string `json:"post_id"` - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 -} - -// GetUserPageResponse 获取用户列表-分页 -func GetUserPageResponse(adminUser []*model.AdminUser) []getUserPage { - // 处理返回值 - getUserPageResponses := make([]getUserPage, len(adminUser)) - - if len(adminUser) > 0 { - for i, v := range adminUser { - var role *getUserPageRole - if v.Role != nil { - role = &getUserPageRole{ - RoleId: strconv.FormatInt(v.Role.RoleId, 10), - RoleName: v.Role.RoleName, - } - } - - var dept *getUserPageDept - if v.Dept != nil { - dept = &getUserPageDept{ - DeptId: strconv.FormatInt(v.Dept.DeptId, 10), - DeptName: v.Dept.DeptName, - } - } - - var post *getUserPagePost - if v.Post != nil { - post = &getUserPagePost{ - PostId: strconv.FormatInt(v.Post.PostId, 10), - PostName: v.Post.PostName, - } - } - - // 将原始结构体转换为新结构体 - getUserPageResponse := getUserPage{ - UserID: strconv.Itoa(int(v.UserID)), - Access: v.Access, - Status: v.Status, - IsDeleted: v.IsDeleted, - IsDisabled: v.IsDisabled, - NickName: v.NickName, - Phone: v.Phone, - Avatar: utils.AddOssDomain(v.Avatar), - Sex: v.Sex, - Email: v.Email, - RoleID: strconv.Itoa(int(v.RoleID)), - DeptID: strconv.Itoa(int(v.DeptID)), - PostID: strconv.Itoa(int(v.PostID)), - CreatedAt: v.CreatedAt, - UpdatedAt: v.UpdatedAt, - Role: role, - Dept: dept, - Post: post, - } - - // 将转换后的结构体添加到新切片中 - getUserPageResponses[i] = getUserPageResponse - } - } - - return getUserPageResponses -} - -// GetUserResponse 用户详情 -func GetUserResponse(adminUser *model.AdminUser) *getUser { - return &getUser{ - UserID: strconv.FormatInt(adminUser.UserID, 10), - Access: adminUser.Access, - Status: adminUser.Status, - IsDeleted: adminUser.IsDeleted, - IsDisabled: adminUser.IsDisabled, - NickName: adminUser.NickName, - Phone: adminUser.Phone, - Avatar: utils.AddOssDomain(adminUser.Avatar), - Sex: adminUser.Sex, - Email: adminUser.Email, - RoleID: strconv.FormatInt(adminUser.RoleID, 10), - DeptID: strconv.FormatInt(adminUser.DeptID, 10), - PostID: strconv.FormatInt(adminUser.PostID, 10), - CreatedAt: adminUser.CreatedAt, - UpdatedAt: adminUser.UpdatedAt, - } -} diff --git a/api/responses/apiResponse/api.go b/api/responses/apiResponse/api.go deleted file mode 100644 index 3fedbfc..0000000 --- a/api/responses/apiResponse/api.go +++ /dev/null @@ -1,94 +0,0 @@ -package apiResponse - -import ( - "hospital-admin-api/api/model" - "strconv" -) - -// getApiPage 获取接口列表-分页 -type getApiPage struct { - APIID string `json:"api_id"` // 主键id - APIName string `json:"api_name"` // api名称 - APIPath string `json:"api_path"` // 接口路径(全路径 id为:id) - APIMethod string `json:"api_method"` // 请求类型 - IsAuth int `json:"is_auth"` // 是否验证权限(0:否 1:是) - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 -} - -// getApiList 获取接口列表 -type getApiList struct { - APIID string `json:"api_id"` // 主键id - APIName string `json:"api_name"` // api名称 -} - -// 接口详情 -type getApi struct { - APIID string `json:"api_id"` // 主键id - APIName string `json:"api_name"` // api名称 - APIPath string `json:"api_path"` // 接口路径(全路径 id为:id) - APIMethod string `json:"api_method"` // 请求类型 - IsAuth int `json:"is_auth"` // 是否验证权限(0:否 1:是) - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 -} - -// GetApiPageResponse 获取接口列表-分页 -func GetApiPageResponse(adminApi []*model.AdminAPI) []getApiPage { - // 处理返回值 - getApiPageResponses := make([]getApiPage, len(adminApi)) - - if len(adminApi) > 0 { - for i, v := range adminApi { - // 将原始结构体转换为新结构体 - getApiPageResponse := getApiPage{ - APIID: strconv.Itoa(int(v.APIID)), - APIName: v.APIName, - APIPath: v.APIPath, - APIMethod: v.APIMethod, - IsAuth: v.IsAuth, - CreatedAt: v.CreatedAt, - UpdatedAt: v.UpdatedAt, - } - - // 将转换后的结构体添加到新切片中 - getApiPageResponses[i] = getApiPageResponse - } - } - - return getApiPageResponses -} - -// GetApiListResponse 获取接口列表 -func GetApiListResponse(adminApi []*model.AdminAPI) []getApiList { - // 处理返回值 - getApiListResponses := make([]getApiList, len(adminApi)) - - if len(adminApi) > 0 { - for i, v := range adminApi { - // 将原始结构体转换为新结构体 - getApiListResponse := getApiList{ - APIID: strconv.Itoa(int(v.APIID)), - APIName: v.APIName, - } - - // 将转换后的结构体添加到新切片中 - getApiListResponses[i] = getApiListResponse - } - } - - return getApiListResponses -} - -// GetApiResponse 接口详情 -func GetApiResponse(adminApi *model.AdminAPI) *getApi { - return &getApi{ - APIID: strconv.Itoa(int(adminApi.APIID)), - APIName: adminApi.APIName, - APIPath: adminApi.APIPath, - APIMethod: adminApi.APIMethod, - IsAuth: adminApi.IsAuth, - CreatedAt: adminApi.CreatedAt, - UpdatedAt: adminApi.UpdatedAt, - } -} diff --git a/api/responses/areaResponse/area.go b/api/responses/areaResponse/area.go deleted file mode 100644 index 1469140..0000000 --- a/api/responses/areaResponse/area.go +++ /dev/null @@ -1,49 +0,0 @@ -package areaResponse - -import ( - "hospital-admin-api/api/model" - "strconv" -) - -type Area struct { - AreaId string `json:"area_id"` // 地区编号 - AreaName string `json:"area_name"` // 名称 - ParentId string `json:"parent_id"` // 上级编号 - Zip string `json:"zip"` // 邮编 - AreaType int `json:"area_type"` // 类型(1:国家,2:省,3:市,4:区县) -} - -// AreaResponse 地区详情 -func AreaResponse(area *model.Area) *Area { - return &Area{ - AreaId: strconv.FormatInt(area.AreaId, 10), - AreaName: area.AreaName, - ParentId: strconv.FormatInt(area.ParentId, 10), - Zip: area.Zip, - AreaType: area.AreaType, - } -} - -// GetAreaListResponse 获取银行列表 -func GetAreaListResponse(area []*model.Area) []Area { - // 处理返回值 - r := make([]Area, len(area)) - - if len(area) > 0 { - for i, v := range area { - // 将原始结构体转换为新结构体 - l := Area{ - AreaId: strconv.FormatInt(v.AreaId, 10), - AreaName: v.AreaName, - ParentId: strconv.FormatInt(v.ParentId, 10), - Zip: v.Zip, - AreaType: v.AreaType, - } - - // 将转换后的结构体添加到新切片中 - r[i] = l - } - } - - return r -} diff --git a/api/responses/basicBankResponse/basicBank.go b/api/responses/basicBankResponse/basicBank.go deleted file mode 100644 index d51d99f..0000000 --- a/api/responses/basicBankResponse/basicBank.go +++ /dev/null @@ -1,56 +0,0 @@ -package basicBankResponse - -import ( - "hospital-admin-api/api/model" - "hospital-admin-api/utils" - "strconv" -) - -type BasicBank struct { - BankId string `json:"bank_id"` // 主键 - BankCode string `json:"bank_code"` // 银行编码 - BankName string `json:"bank_name"` // 银行名称 - BankIconPath string `json:"bank_icon_path"` // 银行图标地址 - BankImgPath string `json:"bank_img_path"` // 银行图片地址 - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 -} - -// BasicBankResponse 银行详情 -func BasicBankResponse(basicBank *model.BasicBank) *BasicBank { - return &BasicBank{ - BankId: strconv.FormatInt(basicBank.BankId, 10), - BankCode: basicBank.BankCode, - BankName: basicBank.BankName, - BankIconPath: utils.AddOssDomain(basicBank.BankIconPath), - BankImgPath: utils.AddOssDomain(basicBank.BankImgPath), - CreatedAt: basicBank.CreatedAt, - UpdatedAt: basicBank.UpdatedAt, - } -} - -// GetBasicBankListResponse 获取银行列表 -func GetBasicBankListResponse(basicBank []*model.BasicBank) []BasicBank { - // 处理返回值 - getBasicBankListResponses := make([]BasicBank, len(basicBank)) - - if len(basicBank) > 0 { - for i, v := range basicBank { - // 将原始结构体转换为新结构体 - getBasicBankListResponse := BasicBank{ - BankId: strconv.FormatInt(v.BankId, 10), - BankCode: v.BankCode, - BankName: v.BankName, - BankIconPath: utils.AddOssDomain(v.BankIconPath), - BankImgPath: utils.AddOssDomain(v.BankImgPath), - CreatedAt: v.CreatedAt, - UpdatedAt: v.UpdatedAt, - } - - // 将转换后的结构体添加到新切片中 - getBasicBankListResponses[i] = getBasicBankListResponse - } - } - - return getBasicBankListResponses -} diff --git a/api/responses/deptResponse/dept.go b/api/responses/deptResponse/dept.go deleted file mode 100644 index 8a78e1e..0000000 --- a/api/responses/deptResponse/dept.go +++ /dev/null @@ -1,39 +0,0 @@ -package deptResponse - -import ( - "hospital-admin-api/api/model" - "strconv" -) - -// GetDeptList 获取部门列表 -type GetDeptList struct { - DeptId string `json:"dept_id"` - ParentId string `json:"parent_id"` // 父菜单ID(0表示一级) - DeptName string `json:"dept_name"` // 部门名称 - DeptStatus int `json:"dept_status"` // 部门状态(1:正常 2:删除) - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 - Children []*GetDeptList `json:"children"` // 下级页面 -} - -// GetDept 部门详情 -type getDept struct { - DeptId string `json:"dept_id"` - ParentId string `json:"parent_id"` // 父菜单ID(0表示一级) - DeptName string `json:"dept_name"` // 部门名称 - DeptStatus int `json:"dept_status"` // 部门状态(1:正常 2:删除) - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 -} - -// GetDeptResponse 部门详情 -func GetDeptResponse(adminDept *model.AdminDept) *getDept { - return &getDept{ - DeptId: strconv.Itoa(int(adminDept.DeptId)), - ParentId: strconv.Itoa(int(adminDept.ParentId)), - DeptName: adminDept.DeptName, - DeptStatus: adminDept.DeptStatus, - CreatedAt: adminDept.CreatedAt, - UpdatedAt: adminDept.UpdatedAt, - } -} diff --git a/api/responses/diseaseClassExpertiseResponse/diseaseClassExpertise.go b/api/responses/diseaseClassExpertiseResponse/diseaseClassExpertise.go deleted file mode 100644 index f9af6d2..0000000 --- a/api/responses/diseaseClassExpertiseResponse/diseaseClassExpertise.go +++ /dev/null @@ -1,49 +0,0 @@ -package diseaseClassExpertiseResponse - -import ( - "hospital-admin-api/api/model" - "strconv" -) - -type DiseaseClassExpertise struct { - ExpertiseId string `json:"expertise_id"` // 主键 - ExpertiseName string `json:"expertise_name"` // 专长名称 - ExpertiseSort int `json:"expertise_sort"` // 排序(越大排序越靠前) - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 -} - -// DiseaseClassExpertiseResponse 专长详情 -func DiseaseClassExpertiseResponse(diseaseClassExpertise *model.DiseaseClassExpertise) *DiseaseClassExpertise { - return &DiseaseClassExpertise{ - ExpertiseId: strconv.FormatInt(diseaseClassExpertise.ExpertiseId, 10), - ExpertiseName: diseaseClassExpertise.ExpertiseName, - ExpertiseSort: diseaseClassExpertise.ExpertiseSort, - CreatedAt: diseaseClassExpertise.CreatedAt, - UpdatedAt: diseaseClassExpertise.UpdatedAt, - } -} - -// GetDiseaseClassExpertiseListResponse 自定义列表 -func GetDiseaseClassExpertiseListResponse(diseaseClassExpertises []*model.DiseaseClassExpertise) []DiseaseClassExpertise { - // 处理返回值 - getDiseaseClassExpertiseListResponses := make([]DiseaseClassExpertise, len(diseaseClassExpertises)) - - if len(diseaseClassExpertises) > 0 { - for i, v := range diseaseClassExpertises { - // 将原始结构体转换为新结构体 - getDiseaseClassExpertiseListResponse := DiseaseClassExpertise{ - ExpertiseId: strconv.FormatInt(v.ExpertiseId, 10), - ExpertiseName: v.ExpertiseName, - ExpertiseSort: v.ExpertiseSort, - CreatedAt: v.CreatedAt, - UpdatedAt: v.UpdatedAt, - } - - // 将转换后的结构体添加到新切片中 - getDiseaseClassExpertiseListResponses[i] = getDiseaseClassExpertiseListResponse - } - } - - return getDiseaseClassExpertiseListResponses -} diff --git a/api/responses/hosDepCustomResponse/hospitalDepartmentCustom.go b/api/responses/hosDepCustomResponse/hospitalDepartmentCustom.go deleted file mode 100644 index f871353..0000000 --- a/api/responses/hosDepCustomResponse/hospitalDepartmentCustom.go +++ /dev/null @@ -1,52 +0,0 @@ -package hosDepCustomResponse - -import ( - "hospital-admin-api/api/model" - "strconv" -) - -type HosDepCustom struct { - DepartmentCustomId string `json:"department_custom_id"` // 主键 - DepartmentId string `json:"department_id"` // 医院科室-标准id - DepartmentCustomName string `json:"department_custom_name"` // 科室名称-自定义 - DepartmentName string `json:"department_name"` // 科室名称-标准 - DepartmentCode string `json:"department_code"` // 科室编码-标准 - DepartmentStatus int `json:"department_status"` // 状态(1:正常 2:删除) -} - -// HospitalDepartmentCustomResponse 自定义详情 -func HospitalDepartmentCustomResponse(hospitalDepartmentCustom *model.HospitalDepartmentCustom) *HosDepCustom { - return &HosDepCustom{ - DepartmentCustomId: strconv.FormatInt(hospitalDepartmentCustom.DepartmentCustomId, 10), - DepartmentId: strconv.FormatInt(hospitalDepartmentCustom.DepartmentId, 10), - DepartmentCustomName: hospitalDepartmentCustom.DepartmentCustomName, - DepartmentName: hospitalDepartmentCustom.DepartmentName, - DepartmentCode: hospitalDepartmentCustom.DepartmentCode, - DepartmentStatus: hospitalDepartmentCustom.DepartmentStatus, - } -} - -// GetHospitalDepartmentCustomListResponse 自定义列表 -func GetHospitalDepartmentCustomListResponse(hospitalDepartmentCustom []*model.HospitalDepartmentCustom) []HosDepCustom { - // 处理返回值 - getHospitalDepartmentCustomListResponses := make([]HosDepCustom, len(hospitalDepartmentCustom)) - - if len(hospitalDepartmentCustom) > 0 { - for i, v := range hospitalDepartmentCustom { - // 将原始结构体转换为新结构体 - getHospitalDepartmentCustomListResponse := HosDepCustom{ - DepartmentCustomId: strconv.FormatInt(v.DepartmentCustomId, 10), - DepartmentId: strconv.FormatInt(v.DepartmentId, 10), - DepartmentCustomName: v.DepartmentCustomName, - DepartmentName: v.DepartmentName, - DepartmentCode: v.DepartmentCode, - DepartmentStatus: v.DepartmentStatus, - } - - // 将转换后的结构体添加到新切片中 - getHospitalDepartmentCustomListResponses[i] = getHospitalDepartmentCustomListResponse - } - } - - return getHospitalDepartmentCustomListResponses -} diff --git a/api/responses/orderInquiryResponse/orderInquiry.go b/api/responses/orderInquiryResponse/orderInquiry.go index 6503350..47dc66d 100644 --- a/api/responses/orderInquiryResponse/orderInquiry.go +++ b/api/responses/orderInquiryResponse/orderInquiry.go @@ -2,15 +2,15 @@ package orderInquiryResponse import ( "fmt" + "hospital-admin-api/api/dto" "hospital-admin-api/api/model" "hospital-admin-api/api/responses/orderEvaluationResponse" "hospital-admin-api/api/responses/orderInquiryCaseResponse" "hospital-admin-api/api/responses/orderInquiryCouponResponse" "hospital-admin-api/api/responses/orderInquiryRefundResponse" - "hospital-admin-api/api/responses/userDoctorResponse" ) -// getOrderInquiryPage 获取医生列表-分页 +// getOrderInquiryPage 获取问诊列表-分页 type getOrderInquiryPage struct { OrderInquiryId string `json:"order_inquiry_id"` // 主键id UserId string `json:"user_id"` // 用户id-患者 @@ -88,12 +88,49 @@ type GetOrderInquiry struct { OrderInquiryCase *orderInquiryCaseResponse.OrderInquiryCase `json:"order_inquiry_case"` // 问诊病例 OrderInquiryRefund *orderInquiryRefundResponse.OrderInquiryRefund `json:"order_inquiry_refund"` // 退款数据 OrderEvaluation *orderEvaluationResponse.OrderEvaluation `json:"order_evaluation"` // 订单评价 - UserDoctor *userDoctorResponse.OrderInquiryUserDoctor `json:"user_doctor"` // 医生数据 + UserDoctor *dto.UserDoctorDto `json:"user_doctor"` // 医生数据 CreatedAt model.LocalTime `json:"created_at"` // 创建时间 UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 } -// GetOrderInquiryPageResponse 获取用户列表-分页 +type OrderInquiry struct { + OrderInquiryId string `json:"order_inquiry_id"` // 主键id + UserId string `json:"user_id"` // 用户id-患者 + PatientId string `json:"patient_id"` // 患者id + DoctorId string `json:"doctor_id"` // 医生id(未分配时为null) + FamilyId string `json:"family_id"` // 家庭成员id(就诊用户) + InquiryType int `json:"inquiry_type"` // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测) + InquiryMode int `json:"inquiry_mode"` // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员) + InquiryStatus int `json:"inquiry_status"` // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消) + IsDelete int `json:"is_delete"` // 删除状态(0:否 1:是) + InquiryRefundStatus int `json:"inquiry_refund_status"` // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常) + InquiryPayChannel int `json:"inquiry_pay_channel"` // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付) + InquiryPayStatus int `json:"inquiry_pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) + InquiryNo string `json:"inquiry_no"` // 系统订单编号 + EscrowTradeNo string `json:"escrow_trade_no"` // 第三方支付流水号 + AmountTotal float64 `json:"amount_total"` // 订单金额 + CouponAmountTotal float64 `json:"coupon_amount_total"` // 优惠卷总金额 + PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额 + PayTime model.LocalTime `json:"pay_time"` // 支付时间 + ReceptionTime model.LocalTime `json:"reception_time"` // 接诊时间(已接诊) + CompleteTime model.LocalTime `json:"complete_time"` // 订单完成时间(问诊完成时间) + FinishTime model.LocalTime `json:"finish_time"` // 订单结束时间 + StatisticsStatus int `json:"statistics_status"` // 订单统计状态(0:未统计 1:已统计 2:统计失败) + StatisticsTime model.LocalTime `json:"statistics_time"` // 订单统计时间 + IsWithdrawal int `json:"is_withdrawal"` // 是否提现(0:否 1:是 2:提现中) + WithdrawalTime model.LocalTime `json:"withdrawal_time"` // 提现时间 + CancelTime model.LocalTime `json:"cancel_time"` // 订单取消时间 + CancelReason int `json:"cancel_reason"` // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时) + CancelRemarks string `json:"cancel_remarks"` // 取消订单备注(自动添加) + PatientName string `json:"patient_name"` // 患者姓名-就诊人 + PatientNameMask string `json:"patient_name_mask"` // 患者姓名-就诊人(掩码) + PatientSex int `json:"patient_sex"` // 患者性别-就诊人(0:未知 1:男 2:女) + PatientAge int `json:"patient_age"` // 患者年龄-就诊人 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 +} + +// GetOrderInquiryPageResponse 获取问诊列表-分页 func GetOrderInquiryPageResponse(orderInquiry []*model.OrderInquiry) []getOrderInquiryPage { // 处理返回值 getOrderInquiryPages := make([]getOrderInquiryPage, len(orderInquiry)) diff --git a/api/responses/orderPrescriptionIcdResponse/orderPrescriptionIcd.go b/api/responses/orderPrescriptionIcdResponse/orderPrescriptionIcd.go new file mode 100644 index 0000000..20a26cd --- /dev/null +++ b/api/responses/orderPrescriptionIcdResponse/orderPrescriptionIcd.go @@ -0,0 +1,15 @@ +package orderPrescriptionIcdResponse + +import ( + "hospital-admin-api/api/model" +) + +type OrderPrescriptionIcd struct { + PrescriptionIcdId string `json:"prescription_icd_id"` // 主键id + OrderPrescriptionId string `json:"order_prescription_id"` // 订单-处方id + IcdId string `json:"icd_id"` // 疾病id(icd) + IcdName string `json:"icd_name"` // 疾病名称(icd) + IcdCode string `json:"icd_code"` // icd编码 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} diff --git a/api/responses/orderPrescriptionProductResponse/orderPrescriptionProduct.go b/api/responses/orderPrescriptionProductResponse/orderPrescriptionProduct.go new file mode 100644 index 0000000..9ef6449 --- /dev/null +++ b/api/responses/orderPrescriptionProductResponse/orderPrescriptionProduct.go @@ -0,0 +1,24 @@ +package orderPrescriptionProductResponse + +import ( + "hospital-admin-api/api/model" +) + +type OrderPrescriptionProduct struct { + PrescriptionProductId string `json:"prescription_product_id"` // 主键id + OrderPrescriptionId string `json:"order_prescription_id"` // 订单-处方id;NOT NULL + ProductId string `json:"product_id"` // 商品id;NOT NULL + UseStatus int `json:"use_status"` // 使用状态(1:已使用 0:未使用) + PrescriptionProductNum int `json:"prescription_product_num"` // 商品数量 + ProductName string `json:"product_name"` // 商品名称 + ProductSpec string `json:"product_spec"` // 商品规格 + LicenseNumber string `json:"license_number"` // 批准文号 + Manufacturer string `json:"manufacturer"` // 生产厂家 + SingleUnit string `json:"single_unit"` // 单次剂量(例:1次1包) + SingleUse string `json:"single_use"` // 单次用法(例:口服) + PackagingUnit string `json:"packaging_unit"` // 基本包装单位(例:盒/瓶) + FrequencyUse string `json:"frequency_use"` // 使用频率(例:1天3次) + AvailableDays int `json:"available_days"` // 可用天数(3) + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} diff --git a/api/responses/orderPrescriptionResponse/orderPrescription.go b/api/responses/orderPrescriptionResponse/orderPrescription.go index 49deef6..b8429f1 100644 --- a/api/responses/orderPrescriptionResponse/orderPrescription.go +++ b/api/responses/orderPrescriptionResponse/orderPrescription.go @@ -3,6 +3,7 @@ package orderPrescriptionResponse import ( "fmt" "hospital-admin-api/api/model" + "hospital-admin-api/api/responses/orderInquiryCaseResponse" "hospital-admin-api/utils" "strings" ) @@ -67,6 +68,38 @@ type getOrderPrescriptionPage struct { UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 } +// GetOrderPrescription 处方详情 +type GetOrderPrescription struct { + OrderPrescriptionId string `json:"order_prescription_id"` // 主键id + OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id;NOT NULL + DoctorId string `json:"doctor_id"` // 医生id;NOT NULL + PatientId string `json:"patient_id"` // 患者id + FamilyId string `json:"family_id"` // 家庭成员id(就诊用户) + PharmacistId string `json:"pharmacist_id"` // 药师id + PrescriptionStatus int `json:"prescription_status"` // 处方状态(1:待审核 2:待使用 3:已失效 4:已使用) + PharmacistAuditStatus int `json:"pharmacist_audit_status"` // 药师审核状态(0:审核中 1:审核成功 2:审核驳回) + PharmacistVerifyTime model.LocalTime `json:"pharmacist_verify_time"` // 药师审核时间 + PharmacistFailReason string `json:"pharmacist_fail_reason"` // 药师审核驳回原因 + PlatformAuditStatus int `json:"platform_audit_status"` // 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回) + PlatformFailTime model.LocalTime `json:"platform_fail_time"` // 平台审核失败时间 + PlatformFailReason string `json:"platform_fail_reason"` // 处方平台驳回原因 + IsAutoPharVerify int `json:"is_auto_phar_verify"` // 是否药师自动审核(0:否 1:是) + DoctorCreatedTime model.LocalTime `json:"doctor_created_time"` // 医生开具处方时间 + ExpiredTime model.LocalTime `json:"expired_time"` // 处方过期时间 + VoidTime model.LocalTime `json:"void_time"` // 处方作废时间 + IsDelete int `json:"is_delete"` // 是否删除(0:否 1:是) + PrescriptionCode string `json:"prescription_code"` // 处方编号 + DoctorName string `json:"doctor_name"` // 医生名称 + PatientName string `json:"patient_name"` // 患者姓名-就诊人 + PatientSex int `json:"patient_sex"` // 患者性别-就诊人(1:男 2:女) + PatientAge int `json:"patient_age"` // 患者年龄-就诊人 + DoctorAdvice string `json:"doctor_advice"` // 医嘱 + PharmacistName string `json:"pharmacist_name"` // 药师姓名 + OrderInquiryCase *orderInquiryCaseResponse.OrderInquiryCase `json:"order_inquiry_case"` // 问诊病例 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + // GetOrderPrescriptionPageResponse 获取处方列表-分页 func GetOrderPrescriptionPageResponse(orderPrescription []*model.OrderPrescription) []getOrderPrescriptionPage { // 处理返回值 diff --git a/api/responses/orderProductResponse/orderProduct.go b/api/responses/orderProductResponse/orderProduct.go index 1dda6bb..4917e48 100644 --- a/api/responses/orderProductResponse/orderProduct.go +++ b/api/responses/orderProductResponse/orderProduct.go @@ -89,7 +89,7 @@ type GetOrderProduct struct { OrderProductRefund *orderProductRefundResponse.OrderProductRefund `json:"order_product_refund"` // 退款数据 OrderProductItem []*orderProductItemResponse.OrderProductItem `json:"order_product_item"` // 商品数据 OrderProductLogistics *orderProductLogisticsResponse.OrderProductLogistics `json:"order_product_logistics"` // 物流数据 - UserDoctor *userDoctorResponse.OrderInquiryUserDoctor `json:"user_doctor"` // 医生数据 + UserDoctor *userDoctorResponse.GetUserDoctorById `json:"user_doctor"` // 医生数据 OrderPrescription *orderPrescriptionResponse.OrderPrescription `json:"order_prescription"` // 处方数据 OrderInquiryCase *orderInquiryCaseResponse.OrderInquiryCase `json:"order_inquiry_case"` // 问诊病例 } diff --git a/api/responses/patientFamilyResponse/patientFamily.go b/api/responses/patientFamilyResponse/patientFamily.go index e43a6db..df6102d 100644 --- a/api/responses/patientFamilyResponse/patientFamily.go +++ b/api/responses/patientFamilyResponse/patientFamily.go @@ -1,10 +1,8 @@ package patientFamilyResponse import ( - "fmt" "hospital-admin-api/api/model" "hospital-admin-api/api/responses/userResponse" - "hospital-admin-api/utils" ) type PatientFamily struct { @@ -99,60 +97,3 @@ type GetPatientFamily struct { CreatedAt model.LocalTime `json:"created_at"` // 创建时间 UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 } - -// GetUserPatientResponse 获取患者详情 -func GetUserPatientResponse(patientFamilys []*model.PatientFamily) []*GetUserPatient { - // 处理返回值 - items := make([]*GetUserPatient, len(patientFamilys)) - - if len(patientFamilys) > 0 { - for i, v := range patientFamilys { - // 将原始结构体转换为新结构体 - item := &GetUserPatient{ - FamilyId: fmt.Sprintf("%d", v.FamilyId), - PatientId: fmt.Sprintf("%d", v.PatientId), - Relation: v.Relation, - Status: &v.Status, - IsDefault: &v.IsDefault, - CardNameMask: v.CardNameMask, - IdNumberMask: v.IdNumberMask, - Sex: &v.Sex, - Age: v.Age, - CreatedAt: v.CreatedAt, - UpdatedAt: v.UpdatedAt, - } - - // 将转换后的结构体添加到新切片中 - items[i] = item - } - } - - return items -} - -// GetPatientFamilyPageResponse 获取用户列表-分页 -func GetPatientFamilyPageResponse(patientFamily []*model.PatientFamily) []getPatientFamilyPage { - // 处理返回值 - patientFamilyResponses := make([]getPatientFamilyPage, len(patientFamily)) - - if len(patientFamily) > 0 { - for i, v := range patientFamily { - // 将原始结构体转换为新结构体 - patientFamilyResponse := getPatientFamilyPage{ - FamilyId: fmt.Sprintf("%d", v.FamilyId), - PatientId: fmt.Sprintf("%d", v.PatientId), - Relation: v.Relation, - Status: &v.Status, - CardName: v.CardName, - MobileMask: utils.MaskPhoneStr(v.UserPatient.User.Mobile), - UserName: v.UserPatient.UserName, - CreatedAt: v.CreatedAt, - UpdatedAt: v.UpdatedAt, - } - - // 将转换后的结构体添加到新切片中 - patientFamilyResponses[i] = patientFamilyResponse - } - } - return patientFamilyResponses -} diff --git a/api/responses/postResponse/post.go b/api/responses/postResponse/post.go deleted file mode 100644 index 3117dbe..0000000 --- a/api/responses/postResponse/post.go +++ /dev/null @@ -1,92 +0,0 @@ -package postResponse - -import ( - "hospital-admin-api/api/model" - "strconv" -) - -// getPostPage 获取岗位列表-分页 -type getPostPage struct { - PostId string `json:"post_id"` // 主键id - PostName string `json:"post_name"` // 岗位名称 - PostStatus int `json:"post_status"` // 岗位状态(1:正常 2:删除) - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 -} - -// getPostList 获取岗位列表 -type getPostList struct { - PostId string `json:"post_id"` // 主键id - PostName string `json:"post_name"` // 岗位名称 - PostStatus int `json:"post_status"` // 岗位状态(1:正常 2:删除) - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 -} - -// GetPost 岗位详情 -type GetPost struct { - PostId string `json:"post_id"` // 主键id - PostName string `json:"post_name"` // 岗位名称 - PostStatus int `json:"post_status"` // 岗位状态(1:正常 2:删除) - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 -} - -// GetPostPageResponse 获取接口列表-分页 -func GetPostPageResponse(adminPost []*model.AdminPost) []getPostPage { - // 处理返回值 - getPostPageResponses := make([]getPostPage, len(adminPost)) - - if len(adminPost) > 0 { - for i, v := range adminPost { - // 将原始结构体转换为新结构体 - getPostPageResponse := getPostPage{ - PostId: strconv.Itoa(int(v.PostId)), - PostName: v.PostName, - PostStatus: v.PostStatus, - CreatedAt: v.CreatedAt, - UpdatedAt: v.UpdatedAt, - } - - // 将转换后的结构体添加到新切片中 - getPostPageResponses[i] = getPostPageResponse - } - } - - return getPostPageResponses -} - -// GetPostResponse 部门详情 -func GetPostResponse(adminPost *model.AdminPost) *GetPost { - return &GetPost{ - PostId: strconv.Itoa(int(adminPost.PostId)), - PostName: adminPost.PostName, - PostStatus: adminPost.PostStatus, - CreatedAt: adminPost.CreatedAt, - UpdatedAt: adminPost.UpdatedAt, - } -} - -// GetPostListResponse 获取角色列表 -func GetPostListResponse(adminPost []*model.AdminPost) []getPostList { - // 处理返回值 - getPostListResponses := make([]getPostList, len(adminPost)) - - if len(adminPost) > 0 { - for i, v := range adminPost { - // 将原始结构体转换为新结构体 - getPostListResponse := getPostList{ - PostId: strconv.Itoa(int(v.PostId)), - PostName: v.PostName, - PostStatus: v.PostStatus, - CreatedAt: v.CreatedAt, - UpdatedAt: v.UpdatedAt, - } - - // 将转换后的结构体添加到新切片中 - getPostListResponses[i] = getPostListResponse - } - } - - return getPostListResponses -} diff --git a/api/responses/roleResponse/role.go b/api/responses/roleResponse/role.go deleted file mode 100644 index 65d5133..0000000 --- a/api/responses/roleResponse/role.go +++ /dev/null @@ -1,76 +0,0 @@ -package roleResponse - -import ( - "hospital-admin-api/api/model" - "strconv" -) - -// GetRoleMenuList 角色菜单列表 -type GetRoleMenuList struct { - MenuId string `json:"menu_id"` // 主键id - MenuName string `json:"menu_name"` // 菜单名称 - MenuTitle string `json:"menu_title"` // 菜单名称 - ParentId string `json:"parent_id"` // 父菜单ID(0表示一级) - MenuStatus int `json:"menu_status"` // 菜单状态(0:隐藏 1:正常)此优先级最高 - MenuType int `json:"menu_type"` // 菜单类型(1:模块 2:菜单 3:按钮) - Permission string `json:"permission"` // 标识 - OrderNum int `json:"order_num"` // 显示顺序 - Icon string `json:"icon"` // 图标地址 - Path string `json:"path"` // 页面地址(#表示当前页) - Component string `json:"component"` // 组件名称 - Children []*GetRoleMenuList `json:"children"` // 下级页面 -} - -// GetRole 角色详情 -type GetRole struct { - MenuIds []string `json:"menu_ids"` // 菜单id - RoleId string `json:"role_id"` // 角色id - RoleName string `json:"role_name"` // 角色名称 - RoleStatus int `json:"role_status"` // 角色状态(1:正常 2:禁用) - IsAdmin int `json:"is_admin"` // 是否管理员(0:否 1:是) -} - -// GetRolePage 获取角色列表-分页 -type GetRolePage struct { - RoleId string `json:"role_id"` // 角色id - RoleName string `json:"role_name"` // 角色名称 - RoleStatus int `json:"role_status"` // 角色状态(1:正常 2:禁用) - IsAdmin int `json:"is_admin"` // 是否管理员(0:否 1:是) - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 -} - -// GetRoleList 获取角色列表 -type GetRoleList struct { - RoleId string `json:"role_id"` // 角色id - RoleName string `json:"role_name"` // 角色名称 - RoleStatus int `json:"role_status"` // 角色状态(1:正常 2:禁用) - IsAdmin int `json:"is_admin"` // 是否管理员(0:否 1:是) - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 -} - -// GetRoleListResponse 获取角色列表 -func GetRoleListResponse(adminRole []*model.AdminRole) []GetRoleList { - // 处理返回值 - getRoleListResponses := make([]GetRoleList, len(adminRole)) - - if len(adminRole) > 0 { - for i, v := range adminRole { - // 将原始结构体转换为新结构体 - getRoleListResponse := GetRoleList{ - RoleId: strconv.Itoa(int(v.RoleId)), - RoleName: v.RoleName, - RoleStatus: v.RoleStatus, - IsAdmin: v.IsAdmin, - CreatedAt: v.CreatedAt, - UpdatedAt: v.UpdatedAt, - } - - // 将转换后的结构体添加到新切片中 - getRoleListResponses[i] = getRoleListResponse - } - } - - return getRoleListResponses -} diff --git a/api/responses/userDoctorInfoResponse/userDoctorInfo.go b/api/responses/userDoctorInfoResponse/userDoctorInfo.go index a9154bb..d98a607 100644 --- a/api/responses/userDoctorInfoResponse/userDoctorInfo.go +++ b/api/responses/userDoctorInfoResponse/userDoctorInfo.go @@ -2,9 +2,6 @@ package userDoctorInfoResponse import ( "hospital-admin-api/api/model" - "hospital-admin-api/utils" - "strconv" - "strings" ) type UserDoctorInfo struct { @@ -26,67 +23,3 @@ type UserDoctorInfo struct { CreatedAt model.LocalTime `json:"created_at"` // 创建时间 UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 } - -// UserDoctorInfoResponse 医生详情 -func UserDoctorInfoResponse(userDoctorInfo *model.UserDoctorInfo) *UserDoctorInfo { - var licenseCert []string - if userDoctorInfo.LicenseCert != "" { - result := strings.Split(userDoctorInfo.LicenseCert, ",") - if len(result) > 0 { - for _, v := range result { - v = utils.AddOssDomain(v) - licenseCert = append(licenseCert, v) - } - } - } - - var qualificationCert []string - if userDoctorInfo.QualificationCert != "" { - result := strings.Split(userDoctorInfo.QualificationCert, ",") - if len(result) > 0 { - for _, v := range result { - v = utils.AddOssDomain(v) - qualificationCert = append(qualificationCert, v) - } - } - } - - var workCert []string - if userDoctorInfo.WorkCert != "" { - result := strings.Split(userDoctorInfo.WorkCert, ",") - if len(result) > 0 { - for _, v := range result { - v = utils.AddOssDomain(v) - workCert = append(workCert, v) - } - } - } - - var multiPointImages []string - if userDoctorInfo.MultiPointImages != "" { - result := strings.Split(userDoctorInfo.MultiPointImages, ",") - if len(result) > 0 { - for _, v := range result { - multiPointImages = append(multiPointImages, v) - } - } - } - - return &UserDoctorInfo{ - DoctorInfoId: strconv.FormatInt(userDoctorInfo.DoctorInfoId, 10), - UserId: strconv.FormatInt(userDoctorInfo.UserId, 10), - DoctorId: strconv.FormatInt(userDoctorInfo.DoctorId, 10), - CardType: userDoctorInfo.CardType, - CardName: userDoctorInfo.CardName, - CardNameMask: userDoctorInfo.CardNameMask, - CardNumMask: userDoctorInfo.CardNumMask, - LicenseCert: licenseCert, - QualificationCert: qualificationCert, - QualificationCertNum: userDoctorInfo.QualificationCertNum, - WorkCert: workCert, - MultiPointImages: multiPointImages, - IdCardFront: utils.AddOssDomain(userDoctorInfo.IdCardFront), - IdCardBack: utils.AddOssDomain(userDoctorInfo.IdCardBack), - SignImage: utils.AddOssDomain(userDoctorInfo.SignImage), - } -} diff --git a/api/responses/userDoctorResponse/userDoctor.go b/api/responses/userDoctorResponse/userDoctor.go index c3a3689..7b21141 100644 --- a/api/responses/userDoctorResponse/userDoctor.go +++ b/api/responses/userDoctorResponse/userDoctor.go @@ -1,256 +1,13 @@ package userDoctorResponse import ( + "hospital-admin-api/api/dto" "hospital-admin-api/api/model" - "hospital-admin-api/api/responses/doctorBankCardResponse" - "hospital-admin-api/api/responses/doctorExpertiseResponse" - "hospital-admin-api/api/responses/hospitalResponse" "hospital-admin-api/api/responses/userDoctorInfoResponse" - "hospital-admin-api/api/responses/userResponse" - "hospital-admin-api/utils" - "strconv" ) -// getUserDoctorPage 获取医生列表-分页 -type getUserDoctorPage 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:认证失败) - IdenAuthStatus int `json:"iden_auth_status"` // 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) - IdenAuthTime model.LocalTime `json:"iden_auth_time"` // 审核时间 - IdenAuthFailReason string `json:"iden_auth_fail_reason"` // 身份认证失败原因 - MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) - MultiPointTime model.LocalTime `json:"multi_point_time"` // 审核时间 - MultiPointFailReason string `json:"multi_point_fail_reason"` // 多点执业认证失败原因 - IsBindBank int `json:"is_bind_bank"` // 是否已绑定结算银行卡(0:否 1:是) - IsRecommend int `json:"is_recommend"` // 是否首页推荐(0:否 1:是) - 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"` // 医院名称 - ServedPatientsNum int `json:"served_patients_num"` // 服务患者数量(订单结束时统计) - PraiseRate float64 `json:"praise_rate"` // 好评率(百分制。订单平均评价中超过4-5分的订单总数 / 总订单数 * 5) - AvgResponseTime float64 `json:"avg_response_time"` // 平均响应时间(分钟制) - NumberOfFans uint `json:"number_of_fans"` // 被关注数量 - IsImgExpertReception int `json:"is_img_expert_reception"` // 是否参加专家图文接诊(0:否 1:是) - IsImgWelfareReception int `json:"is_img_welfare_reception"` // 是否参加公益图文问诊(0:否 1:是) - IsImgQuickReception int `json:"is_img_quick_reception"` // 是否参加快速图文接诊(0:否 1:是) - IsPlatformDeepCooperation int `json:"is_platform_deep_cooperation"` // 是否平台深度合作医生(0:否 1:是) - Mobile string `json:"mobile"` // 手机号 - RegisterMethod int `json:"register_method"` // 注册方式(1:微信小程序 ) - Age uint `json:"age"` // 年龄 - Sex int `json:"sex"` // 性别(0:未知 1:男 2:女) - CreatedAt model.LocalTime `json:"created_at"` // 创建时间 - UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 -} - -// GetUserDoctor 医生详情 -type GetUserDoctor 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:认证失败) - IdenAuthStatus int `json:"iden_auth_status"` // 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) - IdenAuthTime model.LocalTime `json:"iden_auth_time"` // 审核时间 - IdenAuthFailReason string `json:"iden_auth_fail_reason"` // 身份认证失败原因 - MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) - MultiPointTime model.LocalTime `json:"multi_point_time"` // 审核时间 - MultiPointFailReason string `json:"multi_point_fail_reason"` // 多点执业认证失败原因 - IsBindBank int `json:"is_bind_bank"` // 是否已绑定结算银行卡(0:否 1:是) - IsRecommend int `json:"is_recommend"` // 是否首页推荐(0:否 1:是) - 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 - ServedPatientsNum int `json:"served_patients_num"` // 服务患者数量(订单结束时统计) - PraiseRate float64 `json:"praise_rate"` // 好评率(百分制。订单平均评价中超过4-5分的订单总数 / 总订单数 * 5) - AvgResponseTime float64 `json:"avg_response_time"` // 平均响应时间(分钟制) - NumberOfFans uint `json:"number_of_fans"` // 被关注数量 - IsOnline int `json:"is_online"` // 是否在线(0:不在线 1:在线) - IsImgExpertReception int `json:"is_img_expert_reception"` // 是否参加专家图文接诊(0:否 1:是) - IsImgWelfareReception int `json:"is_img_welfare_reception"` // 是否参加公益图文问诊(0:否 1:是) - IsImgQuickReception int `json:"is_img_quick_reception"` // 是否参加快速图文接诊(0:否 1:是) - IsPlatformDeepCooperation int `json:"is_platform_deep_cooperation"` // 是否平台深度合作医生(0:否 1:是) - IsEnterpriseDeepCooperation int `json:"is_enterprise_deep_cooperation"` // 是否企业深度合作医生(0:否 1:是) - IsSysDiagnoCooperation int `json:"is_sys_diagno_cooperation"` // 是否先思达合作医生(0:否 1:是) - QrCode string `json:"qr_code"` // 分享二维码 - 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"` // 医生专长 - DoctorBankCard doctorBankCardResponse.DoctorBankCard `json:"doctor_bank_card"` // 医生银行卡 -} - -// UserDoctor 医生详情 -type UserDoctor 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:认证失败) - IdenAuthStatus int `json:"iden_auth_status"` // 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) - IdenAuthTime model.LocalTime `json:"iden_auth_time"` // 审核时间 - IdenAuthFailReason string `json:"iden_auth_fail_reason"` // 身份认证失败原因 - MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) - MultiPointTime model.LocalTime `json:"multi_point_time"` // 审核时间 - MultiPointFailReason string `json:"multi_point_fail_reason"` // 多点执业认证失败原因 - IsBindBank int `json:"is_bind_bank"` // 是否已绑定结算银行卡(0:否 1:是) - IsRecommend int `json:"is_recommend"` // 是否首页推荐(0:否 1:是) - 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 - ServedPatientsNum int `json:"served_patients_num"` // 服务患者数量(订单结束时统计) - PraiseRate float64 `json:"praise_rate"` // 好评率(百分制。订单平均评价中超过4-5分的订单总数 / 总订单数 * 5) - AvgResponseTime float64 `json:"avg_response_time"` // 平均响应时间(分钟制) - NumberOfFans uint `json:"number_of_fans"` // 被关注数量 - IsOnline int `json:"is_online"` // 是否在线(0:不在线 1:在线) - IsImgExpertReception int `json:"is_img_expert_reception"` // 是否参加专家图文接诊(0:否 1:是) - IsImgWelfareReception int `json:"is_img_welfare_reception"` // 是否参加公益图文问诊(0:否 1:是) - IsImgQuickReception int `json:"is_img_quick_reception"` // 是否参加快速图文接诊(0:否 1:是) - IsPlatformDeepCooperation int `json:"is_platform_deep_cooperation"` // 是否平台深度合作医生(0:否 1:是) - IsEnterpriseDeepCooperation int `json:"is_enterprise_deep_cooperation"` // 是否企业深度合作医生(0:否 1:是) - IsSysDiagnoCooperation int `json:"is_sys_diagno_cooperation"` // 是否先思达合作医生(0:否 1:是) - QrCode string `json:"qr_code"` // 分享二维码 - 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"` // 医生专长 - DoctorBankCard doctorBankCardResponse.DoctorBankCard `json:"doctor_bank_card"` // 医生银行卡 -} - -// getUserDoctorPendingPage 身份审核-获取医生列表-分页 -type getUserDoctorPendingPage 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:认证失败) - IdenAuthStatus int `json:"iden_auth_status"` // 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) - IdenAuthTime model.LocalTime `json:"iden_auth_time"` // 审核时间 - IdenAuthFailReason string `json:"iden_auth_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"` // 更新时间 -} - -// 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 - UserName string `json:"user_name"` // 用户名称 - Status int `json:"status"` // 状态(0:禁用 1:正常 2:删除) - IDCardStatus int `json:"idcard_status"` // 实名认证状态(0:未认证 1:认证通过 2:认证失败) - IdenAuthStatus int `json:"iden_auth_status"` // 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) - IdenAuthTime model.LocalTime `json:"iden_auth_time"` // 审核时间 - IdenAuthFailReason *IdenAuthFailReason `json:"iden_auth_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"` // 医生简介 - IsPlatformDeepCooperation int `json:"is_platform_deep_cooperation"` // 是否平台深度合作医生(0:否 1:是) - IsEnterpriseDeepCooperation int `json:"is_enterprise_deep_cooperation"` // 是否企业深度合作医生(0:否 1:是) - IsSysDiagnoCooperation int `json:"is_sys_diagno_cooperation"` // 是否先思达合作医生(0:否 1:是) - IsRecommend int `json:"is_recommend"` // 是否首页推荐(0:否 1:是) - 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"` // 医生专长 -} - -// IdenAuthFailReason 身份认证失败原因 -type IdenAuthFailReason struct { - AvatarReason string `json:"avatar_reason"` // 头像失败原因 - DepartmentCustomMobileReason string `json:"department_custom_mobile_reason"` // 科室电话失败原因 - DepartmentCustomNameReason string `json:"department_custom_name_reason"` // 科室名称失败原因 - BriefIntroductionReason string `json:"brief_introduction_reason"` // 医生简介失败原因 - BeGoodAtReason string `json:"be_good_at_reason"` // 医生简介失败原因 - LicenseCertReason string `json:"license_cert_reason"` // 医师执业证失败原因 - QualificationCertReason string `json:"qualification_cert_reason"` // 医师资格证失败原因 - 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"` // 医生详情 -} - -// OrderInquiryUserDoctor 订单-医生详情 -type OrderInquiryUserDoctor struct { +// GetUserDoctorById 医生详情-医生id +type GetUserDoctorById struct { DoctorID string `json:"doctor_id"` // 主键id UserID string `json:"user_id"` // 用户id UserName string `json:"user_name"` // 用户名称 @@ -263,152 +20,6 @@ type OrderInquiryUserDoctor struct { HospitalID string `json:"hospital_id"` // 所属医院id CreatedAt model.LocalTime `json:"created_at"` // 创建时间 UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 - Hospital *hospitalResponse.Hospital `json:"hospital"` // 医院 + Hospital *dto.HospitalDto `json:"hospital"` // 医院 UserDoctorInfo *userDoctorInfoResponse.UserDoctorInfo `json:"user_doctor_info"` // 医生详情 } - -// GetUserDoctorPageResponse 获取用户列表-分页 -func GetUserDoctorPageResponse(userDoctor []*model.UserDoctor) []getUserDoctorPage { - // 处理返回值 - getUserPageResponses := make([]getUserDoctorPage, len(userDoctor)) - - if len(userDoctor) > 0 { - for i, v := range userDoctor { - // 将原始结构体转换为新结构体 - getUserDoctorPageResponse := getUserDoctorPage{ - DoctorID: strconv.Itoa(int(v.DoctorId)), - UserID: strconv.Itoa(int(v.UserId)), - UserName: v.UserName, - Status: v.Status, - IDCardStatus: v.Status, - IdenAuthStatus: v.IdenAuthStatus, - IdenAuthTime: v.IdenAuthTime, - IdenAuthFailReason: v.IdenAuthFailReason, - MultiPointStatus: v.MultiPointStatus, - MultiPointTime: v.MultiPointTime, - MultiPointFailReason: v.MultiPointFailReason, - IsBindBank: v.IsBindBank, - IsRecommend: v.IsRecommend, - Avatar: utils.AddOssDomain(v.Avatar), - DoctorTitle: v.DoctorTitle, - DepartmentCustomName: v.DepartmentCustomName, - DepartmentCustomMobile: v.DepartmentCustomMobile, - HospitalID: strconv.Itoa(int(v.HospitalID)), - ServedPatientsNum: v.ServedPatientsNum, - PraiseRate: v.PraiseRate, - AvgResponseTime: v.AvgResponseTime, - NumberOfFans: v.NumberOfFans, - IsImgExpertReception: v.IsImgExpertReception, - IsImgWelfareReception: v.IsImgWelfareReception, - IsImgQuickReception: v.IsImgQuickReception, - IsPlatformDeepCooperation: v.IsPlatformDeepCooperation, - CreatedAt: v.CreatedAt, - UpdatedAt: v.UpdatedAt, - } - - if v.User != nil { - getUserDoctorPageResponse.Mobile = v.User.Mobile - getUserDoctorPageResponse.RegisterMethod = v.User.RegisterMethod - getUserDoctorPageResponse.Age = v.User.Age - getUserDoctorPageResponse.Sex = v.User.Sex - } - - if v.Hospital != nil { - getUserDoctorPageResponse.HospitalName = v.Hospital.HospitalName - } - - // 将转换后的结构体添加到新切片中 - getUserPageResponses[i] = getUserDoctorPageResponse - } - } - - return getUserPageResponses -} - -// GetUserDoctorPendingPageResponse 身份审核-获取医生列表-分页 -func GetUserDoctorPendingPageResponse(userDoctor []*model.UserDoctor) []getUserDoctorPendingPage { - // 处理返回值 - getUserDoctorPendingPageResponses := make([]getUserDoctorPendingPage, len(userDoctor)) - - if len(userDoctor) > 0 { - for i, v := range userDoctor { - // 将原始结构体转换为新结构体 - getUserDoctorPageResponse := getUserDoctorPendingPage{ - DoctorID: strconv.Itoa(int(v.DoctorId)), - UserID: strconv.Itoa(int(v.UserId)), - UserName: v.UserName, - Status: v.Status, - IDCardStatus: v.Status, - IdenAuthStatus: v.IdenAuthStatus, - IdenAuthTime: v.IdenAuthTime, - IdenAuthFailReason: v.IdenAuthFailReason, - Avatar: utils.AddOssDomain(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 { - getUserDoctorPageResponse.Mobile = v.User.Mobile - getUserDoctorPageResponse.Age = v.User.Age - getUserDoctorPageResponse.Sex = v.User.Sex - } - - if v.Hospital != nil { - getUserDoctorPageResponse.HospitalName = v.Hospital.HospitalName - } - - // 将转换后的结构体添加到新切片中 - getUserDoctorPendingPageResponses[i] = getUserDoctorPageResponse - } - } - - 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: utils.AddOssDomain(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 -} diff --git a/api/responses/userPatientResponse/userPatient.go b/api/responses/userPatientResponse/userPatient.go index 7fcdce1..97f660e 100644 --- a/api/responses/userPatientResponse/userPatient.go +++ b/api/responses/userPatientResponse/userPatient.go @@ -1,11 +1,9 @@ package userPatientResponse import ( - "fmt" "hospital-admin-api/api/model" "hospital-admin-api/api/responses/patientFamilyResponse" "hospital-admin-api/api/responses/userShipAddressResponse" - "hospital-admin-api/utils" ) // getUserPatientPage 获取患者列表-分页 @@ -36,38 +34,3 @@ type GetUserPatient struct { CreatedAt model.LocalTime `json:"created_at"` // 创建时间 UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 } - -// GetUserPatientPageResponse 获取用户列表-分页 -func GetUserPatientPageResponse(userPatient []*model.UserPatient) []getUserPatientPage { - // 处理返回值 - responses := make([]getUserPatientPage, len(userPatient)) - - if len(userPatient) > 0 { - for i, v := range userPatient { - // 将原始结构体转换为新结构体 - response := getUserPatientPage{ - PatientId: fmt.Sprintf("%d", v.PatientId), - UserId: fmt.Sprintf("%d", v.UserId), - UserName: v.UserName, - Status: v.Status, - Avatar: utils.AddOssDomain(v.Avatar), - DisableReason: v.DisableReason, - CreatedAt: v.CreatedAt, - UpdatedAt: v.UpdatedAt, - } - - if v.PatientFamily != nil { - response.PatientFamilyCount = len(v.PatientFamily) - } - - if v.User != nil { - response.Mobile = utils.MaskPhoneStr(v.User.Mobile) - } - - // 将转换后的结构体添加到新切片中 - responses[i] = response - } - } - - return responses -} diff --git a/api/router/router.go b/api/router/router.go index d40d7a6..b058a06 100644 --- a/api/router/router.go +++ b/api/router/router.go @@ -435,7 +435,6 @@ func privateRouter(r *gin.Engine, api controller.Api) { // 就诊人详情 patientFamilyGroup.GET("/:family_id", api.PatientFamily.GetPatientFamily) - } } @@ -446,6 +445,6 @@ func privateRouter(r *gin.Engine, api controller.Api) { prescriptionGroup.GET("", api.OrderPrescription.GetOrderPrescriptionPage) // 处方详情 - prescriptionGroup.GET("/:patient_id", api.OrderPrescription.GetOrderPrescriptionPage) + prescriptionGroup.GET("/:order_prescription_id", api.OrderPrescription.GetOrderPrescription) } } diff --git a/api/service/OrderInquiry.go b/api/service/OrderInquiry.go index 78fd452..b352381 100644 --- a/api/service/OrderInquiry.go +++ b/api/service/OrderInquiry.go @@ -5,11 +5,10 @@ import ( "fmt" "gorm.io/gorm" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/model" "hospital-admin-api/api/requests" - "hospital-admin-api/api/responses/orderEvaluationResponse" - "hospital-admin-api/api/responses/orderInquiryCouponResponse" - "hospital-admin-api/api/responses/orderInquiryRefundResponse" + "hospital-admin-api/api/responses/orderInquiryCaseResponse" "hospital-admin-api/api/responses/orderInquiryResponse" "hospital-admin-api/config" "hospital-admin-api/extend/weChat" @@ -272,7 +271,7 @@ func ReturnInquiryCoupon(tx *gorm.DB, orderInquiryId int64) bool { } // GetOrderInquiry 问诊订单详情 -func (r *OrderInquiryService) GetOrderInquiry(orderInquiryId int64) (getOrderInquiryResponse *orderInquiryResponse.GetOrderInquiry, err error) { +func (r *OrderInquiryService) GetOrderInquiry(orderInquiryId int64) (g *dto.OrderInquiryDto, err error) { // 获取问诊订单数据 orderInquiryDao := dao.OrderInquiryDao{} orderInquiry, err := orderInquiryDao.GetOrderInquiryPreloadById(orderInquiryId) @@ -281,48 +280,91 @@ func (r *OrderInquiryService) GetOrderInquiry(orderInquiryId int64) (getOrderInq } // 获取问诊订单优惠卷 - orderInquiryCoupon, err := r.GetOrderInquiryCoupon(orderInquiryId) - if err != nil { - return nil, errors.New(err.Error()) - } + orderInquiryCouponDao := dao.OrderInquiryCouponDao{} + orderInquiryCoupon, err := orderInquiryCouponDao.GetOrderInquiryCouponByOrderInquiryId(orderInquiryId) // 获取问诊病例 - orderInquiryCaseService := OrderInquiryCaseService{} - orderInquiryCase, err := orderInquiryCaseService.GetOrderInquiryCaseByOrderInquiryId(orderInquiryId) - if err != nil { - return nil, errors.New(err.Error()) + orderInquiryCaseDao := dao.OrderInquiryCaseDao{} + orderInquiryCase, err := orderInquiryCaseDao.GetOrderInquiryCaseByOrderInquiryId(orderInquiryId) + if orderInquiryCase == nil { + return nil, errors.New("数据错误,无问诊病例") } // 获取退款数据 - orderInquiryRefund, err := r.GetOrderInquiryRefund(orderInquiryId) - if err != nil { - return nil, errors.New(err.Error()) - } + orderInquiryRefundDao := dao.OrderInquiryRefundDao{} + orderInquiryRefund, err := orderInquiryRefundDao.GetOrderInquiryRefundByOrderInquiryId(orderInquiryId) // 获取订单评价 - orderEvaluation, err := r.GetOrderEvaluation(orderInquiryId) - if err != nil { - return nil, errors.New(err.Error()) + orderEvaluationDao := dao.OrderEvaluationDao{} + orderEvaluation, err := orderEvaluationDao.GetOrderEvaluationByOrderInquiryId(orderInquiryId) + if orderEvaluation == nil { + return nil, nil } // 医生数据 userDoctorService := UserDoctorService{} - userDoctor, err := userDoctorService.GetOrderInquiryUserDoctor(orderInquiry.DoctorId) + userDoctor, err := userDoctorService.GetUserDoctorById(orderInquiry.DoctorId) if err != nil { return nil, errors.New(err.Error()) } - // 处理医生id - var doctorId string - if orderInquiry.DoctorId != 0 { - doctorId = fmt.Sprintf("%v", orderInquiry.DoctorId) + // 处理返回值 + g = dto.GetOrderInquiryDto(orderInquiry) + + // 加载医生数据 + g.UserDoctor = userDoctor + + // 加载订单退款数据 + g.LoadOrderInquiryRefund(orderInquiryRefund) + + // 加载问诊订单优惠卷 + g.LoadOrderInquiryCoupon(orderInquiryCoupon) + + // 加载问诊病例 + g.LoadOrderInquiryCase(orderInquiryCase) + + // 加载订单评价 + g.LoadOrderEvaluation(orderEvaluation) + return g, nil +} + +// GetOrderInquiryCaseByOrderInquiryId 获取问诊订单病例-问诊订单 +func (r *OrderInquiryService) GetOrderInquiryCaseByOrderInquiryId(orderInquiryId int64) (u *orderInquiryCaseResponse.OrderInquiryCase, err error) { + orderInquiryCaseDao := dao.OrderInquiryCaseDao{} + orderInquiryCase, err := orderInquiryCaseDao.GetOrderInquiryCaseByOrderInquiryId(orderInquiryId) + if orderInquiryCase == nil { + return nil, errors.New("数据错误,无问诊病例") + } + + u = &orderInquiryCaseResponse.OrderInquiryCase{ + InquiryCaseId: strconv.FormatInt(orderInquiryCase.InquiryCaseId, 10), + UserId: strconv.FormatInt(orderInquiryCase.UserId, 10), + PatientId: strconv.FormatInt(orderInquiryCase.PatientId, 10), + OrderInquiryId: strconv.FormatInt(orderInquiryCase.OrderInquiryId, 10), + FamilyId: strconv.FormatInt(orderInquiryCase.FamilyId, 10), + Name: orderInquiryCase.Name, + Sex: orderInquiryCase.Sex, + Age: orderInquiryCase.Age, + DiseaseClassName: orderInquiryCase.DiseaseClassName, + DiseaseDesc: orderInquiryCase.DiseaseDesc, + } + + return u, nil +} + +// GetOrderInquiryById 问诊订单详情-问诊订单id +func (r *OrderInquiryService) GetOrderInquiryById(orderInquiryId int64) (res *orderInquiryResponse.OrderInquiry, err error) { + // 获取问诊订单数据 + orderInquiryDao := dao.OrderInquiryDao{} + orderInquiry, err := orderInquiryDao.GetOrderInquiryPreloadById(orderInquiryId) + if err != nil || orderInquiry == nil { + return nil, errors.New(err.Error()) } // 处理返回值 - getOrderInquiryResponse = &orderInquiryResponse.GetOrderInquiry{ + res = &orderInquiryResponse.OrderInquiry{ OrderInquiryId: strconv.FormatInt(orderInquiry.OrderInquiryId, 10), UserId: strconv.FormatInt(orderInquiry.UserId, 10), - DoctorId: doctorId, PatientId: strconv.FormatInt(orderInquiry.PatientId, 10), FamilyId: strconv.FormatInt(orderInquiry.FamilyId, 10), InquiryType: orderInquiry.InquiryType, @@ -352,88 +394,9 @@ func (r *OrderInquiryService) GetOrderInquiry(orderInquiryId int64) (getOrderInq PatientNameMask: orderInquiry.PatientNameMask, PatientSex: orderInquiry.PatientSex, PatientAge: orderInquiry.PatientAge, - OrderInquiryCoupon: orderInquiryCoupon, - OrderInquiryCase: orderInquiryCase, - OrderInquiryRefund: orderInquiryRefund, - OrderEvaluation: orderEvaluation, - UserDoctor: userDoctor, CreatedAt: orderInquiry.CreatedAt, UpdatedAt: orderInquiry.UpdatedAt, } - return getOrderInquiryResponse, nil -} - -// GetOrderInquiryCoupon 获取问诊订单优惠卷 -func (r *OrderInquiryService) GetOrderInquiryCoupon(orderInquiryId int64) (u *orderInquiryCouponResponse.OrderInquiryCoupon, err error) { - orderInquiryCouponDao := dao.OrderInquiryCouponDao{} - orderInquiryCoupon, err := orderInquiryCouponDao.GetOrderInquiryCouponByOrderInquiryId(orderInquiryId) - if orderInquiryCoupon == nil { - return nil, nil - } - - u = &orderInquiryCouponResponse.OrderInquiryCoupon{ - OrderCouponId: strconv.FormatInt(orderInquiryCoupon.OrderCouponId, 10), - OrderInquiryId: strconv.FormatInt(orderInquiryCoupon.OrderInquiryId, 10), - UserCouponId: strconv.FormatInt(orderInquiryCoupon.UserCouponId, 10), - CouponName: orderInquiryCoupon.CouponName, - CouponUsePrice: orderInquiryCoupon.CouponUsePrice, - CreatedAt: orderInquiryCoupon.CreatedAt, - UpdatedAt: orderInquiryCoupon.UpdatedAt, - } - - return u, nil -} - -// GetOrderInquiryRefund 获取问诊订单退款数据 -func (r *OrderInquiryService) GetOrderInquiryRefund(orderInquiryId int64) (u *orderInquiryRefundResponse.OrderInquiryRefund, err error) { - orderInquiryRefundDao := dao.OrderInquiryRefundDao{} - orderInquiryRefund, err := orderInquiryRefundDao.GetOrderInquiryRefundByOrderInquiryId(orderInquiryId) - if orderInquiryRefund == nil { - return nil, nil - } - - u = &orderInquiryRefundResponse.OrderInquiryRefund{ - InquiryRefundId: strconv.FormatInt(orderInquiryRefund.InquiryRefundId, 10), - PatientId: strconv.FormatInt(orderInquiryRefund.PatientId, 10), - OrderInquiryId: strconv.FormatInt(orderInquiryRefund.OrderInquiryId, 10), - InquiryNo: orderInquiryRefund.InquiryNo, - InquiryRefundNo: orderInquiryRefund.InquiryRefundNo, - RefundId: orderInquiryRefund.RefundId, - InquiryRefundStatus: orderInquiryRefund.InquiryRefundStatus, - RefundTotal: orderInquiryRefund.RefundTotal, - RefundReason: orderInquiryRefund.RefundReason, - SuccessTime: orderInquiryRefund.SuccessTime, - CreatedAt: orderInquiryRefund.CreatedAt, - UpdatedAt: orderInquiryRefund.UpdatedAt, - } - - return u, nil -} - -// GetOrderEvaluation 获取问诊订单评价数据 -func (r *OrderInquiryService) GetOrderEvaluation(orderInquiryId int64) (u *orderEvaluationResponse.OrderEvaluation, err error) { - orderEvaluationDao := dao.OrderEvaluationDao{} - orderEvaluation, err := orderEvaluationDao.GetOrderEvaluationByOrderInquiryId(orderInquiryId) - if orderEvaluation == nil { - return nil, nil - } - - u = &orderEvaluationResponse.OrderEvaluation{ - EvaluationId: strconv.FormatInt(orderEvaluation.EvaluationId, 10), - DoctorId: strconv.FormatInt(orderEvaluation.DoctorId, 10), - PatientId: strconv.FormatInt(orderEvaluation.PatientId, 10), - OrderInquiryId: strconv.FormatInt(orderEvaluation.OrderInquiryId, 10), - NameMask: orderEvaluation.NameMask, - ReplyQuality: orderEvaluation.ReplyQuality, - ServiceAttitude: orderEvaluation.ServiceAttitude, - ReplyProgress: orderEvaluation.ReplyProgress, - AvgScore: orderEvaluation.AvgScore, - Type: orderEvaluation.Type, - Content: orderEvaluation.Content, - CreatedAt: orderEvaluation.CreatedAt, - UpdatedAt: orderEvaluation.UpdatedAt, - } - - return u, nil + return res, nil } diff --git a/api/service/admin.go b/api/service/admin.go index c96ce0e..aafbabb 100644 --- a/api/service/admin.go +++ b/api/service/admin.go @@ -5,8 +5,8 @@ import ( "encoding/hex" "errors" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" - "hospital-admin-api/api/responses/adminResponse" "hospital-admin-api/extend/aliyun" "hospital-admin-api/utils" "strconv" @@ -16,7 +16,7 @@ type AdminService struct { } // Login 登陆 -func (b *AdminService) Login(LoginRequest requests.Login) (*adminResponse.Login, error) { +func (b *AdminService) Login(LoginRequest requests.Login) (*dto.Login, error) { // 获取用户信息 AdminUserDao := dao.AdminUserDao{} adminUser, err := AdminUserDao.GetAdminUserFirstByAccess(LoginRequest.Access) @@ -55,14 +55,14 @@ func (b *AdminService) Login(LoginRequest requests.Login) (*adminResponse.Login, return nil, errors.New("登陆失败") } - result := &adminResponse.Login{ + result := &dto.Login{ UserId: strconv.FormatInt(adminUser.UserID, 10), NickName: adminUser.NickName, Avatar: adminUser.Avatar, Token: jwt, } - result.GetFullAvatar() + result.GetLoginFullAvatar() return result, nil } diff --git a/api/service/case.go b/api/service/case.go index 55e0f1d..8bac66e 100644 --- a/api/service/case.go +++ b/api/service/case.go @@ -2,12 +2,8 @@ package service import ( "errors" - "fmt" "hospital-admin-api/api/dao" - "hospital-admin-api/api/responses/orderInquiryCaseResponse" - "hospital-admin-api/utils" - "strconv" - "strings" + "hospital-admin-api/api/dto" ) // CaseService 病例 @@ -15,7 +11,7 @@ type CaseService struct { } // GetOrderInquiryCaseByInquiryCaseId 获取病例-问诊订单 -func (r *CaseService) GetOrderInquiryCaseByInquiryCaseId(inquiryCaseId int64) (u *orderInquiryCaseResponse.OrderInquiryCase, err error) { +func (r *CaseService) GetOrderInquiryCaseByInquiryCaseId(inquiryCaseId int64) (g *dto.OrderInquiryCaseDto, err error) { orderInquiryCaseDao := dao.OrderInquiryCaseDao{} orderInquiryCase, err := orderInquiryCaseDao.GetOrderInquiryCaseById(inquiryCaseId) if orderInquiryCase == nil { @@ -35,80 +31,16 @@ func (r *CaseService) GetOrderInquiryCaseByInquiryCaseId(inquiryCaseId int64) (u inquiryCaseProducts, err := inquiryCaseProductDao.GetInquiryCaseProductListByInquiryCaseId(orderInquiryCase.InquiryCaseId) // 处理返回数据 - u = &orderInquiryCaseResponse.OrderInquiryCase{ - InquiryCaseId: strconv.FormatInt(orderInquiryCase.InquiryCaseId, 10), - UserId: strconv.FormatInt(orderInquiryCase.UserId, 10), - PatientId: strconv.FormatInt(orderInquiryCase.PatientId, 10), - OrderInquiryId: strconv.FormatInt(orderInquiryCase.OrderInquiryId, 10), - FamilyId: strconv.FormatInt(orderInquiryCase.FamilyId, 10), - Relation: orderInquiryCase.Relation, - Status: orderInquiryCase.Status, - Name: orderInquiryCase.Name, - Sex: orderInquiryCase.Sex, - Age: orderInquiryCase.Age, - Height: orderInquiryCase.Height, - Weight: orderInquiryCase.Weight, - DiseaseClassId: strconv.FormatInt(orderInquiryCase.DiseaseClassId, 10), - DiseaseClassName: orderInquiryCase.DiseaseClassName, - DiagnosisDate: orderInquiryCase.DiagnosisDate, - DiseaseDesc: orderInquiryCase.DiseaseDesc, - IsAllergyHistory: orderInquiryCase.IsAllergyHistory, - AllergyHistory: orderInquiryCase.AllergyHistory, - IsFamilyHistory: orderInquiryCase.IsFamilyHistory, - FamilyHistory: orderInquiryCase.FamilyHistory, - IsPregnant: orderInquiryCase.IsPregnant, - Pregnant: orderInquiryCase.Pregnant, - IsTaboo: orderInquiryCase.IsTaboo, - CreatedAt: orderInquiryCase.CreatedAt, - UpdatedAt: orderInquiryCase.UpdatedAt, - } + g = dto.GetOrderInquiryCaseDto(orderInquiryCase) - if patientFamilyHealth != nil { - u.DiagnosisHospital = patientFamilyHealth.DiagnosisHospital - u.IsTakeMedicine = patientFamilyHealth.IsTakeMedicine - u.DrugsName = patientFamilyHealth.DrugsName - } + // 加载健康属性 + g.LoadPatientFamilyHealthAttr(patientFamilyHealth) - if patientFamilyPersonal != nil { - u.DrinkWineStatus = patientFamilyPersonal.DrinkWineStatus - u.SmokeStatus = patientFamilyPersonal.SmokeStatus - u.ChemicalCompoundStatus = patientFamilyPersonal.ChemicalCompoundStatus - u.ChemicalCompoundDescribe = patientFamilyPersonal.ChemicalCompoundDescribe - u.IsOperation = patientFamilyPersonal.IsOperation - u.Operation = patientFamilyPersonal.Operation - } + // 加载个人情况属性 + g.LoadPatientFamilyPersonalAttr(patientFamilyPersonal) - // 处理复诊凭证 - var diagnoseImages []*string - if orderInquiryCase.DiagnoseImages != "" { - diagnoseImages := strings.Split(orderInquiryCase.DiagnoseImages, ",") + // 加载用药意向 + g.LoadInquiryCaseProduct(inquiryCaseProducts) - for i, image := range diagnoseImages { - diagnoseImages[i] = utils.AddOssDomain(image) - } - } - - u.DiagnoseImages = diagnoseImages - - // 处理用药意向 - var product []*string - if inquiryCaseProducts != nil { - for _, inquiryCaseProduct := range inquiryCaseProducts { - // 获取商品数据 - productDao := dao.ProductDao{} - productData, err := productDao.GetProductById(inquiryCaseProduct.ProductId) - if err != nil { - return nil, errors.New("数据错误") - } - - caseProductNum := fmt.Sprintf("%d", inquiryCaseProduct.CaseProductNum) - productName := productData.ProductName + productData.ProductSpec + "(" + caseProductNum + productData.PackagingUnit + ")" - - product = append(product, &productName) - } - } - - u.Product = product - - return u, nil + return g, nil } diff --git a/api/service/dept.go b/api/service/dept.go index 6de0924..d914255 100644 --- a/api/service/dept.go +++ b/api/service/dept.go @@ -3,9 +3,9 @@ package service import ( "errors" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/model" "hospital-admin-api/api/requests" - "hospital-admin-api/api/responses/deptResponse" "hospital-admin-api/global" "strconv" ) @@ -14,7 +14,7 @@ type DeptService struct { } // GetDeptList 获取部门列表 -func (r *DeptService) GetDeptList() ([]*deptResponse.GetDeptList, error) { +func (r *DeptService) GetDeptList() ([]*dto.AdminDeptDto, error) { // 获取全部部门 adminDeptDao := dao.AdminDeptDao{} @@ -25,11 +25,11 @@ func (r *DeptService) GetDeptList() ([]*deptResponse.GetDeptList, error) { return nil, nil } - deptMap := make(map[int64]*deptResponse.GetDeptList) - var deptTree []*deptResponse.GetDeptList + deptMap := make(map[int64]*dto.AdminDeptDto) + var deptTree []*dto.AdminDeptDto for _, dept := range adminDept { - node := &deptResponse.GetDeptList{ + node := &dto.AdminDeptDto{ DeptId: strconv.FormatInt(dept.DeptId, 10), ParentId: strconv.FormatInt(dept.ParentId, 10), DeptName: dept.DeptName, diff --git a/api/service/menu.go b/api/service/menu.go index 31e8184..404ee6c 100644 --- a/api/service/menu.go +++ b/api/service/menu.go @@ -4,9 +4,9 @@ import ( "errors" "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/model" "hospital-admin-api/api/requests" - "hospital-admin-api/api/responses/menuResponse" "hospital-admin-api/global" "strconv" ) @@ -14,7 +14,7 @@ import ( type MenuService struct{} // GetMenuList 获取菜单列表 -func (r *MenuService) GetMenuList() ([]*menuResponse.GetMenuList, error) { +func (r *MenuService) GetMenuList() ([]*dto.AdminMenuDto, error) { // 获取全部菜单 AdminMenuDao := dao.AdminMenuDao{} adminMenu, _ := AdminMenuDao.GetAdminMenuListSortOrderNum() @@ -22,11 +22,11 @@ func (r *MenuService) GetMenuList() ([]*menuResponse.GetMenuList, error) { return nil, nil } - menuMap := make(map[int64]*menuResponse.GetMenuList) - var menuTree []*menuResponse.GetMenuList + menuMap := make(map[int64]*dto.AdminMenuDto) + var menuTree []*dto.AdminMenuDto for _, menu := range adminMenu { - node := &menuResponse.GetMenuList{ + node := &dto.AdminMenuDto{ MenuId: strconv.FormatInt(menu.MenuId, 10), MenuName: menu.MenuName, MenuTitle: menu.MenuTitle, diff --git a/api/service/orderInquiryCase.go b/api/service/orderInquiryCase.go deleted file mode 100644 index 5c04307..0000000 --- a/api/service/orderInquiryCase.go +++ /dev/null @@ -1,35 +0,0 @@ -package service - -import ( - "errors" - "hospital-admin-api/api/dao" - "hospital-admin-api/api/responses/orderInquiryCaseResponse" - "strconv" -) - -type OrderInquiryCaseService struct { -} - -// GetOrderInquiryCaseByOrderInquiryId 获取问诊订单病例-问诊订单 -func (r *OrderInquiryCaseService) GetOrderInquiryCaseByOrderInquiryId(orderInquiryId int64) (u *orderInquiryCaseResponse.OrderInquiryCase, err error) { - orderInquiryCaseDao := dao.OrderInquiryCaseDao{} - orderInquiryCase, err := orderInquiryCaseDao.GetOrderInquiryCaseByOrderInquiryId(orderInquiryId) - if orderInquiryCase == nil { - return nil, errors.New("数据错误,无问诊病例") - } - - u = &orderInquiryCaseResponse.OrderInquiryCase{ - InquiryCaseId: strconv.FormatInt(orderInquiryCase.InquiryCaseId, 10), - UserId: strconv.FormatInt(orderInquiryCase.UserId, 10), - PatientId: strconv.FormatInt(orderInquiryCase.PatientId, 10), - OrderInquiryId: strconv.FormatInt(orderInquiryCase.OrderInquiryId, 10), - FamilyId: strconv.FormatInt(orderInquiryCase.FamilyId, 10), - Name: orderInquiryCase.Name, - Sex: orderInquiryCase.Sex, - Age: orderInquiryCase.Age, - DiseaseClassName: orderInquiryCase.DiseaseClassName, - DiseaseDesc: orderInquiryCase.DiseaseDesc, - } - - return u, nil -} diff --git a/api/service/orderPrescription.go b/api/service/orderPrescription.go index c3194d9..545f9f1 100644 --- a/api/service/orderPrescription.go +++ b/api/service/orderPrescription.go @@ -1,8 +1,12 @@ package service import ( + "errors" "fmt" "hospital-admin-api/api/dao" + "hospital-admin-api/api/model" + "hospital-admin-api/api/responses/orderPrescriptionIcdResponse" + "hospital-admin-api/api/responses/orderPrescriptionProductResponse" "hospital-admin-api/api/responses/orderPrescriptionResponse" ) @@ -47,3 +51,124 @@ func (r *OrderPrescriptionService) GetOrderPrescriptionById(OrderPrescriptionId } return u, nil } + +// GetOrderPrescription 处方详情 +func (r *OrderPrescriptionService) GetOrderPrescription(OrderPrescriptionId int64) (getOrderPrescriptionResponse *orderPrescriptionResponse.GetOrderPrescription, err error) { + orderPrescriptionDao := dao.OrderPrescriptionDao{} + orderPrescription, err := orderPrescriptionDao.GetById(OrderPrescriptionId) + if orderPrescription == nil { + return nil, errors.New("处方错误") + } + + // 获取处方关联疾病数据 + orderPrescriptionIcds, err := r.GetOrderPrescriptionIcdByOrderPrescriptionId(OrderPrescriptionId) + if err != nil { + return nil, errors.New(err.Error()) + } + + fmt.Println(orderPrescriptionIcds) + // 获取问诊病例 + orderInquiryService := OrderInquiryService{} + orderInquiryCase, err := orderInquiryService.GetOrderInquiryCaseByOrderInquiryId(orderPrescription.OrderInquiryId) + if err != nil { + return nil, errors.New(err.Error()) + } + fmt.Println(orderInquiryCase) + + // 获取处方关联问诊数据 + orderInquiry, err := orderInquiryService.GetOrderInquiryById(orderPrescription.OrderInquiryId) + if err != nil { + return nil, errors.New(err.Error()) + } + fmt.Println(orderInquiry) + + // 获取处方商品数据 + orderPrescriptionProducts, err := r.GetOrderPrescriptionProductByOrderPrescriptionId(OrderPrescriptionId) + if err != nil { + return nil, errors.New(err.Error()) + } + fmt.Println(orderPrescriptionProducts) + + // 获取医生数据 + userDoctorService := UserDoctorService{} + userDoctor, err := userDoctorService.GetUserDoctorById(orderPrescription.DoctorId) + if err != nil { + return nil, errors.New(err.Error()) + } + fmt.Println(userDoctor) + + // 获取药师数据 + + result := &orderPrescriptionResponse.GetOrderPrescription{ + + CreatedAt: model.LocalTime{}, + UpdatedAt: model.LocalTime{}, + } + + return result, nil +} + +// GetOrderPrescriptionIcdByOrderPrescriptionId 获取处方关联疾病数据-处方id +func (r *OrderPrescriptionService) GetOrderPrescriptionIcdByOrderPrescriptionId(OrderPrescriptionId int64) (res *orderPrescriptionIcdResponse.OrderPrescriptionIcd, err error) { + orderPrescriptionIcdDao := dao.OrderPrescriptionIcdDao{} + orderPrescriptionIcd, err := orderPrescriptionIcdDao.GetOrderPrescriptionIcdById(OrderPrescriptionId) + if orderPrescriptionIcd == nil { + return nil, errors.New("处方病例错误") + } + + result := &orderPrescriptionIcdResponse.OrderPrescriptionIcd{ + PrescriptionIcdId: fmt.Sprintf("%d", orderPrescriptionIcd.PrescriptionIcdId), + OrderPrescriptionId: fmt.Sprintf("%d", orderPrescriptionIcd.OrderPrescriptionId), + IcdId: fmt.Sprintf("%d", orderPrescriptionIcd.IcdId), + IcdName: orderPrescriptionIcd.IcdName, + IcdCode: orderPrescriptionIcd.IcdCode, + CreatedAt: orderPrescriptionIcd.CreatedAt, + UpdatedAt: orderPrescriptionIcd.UpdatedAt, + } + + return result, nil +} + +// GetOrderPrescriptionProductByOrderPrescriptionId 获取处方关联商品数据-处方id +func (r *OrderPrescriptionService) GetOrderPrescriptionProductByOrderPrescriptionId(orderPrescriptionId int64) (res []*orderPrescriptionProductResponse.OrderPrescriptionProduct, err error) { + orderPrescriptionProductDao := dao.OrderPrescriptionProductDao{} + orderPrescriptionProducts, err := orderPrescriptionProductDao.GetOrderPrescriptionProductListByOrderPrescriptionId(orderPrescriptionId) + if err != nil { + return nil, errors.New("数据错误,无处方药品数据") + } + + if len(orderPrescriptionProducts) == 0 { + return nil, errors.New("数据错误,无处方药品数据") + } + + // 处理返回值 + items := make([]*orderPrescriptionProductResponse.OrderPrescriptionProduct, len(orderPrescriptionProducts)) + + if len(orderPrescriptionProducts) > 0 { + for i, v := range orderPrescriptionProducts { + // 将原始结构体转换为新结构体 + item := &orderPrescriptionProductResponse.OrderPrescriptionProduct{ + PrescriptionProductId: fmt.Sprintf("%d", v.OrderPrescriptionId), + OrderPrescriptionId: fmt.Sprintf("%d", v.OrderPrescriptionId), + ProductId: fmt.Sprintf("%d", v.ProductId), + UseStatus: v.UseStatus, + PrescriptionProductNum: v.PrescriptionProductNum, + ProductName: v.ProductName, + ProductSpec: v.ProductSpec, + LicenseNumber: v.LicenseNumber, + Manufacturer: v.Manufacturer, + SingleUnit: v.SingleUnit, + SingleUse: v.SingleUse, + PackagingUnit: v.PackagingUnit, + FrequencyUse: v.FrequencyUse, + AvailableDays: v.AvailableDays, + CreatedAt: v.CreatedAt, + UpdatedAt: v.UpdatedAt, + } + + // 将转换后的结构体添加到新切片中 + items[i] = item + } + } + return items, nil +} diff --git a/api/service/orderProduct.go b/api/service/orderProduct.go index e24b56d..9db13f9 100644 --- a/api/service/orderProduct.go +++ b/api/service/orderProduct.go @@ -2,11 +2,10 @@ package service import ( "errors" - "fmt" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/model" "hospital-admin-api/api/requests" - "hospital-admin-api/api/responses/orderProductResponse" "hospital-admin-api/config" "hospital-admin-api/extend/weChat" "hospital-admin-api/global" @@ -18,7 +17,7 @@ type OrderProductService struct { } // GetOrderProduct 药品订单详情 -func (r *OrderProductService) GetOrderProduct(orderProductId int64) (getOrderProductResponse *orderProductResponse.GetOrderProduct, err error) { +func (r *OrderProductService) GetOrderProduct(orderProductId int64) (g *dto.OrderProductDto, err error) { // 获取药品订单数据 orderProductDao := dao.OrderProductDao{} orderProduct, err := orderProductDao.GetOrderProductPreloadById(orderProductId) @@ -27,95 +26,60 @@ func (r *OrderProductService) GetOrderProduct(orderProductId int64) (getOrderPro } // 获取退款数据 - orderProductRefundService := OrderProductRefundService{} - orderProductRefund, err := orderProductRefundService.GetOrderProductRefundByOrderProductId(orderProductId) - if err != nil { - return nil, errors.New(err.Error()) - } + orderProductRefundDao := dao.OrderProductRefundDao{} + orderProductRefund, err := orderProductRefundDao.GetOrderProductRefundByOrderProductId(orderProductId) // 获取商品数据 - orderProductItemService := OrderProductItemService{} - orderProductItem, err := orderProductItemService.GetOrderProductItemByOrderProductId(orderProductId) - if err != nil { - return nil, errors.New(err.Error()) + orderProductItemDao := dao.OrderProductItemDao{} + orderProductItems, err := orderProductItemDao.GetOrderProductItemByOrderProductId(orderProductId) + if err != nil || len(orderProductItems) == 0 { + return nil, errors.New("数据错误,无药品数据") } // 获取物流数据 - orderProductLogisticsService := OrderProductLogisticsService{} - orderProductLogistics, err := orderProductLogisticsService.GetOrderProductLogisticsByOrderProductId(orderProductId) - if err != nil { - return nil, errors.New(err.Error()) - } + orderProductLogisticsDao := dao.OrderProductLogisticsDao{} + orderProductLogistics, err := orderProductLogisticsDao.GetOrderProductLogisticsByOrderProductId(orderProductId) // 获取处方数据 - orderPrescriptionService := OrderPrescriptionService{} - orderPrescription, err := orderPrescriptionService.GetOrderPrescriptionById(orderProduct.OrderPrescriptionId) - if err != nil { - return nil, errors.New(err.Error()) - } + orderPrescriptionDao := dao.OrderPrescriptionDao{} + orderPrescription, err := orderPrescriptionDao.GetById(orderProduct.OrderPrescriptionId) // 获取问诊病例 - orderInquiryCaseService := OrderInquiryCaseService{} - orderInquiryCase, err := orderInquiryCaseService.GetOrderInquiryCaseByOrderInquiryId(orderProduct.OrderInquiryId) - if err != nil { - return nil, errors.New(err.Error()) + orderInquiryCaseDao := dao.OrderInquiryCaseDao{} + orderInquiryCase, err := orderInquiryCaseDao.GetOrderInquiryCaseByOrderInquiryId(orderProduct.OrderInquiryId) + if orderInquiryCase == nil { + return nil, errors.New("数据错误,无问诊病例") } // 医生数据 userDoctorService := UserDoctorService{} - userDoctor, err := userDoctorService.GetOrderInquiryUserDoctor(orderProduct.DoctorId) + userDoctor, err := userDoctorService.GetUserDoctorById(orderProduct.DoctorId) if err != nil { return nil, errors.New(err.Error()) } // 处理返回值 - getOrderProductResponse = &orderProductResponse.GetOrderProduct{ - OrderProductId: fmt.Sprintf("%v", orderProduct.OrderProductId), - OrderInquiryId: fmt.Sprintf("%v", orderProduct.OrderInquiryId), - OrderPrescriptionId: fmt.Sprintf("%v", orderProduct.OrderPrescriptionId), - DoctorId: fmt.Sprintf("%v", orderProduct.DoctorId), - PatientId: fmt.Sprintf("%v", orderProduct.PatientId), - FamilyId: fmt.Sprintf("%v", orderProduct.FamilyId), - OrderProductNo: orderProduct.OrderProductNo, - EscrowTradeNo: orderProduct.EscrowTradeNo, - OrderProductStatus: orderProduct.OrderProductStatus, - PayChannel: orderProduct.PayChannel, - PayStatus: orderProduct.PayStatus, - CancelReason: orderProduct.CancelReason, - AmountTotal: orderProduct.AmountTotal, - PaymentAmountTotal: orderProduct.PaymentAmountTotal, - LogisticsFee: orderProduct.LogisticsFee, - LogisticsNo: orderProduct.LogisticsNo, - LogisticsCompanyCode: orderProduct.LogisticsCompanyCode, - DeliveryTime: orderProduct.DeliveryTime, - PayTime: orderProduct.PayTime, - Remarks: orderProduct.Remarks, - RefundStatus: orderProduct.RefundStatus, - CancelTime: orderProduct.CancelTime, - CancelRemarks: orderProduct.CancelRemarks, - ReportPreStatus: orderProduct.ReportPreStatus, - ReportPreTime: orderProduct.ReportPreTime, - ReportPreFailReason: orderProduct.ReportPreFailReason, - ProvinceId: orderProduct.ProvinceId, - Province: orderProduct.Province, - CityId: orderProduct.CityId, - City: orderProduct.City, - CountyId: orderProduct.CountyId, - County: orderProduct.County, - AddressMask: orderProduct.AddressMask, - ConsigneeNameMask: orderProduct.ConsigneeNameMask, - ConsigneeTelMask: orderProduct.ConsigneeTelMask, - CreatedAt: orderProduct.CreatedAt, - UpdatedAt: orderProduct.UpdatedAt, - OrderProductRefund: orderProductRefund, - OrderProductItem: orderProductItem, - OrderProductLogistics: orderProductLogistics, - UserDoctor: userDoctor, - OrderPrescription: orderPrescription, - OrderInquiryCase: orderInquiryCase, - } + g = dto.GetOrderProductDto(orderProduct) - return getOrderProductResponse, nil + // 加载医生数据 + g.UserDoctor = userDoctor + + // 加载问诊病例 + g.LoadOrderInquiryCase(orderInquiryCase) + + // 加载处方数据 + g.LoadOrderPrescription(orderPrescription) + + // 加载物流数据 + g.LoadOrderProductLogistics(orderProductLogistics) + + // 加载商品数据 + g.LoadOrderProductItem(orderProductItems) + + // 加载退款数据 + g.LoadOrderProductRefund(orderProductRefund) + + return g, nil } // CancelOrderProduct 取消药品订单 @@ -305,7 +269,7 @@ func (r *OrderProductService) CancelOrderProduct(req requests.CancelOrderProduct } // GetOrderProductConsignee 获取药品订单收货人数据 -func (r *OrderProductService) GetOrderProductConsignee(orderProductId int64) (*orderProductResponse.GetOrderProductConsignee, error) { +func (r *OrderProductService) GetOrderProductConsignee(orderProductId int64) (*dto.OrderProductConsigneeDto, error) { // 获取药品订单数据 orderProductDao := dao.OrderProductDao{} orderProduct, err := orderProductDao.GetOrderProductById(orderProductId) @@ -314,7 +278,7 @@ func (r *OrderProductService) GetOrderProductConsignee(orderProductId int64) (*o } // 处理返回值 - u := orderProductResponse.GetOrderProductConsigneeResponse(orderProduct) + u := dto.GetOrderProductConsigneeDtoDto(orderProduct) return u, nil } diff --git a/api/service/patientFamily.go b/api/service/patientFamily.go index e51af04..d43c495 100644 --- a/api/service/patientFamily.go +++ b/api/service/patientFamily.go @@ -4,10 +4,8 @@ import ( "errors" "fmt" "hospital-admin-api/api/dao" - "hospital-admin-api/api/model" + "hospital-admin-api/api/dto" "hospital-admin-api/api/responses/patientFamilyResponse" - "hospital-admin-api/api/responses/userResponse" - "hospital-admin-api/utils" ) type PatientFamilyService struct { @@ -69,7 +67,7 @@ func (r *PatientFamilyService) GetPatientFamilyListByPatientId(patientId int64) } // GetPatientFamily 家庭成员详情 -func (r *PatientFamilyService) GetPatientFamily(familyId int64) (getPatientFamilyResponse *patientFamilyResponse.GetPatientFamily, err error) { +func (r *PatientFamilyService) GetPatientFamily(familyId int64) (g *dto.PatientFamilyDto, err error) { patientFamilyDao := dao.PatientFamilyDao{} patientFamily, err := patientFamilyDao.GetPatientFamilyById(familyId) if err != nil || patientFamily == nil { @@ -90,45 +88,11 @@ func (r *PatientFamilyService) GetPatientFamily(familyId int64) (getPatientFamil return nil, errors.New("用户错误") } - var userData *userResponse.User - if userPatient.User != nil { - userData = userResponse.UserResponse(user) + // 处理返回数据 + g = dto.GetPatientFamilyDto(patientFamily) - // 加密患者手机号 - userData.Mobile = utils.MaskPhoneStr(userData.Mobile) - userData.WxMobile = utils.MaskPhoneStr(userData.WxMobile) - } + // 加载用户数据-加密 + g.LoadMaskUser(user) - getPatientFamilyResponse = &patientFamilyResponse.GetPatientFamily{ - FamilyId: fmt.Sprintf("%d", patientFamily.FamilyId), - PatientId: fmt.Sprintf("%d", patientFamily.PatientId), - Relation: patientFamily.Relation, - Status: &patientFamily.Status, - IsDefault: &patientFamily.IsDefault, - CardName: patientFamily.CardName, - CardNameMask: patientFamily.CardNameMask, - MobileMask: patientFamily.MobileMask, - Type: &patientFamily.Type, - IdNumberMask: patientFamily.IdNumberMask, - Sex: &patientFamily.Sex, - Age: patientFamily.Age, - ProvinceId: fmt.Sprintf("%d", patientFamily.ProvinceId), - Province: patientFamily.Province, - CityId: fmt.Sprintf("%d", patientFamily.CityId), - City: patientFamily.City, - CountyId: fmt.Sprintf("%d", patientFamily.CountyId), - County: patientFamily.County, - Height: patientFamily.Height, - Weight: patientFamily.Weight, - MaritalStatus: &patientFamily.MaritalStatus, - NationId: fmt.Sprintf("%d", patientFamily.NationId), - NationName: patientFamily.NationName, - JobId: fmt.Sprintf("%d", patientFamily.JobId), - JobName: patientFamily.JobName, - User: userData, - CreatedAt: model.LocalTime{}, - UpdatedAt: model.LocalTime{}, - } - - return getPatientFamilyResponse, nil + return g, nil } diff --git a/api/service/role.go b/api/service/role.go index 662d310..85dd1ca 100644 --- a/api/service/role.go +++ b/api/service/role.go @@ -4,9 +4,9 @@ import ( "errors" "github.com/gin-gonic/gin" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/model" "hospital-admin-api/api/requests" - "hospital-admin-api/api/responses/roleResponse" "hospital-admin-api/global" "strconv" ) @@ -14,7 +14,7 @@ import ( type RoleService struct{} // GetRoleMenuList 获取角色菜单 -func (r *RoleService) GetRoleMenuList(roleId int64, isAdmin bool) ([]*roleResponse.GetRoleMenuList, error) { +func (r *RoleService) GetRoleMenuList(roleId int64, isAdmin bool) ([]*dto.AdminRoleMenuDto, error) { // 获取角色菜单 adminRoleMenuDao := dao.AdminRoleMenuDao{} adminMenuDao := dao.AdminMenuDao{} @@ -41,7 +41,7 @@ func (r *RoleService) GetRoleMenuList(roleId int64, isAdmin bool) ([]*roleRespon return nil, nil } - var getRoleMenuListResponse []*roleResponse.GetRoleMenuList + var getRoleMenuListResponse []*dto.AdminRoleMenuDto if len(menuIDs) > 0 { // 构建菜单树 @@ -81,15 +81,15 @@ func (r *RoleService) GetRoleMenuButtonList(roleId int64) ([]string, error) { } // 获取角色菜单-构建菜单树 -func buildMenuTree(menuIds []int64, menuData []*model.AdminMenu) []*roleResponse.GetRoleMenuList { - menuMap := make(map[int64]*roleResponse.GetRoleMenuList) - rootNodes := make([]*roleResponse.GetRoleMenuList, 0) +func buildMenuTree(menuIds []int64, menuData []*model.AdminMenu) []*dto.AdminRoleMenuDto { + menuMap := make(map[int64]*dto.AdminRoleMenuDto) + rootNodes := make([]*dto.AdminRoleMenuDto, 0) // 构建菜单映射 for _, menu := range menuData { for _, v := range menuIds { if v == menu.MenuId { - node := &roleResponse.GetRoleMenuList{ + node := &dto.AdminRoleMenuDto{ MenuId: strconv.FormatInt(menu.MenuId, 10), MenuName: menu.MenuName, MenuTitle: menu.MenuTitle, diff --git a/api/service/userDoctor.go b/api/service/userDoctor.go index eda5083..bdfcdc0 100644 --- a/api/service/userDoctor.go +++ b/api/service/userDoctor.go @@ -3,14 +3,9 @@ package service import ( "errors" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/model" "hospital-admin-api/api/requests" - "hospital-admin-api/api/responses/doctorBankCardResponse" - "hospital-admin-api/api/responses/doctorExpertiseResponse" - "hospital-admin-api/api/responses/hospitalResponse" - "hospital-admin-api/api/responses/userDoctorInfoResponse" - "hospital-admin-api/api/responses/userDoctorResponse" - "hospital-admin-api/api/responses/userResponse" "hospital-admin-api/config" "hospital-admin-api/extend/ca" "hospital-admin-api/extend/tencentIm" @@ -26,7 +21,7 @@ type UserDoctorService struct { } // GetUserDoctor 医生详情 -func (r *UserDoctorService) GetUserDoctor(doctorId int64) (getUserDoctorResponse *userDoctorResponse.GetUserDoctor, err error) { +func (r *UserDoctorService) GetUserDoctor(doctorId int64) (getUserDoctorResponse *dto.UserDoctorDto, err error) { // 获取医生数据 userDoctorDao := dao.UserDoctorDao{} userDoctor, err := userDoctorDao.GetUserDoctorPreloadById(doctorId) @@ -43,69 +38,29 @@ func (r *UserDoctorService) GetUserDoctor(doctorId int64) (getUserDoctorResponse } // 获取医生银行卡 - doctorBankCard, err := userDoctorService.GetUserDoctorBankByDoctorId(doctorId) - if err != nil { + doctorBankCardDao := dao.DoctorBankCardDao{} + doctorBankCard, err := doctorBankCardDao.GetDoctorBankCardByDoctorId(doctorId) + if err != nil && doctorBankCard == nil { return nil, errors.New(err.Error()) } // 处理返回值 - var userDoctorInfo *userDoctorInfoResponse.UserDoctorInfo - if userDoctor.UserDoctorInfo != nil { - userDoctorInfo = userDoctorInfoResponse.UserDoctorInfoResponse(userDoctor.UserDoctorInfo) - } + getUserDoctorResponse = dto.GetUserDoctorDto(userDoctor) - // 医院 - var hospital *hospitalResponse.Hospital - if userDoctor.Hospital != nil { - hospital = hospitalResponse.HospitalResponse(userDoctor.Hospital) - } + // 加载用户 + getUserDoctorResponse.LoadUser(userDoctor.User) - // 用户 - var user *userResponse.User - if userDoctor.User != nil { - user = userResponse.UserResponse(userDoctor.User) - } + // 加载医院 + getUserDoctorResponse.LoadHospital(userDoctor.Hospital) - getUserDoctorResponse = &userDoctorResponse.GetUserDoctor{ - DoctorID: strconv.Itoa(int(userDoctor.DoctorId)), - UserID: strconv.Itoa(int(userDoctor.UserId)), - UserName: userDoctor.UserName, - Status: userDoctor.Status, - IDCardStatus: userDoctor.Status, - IdenAuthStatus: userDoctor.IdenAuthStatus, - IdenAuthTime: userDoctor.IdenAuthTime, - IdenAuthFailReason: userDoctor.IdenAuthFailReason, - MultiPointStatus: userDoctor.MultiPointStatus, - MultiPointTime: userDoctor.MultiPointTime, - MultiPointFailReason: userDoctor.MultiPointFailReason, - IsBindBank: userDoctor.IsBindBank, - IsRecommend: userDoctor.IsRecommend, - Avatar: utils.AddOssDomain(userDoctor.Avatar), - DoctorTitle: userDoctor.DoctorTitle, - DepartmentCustomID: strconv.Itoa(int(userDoctor.DepartmentCustomId)), - DepartmentCustomName: userDoctor.DepartmentCustomName, - DepartmentCustomMobile: userDoctor.DepartmentCustomMobile, - HospitalID: strconv.Itoa(int(userDoctor.HospitalID)), - ServedPatientsNum: userDoctor.ServedPatientsNum, - PraiseRate: userDoctor.PraiseRate, - AvgResponseTime: userDoctor.AvgResponseTime, - NumberOfFans: userDoctor.NumberOfFans, - IsImgExpertReception: userDoctor.IsImgExpertReception, - IsImgWelfareReception: userDoctor.IsImgWelfareReception, - IsImgQuickReception: userDoctor.IsImgQuickReception, - IsPlatformDeepCooperation: userDoctor.IsPlatformDeepCooperation, - IsSysDiagnoCooperation: userDoctor.IsSysDiagnoCooperation, - QrCode: utils.AddOssDomain(userDoctor.QrCode), - BeGoodAt: userDoctor.BeGoodAt, - BriefIntroduction: userDoctor.BriefIntroduction, - CreatedAt: userDoctor.CreatedAt, - UpdatedAt: userDoctor.UpdatedAt, - User: user, - Hospital: hospital, - UserDoctorInfo: userDoctorInfo, - DoctorExpertise: doctorExpertise, // 专长 - DoctorBankCard: doctorBankCard, // 银行卡 - } + // 加载医生专长 + getUserDoctorResponse.DoctorExpertise = doctorExpertise + + // 加载医生银行卡 + getUserDoctorResponse.LoadDoctorBankCard(doctorBankCard) + + // 加载医生详情 + getUserDoctorResponse.LoadUserDoctorInfo(userDoctor.UserDoctorInfo) return getUserDoctorResponse, nil } @@ -1114,7 +1069,7 @@ func (r *UserDoctorService) AddUserDoctor(userId string, req requests.AddUserDoc } // GetUserDoctorExpertiseByDoctorId 获取医生专长 -func (r *UserDoctorService) GetUserDoctorExpertiseByDoctorId(doctorId int64) ([]*doctorExpertiseResponse.DoctorExpertise, error) { +func (r *UserDoctorService) GetUserDoctorExpertiseByDoctorId(doctorId int64) ([]*dto.DoctorExpertiseDto, error) { DiseaseClassExpertiseDao := dao.DiseaseClassExpertiseDao{} // 获取医生专长 @@ -1124,96 +1079,31 @@ func (r *UserDoctorService) GetUserDoctorExpertiseByDoctorId(doctorId int64) ([] return nil, errors.New("用户数据错误") } - doctorExpertisesResponses := make([]*doctorExpertiseResponse.DoctorExpertise, len(doctorExpertises)) + // 处理返回值 + responses := make([]*dto.DoctorExpertiseDto, len(doctorExpertises)) if len(doctorExpertises) > 0 { for i, v := range doctorExpertises { + response := dto.GetDoctorExpertiseDto(v) + // 获取专长 diseaseClassExpertise, err := DiseaseClassExpertiseDao.GetDiseaseClassExpertiseById(v.ExpertiseId) if err != nil || diseaseClassExpertise == nil { return nil, errors.New("专长数据错误") } - doctorExpertisesResponse := &doctorExpertiseResponse.DoctorExpertise{ - DoctorId: strconv.FormatInt(doctorId, 10), - ExpertiseId: strconv.FormatInt(v.ExpertiseId, 10), - ExpertiseName: diseaseClassExpertise.ExpertiseName, - } + response.LoadExpertiseName(diseaseClassExpertise) // 将转换后的结构体添加到新切片中 - doctorExpertisesResponses[i] = doctorExpertisesResponse + responses[i] = response } } - return doctorExpertisesResponses, nil -} - -// GetUserDoctorBankByDoctorId 获取医生银行卡 -func (r *UserDoctorService) GetUserDoctorBankByDoctorId(doctorId int64) (doctorBankCardResponse.DoctorBankCard, error) { - var doctorExpertisesResponse doctorBankCardResponse.DoctorBankCard - // 获取医生银行卡 - doctorBankCardDao := dao.DoctorBankCardDao{} - doctorBankCard, err := doctorBankCardDao.GetDoctorBankCardByDoctorId(doctorId) - if err != nil && doctorBankCard == nil { - return doctorExpertisesResponse, nil - } - - doctorExpertisesResponse = doctorBankCardResponse.DoctorBankCard{ - BankCardId: strconv.FormatInt(doctorBankCard.BankCardId, 10), - DoctorId: strconv.FormatInt(doctorBankCard.DoctorId, 10), - BankId: strconv.FormatInt(doctorBankCard.BankId, 10), - BankCardCodeMask: doctorBankCard.BankCardCodeMask, - ProvinceId: doctorBankCard.ProvinceId, - Province: doctorBankCard.Province, - CityId: doctorBankCard.CityId, - City: doctorBankCard.City, - CountyId: doctorBankCard.CountyId, - County: doctorBankCard.County, - } - - return doctorExpertisesResponse, nil -} - -// GetDoctorIdenFailReasonByDoctorId 获取医生审核失败原因 -func (r *UserDoctorService) GetDoctorIdenFailReasonByDoctorId(doctorId int64) (*userDoctorResponse.IdenAuthFailReason, error) { - doctorIdenFailDao := dao.DoctorIdenFailDao{} - doctorIdenFail, err := doctorIdenFailDao.GetDoctorIdenFailListByDoctorId(doctorId) - if err != nil { - return nil, errors.New(err.Error()) - } - - var idenAuthFailReason userDoctorResponse.IdenAuthFailReason - - if len(doctorIdenFail) > 0 { - for _, v := range doctorIdenFail { - switch v.FieldName { - case "avatar": - idenAuthFailReason.AvatarReason = v.FailReason - case "department_custom_mobile": - idenAuthFailReason.DepartmentCustomMobileReason = v.FailReason - case "department_custom_name": - idenAuthFailReason.DepartmentCustomNameReason = v.FailReason - case "brief_introduction": - idenAuthFailReason.BriefIntroductionReason = v.FailReason - case "be_good_at": - idenAuthFailReason.BeGoodAtReason = v.FailReason - case "license_cert": - idenAuthFailReason.LicenseCertReason = v.FailReason - case "qualification_cert": - idenAuthFailReason.QualificationCertReason = v.FailReason - case "work_cert": - idenAuthFailReason.WorkCertReason = v.FailReason - default: - return nil, errors.New("审核失败原因数据错误") - } - } - } - - return &idenAuthFailReason, nil + return responses, nil } // GetUserDoctorPending 身份审核-医生详情 -func (r *UserDoctorService) GetUserDoctorPending(doctorId int64) (g *userDoctorResponse.GetUserDoctorPending, err error) { +func (r *UserDoctorService) GetUserDoctorPending(doctorId int64) (g *dto.UserDoctorPendingDto, err error) { // 获取医生数据 userDoctorDao := dao.UserDoctorDao{} userDoctor, err := userDoctorDao.GetUserDoctorPreloadById(doctorId) @@ -1230,59 +1120,29 @@ func (r *UserDoctorService) GetUserDoctorPending(doctorId int64) (g *userDoctorR } // 获取医生审核失败原因 - var IdenAuthFailReason *userDoctorResponse.IdenAuthFailReason - if userDoctor.IdenAuthStatus == 3 { - IdenAuthFailReason, err = userDoctorService.GetDoctorIdenFailReasonByDoctorId(doctorId) - if err != nil { - return nil, errors.New(err.Error()) - } + doctorIdenFailDao := dao.DoctorIdenFailDao{} + doctorIdenFail, err := doctorIdenFailDao.GetDoctorIdenFailListByDoctorId(doctorId) + if err != nil { + return nil, errors.New(err.Error()) } + // 处理返回值 - var userDoctorInfo *userDoctorInfoResponse.UserDoctorInfo - if userDoctor.UserDoctorInfo != nil { - userDoctorInfo = userDoctorInfoResponse.UserDoctorInfoResponse(userDoctor.UserDoctorInfo) - } + g = dto.GetUserDoctorPendingDto(userDoctor) - // 医院 - var hospital *hospitalResponse.Hospital - if userDoctor.Hospital != nil { - hospital = hospitalResponse.HospitalResponse(userDoctor.Hospital) - } + // 加载用户 + g.LoadUser(userDoctor.User) - // 用户 - var user *userResponse.User - if userDoctor.User != nil { - user = userResponse.UserResponse(userDoctor.User) - } + // 加载医院 + g.LoadHospital(userDoctor.Hospital) - g = &userDoctorResponse.GetUserDoctorPending{ - DoctorID: strconv.Itoa(int(userDoctor.DoctorId)), - UserID: strconv.Itoa(int(userDoctor.UserId)), - UserName: userDoctor.UserName, - Status: userDoctor.Status, - IDCardStatus: userDoctor.Status, - IdenAuthStatus: userDoctor.IdenAuthStatus, - IdenAuthTime: userDoctor.IdenAuthTime, - IdenAuthFailReason: IdenAuthFailReason, - Avatar: utils.AddOssDomain(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, - IsPlatformDeepCooperation: userDoctor.IsPlatformDeepCooperation, - IsEnterpriseDeepCooperation: userDoctor.IsEnterpriseDeepCooperation, - IsSysDiagnoCooperation: userDoctor.IsSysDiagnoCooperation, - IsRecommend: userDoctor.IsRecommend, - CreatedAt: userDoctor.CreatedAt, - UpdatedAt: userDoctor.UpdatedAt, - User: user, - Hospital: hospital, - UserDoctorInfo: userDoctorInfo, - DoctorExpertise: doctorExpertise, // 专长 - } + // 加载医生专长 + g.DoctorExpertise = doctorExpertise + + // 加载医生详情 + g.LoadUserDoctorInfo(userDoctor.UserDoctorInfo) + + // 加载医生审核失败原因 + g.IdenAuthFailReason = dto.GetIdenAuthFailReasonDto(doctorIdenFail) return g, nil } @@ -1508,7 +1368,7 @@ func (r *UserDoctorService) PutUserDoctorPending(doctorId int64, req requests.Pu } // GetMulti 多点-医生详情 -func (r *UserDoctorService) GetMulti(doctorId int64) (g *userDoctorResponse.GetMulti, err error) { +func (r *UserDoctorService) GetMulti(doctorId int64) (g *dto.UserDoctorDto, err error) { // 获取医生数据 userDoctorDao := dao.UserDoctorDao{} userDoctor, err := userDoctorDao.GetUserDoctorPreloadById(doctorId) @@ -1517,46 +1377,16 @@ func (r *UserDoctorService) GetMulti(doctorId int64) (g *userDoctorResponse.GetM } // 处理返回值 - var userDoctorInfo *userDoctorInfoResponse.UserDoctorInfo - if userDoctor.UserDoctorInfo != nil { - userDoctorInfo = userDoctorInfoResponse.UserDoctorInfoResponse(userDoctor.UserDoctorInfo) - } + g = dto.GetUserDoctorDto(userDoctor) - // 医院 - var hospital *hospitalResponse.Hospital - if userDoctor.Hospital != nil { - hospital = hospitalResponse.HospitalResponse(userDoctor.Hospital) - } + // 加载用户 + g.LoadUser(userDoctor.User) - // 用户 - var user *userResponse.User - if userDoctor.User != nil { - user = userResponse.UserResponse(userDoctor.User) - } + // 加载医院 + g.LoadHospital(userDoctor.Hospital) - 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: utils.AddOssDomain(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, - } + // 加载医生详情 + g.LoadUserDoctorInfo(userDoctor.UserDoctorInfo) return g, nil } @@ -1739,8 +1569,8 @@ func (r *UserDoctorService) PutMulti(doctorId int64, req requests.PutMulti) (boo return true, nil } -// GetOrderInquiryUserDoctor 获取医生数据-问诊订单 -func (r *UserDoctorService) GetOrderInquiryUserDoctor(doctorId int64) (u *userDoctorResponse.OrderInquiryUserDoctor, err error) { +// GetUserDoctorById 获取医生数据-医生id +func (r *UserDoctorService) GetUserDoctorById(doctorId int64) (g *dto.UserDoctorDto, err error) { if doctorId == 0 { return nil, nil } @@ -1750,33 +1580,14 @@ func (r *UserDoctorService) GetOrderInquiryUserDoctor(doctorId int64) (u *userDo return nil, errors.New("医生数据错误") } - // 医院 - var hospital *hospitalResponse.Hospital - if userDoctor.Hospital != nil { - hospital = hospitalResponse.HospitalResponse(userDoctor.Hospital) - } + // 处理返回值 + g = dto.GetUserDoctorDto(userDoctor) - var userDoctorInfo *userDoctorInfoResponse.UserDoctorInfo - if userDoctor.UserDoctorInfo != nil { - userDoctorInfo = userDoctorInfoResponse.UserDoctorInfoResponse(userDoctor.UserDoctorInfo) - } + // 加载医院 + g.LoadHospital(userDoctor.Hospital) - u = &userDoctorResponse.OrderInquiryUserDoctor{ - DoctorID: strconv.Itoa(int(userDoctor.DoctorId)), - UserID: strconv.Itoa(int(userDoctor.UserId)), - UserName: userDoctor.UserName, - Status: userDoctor.Status, - IDCardStatus: userDoctor.Status, - MultiPointStatus: userDoctor.MultiPointStatus, - Avatar: utils.AddOssDomain(userDoctor.Avatar), - DoctorTitle: userDoctor.DoctorTitle, - DepartmentCustomName: userDoctor.DepartmentCustomName, - HospitalID: strconv.Itoa(int(userDoctor.HospitalID)), - CreatedAt: userDoctor.CreatedAt, - UpdatedAt: userDoctor.UpdatedAt, - Hospital: hospital, - UserDoctorInfo: userDoctorInfo, - } + // 加载医生详情 + g.LoadUserDoctorInfo(userDoctor.UserDoctorInfo) - return u, nil + return g, nil } diff --git a/api/service/userPatient.go b/api/service/userPatient.go index 89e52c7..7ab386b 100644 --- a/api/service/userPatient.go +++ b/api/service/userPatient.go @@ -2,22 +2,17 @@ package service import ( "errors" - "fmt" "hospital-admin-api/api/dao" + "hospital-admin-api/api/dto" "hospital-admin-api/api/requests" - "hospital-admin-api/api/responses/patientFamilyResponse" - "hospital-admin-api/api/responses/userPatientResponse" - "hospital-admin-api/api/responses/userResponse" - "hospital-admin-api/api/responses/userShipAddressResponse" "hospital-admin-api/global" - "hospital-admin-api/utils" ) type UserPatientService struct { } // GetUserPatient 患者详情 -func (r *UserPatientService) GetUserPatient(patientId int64) (getUserPatientResponse *userPatientResponse.GetUserPatient, err error) { +func (r *UserPatientService) GetUserPatient(patientId int64) (g *dto.UserPatientDto, err error) { // 获取患者数据 userPatientDao := dao.UserPatientDao{} userPatient, err := userPatientDao.GetUserPatientPreloadById(patientId) @@ -25,39 +20,19 @@ func (r *UserPatientService) GetUserPatient(patientId int64) (getUserPatientResp return nil, errors.New("患者错误") } - // 患者收货地址 - var userShipAddress []*userShipAddressResponse.UserShipAddress - if userPatient.UserShipAddress != nil { - userShipAddress = userShipAddressResponse.GetUserShipAddressListResponse(userPatient.UserShipAddress) - } + // 处理返回数据 + g = dto.GetUserPatientDto(userPatient) - // 获取家庭成员数据 - var patientFamilysResponse []*patientFamilyResponse.GetUserPatient - if userPatient.PatientFamily != nil { - patientFamilysResponse = patientFamilyResponse.GetUserPatientResponse(userPatient.PatientFamily) - } + // 加载用户手机号 + g.LoadPatientMobile(userPatient.User) - // 获取用户数据 - var user *userResponse.User - if userPatient.User != nil { - user = userResponse.UserResponse(userPatient.User) - } + // 加载用户收货地址 + g.LoadUserShipAddress(userPatient.UserShipAddress) - getUserPatientResponse = &userPatientResponse.GetUserPatient{ - PatientId: fmt.Sprintf("%d", userPatient.PatientId), - UserId: fmt.Sprintf("%d", userPatient.UserId), - UserName: userPatient.UserName, - Status: &userPatient.Status, - Avatar: utils.AddOssDomain(userPatient.Avatar), - Mobile: user.Mobile, - DisableReason: userPatient.DisableReason, - PatientFamily: patientFamilysResponse, - UserShipAddress: userShipAddress, - CreatedAt: userPatient.CreatedAt, - UpdatedAt: userPatient.UpdatedAt, - } + // 加载家庭成员数据 + g.LoadMaskPatientFamily(userPatient.PatientFamily) - return getUserPatientResponse, nil + return g, nil } // PutUserDoctorStatus 修改患者状态 diff --git a/api/service/userPharmacist.go b/api/service/userPharmacist.go new file mode 100644 index 0000000..2d240e0 --- /dev/null +++ b/api/service/userPharmacist.go @@ -0,0 +1,4 @@ +package service + +type UserPharmacistService struct { +}