新增开发接口,可以清除实名信息
This commit is contained in:
@@ -18,19 +18,7 @@ import (
|
|||||||
jdclient "github.com/jdcloud-api/jdcloud-sdk-go/services/cloudauth/client"
|
jdclient "github.com/jdcloud-api/jdcloud-sdk-go/services/cloudauth/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
// region Identify
|
// Identify 发起实名认证
|
||||||
|
|
||||||
type IdentifyReq struct {
|
|
||||||
Type int `json:"type" validate:"required,oneof=1 2"`
|
|
||||||
Name string `json:"name" validate:"required"`
|
|
||||||
IdenNo string `json:"iden_no" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type IdentifyRes struct {
|
|
||||||
Identified bool `json:"identified"`
|
|
||||||
Target string `json:"target"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func Identify(c *fiber.Ctx) error {
|
func Identify(c *fiber.Ctx) error {
|
||||||
|
|
||||||
// 检查权限
|
// 检查权限
|
||||||
@@ -99,20 +87,22 @@ func Identify(c *fiber.Ctx) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// endregion
|
type IdentifyReq struct {
|
||||||
|
Type int `json:"type" validate:"required,oneof=1 2"`
|
||||||
|
Name string `json:"name" validate:"required"`
|
||||||
|
IdenNo string `json:"iden_no" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type IdentifyRes struct {
|
||||||
|
Identified bool `json:"identified"`
|
||||||
|
Target string `json:"target"`
|
||||||
|
}
|
||||||
|
|
||||||
type idenResultData struct {
|
type idenResultData struct {
|
||||||
Success bool
|
Success bool
|
||||||
Message string
|
Message string
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderIdenResult(c *fiber.Ctx, success bool, message string) error {
|
|
||||||
return c.Render("views/iden-result", idenResultData{
|
|
||||||
Success: success,
|
|
||||||
Message: message,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// IdentifyCallbackNew 更新用户实名认证状态
|
// IdentifyCallbackNew 更新用户实名认证状态
|
||||||
func IdentifyCallbackNew(c *fiber.Ctx) error {
|
func IdentifyCallbackNew(c *fiber.Ctx) error {
|
||||||
|
|
||||||
@@ -168,6 +158,36 @@ func IdentifyCallbackNew(c *fiber.Ctx) error {
|
|||||||
return renderIdenResult(c, true, "实名认证成功,请在扫码页面点击按钮完成认证")
|
return renderIdenResult(c, true, "实名认证成功,请在扫码页面点击按钮完成认证")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func renderIdenResult(c *fiber.Ctx, success bool, message string) error {
|
||||||
|
return c.Render("views/iden-result", idenResultData{
|
||||||
|
Success: success,
|
||||||
|
Message: message,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// DebugIdentifyClear 清除用户实名认证状态(调试用)
|
||||||
|
func DebugIdentifyClear(c *fiber.Ctx) error {
|
||||||
|
phone := c.Params("phone")
|
||||||
|
if phone == "" {
|
||||||
|
return core.NewServErr("需要提供手机号")
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := q.User.
|
||||||
|
Where(
|
||||||
|
q.User.Phone.Eq(phone),
|
||||||
|
).
|
||||||
|
UpdateSimple(
|
||||||
|
q.User.IDType.Value(0),
|
||||||
|
q.User.IDNo.Value(""),
|
||||||
|
q.User.IDToken.Value(""),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return core.NewServErr("清除实名认证失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.SendString("实名信息已清除")
|
||||||
|
}
|
||||||
|
|
||||||
func idenKey(id string) string {
|
func idenKey(id string) string {
|
||||||
return fmt.Sprintf("iden:%s", id)
|
return fmt.Sprintf("iden:%s", id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ func ApplyRouters(app *fiber.App) {
|
|||||||
debug := app.Group("/debug")
|
debug := app.Group("/debug")
|
||||||
debug.Get("/sms/:phone", handlers.DebugGetSmsCode)
|
debug.Get("/sms/:phone", handlers.DebugGetSmsCode)
|
||||||
debug.Get("/proxy/register", handlers.DebugRegisterProxyBaiYin)
|
debug.Get("/proxy/register", handlers.DebugRegisterProxyBaiYin)
|
||||||
|
debug.Get("/iden/clear/:phone", handlers.DebugIdentifyClear)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user