新增专长
This commit is contained in:
parent
b7528ce40f
commit
fade9ea4a7
@ -25,6 +25,7 @@ type userDoctorManage struct {
|
||||
|
||||
// Basic 基础数据
|
||||
type basic struct {
|
||||
Department // 科室管理
|
||||
Hospital // 医院管理
|
||||
Department // 科室管理
|
||||
Hospital // 医院管理
|
||||
DiseaseClassExpertise // 专长管理
|
||||
}
|
||||
|
||||
@ -29,28 +29,7 @@ func (b *Department) GetDepartmentCustomList(c *gin.Context) {
|
||||
|
||||
hospitalDepartmentCustomDao := dao.HospitalDepartmentCustom{}
|
||||
|
||||
maps := make(map[string]interface{})
|
||||
if departmentRequest.DepartmentId != "" {
|
||||
maps["department_id"] = departmentRequest.DepartmentId
|
||||
}
|
||||
|
||||
if departmentRequest.DepartmentCustomName != "" {
|
||||
maps["department_custom_name"] = departmentRequest.DepartmentCustomName
|
||||
}
|
||||
|
||||
if departmentRequest.DepartmentName != "" {
|
||||
maps["department_name"] = departmentRequest.DepartmentName
|
||||
}
|
||||
|
||||
if departmentRequest.DepartmentCode != "" {
|
||||
maps["department_code"] = departmentRequest.DepartmentCode
|
||||
}
|
||||
|
||||
if departmentRequest.DepartmentStatus != 0 {
|
||||
maps["department_status"] = departmentRequest.DepartmentStatus
|
||||
}
|
||||
|
||||
hospitalDepartmentCustom, err := hospitalDepartmentCustomDao.GetHospitalDepartmentCustomList(maps)
|
||||
hospitalDepartmentCustom, err := hospitalDepartmentCustomDao.GetHospitalDepartmentCustomListByMaps(departmentRequest.GetDepartmentCustomList)
|
||||
if err != nil {
|
||||
responses.Ok(c)
|
||||
return
|
||||
|
||||
41
api/controller/diseaseClassExpertise.go
Normal file
41
api/controller/diseaseClassExpertise.go
Normal file
@ -0,0 +1,41 @@
|
||||
// Package controller 专长
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses"
|
||||
"hospital-admin-api/api/responses/diseaseClassExpertiseResponse"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
)
|
||||
|
||||
type DiseaseClassExpertise struct{}
|
||||
|
||||
// GetExpertiseList 获取专长列表
|
||||
func (b *DiseaseClassExpertise) GetExpertiseList(c *gin.Context) {
|
||||
expertiseRequest := requests.ExpertiseRequest{}
|
||||
if err := c.ShouldBind(&expertiseRequest.GetExpertiseList); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(expertiseRequest.GetExpertiseList); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
diseaseClassExpertiseDao := dao.DiseaseClassExpertiseDao{}
|
||||
|
||||
diseaseClassExpertises, err := diseaseClassExpertiseDao.GetDiseaseClassExpertiseListByMaps(expertiseRequest.GetExpertiseList)
|
||||
if err != nil {
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
getDepartmentListResponse := diseaseClassExpertiseResponse.GetDiseaseClassExpertiseListResponse(diseaseClassExpertises)
|
||||
responses.OkWithData(getDepartmentListResponse, c)
|
||||
}
|
||||
@ -3,6 +3,7 @@ package dao
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
@ -70,3 +71,22 @@ func (r *DiseaseClassExpertiseDao) AddDiseaseClassExpertiseByMap(tx *gorm.DB, da
|
||||
}
|
||||
return userDoctorInfo, nil
|
||||
}
|
||||
|
||||
// GetDiseaseClassExpertiseListByMaps 获取专长列表
|
||||
func (r *DiseaseClassExpertiseDao) GetDiseaseClassExpertiseListByMaps(expertiseRequest requests.GetExpertiseList) (m []*model.DiseaseClassExpertise, err error) {
|
||||
result := global.Db
|
||||
|
||||
if expertiseRequest.ExpertiseId != "" {
|
||||
result = result.Where("expertise_id = ?", expertiseRequest.ExpertiseId)
|
||||
}
|
||||
|
||||
if expertiseRequest.ExpertiseName != "" {
|
||||
result = result.Where("expertise_name like ?", "%"+expertiseRequest.ExpertiseName+"%")
|
||||
}
|
||||
|
||||
err = result.Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
11
api/requests/expertise.go
Normal file
11
api/requests/expertise.go
Normal file
@ -0,0 +1,11 @@
|
||||
package requests
|
||||
|
||||
type ExpertiseRequest struct {
|
||||
GetExpertiseList // 获取专长列表
|
||||
}
|
||||
|
||||
// GetExpertiseList 获取专长列表
|
||||
type GetExpertiseList struct {
|
||||
ExpertiseId string `json:"expertise_id" form:"expertise_id" label:"主键id"`
|
||||
ExpertiseName string `json:"expertise_name" form:"expertise_name" label:"专长名称"`
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
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
|
||||
}
|
||||
@ -283,4 +283,19 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
// 获取医院列表-限制条数
|
||||
hospitalGroup.GET("/list", api.Hospital.GetHospitalLimit)
|
||||
}
|
||||
|
||||
// 专长管理-基础数据
|
||||
expertiseGroup := adminGroup.Group("/expertise")
|
||||
{
|
||||
// 获取专长列表
|
||||
expertiseGroup.GET("/list", api.DiseaseClassExpertise.GetExpertiseList)
|
||||
|
||||
// 获取专长列表-分页
|
||||
|
||||
// 专长详情
|
||||
|
||||
// 修改专长
|
||||
|
||||
// 新增专长
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user