| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 | <?phpnamespace app\common\api;use app\common\model\EducationSchool as EduModel;use app\common\state\MainState;use think\facade\Db;/** * Description of EducationApi * * @author sgq */class EducationApi {    public static function getList($params) {        $user = session("user");        $order = trim($params["order"]) ?: "desc";        $offset = trim($params["offset"]) ?: 0;        $limit = trim($params["limit"]) ?: 10;        $where = [];        if ($user["usertype"] == 3) {            $where[] = ["personId", "=", $user["uid"]];        } else if ($user["usertype"] == 1) {            $where[] = ["type", "=", $user["type"]];        } else {            return [];        }        if ($_where = self::getWhereByParams($params)) {            $where = array_merge($where, $_where);        }        $count = EduModel::where($where)->count();        $list = EduModel::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();        $levelMap = DictApi::selectByParentCode("talent_arrange");        $streetMap = DictApi::selectByParentCode("street");        $relationMap = DictApi::selectByParentCode("education_relation");        $gradeMap = DictApi::selectByParentCode("education_grade");        $educationProjectMap = DictApi::selectByParentCode("education_project");        $schoolMap = DictApi::selectByParentCode("education_school_pool");        foreach ($list as $key => $item) {            $list[$key]["talentArrangeName"] = $levelMap[$item["talentArrange"]];            $list[$key]["houseStreetName"] = $streetMap[$item["houseStreet"]];            $list[$key]["companyStreetName"] = $streetMap[$item["companyStreet"]];            $list[$key]["cRelationName"] = $relationMap[$item["cRelation"]];            $list[$key]["nowGradeName"] = $gradeMap[$item["nowGrade"]];            $list[$key]["projectName"] = $educationProjectMap[$item["project"]];            $list[$key]["applySchoolName"] = $schoolMap[$item["applySchool"]];        }        return ["total" => $count, "rows" => $list];    }    public static function getWhereByParams($params) {        foreach ($params as &$param) {            $param = trim($param);        }unset($param);        $where = [];        if ($params["year"]) {            $where[] = ["year", "=", $params["year"]];        }        if ($params["enterpriseName"]) {            $where[] = ["enterpriseName", "like", "%" . $params["enterpriseName"] . "%"];        }        if ($params["pName"]) {            $where[] = ["pName", "like", "%" . $params["pName"] . "%"];        }        if ($params["pSex"]) {            $where[] = ["pSex", "=", $params["pSex"]];        }        if ($params["pIdcard"]) {            $where[] = ["pIdcard", "like", "%" . $params["pIdcard"] . "%"];        }        if ($params["talentArrange"]) {            $where[] = ["talentArrange", "=", $params["talentArrange"]];        }        if ($params["certificateNo"]) {            $where[] = ["certificateNo", "like", "%" . $params["certificateNo"] . "%"];        }        if ($params["address"]) {            $where[] = ["address", "like", "%" . $params["address"] . "%"];        }        if ($params["phone"]) {            $where[] = ["phone", "like", "%" . $params["phone"] . "%"];        }        if ($params["cName"]) {            $where[] = ["cName", "like", "%" . $params["cName"] . "%"];        }        if ($params["cSex"]) {            $where[] = ["cSex", "=", $params["cSex"]];        }        if ($params["cIdcard"]) {            $where[] = ["cIdcard", "like", "%" . $params["cIdcard"] . "%"];        }        if ($params["cRelation"]) {            $where[] = ["cRelation", "=", $params["cRelation"]];        }        if ($params["nowSchool"]) {            $where[] = ["nowSchool", "like", "%" . $params["nowSchool"] . "%"];        }        if ($params["nowGrade"]) {            $where[] = ["nowGrade", "=", $params["nowGrade"]];        }        if ($params["applySchool"]) {            $where[] = ["applySchool", "=", $params["applySchool"]];        }        if ($params["companyStreet"]) {            $where[] = ["companyStreet", "=", $params["companyStreet"]];        }        if ($params["houseStreet"]) {            $where[] = ["houseStreet", "=", $params["houseStreet"]];        }        if ($params["checkState"]) {            $where[] = ["checkState", "=", $params["checkState"]];        }        return $where;    }    public static function getInfoById($id) {        return EduModel::findOrEmpty($id)->toArray();    }}
 |