新增患者手机号

This commit is contained in:
wucongxing 2023-09-12 09:35:32 +08:00
parent 09b062aa5d
commit 3fcafc909a
2 changed files with 25 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import (
"hospital-admin-api/api/responses/orderInquiryCouponResponse"
"hospital-admin-api/api/responses/orderInquiryRefundResponse"
"hospital-admin-api/api/responses/userDoctorResponse"
"hospital-admin-api/utils"
)
// getOrderInquiryPage 获取医生列表-分页
@ -134,7 +135,7 @@ func GetOrderInquiryPageResponse(orderInquiry []*model.OrderInquiry) []getOrderI
PatientNameMask: v.PatientNameMask,
PatientSex: v.PatientSex,
PatientAge: v.PatientAge,
PatientMobile: v.User.Mobile,
PatientMobile: utils.MaskPhoneStr(v.User.Mobile),
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}

View File

@ -64,3 +64,26 @@ func MaskNameStr(str string, maskType int) string {
return str
}
// MaskPhoneStr 手机号、固话加密
// 固话0510-89754815 0510-8****815
// 手机号18221234158 18*******58
func MaskPhoneStr(phone string) string {
if phone == "" {
return phone
}
// 使用正则表达式匹配固定电话
phonePattern := `(0[0-9]{2,3}[\-]?[2-9][0-9]{6,7}[\-]?[0-9]?)`
isFixedLine := regexp.MustCompile(phonePattern).MatchString(phone)
if isFixedLine {
// 匹配到固定电话
// 替换匹配的部分为固定格式
return regexp.MustCompile(`(0[0-9]{2,3}[\-]?[2-9])[0-9]{3,4}([0-9]{3}[\-]?[0-9]?)`).ReplaceAllString(phone, "$1****$2")
} else {
// 匹配到手机号
// 替换匹配的部分为固定格式
return regexp.MustCompile(`(1[0-9]{1})[0-9]{7}([0-9]{2})`).ReplaceAllString(phone, "$1*******$2")
}
}