Volunteer.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use liuniu\UtilService;
  5. use think\Request;
  6. use app\common\model\Volunteer as VolunteerModel;
  7. class Volunteer extends Api
  8. {
  9. protected $noNeedRight = ['*'];
  10. public function apply(Request $request)
  11. {
  12. $where = UtilService::postMore(
  13. [
  14. ['name',''],
  15. ['phone',''],
  16. ['sex',0],
  17. ['birth',''],
  18. ['image',''],
  19. ['certificateimage',''],
  20. ['email',''],
  21. ['address',''],
  22. ['work',''],
  23. ['specialty',''],
  24. ['education',0],
  25. ['is_vol',0],
  26. ['volunteer_id',0],
  27. ['is_experience',0],
  28. ['start_hour',7],
  29. ['end_hour',22],
  30. ['work_week','1'],
  31. ['taste',''],
  32. ['taste_title',''],
  33. ['speciali',''],
  34. ['speciali_title',''],
  35. ],$request
  36. );
  37. if($where['name']=='')$this->error('姓名不能为空');
  38. if($where['phone']=='')$this->error('电话不能为空');
  39. if($where['address']=='')$this->error('地址信息不能为空');
  40. if($where['image']=='')$this->error('照片不能为空');
  41. if($where['birth']=='')$this->error('生日不能为空');
  42. $where['cid'] = $this->cid;
  43. $where['user_id'] = $this->auth->getUserinfo()['id'];
  44. if(VolunteerModel::where('user_id',$where['user_id'])->where('status','>',-1)->find()) $this->error('已经存,不能重复申请');
  45. if(!VolunteerModel::create($where))
  46. {
  47. $this->error(RescueModel::getErrorInfo());
  48. }
  49. $this->success('创建成功');
  50. }
  51. public function lst()
  52. {
  53. $this->success('获取成功',VolunteerModel::where('cid',$this->cid)->where('user_id',$this->auth->getUserinfo()['id'])->select());
  54. }
  55. }