<?php namespace app\mobile\controller; use think\Db; use app\common\controller\Api; use app\mobile\model\UserJobBanner; use app\mobile\model\CompanyJob; use app\mobile\model\CompanyJobResume; /** * 求职接口 * @ApiWeigh (91) */ class UserJob extends Api { protected $noNeedLogin = ['*']; protected $noNeedRight = ['*']; protected $model = null; public function _initialize() { parent::_initialize(); $this->model = model('app\mobile\model\UserJob'); } /** * @ApiTitle (求职-轮播图) * @ApiSummary (求职-轮播图) * @ApiMethod (POST) * * @ApiReturn({ "code": 1, "msg": "成功", "time": "1599907184", "data": [{ "id": 1, // 轮播图ID "image": "https://img02.mockplus.cn/idoc/sketch/2020-08-06/006324c3-e5d3-4206-be48-52a7c7468e74.7C1FC40C-CED5-4B08-9506-3E48A2732B2C.png", // 图片地址 "user_job_id": 1, // 求职ID }] }) */ public function banner() { $list = UserJobBanner::order('createtime desc') ->field('id,image,user_job_id') ->select(); $this->success('成功',$list); } /** * @ApiWeigh (99) * @ApiTitle (求职-首页) * @ApiSummary (求职-首页) * @ApiMethod (POST) * * @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)") * @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)") * @ApiParams (name="keyword", type="string", required=false, description="输入岗位名称") * @ApiParams (name="type", type="inter", required=false, description="岗位类型:1=全职,2=兼职,3=其他") * * @ApiReturn({ "code": 1, "msg": "成功", "time": "1599017563", "data": "用户协议内容" //协议内容 }) */ public function index() { $page = $this->request->param('page', 1, 'intval'); $page_num = $this->request->param('page_num', 10, 'intval'); $keyword = $this->request->param('keyword'); $type = $this->request->param('type'); $where = []; // 搜索关键词 if(!empty($keyword)){ $where['name'] = ['like','%'.$keyword.'%']; } // 求职类型 if(!empty($type)){ $where['type'] = $type; } $data = CompanyJob::where($where) ->field('id,name,salary,address') ->order('createtime desc') ->paginate($page_num,false,['page'=>$page]) ->toArray(); $this->success('注册成功', $data); } /** * @ApiWeigh (99) * @ApiTitle (求职-详情) * @ApiSummary (求职-详情) * @ApiMethod (POST) * * @ApiParams (name="company_job_id", type="inter", required=false, description="招聘职位ID") * * @ApiReturn({ "code": 1, "msg": "成功", "time": "1599017563", "data": "用户协议内容" //协议内容 }) */ public function info() { $company_job_id = $this->request->param('company_job_id'); empty($company_job_id) && $this->error('缺少必需参数'); $info = CompanyJob::get($company_job_id); empty($info) && $this->error('招聘信息不存在'); $this->success('成功', $info); } /** * @ApiWeigh (93) * @ApiTitle (投递简历) * @ApiSummary (投递简历) * @ApiMethod (POST) * * @ApiParams (name="company_job_id", type="inter", required=false, description="招聘职位ID") * @ApiParams (name="user_resume_id", type="inter", required=false, description="求职简历ID") * * @ApiReturn({ "code": 1, "msg": "成功", "time": "1599017563", "data": null }) */ public function sendResume() { $company_job_id = $this->request->param('company_job_id'); $user_resume_id = $this->request->param('user_resume_id'); if(!$company_job_id || $user_resume_id){ $this->error('缺少必需参数'); } CompanyJobResume::create([ 'company_job_id' => $company_job_id, 'user_resume_id' => $user_resume_id ]); $this->success('投递成功'); } /** * @ApiWeigh (91) * @ApiTitle (发布求职) * @ApiSummary (发布求职) * @ApiMethod (POST) * * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") * @ApiParams (name="name", type="string", required=true, description="岗位名称") * @ApiParams (name="type", type="string", required=true, description="岗位类型:1=全职,2=兼职,3=其他") * @ApiParams (name="mobile", type="string", required=true, description="手机号") * @ApiParams (name="start_time", type="string", required=true, description="开始工作日期") * @ApiParams (name="end_time", type="string", required=true, description="结束工作日期") * @ApiParams (name="salary", type="string", required=true, description="薪资待遇") * @ApiParams (name="address", type="string", required=true, description="期望工作地点") * @ApiParams (name="user_job_ability_ids", type="string", required=true, description="资质能力") * @ApiParams (name="qualification", type="string", required=true, description="资质证明(多文件用英文逗号隔开)") * @ApiParams (name="user_resume_id", type="string", required=true, description="简历ID") * * @ApiReturn({ "code": 1, "msg": "登录成功", "time": "1600498819", "data": null }) */ public function addJob() { $post = $this->request->param(); empty($post['name']) && $this->error('请输入岗位名称'); empty($post['type']) && $this->error('请选择岗位类型'); empty($post['mobile']) && $this->error('请输入手机号'); empty($post['start_time']) && $this->error('请选择开始工作日期'); empty($post['end_time']) && $this->error('请选择结束工作日期'); empty($post['salary']) && $this->error('请输入薪资待遇'); empty($post['address']) && $this->error('请输入期望工作地点'); empty($post['user_job_ability_ids']) && $this->error('请选择资质能力'); empty($post['user_resume_id']) && $this->error('请选择简历'); $this->model->allowField(true)->save(array_merge([ 'user_id' => $this->auth->id ],$post)); $this->success('发布求职成功'); } }