TalentApi.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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("idCard"));
  17. $sex = trim($request->param("sex"));
  18. $nation = trim($request->param("nation"));
  19. $nationality = trim($request->param("nationality"));
  20. $talentType = trim($request->param("talentType"));
  21. $talentArrange = trim($request->param("talentArrange"));
  22. $checkState = trim($request->param("checkState"));
  23. $where = [];
  24. if ($name) {
  25. $where[] = ["name", "like", "%" . $name . "%"];
  26. }
  27. if ($idCard) {
  28. $where[] = ["idCard", "like", "%" . $idCard . "%"];
  29. }
  30. if ($sex) {
  31. $where[] = ["sex", $sex];
  32. }
  33. if ($nation) {
  34. $where[] = ["nation", $nation];
  35. }
  36. if ($nationality) {
  37. $where[] = ["nationality", $nationality];
  38. }
  39. if ($talentType) {
  40. $where[] = ["talentType", $talentType];
  41. }
  42. if ($talentArrange) {
  43. $where[] = ["name", $talentArrange];
  44. }
  45. if ($checkState) {
  46. switch ($checkState) {
  47. case -1:
  48. $where[] = [["checkState", $checkState], ["isPublic", ">=", 5]];
  49. break;
  50. case 1:
  51. $where[] = [["checkState", $checkState]];
  52. break;
  53. case 2:
  54. $where[] = [["checkState", "in", "5,10"]];
  55. break;
  56. case 3:
  57. $where[] = [["checkState", "not in", "1,5,10"], ["isPublic", "<", 5]];
  58. break;
  59. case 4:
  60. $where[] = [["checkState", 35], ["isPublic", ">=", 5]];
  61. break;
  62. }
  63. }
  64. if ($request->param("type") == 2) {
  65. $where[] = [["checkState", 35], ["isPublic", 6]];
  66. }
  67. $count = Talent::where($where)->count();
  68. $list = Talent::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
  69. $talentTypeList = DictApi::selectByParentCode("un_jbt_talentType"); //人才标签
  70. $talentArangeList = DictApi::selectByParentCode("un_talentLevel");//人才层次
  71. //$talentTypeNameList = DictApi::selectByParentCode("un_talentLevel");//认定条件
  72. //DictApi::selectByParentCode($code);
  73. foreach ($list as $key => $item) {
  74. $list[$key]["talentArrangeName"] = $talentArangeList[$item["talentArrange"]];
  75. $list[$key]["talentTypeName"] = $talentTypeList[$item["talentType"]];
  76. $list[$key]["identifyConditionText"] = "";
  77. }
  78. return ["total" => $count, "rows" => $list];
  79. }
  80. }