实现角色接口增删改查

This commit is contained in:
2025-06-03 16:04:00 +08:00
parent bcd274c750
commit fedcd288e8
35 changed files with 596 additions and 57 deletions

View File

@ -3,7 +3,7 @@ package v1
import "github.com/gogf/gf/v2/frame/g"
type AdminInfoReq struct {
g.Meta `path:"/admin/info" method:"get" tags:"Admin" summary:"获取管理员信息"`
g.Meta `path:"/admin/info" method:"get" tags:"Admin" summary:"(系统管理员)获取管理员信息"`
}
type AdminInfoRes struct {
g.Meta `mime:"application/json"`

View File

@ -3,7 +3,7 @@ package v1
import "github.com/gogf/gf/v2/frame/g"
type AdminLoginReq struct {
g.Meta `path:"/admin/login" method:"post" tags:"Admin" summary:"管理员登录"`
g.Meta `path:"/admin/login" method:"post" tags:"Admin" summary:"(系统管理员)管理员登录"`
Username string `json:"username" v:"required" dc:"用户名"`
Password string `json:"password" v:"required" dc:"密码"`
}
@ -13,7 +13,7 @@ type AdminLoginRes struct {
}
type MerchantLoginReq struct {
g.Meta `path:"/merchant/login" method:"post" tags:"Merchant" summary:"商户登录"`
g.Meta `path:"/merchant/login" method:"post" tags:"Merchant" summary:"(商户管理员)商户登录"`
Usernaem string `json:"username" v:"required" dc:"用户名"`
Password string `json:"password" v:"required" dc:"密码"`
}
@ -27,7 +27,7 @@ type MerchantRegisterRes struct {
}
type StoreLoginReq struct {
g.Meta `path:"/store/login" method:"post" tags:"Store" summary:"门店登录"`
g.Meta `path:"/store/login" method:"post" tags:"Store" summary:"(门店管理员)门店登录"`
Username string `json:"username" v:"required" dc:"用户名"`
Password string `json:"password" v:"required" dc:"密码"`
}

19
api/role/role.go Normal file
View File

@ -0,0 +1,19 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package role
import (
"context"
"server/api/role/v1"
)
type IRoleV1 interface {
List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error)
Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error)
Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error)
Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error)
BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (res *v1.BatchDeleteRes, err error)
}

67
api/role/v1/role.go Normal file
View File

@ -0,0 +1,67 @@
package v1
import (
"github.com/gogf/gf/v2/frame/g"
)
// ListReq 获取角色列表请求参数
type ListReq struct {
g.Meta `path:"/role" method:"get" tags:"Role" summary:"(系统管理员)获取角色列表"`
Page int `json:"page" dc:"页数"`
Size int `json:"size" dc:"每页数量"`
Status int `json:"status" dc:"状态1=启用2=禁用"`
}
// ListRes 获取角色列表响应参数
type ListRes struct {
List interface{} `json:"list" dc:"角色列表"`
Total int `json:"total" dc:"总数"`
}
// CreateReq 创建角色请求参数
type CreateReq struct {
g.Meta `path:"/role" method:"post" tags:"Role" summary:"(系统管理员)创建角色"`
Name string `json:"name" v:"required" dc:"角色名称"`
Code string `json:"code" v:"required" dc:"角色编码"`
Description string `json:"description" dc:"角色描述"`
Status int `json:"status" v:"required|in:1,2" dc:"状态1=启用2=禁用"`
}
// CreateRes 创建角色响应参数
type CreateRes struct {
Id int64 `json:"id" dc:"角色ID"`
}
// UpdateReq 更新角色请求参数
type UpdateReq struct {
g.Meta `path:"/role" method:"put" tags:"Role" summary:"(系统管理员)更新角色"`
Id int64 `json:"id" v:"required" dc:"角色ID"`
Name string `json:"name" v:"required" dc:"角色名称"`
Code string `json:"code" v:"required" dc:"角色编码"`
Description string `json:"description" dc:"角色描述"`
Status int `json:"status" v:"required|in:1,2" dc:"状态1=启用2=禁用"`
}
// UpdateRes 更新角色响应参数
type UpdateRes struct {
Success bool `json:"success" dc:"是否成功"`
}
// DeleteReq 删除角色请求参数
type DeleteReq struct {
g.Meta `path:"/role/{id}" method:"delete" tags:"Role" summary:"(系统管理员)删除角色"`
Id int64 `json:"id" in:"path" v:"required" dc:"角色ID"`
}
// DeleteRes 删除角色响应参数
type DeleteRes struct {
Success bool `json:"success" dc:"是否成功"`
}
type BatchDeleteReq struct {
g.Meta `path:"/role" method:"delete" tags:"Role" summary:"(系统管理员)批量删除角色"`
Ids []int `json:"ids" v:"required" dc:"角色ID"`
}
type BatchDeleteRes struct {
Success bool `json:"success" dc:"是否成功"`
}

View File

@ -3,7 +3,7 @@ package v1
import "github.com/gogf/gf/v2/frame/g"
type WeChatLoginReq struct {
g.Meta `path:"/wechat/login" method:"post" tags:"WeChat" summary:"获取微信二维码登录"`
g.Meta `path:"/wechat/login" method:"post" tags:"WeChat" summary:"(用户)获取微信二维码登录"`
SceneId string `json:"sceneId" v:"required" dc:"场景ID,规则:[门店id]_[6位随机字符串]"`
}
type WeChatLoginRes struct {
@ -35,7 +35,7 @@ type WeChatVertifyRes struct {
}
type WeChatPollingReq struct {
g.Meta `path:"/wechat/polling" method:"post" tags:"WeChat" summary:"微信长轮询"`
g.Meta `path:"/wechat/polling" method:"post" tags:"WeChat" summary:"(用户)微信长轮询"`
SceneId string `json:"sceneId" v:"required" dc:"场景ID"`
}
type WeChatPollingRes struct {