/** * Logs in a user using the provided username and password. * * @return boolean whether the user is logged in successfully */ public function login() { // if ($this->validate()) { // return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0); // } else { // return false; // } $user = $this->getUser(); if (!$user) { return Message::say(Message::E_ERROR, null, "用户名不存在"); } return Message::say(Message::E_OK, $user, "登录成功"); }
public function actionUpdate() { $params = yii::$app->request->getBodyParams(); if (empty($params['applicant_id'])) { return Message::say(Message::E_ERROR, null, "用户id不能为空"); } $model = $this->modelClass; $applicant = $model::findOne(yii::$app->getRequest()->post('applicant_id')); $applicant_edu = $params['applicant_edu']; if ($applicant_edu != null) { $applicant->applicant_edu = $applicant_edu; } if ($applicant->save()) { return Message::say(Message::E_OK, $applicant, "修改成功"); } else { return Message::say(Message::E_ERROR, null, "修改失败"); } }
public function actionQunfa() { $type = yii::$app->getRequest()->getQueryParam('type'); $data = yii::$app->getRequest()->getBodyParams(); $mobiles = explode(',', $data['mobiles']); $mobiles = array_chunk($mobiles, 100); $reason = $data['reason']; $startime = $data['startime']; $endtime = $data['endtime']; $where = $data['where']; $from = $data['from']; $sms = new Sms(); switch ($type) { //停电 case 'td': $sms->tempid = "MB-2015011907"; break; //停水 //停水 case 'ts': $sms->tempid = "MB-2015011948"; break; //电梯维修 //电梯维修 case 'dtwx': $sms->tempid = "MB-2015011928"; break; default: $sms->tempid = ""; break; } $template = '@1@=%s,@2@=%s,@3@=%s,@4@=%s,@5@=%s'; $content = sprintf($template, $reason, $where, $startime, $endtime, $from); static $error = 0; foreach ($mobiles as $m) { $mobile = implode(',', $m); $return = $sms->post(['mobile' => $mobile, 'content' => $content]); $error += $return['error']; } return Message::say(Message::E_OK, $error, "发送成功"); }
public function actionFavourite() { $params = yii::$app->request->getBodyParams(); $flag = $params['flag']; $recruitment_id = $params['recruitment_id']; $applicant_id = $params['applicant_id']; if (!isset($flag)) { return Message::say(Message::E_ERROR, null, "字段错误"); } if (empty($recruitment_id)) { return Message::say(Message::E_ERROR, null, "招聘id不能为空"); } if (empty($applicant_id)) { return Message::say(Message::E_ERROR, null, "用户id不能为空"); } //先找出该用户、该招聘是否有收藏过 // $model=new Favourites(); $favourite = Favourites::find()->andWhere('applicant_id=:aID', [':aID' => $applicant_id])->andWhere('recruitment_id=:rID', [':rID' => $recruitment_id])->one(); // return Message::say(Message::E_OK,$favourite,"ok"); //判断用户是要收藏,还是要取消 if ($flag == 0) { //取消收藏 if ($favourite !== null) { $favourite->delete(); return Message::say(Message::E_OK, null, "取消收藏"); } return Message::say(Message::E_ERROR, null, "取消失败"); } else { if ($flag == 1) { //添加收藏 if ($favourite) { return Message::say(Message::E_ERROR, null, "不能重复收藏"); } $model = new $this->modelClass(); $model->applicant_id = $applicant_id; $model->recruitment_id = $recruitment_id; if ($model->save()) { return Message::say(Message::E_OK, $model, "收藏成功"); } return Message::say(Message::E_ERROR, null, "收藏失败"); } else { return Message::say(Message::E_ERROR, null, "操作失败"); } } }
public function actionBusinessupdate() { return Message::say(Message::E_OK, null, "ok"); }
public function userReg($mobile, $devisetoken, $access_token) { $params = Yii::$app->request->getBodyParams(); $acc_type = $params['type']; if ($acc_type == 0) { //求职人员 $model = new Applicants(); $model->applicant_nickname = $mobile; if ($model->validate() && $model->save()) { if ($this->saveAccount($model)) { return $model; } else { $model->delete(); } } } else { if ($acc_type == 1) { //商家 $model = new Business(); $model->business_name = $mobile; $model->business_contactor_mobile = $mobile; $model->province_id = $params['province_id']; $model->province_name = $params['province_name']; $model->city_id = $params['city_id']; $model->city_name = $params['city_name']; $model->district_id = $params['district_id']; $model->district_name = $params['district_name']; $model->district_detail = $params['district_detail']; if ($model->validate() && $model->save()) { if ($this->saveAccount($model)) { return $model; } else { $model->delete(); } } else { return Message::say(Message::E_ERROR, null, "字段错误"); } } } return null; }
public function actionCreate() { $params = yii::$app->request->getBodyParams(); if (empty($params['business_id'])) { return Message::say(Message::E_ERROR, null, "商家id不能为空"); } if (empty($params['applicant_id'])) { return Message::say(Message::E_ERROR, null, "求职者id不能为空"); } if (!isset($params['recruitment_id'])) { return Message::say(Message::E_ERROR, null, "招聘id不能为空"); } if (empty($params['application_text'])) { return Message::say(Message::E_ERROR, null, "应聘内容不能为空"); } $model = new $this->modelClass(); $model->load(Yii::$app->getRequest()->getBodyParams(), ''); if ($model->validate() && $model->save()) { return Message::say(Message::E_OK, $model, "发布应聘成功"); } else { return Message::say(Message::E_ERROR, null, "发布应聘失败"); } }
protected function findModel($id) { $model = Recruitments::find()->where('recruitment_id=:id', [':id' => $id])->one(); if ($model !== null) { return $model; } else { // throw new NotFoundHttpException('您访问的事件没有找到'); return Message::say(Message::E_ERROR, null, "该招聘不存在"); } }
public function actionApplicationstate() { $params = yii::$app->request->getBodyParams(); if (!isset($params['application_id'])) { return Message::say(Message::E_ERROR, null, "应聘id不能为空"); } if (!isset($params['application_state'])) { return Message::say(Message::E_ERROR, null, "应聘状态不能为空"); } $application = Applications::findOne($params['application_id']); if ($application == null) { return Message::say(Message::E_ERROR, null, "该应聘不存在"); } $application->application_state = $params['application_state']; if ($application->save()) { return Message::say(Message::E_OK, null, "修改成功"); } return Message::say(Message::E_ERROR, null, "修改失败"); }