feat(1.0): 调整模版变量
This commit is contained in:
parent
7eade510a5
commit
4001993e96
@ -1946,6 +1946,10 @@ const docTemplate = `{
|
||||
"description": "小程序头像",
|
||||
"type": "string"
|
||||
},
|
||||
"check_status_text": {
|
||||
"description": "状态文字描述",
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"description": "创建时间",
|
||||
"type": "string"
|
||||
|
||||
@ -1938,6 +1938,10 @@
|
||||
"description": "小程序头像",
|
||||
"type": "string"
|
||||
},
|
||||
"check_status_text": {
|
||||
"description": "状态文字描述",
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"description": "创建时间",
|
||||
"type": "string"
|
||||
|
||||
@ -311,6 +311,9 @@ definitions:
|
||||
avatar:
|
||||
description: 小程序头像
|
||||
type: string
|
||||
check_status_text:
|
||||
description: 状态文字描述
|
||||
type: string
|
||||
created_at:
|
||||
description: 创建时间
|
||||
type: string
|
||||
|
||||
@ -6,9 +6,11 @@ import (
|
||||
|
||||
"mini-chat/internal/code"
|
||||
"mini-chat/internal/pkg/core"
|
||||
"mini-chat/internal/pkg/httpclient"
|
||||
"mini-chat/internal/pkg/timeutil"
|
||||
"mini-chat/internal/pkg/validation"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@ -31,6 +33,7 @@ type listData struct {
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
UpdatedAt string `json:"updated_at"` // 更新时间
|
||||
MessageTotal int64 `json:"message_total"` // 消息总数
|
||||
CheckStatusText string `json:"check_status_text"` // 状态文字描述
|
||||
}
|
||||
|
||||
type listResponse struct {
|
||||
@ -135,8 +138,38 @@ func (h *handler) PageList() core.HandlerFunc {
|
||||
res.Total = count
|
||||
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 {
|
||||
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{
|
||||
ID: v.ID,
|
||||
AppID: v.AppID,
|
||||
@ -148,6 +181,7 @@ func (h *handler) PageList() core.HandlerFunc {
|
||||
CreatedAt: timeutil.FriendlyTime(v.CreatedAt),
|
||||
UpdatedAt: timeutil.FriendlyTime(v.UpdatedAt),
|
||||
MessageTotal: messageTotalCount,
|
||||
CheckStatusText: checkStatusText,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user