Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #1

Merged
merged 4 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 68 additions & 5 deletions api/api_desc/apis.api
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,70 @@ info(
import "base.api"

type (
// The response data of API information | API信息
// swagger:response ApiInfo
ApiInfo {
// ID
Id uint64 `json:"id"`
CreateAt int64 `json:"createAt"`
// API path | API路径
Path string `json:"path"`
// API Description | API 描述
Description string `json:"description"`
// API group | API分组
Group string `json:"group"`
// API request method e.g. POST | API请求类型 如POST
Method string `json:"method"`
}

// swagger:parameters createOrUpdateApi
// Create or update API information request | 创建或更新API信息
CreateOrUpdateApiReq {
// ID
// Required: true
Id uint64 `json:"id"`
// Create date | 创建日期
// Required: true
CreateAt int64 `json:"createAt"`
// API path | API路径
// Required: true
Path string `json:"path"`
// API Description | API 描述
// Required: true
Description string `json:"description"`
// API group | API分组
// Require: true
Group string `json:"group"`
// API request method e.g. POST | API请求类型 如POST
// Required: true
Method string `json:"method"`
}

// The response data of API list | API列表数据
// swagger:response ApiListResp
ApiListResp {
PageList
// The total number of data | 数据总数
Total uint64 `json:"total"`
// The api list data | 角色列表数据
// in: body
Data []ApiInfo `json:"data"`
}

// swagger:parameters getApiList
// Get API list request params | API列表请求参数
ApiListReq {
PageInfo
// API path | API路径
// Required: true
Path string `json:"path"`
// API Description | API 描述
// Required: true
Description string `json:"description"`
// API group | API分组
// Required: true
Group string `json:"group"`
// API request method e.g. POST | API请求类型 如POST
// Required: true
Method string `json:"method"`
}
)
Expand All @@ -41,12 +86,30 @@ type (
)

service core {
@handler createOrUpdateApiHandler
post /api (ApiInfo) returns (SimpleMsg)
// swagger:route POST /api api createOrUpdateApi
// Create or update API information | 创建或更新API
// Responses:
// 200: SimpleMsg
// 401: SimpleMsg
// 500: SimpleMsg
@handler createOrUpdateApi
post /api (CreateOrUpdateApiReq) returns (SimpleMsg)

@handler deleteApiHandler
// swagger:route DELETE /api api deleteApi
// Delete API information | 删除API信息
// Responses:
// 200: SimpleMsg
// 401: SimpleMsg
// 500: SimpleMsg
@handler deleteApi
delete /api (IdReq) returns (SimpleMsg)

@handler getApiListHandler
// swagger:route POST /api/list api getApiList
// Get API list | 获取API列表
// Responses:
// 200: ApiListResp
// 401: SimpleMsg
// 500: SimpleMsg
@handler getApiList
post /api/list (ApiListReq) returns (ApiListResp)
}
60 changes: 50 additions & 10 deletions api/api_desc/authority.api
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,44 @@ info(
import "base.api"

type (
// api struct
// The response data of api authorization | API授权数据
// swagger:response ApiAuthorityInfo
ApiAuthorityInfo {
// API path | API 路径
Path string `json:"path"`
// API method | API请求方法
Method string `json:"method"`
}

// swagger:parameters createOrUpdateApiAuthority
// Create or update api authorization information request | 创建或更新API授权信息
CreateOrUpdateApiAuthorityReq {
// Role ID | 角色ID
// Required: true
RoleId uint64 `json:"roleId"`
// API authorization list | API授权列表数据
// Required: true
Data []ApiAuthorityInfo `json:"data"`
}

// The response data of api authorization list | API授权列表数据
// swagger:response ApiAuthorityListResp
ApiAuthorityListResp {
PageList
// The total number of data | 数据总数
Total uint64 `json:"total"`
// The api authorization list data | API授权列表数据
// in: body
Data []ApiAuthorityInfo `json:"data"`
}

// menu struct
// swagger:parameters createOrUpdateMenuAuthority
// Create or update menu authorization information request params | 创建或更新菜单授权信息参数
MenuAuthorityInfo {
// role ID | 角色ID
// Required: true
RoleId uint64 `json:"roleId"`
// menu ID array | 菜单ID数组
// Required: true
MenuIds []uint64 `json:"menuIds"`
}
)
Expand All @@ -41,18 +60,39 @@ type (
)

service core {
// api authorization management
// api 访问权限管理
@handler createOrUpdateApiAuthorityHandler
// swagger:route POST /authority/api authority createOrUpdateApiAuthority
// Create or update API authorization information | 创建或更新API权限
// Responses:
// 200: SimpleMsg
// 401: SimpleMsg
// 500: SimpleMsg
@handler createOrUpdateApiAuthority
post /authority/api (CreateOrUpdateApiAuthorityReq) returns (SimpleMsg)

@handler getApiAuthorityhandler
// swagger:route GET /authority/api/role authority getApiAuthority
// Get role's API authorization list | 获取角色api权限列表
// Responses:
// 200: ApiAuthorityListResp
// 401: SimpleMsg
// 500: SimpleMsg
@handler getApiAuthority
post /authority/api/role (IdReq) returns (ApiAuthorityListResp)

// menu authorization management
@handler createOrUpdateMenuAuthorityHandler
// swagger:route POST /authority/menu authority createOrUpdateMenuAuthority
// Create or update menu authorization information | 创建或更新菜单权限
// Responses:
// 200: SimpleMsg
// 401: SimpleMsg
// 500: SimpleMsg
@handler createOrUpdateMenuAuthority
post /authority/menu (MenuAuthorityInfo) returns (SimpleMsg)

@handler getMenuAuthorityHandler
// swagger:route GET /authority/menu/role authority getMenuAuthority
// Get role's menu authorization list | 获取角色菜单权限列表
// Responses:
// 200: MenuAuthorityInfo
// 401: SimpleMsg
// 500: SimpleMsg
@handler getMenuAuthority
post /authority/menu/role (IdReq) returns (MenuAuthorityInfo)
}
48 changes: 39 additions & 9 deletions api/api_desc/base.api
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,73 @@ info(
version: "v1.0"
)


// The basic response with data | 基础带数据信息
// swagger:response BaseMsg
type BaseMsg {
Code int32 `json:"code"`
Msg string `json:"msg"`
Data string `json:"data"`
}

// The basic response without data | 基础不带数据信息
// swagger:response BaseMsg
type BaseResp {
Code int32 `json:"code"`
Msg string `json:"msg"`
}

// The simplest message | 最简单的信息
// swagger:response SimpleMsg
type SimpleMsg {
// Message | 信息
Msg string `json:"msg"`
}

// The page request parameters | 列表请求参数
// swagger:parameters getRoleList
type PageInfo {
// Page number | 第几页
// Required: true
Page uint64 `json:"page"`
// Page size | 单页数据行数
// Required: true
PageSize uint64 `json:"pageSize"`
}

// The page response data model | 列表返回信息
// swagger:response PageList
type PageList {
// Total number | 数据总数
Total uint64 `json:"total"`
// Data | 数据
Data []string `json:"data"`
}

type BaseInfo {
ID uint `json:"id"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
DeletedAt int64 `json:"deletedAt"`
}

// swagger:parameters deleteUser deleteApi getApiAuthority getMenuAuthority deleteMenu deleteRole
// Basic id request | 基础id参数请求
type IdReq {
// ID
// Required: true
ID uint `json:"id"`
}

// swagger:parameters deleteUser
// Basic UUID request | 基础UUID参数请求
type UUIDReq {
// UUID
// Required: true
UUID string `json:"uuid"`
}
}

// The base response data | 基础信息
// swagger:response BaseInfo
type BaseInfo {
// ID
ID uint `json:"id"`
// Create date | 创建日期
CreatedAt int64 `json:"createdAt"`
// Update date | 更新日期
UpdatedAt int64 `json:"updatedAt"`
// Delete date | 删除日期
DeletedAt int64 `json:"deletedAt"`
}
15 changes: 9 additions & 6 deletions api/api_desc/captcha.api
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ info(

import "base.api"

type CaptchaInfoResp {
BaseMsg
Data CaptchaInfo `json:"data"`
}

// The response data of captcha | 验证码返回数据
// swagger:response CaptchaInfo
type CaptchaInfo {
CaptchaId string `json:"captchaId"`
ImgPath string `json:"imgPath"`
Expand All @@ -25,6 +22,12 @@ type CaptchaInfo {
)

service core {
@handler getCaptchaHandler
// swagger:route GET /captcha captcha getCaptcha
// Get captcha | 获取验证码
// Responses:
// 200: CaptchaInfo
// 401: SimpleMsg
// 500: SimpleMsg
@handler getCaptcha
get /captcha returns (CaptchaInfo)
}
14 changes: 10 additions & 4 deletions api/api_desc/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ import "base.api"
)

service core {
@doc "core"
@handler healthCheckHandler
// swagger:route get /core/health core healthCheck
// Check the system status | 检查系统状态
@handler healthCheck
get /core/health

@handler initDatabaseHandler
get /core/init_database returns (SimpleMsg)
// swagger:route get /core/init/database core initDatabase
// Initialize database | 初始化数据库
// Responses:
// 200: SimpleMsg
// 500: SimpleMsg
@handler initDatabase
get /core/init/database returns (SimpleMsg)
}
Loading