新增患者详情
This commit is contained in:
parent
ce3168867f
commit
dbe0e24241
@ -71,12 +71,12 @@ func (r *UserPatient) GetUserPatient(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
userDoctorService := service.UserDoctorService{}
|
||||
getUserDoctorResponses, err := userDoctorService.GetUserDoctor(patientId)
|
||||
userPatientService := service.UserPatientService{}
|
||||
getUserPatientResponses, err := userPatientService.GetUserPatient(patientId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(getUserDoctorResponses, c)
|
||||
responses.OkWithData(getUserPatientResponses, c)
|
||||
}
|
||||
|
||||
@ -18,6 +18,15 @@ func (r *PatientFamilyDao) GetPatientFamilyById(familyId int64) (m *model.Patien
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetPatientFamilyListByPatientId 获取家庭成员列表-患者id
|
||||
func (r *PatientFamilyDao) GetPatientFamilyListByPatientId(patientId int64) (m []*model.PatientFamily, err error) {
|
||||
err = global.Db.Where("patient_id = ?", patientId).Find(&m, patientId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeletePatientFamily 删除家庭成员
|
||||
func (r *PatientFamilyDao) DeletePatientFamily(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.PatientFamily{}).Error
|
||||
|
||||
82
api/dao/userShipAddress.go
Normal file
82
api/dao/userShipAddress.go
Normal file
@ -0,0 +1,82 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type UserShipAddressDao struct {
|
||||
}
|
||||
|
||||
// GetUserShipAddressById 获取用户收货地址数据-用户收货地址id
|
||||
func (r *UserShipAddressDao) GetUserShipAddressById(addressId int64) (m *model.UserShipAddress, err error) {
|
||||
err = global.Db.First(&m, addressId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetUserShipAddressPreloadById 获取用户收货地址数据-加载全部关联-用户收货地址id
|
||||
func (r *UserShipAddressDao) GetUserShipAddressPreloadById(addressId int64) (m *model.UserShipAddress, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, addressId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetUserShipAddressListByOrderUserId 获取用户收货地址数据-用户id
|
||||
func (r *UserShipAddressDao) GetUserShipAddressListByOrderUserId(userId int64) (m []*model.UserShipAddress, err error) {
|
||||
err = global.Db.Where("user_id = ?", userId).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteUserShipAddress 删除用户收货地址
|
||||
func (r *UserShipAddressDao) DeleteUserShipAddress(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.UserShipAddress{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditUserShipAddress 修改用户收货地址
|
||||
func (r *UserShipAddressDao) EditUserShipAddress(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.UserShipAddress{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditUserShipAddressById 修改用户收货地址-用户收货地址id
|
||||
func (r *UserShipAddressDao) EditUserShipAddressById(tx *gorm.DB, addressId int64, data interface{}) error {
|
||||
err := tx.Model(&model.UserShipAddress{}).Where("address_id = ?", addressId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetUserShipAddressList 获取用户收货地址列表
|
||||
func (r *UserShipAddressDao) GetUserShipAddressList(maps interface{}) (m []*model.UserShipAddress, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddUserShipAddress 新增用户收货地址
|
||||
func (r *UserShipAddressDao) AddUserShipAddress(tx *gorm.DB, model *model.UserShipAddress) (*model.UserShipAddress, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
@ -21,6 +21,7 @@ type User struct {
|
||||
Age uint `gorm:"column:age;type:int(10) unsigned;comment:年龄" json:"age"`
|
||||
Sex int `gorm:"column:sex;type:tinyint(1);default:0;comment:性别(0:未知 1:男 2:女)" json:"sex"`
|
||||
Avatar string `gorm:"column:avatar;type:varchar(255);comment:头像" json:"avatar"`
|
||||
DisableReason string `gorm:"column:disable_reason;type:varchar(255);comment:禁用理由" json:"disable_reason"`
|
||||
LoginIp string `gorm:"column:login_ip;type:varchar(255);comment:登陆ip" json:"login_ip"`
|
||||
LastLoginAt LocalTime `gorm:"column:last_login_at;type:datetime;comment:最后登陆时间" json:"last_login_at"`
|
||||
CreatedBy string `gorm:"column:created_by;type:varchar(100);comment:创建者id(后台用户表id null:自己注册)" json:"created_by"`
|
||||
|
||||
@ -8,17 +8,19 @@ import (
|
||||
|
||||
// UserPatient 用户-患者表
|
||||
type UserPatient struct {
|
||||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);primary_key;comment:主键id" json:"patient_id"`
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
|
||||
UserName string `gorm:"column:user_name;type:varchar(100);comment:用户名称" json:"user_name"`
|
||||
OpenId string `gorm:"column:open_id;type:varchar(100);comment:微信open_id" json:"open_id"`
|
||||
UnionId string `gorm:"column:union_id;type:varchar(100);comment:微信开放平台唯一标识" json:"union_id"`
|
||||
WxSessionKey string `gorm:"column:wx_session_key;type:varchar(255);comment:微信会话密钥" json:"wx_session_key"`
|
||||
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(0:禁用 1:正常 2:删除)" json:"status"`
|
||||
IdcardStatus int `gorm:"column:idcard_status;type:tinyint(1);default:0;comment:实名认证状态(0:未认证 1:认证通过 2:认证失败)" json:"idcard_status"`
|
||||
Avatar string `gorm:"column:avatar;type:varchar(255);comment:头像" json:"avatar"`
|
||||
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 用户
|
||||
PatientFamily []*PatientFamily `gorm:"foreignKey:PatientId;references:patient_id" json:"patient_family"` // 家庭成员
|
||||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);primary_key;comment:主键id" json:"patient_id"`
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
|
||||
UserName string `gorm:"column:user_name;type:varchar(100);comment:用户名称" json:"user_name"`
|
||||
OpenId string `gorm:"column:open_id;type:varchar(100);comment:微信open_id" json:"open_id"`
|
||||
UnionId string `gorm:"column:union_id;type:varchar(100);comment:微信开放平台唯一标识" json:"union_id"`
|
||||
WxSessionKey string `gorm:"column:wx_session_key;type:varchar(255);comment:微信会话密钥" json:"wx_session_key"`
|
||||
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(0:禁用 1:正常 2:删除)" json:"status"`
|
||||
IdcardStatus int `gorm:"column:idcard_status;type:tinyint(1);default:0;comment:实名认证状态(0:未认证 1:认证通过 2:认证失败)" json:"idcard_status"`
|
||||
Avatar string `gorm:"column:avatar;type:varchar(255);comment:头像" json:"avatar"`
|
||||
DisableReason string `gorm:"column:disable_reason;type:varchar(255);comment:禁用理由" json:"disable_reason"`
|
||||
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 用户
|
||||
PatientFamily []*PatientFamily `gorm:"foreignKey:PatientId;references:patient_id" json:"patient_family"` // 家庭成员
|
||||
UserShipAddress []*UserShipAddress `gorm:"foreignKey:UserId;references:user_id" json:"UserShipAddress"` // 收货地址
|
||||
Model
|
||||
}
|
||||
|
||||
|
||||
49
api/model/userShipAddress.go
Normal file
49
api/model/userShipAddress.go
Normal file
@ -0,0 +1,49 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserShipAddress 用户收货地址表
|
||||
type UserShipAddress struct {
|
||||
AddressId int64 `gorm:"column:address_id;type:bigint(19);primary_key;comment:主键id" json:"address_id"`
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
|
||||
ProvinceId int `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
|
||||
Province string `gorm:"column:province;type:varchar(40);comment:省份" json:"province"`
|
||||
CityId int `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
|
||||
City string `gorm:"column:city;type:varchar(40);comment:城市" json:"city"`
|
||||
CountyId int `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
|
||||
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
|
||||
ConsigneeTownId int `gorm:"column:consignee_town_id;type:int(11);comment:镇id" json:"consignee_town_id"`
|
||||
ConsigneeTown string `gorm:"column:consignee_town;type:varchar(150);comment:镇" json:"consignee_town"`
|
||||
Address string `gorm:"column:address;type:varchar(255);comment:详细地址" json:"address"`
|
||||
AddressMask string `gorm:"column:address_mask;type:varchar(255);comment:详细地址(掩码)" json:"address_mask"`
|
||||
ConsigneeName string `gorm:"column:consignee_name;type:varchar(150);comment:收货人姓名;NOT NULL" json:"consignee_name"`
|
||||
ConsigneeNameMask string `gorm:"column:consignee_name_mask;type:varchar(150);comment:收货人姓名(掩码)" json:"consignee_name_mask"`
|
||||
ConsigneeTel string `gorm:"column:consignee_tel;type:varchar(100);comment:收货人电话;NOT NULL" json:"consignee_tel"`
|
||||
ConsigneeTelMask string `gorm:"column:consignee_tel_mask;type:varchar(100);comment:收货人电话(掩码)" json:"consignee_tel_mask"`
|
||||
ConsigneeZipCode string `gorm:"column:consignee_zip_code;type:varchar(20);comment:收货邮编" json:"consignee_zip_code"`
|
||||
IsDefault int `gorm:"column:is_default;type:tinyint(1);default:0;comment:默认地址(0:否 1:是)" json:"is_default"`
|
||||
Tag int `gorm:"column:tag;type:tinyint(1);comment:地址标签(1:家 2:公司 3:学校 4:其他)" json:"tag"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *UserShipAddress) TableName() string {
|
||||
return "gdxz_user_ship_address"
|
||||
}
|
||||
|
||||
func (m *UserShipAddress) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.AddressId == 0 {
|
||||
m.AddressId = 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
|
||||
}
|
||||
@ -2,8 +2,6 @@ package orderProductItemResponse
|
||||
|
||||
import (
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/utils"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type OrderProductItem struct {
|
||||
@ -22,36 +20,3 @@ type OrderProductItem struct {
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
|
||||
// GetOrderProductItemListResponse 获取订单商品列表
|
||||
func GetOrderProductItemListResponse(u []*model.OrderProductItem) []*OrderProductItem {
|
||||
// 处理返回值
|
||||
orderProductItemResponses := make([]*OrderProductItem, len(u))
|
||||
|
||||
if len(u) > 0 {
|
||||
for i, v := range u {
|
||||
// 将原始结构体转换为新结构体
|
||||
orderProductItemResponse := &OrderProductItem{
|
||||
ProductItemId: strconv.Itoa(int(v.ProductItemId)),
|
||||
OrderProductId: strconv.Itoa(int(v.OrderProductId)),
|
||||
OrderInquiryId: strconv.Itoa(int(v.OrderInquiryId)),
|
||||
OrderPrescriptionId: strconv.Itoa(int(v.OrderPrescriptionId)),
|
||||
ProductId: strconv.Itoa(int(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,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
orderProductItemResponses[i] = orderProductItemResponse
|
||||
}
|
||||
}
|
||||
|
||||
return orderProductItemResponses
|
||||
}
|
||||
|
||||
84
api/responses/patientFamilyResponse/patientFamily.go
Normal file
84
api/responses/patientFamilyResponse/patientFamily.go
Normal file
@ -0,0 +1,84 @@
|
||||
package patientFamilyResponse
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
)
|
||||
|
||||
type PatientFamily 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"` // 职业名称
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetUserPatient 患者详情
|
||||
type GetUserPatient 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"` // 更新时间
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
@ -3,10 +3,12 @@ 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 获取医生列表-分页
|
||||
// getUserPatientPage 获取患者列表-分页
|
||||
type getUserPatientPage struct {
|
||||
PatientId string `json:"patient_id"` // 主键id
|
||||
UserId string `json:"user_id"` // 用户id;NOT NULL
|
||||
@ -14,11 +16,26 @@ type getUserPatientPage struct {
|
||||
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"` // 更新时间
|
||||
}
|
||||
|
||||
// GetUserPatient 患者详情
|
||||
type GetUserPatient 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"` // 手机号
|
||||
PatientFamily []*patientFamilyResponse.GetUserPatient `json:"patient_family"` // 家庭成员
|
||||
UserShipAddress []*userShipAddressResponse.UserShipAddress `json:"user_ship_address"` // 收货地址
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetUserPatientPageResponse 获取用户列表-分页
|
||||
func GetUserPatientPageResponse(userPatient []*model.UserPatient) []getUserPatientPage {
|
||||
// 处理返回值
|
||||
@ -28,13 +45,14 @@ func GetUserPatientPageResponse(userPatient []*model.UserPatient) []getUserPatie
|
||||
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),
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
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 {
|
||||
|
||||
70
api/responses/userShipAddressResponse/userShipAddress.go
Normal file
70
api/responses/userShipAddressResponse/userShipAddress.go
Normal file
@ -0,0 +1,70 @@
|
||||
package userShipAddressResponse
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
)
|
||||
|
||||
type UserShipAddress 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"` // 修改时间
|
||||
}
|
||||
|
||||
// GetUserShipAddressListResponse 获取收货地址列表
|
||||
func GetUserShipAddressListResponse(userShipAddress []*model.UserShipAddress) []*UserShipAddress {
|
||||
// 处理返回值
|
||||
items := make([]*UserShipAddress, len(userShipAddress))
|
||||
|
||||
if len(userShipAddress) > 0 {
|
||||
for i, v := range userShipAddress {
|
||||
// 将原始结构体转换为新结构体
|
||||
item := &UserShipAddress{
|
||||
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,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
items[i] = item
|
||||
}
|
||||
}
|
||||
|
||||
return items
|
||||
}
|
||||
48
api/service/patientFamily.go
Normal file
48
api/service/patientFamily.go
Normal file
@ -0,0 +1,48 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/responses/patientFamilyResponse"
|
||||
)
|
||||
|
||||
type PatientFamilyService struct {
|
||||
}
|
||||
|
||||
// GetPatientFamilyListByPatientId 获取患者家庭成员-患者id
|
||||
func (r *PatientFamilyService) GetPatientFamilyListByPatientId(patientId int64) (u []*patientFamilyResponse.GetUserPatient, err error) {
|
||||
patientFamilyDao := dao.PatientFamilyDao{}
|
||||
patientFamilys, err := patientFamilyDao.GetPatientFamilyListByPatientId(patientId)
|
||||
|
||||
if len(patientFamilys) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
items := make([]*patientFamilyResponse.GetUserPatient, len(patientFamilys))
|
||||
|
||||
if len(patientFamilys) > 0 {
|
||||
for i, v := range patientFamilys {
|
||||
// 将原始结构体转换为新结构体
|
||||
item := &patientFamilyResponse.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,
|
||||
MobileMask: v.MobileMask,
|
||||
IdNumberMask: v.IdNumberMask,
|
||||
Sex: &v.Sex,
|
||||
Age: v.Age,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
items[i] = item
|
||||
}
|
||||
}
|
||||
|
||||
return items, nil
|
||||
}
|
||||
@ -1,4 +1,58 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"hospital-admin-api/api/dao"
|
||||
"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/utils"
|
||||
)
|
||||
|
||||
type UserPatientService struct {
|
||||
}
|
||||
|
||||
// GetUserPatient 患者详情
|
||||
func (r *UserPatientService) GetUserPatient(patientId int64) (getUserPatientResponse *userPatientResponse.GetUserPatient, err error) {
|
||||
// 获取患者数据
|
||||
userPatientDao := dao.UserPatientDao{}
|
||||
userPatient, err := userPatientDao.GetUserPatientPreloadById(patientId)
|
||||
if err != nil || userPatient == nil {
|
||||
return nil, errors.New("患者错误")
|
||||
}
|
||||
|
||||
// 患者收货地址
|
||||
var userShipAddress []*userShipAddressResponse.UserShipAddress
|
||||
if userPatient.UserShipAddress != nil {
|
||||
userShipAddress = userShipAddressResponse.GetUserShipAddressListResponse(userPatient.UserShipAddress)
|
||||
}
|
||||
|
||||
// 获取家庭成员数据
|
||||
var patientFamilysResponse []*patientFamilyResponse.GetUserPatient
|
||||
if userPatient.PatientFamily != nil {
|
||||
patientFamilysResponse = patientFamilyResponse.GetUserPatientResponse(userPatient.PatientFamily)
|
||||
}
|
||||
|
||||
// 获取用户数据
|
||||
var user *userResponse.User
|
||||
if userPatient.User != nil {
|
||||
user = userResponse.UserResponse(userPatient.User)
|
||||
}
|
||||
|
||||
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,
|
||||
PatientFamily: patientFamilysResponse,
|
||||
UserShipAddress: userShipAddress,
|
||||
CreatedAt: userPatient.CreatedAt,
|
||||
UpdatedAt: userPatient.UpdatedAt,
|
||||
}
|
||||
|
||||
return getUserPatientResponse, nil
|
||||
}
|
||||
|
||||
57
api/service/userShipAddress.go
Normal file
57
api/service/userShipAddress.go
Normal file
@ -0,0 +1,57 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/responses/userShipAddressResponse"
|
||||
)
|
||||
|
||||
type UserShipAddressService struct {
|
||||
}
|
||||
|
||||
// GetUserShipAddressByUserId 获取用户收货地址-用户id
|
||||
func (r *UserShipAddressService) GetUserShipAddressByUserId(userId int64) (u []*userShipAddressResponse.UserShipAddress, err error) {
|
||||
userShipAddressDao := dao.UserShipAddressDao{}
|
||||
orderProductLogistics, err := userShipAddressDao.GetUserShipAddressListByOrderUserId(userId)
|
||||
|
||||
if len(orderProductLogistics) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
items := make([]*userShipAddressResponse.UserShipAddress, len(orderProductLogistics))
|
||||
|
||||
if len(orderProductLogistics) > 0 {
|
||||
for i, v := range orderProductLogistics {
|
||||
// 将原始结构体转换为新结构体
|
||||
item := &userShipAddressResponse.UserShipAddress{
|
||||
AddressId: fmt.Sprintf("%d", v.AddressId),
|
||||
UserId: fmt.Sprintf("%d", v.AddressId),
|
||||
ProvinceId: fmt.Sprintf("%d", v.AddressId),
|
||||
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,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
items[i] = item
|
||||
}
|
||||
}
|
||||
|
||||
return items, nil
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user