|
@@ -0,0 +1,89 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Http\Controllers\Api\Soldier;
|
|
|
+
|
|
|
+use App\Http\Controllers\Api\ApiBaseController;
|
|
|
+use App\Models\Category;
|
|
|
+use App\Models\CategoryJobs;
|
|
|
+use App\Models\Jobs;
|
|
|
+use App\Models\JobsContact;
|
|
|
+use Illuminate\Http\Request;
|
|
|
+
|
|
|
+class JobController extends ApiBaseController
|
|
|
+{
|
|
|
+
|
|
|
+ public function getSoldierJobList(Request $request)
|
|
|
+ {
|
|
|
+ $page = $request->input('page', 1);
|
|
|
+ $limit = $request->input('limit', 10);
|
|
|
+ $update_at = $request->input('update_time', '');
|
|
|
+
|
|
|
+ $where = [
|
|
|
+ ['valid', '=', 1],
|
|
|
+ ['company_audit', '=', 1],
|
|
|
+ ['audit', '=', 1],
|
|
|
+ ['display', '=', 1],
|
|
|
+ ['is_soldier', '=', 1],
|
|
|
+ ];
|
|
|
+ if (!empty($update_at)) {
|
|
|
+ $where[] = ['updated_at', '>', $update_at];
|
|
|
+ }
|
|
|
+
|
|
|
+ $list = Jobs::select('id', 'jobs_name', 'company_name', 'nature', 'sex', 'age', 'amount', 'topclass', 'category', 'subclass', 'trade', 'scale', 'tag', 'education', 'experience', 'wage', 'wage_max', 'negotiable', 'wage_min', 'wage_str', 'jobs_content', 'department', 'created_at', 'updated_at')
|
|
|
+ ->where($where)
|
|
|
+ ->offset(($page - 1) * $limit)
|
|
|
+ ->limit($limit)
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ $ids = [];
|
|
|
+ $category = [];
|
|
|
+ $category_job = [];
|
|
|
+ $tag = [];
|
|
|
+ foreach ($list as $v) {
|
|
|
+ $ids[] = $v['id'];
|
|
|
+ $category[] = $v['nature'];
|
|
|
+ $category_job[] = $v['topclass'];
|
|
|
+ $category_job[] = $v['category'];
|
|
|
+ $category_job[] = $v['subclass'];
|
|
|
+ $category[] = $v['trade'];
|
|
|
+ $category[] = $v['scale'];
|
|
|
+ if (!empty($v['tag'][0])) {
|
|
|
+ $tag = array_merge($tag, $v['tag']);
|
|
|
+ }
|
|
|
+ $category[] = $v['education'];
|
|
|
+ $category[] = $v['experience'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $category = array_merge($category, $tag);
|
|
|
+ $contact_list = JobsContact::select('job_id', 'contact', 'telephone', 'email', 'address')->whereIn('job_id', $ids)->get()->keyBy('job_id')->toArray();
|
|
|
+ $category_list = Category::whereIn('id', array_unique($category))->pluck('demand', 'id')->toArray();
|
|
|
+ $category_job_list = CategoryJobs::whereIn('id', array_unique($category_job))->pluck('name', 'id')->toArray();
|
|
|
+
|
|
|
+ foreach ($list as $k => $v) {
|
|
|
+ $list[$k]['contact_name'] = $contact_list[$v['id']]['contact'];
|
|
|
+ $list[$k]['contact_telephone'] = $contact_list[$v['id']]['telephone'];
|
|
|
+ $list[$k]['contact_email'] = $contact_list[$v['id']]['email'];
|
|
|
+ $list[$k]['contact_address'] = $contact_list[$v['id']]['address'];
|
|
|
+ $list[$k]['nature'] = empty($category_list[$v['nature']]) ? '' : $category_list[$v['nature']];
|
|
|
+ $list[$k]['topclass'] = empty($category_job_list[$v['topclass']]) ? '' : $category_job_list[$v['topclass']];
|
|
|
+ $list[$k]['category'] = empty($category_job_list[$v['category']]) ? '' : $category_job_list[$v['category']];
|
|
|
+ $list[$k]['subclass'] = empty($category_job_list[$v['subclass']]) ? '' : $category_job_list[$v['subclass']];
|
|
|
+ $list[$k]['trade'] = empty($category_list[$v['trade']]) ? '' : $category_list[$v['trade']];
|
|
|
+ $list[$k]['scale'] = empty($category_list[$v['scale']]) ? '' : $category_list[$v['scale']];
|
|
|
+ $tags = [];
|
|
|
+ foreach ($v['tag'] as $tag) {
|
|
|
+ if (!empty($category_list[$tag])) {
|
|
|
+ $tags[] = $category_list[$tag];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $list[$k]['tag'] = $tags;
|
|
|
+ $list[$k]['education'] = empty($category_list[$v['education']]) ? '' : $category_list[$v['education']];
|
|
|
+ $list[$k]['experience'] = empty($category_list[$v['experience']]) ? '' : $category_list[$v['experience']];
|
|
|
+ $list[$k]['experience'] = empty($category_list[$v['experience']]) ? '' : $category_list[$v['experience']];
|
|
|
+ }
|
|
|
+
|
|
|
+ return response()->json($list);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|