TalentApi.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace app\enterprise\api;
  3. use app\enterprise\model\Talent;
  4. use app\common\api\DictApi;
  5. /**
  6. * Description of TalentApi
  7. *
  8. * @author sgq
  9. */
  10. class TalentApi {
  11. public static function getList($request) {
  12. $order = trim($request->param("order")) ?: "desc";
  13. $offset = trim($request->param("offset")) ?: 0;
  14. $limit = trim($request->param("limit")) ?: 10;
  15. $name = trim($request->param("name"));
  16. $idCard = trim($request->param("card_number"));
  17. $sex = trim($request->param("sex"));
  18. $nation = trim($request->param("nation"));
  19. $nationality = trim($request->param("nationality"));
  20. $talentArrange = trim($request->param("talent_arrange"));
  21. $checkState = trim($request->param("checkState"));
  22. $where = [];
  23. if (session("user")["usertype"] == 2) {
  24. $where[] = ["enterprise_id", "=", session("user")["uid"]];
  25. }
  26. if ($name) {
  27. $where[] = ["name", "like", "%" . $name . "%"];
  28. }
  29. if ($idCard) {
  30. $where[] = ["card_number", "like", "%" . $idCard . "%"];
  31. }
  32. if ($sex) {
  33. $where[] = ["sex", $sex];
  34. }
  35. if ($nation) {
  36. $where[] = ["nation", $nation];
  37. }
  38. if ($nationality) {
  39. $where[] = ["nationality", $nationality];
  40. }
  41. if ($talentArrange) {
  42. $where[] = ["talent_arrange", $talentArrange];
  43. }
  44. if ($checkState) {
  45. switch ($checkState) {
  46. case -1:
  47. $where[] = [["checkState", $checkState], ["isPublic", ">=", 5]];
  48. break;
  49. case 1:
  50. $where[] = [["checkState", $checkState]];
  51. break;
  52. case 2:
  53. $where[] = [["checkState", "in", "5,10"]];
  54. break;
  55. case 3:
  56. $where[] = [["checkState", "not in", "1,5,10"], ["isPublic", "<", 5]];
  57. break;
  58. case 4:
  59. $where[] = [["checkState", 35], ["isPublic", ">=", 5]];
  60. break;
  61. }
  62. }
  63. if ($request->param("type") == 2) {
  64. $where[] = [["checkState", 35], ["isPublic", 6]];
  65. }
  66. $count = Talent::where($where)->count();
  67. $list = Talent::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
  68. $talentTypeList = DictApi::selectByParentCode("enterprise_tag"); //人才标签
  69. $talentArangeList = DictApi::selectByParentCode("talent_arrange"); //人才层次
  70. //$talentTypeNameList = DictApi::selectByParentCode("un_talentLevel");//认定条件
  71. //DictApi::selectByParentCode($code);
  72. foreach ($list as $key => $item) {
  73. $list[$key]["talentArrangeName"] = isset($talentArangeList[$item["talent_arrange"]]) ? $talentArangeList[$item["talent_arrange"]] : "";
  74. $list[$key]["identifyConditionText"] = "";
  75. }
  76. return ["total" => $count, "rows" => $list];
  77. }
  78. }