HrLogic.php 4.1 KB
<?php

namespace App\Http\Logic\Aside\Manage;


use App\Http\Logic\Aside\BaseLogic;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\EntryPosition;
use App\Models\Manage\JobLevel;
use App\Models\Manage\ManageHr;


/**
 * Class ManageHrLogic
 * @package App\Http\Logic\Aside\Manage
 * @author zgj
 * @date 2023/5/30
 */
class HrLogic extends BaseLogic
{
    public function __construct()
    {
        parent::__construct();
        $this->model = new ManageHr();
    }

    public function getList(array $param = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20){
        $search = isset($param['search'])?$param['search']:'';
        $pagesize = isset($param['pagesize'])?$param['pagesize']:20;
        $map = [];
        if($search){
            $map[] = ['name','like','%'.$search.'%'];
        }
        $list =  parent::getList($map, $sort, $columns, $pagesize);
        return $list;
    }

    public function save($param){
        foreach ($this->model::specielField() as $v){
            $param = $this->setJson($v,$param);
        }
        return parent::save($param);
    }

    public function getInfo($id){
        $data = parent::getInfo($id);
        foreach ($this->model::specielField() as $v){
            $data[$v] = json_decode($data[$v],true);
        }
        return $data;
    }

    //数组转json存储
    public function setJson($str,$param){
        if(isset($param[$str]) && is_array($param[$str])){
            $param[$str] = json_encode($param[$str]);
        }else{
            $param[$str] = '';
        }
        return $param;
    }

    /**
     * @remark :获取所有搜索参数
     * @name   :getParams
     * @author :lyh
     * @method :post
     * @time   :2023/7/24 11:05
     */
    public function getSearchParams(){
        $data['belong_group'] = $this->belongGroupList();
        $data['education'] = $this->educationList();
        $data['entry_position'] = $this->entryPositionList();
        $data['p_level'] = $this->pLevel();
        $data['political_outlook'] = $this->politicalOutlook();
        $data['PartyBranch'] = $this->IsPartyBranch();
        return $data;
    }

    /**
     * @remark :获取归属小组
     * @name   :belongGroupList
     * @author :lyh
     * @method :post
     * @time   :2023/7/22 17:35
     */
    public function belongGroupList(){
        $belongingGroupModel = new BelongingGroup();
        $lists = $belongingGroupModel->list();
        return $this->success($lists);
    }

    /**
     * @remark :获取学历
     * @name   :educationList
     * @author :lyh
     * @method :post
     * @time   :2023/7/22 17:49
     */
    public function educationList(){
        $data = [
            1 => '专科',
            2 => '本科',
            3 => '研究生及以上',
            0 => '其他',
        ];
        return $this->success($data);
    }

    /**
     * @remark :入职岗位
     * @name   :entryPositionList
     * @author :lyh
     * @method :post
     * @time   :2023/7/22 17:51
     */
    public function entryPositionList(){
        $entryPositionModel = new EntryPosition();
        $lists = $entryPositionModel->list();
        return $this->success($lists);
    }

    /**
     * @remark :职务级别
     * @name   :pLevel
     * @author :lyh
     * @method :post
     * @time   :2023/7/22 18:10
     */
    public function pLevel(){
        $jobLevelModel = new JobLevel();
        $jobLevelModel->list();
        $lists = [];
        return $this->success($lists);
    }

    /**
     * @remark :政治面貌
     * @name   :politicalOutlook
     * @author :lyh
     * @method :post
     * @time   :2023/7/24 10:57
     */
    public function politicalOutlook(){
        $data = [
            0 => '群众',
            1 => '预备党员',
            2 => '正式党员',
        ];
        return $this->success($data);
    }

    /**
     * @remark :是否有党支部
     * @name   :IsPartyBranch
     * @author :lyh
     * @method :post
     * @time   :2023/7/24 11:01
     */
    public function IsPartyBranch(){
        $data = [
            0 => '无',
            1 => '是',
            2 => '否',
        ];
        return $this->success($data);
    }
}