更新密码找回uniapp

This commit is contained in:
hero920103 committed 2026-11-16 17:22:50 +08:00
1 parent 7f9a66da0f
commit 3fdda89833
1304 files changed
+3503 -26132

No files matched your search

+1 -31
View File
@@ -25,23 +25,15 @@ type domainPoolPayload struct {
var subDomainRe = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$`)
// customDomainPayload 绑定自有域名的请求体。
// tid 仅平台端(运营代操作)使用;租户端一律以登录态里的租户 ID 为准。
type customDomainPayload struct {
Tid uint64 `json:"tid"`
Domain string `json:"domain"`
}
// domainIDPayload 仅带域名记录 ID 的请求体
type domainIDPayload struct {
ID uint64 `json:"id"`
}
// ===== 列表输出 =====
// tenantDomainDTO 把域名记录转成前端需要的结构。
// 直接把 ORM 结构体丢给前端会让时间字段变成 RFC3339,且拿不到租户名称,
// 因此列表统一走这里:时间格式化,租户名按 tid 批量补齐。
func tenantDomainDTO(row models.SystemTenantDomain, tenantNames map[uint64]string) map[string]interface{} {
item := map[string]interface{}{
"id": row.ID,
@@ -72,7 +64,6 @@ func tenantDomainDTO(row models.SystemTenantDomain, tenantNames map[uint64]strin
return item
}
// tenantDomainList 批量转换,顺带一次性查出涉及的租户名称
func tenantDomainList(rows []models.SystemTenantDomain) []map[string]interface{} {
tenantNames := lookupTenantNames(rows)
list := make([]map[string]interface{}, 0, len(rows))
@@ -82,7 +73,6 @@ func tenantDomainList(rows []models.SystemTenantDomain) []map[string]interface{}
return list
}
// lookupTenantNames 按 tid 查租户名称,避免列表里逐行查库
func lookupTenantNames(rows []models.SystemTenantDomain) map[uint64]string {
ids := make([]uint64, 0, len(rows))
seen := make(map[uint64]bool, len(rows))
@@ -120,10 +110,6 @@ func strPtrVal(p *string) string {
return *p
}
// ===== 以下逻辑被 backend / platform 两套控制器共用 =====
// bindCustomDomain 为租户绑定自有域名。
// 返回 (记录ID, HTTP状态码, 错误信息);错误信息为空表示成功。
func bindCustomDomain(tid uint64, rawDomain string) (uint64, int, string) {
if tid == 0 {
return 0, 400, "租户ID不能为空"
@@ -134,13 +120,10 @@ func bindCustomDomain(tid uint64, rawDomain string) (uint64, int, string) {
return 0, 400, "域名格式不正确,请填写完整域名(如 www.example.com)"
}
// 通配符只在平台域名池里有意义:自有域名一条记录对应一个精确 Host,
// 悄悄把 *.example.com 收成 example.com 会绑到用户没想绑的域名上。
if strings.HasPrefix(strings.TrimSpace(rawDomain), "*.") {
return 0, 400, "暂不支持通配符域名,请填写要绑定的具体域名(如 www.example.com)"
}
// 租户必须存在且未停用(平台端可以传任意 tid,这里兜住手误)
tenantOK, _ := models.Orm.QueryTable(new(models.SystemTenant)).
Filter("id", tid).
Filter("delete_time__isnull", true).
@@ -149,7 +132,6 @@ func bindCustomDomain(tid uint64, rawDomain string) (uint64, int, string) {
return 0, 400, "租户不存在"
}
// 不允许绑定平台自己的域名:平台主域及其任意子域都由域名池统一发放
msg, err := checkNotPlatformDomain(host)
if err != nil {
return 0, 500, "域名校验失败,请稍后重试"
@@ -158,7 +140,6 @@ func bindCustomDomain(tid uint64, rawDomain string) (uint64, int, string) {
return 0, 400, msg
}
// 全局唯一:同一个域名只能指向一个租户官网
used, _ := models.Orm.QueryTable(new(models.SystemTenantDomain)).
Filter("full_domain", host).
Filter("delete_time__isnull", true).
@@ -167,7 +148,6 @@ func bindCustomDomain(tid uint64, rawDomain string) (uint64, int, string) {
return 0, 400, "该域名已被绑定"
}
// 每个租户一个自有域名(平台二级域名不受此限制,两者可以同时存在)
exists, _ := models.Orm.QueryTable(new(models.SystemTenantDomain)).
Filter("tid", tid).
Filter("domain_type", models.DomainTypeCustom).
@@ -183,7 +163,7 @@ func bindCustomDomain(tid uint64, rawDomain string) (uint64, int, string) {
Tid: &tidCopy,
DomainType: models.DomainTypeCustom,
FullDomain: &host,
Status: 0, // DNS 检测通过且证书签发成功后自动置 1
Status: 0,
SSLStatus: models.SSLStatusPending,
VerifyStatus: models.VerifyStatusNone,
CreateTime: now,
@@ -196,10 +176,6 @@ func bindCustomDomain(tid uint64, rawDomain string) (uint64, int, string) {
return uint64(id), 200, ""
}
// checkNotPlatformDomain 校验域名不属于平台域名池(含子域)。
// 平台域名的解析与证书由平台统一维护,租户只能通过「申请二级域名」获得。
// 返回 (拒绝原因, 查询错误)。查询出错时必须由调用方拒绝,
// 否则一次数据库抖动就能让租户把平台主域绑走。
func checkNotPlatformDomain(host string) (string, error) {
var pools []models.SystemDomainPool
if _, err := models.Orm.QueryTable(new(models.SystemDomainPool)).
@@ -219,9 +195,6 @@ func checkNotPlatformDomain(host string) (string, error) {
return "", nil
}
// checkCustomDomainDNS 检测自有域名解析,通过则异步触发证书签发。
// tid 传 0 表示不限制归属(平台端运营场景)。
// 返回 (给前端的数据, HTTP状态码, 错误信息)。
func checkCustomDomainDNS(id, tid uint64) (map[string]interface{}, int, string) {
if id == 0 {
return nil, 400, "参数错误"
@@ -246,7 +219,6 @@ func checkCustomDomainDNS(id, tid uint64) (map[string]interface{}, int, string)
host := *row.FullDomain
passed, msg := services.VerifyCustomDomainDNS(host)
// verify_msg 字段 varchar(500),解析出的 IP 列表可能很长,截断避免写库失败
if len(msg) > 480 {
msg = msg[:480]
}
@@ -276,7 +248,6 @@ func checkCustomDomainDNS(id, tid uint64) (map[string]interface{}, int, string)
return data, 200, ""
}
// 解析已通过:证书没签好就发起签发
if row.SSLStatus == models.SSLStatusIssued {
data["ssl_message"] = "解析正常,证书已就绪"
return data, 200, ""
@@ -290,7 +261,6 @@ func checkCustomDomainDNS(id, tid uint64) (map[string]interface{}, int, string)
return data, 200, ""
}
// customDomainGuideData 返回租户配置解析所需的信息
func customDomainGuideData() map[string]interface{} {
guide := services.GetCustomDomainGuide()
return map[string]interface{}{