feat(1.0): 调整模版变量
This commit is contained in:
parent
7eade510a5
commit
4001993e96
@ -1946,6 +1946,10 @@ const docTemplate = `{
|
|||||||
"description": "小程序头像",
|
"description": "小程序头像",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"check_status_text": {
|
||||||
|
"description": "状态文字描述",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"description": "创建时间",
|
"description": "创建时间",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|||||||
@ -1938,6 +1938,10 @@
|
|||||||
"description": "小程序头像",
|
"description": "小程序头像",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"check_status_text": {
|
||||||
|
"description": "状态文字描述",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"description": "创建时间",
|
"description": "创建时间",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|||||||
@ -311,6 +311,9 @@ definitions:
|
|||||||
avatar:
|
avatar:
|
||||||
description: 小程序头像
|
description: 小程序头像
|
||||||
type: string
|
type: string
|
||||||
|
check_status_text:
|
||||||
|
description: 状态文字描述
|
||||||
|
type: string
|
||||||
created_at:
|
created_at:
|
||||||
description: 创建时间
|
description: 创建时间
|
||||||
type: string
|
type: string
|
||||||
|
|||||||
@ -6,9 +6,11 @@ import (
|
|||||||
|
|
||||||
"mini-chat/internal/code"
|
"mini-chat/internal/code"
|
||||||
"mini-chat/internal/pkg/core"
|
"mini-chat/internal/pkg/core"
|
||||||
|
"mini-chat/internal/pkg/httpclient"
|
||||||
"mini-chat/internal/pkg/timeutil"
|
"mini-chat/internal/pkg/timeutil"
|
||||||
"mini-chat/internal/pkg/validation"
|
"mini-chat/internal/pkg/validation"
|
||||||
|
|
||||||
|
"go.uber.org/zap"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,16 +23,17 @@ type listRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type listData struct {
|
type listData struct {
|
||||||
ID int32 `json:"id"` // 小程序编号
|
ID int32 `json:"id"` // 小程序编号
|
||||||
AppID string `json:"app_id"` // 小程序ID
|
AppID string `json:"app_id"` // 小程序ID
|
||||||
AppSecret string `json:"app_secret"` // 小程序密钥
|
AppSecret string `json:"app_secret"` // 小程序密钥
|
||||||
Name string `json:"name"` // 小程序名称
|
Name string `json:"name"` // 小程序名称
|
||||||
Description string `json:"description"` // 小程序描述
|
Description string `json:"description"` // 小程序描述
|
||||||
Avatar string `json:"avatar"` // 小程序头像
|
Avatar string `json:"avatar"` // 小程序头像
|
||||||
TemplateID string `json:"template_id"` // 模版ID
|
TemplateID string `json:"template_id"` // 模版ID
|
||||||
CreatedAt string `json:"created_at"` // 创建时间
|
CreatedAt string `json:"created_at"` // 创建时间
|
||||||
UpdatedAt string `json:"updated_at"` // 更新时间
|
UpdatedAt string `json:"updated_at"` // 更新时间
|
||||||
MessageTotal int64 `json:"message_total"` // 消息总数
|
MessageTotal int64 `json:"message_total"` // 消息总数
|
||||||
|
CheckStatusText string `json:"check_status_text"` // 状态文字描述
|
||||||
}
|
}
|
||||||
|
|
||||||
type listResponse struct {
|
type listResponse struct {
|
||||||
@ -135,19 +138,50 @@ func (h *handler) PageList() core.HandlerFunc {
|
|||||||
res.Total = count
|
res.Total = count
|
||||||
res.List = make([]listData, len(resultData))
|
res.List = make([]listData, len(resultData))
|
||||||
|
|
||||||
|
type checkAppResponse struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Appid string `json:"appid"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
checkAppRes := new(checkAppResponse)
|
||||||
for k, v := range resultData {
|
for k, v := range resultData {
|
||||||
messageTotalCount, _ := h.readDB.AppMessageLog.WithContext(ctx.RequestContext()).Where(h.readDB.AppMessageLog.AppID.Eq(v.AppID)).Count()
|
messageTotalCount, _ := h.readDB.AppMessageLog.WithContext(ctx.RequestContext()).Where(h.readDB.AppMessageLog.AppID.Eq(v.AppID)).Count()
|
||||||
|
checkStatusText := "未知"
|
||||||
|
response, err := httpclient.GetHttpClientWithContext(ctx.RequestContext()).R().
|
||||||
|
SetQueryParams(map[string]string{
|
||||||
|
"appid": v.AppID,
|
||||||
|
}).
|
||||||
|
SetResult(checkAppRes).
|
||||||
|
Get("https://api.wxapi.work/xcx/checkxcx.php")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
h.logger.Error("请求失败", zap.Error(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查响应状态码
|
||||||
|
if response.IsError() {
|
||||||
|
h.logger.Error(fmt.Sprintf("请求APP验证服务异常(%d)", response.StatusCode()))
|
||||||
|
}
|
||||||
|
|
||||||
|
if checkAppRes.Code == 1 {
|
||||||
|
checkStatusText = "正常"
|
||||||
|
} else if checkAppRes.Code == 0 {
|
||||||
|
checkStatusText = "封禁"
|
||||||
|
}
|
||||||
|
|
||||||
res.List[k] = listData{
|
res.List[k] = listData{
|
||||||
ID: v.ID,
|
ID: v.ID,
|
||||||
AppID: v.AppID,
|
AppID: v.AppID,
|
||||||
AppSecret: v.AppSecret,
|
AppSecret: v.AppSecret,
|
||||||
Name: v.Name,
|
Name: v.Name,
|
||||||
Description: v.Description,
|
Description: v.Description,
|
||||||
Avatar: v.Avatar,
|
Avatar: v.Avatar,
|
||||||
TemplateID: v.TemplateID,
|
TemplateID: v.TemplateID,
|
||||||
CreatedAt: timeutil.FriendlyTime(v.CreatedAt),
|
CreatedAt: timeutil.FriendlyTime(v.CreatedAt),
|
||||||
UpdatedAt: timeutil.FriendlyTime(v.UpdatedAt),
|
UpdatedAt: timeutil.FriendlyTime(v.UpdatedAt),
|
||||||
MessageTotal: messageTotalCount,
|
MessageTotal: messageTotalCount,
|
||||||
|
CheckStatusText: checkStatusText,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user