实现角色接口增删改查

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

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:"是否成功"`
}