DeptUserLogic.php 2.5 KB
<?php

namespace App\Http\Logic\Bside\User;

use App\Http\Logic\Bside\BaseLogic;
use App\Models\User\DeptUser;
use App\Models\User\User as UserModel;
use Illuminate\Support\Facades\DB;

class DeptUserLogic extends BaseLogic
{
    public function __construct()
    {
        parent::__construct();

        $this->model = new DeptUser();
        $this->param = $this->requestAll;
    }
    /**
     * @name   :(部门用户)dept_user_add
     * @author :lyh
     * @method :post
     * @time   :2023/5/18 10:21
     */
    public function dept_user_save(){
        if(isset($this->param['id']) && !empty($this->param['id'])){
            $rs = $this->dept_user_edit();
        }else{
            $rs = $this->dept_user_add();
        }
        if ($rs === false) {
            $this->fail('error');
        }
        return $this->success();
    }

    /**
     * @name   :(部门添加用户)dept_user_add
     * @author :lyh
     * @method :post
     * @time   :2023/5/18 10:21
     */
    public function dept_user_add(){
        $param = [
            'dept_id'=> $this->param['dept_id'],
            'project_id'=>$this->user['project_id'],
            'user_id'=>$this->param['user_id'],
            'operator_id'=>$this->user['id'],
            'create_id'=>$this->user['id']
        ];
        $rs = $this->model->add($param);
        if($rs === false){
            $this->fail('部门添加成员失败');
        }
        return $this->success();
    }

    /**
     * @name   :(用户更改部门)dept_user_edit
     * @author :lyh
     * @method :post
     * @time   :2023/5/17 17:54
     */
    public function dept_user_edit(){
        $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
        if($rs === false){
            $this->fail('error');
        }
        return $this->success();
    }

    /**
     * @name   :(用户设置角色)user_edit_role
     * @author :lyh
     * @method :post
     * @time   :2023/5/19 9:35
     */
    public function user_edit_role(){
        $userModel = new UserModel();
        $rs = $userModel->edit(['role_id'=>$this->param['role_id']],['id'=>$this->param['id']]);
        if($rs === false){
            $this->fail('error');
        }
        return $this->success();
    }

    /**
     * @name   :(获取详情)dept_user_info
     * @author :lyh
     * @method :post
     * @time   :2023/6/14 14:41
     */
    public function dept_user_info(){
        $info = $this->model->read($this->param);
        if($info === false){
            $this->fail('error');
        }
        return $this->success();
    }
}