初始化提交
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package controller
|
||||
|
||||
import "hospital-open-api/api/controller/v1"
|
||||
|
||||
// Api api接口
|
||||
type Api struct {
|
||||
V1 version1
|
||||
}
|
||||
|
||||
// version1 v1版本
|
||||
type version1 struct {
|
||||
UserDoctor v1.UserDoctor // 角色数据
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-open-api/api/dao"
|
||||
"hospital-open-api/api/requests/v1"
|
||||
"hospital-open-api/api/responses"
|
||||
"hospital-open-api/api/responses/v1/userDoctorResponse"
|
||||
"hospital-open-api/global"
|
||||
"hospital-open-api/utils"
|
||||
)
|
||||
|
||||
type UserDoctor struct{}
|
||||
|
||||
// GetMultiDoctor 获取多点执业医生详情
|
||||
func (r *UserDoctor) GetMultiDoctor(c *gin.Context) {
|
||||
req := v1.UserDoctorRequest{}
|
||||
if err := c.ShouldBindJSON(&req.GetMultiDoctor); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req.GetMultiDoctor); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctor(req.GetMultiDoctor)
|
||||
if err != nil && userDoctor == nil {
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
getMultiDoctorResponse := userDoctorResponse.GetMultiDoctorResponse(userDoctor)
|
||||
responses.OkWithData(getMultiDoctorResponse, c)
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type DoctorBankCardDao struct {
|
||||
}
|
||||
|
||||
// GetDoctorBankCardByDoctorId 获取医生银行卡数据-医生id
|
||||
func (r *DoctorBankCardDao) GetDoctorBankCardByDoctorId(doctorId int64) (m *model.DoctorBankCard, err error) {
|
||||
err = global.Db.Where("doctor_id = ?", doctorId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetDoctorBankCardListByDoctorId 获取医生银行卡数据列表-医生id
|
||||
func (r *DoctorBankCardDao) GetDoctorBankCardListByDoctorId(doctorId int64) (m []*model.DoctorBankCard, err error) {
|
||||
err = global.Db.Where("doctor_id = ?", doctorId).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteDoctorBankCard 删除医生银行卡
|
||||
func (r *DoctorBankCardDao) DeleteDoctorBankCard(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.DoctorBankCard{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditDoctorBankCard 修改医生银行卡
|
||||
func (r *DoctorBankCardDao) EditDoctorBankCard(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.DoctorBankCard{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditDoctorBankCardById 修改医生银行卡-医生id
|
||||
func (r *DoctorBankCardDao) EditDoctorBankCardById(tx *gorm.DB, doctorId int64, data interface{}) error {
|
||||
err := tx.Model(&model.DoctorBankCard{}).Where("doctor_id = ?", doctorId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDoctorBankCardList 获取医生银行卡列表
|
||||
func (r *DoctorBankCardDao) GetDoctorBankCardList(maps interface{}) (m []*model.DoctorBankCard, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddDoctorBankCard 新增医生银行卡
|
||||
func (r *DoctorBankCardDao) AddDoctorBankCard(tx *gorm.DB, model *model.DoctorBankCard) (*model.DoctorBankCard, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// AddDoctorBankCardByMap 新增医生银行卡-map
|
||||
func (r *DoctorBankCardDao) AddDoctorBankCardByMap(tx *gorm.DB, data map[string]interface{}) (*model.DoctorBankCard, error) {
|
||||
userDoctorInfo := &model.DoctorBankCard{}
|
||||
if err := tx.Model(&model.DoctorBankCard{}).Create(data).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return userDoctorInfo, nil
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type DoctorExpertiseDao struct {
|
||||
}
|
||||
|
||||
// GetDoctorExpertiseByDoctorId 获取医生专长数据-医生id
|
||||
func (r *DoctorExpertiseDao) GetDoctorExpertiseByDoctorId(doctorId int64) (m *model.DoctorExpertise, err error) {
|
||||
err = global.Db.Where("doctor_id = ?", doctorId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetDoctorExpertiseListByDoctorId 获取医生专长数据列表-医生id
|
||||
func (r *DoctorExpertiseDao) GetDoctorExpertiseListByDoctorId(doctorId int64) (m []*model.DoctorExpertise, err error) {
|
||||
err = global.Db.Where("doctor_id = ?", doctorId).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteDoctorExpertise 删除医生专长
|
||||
func (r *DoctorExpertiseDao) DeleteDoctorExpertise(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.DoctorExpertise{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditDoctorExpertise 修改医生专长
|
||||
func (r *DoctorExpertiseDao) EditDoctorExpertise(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.DoctorExpertise{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditDoctorExpertiseById 修改医生专长-医生id
|
||||
func (r *DoctorExpertiseDao) EditDoctorExpertiseById(tx *gorm.DB, doctorId int64, data interface{}) error {
|
||||
err := tx.Model(&model.DoctorExpertise{}).Where("doctor_id = ?", doctorId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDoctorExpertiseList 获取医生专长列表
|
||||
func (r *DoctorExpertiseDao) GetDoctorExpertiseList(maps interface{}) (m []*model.DoctorExpertise, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddDoctorExpertise 新增医生专长
|
||||
func (r *DoctorExpertiseDao) AddDoctorExpertise(tx *gorm.DB, model *model.DoctorExpertise) (*model.DoctorExpertise, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// AddDoctorExpertises 新增医生专长-多
|
||||
func (r *DoctorExpertiseDao) AddDoctorExpertises(tx *gorm.DB, models []model.DoctorExpertise) error {
|
||||
if err := tx.Create(&models).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddDoctorExpertiseByMap 新增医生专长-map
|
||||
func (r *DoctorExpertiseDao) AddDoctorExpertiseByMap(tx *gorm.DB, data map[string]interface{}) (*model.DoctorExpertise, error) {
|
||||
userDoctorInfo := &model.DoctorExpertise{}
|
||||
if err := tx.Model(&model.DoctorExpertise{}).Create(data).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return userDoctorInfo, nil
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type Hospital struct {
|
||||
}
|
||||
|
||||
// GetHospitalById 获取医院数据-医院id
|
||||
func (r *Hospital) GetHospitalById(hospitalId int64) (m *model.Hospital, err error) {
|
||||
err = global.Db.First(&m, hospitalId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddHospital 新增医院
|
||||
func (r *Hospital) AddHospital(tx *gorm.DB, model *model.Hospital) (*model.Hospital, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// GetHospitalList 获取医院列表
|
||||
func (r *Hospital) GetHospitalList(maps interface{}) (m []*model.Hospital, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteHospitalById 删除医院-医院id
|
||||
func (r *Hospital) DeleteHospitalById(tx *gorm.DB, hospitalId int64) error {
|
||||
if err := tx.Delete(&model.Hospital{}, hospitalId).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditHospitalById 修改医院-医院id
|
||||
func (r *Hospital) EditHospitalById(tx *gorm.DB, hospitalId int64, data interface{}) error {
|
||||
err := tx.Model(&model.Hospital{}).Where("hospital_id = ?", hospitalId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type HospitalDepartment struct {
|
||||
}
|
||||
|
||||
// GetHospitalDepartmentById 获取科室数据-科室id
|
||||
func (r *HospitalDepartment) GetHospitalDepartmentById(departmentId int64) (m *model.HospitalDepartment, err error) {
|
||||
err = global.Db.First(&m, departmentId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddHospitalDepartment 新增科室
|
||||
func (r *HospitalDepartment) AddHospitalDepartment(tx *gorm.DB, model *model.HospitalDepartment) (*model.HospitalDepartment, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// GetHospitalDepartmentList 获取科室列表
|
||||
func (r *HospitalDepartment) GetHospitalDepartmentList(maps interface{}) (m []*model.HospitalDepartment, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteHospitalDepartmentById 删除科室-科室id
|
||||
func (r *HospitalDepartment) DeleteHospitalDepartmentById(tx *gorm.DB, departmentId int64) error {
|
||||
if err := tx.Delete(&model.HospitalDepartment{}, departmentId).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditHospitalDepartmentById 修改科室-科室id
|
||||
func (r *HospitalDepartment) EditHospitalDepartmentById(tx *gorm.DB, departmentId int64, data interface{}) error {
|
||||
err := tx.Model(&model.HospitalDepartment{}).Where("department_id = ?", departmentId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type HospitalDepartmentCustom struct {
|
||||
}
|
||||
|
||||
// GetHospitalDepartmentCustomById 获取自定义科室数据-自定义科室id
|
||||
func (r *HospitalDepartmentCustom) GetHospitalDepartmentCustomById(departmentCustomId int64) (m *model.HospitalDepartmentCustom, err error) {
|
||||
err = global.Db.First(&m, departmentCustomId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddHospitalDepartmentCustom 新增自定义科室
|
||||
func (r *HospitalDepartmentCustom) AddHospitalDepartmentCustom(tx *gorm.DB, model *model.HospitalDepartmentCustom) (*model.HospitalDepartmentCustom, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// GetHospitalDepartmentCustomList 获取自定义科室列表
|
||||
func (r *HospitalDepartmentCustom) GetHospitalDepartmentCustomList(maps interface{}) (m []*model.HospitalDepartmentCustom, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteHospitalDepartmentCustomById 删除自定义科室-自定义科室id
|
||||
func (r *HospitalDepartmentCustom) DeleteHospitalDepartmentCustomById(tx *gorm.DB, departmentCustomId int64) error {
|
||||
if err := tx.Delete(&model.HospitalDepartmentCustom{}, departmentCustomId).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditHospitalDepartmentCustomById 修改自定义科室-自定义科室id
|
||||
func (r *HospitalDepartmentCustom) EditHospitalDepartmentCustomById(tx *gorm.DB, departmentCustomId int64, data interface{}) error {
|
||||
err := tx.Model(&model.HospitalDepartmentCustom{}).Where("department_custom_id = ?", departmentCustomId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type LogSms struct {
|
||||
}
|
||||
|
||||
// GetLogSmsById 获取短信数据-短信id
|
||||
func (r *LogSms) GetLogSmsById(hospitalId int64) (m *model.LogSms, err error) {
|
||||
err = global.Db.First(&m, hospitalId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (r *LogSms) GetLogSmsListByPhone(phone int64) (m []*model.LogSms, err error) {
|
||||
err = global.Db.Where("phone = ?", phone).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddLogSms 新增短信
|
||||
func (r *LogSms) AddLogSms(tx *gorm.DB, model *model.LogSms) (*model.LogSms, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// AddLogSmsUnTransaction 新增短信-无事物
|
||||
func (r *LogSms) AddLogSmsUnTransaction(model *model.LogSms) (*model.LogSms, error) {
|
||||
if err := global.Db.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// GetLogSmsList 获取短信列表
|
||||
func (r *LogSms) GetLogSmsList(maps interface{}) (m []*model.LogSms, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteLogSmsById 删除短信-短信id
|
||||
func (r *LogSms) DeleteLogSmsById(tx *gorm.DB, logId int64) error {
|
||||
if err := tx.Delete(&model.LogSms{}, logId).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type OpenKeyDao struct {
|
||||
}
|
||||
|
||||
// GetOpenKeyById 获取秘钥数据-开放id
|
||||
func (r *OpenKeyDao) GetOpenKeyById(openId int64) (m *model.OpenKey, err error) {
|
||||
err = global.Db.First(&m, openId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOpenKeyPreloadById 获取秘钥数据-开放id
|
||||
func (r *OpenKeyDao) GetOpenKeyPreloadById(openId int64) (m *model.OpenKey, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, openId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOpenKeyByDoctorId 获取医生详情数据-医生id
|
||||
func (r *OpenKeyDao) GetOpenKeyByDoctorId(appId string) (m *model.OpenKey, err error) {
|
||||
err = global.Db.Where("app_id = ?", appId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type OrderInquiryDao struct {
|
||||
}
|
||||
|
||||
// GetOrderInquiryById 获取问诊订单数据-问诊订单id
|
||||
func (r *OrderInquiryDao) GetOrderInquiryById(orderInquiryId int64) (m *model.OrderInquiry, err error) {
|
||||
err = global.Db.First(&m, orderInquiryId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryPreloadById 获取问诊订单数据-加载全部关联-问诊订单id
|
||||
func (r *OrderInquiryDao) GetOrderInquiryPreloadById(orderInquiryId int64) (m *model.OrderInquiry, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, orderInquiryId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteOrderInquiry 删除问诊订单
|
||||
func (r *OrderInquiryDao) DeleteOrderInquiry(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.OrderInquiry{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderInquiry 修改问诊订单
|
||||
func (r *OrderInquiryDao) EditOrderInquiry(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.OrderInquiry{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderInquiryById 修改问诊订单-问诊订单id
|
||||
func (r *OrderInquiryDao) EditOrderInquiryById(tx *gorm.DB, orderInquiryId int64, data interface{}) error {
|
||||
err := tx.Model(&model.OrderInquiry{}).Where("order_inquiry_id = ?", orderInquiryId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryList 获取问诊订单列表
|
||||
func (r *OrderInquiryDao) GetOrderInquiryList(maps interface{}) (m []*model.OrderInquiry, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddOrderInquiry 新增问诊订单
|
||||
func (r *OrderInquiryDao) AddOrderInquiry(tx *gorm.DB, model *model.OrderInquiry) (*model.OrderInquiry, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type OrderInquiryCouponDao struct {
|
||||
}
|
||||
|
||||
// GetOrderInquiryCouponById 获取问诊订单优惠卷数据-问诊订单优惠卷id
|
||||
func (r *OrderInquiryCouponDao) GetOrderInquiryCouponById(orderCouponId int64) (m *model.OrderInquiryCoupon, err error) {
|
||||
err = global.Db.First(&m, orderCouponId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (r *OrderInquiryCouponDao) GetOrderInquiryCouponByOrderInquiryId(orderInquiryId int64) (m *model.OrderInquiryCoupon, err error) {
|
||||
err = global.Db.Where("order_inquiry_id = ?", orderInquiryId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryCouponPreloadById 获取问诊订单优惠卷数据-加载全部关联-问诊订单优惠卷id
|
||||
func (r *OrderInquiryCouponDao) GetOrderInquiryCouponPreloadById(orderCouponId int64) (m *model.OrderInquiryCoupon, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, orderCouponId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteOrderInquiryCoupon 删除问诊订单优惠卷
|
||||
func (r *OrderInquiryCouponDao) DeleteOrderInquiryCoupon(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.OrderInquiryCoupon{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderInquiryCoupon 修改问诊订单优惠卷
|
||||
func (r *OrderInquiryCouponDao) EditOrderInquiryCoupon(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.OrderInquiryCoupon{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderInquiryCouponById 修改问诊订单优惠卷-问诊订单优惠卷id
|
||||
func (r *OrderInquiryCouponDao) EditOrderInquiryCouponById(tx *gorm.DB, orderCouponId int64, data interface{}) error {
|
||||
err := tx.Model(&model.OrderInquiryCoupon{}).Where("order_coupon_id = ?", orderCouponId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryCouponList 获取问诊订单优惠卷列表
|
||||
func (r *OrderInquiryCouponDao) GetOrderInquiryCouponList(maps interface{}) (m []*model.OrderInquiryCoupon, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddOrderInquiryCoupon 新增问诊订单优惠卷
|
||||
func (r *OrderInquiryCouponDao) AddOrderInquiryCoupon(tx *gorm.DB, model *model.OrderInquiryCoupon) (*model.OrderInquiryCoupon, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type OrderInquiryRefundDao struct {
|
||||
}
|
||||
|
||||
// GetOrderInquiryRefundById 获取问诊退款订单数据-问诊退款订单id
|
||||
func (r *OrderInquiryRefundDao) GetOrderInquiryRefundById(doctorId int64) (m *model.OrderInquiryRefund, err error) {
|
||||
err = global.Db.First(&m, doctorId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryRefundPreloadById 获取问诊退款订单数据-加载全部关联-问诊退款订单id
|
||||
func (r *OrderInquiryRefundDao) GetOrderInquiryRefundPreloadById(inquiryRefundId int64) (m *model.OrderInquiryRefund, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, inquiryRefundId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteOrderInquiryRefund 删除问诊退款订单
|
||||
func (r *OrderInquiryRefundDao) DeleteOrderInquiryRefund(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.OrderInquiryRefund{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderInquiryRefund 修改问诊退款订单
|
||||
func (r *OrderInquiryRefundDao) EditOrderInquiryRefund(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.OrderInquiryRefund{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderInquiryRefundById 修改问诊退款订单-问诊退款订单id
|
||||
func (r *OrderInquiryRefundDao) EditOrderInquiryRefundById(tx *gorm.DB, inquiryRefundId int64, data interface{}) error {
|
||||
err := tx.Model(&model.OrderInquiryRefund{}).Where("inquiry_refund_id = ?", inquiryRefundId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryRefundList 获取问诊退款订单列表
|
||||
func (r *OrderInquiryRefundDao) GetOrderInquiryRefundList(maps interface{}) (m []*model.OrderInquiryRefund, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddOrderInquiryRefund 新增问诊退款订单
|
||||
func (r *OrderInquiryRefundDao) AddOrderInquiryRefund(tx *gorm.DB, model *model.OrderInquiryRefund) (*model.OrderInquiryRefund, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type OrderPrescriptionDao struct {
|
||||
}
|
||||
|
||||
// GetById 获取处方-处方id
|
||||
func (r *OrderPrescriptionDao) GetById(orderPrescriptionId int64) (m *model.OrderPrescription, err error) {
|
||||
err = global.Db.First(&m, orderPrescriptionId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// Delete 删除处方
|
||||
func (r *OrderPrescriptionDao) Delete(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.OrderPrescription{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Edit 修改处方
|
||||
func (r *OrderPrescriptionDao) Edit(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.OrderPrescription{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditById 修改处方-处方id
|
||||
func (r *OrderPrescriptionDao) EditById(tx *gorm.DB, orderPrescriptionId int64, data interface{}) error {
|
||||
err := tx.Model(&model.OrderPrescription{}).Where("order_prescription_id = ?", orderPrescriptionId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetList 获取处方列表
|
||||
func (r *OrderPrescriptionDao) GetList(maps interface{}) (m []*model.OrderPrescription, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// Add 新增处方
|
||||
func (r *OrderPrescriptionDao) Add(tx *gorm.DB, model *model.OrderPrescription) (*model.OrderPrescription, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// AddByMap 新增处方-map
|
||||
func (r *OrderPrescriptionDao) AddByMap(tx *gorm.DB, data map[string]interface{}) (*model.OrderPrescription, error) {
|
||||
orderPrescription := &model.OrderPrescription{}
|
||||
if err := tx.Model(&model.OrderPrescription{}).Create(data).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return orderPrescription, nil
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type PatientFamilyDao struct {
|
||||
}
|
||||
|
||||
// GetPatientFamilyById 获取家庭成员-家庭成员id
|
||||
func (r *PatientFamilyDao) GetPatientFamilyById(familyId int64) (m *model.PatientFamily, err error) {
|
||||
err = global.Db.First(&m, familyId).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
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditPatientFamily 修改家庭成员
|
||||
func (r *PatientFamilyDao) EditPatientFamily(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.PatientFamily{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditPatientFamilyById 修改家庭成员-医生id
|
||||
func (r *PatientFamilyDao) EditPatientFamilyById(tx *gorm.DB, familyId int64, data interface{}) error {
|
||||
err := tx.Model(&model.PatientFamily{}).Where("family_id = ?", familyId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPatientFamilyList 获取家庭成员列表
|
||||
func (r *PatientFamilyDao) GetPatientFamilyList(maps interface{}) (m []*model.PatientFamily, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddPatientFamily 新增家庭成员
|
||||
func (r *PatientFamilyDao) AddPatientFamily(tx *gorm.DB, model *model.PatientFamily) (*model.PatientFamily, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// AddPatientFamilyByMap 新增家庭成员-map
|
||||
func (r *PatientFamilyDao) AddPatientFamilyByMap(tx *gorm.DB, data map[string]interface{}) (*model.PatientFamily, error) {
|
||||
userDoctorInfo := &model.PatientFamily{}
|
||||
if err := tx.Model(&model.PatientFamily{}).Create(data).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return userDoctorInfo, nil
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type UserDao struct {
|
||||
}
|
||||
|
||||
// GetUserById 获取用户数据-用户id
|
||||
func (r *UserDao) GetUserById(userId int64) (m *model.User, err error) {
|
||||
err = global.Db.First(&m, userId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetUserPreloadById 获取用户数据-加载全部关联-用户id
|
||||
func (r *UserDao) GetUserPreloadById(userId int64) (m *model.User, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, userId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteUser 删除用户
|
||||
func (r *UserDao) DeleteUser(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.User{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteUserById 删除用户-用户id
|
||||
func (r *UserDao) DeleteUserById(tx *gorm.DB, userId int64) error {
|
||||
if err := tx.Delete(&model.User{}, userId).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditUser 修改用户
|
||||
func (r *UserDao) EditUser(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.User{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditUserById 修改用户-用户id
|
||||
func (r *UserDao) EditUserById(tx *gorm.DB, userId int64, data interface{}) error {
|
||||
err := tx.Model(&model.User{}).Where("user_id = ?", userId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetUserList 获取用户列表
|
||||
func (r *UserDao) GetUserList(maps interface{}) (m []*model.User, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type UserCaCert struct {
|
||||
}
|
||||
|
||||
// GetUserCaCertById 获取监管证书数据-监管证书id
|
||||
func (r *UserCaCert) GetUserCaCertById(certId int64) (m *model.UserCaCert, err error) {
|
||||
err = global.Db.First(&m, certId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetUserCaCertByUserId 获取监管证书数据-监管证书id
|
||||
func (r *UserCaCert) GetUserCaCertByUserId(userId int64) (m *model.UserCaCert, err error) {
|
||||
err = global.Db.Where("user_id = ?", userId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetUserCaCertListByUserId 获取监管证书数据-监管证书id
|
||||
func (r *UserCaCert) GetUserCaCertListByUserId(userId int64) (m []*model.UserCaCert, err error) {
|
||||
err = global.Db.Where("user_id = ?", userId).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddUserCaCert 新增监管证书
|
||||
func (r *UserCaCert) AddUserCaCert(tx *gorm.DB, model *model.UserCaCert) (*model.UserCaCert, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// GetUserCaCertList 获取监管证书列表
|
||||
func (r *UserCaCert) GetUserCaCertList(maps interface{}) (m []*model.UserCaCert, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteUserCaCertById 删除监管证书-监管证书id
|
||||
func (r *UserCaCert) DeleteUserCaCertById(tx *gorm.DB, certId int64) error {
|
||||
if err := tx.Delete(&model.UserCaCert{}, certId).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditUserCaCertById 修改监管证书-监管证书id
|
||||
func (r *UserCaCert) EditUserCaCertById(tx *gorm.DB, certId int64, data interface{}) error {
|
||||
err := tx.Model(&model.UserCaCert{}).Where("cert_id = ?", certId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type UserCouponDao struct {
|
||||
}
|
||||
|
||||
// GetUserCouponById 获取用户优惠卷数据-用户优惠卷id
|
||||
func (r *UserCouponDao) GetUserCouponById(userCouponId int64) (m *model.UserCoupon, err error) {
|
||||
err = global.Db.First(&m, userCouponId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (r *UserCouponDao) GetUserCouponByUserId(userId int64) (m *model.UserCoupon, err error) {
|
||||
err = global.Db.Where("user_id = ?", userId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetUserCouponPreloadById 获取用户优惠卷数据-加载全部关联-用户优惠卷id
|
||||
func (r *UserCouponDao) GetUserCouponPreloadById(userCouponId int64) (m *model.UserCoupon, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, userCouponId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteUserCoupon 删除用户优惠卷
|
||||
func (r *UserCouponDao) DeleteUserCoupon(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.UserCoupon{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditUserCoupon 修改用户优惠卷
|
||||
func (r *UserCouponDao) EditUserCoupon(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.UserCoupon{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditUserCouponById 修改用户优惠卷-用户优惠卷id
|
||||
func (r *UserCouponDao) EditUserCouponById(tx *gorm.DB, userCouponId int64, data interface{}) error {
|
||||
err := tx.Model(&model.UserCoupon{}).Where("user_coupon_id = ?", userCouponId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetUserCouponList 获取用户优惠卷列表
|
||||
func (r *UserCouponDao) GetUserCouponList(maps interface{}) (m []*model.UserCoupon, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddUserCoupon 新增用户优惠卷
|
||||
func (r *UserCouponDao) AddUserCoupon(tx *gorm.DB, model *model.UserCoupon) (*model.UserCoupon, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/api/requests/v1"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type UserDoctorDao struct {
|
||||
}
|
||||
|
||||
// GetUserDoctorById 获取医生数据-医生id
|
||||
func (r *UserDoctorDao) GetUserDoctorById(doctorId int64) (m *model.UserDoctor, err error) {
|
||||
err = global.Db.First(&m, doctorId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetUserDoctorPreloadById 获取医生数据-加载全部关联-医生id
|
||||
func (r *UserDoctorDao) GetUserDoctorPreloadById(doctorId int64) (m *model.UserDoctor, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, doctorId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetUserDoctor 获取医生详情
|
||||
func (r *UserDoctorDao) GetUserDoctor(req v1.GetMultiDoctor) (m *model.UserDoctor, err error) {
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.UserDoctor{}).Omit("open_id", "union_id", "wx_session_key")
|
||||
|
||||
// 用户
|
||||
query = query.Preload("User", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("user_password", "salt")
|
||||
})
|
||||
|
||||
// 医院
|
||||
query = query.Preload("Hospital", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("hospital_id,hospital_name,hospital_level_name")
|
||||
})
|
||||
|
||||
// 状态
|
||||
query = query.Where("status = ?", 1)
|
||||
|
||||
// 实名认证状态
|
||||
query = query.Where("idcard_status = ?", 1)
|
||||
|
||||
// 身份认证状态
|
||||
query = query.Where("iden_auth_status = ?", 1)
|
||||
|
||||
// 是否已绑定结算银行卡
|
||||
query = query.Where("is_bind_bank = ?", 1)
|
||||
|
||||
// 姓名
|
||||
if req.UserName != "" {
|
||||
query = query.Where("user_name = ?", req.UserName)
|
||||
}
|
||||
|
||||
// 手机号
|
||||
if req.Mobile != "" {
|
||||
subQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
query = query.Where(gorm.Expr("user_id IN (?)", subQuery))
|
||||
}
|
||||
|
||||
err = query.First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/global"
|
||||
)
|
||||
|
||||
type UserDoctorInfoDao struct {
|
||||
}
|
||||
|
||||
// GetUserDoctorInfoById 获取医生详情数据-医生详情id
|
||||
func (r *UserDoctorInfoDao) GetUserDoctorInfoById(doctorInfoId int64) (m *model.UserDoctorInfo, err error) {
|
||||
err = global.Db.First(&m, doctorInfoId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetUserDoctorInfoByDoctorId 获取医生详情数据-医生id
|
||||
func (r *UserDoctorInfoDao) GetUserDoctorInfoByDoctorId(doctorId int64) (m *model.UserDoctorInfo, err error) {
|
||||
err = global.Db.Where("doctor_id = ?", doctorId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetUserDoctorInfoByUserId 获取医生详情数据-用户id
|
||||
func (r *UserDoctorInfoDao) GetUserDoctorInfoByUserId(userId int64) (m *model.UserDoctorInfo, err error) {
|
||||
err = global.Db.Where("user_id = ?", userId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteUserDoctorInfo 删除医生详情
|
||||
func (r *UserDoctorInfoDao) DeleteUserDoctorInfo(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.UserDoctorInfo{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteUserDoctorInfoById 删除医生详情-医生详情id
|
||||
func (r *UserDoctorInfoDao) DeleteUserDoctorInfoById(tx *gorm.DB, doctorInfoId int64) error {
|
||||
if err := tx.Delete(&model.UserDoctorInfo{}, doctorInfoId).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditUserDoctorInfo 修改医生详情
|
||||
func (r *UserDoctorInfoDao) EditUserDoctorInfo(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.UserDoctorInfo{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditUserDoctorInfoById 修改医生详情-医生详情id
|
||||
func (r *UserDoctorInfoDao) EditUserDoctorInfoById(tx *gorm.DB, doctorInfoId int64, data interface{}) error {
|
||||
err := tx.Model(&model.UserDoctorInfo{}).Where("doctor_info_id = ?", doctorInfoId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetUserDoctorInfoList 获取医生详情列表
|
||||
func (r *UserDoctorInfoDao) GetUserDoctorInfoList(maps interface{}) (m []*model.UserDoctorInfo, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddUserDoctorInfo 新增医生详情
|
||||
func (r *UserDoctorInfoDao) AddUserDoctorInfo(tx *gorm.DB, model *model.UserDoctorInfo) (*model.UserDoctorInfo, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// AddUserDoctorInfoByMap 新增医生详情-map
|
||||
func (r *UserDoctorInfoDao) AddUserDoctorInfoByMap(tx *gorm.DB, data map[string]interface{}) (*model.UserDoctorInfo, error) {
|
||||
userDoctorInfo := &model.UserDoctorInfo{}
|
||||
if err := tx.Model(&model.UserDoctorInfo{}).Create(data).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return userDoctorInfo, nil
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package exception
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-open-api/consts"
|
||||
"log"
|
||||
"net/http"
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
// Recover
|
||||
// @Description: 处理全局异常
|
||||
// @return gin.HandlerFunc
|
||||
func Recover() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
// 打印错误堆栈信息
|
||||
log.Printf("panic: %v\n", r)
|
||||
debug.PrintStack()
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"code": consts.ServerError,
|
||||
"message": errorToString(r),
|
||||
"data": "",
|
||||
})
|
||||
// 终止后续接口调用,不加的话recover到异常后,还会继续执行接口里后续代码
|
||||
c.Abort()
|
||||
}
|
||||
}()
|
||||
// 加载完 defer recover,继续后续接口调用
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
// recover错误,转string
|
||||
func errorToString(r interface{}) string {
|
||||
switch v := r.(type) {
|
||||
case error:
|
||||
return v.Error()
|
||||
default:
|
||||
return r.(string)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-open-api/api/dao"
|
||||
"hospital-open-api/api/responses"
|
||||
"hospital-open-api/consts"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Auth Auth认证
|
||||
func Auth() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
appId := c.Request.Header.Get("app_id")
|
||||
if appId == "" {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
"message": "请求未授权",
|
||||
"code": consts.TokenError,
|
||||
"data": "",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
sign := c.Request.Header.Get("sign")
|
||||
if sign == "" {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
"message": "缺少签名",
|
||||
"code": consts.TokenError,
|
||||
"data": "",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
// 获取开放数据
|
||||
openKeyDao := dao.OpenKeyDao{}
|
||||
openKey, err := openKeyDao.GetOpenKeyByDoctorId(appId)
|
||||
if err != nil || openKey == nil {
|
||||
responses.FailWithMessage("非法app_id", c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
if openKey.Status != 1 {
|
||||
responses.FailWithMessage("非法app_id", c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
paramsRaw, ok := c.Get("params")
|
||||
if !ok {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "Invalid params type1",
|
||||
"code": consts.ServerError,
|
||||
"data": "",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
concatenatedParamsStr := ""
|
||||
requestParams, ok := paramsRaw.(map[string]string)
|
||||
if ok || len(requestParams) > 0 {
|
||||
// 将请求参数按照参数名升序排序
|
||||
sortedKeys := make([]string, 0, len(requestParams))
|
||||
for key := range requestParams {
|
||||
sortedKeys = append(sortedKeys, key)
|
||||
}
|
||||
sort.Strings(sortedKeys)
|
||||
|
||||
// 按照参数名=参数值的格式拼接参数
|
||||
var concatenatedParams []string
|
||||
for _, key := range sortedKeys {
|
||||
value := url.QueryEscape(requestParams[key]) // 对参数值进行 URL 编码
|
||||
concatenatedParams = append(concatenatedParams, fmt.Sprintf("%s=%s", key, value))
|
||||
}
|
||||
concatenatedParamsStr = strings.Join(concatenatedParams, "&")
|
||||
}
|
||||
|
||||
h := hmac.New(sha1.New, []byte(openKey.AppSecret))
|
||||
h.Write([]byte(concatenatedParamsStr))
|
||||
signature := hex.EncodeToString(h.Sum(nil))
|
||||
fmt.Println(signature)
|
||||
if signature == "" {
|
||||
responses.FailWithMessage("签名错误", c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
// 检测签名
|
||||
if signature != sign {
|
||||
responses.FailWithMessage("签名错误", c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Cors
|
||||
// @Description: 跨域中间件
|
||||
// @return gin.HandlerFunc
|
||||
func Cors() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
method := c.Request.Method
|
||||
origin := c.Request.Header.Get("Origin")
|
||||
if origin != "" {
|
||||
c.Header("Access-Control-Allow-Origin", origin)
|
||||
c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE")
|
||||
c.Header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization")
|
||||
c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Cache-Control, Content-Language, Content-Type")
|
||||
c.Header("Access-Control-Allow-Credentials", "false")
|
||||
c.Set("content-type", "application/json")
|
||||
}
|
||||
if method == "OPTIONS" {
|
||||
c.AbortWithStatus(http.StatusNoContent)
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/sirupsen/logrus"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Logrus 日志中间件
|
||||
func Logrus() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
// 开始时间
|
||||
startTime := time.Now()
|
||||
|
||||
// 处理请求
|
||||
c.Next()
|
||||
|
||||
// 获取 请求 参数
|
||||
params := make(map[string]string)
|
||||
|
||||
paramsRaw, ok := c.Get("params")
|
||||
if ok {
|
||||
requestParams, ok := paramsRaw.(map[string]string)
|
||||
if ok || len(requestParams) > 0 {
|
||||
params = requestParams
|
||||
}
|
||||
}
|
||||
|
||||
// 结束时间
|
||||
endTime := time.Now()
|
||||
|
||||
// 执行时间
|
||||
latencyTime := fmt.Sprintf("%6v", endTime.Sub(startTime))
|
||||
|
||||
// 请求方式
|
||||
reqMethod := c.Request.Method
|
||||
|
||||
// 请求路由
|
||||
reqUri := c.Request.RequestURI
|
||||
|
||||
// 状态码
|
||||
statusCode := c.Writer.Status()
|
||||
|
||||
// 请求IP
|
||||
clientIP := c.ClientIP()
|
||||
|
||||
// 日志格式
|
||||
global.Logger.WithFields(logrus.Fields{
|
||||
"http_status": statusCode,
|
||||
"total_time": latencyTime,
|
||||
"ip": clientIP,
|
||||
"method": reqMethod,
|
||||
"uri": reqUri,
|
||||
"params": params,
|
||||
}).Info("access")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-open-api/consts"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// RequestParamsMiddleware 获取请求参数中间件
|
||||
func RequestParamsMiddleware() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
contentType := c.Request.Header.Get("Content-Type")
|
||||
|
||||
params := make(map[string]string)
|
||||
|
||||
// 判断请求参数类型
|
||||
switch contentType {
|
||||
case "application/json":
|
||||
// 解析 application/json 请求体
|
||||
bodyBytes, err := io.ReadAll(c.Request.Body)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to read request body"})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
// 创建新的请求对象,并设置请求体数据
|
||||
c.Request.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
|
||||
|
||||
var jsonParams map[string]interface{}
|
||||
err = json.Unmarshal(bodyBytes, &jsonParams)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "Invalid JSON data",
|
||||
"code": consts.HttpError,
|
||||
"data": "",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
for key, value := range jsonParams {
|
||||
params[key] = fmt.Sprintf("%v", value)
|
||||
}
|
||||
|
||||
// 存储参数到上下文
|
||||
c.Set("params", params)
|
||||
|
||||
case "multipart/form-data", "application/form-data", "application/x-www-form-urlencoded":
|
||||
// 解析 Form 表单参数
|
||||
err := c.Request.ParseForm()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "Invalid form data",
|
||||
"code": consts.HttpError,
|
||||
"data": "",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
for key, values := range c.Request.Form {
|
||||
if len(values) > 0 {
|
||||
params[key] = fmt.Sprintf("%v", values[0])
|
||||
}
|
||||
}
|
||||
|
||||
// 存储参数到上下文
|
||||
c.Set("params", params)
|
||||
|
||||
default:
|
||||
// 解析 URL 参数
|
||||
queryParams := c.Request.URL.Query()
|
||||
|
||||
// 将参数转换为 map[string]interface{}
|
||||
params := make(map[string]interface{})
|
||||
for key, values := range queryParams {
|
||||
if len(values) > 0 {
|
||||
params[key] = fmt.Sprintf("%v", values[0])
|
||||
}
|
||||
}
|
||||
|
||||
// 存储参数到上下文
|
||||
c.Set("params", params)
|
||||
}
|
||||
|
||||
// 继续处理请求
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-open-api/consts"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// RequestParamsMiddleware1 获取请求参数中间件
|
||||
func RequestParamsMiddleware1() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
contentType := c.GetHeader("Content-Type")
|
||||
|
||||
// 判断请求参数类型
|
||||
switch contentType {
|
||||
case "application/json":
|
||||
// 解析 JSON 参数
|
||||
var params map[string]interface{}
|
||||
// 读取请求体数据
|
||||
data, err := c.GetRawData()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to read request body"})
|
||||
return
|
||||
}
|
||||
|
||||
// 解析 JSON 数据到 map[string]interface{}
|
||||
err = json.Unmarshal(data, ¶ms)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "Invalid JSON data",
|
||||
"code": consts.HttpError,
|
||||
"data": "",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
// 存储参数到上下文
|
||||
c.Set("params", params)
|
||||
|
||||
case "application/form-data", "application/x-www-form-urlencoded":
|
||||
// 解析 Form 表单参数
|
||||
err := c.Request.ParseForm()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "Invalid form data",
|
||||
"code": consts.HttpError,
|
||||
"data": "",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
// 将参数转换为 map[string]interface{}
|
||||
params := make(map[string]interface{})
|
||||
for key, values := range c.Request.Form {
|
||||
if len(values) > 0 {
|
||||
params[key] = values[0]
|
||||
}
|
||||
}
|
||||
|
||||
// 存储参数到上下文
|
||||
c.Set("params", params)
|
||||
|
||||
default:
|
||||
// 解析 URL 参数
|
||||
queryParams := c.Request.URL.Query()
|
||||
|
||||
// 将参数转换为 map[string]interface{}
|
||||
params := make(map[string]interface{})
|
||||
for key, values := range queryParams {
|
||||
if len(values) > 0 {
|
||||
params[key] = values[0]
|
||||
}
|
||||
}
|
||||
|
||||
// 存储参数到上下文
|
||||
c.Set("params", params)
|
||||
}
|
||||
|
||||
// 继续处理请求
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DiseaseClassExpertise 疾病分类表-医生专长
|
||||
type DiseaseClassExpertise struct {
|
||||
ExpertiseId int64 `gorm:"column:expertise_id;type:bigint(19);primary_key;comment:主键id" json:"expertise_id"`
|
||||
ExpertiseName string `gorm:"column:expertise_name;type:varchar(255);comment:专长名称" json:"expertise_name"`
|
||||
ExpertiseSort int `gorm:"column:expertise_sort;type:int(11);default:0;comment:排序(越大排序越靠前)" json:"expertise_sort"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *DiseaseClassExpertise) TableName() string {
|
||||
return "gdxz_disease_class_expertise"
|
||||
}
|
||||
|
||||
func (m *DiseaseClassExpertise) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.ExpertiseId == 0 {
|
||||
m.ExpertiseId = 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
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DoctorBankCard 医生银行卡
|
||||
type DoctorBankCard struct {
|
||||
BankCardId int64 `gorm:"column:bank_card_id;type:bigint(19);primary_key;comment:主键id" json:"bank_card_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id;NOT NULL" json:"doctor_id"`
|
||||
BankId int64 `gorm:"column:bank_id;type:bigint(19);comment:银行id" json:"bank_id"`
|
||||
BankCardCode string `gorm:"column:bank_card_code;type:varchar(100);comment:银行卡号" json:"bank_card_code"`
|
||||
BankCardCodeMask string `gorm:"column:bank_card_code_mask;type:varchar(100);comment:银行卡号(掩码)" json:"bank_card_code_mask"`
|
||||
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"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *DoctorBankCard) TableName() string {
|
||||
return "gdxz_doctor_bank_card"
|
||||
}
|
||||
|
||||
func (m *DoctorBankCard) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.BankCardId == 0 {
|
||||
m.BankCardId = 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
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DoctorExpertise 医生专长表
|
||||
type DoctorExpertise struct {
|
||||
DoctorExpertiseId int64 `gorm:"column:doctor_expertise_id;type:bigint(19);primary_key;comment:主键id" json:"doctor_expertise_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id" json:"doctor_id"`
|
||||
ExpertiseId int64 `gorm:"column:expertise_id;type:bigint(19);comment:专长id" json:"expertise_id"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *DoctorExpertise) TableName() string {
|
||||
return "gdxz_doctor_expertise"
|
||||
}
|
||||
|
||||
func (m *DoctorExpertise) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.DoctorExpertiseId == 0 {
|
||||
m.DoctorExpertiseId = 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
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DoctorIdenFail 医生身份审核失败原因表
|
||||
type DoctorIdenFail struct {
|
||||
IdenFailId int64 `gorm:"column:iden_fail_id;type:bigint(19);primary_key;comment:主键id" json:"iden_fail_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id" json:"doctor_id"`
|
||||
FieldName string `gorm:"column:field_name;type:varchar(50);comment:字段名称" json:"field_name"`
|
||||
FailReason string `gorm:"column:fail_reason;type:varchar(255);comment:失败原因" json:"fail_reason"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *DoctorIdenFail) TableName() string {
|
||||
return "gdxz_doctor_iden_fail"
|
||||
}
|
||||
|
||||
func (m *DoctorIdenFail) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.IdenFailId == 0 {
|
||||
m.IdenFailId = 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
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Hospital 医院表
|
||||
type Hospital struct {
|
||||
HospitalID int64 `gorm:"column:hospital_id;type:bigint(19);primary_key;comment:主键id" json:"hospital_id"`
|
||||
HospitalName string `gorm:"column:hospital_name;type:varchar(255);comment:医院名称" json:"hospital_name"`
|
||||
HospitalStatus int `gorm:"column:hospital_status;type:tinyint(1);default:1;comment:状态(0:禁用 1:正常 2:删除)" json:"hospital_status"`
|
||||
HospitalLevelName string `gorm:"column:hospital_level_name;type:varchar(20);comment:医院等级名称" json:"hospital_level_name"`
|
||||
PostCode string `gorm:"column:post_code;type:varchar(50);comment:邮政编码" json:"post_code"`
|
||||
TelePhone string `gorm:"column:tele_phone;type:varchar(20);comment:电话" json:"tele_phone"`
|
||||
ProvinceId int `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
|
||||
Province string `gorm:"column:province;type:varchar(50);comment:省份" json:"province"`
|
||||
CityId int `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
|
||||
City string `gorm:"column:city;type:varchar(50);comment:城市" json:"city"`
|
||||
CountyId int `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
|
||||
County string `gorm:"column:county;type:varchar(50);comment:区县" json:"county"`
|
||||
Address string `gorm:"column:address;type:varchar(255);comment:地址" json:"address"`
|
||||
Lat string `gorm:"column:lat;type:varchar(255);comment:纬度" json:"lat"`
|
||||
Lng string `gorm:"column:lng;type:varchar(255);comment:经度" json:"lng"`
|
||||
Desc string `gorm:"column:desc;type:varchar(255);comment:简介" json:"desc"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *Hospital) TableName() string {
|
||||
return "gdxz_hospital"
|
||||
}
|
||||
|
||||
func (m *Hospital) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.HospitalID == 0 {
|
||||
m.HospitalID = 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
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// HospitalDepartment 医院科室表-标准
|
||||
type HospitalDepartment struct {
|
||||
DepartmentId int64 `gorm:"column:department_id;type:bigint(19);primary_key;comment:主键id" json:"department_id"`
|
||||
DepartmentName string `gorm:"column:department_name;type:varchar(255);comment:科室名称" json:"department_name"`
|
||||
DepartmentCode string `gorm:"column:department_code;type:varchar(100);comment:科室代码" json:"department_code"`
|
||||
DepartmentType int `gorm:"column:department_type;type:tinyint(1);default:0;comment:科室类型(0:未知 1:肝脏病)" json:"department_type"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *HospitalDepartment) TableName() string {
|
||||
return "gdxz_hospital_department"
|
||||
}
|
||||
|
||||
func (m *HospitalDepartment) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.DepartmentId == 0 {
|
||||
m.DepartmentId = 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
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// HospitalDepartmentCustom 医院科室表-自定义
|
||||
type HospitalDepartmentCustom struct {
|
||||
DepartmentCustomId int64 `gorm:"column:department_custom_id;type:bigint(19);primary_key;comment:主键id" json:"department_custom_id"`
|
||||
DepartmentId int64 `gorm:"column:department_id;type:bigint(19);comment:医院科室-标准id" json:"department_id"`
|
||||
DepartmentCustomName string `gorm:"column:department_custom_name;type:varchar(100);comment:科室名称-自定义" json:"department_custom_name"`
|
||||
DepartmentName string `gorm:"column:department_name;type:varchar(255);comment:科室名称-标准" json:"department_name"`
|
||||
DepartmentCode string `gorm:"column:department_code;type:varchar(100);comment:科室编码-标准" json:"department_code"`
|
||||
DepartmentStatus int `gorm:"column:department_status;type:tinyint(1);default:1;comment:状态(1:正常 2:删除)" json:"department_status"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *HospitalDepartmentCustom) TableName() string {
|
||||
return "gdxz_hospital_department_custom"
|
||||
}
|
||||
|
||||
func (m *HospitalDepartmentCustom) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.DepartmentCustomId == 0 {
|
||||
m.DepartmentCustomId = 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
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// LogSms 日志-短信发送表
|
||||
type LogSms struct {
|
||||
LogId int64 `gorm:"column:log_id;type:bigint(19);primary_key;comment:主键id" json:"log_id"`
|
||||
Type int `gorm:"column:type;type:tinyint(1);comment:类型(1:短信 2:邮件);NOT NULL" json:"type"`
|
||||
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(1:发送成功 2:发送失败)" json:"status"`
|
||||
Phone string `gorm:"column:phone;type:varchar(20);comment:手机号" json:"phone"`
|
||||
TemplateCode string `gorm:"column:template_code;type:varchar(20);comment:模版code" json:"template_code"`
|
||||
ThirdCode string `gorm:"column:third_code;type:varchar(100);comment:第三方编码" json:"third_code"`
|
||||
SceneDesc string `gorm:"column:scene_desc;type:varchar(255);comment:场景描述" json:"scene_desc"`
|
||||
Remarks string `gorm:"column:remarks;type:varchar(255);comment:备注" json:"remarks"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *LogSms) TableName() string {
|
||||
return "gdxz_log_sms"
|
||||
}
|
||||
|
||||
func (m *LogSms) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.LogId == 0 {
|
||||
m.LogId = 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
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
CreatedAt LocalTime `gorm:"column:created_at;type:datetime;comment:创建时间" json:"created_at"`
|
||||
UpdatedAt LocalTime `gorm:"column:updated_at;type:datetime;comment:修改时间" json:"updated_at"`
|
||||
}
|
||||
|
||||
// LocalTime 自定义数据类型
|
||||
type LocalTime time.Time
|
||||
|
||||
func (t *LocalTime) UnmarshalJSON(data []byte) error {
|
||||
if string(data) == "null" {
|
||||
return nil
|
||||
}
|
||||
var err error
|
||||
// 前端接收的时间字符串
|
||||
str := string(data)
|
||||
// 去除接收的str收尾多余的"
|
||||
timeStr := strings.Trim(str, "\"")
|
||||
t1, err := time.Parse("2006-01-02 15:04:05", timeStr)
|
||||
*t = LocalTime(t1)
|
||||
return err
|
||||
}
|
||||
|
||||
func (t LocalTime) MarshalJSON() ([]byte, error) {
|
||||
formatted := fmt.Sprintf("\"%v\"", time.Time(t).Format("2006-01-02 15:04:05"))
|
||||
return []byte(formatted), nil
|
||||
}
|
||||
|
||||
func (t LocalTime) Value() (driver.Value, error) {
|
||||
// MyTime 转换成 time.Time 类型
|
||||
tTime := time.Time(t)
|
||||
return tTime.Format("2006-01-02 15:04:05"), nil
|
||||
}
|
||||
|
||||
func (t *LocalTime) Scan(v interface{}) error {
|
||||
switch vt := v.(type) {
|
||||
case time.Time:
|
||||
// 字符串转成 time.Time 类型
|
||||
*t = LocalTime(vt)
|
||||
default:
|
||||
return errors.New("类型处理错误")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *LocalTime) String() string {
|
||||
return fmt.Sprintf("hhh:%s", time.Time(*t).String())
|
||||
}
|
||||
|
||||
func (t *LocalTime) IsEmpty() bool {
|
||||
return time.Time(*t).IsZero()
|
||||
}
|
||||
|
||||
func (m *Model) BeforeUpdate(tx *gorm.DB) (err error) {
|
||||
m.UpdatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Paginate(page, pageSize int) func(db *gorm.DB) *gorm.DB {
|
||||
return func(db *gorm.DB) *gorm.DB {
|
||||
if page <= 0 {
|
||||
page = 1
|
||||
}
|
||||
|
||||
switch {
|
||||
case pageSize > 100:
|
||||
pageSize = 100
|
||||
case pageSize <= 0:
|
||||
pageSize = 10
|
||||
}
|
||||
|
||||
offset := (page - 1) * pageSize
|
||||
return db.Offset(offset).Limit(pageSize)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OpenKey 开放平台密钥表
|
||||
type OpenKey struct {
|
||||
OpenId int64 `gorm:"column:open_id;type:bigint(19) unsigned;primary_key;comment:主键id" json:"open_id"`
|
||||
AppId string `gorm:"column:app_id;type:varchar(50);NOT NULL" json:"app_id"`
|
||||
AppSecret string `gorm:"column:app_secret;type:varchar(200);comment:秘钥" json:"app_secret"`
|
||||
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(1:正常 2:作废)" json:"status"`
|
||||
UserType string `gorm:"column:user_type;type:varchar(255);comment:下发用户类型" json:"user_type"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *OpenKey) TableName() string {
|
||||
return "gdxz_open_key"
|
||||
}
|
||||
|
||||
func (m *OpenKey) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.OpenId == 0 {
|
||||
m.OpenId = 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
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderInquiry 订单-问诊表
|
||||
type OrderInquiry struct {
|
||||
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);primary_key;comment:主键id" json:"order_inquiry_id"`
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id-患者;NOT NULL" json:"user_id"`
|
||||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id;NOT NULL" json:"patient_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id(未分配时为null)" json:"doctor_id"`
|
||||
FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id(就诊用户);NOT NULL" json:"family_id"`
|
||||
InquiryType int `gorm:"column:inquiry_type;type:tinyint(1);comment:订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测);NOT NULL" json:"inquiry_type"`
|
||||
InquiryMode int `gorm:"column:inquiry_mode;type:tinyint(1);comment:订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员);NOT NULL" json:"inquiry_mode"`
|
||||
InquiryStatus int `gorm:"column:inquiry_status;type:tinyint(1);default:1;comment:问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消);NOT NULL" json:"inquiry_status"`
|
||||
IsDelete int `gorm:"column:is_delete;type:tinyint(1);default:0;comment:删除状态(0:否 1:是)" json:"is_delete"`
|
||||
InquiryRefundStatus int `gorm:"column:inquiry_refund_status;type:tinyint(1);default:0;comment:问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)" json:"inquiry_refund_status"`
|
||||
InquiryPayChannel int `gorm:"column:inquiry_pay_channel;type:tinyint(1);comment:支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)" json:"inquiry_pay_channel"`
|
||||
InquiryPayStatus int `gorm:"column:inquiry_pay_status;type:tinyint(1);default:1;comment:支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款);NOT NULL" json:"inquiry_pay_status"`
|
||||
InquiryNo string `gorm:"column:inquiry_no;type:varchar(30);comment:系统订单编号;NOT NULL" json:"inquiry_no"`
|
||||
EscrowTradeNo string `gorm:"column:escrow_trade_no;type:varchar(100);comment:第三方支付流水号" json:"escrow_trade_no"`
|
||||
AmountTotal float64 `gorm:"column:amount_total;type:decimal(10,2);default:0.00;comment:订单金额" json:"amount_total"`
|
||||
CouponAmountTotal float64 `gorm:"column:coupon_amount_total;type:decimal(10,2);comment:优惠卷总金额" json:"coupon_amount_total"`
|
||||
PaymentAmountTotal float64 `gorm:"column:payment_amount_total;type:decimal(10,2);default:0.00;comment:实际付款金额" json:"payment_amount_total"`
|
||||
PayTime LocalTime `gorm:"column:pay_time;type:datetime;comment:支付时间" json:"pay_time"`
|
||||
ReceptionTime LocalTime `gorm:"column:reception_time;type:datetime;comment:接诊时间(已接诊)" json:"reception_time"`
|
||||
CompleteTime LocalTime `gorm:"column:complete_time;type:datetime;comment:订单完成时间(问诊完成时间)" json:"complete_time"`
|
||||
FinishTime LocalTime `gorm:"column:finish_time;type:datetime;comment:订单结束时间" json:"finish_time"`
|
||||
StatisticsStatus int `gorm:"column:statistics_status;type:tinyint(1);default:0;comment:订单统计状态(0:未统计 1:已统计 2:统计失败)" json:"statistics_status"`
|
||||
StatisticsTime LocalTime `gorm:"column:statistics_time;type:datetime;comment:订单统计时间" json:"statistics_time"`
|
||||
IsWithdrawal int `gorm:"column:is_withdrawal;type:tinyint(1);default:0;comment:是否提现(0:否 1:是 2:提现中)" json:"is_withdrawal"`
|
||||
WithdrawalTime LocalTime `gorm:"column:withdrawal_time;type:datetime;comment:提现时间" json:"withdrawal_time"`
|
||||
CancelTime LocalTime `gorm:"column:cancel_time;type:datetime;comment:订单取消时间" json:"cancel_time"`
|
||||
CancelReason int `gorm:"column:cancel_reason;type:tinyint(1);comment:取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)" json:"cancel_reason"`
|
||||
CancelRemarks string `gorm:"column:cancel_remarks;type:varchar(255);comment:取消订单备注(自动添加)" json:"cancel_remarks"`
|
||||
PatientName string `gorm:"column:patient_name;type:varchar(255);comment:患者姓名-就诊人" json:"patient_name"`
|
||||
PatientNameMask string `gorm:"column:patient_name_mask;type:varchar(255);comment:患者姓名-就诊人(掩码)" json:"patient_name_mask"`
|
||||
PatientSex int `gorm:"column:patient_sex;type:tinyint(1);default:0;comment:患者性别-就诊人(0:未知 1:男 2:女)" json:"patient_sex"`
|
||||
PatientAge int `gorm:"column:patient_age;type:int(1);comment:患者年龄-就诊人" json:"patient_age"`
|
||||
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||||
PatientUser *User `gorm:"foreignKey:UserId;references:user_id" json:"patient_user"` // 用户-患者
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *OrderInquiry) TableName() string {
|
||||
return "gdxz_order_inquiry"
|
||||
}
|
||||
|
||||
func (m *OrderInquiry) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.OrderInquiryId == 0 {
|
||||
m.OrderInquiryId = 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
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderInquiryCase 订单-问诊病例表
|
||||
type OrderInquiryCase struct {
|
||||
InquiryCaseId int64 `gorm:"column:inquiry_case_id;type:bigint(19);primary_key;comment:主键id" json:"inquiry_case_id"`
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id" json:"user_id"`
|
||||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"`
|
||||
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:订单-问诊id;NOT NULL" json:"order_inquiry_id"`
|
||||
FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id" json:"family_id"`
|
||||
Relation int `gorm:"column:relation;type:tinyint(1);default:1;comment:与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 )" json:"relation"`
|
||||
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(1:正常 2:删除)" json:"status"`
|
||||
Name string `gorm:"column:name;type:varchar(50);comment:患者名称" json:"name"`
|
||||
Sex int `gorm:"column:sex;type:tinyint(1);default:0;comment:患者性别(0:未知 1:男 2:女)" json:"sex"`
|
||||
Age int `gorm:"column:age;type:int(11);comment:患者年龄" json:"age"`
|
||||
Height string `gorm:"column:height;type:varchar(100);comment:身高(cm)" json:"height"`
|
||||
Weight string `gorm:"column:weight;type:varchar(100);comment:体重(kg)" json:"weight"`
|
||||
DiseaseClassId int64 `gorm:"column:disease_class_id;type:bigint(19);comment:疾病分类id-系统" json:"disease_class_id"`
|
||||
DiseaseClassName string `gorm:"column:disease_class_name;type:varchar(255);comment:疾病名称-系统" json:"disease_class_name"`
|
||||
DiagnosisDate LocalTime `gorm:"column:diagnosis_date;type:datetime;comment:确诊日期" json:"diagnosis_date"`
|
||||
DiseaseDesc string `gorm:"column:disease_desc;type:text;comment:病情描述(主诉)" json:"disease_desc"`
|
||||
DiagnoseImages string `gorm:"column:diagnose_images;type:varchar(1000);comment:复诊凭证(多个使用逗号分隔)" json:"diagnose_images"`
|
||||
IsAllergyHistory int `gorm:"column:is_allergy_history;type:tinyint(1);comment:是否存在过敏史(0:否 1:是)" json:"is_allergy_history"`
|
||||
AllergyHistory string `gorm:"column:allergy_history;type:varchar(255);comment:过敏史描述" json:"allergy_history"`
|
||||
IsFamilyHistory int `gorm:"column:is_family_history;type:tinyint(1);comment:是否存在家族病史(0:否 1:是)" json:"is_family_history"`
|
||||
FamilyHistory string `gorm:"column:family_history;type:varchar(255);comment:家族病史描述" json:"family_history"`
|
||||
IsPregnant int `gorm:"column:is_pregnant;type:tinyint(1);comment:是否备孕、妊娠、哺乳期(0:否 1:是)" json:"is_pregnant"`
|
||||
Pregnant string `gorm:"column:pregnant;type:varchar(255);comment:备孕、妊娠、哺乳期描述" json:"pregnant"`
|
||||
IsTaboo int `gorm:"column:is_taboo;type:tinyint(1);comment:是否服用过禁忌药物,且无相关禁忌(0:否 1:是)问诊购药时存在" json:"is_taboo"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *OrderInquiryCase) TableName() string {
|
||||
return "gdxz_order_inquiry_case"
|
||||
}
|
||||
|
||||
func (m *OrderInquiryCase) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.InquiryCaseId == 0 {
|
||||
m.InquiryCaseId = 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
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderInquiryCoupon 订单-问诊-优惠卷表
|
||||
type OrderInquiryCoupon struct {
|
||||
OrderCouponId int64 `gorm:"column:order_coupon_id;type:bigint(19);primary_key;comment:主键id" json:"order_coupon_id"`
|
||||
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:订单-问诊id;NOT NULL" json:"order_inquiry_id"`
|
||||
UserCouponId int64 `gorm:"column:user_coupon_id;type:bigint(19);comment:用户优惠卷表;NOT NULL" json:"user_coupon_id"`
|
||||
CouponName string `gorm:"column:coupon_name;type:varchar(255);comment:优惠卷名称" json:"coupon_name"`
|
||||
CouponUsePrice float64 `gorm:"column:coupon_use_price;type:decimal(10,2);default:0.00;comment:优惠卷使用金额" json:"coupon_use_price"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *OrderInquiryCoupon) TableName() string {
|
||||
return "gdxz_order_inquiry_coupon"
|
||||
}
|
||||
|
||||
func (m *OrderInquiryCoupon) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.OrderCouponId == 0 {
|
||||
m.OrderCouponId = 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
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderInquiryRefund 订单-问诊-退款表
|
||||
type OrderInquiryRefund struct {
|
||||
InquiryRefundId int64 `gorm:"column:inquiry_refund_id;type:bigint(19);primary_key;comment:主键id" json:"inquiry_refund_id"`
|
||||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"`
|
||||
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:订单-问诊id" json:"order_inquiry_id"`
|
||||
InquiryNo string `gorm:"column:inquiry_no;type:varchar(40);comment:系统订单编号" json:"inquiry_no"`
|
||||
InquiryRefundNo string `gorm:"column:inquiry_refund_no;type:varchar(50);comment:系统退款编号" json:"inquiry_refund_no"`
|
||||
RefundId string `gorm:"column:refund_id;type:varchar(50);comment:第三方退款单号" json:"refund_id"`
|
||||
InquiryRefundStatus int `gorm:"column:inquiry_refund_status;type:tinyint(4);comment:问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)" json:"inquiry_refund_status"`
|
||||
RefundTotal float64 `gorm:"column:refund_total;type:decimal(10,2);comment:退款金额" json:"refund_total"`
|
||||
RefundReason string `gorm:"column:refund_reason;type:varchar(255);comment:退款原因" json:"refund_reason"`
|
||||
SuccessTime time.Time `gorm:"column:success_time;type:datetime;comment:退款成功时间" json:"success_time"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *OrderInquiryRefund) TableName() string {
|
||||
return "gdxz_order_inquiry_refund"
|
||||
}
|
||||
func (m *OrderInquiryRefund) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.InquiryRefundId == 0 {
|
||||
m.InquiryRefundId = 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
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderPrescription 订单-处方表
|
||||
type OrderPrescription struct {
|
||||
OrderPrescriptionId int64 `gorm:"column:order_prescription_id;type:bigint(19);primary_key;comment:主键id" json:"order_prescription_id"`
|
||||
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:订单-问诊id;NOT NULL" json:"order_inquiry_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id;NOT NULL" json:"doctor_id"`
|
||||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"`
|
||||
FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id(就诊用户)" json:"family_id"`
|
||||
PharmacistId int64 `gorm:"column:pharmacist_id;type:bigint(19);comment:药师id" json:"pharmacist_id"`
|
||||
PrescriptionStatus int `gorm:"column:prescription_status;type:tinyint(1);comment:处方状态(1:待审核 2:待使用 3:已失效 4:已使用)" json:"prescription_status"`
|
||||
PharmacistAuditStatus int `gorm:"column:pharmacist_audit_status;type:tinyint(1);default:0;comment:药师审核状态(0:审核中 1:审核成功 2:审核驳回)" json:"pharmacist_audit_status"`
|
||||
PharmacistVerifyTime time.Time `gorm:"column:pharmacist_verify_time;type:datetime;comment:药师审核时间" json:"pharmacist_verify_time"`
|
||||
PharmacistFailReason string `gorm:"column:pharmacist_fail_reason;type:varchar(255);comment:药师审核驳回原因" json:"pharmacist_fail_reason"`
|
||||
PlatformAuditStatus int `gorm:"column:platform_audit_status;type:tinyint(1);default:0;comment:处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)" json:"platform_audit_status"`
|
||||
PlatformFailTime time.Time `gorm:"column:platform_fail_time;type:datetime;comment:平台审核失败时间" json:"platform_fail_time"`
|
||||
PlatformFailReason string `gorm:"column:platform_fail_reason;type:varchar(255);comment:处方平台驳回原因" json:"platform_fail_reason"`
|
||||
IsAutoPharVerify int `gorm:"column:is_auto_phar_verify;type:tinyint(1);default:0;comment:是否药师自动审核(0:否 1:是)" json:"is_auto_phar_verify"`
|
||||
DoctorCreatedTime time.Time `gorm:"column:doctor_created_time;type:datetime;comment:医生开具处方时间" json:"doctor_created_time"`
|
||||
ExpiredTime time.Time `gorm:"column:expired_time;type:datetime;comment:处方过期时间" json:"expired_time"`
|
||||
VoidTime time.Time `gorm:"column:void_time;type:datetime;comment:处方作废时间" json:"void_time"`
|
||||
IsDelete int `gorm:"column:is_delete;type:tinyint(1);default:0;comment:是否删除(0:否 1:是)" json:"is_delete"`
|
||||
PrescriptionCode string `gorm:"column:prescription_code;type:varchar(255);comment:处方编号" json:"prescription_code"`
|
||||
DoctorName string `gorm:"column:doctor_name;type:varchar(100);comment:医生名称" json:"doctor_name"`
|
||||
PatientName string `gorm:"column:patient_name;type:varchar(100);comment:患者姓名-就诊人" json:"patient_name"`
|
||||
PatientSex int `gorm:"column:patient_sex;type:tinyint(1);comment:患者性别-就诊人(1:男 2:女)" json:"patient_sex"`
|
||||
PatientAge int `gorm:"column:patient_age;type:int(11);comment:患者年龄-就诊人" json:"patient_age"`
|
||||
DoctorAdvice string `gorm:"column:doctor_advice;type:varchar(255);comment:医嘱" json:"doctor_advice"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *OrderPrescription) TableName() string {
|
||||
return "gdxz_order_prescription"
|
||||
}
|
||||
|
||||
func (m *OrderPrescription) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.OrderPrescriptionId == 0 {
|
||||
m.OrderPrescriptionId = 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
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// PatientFamily 患者家庭成员信息表-基本信息
|
||||
type PatientFamily struct {
|
||||
FamilyId int64 `gorm:"column:family_id;type:bigint(19);primary_key;comment:主键id" json:"family_id"`
|
||||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"`
|
||||
Relation int `gorm:"column:relation;type:tinyint(1);comment:与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 )" json:"relation"`
|
||||
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(1:正常 2:删除)" json:"status"`
|
||||
IsDefault int `gorm:"column:is_default;type:tinyint(1);default:0;comment:是否默认(0:否 1:是)" json:"is_default"`
|
||||
CardName string `gorm:"column:card_name;type:varchar(50);comment:姓名" json:"card_name"`
|
||||
CardNameMask string `gorm:"column:card_name_mask;type:varchar(50);comment:姓名(掩码)" json:"card_name_mask"`
|
||||
Mobile string `gorm:"column:mobile;type:varchar(20);comment:电话" json:"mobile"`
|
||||
MobileMask string `gorm:"column:mobile_mask;type:varchar(20);comment:电话(掩码)" json:"mobile_mask"`
|
||||
Type int `gorm:"column:type;type:tinyint(1);default:1;comment:身份类型(1:身份证 2:护照 3:港澳通行证 4:台胞证)" json:"type"`
|
||||
IdNumber string `gorm:"column:id_number;type:varchar(30);comment:证件号码" json:"id_number"`
|
||||
IdNumberMask string `gorm:"column:id_number_mask;type:varchar(30);comment:证件号码(掩码)" json:"id_number_mask"`
|
||||
Sex int `gorm:"column:sex;type:tinyint(1);default:0;comment:性别(0:未知 1:男 2:女)" json:"sex"`
|
||||
Age int `gorm:"column:age;type:int(11);comment:年龄" json:"age"`
|
||||
ProvinceId int `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
|
||||
Province string `gorm:"column:province;type:varchar(50);comment:省份" json:"province"`
|
||||
CityId int `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
|
||||
City string `gorm:"column:city;type:varchar(50);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"`
|
||||
Height string `gorm:"column:height;type:varchar(100);comment:身高(cm)" json:"height"`
|
||||
Weight string `gorm:"column:weight;type:varchar(100);comment:体重(kg)" json:"weight"`
|
||||
MaritalStatus int `gorm:"column:marital_status;type:tinyint(1);comment:婚姻状况(0:未婚 1:已婚 2:离异)" json:"marital_status"`
|
||||
NationId int64 `gorm:"column:nation_id;type:bigint(19);comment:民族" json:"nation_id"`
|
||||
NationName string `gorm:"column:nation_name;type:varchar(50);comment:民族名称" json:"nation_name"`
|
||||
JobId int64 `gorm:"column:job_id;type:bigint(19);comment:职业" json:"job_id"`
|
||||
JobName string `gorm:"column:job_name;type:varchar(50);comment:职业名称" json:"job_name"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *PatientFamily) TableName() string {
|
||||
return "gdxz_patient_family"
|
||||
}
|
||||
|
||||
func (m *PatientFamily) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.FamilyId == 0 {
|
||||
m.FamilyId = 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
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// User 用户主表
|
||||
type User struct {
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);primary_key;comment:主键" json:"user_id"`
|
||||
UserName string `gorm:"column:user_name;type:varchar(50);comment:用户名称" json:"user_name"`
|
||||
UserAccount string `gorm:"column:user_account;type:varchar(50);comment:账号" json:"user_account"`
|
||||
Mobile string `gorm:"column:mobile;type:varchar(20);comment:手机号" json:"mobile"`
|
||||
WxMobile string `gorm:"column:wx_mobile;type:varchar(20);comment:微信手机号" json:"wx_mobile"`
|
||||
UserPassword string `gorm:"column:user_password;type:varchar(50);comment:密码" json:"user_password"`
|
||||
Salt string `gorm:"column:salt;type:varchar(50);comment:密码混淆码" json:"salt"`
|
||||
UserType int `gorm:"column:user_type;type:tinyint(1);comment:用户类型(1:患者 2:医师 3:药师);NOT NULL" json:"user_type"`
|
||||
UserStatus int `gorm:"column:user_status;type:tinyint(4);default:1;comment:状态(0:禁用 1:正常 2:删除)" json:"user_status"`
|
||||
RegisterMethod int `gorm:"column:register_method;type:tinyint(1);comment:注册方式(1:微信小程序 )" json:"register_method"`
|
||||
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"`
|
||||
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"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *User) TableName() string {
|
||||
return "gdxz_user"
|
||||
}
|
||||
|
||||
func (m *User) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.UserId == 0 {
|
||||
m.UserId = 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
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserCaCert 医师/药师ca监管证书表
|
||||
type UserCaCert struct {
|
||||
CertId int64 `gorm:"column:cert_id;type:bigint(19);primary_key;comment:主键id" json:"cert_id"`
|
||||
UserId *int64 `gorm:"column:user_id;type:bigint(19);comment:用户id(系统证书时为null)" json:"user_id"`
|
||||
IsSystem int `gorm:"column:is_system;type:tinyint(1);default:0;comment:是否系统证书(0:否 1:是)" json:"is_system"`
|
||||
Type int `gorm:"column:type;type:tinyint(1);comment:证书类型(1:线下 2:线上)" json:"type"`
|
||||
CertBase64 string `gorm:"column:cert_base64;type:text;comment:签名值证书" json:"cert_base64"`
|
||||
CertChainP7 string `gorm:"column:cert_chain_p7;type:text;comment:证书链" json:"cert_chain_p7"`
|
||||
CertSerialNumber string `gorm:"column:cert_serial_number;type:varchar(100);comment:证书序列号" json:"cert_serial_number"`
|
||||
CaPin string `gorm:"column:ca_pin;type:varchar(100);comment:ca认证pin值" json:"ca_pin"`
|
||||
IsSignConfig int `gorm:"column:is_sign_config;type:tinyint(1);default:0;comment:是否已添加签章配置(第一次需申请)" json:"is_sign_config"`
|
||||
SignConfig string `gorm:"column:sign_config;type:text;comment:签章坐标配置" json:"sign_config"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *UserCaCert) TableName() string {
|
||||
return "gdxz_user_ca_cert"
|
||||
}
|
||||
|
||||
func (m *UserCaCert) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.CertId == 0 {
|
||||
m.CertId = 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
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserCoupon 用户优惠卷表
|
||||
type UserCoupon struct {
|
||||
UserCouponId int64 `gorm:"column:user_coupon_id;type:bigint(19);primary_key;comment:主键id" json:"user_coupon_id"`
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
|
||||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"`
|
||||
CouponId int64 `gorm:"column:coupon_id;type:bigint(19);comment:优惠卷id;NOT NULL" json:"coupon_id"`
|
||||
UserCouponStatus int `gorm:"column:user_coupon_status;type:tinyint(1);default:0;comment:状态(0:未使用 1:已使用 3:已过期)" json:"user_coupon_status"`
|
||||
CouponUseDate time.Time `gorm:"column:coupon_use_date;type:datetime;comment:使用时间" json:"coupon_use_date"`
|
||||
ValidStartTime time.Time `gorm:"column:valid_start_time;type:datetime;comment:有效使用时间" json:"valid_start_time"`
|
||||
ValidEndTime time.Time `gorm:"column:valid_end_time;type:datetime;comment:过期使用时间" json:"valid_end_time"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *UserCoupon) TableName() string {
|
||||
return "gdxz_user_coupon"
|
||||
}
|
||||
|
||||
func (m *UserCoupon) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.UserCouponId == 0 {
|
||||
m.UserCouponId = 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
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserDoctor 用户-医生表
|
||||
type UserDoctor struct {
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);primary_key;comment:主键" json:"doctor_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(50);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:删除);NOT NULL" json:"status"`
|
||||
IdcardStatus int `gorm:"column:idcard_status;type:tinyint(1);default:0;comment:实名认证状态(0:未认证 1:认证通过 2:认证失败)" json:"idcard_status"`
|
||||
IdenAuthStatus int `gorm:"column:iden_auth_status;type:tinyint(1);default:0;comment:身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败);NOT NULL" json:"iden_auth_status"`
|
||||
IdenAuthTime LocalTime `gorm:"column:iden_auth_time;type:datetime;comment:审核时间" json:"iden_auth_time"`
|
||||
IdenAuthFailReason string `gorm:"column:iden_auth_fail_reason;type:text;comment:身份认证失败原因" json:"iden_auth_fail_reason"`
|
||||
MultiPointStatus int `gorm:"column:multi_point_status;type:tinyint(1);default:0;comment:医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)" json:"multi_point_status"`
|
||||
MultiPointTime LocalTime `gorm:"column:multi_point_time;type:datetime;comment:审核时间" json:"multi_point_time"`
|
||||
MultiPointFailReason string `gorm:"column:multi_point_fail_reason;type:varchar(255);comment:多点执业认证失败原因" json:"multi_point_fail_reason"`
|
||||
IsBindBank int `gorm:"column:is_bind_bank;type:tinyint(1);default:0;comment:是否已绑定结算银行卡(0:否 1:是);NOT NULL" json:"is_bind_bank"`
|
||||
IsRecommend int `gorm:"column:is_recommend;type:tinyint(1);default:0;comment:是否首页推荐(0:否 1:是)" json:"is_recommend"`
|
||||
Avatar string `gorm:"column:avatar;type:varchar(255);comment:头像" json:"avatar"`
|
||||
DoctorTitle int `gorm:"column:doctor_title;type:tinyint(1);comment:医生职称(1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)" json:"doctor_title"`
|
||||
DepartmentCustomId int64 `gorm:"column:department_custom_id;type:bigint(19);comment:科室id-自定义" json:"department_custom_id"`
|
||||
DepartmentCustomName string `gorm:"column:department_custom_name;type:varchar(100);comment:科室名称(如未自己输入,填入标准科室名称)" json:"department_custom_name"`
|
||||
DepartmentCustomMobile string `gorm:"column:department_custom_mobile;type:varchar(30);comment:科室电话" json:"department_custom_mobile"`
|
||||
HospitalID int64 `gorm:"column:hospital_id;type:bigint(19);comment:所属医院id" json:"hospital_id"`
|
||||
ServedPatientsNum int `gorm:"column:served_patients_num;type:int(11);default:0;comment:服务患者数量(订单结束时统计)" json:"served_patients_num"`
|
||||
PraiseRate float64 `gorm:"column:praise_rate;type:float(10,2);default:0.00;comment:好评率(百分制。订单平均评价中超过4-5分的订单总数 / 总订单数 * 5)" json:"praise_rate"`
|
||||
AvgResponseTime float64 `gorm:"column:avg_response_time;type:float(10,2);default:0.00;comment:平均响应时间(分钟制)" json:"avg_response_time"`
|
||||
NumberOfFans uint `gorm:"column:number_of_fans;type:int(10) unsigned;default:0;comment:被关注数量" json:"number_of_fans"`
|
||||
IsOnline int `gorm:"column:is_online;type:tinyint(1);default:0;comment:是否在线(0:不在线 1:在线)" json:"is_online"`
|
||||
IsImgExpertReception int `gorm:"column:is_img_expert_reception;type:tinyint(1);default:0;comment:是否参加专家图文接诊(0:否 1:是)" json:"is_img_expert_reception"`
|
||||
IsImgWelfareReception int `gorm:"column:is_img_welfare_reception;type:tinyint(1);default:0;comment:是否参加公益图文问诊(0:否 1:是)" json:"is_img_welfare_reception"`
|
||||
IsImgQuickReception int `gorm:"column:is_img_quick_reception;type:tinyint(1);default:0;comment:是否参加快速图文接诊(0:否 1:是)" json:"is_img_quick_reception"`
|
||||
IsPlatformDeepCooperation int `gorm:"column:is_platform_deep_cooperation;type:tinyint(1);default:0;comment:是否平台深度合作医生(0:否 1:是)" json:"is_platform_deep_cooperation"`
|
||||
IsEnterpriseDeepCooperation int `gorm:"column:is_enterprise_deep_cooperation;type:tinyint(1);default:0;comment:是否企业深度合作医生(0:否 1:是)" json:"is_enterprise_deep_cooperation"`
|
||||
IsSysDiagnoCooperation int `gorm:"column:is_sys_diagno_cooperation;type:tinyint(1);default:0;comment:是否先思达合作医生(0:否 1:是)" json:"is_sys_diagno_cooperation"`
|
||||
QrCode string `gorm:"column:qr_code;type:varchar(255);comment:分享二维码" json:"qr_code"`
|
||||
BeGoodAt string `gorm:"column:be_good_at;type:text;comment:擅长" json:"be_good_at"`
|
||||
BriefIntroduction string `gorm:"column:brief_introduction;type:text;comment:医生简介" json:"brief_introduction"`
|
||||
Model
|
||||
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 用户
|
||||
Hospital *Hospital `gorm:"foreignKey:HospitalID;references:hospital_id" json:"hospital"` // 医院
|
||||
}
|
||||
|
||||
func (m *UserDoctor) TableName() string {
|
||||
return "gdxz_user_doctor"
|
||||
}
|
||||
|
||||
func (m *UserDoctor) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.DoctorId == 0 {
|
||||
m.DoctorId = 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
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-open-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserDoctorInfo 用户-医生详情表
|
||||
type UserDoctorInfo struct {
|
||||
DoctorInfoId int64 `gorm:"column:doctor_info_id;type:bigint(19);primary_key;comment:主键" json:"doctor_info_id"`
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id" json:"user_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id" json:"doctor_id"`
|
||||
CardType int `gorm:"column:card_type;type:tinyint(1);comment:类型(1:身份证 2:护照 3:港澳通行证 4:台胞证);NOT NULL" json:"card_type"`
|
||||
CardName string `gorm:"column:card_name;type:varchar(50);comment:证件姓名" json:"card_name"`
|
||||
CardNameMask string `gorm:"column:card_name_mask;type:varchar(50);comment:证件姓名(掩码)" json:"card_name_mask"`
|
||||
CardNum string `gorm:"column:card_num;type:varchar(30);comment:证件号码" json:"card_num"`
|
||||
CardNumMask string `gorm:"column:card_num_mask;type:varchar(50);comment:证件号码(掩码)" json:"card_num_mask"`
|
||||
LicenseCert string `gorm:"column:license_cert;type:varchar(255);comment:医师执业证(逗号分隔)" json:"license_cert"`
|
||||
QualificationCert string `gorm:"column:qualification_cert;type:varchar(255);comment:医师资格证(逗号分隔)" json:"qualification_cert"`
|
||||
QualificationCertNum string `gorm:"column:qualification_cert_num;type:varchar(255);comment:医师资格证号(逗号分隔)" json:"qualification_cert_num"`
|
||||
WorkCert string `gorm:"column:work_cert;type:varchar(255);comment:医师工作证(逗号分隔)" json:"work_cert"`
|
||||
MultiPointImages string `gorm:"column:multi_point_images;type:varchar(255);comment:多点执业备案信息(逗号分隔)" json:"multi_point_images"`
|
||||
IdCardFront string `gorm:"column:id_card_front;type:varchar(255);comment:身份证正面图片" json:"id_card_front"`
|
||||
IdCardBack string `gorm:"column:id_card_back;type:varchar(255);comment:身份证背面图片" json:"id_card_back"`
|
||||
SignImage string `gorm:"column:sign_image;type:varchar(255);comment:签名图片" json:"sign_image"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *UserDoctorInfo) TableName() string {
|
||||
return "gdxz_user_doctor_info"
|
||||
}
|
||||
|
||||
func (m *UserDoctorInfo) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.DoctorInfoId == 0 {
|
||||
m.DoctorInfoId = 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
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package v1
|
||||
|
||||
type UserDoctorRequest struct {
|
||||
GetMultiDoctor // 获取多点执业医生详情
|
||||
}
|
||||
|
||||
// GetMultiDoctor 获取多点执业医生详情
|
||||
type GetMultiDoctor struct {
|
||||
Mobile string `json:"mobile" form:"mobile" validate:"required,Mobile" label:"手机号"`
|
||||
UserName string `json:"user_name" form:"user_name" validate:"required" label:"用户名"`
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package responses
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-open-api/consts"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type res struct {
|
||||
Code int `json:"code"`
|
||||
Data interface{} `json:"data"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func Result(code int, data interface{}, msg string, c *gin.Context) {
|
||||
if data == nil {
|
||||
data = gin.H{}
|
||||
}
|
||||
c.JSON(http.StatusOK, res{
|
||||
code,
|
||||
data,
|
||||
msg,
|
||||
})
|
||||
}
|
||||
|
||||
func Ok(c *gin.Context) {
|
||||
Result(consts.HttpSuccess, map[string]interface{}{}, "成功", c)
|
||||
}
|
||||
|
||||
func OkWithMessage(message string, c *gin.Context) {
|
||||
Result(consts.HttpSuccess, map[string]interface{}{}, message, c)
|
||||
}
|
||||
|
||||
func OkWithData(data interface{}, c *gin.Context) {
|
||||
Result(consts.HttpSuccess, data, "成功", c)
|
||||
}
|
||||
|
||||
func OkWithDetailed(data interface{}, message string, c *gin.Context) {
|
||||
Result(consts.HttpSuccess, data, message, c)
|
||||
}
|
||||
|
||||
func Fail(c *gin.Context) {
|
||||
Result(consts.HttpError, map[string]interface{}{}, "失败", c)
|
||||
}
|
||||
|
||||
func FailWithMessage(message string, c *gin.Context) {
|
||||
Result(consts.HttpError, map[string]interface{}{}, message, c)
|
||||
}
|
||||
|
||||
func FailWithDetailed(data interface{}, message string, c *gin.Context) {
|
||||
Result(consts.HttpError, data, message, c)
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package userDoctorResponse
|
||||
|
||||
import (
|
||||
"hospital-open-api/api/model"
|
||||
"hospital-open-api/utils"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// GetMultiDoctor 获取多点执业医生详情
|
||||
type GetMultiDoctor 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:认证失败)
|
||||
MultiPointStatus int `json:"multi_point_status"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
DoctorTitle string `json:"doctor_title"` // 医生职称(1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师)
|
||||
DepartmentCustomName string `json:"department_custom_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:是)
|
||||
IsEnterpriseDeepCooperation int `json:"is_enterprise_deep_cooperation"` // 是否企业深度合作医生(0:否 1:是)
|
||||
QrCode string `json:"qr_code"` // 分享二维码
|
||||
BeGoodAt string `json:"be_good_at"` // 擅长
|
||||
BriefIntroduction string `json:"brief_introduction"` // 医生简介
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
Age uint `json:"age"` // 年龄
|
||||
Sex int `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||||
HospitalName string `json:"hospital_name"` // 医院名称
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetMultiDoctorResponse 获取多点执业医生详情
|
||||
func GetMultiDoctorResponse(userDoctor *model.UserDoctor) GetMultiDoctor {
|
||||
res := GetMultiDoctor{
|
||||
DoctorID: strconv.Itoa(int(userDoctor.DoctorId)),
|
||||
UserID: strconv.Itoa(int(userDoctor.UserId)),
|
||||
UserName: userDoctor.UserName,
|
||||
Status: userDoctor.Status,
|
||||
IDCardStatus: userDoctor.Status,
|
||||
IdenAuthStatus: userDoctor.IdenAuthStatus,
|
||||
MultiPointStatus: userDoctor.MultiPointStatus,
|
||||
Avatar: utils.AddOssDomain(userDoctor.Avatar),
|
||||
DoctorTitle: utils.DoctorTitleToStr(userDoctor.DoctorTitle),
|
||||
DepartmentCustomName: userDoctor.DepartmentCustomName,
|
||||
ServedPatientsNum: userDoctor.ServedPatientsNum,
|
||||
PraiseRate: userDoctor.PraiseRate,
|
||||
AvgResponseTime: userDoctor.AvgResponseTime,
|
||||
NumberOfFans: userDoctor.NumberOfFans,
|
||||
IsImgExpertReception: userDoctor.IsImgExpertReception,
|
||||
IsImgWelfareReception: userDoctor.IsImgWelfareReception,
|
||||
IsImgQuickReception: userDoctor.IsImgQuickReception,
|
||||
IsPlatformDeepCooperation: userDoctor.IsPlatformDeepCooperation,
|
||||
IsEnterpriseDeepCooperation: userDoctor.IsEnterpriseDeepCooperation,
|
||||
QrCode: utils.AddOssDomain(userDoctor.QrCode),
|
||||
BeGoodAt: userDoctor.BeGoodAt,
|
||||
BriefIntroduction: userDoctor.BriefIntroduction,
|
||||
CreatedAt: userDoctor.CreatedAt,
|
||||
UpdatedAt: userDoctor.UpdatedAt,
|
||||
}
|
||||
|
||||
if userDoctor.User != nil {
|
||||
res.Mobile = userDoctor.User.Mobile
|
||||
res.Age = userDoctor.User.Age
|
||||
res.Sex = userDoctor.User.Sex
|
||||
}
|
||||
|
||||
if userDoctor.Hospital != nil {
|
||||
res.HospitalName = userDoctor.Hospital.HospitalName
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-open-api/api/controller"
|
||||
"hospital-open-api/api/exception"
|
||||
"hospital-open-api/api/middlewares"
|
||||
"hospital-open-api/config"
|
||||
"hospital-open-api/consts"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Init 初始化路由
|
||||
func Init() *gin.Engine {
|
||||
r := gin.New()
|
||||
|
||||
// 环境设置
|
||||
if config.C.Env == "prod" {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
|
||||
r.Use(middlewares.RequestParamsMiddleware())
|
||||
|
||||
// 日志中间件
|
||||
r.Use(middlewares.Logrus())
|
||||
|
||||
// 异常
|
||||
r.Use(gin.Recovery())
|
||||
|
||||
// 404处理
|
||||
r.NoRoute(func(c *gin.Context) {
|
||||
path := c.Request.URL.Path
|
||||
method := c.Request.Method
|
||||
c.JSON(http.StatusNotFound, gin.H{
|
||||
"msg": fmt.Sprintf("%s %s not found", method, path),
|
||||
"code": consts.ClientHttpNotFound,
|
||||
"data": "",
|
||||
})
|
||||
})
|
||||
//
|
||||
// // 异常处理
|
||||
r.Use(exception.Recover())
|
||||
|
||||
// 跨域处理
|
||||
r.Use(middlewares.Cors())
|
||||
|
||||
// 加载基础路由
|
||||
api := controller.Api{}
|
||||
|
||||
// 公开路由-不验证权限
|
||||
publicRouter(r, api)
|
||||
|
||||
// 验证权限
|
||||
r.Use(middlewares.Auth())
|
||||
|
||||
// 私有路由-验证权限
|
||||
privateRouter(r, api)
|
||||
|
||||
// 基础数据-验证权限
|
||||
basicRouter(r, api)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// publicRouter 公开路由-不验证权限
|
||||
func publicRouter(r *gin.Engine, api controller.Api) {
|
||||
_ = r.Group("/v1")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// basicRouter 基础数据-验证权限
|
||||
func basicRouter(r *gin.Engine, api controller.Api) {
|
||||
|
||||
}
|
||||
|
||||
// privateRouter 私有路由-验证权限
|
||||
func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
v1Group := r.Group("/v1")
|
||||
{
|
||||
userGroup := v1Group.Group("/user")
|
||||
{
|
||||
doctorGroup := userGroup.Group("/doctor")
|
||||
{
|
||||
// 获取多点执业医生详情
|
||||
doctorGroup.POST("/multi", api.V1.UserDoctor.GetMultiDoctor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user