feat(1.0): 新增创建用户
This commit is contained in:
parent
1a857a6794
commit
3522756f6c
85
docs/docs.go
85
docs/docs.go
@ -640,7 +640,7 @@ const docTemplate = `{
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"消息"
|
"管理端.小程序"
|
||||||
],
|
],
|
||||||
"summary": "管理员发送消息",
|
"summary": "管理员发送消息",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
@ -718,7 +718,7 @@ const docTemplate = `{
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"消息"
|
"消息日志"
|
||||||
],
|
],
|
||||||
"summary": "获取消息日志",
|
"summary": "获取消息日志",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
@ -779,7 +779,7 @@ const docTemplate = `{
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"消息"
|
"用户端"
|
||||||
],
|
],
|
||||||
"summary": "用户发送消息",
|
"summary": "用户发送消息",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
@ -808,6 +808,46 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/app/user/create": {
|
||||||
|
"post": {
|
||||||
|
"description": "新增小程序用户",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"用户端"
|
||||||
|
],
|
||||||
|
"summary": "新增小程序用户",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "请求参数",
|
||||||
|
"name": "RequestBody",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/app.createAppUserRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/app.createAppUserResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/code.Failure"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
@ -871,6 +911,45 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"app.createAppUserRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"app_id",
|
||||||
|
"user_id",
|
||||||
|
"user_name"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"app_id": {
|
||||||
|
"description": "小程序ID",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"user_avatar": {
|
||||||
|
"description": "用户头像",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
"description": "用户ID",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"user_mobile": {
|
||||||
|
"description": "用户手机号",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"user_name": {
|
||||||
|
"description": "用户昵称",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"app.createAppUserResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"message": {
|
||||||
|
"description": "提示信息",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"app.deleteAppRequest": {
|
"app.deleteAppRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
@ -632,7 +632,7 @@
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"消息"
|
"管理端.小程序"
|
||||||
],
|
],
|
||||||
"summary": "管理员发送消息",
|
"summary": "管理员发送消息",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
@ -710,7 +710,7 @@
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"消息"
|
"消息日志"
|
||||||
],
|
],
|
||||||
"summary": "获取消息日志",
|
"summary": "获取消息日志",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
@ -771,7 +771,7 @@
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"消息"
|
"用户端"
|
||||||
],
|
],
|
||||||
"summary": "用户发送消息",
|
"summary": "用户发送消息",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
@ -800,6 +800,46 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/app/user/create": {
|
||||||
|
"post": {
|
||||||
|
"description": "新增小程序用户",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"用户端"
|
||||||
|
],
|
||||||
|
"summary": "新增小程序用户",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "请求参数",
|
||||||
|
"name": "RequestBody",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/app.createAppUserRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/app.createAppUserResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/code.Failure"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
@ -863,6 +903,45 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"app.createAppUserRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"app_id",
|
||||||
|
"user_id",
|
||||||
|
"user_name"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"app_id": {
|
||||||
|
"description": "小程序ID",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"user_avatar": {
|
||||||
|
"description": "用户头像",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
"description": "用户ID",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"user_mobile": {
|
||||||
|
"description": "用户手机号",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"user_name": {
|
||||||
|
"description": "用户昵称",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"app.createAppUserResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"message": {
|
||||||
|
"description": "提示信息",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"app.deleteAppRequest": {
|
"app.deleteAppRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
@ -42,6 +42,34 @@ definitions:
|
|||||||
description: 提示信息
|
description: 提示信息
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
app.createAppUserRequest:
|
||||||
|
properties:
|
||||||
|
app_id:
|
||||||
|
description: 小程序ID
|
||||||
|
type: string
|
||||||
|
user_avatar:
|
||||||
|
description: 用户头像
|
||||||
|
type: string
|
||||||
|
user_id:
|
||||||
|
description: 用户ID
|
||||||
|
type: string
|
||||||
|
user_mobile:
|
||||||
|
description: 用户手机号
|
||||||
|
type: string
|
||||||
|
user_name:
|
||||||
|
description: 用户昵称
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- app_id
|
||||||
|
- user_id
|
||||||
|
- user_name
|
||||||
|
type: object
|
||||||
|
app.createAppUserResponse:
|
||||||
|
properties:
|
||||||
|
message:
|
||||||
|
description: 提示信息
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
app.deleteAppRequest:
|
app.deleteAppRequest:
|
||||||
properties:
|
properties:
|
||||||
ids:
|
ids:
|
||||||
@ -832,7 +860,7 @@ paths:
|
|||||||
- LoginVerifyToken: []
|
- LoginVerifyToken: []
|
||||||
summary: 管理员发送消息
|
summary: 管理员发送消息
|
||||||
tags:
|
tags:
|
||||||
- 消息
|
- 管理端.小程序
|
||||||
/admin/upload/image:
|
/admin/upload/image:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
@ -899,7 +927,7 @@ paths:
|
|||||||
$ref: '#/definitions/code.Failure'
|
$ref: '#/definitions/code.Failure'
|
||||||
summary: 获取消息日志
|
summary: 获取消息日志
|
||||||
tags:
|
tags:
|
||||||
- 消息
|
- 消息日志
|
||||||
/app/send_message:
|
/app/send_message:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
@ -925,7 +953,33 @@ paths:
|
|||||||
$ref: '#/definitions/code.Failure'
|
$ref: '#/definitions/code.Failure'
|
||||||
summary: 用户发送消息
|
summary: 用户发送消息
|
||||||
tags:
|
tags:
|
||||||
- 消息
|
- 用户端
|
||||||
|
/app/user/create:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: 新增小程序用户
|
||||||
|
parameters:
|
||||||
|
- description: 请求参数
|
||||||
|
in: body
|
||||||
|
name: RequestBody
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/app.createAppUserRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/app.createAppUserResponse'
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/code.Failure'
|
||||||
|
summary: 新增小程序用户
|
||||||
|
tags:
|
||||||
|
- 用户端
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
LoginVerifyToken:
|
LoginVerifyToken:
|
||||||
in: header
|
in: header
|
||||||
|
|||||||
85
internal/api/app/app_user_create.go
Executable file
85
internal/api/app/app_user_create.go
Executable file
@ -0,0 +1,85 @@
|
|||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"mini-chat/internal/code"
|
||||||
|
"mini-chat/internal/pkg/core"
|
||||||
|
"mini-chat/internal/pkg/validation"
|
||||||
|
"mini-chat/internal/repository/mysql/model"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type createAppUserRequest struct {
|
||||||
|
AppID string `json:"app_id" binding:"required"` // 小程序ID
|
||||||
|
UserID string `json:"user_id" binding:"required"` // 用户ID
|
||||||
|
UserName string `json:"user_name" binding:"required"` // 用户昵称
|
||||||
|
UserMobile string `json:"user_mobile"` // 用户手机号
|
||||||
|
UserAvatar string `json:"user_avatar"` // 用户头像
|
||||||
|
}
|
||||||
|
|
||||||
|
type createAppUserResponse struct {
|
||||||
|
Message string `json:"message"` // 提示信息
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateAppUser 新增小程序用户
|
||||||
|
// @Summary 新增小程序用户
|
||||||
|
// @Description 新增小程序用户
|
||||||
|
// @Tags 用户端
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param RequestBody body createAppUserRequest true "请求参数"
|
||||||
|
// @Success 200 {object} createAppUserResponse
|
||||||
|
// @Failure 400 {object} code.Failure
|
||||||
|
// @Router /app/user/create [post]
|
||||||
|
func (h *handler) CreateAppUser() core.HandlerFunc {
|
||||||
|
return func(ctx core.Context) {
|
||||||
|
req := new(createAppUserRequest)
|
||||||
|
res := new(createAppUserResponse)
|
||||||
|
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||||
|
ctx.AbortWithError(core.Error(
|
||||||
|
http.StatusBadRequest,
|
||||||
|
code.ParamBindError,
|
||||||
|
validation.Error(err)),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
info, err := h.readDB.AppUser.WithContext(ctx.RequestContext()).
|
||||||
|
Where(h.readDB.AppUser.AppID.Eq(req.AppID)).
|
||||||
|
Where(h.readDB.AppUser.UserID.Eq(req.UserID)).
|
||||||
|
First()
|
||||||
|
if err != nil && err != gorm.ErrRecordNotFound {
|
||||||
|
ctx.AbortWithError(core.Error(
|
||||||
|
http.StatusBadRequest,
|
||||||
|
code.CreateAppUserError,
|
||||||
|
fmt.Sprintf("%s: %s", code.Text(code.CreateAppUserError), err.Error())),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if info == nil {
|
||||||
|
AppUser := new(model.AppUser)
|
||||||
|
AppUser.AppID = req.AppID
|
||||||
|
AppUser.UserID = req.UserID
|
||||||
|
AppUser.UserName = req.UserName
|
||||||
|
AppUser.UserMobile = req.UserMobile
|
||||||
|
AppUser.UserAvatar = req.UserAvatar
|
||||||
|
AppUser.CreatedAt = time.Now()
|
||||||
|
if err := h.writeDB.AppUser.WithContext(ctx.RequestContext()).Create(AppUser); err != nil {
|
||||||
|
ctx.AbortWithError(core.Error(
|
||||||
|
http.StatusBadRequest,
|
||||||
|
code.CreateAppUserError,
|
||||||
|
fmt.Sprintf("%s: %s", code.Text(code.CreateAppUserError), err.Error())),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res.Message = "操作成功"
|
||||||
|
ctx.Payload(res)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -38,7 +38,7 @@ type appMessagePageListResponse struct {
|
|||||||
// AppMessagePageList 获取消息日志
|
// AppMessagePageList 获取消息日志
|
||||||
// @Summary 获取消息日志
|
// @Summary 获取消息日志
|
||||||
// @Description 获取消息日志
|
// @Description 获取消息日志
|
||||||
// @Tags 消息
|
// @Tags 消息日志
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param app_id query string true "小程序ID"
|
// @Param app_id query string true "小程序ID"
|
||||||
|
|||||||
@ -25,7 +25,7 @@ type adminSendMessageResponse struct {
|
|||||||
// AdminSendMessage 管理员发送消息
|
// AdminSendMessage 管理员发送消息
|
||||||
// @Summary 管理员发送消息
|
// @Summary 管理员发送消息
|
||||||
// @Description 管理员发送消息
|
// @Description 管理员发送消息
|
||||||
// @Tags 消息
|
// @Tags 管理端.小程序
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param RequestBody body adminSendMessageRequest true "请求参数"
|
// @Param RequestBody body adminSendMessageRequest true "请求参数"
|
||||||
|
|||||||
@ -3,8 +3,6 @@ package message
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gorm.io/gorm"
|
|
||||||
"mini-chat/internal/services"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -12,6 +10,9 @@ import (
|
|||||||
"mini-chat/internal/pkg/core"
|
"mini-chat/internal/pkg/core"
|
||||||
"mini-chat/internal/pkg/validation"
|
"mini-chat/internal/pkg/validation"
|
||||||
"mini-chat/internal/repository/mysql/model"
|
"mini-chat/internal/repository/mysql/model"
|
||||||
|
"mini-chat/internal/services"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type userSendMessageRequest struct {
|
type userSendMessageRequest struct {
|
||||||
@ -29,7 +30,7 @@ type userSendMessageResponse struct {
|
|||||||
// UserSendMessage 用户发送消息
|
// UserSendMessage 用户发送消息
|
||||||
// @Summary 用户发送消息
|
// @Summary 用户发送消息
|
||||||
// @Description 用户发送消息
|
// @Description 用户发送消息
|
||||||
// @Tags 消息
|
// @Tags 用户端
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param RequestBody body userSendMessageRequest true "请求参数"
|
// @Param RequestBody body userSendMessageRequest true "请求参数"
|
||||||
|
|||||||
@ -21,11 +21,12 @@ const (
|
|||||||
JWTAuthVerifyError = 10103
|
JWTAuthVerifyError = 10103
|
||||||
UploadError = 10104
|
UploadError = 10104
|
||||||
|
|
||||||
AdminLoginError = 20101
|
AdminLoginError = 20101
|
||||||
CreateAppError = 20201
|
CreateAppError = 20201
|
||||||
DeleteAppError = 20202
|
DeleteAppError = 20202
|
||||||
ListAppError = 20203
|
ListAppError = 20203
|
||||||
ModifyAppError = 20204
|
ModifyAppError = 20204
|
||||||
|
CreateAppUserError = 20205
|
||||||
|
|
||||||
CreateKeywordError = 20301
|
CreateKeywordError = 20301
|
||||||
ListKeywordError = 20302
|
ListKeywordError = 20302
|
||||||
|
|||||||
@ -8,10 +8,11 @@ var zhCNText = map[int]string{
|
|||||||
|
|
||||||
AdminLoginError: "登录失败",
|
AdminLoginError: "登录失败",
|
||||||
|
|
||||||
CreateAppError: "关联小程序失败",
|
CreateAppError: "关联小程序失败",
|
||||||
DeleteAppError: "删除小程序失败",
|
DeleteAppError: "删除小程序失败",
|
||||||
ListAppError: "获取小程序列表失败",
|
ListAppError: "获取小程序列表失败",
|
||||||
ModifyAppError: "修改小程序失败",
|
ModifyAppError: "修改小程序失败",
|
||||||
|
CreateAppUserError: "创建用户失败",
|
||||||
|
|
||||||
CreateKeywordError: "创建关键字失败",
|
CreateKeywordError: "创建关键字失败",
|
||||||
DeleteKeywordError: "删除关键字失败",
|
DeleteKeywordError: "删除关键字失败",
|
||||||
|
|||||||
@ -31,7 +31,9 @@ func newAppUser(db *gorm.DB, opts ...gen.DOOption) appUser {
|
|||||||
_appUser.AppID = field.NewString(tableName, "app_id")
|
_appUser.AppID = field.NewString(tableName, "app_id")
|
||||||
_appUser.UserID = field.NewString(tableName, "user_id")
|
_appUser.UserID = field.NewString(tableName, "user_id")
|
||||||
_appUser.UserName = field.NewString(tableName, "user_name")
|
_appUser.UserName = field.NewString(tableName, "user_name")
|
||||||
|
_appUser.UserMobile = field.NewString(tableName, "user_mobile")
|
||||||
_appUser.UserAvatar = field.NewString(tableName, "user_avatar")
|
_appUser.UserAvatar = field.NewString(tableName, "user_avatar")
|
||||||
|
_appUser.CreatedAt = field.NewTime(tableName, "created_at")
|
||||||
|
|
||||||
_appUser.fillFieldMap()
|
_appUser.fillFieldMap()
|
||||||
|
|
||||||
@ -47,7 +49,9 @@ type appUser struct {
|
|||||||
AppID field.String // 小程序ID
|
AppID field.String // 小程序ID
|
||||||
UserID field.String // 用户ID
|
UserID field.String // 用户ID
|
||||||
UserName field.String // 用户昵称
|
UserName field.String // 用户昵称
|
||||||
|
UserMobile field.String // 用户手机号
|
||||||
UserAvatar field.String // 用户头像
|
UserAvatar field.String // 用户头像
|
||||||
|
CreatedAt field.Time // 创建时间
|
||||||
|
|
||||||
fieldMap map[string]field.Expr
|
fieldMap map[string]field.Expr
|
||||||
}
|
}
|
||||||
@ -68,7 +72,9 @@ func (a *appUser) updateTableName(table string) *appUser {
|
|||||||
a.AppID = field.NewString(table, "app_id")
|
a.AppID = field.NewString(table, "app_id")
|
||||||
a.UserID = field.NewString(table, "user_id")
|
a.UserID = field.NewString(table, "user_id")
|
||||||
a.UserName = field.NewString(table, "user_name")
|
a.UserName = field.NewString(table, "user_name")
|
||||||
|
a.UserMobile = field.NewString(table, "user_mobile")
|
||||||
a.UserAvatar = field.NewString(table, "user_avatar")
|
a.UserAvatar = field.NewString(table, "user_avatar")
|
||||||
|
a.CreatedAt = field.NewTime(table, "created_at")
|
||||||
|
|
||||||
a.fillFieldMap()
|
a.fillFieldMap()
|
||||||
|
|
||||||
@ -85,12 +91,14 @@ func (a *appUser) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *appUser) fillFieldMap() {
|
func (a *appUser) fillFieldMap() {
|
||||||
a.fieldMap = make(map[string]field.Expr, 5)
|
a.fieldMap = make(map[string]field.Expr, 7)
|
||||||
a.fieldMap["id"] = a.ID
|
a.fieldMap["id"] = a.ID
|
||||||
a.fieldMap["app_id"] = a.AppID
|
a.fieldMap["app_id"] = a.AppID
|
||||||
a.fieldMap["user_id"] = a.UserID
|
a.fieldMap["user_id"] = a.UserID
|
||||||
a.fieldMap["user_name"] = a.UserName
|
a.fieldMap["user_name"] = a.UserName
|
||||||
|
a.fieldMap["user_mobile"] = a.UserMobile
|
||||||
a.fieldMap["user_avatar"] = a.UserAvatar
|
a.fieldMap["user_avatar"] = a.UserAvatar
|
||||||
|
a.fieldMap["created_at"] = a.CreatedAt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a appUser) clone(db *gorm.DB) appUser {
|
func (a appUser) clone(db *gorm.DB) appUser {
|
||||||
|
|||||||
@ -4,15 +4,21 @@
|
|||||||
|
|
||||||
package model
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
const TableNameAppUser = "app_user"
|
const TableNameAppUser = "app_user"
|
||||||
|
|
||||||
// AppUser 小程序的用户表
|
// AppUser 小程序的用户表
|
||||||
type AppUser struct {
|
type AppUser struct {
|
||||||
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:主键ID" json:"id"` // 主键ID
|
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:主键ID" json:"id"` // 主键ID
|
||||||
AppID string `gorm:"column:app_id;not null;comment:小程序ID" json:"app_id"` // 小程序ID
|
AppID string `gorm:"column:app_id;not null;comment:小程序ID" json:"app_id"` // 小程序ID
|
||||||
UserID string `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID
|
UserID string `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID
|
||||||
UserName string `gorm:"column:user_name;not null;comment:用户昵称" json:"user_name"` // 用户昵称
|
UserName string `gorm:"column:user_name;not null;comment:用户昵称" json:"user_name"` // 用户昵称
|
||||||
UserAvatar string `gorm:"column:user_avatar;not null;comment:用户头像" json:"user_avatar"` // 用户头像
|
UserMobile string `gorm:"column:user_mobile;not null;comment:用户手机号" json:"user_mobile"` // 用户手机号
|
||||||
|
UserAvatar string `gorm:"column:user_avatar;not null;comment:用户头像" json:"user_avatar"` // 用户头像
|
||||||
|
CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName AppUser's table name
|
// TableName AppUser's table name
|
||||||
|
|||||||
@ -61,6 +61,7 @@ func NewHTTPMux(logger logger.CustomLogger, db mysql.Repo, cron cron.Server) (co
|
|||||||
|
|
||||||
appNonAuthApiRouter := mux.Group("/app")
|
appNonAuthApiRouter := mux.Group("/app")
|
||||||
{
|
{
|
||||||
|
appNonAuthApiRouter.POST("/user/create", appHandler.CreateAppUser()) // 新增小程序用户
|
||||||
appNonAuthApiRouter.GET("/messages", messageHandler.AppMessagePageList()) // 消息列表
|
appNonAuthApiRouter.GET("/messages", messageHandler.AppMessagePageList()) // 消息列表
|
||||||
appNonAuthApiRouter.POST("/send_message", messageHandler.UserSendMessage()) // 发送消息
|
appNonAuthApiRouter.POST("/send_message", messageHandler.UserSendMessage()) // 发送消息
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user