| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- namespace business\controllers;
- use biz\admin\classes\AdminClass;
- use biz\admin\services\AdminService;
- use common\components\jwt;
- use common\components\util;
- use Yii;
- use yii\web\Controller;
- class AdminController extends BaseController
- {
-
- public $withoutLogin = [];
-
- //获取登陆员工的权限 shish 2019.11.24
- public function actionLoginAuth()
- {
- $auth = AdminService::getAuth($this->adminId,$this->merchantId);
- util::success($auth);
- }
-
- //员工列表 shish 2019.12.8
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $where['merchantId'] = $this->merchantId;
- $list = AdminService::getAdminList($where);
- util::success($list);
- }
-
- //添加员工 shish 2019.12.8
- public function actionAdd()
- {
- $post = Yii::$app->request->post();
- $post['merchantId'] = $this->merchantId;
- $admin = AdminService::addAdmin($post);
- $id = $admin['id'];
- $info = AdminService::getDetail($id);
- util::success($info);
- }
-
- //删除员工 shish 2019.12.9
- public function actionDelete()
- {
- $id = Yii::$app->request->get('id');
- $admin = AdminClass::getById($id);
- AdminService::valid($admin, $this->merchantId);
- AdminService::deleteAdmin($admin, $this->adminId);
- util::ok();
- }
-
- //修改员工 shish 2019.12.9
- public function actionUpdate()
- {
- $post = Yii::$app->request->post();
- $id = isset($post['id']) && is_numeric($post['id']) ? $post['id'] : 0;
- unset($post['id']);
- $originalAdmin = AdminService::getById($id);
- AdminService::updateAdmin($originalAdmin, $post);
- util::ok('修改成功');
- }
-
- //查看员工详情 shish 2019.12.9
- public function actionDetail()
- {
- $id = Yii::$app->request->get('id');
- $admin = AdminService::getDetail($id);
- AdminService::valid($admin, $this->merchantId);
- util::success($admin);
- }
-
- //密码修改
- public function actionPassword()
- {
- $post = Yii::$app->request->post();
- $old = isset($post['old']) ? $post['old'] : '';
- $new = isset($post['new']) ? $post['new'] : '';
- $confirm = isset($post['confirm']) ? $post['confirm'] : '';
- if ($new != $confirm) {
- util::fail('二次密码不一致');
- }
- $admin = $this->admin;
- if (empty($old) && !empty($admin['password'])) {
- util::fail('请输入旧密码');
- }
- }
- //确认密码修改
- public function actionConfirmPassword()
- {
- $post = Yii::$app->request->post();
- $old = isset($post['old']) ? $post['old'] : '';
- $new = isset($post['new']) ? $post['new'] : '';
- $confirm = isset($post['confirm']) ? $post['confirm'] : '';
- if ($new != $confirm) {
- util::fail('二次密码不一致');
- }
- }
-
- }
|