新增获取就诊人列表-分页
This commit is contained in:
@@ -44,7 +44,8 @@ type order struct {
|
||||
|
||||
// 患者管理
|
||||
type userPatientManage struct {
|
||||
UserPatient // 患者列表
|
||||
UserPatient // 患者列表
|
||||
PatientFamily // 家庭成员管理
|
||||
}
|
||||
|
||||
// 病例管理
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
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/patientFamilyResponse"
|
||||
"hospital-admin-api/api/service"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type PatientFamily struct{}
|
||||
|
||||
// GetPatientFamilyPage 获取就诊人列表-分页
|
||||
func (r *PatientFamily) GetPatientFamilyPage(c *gin.Context) {
|
||||
req := requests.PatientFamilyRequest{}
|
||||
if err := c.ShouldBind(&req.GetPatientFamilyPage); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req.GetPatientFamilyPage); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
if req.GetPatientFamilyPage.Page == 0 {
|
||||
req.GetPatientFamilyPage.Page = 1
|
||||
}
|
||||
|
||||
if req.GetPatientFamilyPage.PageSize == 0 {
|
||||
req.GetPatientFamilyPage.PageSize = 20
|
||||
}
|
||||
|
||||
patientFamilyDao := dao.PatientFamilyDao{}
|
||||
patientFamily, total, err := patientFamilyDao.GetPatientFamilyPageSearch(req.GetPatientFamilyPage, req.GetPatientFamilyPage.Page, req.GetPatientFamilyPage.PageSize)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
GetPatientFamilyPage := patientFamilyResponse.GetPatientFamilyPageResponse(patientFamily)
|
||||
|
||||
result := make(map[string]interface{})
|
||||
result["page"] = req.GetPatientFamilyPage.Page
|
||||
result["page_size"] = req.GetPatientFamilyPage.PageSize
|
||||
result["total"] = total
|
||||
result["data"] = GetPatientFamilyPage
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// GetUserPatient 患者详情
|
||||
func (r *PatientFamily) GetUserPatient(c *gin.Context) {
|
||||
id := c.Param("patient_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 将 id 转换为 int64 类型
|
||||
patientId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
userPatientService := service.UserPatientService{}
|
||||
getUserPatientResponses, err := userPatientService.GetUserPatient(patientId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(getUserPatientResponses, c)
|
||||
}
|
||||
@@ -80,3 +80,41 @@ func (r *UserPatient) GetUserPatient(c *gin.Context) {
|
||||
|
||||
responses.OkWithData(getUserPatientResponses, c)
|
||||
}
|
||||
|
||||
// PutUserDoctorStatus 修改患者状态
|
||||
func (r *UserPatient) PutUserDoctorStatus(c *gin.Context) {
|
||||
userPatientRequest := requests.UserPatientRequest{}
|
||||
if err := c.ShouldBind(&userPatientRequest.PutUserDoctorStatus); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(userPatientRequest.PutUserDoctorStatus); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
id := c.Param("patient_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 将 id 转换为 int64 类型
|
||||
patientId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
userPatientService := service.UserPatientService{}
|
||||
_, err = userPatientService.PutUserDoctorStatus(patientId, userPatientRequest.PutUserDoctorStatus)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user