TalentApi.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. namespace app\enterprise\api;
  3. use app\enterprise\model\Talent;
  4. use app\common\api\DictApi;
  5. use app\common\api\TalentConditionApi;
  6. /**
  7. * Description of TalentApi
  8. *
  9. * @author sgq
  10. */
  11. class TalentApi {
  12. /**
  13. * 判断是否可以编辑
  14. * @param type $id
  15. * @return boolean
  16. */
  17. public static function checkIsEditable($id) {
  18. $info = Talent::findOrEmpty($id);
  19. if (!$info || !in_array($info["checkState"], [0, 1, 3, 5]))
  20. return false;
  21. return true;
  22. }
  23. public static function getOne($id) {
  24. return Talent::findOrEmpty($id);
  25. }
  26. public static function getList($request) {
  27. $order = trim($request->param("order")) ?: "desc";
  28. $offset = trim($request->param("offset")) ?: 0;
  29. $limit = trim($request->param("limit")) ?: 10;
  30. $name = trim($request->param("name"));
  31. $idCard = trim($request->param("card_number"));
  32. $sex = trim($request->param("sex"));
  33. $nation = trim($request->param("nation"));
  34. $nationality = trim($request->param("nationality"));
  35. $talentArrange = trim($request->param("talent_arrange"));
  36. $checkState = trim($request->param("checkState"));
  37. $type = session("user")["type"];
  38. $where = [];
  39. $where[] = ["delete", "=", 0];
  40. if (session("user")["usertype"] == 2) {
  41. $where[] = ["enterprise_id", "=", session("user")["uid"]];
  42. }
  43. if ($name) {
  44. $where[] = ["name", "like", "%" . $name . "%"];
  45. }
  46. if ($idCard) {
  47. $where[] = ["card_number", "like", "%" . $idCard . "%"];
  48. }
  49. if ($sex) {
  50. $where[] = ["sex", $sex];
  51. }
  52. if ($nation) {
  53. $where[] = ["nation", $nation];
  54. }
  55. if ($nationality) {
  56. $where[] = ["nationality", $nationality];
  57. }
  58. if ($talentArrange) {
  59. $where[] = ["talent_arrange", $talentArrange];
  60. }
  61. if ($checkState) {
  62. switch ($checkState) {
  63. case -1:
  64. $where[] = [["checkState", $checkState], ["isPublic", ">=", 5]];
  65. break;
  66. case 1:
  67. $where[] = [["checkState", $checkState]];
  68. break;
  69. case 2:
  70. $where[] = [["checkState", "in", "5,10"]];
  71. break;
  72. case 3:
  73. $where[] = [["checkState", "not in", "1,5,10"], ["isPublic", "<", 5]];
  74. break;
  75. case 4:
  76. $where[] = [["checkState", 35], ["isPublic", ">=", 5]];
  77. break;
  78. }
  79. }
  80. if ($request->param("type") == 2) {
  81. $where[] = [["checkState", 35], ["isPublic", 6]];
  82. }
  83. $count = Talent::where($where)->count();
  84. $list = Talent::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
  85. $talentTagList = DictApi::selectByParentCode("enterprise_tag"); //单位标签
  86. $talentArangeList = DictApi::selectByParentCode("talent_arrange"); //人才层次
  87. $enterprise = \app\common\model\Enterprise::find(session("user")["uid"]);
  88. //DictApi::selectByParentCode($code);
  89. foreach ($list as $key => $item) {
  90. $condition = TalentConditionApi::getOne($item["talent_condition"]);
  91. $list[$key]["talentArrangeName"] = isset($talentArangeList[$item["talent_arrange"]]) ? $talentArangeList[$item["talent_arrange"]] : "";
  92. $list[$key]["identifyConditionText"] = $condition["name"];
  93. $list[$key]["companyIds"] = $condition["companyIds"];
  94. $list[$key]["type"] = $enterprise["type"];
  95. $list[$key]["enterpriseTagName"] = $talentTagList[$enterprise["enterpriseTag"]];
  96. }
  97. return ["total" => $count, "rows" => $list];
  98. }
  99. }