syntax = "v1" import ( "base.api" ) type ( QueryUsersReq { PageReq SortReq Keyword string `form:"keyword,optional"` Gender int `form:"gender,optional"` Role int `form:"role,optional"` } QueryDeptUsersReq { PageReq PathId WithChildren bool `form:"withChildren"` } QueryRoleUsersReq { PageReq SortReq PathId } CreateUserReq { Name string `json:"name" validate:"required" comment:"姓名"` // 名称 Username string `json:"username" validate:"required" comment:"用户名"` // 用户名 Mobile string `json:"mobile" validate:"required,mobile" comment:"手机号"` // 手机号 Password string `json:"password" validate:"required,gte=6,lte=12" comment:"密码"` Gender int `json:"gender,optional" validate:"omitempty,lte=2" comment:"性别"` // 0:未知|1:男|2:女 RoleId int `json:"roleId,optional" comment:"角色ID"` //角色id DeptId int `json:"deptId,optional" comment:"部门ID"` //部门id Position string `json:"position,optional" comment:"职位"` // 职位 Status int `json:"status,optional" validate:"omitempty,oneof=0 1" comment:"启用状态"` // 0:启用|1:禁用 } UpdateUserReq { PathId Name string `json:"name" validate:"required" comment:"姓名"` // 名称 Username string `json:"username" validate:"required" comment:"用户名"` // 用户名 Mobile string `json:"mobile" validate:"required,mobile" comment:"手机号"` // 手机号 Gender int `json:"gender,optional" validate:"omitempty,lte=4" comment:"性别"` // 1:男|2:女 RoleId int `json:"roleId,optional" comment:"角色"` //角色id State int `json:"state,optional" validate:"omitempty,oneof=0 1" comment:"启用状态"` // 0:启用|1:禁用 DepartmentId int `json:"departmentId,optional" comment:"部门"` //部门id Position string `json:"position,optional"` // 职位 } SetUserStateReq { PathId Name string `json:"name,optional" comment:"姓名"` // 名称 Status int `json:"status,optional" validate:"omitempty,oneof=0 1" comment:"启用状态"` // 0:启用|1:禁用 } SetUserRolesReq { PathId Roles []int `json:"roles"` } SetUserPasswordReq { OldPassword string `json:"oldPassword,optional" validate:"required,gte=6,lte=12" comment:"当前密码"` // 当前密码 NewPassword string `json:"newPassword,optional" validate:"required,gte=6,lte=12" comment:"新密码"` // 新密码 ConfirmPassword string `json:"confirmPassword,optional" validate:"required,eqfield=NewPassword" comment:"确认密码"` } ResetUserPasswordReq { UserId int `json:"userId"` } QueryUsersReply { PageReply Data []UserInfoReply `json:"data"` } UserInfoReply { Id int `json:"id"` Name string `json:"name" comment:"姓名"` // 名称 Username string `json:"username" comment:"用户名"` // 用户名 Mobile string `json:"mobile" comment:"手机号"` // 手机号 Gender int `json:"gender" comment:"性别"` // 0:未知|1:男|2:女 RoleId int `json:"roleId" comment:"角色ID"` // 角色ID RoleName string `json:"roleName" comment:"角色名称"` // 角色名称 DeptId int `json:"deptId" comment:"部门ID"` // 部门ID DeptName string `json:"deptName" comment:"部门名称"` // 部门名称 Position string `json:"position" comment:"职位"` // 职位 Status int `json:"status" comment:"启用状态"` // 0:启用|1:禁用 CreatedAt int64 `json:"createdAt" comment:"创建时间"` // 创建时间 UpdatedAt int64 `json:"updatedAt" comment:"更新时间"` // 更新时间 } ) @server ( jwt: Auth group: user prefix: /api/v1 ) service spherical-api { @doc "查询用户分页列表" @handler queryUsers get /users (QueryUsersReq) returns (QueryUsersReply) @doc "获取用户详情" @handler getUser get /users/:id (PathId) returns (UserInfoReply) @doc "获取当前登录用户信息" @handler userinfo get /userinfo returns (UserInfoReply) @doc ( summary: "创建用户" comment: "创建成功返回用户信息" ) @handler createUser post /users (CreateUserReq) returns (int) @doc "编辑用户" @handler updateUser put /users/:id (UpdateUserReq) returns (UserInfoReply) @doc "重置密码" @handler resetPassword post /users/resetPassword (ResetUserPasswordReq) @doc "修改密码" @handler changePassword post /users/changePassword (SetUserPasswordReq) @doc "启用用户" @handler enableUser post /users/:id/enable (SetUserStateReq) @doc "禁用用户" @handler disableUser post /users/:id/disable (SetUserStateReq) @doc "删除用户" @handler deleteUser delete /users/:id (PathId) ////////////////////////////////////////////////// @doc "通过部门查询用户分页列表" @handler queryUsersOfDept get /depts/:id/users (QueryDeptUsersReq) returns (QueryUsersReply) @doc "通过角色查询用户分页列表" @handler queryUsersOfRole get /roles/:id/users (QueryRoleUsersReq) returns (QueryUsersReply) @doc "设置用户角色" @handler setUserRoles post /users/:id/roles (SetUserRolesReq) }