MemberController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\BaseController;
  4. use App\Http\Validator\MemberValidator;
  5. use App\Http\Validator\YigongValidator;
  6. use App\Services\MemberService;
  7. use App\Services\YigongService;
  8. use Illuminate\Http\Request;
  9. /**
  10. * 会员控制器类
  11. * @author wesmiler
  12. * @since 2020/11/10
  13. * Class MemberController
  14. * @package App\Http\Controllers
  15. */
  16. class MemberController extends BaseController
  17. {
  18. /**
  19. * 构造函数
  20. * @author wesmiler
  21. * @since 2020/11/11
  22. * MemberController constructor.
  23. */
  24. public function __construct()
  25. {
  26. parent::__construct();
  27. $this->service = new MemberService();
  28. $this->yigongService = new YigongService();
  29. }
  30. /**
  31. * 获取用户信息
  32. * @return array|mixed
  33. */
  34. public function info(){
  35. $info = $this->service->getUserInfo(['m.id'=> $this->userId],'',1);
  36. return message(MESSAGE_OK,true, $info);
  37. }
  38. /**
  39. * 保存资料
  40. * @param MemberValidator $validator
  41. * @return array
  42. */
  43. public function saveInfo(MemberValidator $validator){
  44. $params = $validator->check(request()->all(),'save');
  45. if(!is_array($params)){
  46. return message($params, false);
  47. }
  48. return $this->service->saveInfo($this->userId);
  49. }
  50. /**
  51. * 加入会员
  52. * @return array
  53. */
  54. public function vip(){
  55. return $this->service->buyVip($this->userId);
  56. }
  57. /**
  58. * 签到
  59. * @return mixed
  60. */
  61. public function sign(){
  62. return $this->service->sign($this->userId);
  63. }
  64. /**
  65. * 功德榜
  66. * @return array
  67. */
  68. public function gdList(){
  69. return $this->service->gdList($this->userId);
  70. }
  71. /**
  72. * 关注
  73. * @return array
  74. */
  75. public function follow(){
  76. return $this->service->follow($this->userId);
  77. }
  78. /**
  79. * 关注列表
  80. * @return array
  81. */
  82. public function followList(){
  83. return $this->service->followList($this->userId);
  84. }
  85. /**
  86. * 义工申请信息
  87. * @return mixed
  88. */
  89. public function yigong(){
  90. return $this->yigongService->info($this->userId);
  91. }
  92. /**
  93. * 申请成为义工
  94. * @param Request $request
  95. * @param YigongValidator $validate
  96. * @return array
  97. */
  98. public function yigongApply(Request $request, YigongValidator $validate){
  99. $params = $validate->check($request->all(),'books');
  100. if(!is_array($params)){
  101. return message($params, false);
  102. }
  103. return $this->yigongService->apply($this->userId);
  104. }
  105. /**
  106. * 注销账号
  107. */
  108. public function logout(){
  109. return $this->service->logout($this->userId);
  110. }
  111. }