| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | <?phpnamespace app\common\api;use app\common\api\CompanyApi;use think\facade\Db;use app\admin\model\Enterprise;class EnterpriseApi {    public static function getList($request) {        $companyId = session('user')['companyId'];        $company_info = CompanyApi::getOne($companyId);        $where = [];        if($company_info['code'] != 'super'){            $where[] = ['type','=',session('user')['type']];            if(session('user')['type'] == 1){                $list = Db::table('sys_enterprisetype_properties')->where('companyIds','like',$companyId)->select()->toArray();                $talentType = [];                foreach ($list as $k => $v){                    array_push($talentType,$v['talentType']);                }                $where[] = ['enterpriseTag','in',$talentType];            }        }        $offset = trim($request->param("offset")) ?: 0;        $limit = trim($request->param("limit")) ?: 10;        $count = Enterprise::where($where)->count();        if($count > 0){            $talentTypeList = DictApi::selectByParentCode("enterprise_tag");            $industryFieldNewList = DictApi::selectByParentCode("industry_field");            $industryFieldOldList = DictApi::selectByParentCode("industry_field");            //dd($talentTypeList);            $list = Enterprise::where($where)->limit($offset, $limit)->order("createTime", 'desc')->select()->toArray();            foreach ($list as $k => &$v){                unset($v['password']);                $v['enterpriseTagName'] = $talentTypeList[$v['enterpriseTag']];//此处旧字段为talentType,新字段为enterpriseTag,为防止数据污染与丢失,因而这样写                $v['industryFieldNewName'] = $industryFieldNewList[$v['industryFieldNew']];                $v['industryFieldNewName'] = $industryFieldNewList[$v['industryFieldNew']];            }        }else{            $list = [];        }        return ["total" => $count, "rows" => $list];    }}
 |