TalentApi.php 3.4 KB

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