124 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
		
		
			
		
	
	
			124 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
|  | syntax = "v1" | |||
|  | 
 | |||
|  | info ( | |||
|  | 	title:   "角色服务" | |||
|  | 	desc:    "角色服务" | |||
|  | 	author:  "Liangzai" | |||
|  | 	email:   "2440983361@qq.com" | |||
|  | 	version: "v1" | |||
|  | ) | |||
|  | 
 | |||
|  | @server ( | |||
|  | 	prefix: api/v1/admin/role | |||
|  | 	group:  admin_role | |||
|  | 	jwt:    JwtAuth | |||
|  | ) | |||
|  | service main { | |||
|  | 	@doc "获取角色列表" | |||
|  | 	@handler GetRoleList | |||
|  | 	get /list (GetRoleListReq) returns (GetRoleListResp) | |||
|  | 
 | |||
|  | 	@doc "获取角色详情" | |||
|  | 	@handler GetRoleDetail | |||
|  | 	get /detail/:id (GetRoleDetailReq) returns (GetRoleDetailResp) | |||
|  | 
 | |||
|  | 	@doc "创建角色" | |||
|  | 	@handler CreateRole | |||
|  | 	post /create (CreateRoleReq) returns (CreateRoleResp) | |||
|  | 
 | |||
|  | 	@doc "更新角色" | |||
|  | 	@handler UpdateRole | |||
|  | 	put /update/:id (UpdateRoleReq) returns (UpdateRoleResp) | |||
|  | 
 | |||
|  | 	@doc "删除角色" | |||
|  | 	@handler DeleteRole | |||
|  | 	delete /delete/:id (DeleteRoleReq) returns (DeleteRoleResp) | |||
|  | } | |||
|  | 
 | |||
|  | type ( | |||
|  | 	// 列表请求 | |||
|  | 	GetRoleListReq { | |||
|  | 		Page     int64  `form:"page,default=1"`             // 页码 | |||
|  | 		PageSize int64  `form:"pageSize,default=20"`        // 每页数量 | |||
|  | 		Name     string `form:"name,optional"`              // 角色名称 | |||
|  | 		Code     string `form:"code,optional"`              // 角色编码 | |||
|  | 		Status   int64  `form:"status,optional,default=-1"` // 状态:0-禁用,1-启用 | |||
|  | 	} | |||
|  | 
 | |||
|  | 	// 列表响应 | |||
|  | 	GetRoleListResp { | |||
|  | 		Total int64          `json:"total"` // 总数 | |||
|  | 		Items []RoleListItem `json:"items"` // 列表 | |||
|  | 	} | |||
|  | 
 | |||
|  | 	// 列表项 | |||
|  | 	RoleListItem { | |||
|  | 		Id          int64   `json:"id"`          // 角色ID | |||
|  | 		RoleName    string  `json:"role_name"`   // 角色名称 | |||
|  | 		RoleCode    string  `json:"role_code"`   // 角色编码 | |||
|  | 		Description string  `json:"description"` // 角色描述 | |||
|  | 		Status      int64   `json:"status"`      // 状态:0-禁用,1-启用 | |||
|  | 		Sort        int64   `json:"sort"`        // 排序 | |||
|  | 		CreateTime  string  `json:"create_time"` // 创建时间 | |||
|  | 		MenuIds     []int64 `json:"menu_ids"`    // 关联的菜单ID列表 | |||
|  | 	} | |||
|  | 
 | |||
|  | 	// 详情请求 | |||
|  | 	GetRoleDetailReq { | |||
|  | 		Id int64 `path:"id"` // 角色ID | |||
|  | 	} | |||
|  | 
 | |||
|  | 	// 详情响应 | |||
|  | 	GetRoleDetailResp { | |||
|  | 		Id          int64   `json:"id"`          // 角色ID | |||
|  | 		RoleName    string  `json:"role_name"`   // 角色名称 | |||
|  | 		RoleCode    string  `json:"role_code"`   // 角色编码 | |||
|  | 		Description string  `json:"description"` // 角色描述 | |||
|  | 		Status      int64   `json:"status"`      // 状态:0-禁用,1-启用 | |||
|  | 		Sort        int64   `json:"sort"`        // 排序 | |||
|  | 		CreateTime  string  `json:"create_time"` // 创建时间 | |||
|  | 		UpdateTime  string  `json:"update_time"` // 更新时间 | |||
|  | 		MenuIds     []int64 `json:"menu_ids"`    // 关联的菜单ID列表 | |||
|  | 	} | |||
|  | 
 | |||
|  | 	// 创建请求 | |||
|  | 	CreateRoleReq { | |||
|  | 		RoleName    string  `json:"role_name"`        // 角色名称 | |||
|  | 		RoleCode    string  `json:"role_code"`        // 角色编码 | |||
|  | 		Description string  `json:"description"`      // 角色描述 | |||
|  | 		Status      int64   `json:"status,default=1"` // 状态:0-禁用,1-启用 | |||
|  | 		Sort        int64   `json:"sort,default=0"`   // 排序 | |||
|  | 		MenuIds     []int64 `json:"menu_ids"`         // 关联的菜单ID列表 | |||
|  | 	} | |||
|  | 
 | |||
|  | 	// 创建响应 | |||
|  | 	CreateRoleResp { | |||
|  | 		Id int64 `json:"id"` // 角色ID | |||
|  | 	} | |||
|  | 
 | |||
|  | 	// 更新请求 | |||
|  | 	UpdateRoleReq { | |||
|  | 		Id          int64   `path:"id"`                   // 角色ID | |||
|  | 		RoleName    *string `json:"role_name,optional"`   // 角色名称 | |||
|  | 		RoleCode    *string `json:"role_code,optional"`   // 角色编码 | |||
|  | 		Description *string `json:"description,optional"` // 角色描述 | |||
|  | 		Status      *int64  `json:"status,optional"`      // 状态:0-禁用,1-启用 | |||
|  | 		Sort        *int64  `json:"sort,optional"`        // 排序 | |||
|  | 		MenuIds     []int64 `json:"menu_ids,optional"`    // 关联的菜单ID列表 | |||
|  | 	} | |||
|  | 
 | |||
|  | 	// 更新响应 | |||
|  | 	UpdateRoleResp { | |||
|  | 		Success bool `json:"success"` // 是否成功 | |||
|  | 	} | |||
|  | 
 | |||
|  | 	// 删除请求 | |||
|  | 	DeleteRoleReq { | |||
|  | 		Id int64 `path:"id"` // 角色ID | |||
|  | 	} | |||
|  | 
 | |||
|  | 	// 删除响应 | |||
|  | 	DeleteRoleResp { | |||
|  | 		Success bool `json:"success"` // 是否成功 | |||
|  | 	} | |||
|  | ) |