user.api 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. import "../base.api"
  2. type (
  3. // The response data of user information | 用户信息
  4. UserInfo {
  5. BaseUUIDInfo
  6. // Status | 状态
  7. Status *uint32 `json:"status,optional" validate:"omitempty,lt=20"`
  8. // Username | 用户名
  9. Username *string `json:"username,optional" validate:"omitempty,max=50"`
  10. // Nickname | 昵称
  11. Nickname *string `json:"nickname,optional" validate:"omitempty,max=40"`
  12. // Password | 密码
  13. Password *string `json:"password,optional" validate:"omitempty,min=6"`
  14. // Description | 描述
  15. Description *string `json:"description,optional" validate:"omitempty,max=100"`
  16. // HomePath | 首页
  17. HomePath *string `json:"homePath,optional" validate:"omitempty,max=70"`
  18. // RoleId | 角色ID
  19. RoleIds []uint64 `json:"roleIds,optional"`
  20. // Mobile | 手机号
  21. Mobile *string `json:"mobile,optional" validate:"omitempty,max=18"`
  22. // Email | 邮箱
  23. Email *string `json:"email,optional" validate:"omitempty,max=80"`
  24. // Avatar | 头像地址
  25. Avatar *string `json:"avatar,optional" validate:"omitempty,max=300"`
  26. // Department ID | 部门ID
  27. DepartmentId *uint64 `json:"departmentId,optional,omitempty"`
  28. // Position ID | 职位ID
  29. PositionIds []uint64 `json:"positionId,optional,omitempty"`
  30. }
  31. // The response data of user list | 用户列表数据
  32. UserListResp {
  33. BaseDataInfo
  34. // User list data | User列表数据
  35. Data UserListInfo `json:"data"`
  36. }
  37. // User list data | 用户列表数据
  38. UserListInfo {
  39. BaseListInfo
  40. // The API list data | User列表数据
  41. Data []UserInfo `json:"data"`
  42. }
  43. // Get user list request params | 用户列表请求参数
  44. UserListReq {
  45. PageInfo
  46. // User Name | 用户名
  47. Username *string `json:"username,optional" validate:"omitempty,alphanum,max=20"`
  48. // User's nickname | 用户的昵称
  49. Nickname *string `json:"nickname,optional" validate:"omitempty,alphanumunicode,max=10"`
  50. // User's mobile phone number | 用户的手机号码
  51. Mobile *string `json:"mobile,optional" validate:"omitempty,numeric,max=18"`
  52. // The user's email address | 用户的邮箱
  53. Email *string `json:"email,optional" validate:"omitempty,email,max=100"`
  54. // User's role ID | 用户的角色ID
  55. RoleIds []uint64 `json:"roleIds,optional"`
  56. // The user's department ID | 用户所属部门ID
  57. DepartmentId *uint64 `json:"departmentId,optional"`
  58. // User's position id | 用户的职位ID
  59. PositionId *uint64 `json:"positionId,optional"`
  60. }
  61. // User information response | 用户信息返回体
  62. UserInfoResp {
  63. BaseDataInfo
  64. // User information | User数据
  65. Data UserInfo `json:"data"`
  66. }
  67. // register request | 注册参数
  68. RegisterReq {
  69. // User Name | 用户名
  70. Username string `json:"username" validate:"required,alphanum,max=20"`
  71. // Password | 密码
  72. Password string `json:"password" validate:"required,max=30,min=6"`
  73. // Captcha ID which store in redis | 验证码编号, 存在redis中
  74. CaptchaId string `json:"captchaId" validate:"required,len=20"`
  75. // The Captcha which users input | 用户输入的验证码
  76. Captcha string `json:"captcha" validate:"required,len=5"`
  77. // The user's email address | 用户的邮箱
  78. Email string `json:"email" validate:"required,email,max=100"`
  79. }
  80. // Register by email request | 邮箱注册参数
  81. RegisterByEmailReq {
  82. // User Name | 用户名
  83. Username string `json:"username" validate:"required,alphanum,max=20"`
  84. // Password | 密码
  85. Password string `json:"password" validate:"required,max=30,min=6"`
  86. // The Captcha which users input | 用户输入的验证码
  87. Captcha string `json:"captcha" validate:"required,len=5"`
  88. // The user's email address | 用户的邮箱
  89. Email string `json:"email" validate:"required,email,max=100"`
  90. }
  91. // Register by SMS request | 短信注册参数
  92. RegisterBySmsReq {
  93. // User Name | 用户名
  94. Username string `json:"username" validate:"required,alphanum,max=20"`
  95. // Password | 密码
  96. Password string `json:"password" validate:"required,max=30,min=6"`
  97. // The Captcha which users input | 用户输入的验证码
  98. Captcha string `json:"captcha" validate:"required,len=5"`
  99. // The user's mobile phone number | 用户的手机号码
  100. PhoneNumber string `json:"phoneNumber" validate:"required,numeric,max=20"`
  101. }
  102. // change user's password request | 修改密码请求参数
  103. ChangePasswordReq {
  104. // User's old password | 用户旧密码
  105. OldPassword string `json:"oldPassword" validate:"required,max=30"`
  106. // User's new password | 用户新密码
  107. NewPassword string `json:"newPassword" validate:"required,max=30"`
  108. }
  109. // The log in information | 登陆返回的数据信息
  110. LoginInfo {
  111. // User's UUID | 用户的UUID
  112. UserId string `json:"userId"`
  113. // Token for authorization | 验证身份的token
  114. Token string `json:"token"`
  115. // Expire timestamp | 过期时间戳
  116. Expire uint64 `json:"expire"`
  117. }
  118. // The simple role data | 简单的角色数据
  119. // swagger:model RoleInfoSimple
  120. RoleInfoSimple {
  121. // Role name | 角色名
  122. RoleName string `json:"roleName"`
  123. // Role value | 角色值
  124. Value string `json:"value"`
  125. }
  126. // The response data of user's basic information | 用户基本信息返回数据
  127. UserBaseIDInfoResp {
  128. BaseDataInfo
  129. // The data of user's basic information | 用户基本信息
  130. Data UserBaseIDInfo `json:"data"`
  131. }
  132. // The data of user's basic information | 用户基本信息
  133. UserBaseIDInfo {
  134. // User's UUID | 用户的UUID
  135. UUID *string `json:"userId"`
  136. // User's name | 用户名
  137. Username *string `json:"username"`
  138. // User's nickname | 用户的昵称
  139. Nickname *string `json:"nickname"`
  140. // The user's avatar path | 用户的头像路径
  141. Avatar *string `json:"avatar"`
  142. // The home page that the user enters after logging in | 用户登陆后进入的首页
  143. HomePath *string `json:"homePath"`
  144. // The description of user | 用户的描述信息
  145. Description *string `json:"desc"`
  146. // User's Role Name | 用户的角色名称
  147. RoleName []string `json:"roleName"`
  148. // Department Name | 部门名称
  149. DepartmentName string `json:"departmentName,optional"`
  150. }
  151. // The permission code for front end permission control | 权限码: 用于前端权限控制
  152. PermCodeResp {
  153. BaseDataInfo
  154. // Permission code data | 权限码数据
  155. Data []string `json:"data"`
  156. }
  157. // Login request | 登录参数
  158. LoginReq {
  159. // User Name | 用户名
  160. Username string `json:"username" validate:"required,alphanum,max=20"`
  161. // Password | 密码
  162. Password string `json:"password" validate:"required,max=30,min=6"`
  163. // Captcha ID which store in redis | 验证码编号, 存在redis中
  164. CaptchaId string `json:"captchaId" validate:"required,len=20"`
  165. // The Captcha which users input | 用户输入的验证码
  166. Captcha string `json:"captcha" validate:"required,len=5"`
  167. }
  168. // Log in by email request | 邮箱登录参数
  169. LoginByEmailReq {
  170. // The user's email address | 用户的邮箱
  171. Email string `json:"email" validate:"required,email,max=100"`
  172. // The Captcha which users input | 用户输入的验证码
  173. Captcha string `json:"captcha,optional" validate:"omitempty,len=5"`
  174. }
  175. // Log in by SMS request | 短信登录参数
  176. LoginBySmsReq {
  177. // The user's mobile phone number | 用户的手机号码
  178. PhoneNumber string `json:"phoneNumber" validate:"required,numeric,max=20"`
  179. // The Captcha which users input | 用户输入的验证码
  180. Captcha string `json:"captcha,optional" validate:"omitempty,len=5"`
  181. }
  182. // The log in response data | 登录返回数据
  183. LoginResp {
  184. BaseDataInfo
  185. // The log in information | 登陆返回的数据信息
  186. Data LoginInfo `json:"data"`
  187. }
  188. // The profile information | 个人信息
  189. ProfileInfo {
  190. // user's nickname | 用户的昵称
  191. Nickname *string `json:"nickname" validate:"omitempty,alphanumunicode,max=10"`
  192. // The user's avatar path | 用户的头像路径
  193. Avatar *string `json:"avatar" validate:"omitempty,max=300"`
  194. // User's mobile phone number | 用户的手机号码
  195. Mobile *string `json:"mobile" validate:"omitempty,numeric,max=18"`
  196. // The user's email address | 用户的邮箱
  197. Email *string `json:"email" validate:"omitempty,email,max=100"`
  198. }
  199. // The profile response data | 个人信息返回数据
  200. ProfileResp {
  201. BaseDataInfo
  202. // The profile information | 个人信息
  203. Data ProfileInfo `json:"data"`
  204. }
  205. // Reset password by email request | 通过邮箱重置密码请求
  206. ResetPasswordByEmailReq {
  207. Email string `json:"email" validate:"email"`
  208. Captcha string `json:"captcha"`
  209. Password string `json:"password"`
  210. }
  211. // Reset password by SMS request | 通过短信重置密码请求
  212. ResetPasswordBySmsReq {
  213. PhoneNumber string `json:"phoneNumber"`
  214. Captcha string `json:"captcha"`
  215. Password string `json:"password"`
  216. }
  217. // Refresh token response data | 刷新令牌响应数据
  218. RefreshTokenResp {
  219. BaseDataInfo
  220. // The token information | 令牌信息
  221. Data RefreshTokenInfo `json:"data"`
  222. }
  223. // Refresh token information | 刷新令牌信息
  224. RefreshTokenInfo {
  225. Token string `json:"token"`
  226. ExpiredAt int64 `json:"expiredAt"`
  227. }
  228. )
  229. @server(
  230. group: publicuser
  231. )
  232. service Core {
  233. // Log in | 登录
  234. @handler login
  235. post /user/login (LoginReq) returns (LoginResp)
  236. // Log in by email | 邮箱登录
  237. @handler loginByEmail
  238. post /user/login_by_email (LoginByEmailReq) returns (LoginResp)
  239. // Log in by SMS | 短信登录
  240. @handler loginBySms
  241. post /user/login_by_sms (LoginBySmsReq) returns (LoginResp)
  242. // Register | 注册
  243. @handler register
  244. post /user/register (RegisterReq) returns (BaseMsgResp)
  245. // Register by Email | 邮箱注册
  246. @handler registerByEmail
  247. post /user/register_by_email (RegisterByEmailReq) returns (BaseMsgResp)
  248. // Register by SMS | 短信注册
  249. @handler registerBySms
  250. post /user/register_by_sms (RegisterBySmsReq) returns (BaseMsgResp)
  251. // Reset password by Email | 通过邮箱重置密码
  252. @handler resetPasswordByEmail
  253. post /user/reset_password_by_email (ResetPasswordByEmailReq) returns (BaseMsgResp)
  254. // Reset password by Sms | 通过短信重置密码
  255. @handler resetPasswordBySms
  256. post /user/reset_password_by_sms (ResetPasswordBySmsReq) returns (BaseMsgResp)
  257. }
  258. @server(
  259. jwt: Auth
  260. group: user
  261. middleware: Authority
  262. )
  263. service Core {
  264. // Create user information | 创建用户
  265. @handler createUser
  266. post /user/create (UserInfo) returns (BaseMsgResp)
  267. // Update user information | 更新用户
  268. @handler updateUser
  269. post /user/update (UserInfo) returns (BaseMsgResp)
  270. // Delete user information | 删除用户信息
  271. @handler deleteUser
  272. post /user/delete (UUIDsReq) returns (BaseMsgResp)
  273. // Get user list | 获取用户列表
  274. @handler getUserList
  275. post /user/list (UserListReq) returns (UserListResp)
  276. // Get User by ID | 通过ID获取用户
  277. @handler getUserById
  278. post /user (UUIDReq) returns (UserInfoResp)
  279. // Change Password | 修改密码
  280. @handler changePassword
  281. post /user/change_password (ChangePasswordReq) returns (BaseMsgResp)
  282. // Get user basic information | 获取用户基本信息
  283. @handler getUserInfo
  284. get /user/info returns (UserBaseIDInfoResp)
  285. // Get user's permission code | 获取用户权限码
  286. @handler getUserPermCode
  287. get /user/perm returns (PermCodeResp)
  288. // Get user's profile | 获取用户个人信息
  289. @handler getUserProfile
  290. get /user/profile returns (ProfileResp)
  291. // Update user's profile | 更新用户个人信息
  292. @handler updateUserProfile
  293. post /user/profile (ProfileInfo) returns (BaseMsgResp)
  294. // Log out | 退出登陆
  295. @handler logout
  296. get /user/logout returns (BaseMsgResp)
  297. // Refresh token | 获取刷新 token
  298. @handler refreshToken
  299. get /user/refresh_token returns (RefreshTokenResp)
  300. // Access token | 获取短期 token
  301. @handler accessToken
  302. get /user/access_token returns (RefreshTokenResp)
  303. }