新增获取解密手机号
This commit is contained in:
+37
-50
@@ -5,7 +5,6 @@ import (
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses"
|
||||
"hospital-admin-api/api/service"
|
||||
"hospital-admin-api/config"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
"strconv"
|
||||
@@ -13,55 +12,6 @@ import (
|
||||
|
||||
type Admin struct{}
|
||||
|
||||
// GetCaptcha 获取验证码
|
||||
func (b *Admin) GetCaptcha(c *gin.Context) {
|
||||
id, b64s, err := utils.GenerateCaptcha()
|
||||
if err != nil {
|
||||
responses.FailWithMessage("验证码获取失败", c)
|
||||
}
|
||||
|
||||
responses.OkWithData(gin.H{
|
||||
"id": id,
|
||||
"b64s": b64s,
|
||||
}, c)
|
||||
}
|
||||
|
||||
// Login 登陆
|
||||
func (b *Admin) Login(c *gin.Context) {
|
||||
var adminRequest requests.AdminRequest
|
||||
|
||||
if err := c.ShouldBind(&adminRequest.Login); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(adminRequest.Login); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 验证验证码
|
||||
if config.C.Env == "prod" {
|
||||
isValid := utils.VerifyCaptcha(adminRequest.Login)
|
||||
if !isValid {
|
||||
// 验证码错误
|
||||
responses.FailWithMessage("验证码错误", c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 登陆
|
||||
adminService := service.AdminService{}
|
||||
token, err := adminService.Login(adminRequest.Login)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(token, c)
|
||||
}
|
||||
|
||||
// GetOssSign 获取oss签名
|
||||
func (b *Admin) GetOssSign(c *gin.Context) {
|
||||
var adminRequest requests.AdminRequest
|
||||
@@ -161,3 +111,40 @@ func (b *Admin) GetDecryptOrderProductConsignee(c *gin.Context) {
|
||||
OrderProductConsignee, _ := orderProductService.GetOrderProductConsignee(orderProductId)
|
||||
responses.OkWithData(OrderProductConsignee, c)
|
||||
}
|
||||
|
||||
// GetDecryptMobile 获取解密手机号
|
||||
func (b *Admin) GetDecryptMobile(c *gin.Context) {
|
||||
var adminRequest requests.AdminRequest
|
||||
|
||||
if err := c.ShouldBind(&adminRequest.GetDecryptMobile); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(adminRequest.GetDecryptMobile); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 将 id 转换为 int64 类型
|
||||
userId, err := strconv.ParseInt(adminRequest.GetDecryptMobile.UserId, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
var familyId int64
|
||||
if adminRequest.GetDecryptMobile.FamilyId != "" {
|
||||
familyId, err = strconv.ParseInt(adminRequest.GetDecryptMobile.FamilyId, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 获取用户身份证号
|
||||
userService := service.UserService{}
|
||||
userMobile, _ := userService.GetUserMobile(userId, familyId)
|
||||
responses.OkWithData(userMobile, c)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ package controller
|
||||
type Api struct {
|
||||
sysSetting // 系统设置
|
||||
userDoctorManage // 医生管理
|
||||
Admin // 公共方法
|
||||
Admin // 公共方法-验证权限
|
||||
Public // 公共方法-不验证权限
|
||||
basic // 基础数据
|
||||
order // 订单管理
|
||||
userPatientManage // 患者管理
|
||||
|
||||
@@ -1,3 +1,62 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses"
|
||||
"hospital-admin-api/api/service"
|
||||
"hospital-admin-api/config"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
)
|
||||
|
||||
type Public struct{}
|
||||
|
||||
// GetCaptcha 获取验证码
|
||||
func (b *Public) GetCaptcha(c *gin.Context) {
|
||||
id, b64s, err := utils.GenerateCaptcha()
|
||||
if err != nil {
|
||||
responses.FailWithMessage("验证码获取失败", c)
|
||||
}
|
||||
|
||||
responses.OkWithData(gin.H{
|
||||
"id": id,
|
||||
"b64s": b64s,
|
||||
}, c)
|
||||
}
|
||||
|
||||
// Login 登陆
|
||||
func (b *Public) Login(c *gin.Context) {
|
||||
var adminRequest requests.AdminRequest
|
||||
|
||||
if err := c.ShouldBind(&adminRequest.Login); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(adminRequest.Login); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 验证验证码
|
||||
if config.C.Env == "prod" {
|
||||
isValid := utils.VerifyCaptcha(adminRequest.Login)
|
||||
if !isValid {
|
||||
// 验证码错误
|
||||
responses.FailWithMessage("验证码错误", c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 登陆
|
||||
adminService := service.AdminService{}
|
||||
token, err := adminService.Login(adminRequest.Login)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(token, c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user