TalentApi.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace app\enterprise\api;
  3. use app\enterprise\model\Talent;
  4. /**
  5. * Description of TalentApi
  6. *
  7. * @author sgq
  8. */
  9. class TalentApi {
  10. public static function getList($request) {
  11. $order = trim($request->param("order")) ?: "desc";
  12. $offset = trim($request->param("offset")) ?: 0;
  13. $limit = trim($request->param("limit")) ?: 10;
  14. $name = trim($request->param("name"));
  15. $idCard = trim($request->param("idCard"));
  16. $sex = trim($request->param("sex"));
  17. $nation = trim($request->param("nation"));
  18. $nationality = trim($request->param("nationality"));
  19. $talentType = trim($request->param("talentType"));
  20. $talentArrange = trim($request->param("talentArrange"));
  21. $checkState = trim($request->param("checkState"));
  22. $where = [];
  23. if ($name) {
  24. $where[] = ["name", "like", "%" . $name . "%"];
  25. }
  26. if ($idCard) {
  27. $where[] = ["idCard", "like", "%" . $idCard . "%"];
  28. }
  29. if ($sex) {
  30. $where[] = ["sex", $sex];
  31. }
  32. if ($nation) {
  33. $where[] = ["nation", $nation];
  34. }
  35. if ($nationality) {
  36. $where[] = ["nationality", $nationality];
  37. }
  38. if ($talentType) {
  39. $where[] = ["talentType", $talentType];
  40. }
  41. if ($talentArrange) {
  42. $where[] = ["name", $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 = \app\common\api\DictApi::selectByParentCode("un_jbt_talentType");//人才标签
  69. foreach($list as $key=>$list){
  70. $list[$key]["talentArrangeName"]='';
  71. $list[$key]["talentTypeName"]='';
  72. $list[$key]["identifyConditionName"]='';
  73. }
  74. return ["total" => $count, "rows" => $list];
  75. }
  76. }