feat(小程序): 添加小程序密钥支持并修复更新时间显示问题
添加 AppSecret 字段支持小程序认证 修复列表页中更新时间显示错误的问题 新增微信小程序二维码生成接口
This commit is contained in:
parent
23e7d42531
commit
f1a364bae2
97
docs/docs.go
97
docs/docs.go
@ -1109,6 +1109,52 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/api/wechat/qrcode": {
|
||||||
|
"post": {
|
||||||
|
"description": "根据 AppID、AppSecret 和页面路径生成微信小程序二维码",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"微信"
|
||||||
|
],
|
||||||
|
"summary": "生成微信小程序二维码",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "请求参数",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/wechat.generateQRCodeRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/wechat.generateQRCodeResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/code.Failure"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/code.Failure"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/app/messages": {
|
"/app/messages": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "获取消息日志",
|
"description": "获取消息日志",
|
||||||
@ -1521,6 +1567,7 @@ const docTemplate = `{
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"app_id",
|
"app_id",
|
||||||
|
"app_secret",
|
||||||
"name"
|
"name"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -1528,6 +1575,10 @@ const docTemplate = `{
|
|||||||
"description": "小程序ID",
|
"description": "小程序ID",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"app_secret": {
|
||||||
|
"description": "小程序密钥",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"avatar": {
|
"avatar": {
|
||||||
"description": "头像",
|
"description": "头像",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -1618,6 +1669,10 @@ const docTemplate = `{
|
|||||||
"description": "小程序ID",
|
"description": "小程序ID",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"app_secret": {
|
||||||
|
"description": "小程序密钥",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"avatar": {
|
"avatar": {
|
||||||
"description": "小程序头像",
|
"description": "小程序头像",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -1700,6 +1755,7 @@ const docTemplate = `{
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"app_id",
|
"app_id",
|
||||||
|
"app_secret",
|
||||||
"name"
|
"name"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -1707,6 +1763,10 @@ const docTemplate = `{
|
|||||||
"description": "小程序ID",
|
"description": "小程序ID",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"app_secret": {
|
||||||
|
"description": "小程序密钥",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"avatar": {
|
"avatar": {
|
||||||
"description": "头像",
|
"description": "头像",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -2149,6 +2209,43 @@ const docTemplate = `{
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"wechat.generateQRCodeRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"app_id",
|
||||||
|
"app_secret",
|
||||||
|
"path"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"app_id": {
|
||||||
|
"description": "微信小程序 AppID",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"app_secret": {
|
||||||
|
"description": "微信小程序 AppSecret",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"description": "小程序页面路径",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"wechat.generateQRCodeResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"description": "Base64 编码的图片数据",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"message": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"success": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"securityDefinitions": {
|
"securityDefinitions": {
|
||||||
|
|||||||
@ -1101,6 +1101,52 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/api/wechat/qrcode": {
|
||||||
|
"post": {
|
||||||
|
"description": "根据 AppID、AppSecret 和页面路径生成微信小程序二维码",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"微信"
|
||||||
|
],
|
||||||
|
"summary": "生成微信小程序二维码",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "请求参数",
|
||||||
|
"name": "request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/wechat.generateQRCodeRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/wechat.generateQRCodeResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/code.Failure"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/code.Failure"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/app/messages": {
|
"/app/messages": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "获取消息日志",
|
"description": "获取消息日志",
|
||||||
@ -1513,6 +1559,7 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"app_id",
|
"app_id",
|
||||||
|
"app_secret",
|
||||||
"name"
|
"name"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -1520,6 +1567,10 @@
|
|||||||
"description": "小程序ID",
|
"description": "小程序ID",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"app_secret": {
|
||||||
|
"description": "小程序密钥",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"avatar": {
|
"avatar": {
|
||||||
"description": "头像",
|
"description": "头像",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -1610,6 +1661,10 @@
|
|||||||
"description": "小程序ID",
|
"description": "小程序ID",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"app_secret": {
|
||||||
|
"description": "小程序密钥",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"avatar": {
|
"avatar": {
|
||||||
"description": "小程序头像",
|
"description": "小程序头像",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -1692,6 +1747,7 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"app_id",
|
"app_id",
|
||||||
|
"app_secret",
|
||||||
"name"
|
"name"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -1699,6 +1755,10 @@
|
|||||||
"description": "小程序ID",
|
"description": "小程序ID",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"app_secret": {
|
||||||
|
"description": "小程序密钥",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"avatar": {
|
"avatar": {
|
||||||
"description": "头像",
|
"description": "头像",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@ -2141,6 +2201,43 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"wechat.generateQRCodeRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"app_id",
|
||||||
|
"app_secret",
|
||||||
|
"path"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"app_id": {
|
||||||
|
"description": "微信小程序 AppID",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"app_secret": {
|
||||||
|
"description": "微信小程序 AppSecret",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"description": "小程序页面路径",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"wechat.generateQRCodeResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"description": "Base64 编码的图片数据",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"message": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"success": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"securityDefinitions": {
|
"securityDefinitions": {
|
||||||
|
|||||||
@ -192,6 +192,9 @@ definitions:
|
|||||||
app_id:
|
app_id:
|
||||||
description: 小程序ID
|
description: 小程序ID
|
||||||
type: string
|
type: string
|
||||||
|
app_secret:
|
||||||
|
description: 小程序密钥
|
||||||
|
type: string
|
||||||
avatar:
|
avatar:
|
||||||
description: 头像
|
description: 头像
|
||||||
type: string
|
type: string
|
||||||
@ -203,6 +206,7 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
- app_id
|
- app_id
|
||||||
|
- app_secret
|
||||||
- name
|
- name
|
||||||
type: object
|
type: object
|
||||||
app.createAppResponse:
|
app.createAppResponse:
|
||||||
@ -258,6 +262,9 @@ definitions:
|
|||||||
app_id:
|
app_id:
|
||||||
description: 小程序ID
|
description: 小程序ID
|
||||||
type: string
|
type: string
|
||||||
|
app_secret:
|
||||||
|
description: 小程序密钥
|
||||||
|
type: string
|
||||||
avatar:
|
avatar:
|
||||||
description: 小程序头像
|
description: 小程序头像
|
||||||
type: string
|
type: string
|
||||||
@ -319,6 +326,9 @@ definitions:
|
|||||||
app_id:
|
app_id:
|
||||||
description: 小程序ID
|
description: 小程序ID
|
||||||
type: string
|
type: string
|
||||||
|
app_secret:
|
||||||
|
description: 小程序密钥
|
||||||
|
type: string
|
||||||
avatar:
|
avatar:
|
||||||
description: 头像
|
description: 头像
|
||||||
type: string
|
type: string
|
||||||
@ -330,6 +340,7 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
- app_id
|
- app_id
|
||||||
|
- app_secret
|
||||||
- name
|
- name
|
||||||
type: object
|
type: object
|
||||||
app.modifyAppResponse:
|
app.modifyAppResponse:
|
||||||
@ -635,6 +646,32 @@ definitions:
|
|||||||
description: 真实图片地址
|
description: 真实图片地址
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
wechat.generateQRCodeRequest:
|
||||||
|
properties:
|
||||||
|
app_id:
|
||||||
|
description: 微信小程序 AppID
|
||||||
|
type: string
|
||||||
|
app_secret:
|
||||||
|
description: 微信小程序 AppSecret
|
||||||
|
type: string
|
||||||
|
path:
|
||||||
|
description: 小程序页面路径
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- app_id
|
||||||
|
- app_secret
|
||||||
|
- path
|
||||||
|
type: object
|
||||||
|
wechat.generateQRCodeResponse:
|
||||||
|
properties:
|
||||||
|
data:
|
||||||
|
description: Base64 编码的图片数据
|
||||||
|
type: string
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
success:
|
||||||
|
type: boolean
|
||||||
|
type: object
|
||||||
info:
|
info:
|
||||||
contact: {}
|
contact: {}
|
||||||
title: mini-chat 接口文档
|
title: mini-chat 接口文档
|
||||||
@ -1343,6 +1380,36 @@ paths:
|
|||||||
summary: 上传图片
|
summary: 上传图片
|
||||||
tags:
|
tags:
|
||||||
- 通用
|
- 通用
|
||||||
|
/api/wechat/qrcode:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: 根据 AppID、AppSecret 和页面路径生成微信小程序二维码
|
||||||
|
parameters:
|
||||||
|
- description: 请求参数
|
||||||
|
in: body
|
||||||
|
name: request
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/wechat.generateQRCodeRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/wechat.generateQRCodeResponse'
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/code.Failure'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/code.Failure'
|
||||||
|
summary: 生成微信小程序二维码
|
||||||
|
tags:
|
||||||
|
- 微信
|
||||||
/app/messages:
|
/app/messages:
|
||||||
get:
|
get:
|
||||||
consumes:
|
consumes:
|
||||||
|
|||||||
@ -137,11 +137,12 @@ func (h *handler) PageList() core.HandlerFunc {
|
|||||||
res.List[k] = listData{
|
res.List[k] = listData{
|
||||||
ID: v.ID,
|
ID: v.ID,
|
||||||
AppID: v.AppID,
|
AppID: v.AppID,
|
||||||
|
AppSecret: v.AppSecret,
|
||||||
Name: v.Name,
|
Name: v.Name,
|
||||||
Description: v.Description,
|
Description: v.Description,
|
||||||
Avatar: v.Avatar,
|
Avatar: v.Avatar,
|
||||||
CreatedAt: timeutil.FriendlyTime(v.CreatedAt),
|
CreatedAt: timeutil.FriendlyTime(v.CreatedAt),
|
||||||
UpdatedAt: timeutil.FriendlyTime(v.CreatedAt),
|
UpdatedAt: timeutil.FriendlyTime(v.UpdatedAt),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,10 +14,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type modifyAppRequest struct {
|
type modifyAppRequest struct {
|
||||||
AppID string `json:"app_id" binding:"required"` // 小程序ID
|
AppID string `json:"app_id" binding:"required"` // 小程序ID
|
||||||
Name string `json:"name" binding:"required"` // 名称
|
AppSecret string `json:"app_secret" binding:"required"` // 小程序密钥
|
||||||
Description string `json:"description"` // 描述
|
Name string `json:"name" binding:"required"` // 名称
|
||||||
Avatar string `json:"avatar"` // 头像
|
Description string `json:"description"` // 描述
|
||||||
|
Avatar string `json:"avatar"` // 头像
|
||||||
}
|
}
|
||||||
|
|
||||||
type modifyAppResponse struct {
|
type modifyAppResponse struct {
|
||||||
@ -121,6 +122,7 @@ func (h *handler) ModifyApp() core.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkIdInfo.AppID = req.AppID
|
checkIdInfo.AppID = req.AppID
|
||||||
|
checkIdInfo.AppSecret = req.AppSecret
|
||||||
checkIdInfo.Name = req.Name
|
checkIdInfo.Name = req.Name
|
||||||
checkIdInfo.Description = req.Description
|
checkIdInfo.Description = req.Description
|
||||||
checkIdInfo.Avatar = req.Avatar
|
checkIdInfo.Avatar = req.Avatar
|
||||||
|
|||||||
@ -29,6 +29,7 @@ func newMiniProgram(db *gorm.DB, opts ...gen.DOOption) miniProgram {
|
|||||||
_miniProgram.ALL = field.NewAsterisk(tableName)
|
_miniProgram.ALL = field.NewAsterisk(tableName)
|
||||||
_miniProgram.ID = field.NewInt32(tableName, "id")
|
_miniProgram.ID = field.NewInt32(tableName, "id")
|
||||||
_miniProgram.AppID = field.NewString(tableName, "app_id")
|
_miniProgram.AppID = field.NewString(tableName, "app_id")
|
||||||
|
_miniProgram.AppSecret = field.NewString(tableName, "app_secret")
|
||||||
_miniProgram.AdminID = field.NewInt32(tableName, "admin_id")
|
_miniProgram.AdminID = field.NewInt32(tableName, "admin_id")
|
||||||
_miniProgram.Name = field.NewString(tableName, "name")
|
_miniProgram.Name = field.NewString(tableName, "name")
|
||||||
_miniProgram.Description = field.NewString(tableName, "description")
|
_miniProgram.Description = field.NewString(tableName, "description")
|
||||||
@ -50,6 +51,7 @@ type miniProgram struct {
|
|||||||
ALL field.Asterisk
|
ALL field.Asterisk
|
||||||
ID field.Int32 // 主键ID
|
ID field.Int32 // 主键ID
|
||||||
AppID field.String // 小程序ID
|
AppID field.String // 小程序ID
|
||||||
|
AppSecret field.String // 小程序密钥
|
||||||
AdminID field.Int32 // 管理员ID
|
AdminID field.Int32 // 管理员ID
|
||||||
Name field.String // 名称
|
Name field.String // 名称
|
||||||
Description field.String // 描述
|
Description field.String // 描述
|
||||||
@ -76,6 +78,7 @@ func (m *miniProgram) updateTableName(table string) *miniProgram {
|
|||||||
m.ALL = field.NewAsterisk(table)
|
m.ALL = field.NewAsterisk(table)
|
||||||
m.ID = field.NewInt32(table, "id")
|
m.ID = field.NewInt32(table, "id")
|
||||||
m.AppID = field.NewString(table, "app_id")
|
m.AppID = field.NewString(table, "app_id")
|
||||||
|
m.AppSecret = field.NewString(table, "app_secret")
|
||||||
m.AdminID = field.NewInt32(table, "admin_id")
|
m.AdminID = field.NewInt32(table, "admin_id")
|
||||||
m.Name = field.NewString(table, "name")
|
m.Name = field.NewString(table, "name")
|
||||||
m.Description = field.NewString(table, "description")
|
m.Description = field.NewString(table, "description")
|
||||||
@ -100,9 +103,10 @@ func (m *miniProgram) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *miniProgram) fillFieldMap() {
|
func (m *miniProgram) fillFieldMap() {
|
||||||
m.fieldMap = make(map[string]field.Expr, 10)
|
m.fieldMap = make(map[string]field.Expr, 11)
|
||||||
m.fieldMap["id"] = m.ID
|
m.fieldMap["id"] = m.ID
|
||||||
m.fieldMap["app_id"] = m.AppID
|
m.fieldMap["app_id"] = m.AppID
|
||||||
|
m.fieldMap["app_secret"] = m.AppSecret
|
||||||
m.fieldMap["admin_id"] = m.AdminID
|
m.fieldMap["admin_id"] = m.AdminID
|
||||||
m.fieldMap["name"] = m.Name
|
m.fieldMap["name"] = m.Name
|
||||||
m.fieldMap["description"] = m.Description
|
m.fieldMap["description"] = m.Description
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user