UserController.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/3/8
  6. * Time: 上午10:33
  7. */
  8. namespace backend\controllers;
  9. use backend\base\CommonController;
  10. use backend\base\Help;
  11. use backend\server\User;
  12. use Yii;
  13. class UserController extends CommonController
  14. {
  15. /*
  16. * 用户管理-用户列表页面
  17. * */
  18. public function actionHome()
  19. {
  20. return $this->render('home');
  21. }
  22. /*
  23. * 用户管理-用户列表数据
  24. * */
  25. public function actionHomefrom()
  26. {
  27. $model = new User();
  28. $result = $model->Userlist();
  29. if ($result != false) {
  30. return Help::JsonData(0, '成功', $result['count'], $result['data']);
  31. }
  32. return Help::JsonData(Help::ERROR, '暂无数据');
  33. }
  34. /*
  35. * 添加用户页面
  36. * */
  37. public function actionAdduser()
  38. {
  39. return $this->render('adduser');
  40. }
  41. /*
  42. * 添加用户数据
  43. * */
  44. public function actionAdduserfrom()
  45. {
  46. $model = new User();
  47. $user = $model->Signup();
  48. if ($user === true) return Help::JsonCode(Help::SUCCESS, '账号添加成功');
  49. return Help::JsonCode(Help::ERROR, '账号添加失败');
  50. }
  51. /*
  52. * 用户添加角色页面
  53. * */
  54. public function actionAdduserrole()
  55. {
  56. $model = new User();
  57. $result = $model->UserRoleFilter();
  58. if ($result != false) {
  59. return $this->render('adduserrole', ['uid' => Yii::$app->request->get('uid'), 'model' => $result]);
  60. }
  61. }
  62. /*
  63. * 2020.6.23 lyy 设置用户状态
  64. * */
  65. public function actionUsersetstatus()
  66. {
  67. $model = new \backend\server\User();
  68. $result = $model->Usersetstatus();
  69. if ($result === true) return Help::JsonCode(Help::SUCCESS, '设置成功');
  70. return Help::JsonCode(Help::ERROR, '设置失败');
  71. }
  72. /*
  73. * 用户添加角色
  74. * */
  75. public function actionAdduserrolefrom()
  76. {
  77. $model = new \backend\server\RoleAuthority();
  78. if ($model->CreateUserRole() === true) {
  79. return Help::JsonCode(Help::SUCCESS, '添加成功');
  80. }
  81. return Help::JsonCode(Help::ERROR, '添加成功');
  82. }
  83. /*
  84. * 修改用户界面
  85. * */
  86. public function actionEdit()
  87. {
  88. $model = new \common\models\User();
  89. $model->uid = Yii::$app->request->get('id');
  90. $userInfo = $model->findUserName();
  91. if ($userInfo != null) return $this->render('edit', ['model' => $userInfo]);
  92. }
  93. /*
  94. * 修改用户数据
  95. * */
  96. public function actionEditform()
  97. {
  98. $model = new \backend\server\User();
  99. $result = $model->UserSaveForm();
  100. if ($result === true) return Help::JsonCode(Help::SUCCESS, '修改成功');
  101. return Help::JsonCode(Help::ERROR, '修改失败', $result);
  102. }
  103. /*
  104. * 个人密码修改
  105. * */
  106. public function actionPwdsave()
  107. {
  108. return $this->render('pwdsave');
  109. }
  110. /*
  111. * 用户密码修改
  112. * */
  113. public function actionPwdsaveform()
  114. {
  115. $model = new \backend\server\User();
  116. $result = $model->PasswordSave();
  117. if ($result === true) {
  118. return Help::JsonCode(Help::SUCCESS, '密码修改成功');
  119. }
  120. return Help::JsonCode(Help::ERROR, $result);
  121. }
  122. }