作者 Your Name

gx

  1 +<?php
  2 +
  3 +namespace App\Http\Logic\Bside\Blog;
  4 +
  5 +use App\Http\Logic\Bside\BaseLogic;
  6 +use App\Models\Blog\BlogLabel as BlogLabelModel;
  7 +
  8 +class BlogLabelLogic extends BaseLogic
  9 +{
  10 + public function __construct()
  11 + {
  12 + parent::__construct();
  13 +
  14 + $this->model = new BlogLabelModel();
  15 + $this->param = $this->requestAll;
  16 + }
  17 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Logic\Bside;
  4 +
  5 +use App\Models\ProjectGroup;
  6 +
  7 +class GroupLogic extends BaseLogic
  8 +{
  9 + public function __construct()
  10 + {
  11 + parent::__construct();
  12 +
  13 + $this->model = new ProjectGroup();
  14 + $this->param = $this->requestAll;
  15 + }
  16 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Logic\Bside;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Models\ProjectMenu as ProjectMenuModel;
  7 +use App\Models\ProjectRole as ProjectRoleModel;
  8 +use App\Models\User;
  9 +use App\Models\User as UserModel;
  10 +
  11 +class RoleLogic extends BaseLogic
  12 +{
  13 + public function __construct()
  14 + {
  15 + parent::__construct();
  16 + $this->model = new ProjectRoleModel();
  17 + $this->param = $this->requestAll;
  18 + }
  19 +
  20 + /**
  21 + * @name :添加角色
  22 + * @return void
  23 + * @author :liyuhang
  24 + * @method
  25 + */
  26 + public function role_add(){
  27 + $this->param['create_id'] = $this->user['id'];
  28 + $this->param['operator_id'] = $this->user['id'];
  29 + $this->param['project_id'] = $this->user['project_id'];
  30 + //验证当前角色是否存在
  31 + $info = $this->model->read(['name'=>$this->param['name']]);
  32 + if($info !== false){
  33 + $this->fail('当前添加的角色已存在',Code::USER_ERROR);
  34 + }
  35 + $rs = $this->model->add($this->param);
  36 + if($rs === false){
  37 + $this->fail('添加失败',Code::USER_PARAMS_ERROE);
  38 + }
  39 + return $this->success();
  40 + }
  41 +
  42 + /**
  43 + * @name :编辑角色
  44 + * @return void
  45 + * @author :liyuhang
  46 + * @method
  47 + */
  48 + public function role_edit(){
  49 + //TODO::查询当前名称是否重复
  50 + $condition = [
  51 + ['id'=>['!=',$this->param['id']]],
  52 + ['name'=>$this->param['name']],
  53 + ['project_id'=>$this->user['project_id']],
  54 + ];
  55 + $info = $this->model->read($condition);
  56 + if($info !== false){
  57 + $this->fail('当前添加的角色已存在',Code::USER_PARAMS_ERROE);
  58 + }
  59 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
  60 + if($rs === false){
  61 + $this->fail('编辑失败',Code::USER_PARAMS_ERROE);
  62 + }
  63 + return $this->success();
  64 + }
  65 +
  66 + /**
  67 + * @name :修改状态/排序
  68 + * @return void
  69 + * @author :liyuhang
  70 + * @method
  71 + */
  72 + public function role_status(){
  73 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
  74 + if($rs === false){
  75 + $this->fail('error',Code::USER_PARAMS_ERROE);
  76 + }
  77 + return $this->success();
  78 + }
  79 +
  80 + /**
  81 + * @name :删除角色
  82 + * @return void
  83 + * @author :liyuhang
  84 + */
  85 + public function role_del(){
  86 + //查询当前角色下是否有用户
  87 + $userModel = new UserModel();
  88 + //批量删除
  89 + foreach ($this->param['id'] as $v){
  90 + $user_info = $userModel->read(['role_id'=>$v]);
  91 + if(!empty($user_info)){
  92 + $this->fail('当前角色下有用户存在,不允许删除',Code::USER_ERROR);
  93 + }
  94 + }
  95 + $this->param['id'] = ['in',$this->param['id']];
  96 + $rs = $this->model->del(['id'=>$this->param['id']]);
  97 + if($rs === false){
  98 + $this->fail('error',Code::USER_ERROR);
  99 + }
  100 + return $this->success();
  101 + }
  102 +
  103 + /**
  104 + * @name :获取角色详情
  105 + * @return void
  106 + * @author :liyuhang
  107 + * @method
  108 + */
  109 + public function role_info(){
  110 + $info = $this->model->read($this->param);
  111 + if($info === false){
  112 + $this->fail('error',Code::USER_ERROR);
  113 + }
  114 + return $this->success($info);
  115 + }
  116 +
  117 + /**
  118 + * @name :获取菜单列表
  119 + * @return array
  120 + * @author :liyuhang
  121 + * @method
  122 + */
  123 + public function role_get_menu(){
  124 + //根据当前登录用户角色返回用户菜单列表
  125 + $info = $this->model->read(['id'=>$this->user['role_id']]);
  126 + $info['role_menu'] = trim($info['role_menu'],',');
  127 + $menuModel = new ProjectMenu();
  128 + $lists = $menuModel->where(['status'=>0])->whereIn('id',explode(',',$info['role_menu']))->get();
  129 + $lists = $lists->toArray();
  130 + $menu = array();
  131 + foreach ($lists as $k => $v){
  132 + $v = (array)$v;
  133 + if ($v['pid'] == 0) {
  134 + $v['sub'] = $this->_get_child($v['id'], $lists);
  135 + $menu[] = $v;
  136 + }
  137 + }
  138 + return $this->success($menu);
  139 + }
  140 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Logic\Bside;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Models\Department;
  7 +use App\Models\User;
  8 +
  9 +class UserLogic extends BaseLogic
  10 +{
  11 + public function __construct()
  12 + {
  13 + parent::__construct();
  14 +
  15 + $this->model = new User();
  16 + $this->param = $this->requestAll;
  17 + }
  18 +
  19 + /**
  20 + * @name :添加会员
  21 + * @author :liyuhang
  22 + */
  23 + public function user_add(){
  24 + $this->param['create_id'] = $this->user['id'];
  25 + $this->param['operator_id'] = $this->user['id'];
  26 + $this->param['project_id'] = $this->user['project_id'];
  27 + //验证当前用户是否存在
  28 + $info = $this->model->read(['mobile'=>$this->param['mobile']]);
  29 + if($info !== false){
  30 + $this->fail('error',Code::USER_ERROR);
  31 + }
  32 + //密码加密
  33 + $param['password'] = base64_encode(md5($this->param['password']));
  34 + //上传头像
  35 + $rs = $this->model->add($param);
  36 + if($rs === false){
  37 + $this->fail('error',Code::USER_ERROR);
  38 + }
  39 + return $this->success();
  40 + }
  41 +
  42 + /**
  43 + * @name :编辑用户
  44 + * @author :liyuhang
  45 + */
  46 + public function user_edit(){
  47 + $condition = [
  48 + ['id'=>['!=',$this->param['id']]],
  49 + ['mobile'=>$this->param['mobile']]
  50 + ];
  51 + $info = $this->model->read($condition);
  52 + if($info !== false){
  53 + $this->fail('当前编辑的手机号码已存在',Code::USER_PARAMS_ERROE);
  54 + }
  55 + $this->param['operator_id'] = $this->user['id'];
  56 + $rs = $this->model->edits($this->param);
  57 + if($rs === false){
  58 + $this->fail('参数错误或其他服务器原因,编辑失败',Code::USER_ERROR,[]);
  59 + }
  60 + return $this->success();
  61 + }
  62 +
  63 + /**
  64 + * @name :编辑状态/排序
  65 + * @author :liyuhang
  66 + */
  67 + public function user_status(){
  68 + $this->param['operator_id'] = $this->user['id'];
  69 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
  70 + if($rs === false){
  71 + $this->fail('error',Code::USER_ERROR);
  72 + }
  73 + return $this->success();
  74 + }
  75 +
  76 + /**
  77 + * @name :用户详情
  78 + * @return void
  79 + * @author :liyuhang
  80 + * @method
  81 + */
  82 + public function user_info(){
  83 + $rs = $this->model->read($this->param);
  84 + if($rs === false){
  85 + $this->fail('error',Code::USER_ERROR);
  86 + }
  87 + return $this->success();
  88 + }
  89 +
  90 + /**
  91 + * @name :删除用户(逻辑删除)
  92 + * @return void
  93 + * @author :liyuhang
  94 + * @method
  95 + */
  96 + public function user_del(){
  97 + $this->param['operator_id'] = $this->user['id'];
  98 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
  99 + if($rs === false){
  100 + $this->fail('error',Code::USER_ERROR);
  101 + }
  102 + return $this->success();
  103 + }
  104 +}