redis token

This commit is contained in:
zp
2024-01-15 17:30:07 +08:00
parent 00122cc66d
commit cb8ca55aba
28 changed files with 931 additions and 31 deletions

View File

@ -2,25 +2,39 @@ package backend
import (
"github.com/gogf/gf/v2/frame/g"
"novel/internal/model/entity"
)
// verify code
type GetCodeReq struct {
g.Meta `path:"/get-code" method:"post" tags:"获取验证码" summary:"获取验证码"`
g.Meta `path:"/get-phone-code" method:"post" tags:"获取验证码" summary:"获取验证码"`
Phone string `json:"phone" v:"required|phone" description:"手机号"`
CodeType int `json:"codeType" v:"required|in:1,2#类型不合法" description:"验证码类型"`
}
type GetCodeRes struct {
Code int
}
// createOrLogin
type CreateOrLoginReq struct {
g.Meta `path:"/create-or-login" method:"post" tags:"注册或登录" summary:"注册或者登录"`
Phone string `json:"phone" v:"required|phone" description:"手机号"`
Code int `json:"code" v:"required|size:6" description:"验证码"`
// g.Meta `path:"/create-or-login" method:"post" tags:"注册或登录" summary:"注册或者登录"`
Phone string `json:"phone" v:"required|phone" description:"手机号"`
Code int `json:"code" v:"required|size:6" description:"验证码"`
}
type CreateOrLoginRes struct {
Id uint
type CreateLoginRes struct {
Id uint
PenName string
}
// for gtoken
type CreateOrLoginRes struct {
Type string `json:"type"`
Token string `json:"token"`
ExpireIn int `json:"expire_in"`
IsAdmin uint `json:"is_admin"` // 是否超管
RoleIds string `json:"role_ids"` // 角色
Permissions []entity.PermissionInfo `json:"permissions"` // 权限列表
}

64
api/backend/writer.go Normal file
View File

@ -0,0 +1,64 @@
package backend
import (
"github.com/gogf/gf/v2/frame/g"
)
// type WriterReq struct {
// g.Meta `path:"/writer/add" tags:"writer" method:"post" summary:"writer add api"`
// Name string `json:"name" v:"required#用户名不能为空" dc:"用户名"`
// Password string `json:"password" v:"required#密码不能为空" dc:"密码"`
// RoleIds string `json:"role_ids" dc:"角色ids"`
// IsAdmin int `json:"is_admin" dc:"是否超级管理员"`
// }
//
// type WriterRes struct {
// AdminId int `json:"admin_id"`
// }
//
// type AdminDeleteReq struct {
// g.Meta `path:"/admin/delete" method:"delete" tags:"管理员" summary:"删除管理员接口"`
// Id uint `v:"min:1#请选择需要删除的管理员" dc:"管理员id"`
// }
// type AdminDeleteRes struct{}
//
// type AdminUpdateReq struct {
// g.Meta `path:"/admin/update/{Id}" method:"post" tags:"管理员" summary:"修改管理员接口"`
// Id uint `json:"id" v:"min:1#请选择需要修改的管理员" dc:"管理员Id"`
// Name string `json:"name" v:"required#用户名不能为空" dc:"用户名"`
// Password string `json:"password" v:"required#密码不能为空" dc:"密码"`
// RoleIds string `json:"role_ids" dc:"角色ids"`
// IsAdmin int `json:"is_admin" dc:"是否超级管理员"`
// }
// type AdminUpdateRes struct {
// Id uint `json:"id"`
// }
// type AdminGetListCommonReq struct {
// g.Meta `path:"/admin/list" method:"get" tags:"管理员" summary:"管理员列表接口"`
// // CommonPaginationReq
// }
// type AdminGetListCommonRes struct {
// List interface{} `json:"list" description:"列表"`
// Page int `json:"page" description:"分页码"`
// Size int `json:"size" description:"分页数量"`
// Total int `json:"total" description:"数据总数"`
// }
type WriterGetInfoReq struct {
g.Meta `path:"/writer/info" method:"get"`
}
// for jwt
// type AdminGetInfoRes struct {
// Id int `json:"id"`
// IdentityKey string `json:"identity_key"`
// Payload string `json:"payload"`
// }
// for gtoken
type WriterGetInfoRes struct {
Id int `json:"id"`
PenName string `json:"pen_name"`
RoleIds string `json:"role_ids"`
IsAdmin int `json:"is_admin"`
}