user.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. class SysUserController extends Controller {
  4. async list() {
  5. const {ctx, service} = this;
  6. let query = ctx.request.query;
  7. let ret = await service.sysUser.list(query);
  8. ctx.adminOK(ret);
  9. }
  10. async roleList() {
  11. const {ctx, service} = this;
  12. let query = ctx.request.query;
  13. let ret = await service.sysUser.roleList(query);
  14. ctx.adminOK(ret);
  15. }
  16. async userRoleList() {
  17. const {ctx, service} = this;
  18. let query = ctx.request.query;
  19. let ret = await service.sysUser.userRoleList(query);
  20. ctx.adminOK(ret);
  21. }
  22. async delete() {
  23. const {ctx, service} = this;
  24. let id = ctx.request.query.id;
  25. let ret = await service.sysUser.delete(id);
  26. ctx.adminOK(ret, "删除成功");
  27. }
  28. async deleteRole() {
  29. const {ctx, service} = this;
  30. let id = ctx.request.query.id;
  31. let ret = await service.sysUser.deleteRole(id);
  32. ctx.adminOK(ret, "删除成功");
  33. }
  34. async deleteUserRole() {
  35. const {ctx, service} = this;
  36. let data = ctx.request.query;
  37. let ret = await service.sysUser.deleteUserRole(data);
  38. ctx.adminOK(ret, "删除成功");
  39. }
  40. async deleteUserRoleBatch ()
  41. {
  42. const {ctx, service} = this;
  43. let data = ctx.request.query;
  44. let ret = await service.sysUser.deleteUserRoleBatch(data);
  45. ctx.adminOK(ret, "删除成功");
  46. }
  47. async edit() {
  48. const {ctx, service} = this;
  49. let data = ctx.request.body;
  50. let ret = await service.sysUser.edit( data );
  51. ctx.adminOK(ret, "更新成功");
  52. }
  53. async editRole() {
  54. const {ctx, service} = this;
  55. let data = ctx.request.body;
  56. let ret = await service.sysUser.editRole( data );
  57. ctx.adminOK(ret, "更新成功");
  58. }
  59. async add() {
  60. const {ctx, service} = this;
  61. let data = ctx.request.body;
  62. let ret = await service.sysUser.add( data );
  63. ctx.adminOK(ret, "添加成功");
  64. }
  65. async addRole() {
  66. const {ctx, service} = this;
  67. let data = ctx.request.body;
  68. let ret = await service.sysUser.addRole( data );
  69. ctx.adminOK(ret, "添加成功");
  70. }
  71. async addSysUserRole() {
  72. const {ctx, service} = this;
  73. let data = ctx.request.body;
  74. let ret = await service.sysUser.addSysUserRole( data );
  75. ctx.adminOK(ret, "添加成功");
  76. }
  77. async resetpwd() {
  78. const {ctx, service} = this;
  79. let data = ctx.request.body;
  80. let ret = await service.sysUser.resetpwd( data );
  81. ctx.adminOK(ret, "重置成功");
  82. }
  83. async frozenBatch() {
  84. const {ctx, service} = this;
  85. let data = ctx.request.body;
  86. let ret = await service.sysUser.frozenBatch( data );
  87. ctx.adminOK(ret, "冻结成功");
  88. }
  89. async queryUserRole() {
  90. const {ctx, service} = this;
  91. let data = ctx.request.query;
  92. let ret = await service.sysUser.queryUserRole( data );
  93. ctx.adminOK(ret);
  94. }
  95. async checkOnlyUser() {
  96. const {ctx, service} = this;
  97. let data = ctx.request.query;
  98. let ret = await service.sysUser.checkOnlyUser( data );
  99. ctx.adminOK(ret);
  100. }
  101. async queryTreeList() {
  102. const {ctx, service} = this;
  103. await ctx.queryHandleByService(service.sysUser, "queryTreeList");
  104. }
  105. async saveRolePermission()
  106. {
  107. //sys/permission/saveRolePermission
  108. const {ctx, service} = this;
  109. await ctx.bodyHandleByService(service.sysUser, "saveRolePermission", "保存成功");
  110. }
  111. async queryRolePermission() {
  112. const {ctx, service} = this;
  113. await ctx.queryHandleByService(service.sysUser, "queryRolePermission");
  114. }
  115. }
  116. module.exports = SysUserController;