添加adminHandler
This commit is contained in:
34
server/internal/admin/admin.go
Normal file
34
server/internal/admin/admin.go
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/config"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/handler"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/svc"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/conf"
|
||||||
|
"github.com/zeromicro/go-zero/rest"
|
||||||
|
)
|
||||||
|
|
||||||
|
var configFile = flag.String("f", "etc/admin-api.yaml", "the config file")
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
var c config.Config
|
||||||
|
conf.MustLoad(*configFile, &c)
|
||||||
|
|
||||||
|
server := rest.MustNewServer(c.RestConf)
|
||||||
|
defer server.Stop()
|
||||||
|
|
||||||
|
ctx := svc.NewServiceContext(c)
|
||||||
|
handler.RegisterHandlers(server, ctx)
|
||||||
|
|
||||||
|
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
|
||||||
|
server.Start()
|
||||||
|
}
|
||||||
3
server/internal/admin/etc/admin-api.yaml
Normal file
3
server/internal/admin/etc/admin-api.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Name: admin-api
|
||||||
|
Host: 0.0.0.0
|
||||||
|
Port: 8888
|
||||||
10
server/internal/admin/internal/config/config.go
Normal file
10
server/internal/admin/internal/config/config.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package config
|
||||||
|
|
||||||
|
import "github.com/zeromicro/go-zero/rest"
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
rest.RestConf
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/logic/admin"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CreateAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.CreateAdminReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := admin.NewCreateAdminLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.CreateAdmin(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/logic/admin"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func DeleteAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.DeleteAdminReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := admin.NewDeleteAdminLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.DeleteAdmin(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/logic/admin"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.GetAdminReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := admin.NewGetAdminLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.GetAdmin(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/logic/admin"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ListAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.ListAdminReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := admin.NewListAdminLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.ListAdmin(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/logic/admin"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func UpdateAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.UpdateAdminReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := admin.NewUpdateAdminLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.UpdateAdmin(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
46
server/internal/admin/internal/handler/routes.go
Normal file
46
server/internal/admin/internal/handler/routes.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
admin "github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/handler/admin"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/svc"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
|
server.AddRoutes(
|
||||||
|
[]rest.Route{
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/admin",
|
||||||
|
Handler: admin.GetAdminHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/admin",
|
||||||
|
Handler: admin.CreateAdminHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPut,
|
||||||
|
Path: "/admin",
|
||||||
|
Handler: admin.UpdateAdminHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodDelete,
|
||||||
|
Path: "/admin",
|
||||||
|
Handler: admin.DeleteAdminHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/admin/list",
|
||||||
|
Handler: admin.ListAdminHandler(serverCtx),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rest.WithPrefix("/api/admin"),
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CreateAdminLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCreateAdminLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAdminLogic {
|
||||||
|
return &CreateAdminLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *CreateAdminLogic) CreateAdmin(req *types.CreateAdminReq) (resp *types.CreateAdminResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DeleteAdminLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDeleteAdminLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAdminLogic {
|
||||||
|
return &DeleteAdminLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *DeleteAdminLogic) DeleteAdmin(req *types.DeleteAdminReq) (resp *types.DeleteAdminResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
33
server/internal/admin/internal/logic/admin/getadminlogic.go
Normal file
33
server/internal/admin/internal/logic/admin/getadminlogic.go
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetAdminLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGetAdminLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAdminLogic {
|
||||||
|
return &GetAdminLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *GetAdminLogic) GetAdmin(req *types.GetAdminReq) (resp *types.GetAdminResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
33
server/internal/admin/internal/logic/admin/listadminlogic.go
Normal file
33
server/internal/admin/internal/logic/admin/listadminlogic.go
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ListAdminLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewListAdminLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListAdminLogic {
|
||||||
|
return &ListAdminLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *ListAdminLogic) ListAdmin(req *types.ListAdminReq) (resp *types.ListAdminResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UpdateAdminLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUpdateAdminLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateAdminLogic {
|
||||||
|
return &UpdateAdminLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *UpdateAdminLogic) UpdateAdmin(req *types.UpdateAdminReq) (resp *types.UpdateAdminResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
18
server/internal/admin/internal/svc/servicecontext.go
Normal file
18
server/internal/admin/internal/svc/servicecontext.go
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package svc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/admin/internal/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ServiceContext struct {
|
||||||
|
Config config.Config
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewServiceContext(c config.Config) *ServiceContext {
|
||||||
|
return &ServiceContext{
|
||||||
|
Config: c,
|
||||||
|
}
|
||||||
|
}
|
||||||
87
server/internal/admin/internal/types/types.go
Normal file
87
server/internal/admin/internal/types/types.go
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// goctl 1.9.1
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
type AdminInfo struct {
|
||||||
|
Id int64 `json:"id"` // 用户ID
|
||||||
|
Username string `json:"username"` // 用户名
|
||||||
|
Password string `json:"password"` // 密码(仅创建/更新时传递)
|
||||||
|
CoverUrl string `json:"cover_url"` // 封面URL
|
||||||
|
Intro string `json:"intro"` // 简介
|
||||||
|
CreateTime string `json:"create_time"` // 创建时间
|
||||||
|
UpdateTime string `json:"update_time"` // 更新时间
|
||||||
|
Role string `json:"role"` // 角色(super_admin/normal_admin)
|
||||||
|
Status int32 `json:"status"` // 1启用,0禁用
|
||||||
|
}
|
||||||
|
|
||||||
|
type BaseResp struct {
|
||||||
|
Code int32 `json:"code"` // 0成功,非0失败
|
||||||
|
Message string `json:"message"` // 提示信息
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateAdminData struct {
|
||||||
|
Id int64 `json:"id"` // 新增的管理员ID
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateAdminReq struct {
|
||||||
|
Username string `json:"username" form:"username"` // 用户名(必填)
|
||||||
|
Password string `json:"password" form:"password"` // 密码(必填,需加密)
|
||||||
|
CoverUrl string `json:"cover_url,optional" form:"cover_url"` // 封面URL(可选)
|
||||||
|
Intro string `json:"intro,optional" form:"intro"` // 简介(可选)
|
||||||
|
Role string `json:"role,optional" form:"role"` // 角色(默认normal_admin)
|
||||||
|
Status int32 `json:"status,optional" form:"status"` // 状态(默认1)
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateAdminResp struct {
|
||||||
|
BaseResp
|
||||||
|
Data CreateAdminData `json:"data,optional"` // 业务数据(可选)
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteAdminReq struct {
|
||||||
|
Id int64 `json:"id" form:"id"` // 用户ID(必填)
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteAdminResp struct {
|
||||||
|
BaseResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetAdminReq struct {
|
||||||
|
Id int64 `json:"id" form:"id"` // 用户ID(必填)
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetAdminResp struct {
|
||||||
|
BaseResp
|
||||||
|
Data AdminInfo `json:"data"` // 管理员详情数据
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListAdminData struct {
|
||||||
|
Total int64 `json:"total"` // 总条数
|
||||||
|
List []AdminInfo `json:"list"` // 管理员列表
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListAdminReq struct {
|
||||||
|
Page int32 `json:"page,optional" form:"page"` // 页码,默认1
|
||||||
|
Size int32 `json:"size,optional" form:"size"` // 每页条数,默认10
|
||||||
|
Role string `json:"role,optional" form:"role"` // 按角色筛选
|
||||||
|
Status int32 `json:"status,optional" form:"status"` // 按状态筛选
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListAdminResp struct {
|
||||||
|
BaseResp
|
||||||
|
Data ListAdminData `json:"data"` // 业务数据
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateAdminReq struct {
|
||||||
|
Id int64 `json:"id" form:"id"` // 用户ID(必填)
|
||||||
|
Username string `json:"username,optional" form:"username"` // 用户名(可选)
|
||||||
|
Password string `json:"password,optional" form:"password"` // 密码(可选)
|
||||||
|
CoverUrl string `json:"cover_url,optional" form:"cover_url"` // 封面URL(可选)
|
||||||
|
Intro string `json:"intro,optional" form:"intro"` // 简介(可选)
|
||||||
|
Role string `json:"role,optional" form:"role"` // 角色(可选)
|
||||||
|
Status int32 `json:"status,optional" form:"status"` // 状态(可选)
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateAdminResp struct {
|
||||||
|
BaseResp
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user