| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 | <?phpnamespace app\common\api;use app\common\model\TalentCondition;/** * Description of TalentConditionApi * * @author sgq */class TalentConditionApi {    public static function getList($lv, $type, $cat) {        $where[] = ["talentLevel", "=", $lv];        $where[] = ["type", "=", $type];        $where[] = ["delete", "=", 0];        $where[] = ["active", "=", 1];        if ($type == 1) {            $where[] = ["talentLevelCat", "=", $cat];        }        return TalentCondition::where($where)->select()->toArray();    }    public static function getOne($id) {        return TalentCondition::findOrEmpty($id)->toArray();    }    public static function edit($params) {        $data["type"] = $params["type"];        $data["talentLevel"] = $params["talentLevel"];        $data["talentLevelCat"] = $params["talentLevelCat"];        $data["companyIds"] = $params["companyIds"];        $data["bindFileTypes"] = $params["bindFileTypes"];        $data["name"] = $params["name"];        $data["active"] = $params["active"];        $data["isSalary"] = $params["isSalary"];        $relation = [];        foreach ($params["relation"] as $_companyId => $_relation) {            $relation[] = $_companyId . ":" . $_relation;        }        $data["companyWithFileType"] = implode(";", $relation);        if ($params["id"]) {            $data["id"] = $params["id"];            $data["updateUser"] = session("user")["uid"];            $data["updateTime"] = date("Y-m-d H:i:s");            return TalentCondition::update($data);        } else {            $data["createUser"] = session("user")["uid"];            $data["createTime"] = date("Y-m-d H:i:s");            return TalentCondition::insert($data);        }    }    public static function delete($id) {        $data["id"] = $id;        $data["delete"] = 1;        $data["updateUser"] = session("user")["uid"];        $data["updateTime"] = date("Y-m-d H:i:s");        return TalentCondition::update($data);    }    public static function getListByCondition($params) {        $order = $params["order"] ?: "desc";        $offset = $params["offset"] ?: 0;        $limit = $params["limit"] ?: 10;        $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");        $companys = \app\common\model\Company::column("name", "id");        $where[] = ["delete", "=", 0];        if ($params["name"]) {            $where[] = ["name", "like", "%" . $params["name"] . "%"];        }        if ($params["type"]) {            $where[] = ["type", "=", $params["type"]];        }        if ($params["talentLevel"]) {            $where[] = ["talentLevel", "=", $params["talentLevel"]];        }        if ($params["active"]) {            $where[] = ["active", "=", $params["active"]];        }        $count = TalentCondition::where($where)->count();        $list = TalentCondition::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();        foreach ($list as &$item) {            $item["talentLevel"] = $talent_arrange_kvs[$item["talentLevel"]];            $company_ids = array_filter(explode(",", $item["companyIds"]));            $tmp_companys = [];            for ($i = 0; $i < count($company_ids); $i++) {                $tmp_companys[] = $companys[$company_ids[$i]];            }            $item["companyNames"] = implode(",", $tmp_companys);        }unset($item);        return ["total" => $count, "rows" => $list];    }}
 |