新增开发接口,可以清除实名信息

This commit is contained in:
2026-03-17 14:19:08 +08:00
parent efce18e6f5
commit 99853b8514
2 changed files with 42 additions and 21 deletions

View File

@@ -18,19 +18,7 @@ import (
jdclient "github.com/jdcloud-api/jdcloud-sdk-go/services/cloudauth/client"
)
// region 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"`
}
// Identify 发起实名认证
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 {
Success bool
Message string
}
func renderIdenResult(c *fiber.Ctx, success bool, message string) error {
return c.Render("views/iden-result", idenResultData{
Success: success,
Message: message,
})
}
// IdentifyCallbackNew 更新用户实名认证状态
func IdentifyCallbackNew(c *fiber.Ctx) error {
@@ -168,6 +158,36 @@ func IdentifyCallbackNew(c *fiber.Ctx) error {
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 {
return fmt.Sprintf("iden:%s", id)
}

View File

@@ -22,6 +22,7 @@ func ApplyRouters(app *fiber.App) {
debug := app.Group("/debug")
debug.Get("/sms/:phone", handlers.DebugGetSmsCode)
debug.Get("/proxy/register", handlers.DebugRegisterProxyBaiYin)
debug.Get("/iden/clear/:phone", handlers.DebugIdentifyClear)
}
}