feat(1.0):调试模版消息
This commit is contained in:
parent
b4d30ddbce
commit
ce83dc1b02
16
docs/docs.go
16
docs/docs.go
@ -1695,6 +1695,10 @@ const docTemplate = `{
|
||||
"name": {
|
||||
"description": "名称",
|
||||
"type": "string"
|
||||
},
|
||||
"template_id": {
|
||||
"description": "模版ID",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -1854,6 +1858,10 @@ const docTemplate = `{
|
||||
"description": "小程序名称",
|
||||
"type": "string"
|
||||
},
|
||||
"template_id": {
|
||||
"description": "模版ID",
|
||||
"type": "string"
|
||||
},
|
||||
"updated_at": {
|
||||
"description": "更新时间",
|
||||
"type": "string"
|
||||
@ -1867,6 +1875,10 @@ const docTemplate = `{
|
||||
"description": "消息内容",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "消息ID",
|
||||
"type": "string"
|
||||
},
|
||||
"msg_type": {
|
||||
"description": "消息类型(1:文本 2:图片)",
|
||||
"type": "integer"
|
||||
@ -1939,6 +1951,10 @@ const docTemplate = `{
|
||||
"name": {
|
||||
"description": "名称",
|
||||
"type": "string"
|
||||
},
|
||||
"template_id": {
|
||||
"description": "模版ID",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -1687,6 +1687,10 @@
|
||||
"name": {
|
||||
"description": "名称",
|
||||
"type": "string"
|
||||
},
|
||||
"template_id": {
|
||||
"description": "模版ID",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -1846,6 +1850,10 @@
|
||||
"description": "小程序名称",
|
||||
"type": "string"
|
||||
},
|
||||
"template_id": {
|
||||
"description": "模版ID",
|
||||
"type": "string"
|
||||
},
|
||||
"updated_at": {
|
||||
"description": "更新时间",
|
||||
"type": "string"
|
||||
@ -1859,6 +1867,10 @@
|
||||
"description": "消息内容",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "消息ID",
|
||||
"type": "string"
|
||||
},
|
||||
"msg_type": {
|
||||
"description": "消息类型(1:文本 2:图片)",
|
||||
"type": "integer"
|
||||
@ -1931,6 +1943,10 @@
|
||||
"name": {
|
||||
"description": "名称",
|
||||
"type": "string"
|
||||
},
|
||||
"template_id": {
|
||||
"description": "模版ID",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -204,6 +204,9 @@ definitions:
|
||||
name:
|
||||
description: 名称
|
||||
type: string
|
||||
template_id:
|
||||
description: 模版ID
|
||||
type: string
|
||||
required:
|
||||
- app_id
|
||||
- app_secret
|
||||
@ -320,6 +323,9 @@ definitions:
|
||||
name:
|
||||
description: 小程序名称
|
||||
type: string
|
||||
template_id:
|
||||
description: 模版ID
|
||||
type: string
|
||||
updated_at:
|
||||
description: 更新时间
|
||||
type: string
|
||||
@ -329,6 +335,9 @@ definitions:
|
||||
content:
|
||||
description: 消息内容
|
||||
type: string
|
||||
id:
|
||||
description: 消息ID
|
||||
type: string
|
||||
msg_type:
|
||||
description: 消息类型(1:文本 2:图片)
|
||||
type: integer
|
||||
@ -378,6 +387,9 @@ definitions:
|
||||
name:
|
||||
description: 名称
|
||||
type: string
|
||||
template_id:
|
||||
description: 模版ID
|
||||
type: string
|
||||
required:
|
||||
- app_id
|
||||
- app_secret
|
||||
|
||||
@ -19,6 +19,7 @@ type createAppRequest struct {
|
||||
Name string `json:"name" binding:"required"` // 名称
|
||||
Description string `json:"description"` // 描述
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
TemplateID string `json:"template_id"` // 模版ID
|
||||
}
|
||||
|
||||
type createAppResponse struct {
|
||||
@ -85,6 +86,7 @@ func (h *handler) CreateApp() core.HandlerFunc {
|
||||
App.Name = req.Name
|
||||
App.Description = req.Description
|
||||
App.Avatar = req.Avatar
|
||||
App.TemplateID = req.TemplateID
|
||||
App.CreatedUser = ctx.SessionUserInfo().UserName
|
||||
App.CreatedAt = time.Now()
|
||||
if err := h.writeDB.MiniProgram.WithContext(ctx.RequestContext()).Create(App); err != nil {
|
||||
|
||||
@ -27,6 +27,7 @@ type listData struct {
|
||||
Name string `json:"name"` // 小程序名称
|
||||
Description string `json:"description"` // 小程序描述
|
||||
Avatar string `json:"avatar"` // 小程序头像
|
||||
TemplateID string `json:"template_id"` // 模版ID
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
UpdatedAt string `json:"updated_at"` // 更新时间
|
||||
}
|
||||
@ -141,6 +142,7 @@ func (h *handler) PageList() core.HandlerFunc {
|
||||
Name: v.Name,
|
||||
Description: v.Description,
|
||||
Avatar: v.Avatar,
|
||||
TemplateID: v.TemplateID,
|
||||
CreatedAt: timeutil.FriendlyTime(v.CreatedAt),
|
||||
UpdatedAt: timeutil.FriendlyTime(v.UpdatedAt),
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ type modifyAppRequest struct {
|
||||
Name string `json:"name" binding:"required"` // 名称
|
||||
Description string `json:"description"` // 描述
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
TemplateID string `json:"template_id"` // 模版ID
|
||||
}
|
||||
|
||||
type modifyAppResponse struct {
|
||||
@ -126,6 +127,7 @@ func (h *handler) ModifyApp() core.HandlerFunc {
|
||||
checkIdInfo.Name = req.Name
|
||||
checkIdInfo.Description = req.Description
|
||||
checkIdInfo.Avatar = req.Avatar
|
||||
checkIdInfo.TemplateID = req.TemplateID
|
||||
checkIdInfo.UpdatedUser = ctx.SessionUserInfo().UserName
|
||||
checkIdInfo.UpdatedAt = time.Now()
|
||||
if err := h.writeDB.MiniProgram.WithContext(ctx.RequestContext()).Save(checkIdInfo); err != nil {
|
||||
|
||||
@ -5,13 +5,13 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mini-chat/internal/pkg/miniprogram"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"mini-chat/internal/code"
|
||||
"mini-chat/internal/pkg/core"
|
||||
"mini-chat/internal/pkg/httpclient"
|
||||
"mini-chat/internal/pkg/miniprogram"
|
||||
"mini-chat/internal/pkg/validation"
|
||||
"mini-chat/internal/repository/mysql/model"
|
||||
|
||||
@ -125,7 +125,7 @@ func (h *handler) MiniprogramLogin() core.HandlerFunc {
|
||||
} else {
|
||||
sendSubscribeMessageRequest := new(miniprogram.SendSubscribeMessageRequest)
|
||||
sendSubscribeMessageRequest.Touser = openID
|
||||
sendSubscribeMessageRequest.TemplateID = "9dCV3z7vRPBGm8iMtSXsD7ZVyUjld46w7HTH9zLnzWw"
|
||||
sendSubscribeMessageRequest.TemplateID = miniProgram.TemplateID
|
||||
sendSubscribeMessageRequest.Page = "pages/contact/index"
|
||||
sendSubscribeMessageRequest.MiniprogramState = "trial"
|
||||
sendSubscribeMessageRequest.Lang = "zh_CN"
|
||||
|
||||
@ -31,6 +31,7 @@ func newMiniProgram(db *gorm.DB, opts ...gen.DOOption) miniProgram {
|
||||
_miniProgram.AppID = field.NewString(tableName, "app_id")
|
||||
_miniProgram.AppSecret = field.NewString(tableName, "app_secret")
|
||||
_miniProgram.AdminID = field.NewInt32(tableName, "admin_id")
|
||||
_miniProgram.TemplateID = field.NewString(tableName, "template_id")
|
||||
_miniProgram.Name = field.NewString(tableName, "name")
|
||||
_miniProgram.Description = field.NewString(tableName, "description")
|
||||
_miniProgram.Avatar = field.NewString(tableName, "avatar")
|
||||
@ -53,6 +54,7 @@ type miniProgram struct {
|
||||
AppID field.String // 小程序ID
|
||||
AppSecret field.String // 小程序密钥
|
||||
AdminID field.Int32 // 管理员ID
|
||||
TemplateID field.String // 模版ID
|
||||
Name field.String // 名称
|
||||
Description field.String // 描述
|
||||
Avatar field.String // 头像
|
||||
@ -80,6 +82,7 @@ func (m *miniProgram) updateTableName(table string) *miniProgram {
|
||||
m.AppID = field.NewString(table, "app_id")
|
||||
m.AppSecret = field.NewString(table, "app_secret")
|
||||
m.AdminID = field.NewInt32(table, "admin_id")
|
||||
m.TemplateID = field.NewString(table, "template_id")
|
||||
m.Name = field.NewString(table, "name")
|
||||
m.Description = field.NewString(table, "description")
|
||||
m.Avatar = field.NewString(table, "avatar")
|
||||
@ -103,11 +106,12 @@ func (m *miniProgram) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
}
|
||||
|
||||
func (m *miniProgram) fillFieldMap() {
|
||||
m.fieldMap = make(map[string]field.Expr, 11)
|
||||
m.fieldMap = make(map[string]field.Expr, 12)
|
||||
m.fieldMap["id"] = m.ID
|
||||
m.fieldMap["app_id"] = m.AppID
|
||||
m.fieldMap["app_secret"] = m.AppSecret
|
||||
m.fieldMap["admin_id"] = m.AdminID
|
||||
m.fieldMap["template_id"] = m.TemplateID
|
||||
m.fieldMap["name"] = m.Name
|
||||
m.fieldMap["description"] = m.Description
|
||||
m.fieldMap["avatar"] = m.Avatar
|
||||
|
||||
@ -16,6 +16,7 @@ type MiniProgram struct {
|
||||
AppID string `gorm:"column:app_id;not null;comment:小程序ID" json:"app_id"` // 小程序ID
|
||||
AppSecret string `gorm:"column:app_secret;not null;comment:小程序密钥" json:"app_secret"` // 小程序密钥
|
||||
AdminID int32 `gorm:"column:admin_id;not null;comment:管理员ID" json:"admin_id"` // 管理员ID
|
||||
TemplateID string `gorm:"column:template_id;not null;comment:模版ID" json:"template_id"` // 模版ID
|
||||
Name string `gorm:"column:name;not null;comment:名称" json:"name"` // 名称
|
||||
Description string `gorm:"column:description;not null;comment:描述" json:"description"` // 描述
|
||||
Avatar string `gorm:"column:avatar;not null;comment:头像" json:"avatar"` // 头像
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user