12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace app\common\api;
- use app\common\model\TalentCondition;
- /**
- * Description of TalentConditionApi
- *
- * @author sgq
- */
- class TalentConditionApi {
- public static function getList($lv, $type, $cat) {
- $where[] = ["talentLevelCat", "=", $cat];
- $where[] = ["talentLevel", "=", $lv];
- $where[] = ["type", "=", $type];
- $where[] = ["active", "=", 1];
- $where[] = ["delete", "=", 0];
- 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];
- }
- }
|