新增身份证解密
This commit is contained in:
parent
cdbaed5755
commit
4465131099
@ -7,6 +7,7 @@ import (
|
|||||||
"hospital-admin-api/api/service"
|
"hospital-admin-api/api/service"
|
||||||
"hospital-admin-api/global"
|
"hospital-admin-api/global"
|
||||||
"hospital-admin-api/utils"
|
"hospital-admin-api/utils"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Admin struct{}
|
type Admin struct{}
|
||||||
@ -78,3 +79,40 @@ func (b *Admin) GetOssSign(c *gin.Context) {
|
|||||||
ossSign, _ := adminService.GetOssSign(adminRequest.GetOssSign)
|
ossSign, _ := adminService.GetOssSign(adminRequest.GetOssSign)
|
||||||
responses.OkWithData(ossSign, c)
|
responses.OkWithData(ossSign, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDecryptCardNum 获取解密身份证号
|
||||||
|
func (b *Admin) GetDecryptCardNum(c *gin.Context) {
|
||||||
|
var adminRequest requests.AdminRequest
|
||||||
|
|
||||||
|
if err := c.ShouldBind(&adminRequest.GetDecryptCardNum); err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 参数验证
|
||||||
|
if err := global.Validate.Struct(adminRequest.GetDecryptCardNum); err != nil {
|
||||||
|
responses.FailWithMessage(utils.Translate(err), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将 id 转换为 int64 类型
|
||||||
|
userId, err := strconv.ParseInt(adminRequest.GetDecryptCardNum.UserId, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
responses.Fail(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var familyId int64
|
||||||
|
if adminRequest.GetDecryptCardNum.FamilyId != "" {
|
||||||
|
familyId, err = strconv.ParseInt(adminRequest.GetDecryptCardNum.FamilyId, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
responses.Fail(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户身份证号
|
||||||
|
userService := service.UserService{}
|
||||||
|
userCardNum, _ := userService.GetUserCardNum(userId, familyId)
|
||||||
|
responses.OkWithData(userCardNum, c)
|
||||||
|
}
|
||||||
|
|||||||
72
api/dao/patientFamily.go
Normal file
72
api/dao/patientFamily.go
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"hospital-admin-api/api/model"
|
||||||
|
"hospital-admin-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
|
||||||
|
}
|
||||||
@ -27,6 +27,15 @@ func (r *UserDoctorInfoDao) GetUserDoctorInfoByDoctorId(doctorId int64) (m *mode
|
|||||||
return m, nil
|
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 删除医生详情
|
// DeleteUserDoctorInfo 删除医生详情
|
||||||
func (r *UserDoctorInfoDao) DeleteUserDoctorInfo(tx *gorm.DB, maps interface{}) error {
|
func (r *UserDoctorInfoDao) DeleteUserDoctorInfo(tx *gorm.DB, maps interface{}) error {
|
||||||
err := tx.Where(maps).Delete(&model.UserDoctorInfo{}).Error
|
err := tx.Where(maps).Delete(&model.UserDoctorInfo{}).Error
|
||||||
|
|||||||
37
api/model/patientFamily.go
Normal file
37
api/model/patientFamily.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// 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"
|
||||||
|
}
|
||||||
@ -1,8 +1,9 @@
|
|||||||
package requests
|
package requests
|
||||||
|
|
||||||
type AdminRequest struct {
|
type AdminRequest struct {
|
||||||
Login // 登陆
|
Login // 登陆
|
||||||
GetOssSign // 获取医生列表-分页
|
GetOssSign // 获取医生列表-分页
|
||||||
|
GetDecryptCardNum // 获取用户身份证号
|
||||||
}
|
}
|
||||||
|
|
||||||
// Login 登陆
|
// Login 登陆
|
||||||
@ -18,3 +19,9 @@ type GetOssSign struct {
|
|||||||
UserType int `json:"user_type" form:"user_type" validate:"required,oneof=1 2 3 4" label:"用户类型"` // (1:患者 2:医生 3:药师 4:后台)
|
UserType int `json:"user_type" form:"user_type" validate:"required,oneof=1 2 3 4" label:"用户类型"` // (1:患者 2:医生 3:药师 4:后台)
|
||||||
Scene int `json:"scene" form:"scene" validate:"required,oneof=1 2 3 4" label:"场景"` // (1:头像 2:证书 3:名片)
|
Scene int `json:"scene" form:"scene" validate:"required,oneof=1 2 3 4" label:"场景"` // (1:头像 2:证书 3:名片)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDecryptCardNum 获取用户身份证号
|
||||||
|
type GetDecryptCardNum struct {
|
||||||
|
FamilyId string `json:"family_id" form:"family_id" label:"家庭成员"` // 家庭成员id
|
||||||
|
UserId string `json:"user_id" form:"user_id" validate:"required" label:"用户"` // 用户id
|
||||||
|
}
|
||||||
|
|||||||
@ -76,6 +76,20 @@ func adminRouter(r *gin.Engine, api controller.Api) {
|
|||||||
// 获取oss签名
|
// 获取oss签名
|
||||||
signGroup.GET("/oss", api.Admin.GetOssSign)
|
signGroup.GET("/oss", api.Admin.GetOssSign)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 解密
|
||||||
|
decryptGroup := r.Group("/decrypt")
|
||||||
|
{
|
||||||
|
cardGroup := decryptGroup.Group("/card")
|
||||||
|
{
|
||||||
|
// 获取解密身份证号
|
||||||
|
cardGroup.GET("/num", api.Admin.GetDecryptCardNum)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取银行卡号
|
||||||
|
decryptGroup.GET("/bank", api.Admin.GetOssSign)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// basicRouter 基础数据-验证权限
|
// basicRouter 基础数据-验证权限
|
||||||
|
|||||||
@ -394,3 +394,45 @@ func (r *UserService) PutUserPassword(requestUserId int64, putUserPasswordReques
|
|||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserCardNum 获取用户身份证号
|
||||||
|
func (r *UserService) GetUserCardNum(userId, familyId int64) (string, error) {
|
||||||
|
var cardNum string
|
||||||
|
|
||||||
|
// 获取用户数据
|
||||||
|
userDao := dao.UserDao{}
|
||||||
|
user, err := userDao.GetUserById(userId)
|
||||||
|
if err != nil || user == nil {
|
||||||
|
return "", errors.New("用户错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断用户类型
|
||||||
|
if user.UserType == 1 {
|
||||||
|
// 患者
|
||||||
|
if familyId == 0 {
|
||||||
|
return "", errors.New("获取失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
patientFamilyDao := dao.PatientFamilyDao{}
|
||||||
|
patientFamily, err := patientFamilyDao.GetPatientFamilyById(familyId)
|
||||||
|
if err != nil || patientFamily == nil {
|
||||||
|
return "", errors.New("获取失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
cardNum = patientFamily.IdNumber
|
||||||
|
} else if user.UserType == 2 {
|
||||||
|
// 医生
|
||||||
|
userDoctorInfoDao := dao.UserDoctorInfoDao{}
|
||||||
|
userDoctorInfo, err := userDoctorInfoDao.GetUserDoctorInfoByUserId(userId)
|
||||||
|
if err != nil || userDoctorInfo == nil {
|
||||||
|
return "", errors.New("获取失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
cardNum = userDoctorInfo.CardNum
|
||||||
|
} else if user.UserType == 3 {
|
||||||
|
// 药师
|
||||||
|
cardNum = "暂时未做"
|
||||||
|
}
|
||||||
|
|
||||||
|
return cardNum, nil
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user