MasterController.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\BaseController;
  4. use App\Http\Validator\MasterValidator;
  5. use App\Services\MasterService;
  6. use Illuminate\Http\Request;
  7. /**
  8. * 法师控制器类
  9. * @author wesmiler
  10. * @since 2020/11/10
  11. * Class MasterController
  12. * @package App\Http\Controllers
  13. */
  14. class MasterController extends BaseController
  15. {
  16. /**
  17. * 构造函数
  18. * @author wesmiler
  19. * @since 2020/11/11
  20. * MasterController constructor.
  21. */
  22. public function __construct()
  23. {
  24. parent::__construct();
  25. $this->service = new MasterService();
  26. }
  27. /**
  28. * 获取用户信息
  29. * @return array|mixed
  30. */
  31. public function info(){
  32. $userId = request()->get('id', 0);
  33. $info = $this->service->getUserInfo($userId, $this->userId);
  34. return message(MESSAGE_OK,true, $info);
  35. }
  36. /**
  37. * 咨询记录
  38. * @return array
  39. */
  40. public function advice(){
  41. return $this->service->advice($this->userId);
  42. }
  43. /**
  44. * 打分
  45. * @return array
  46. */
  47. public function score(){
  48. return $this->service->score($this->userId);
  49. }
  50. /**
  51. * 法师申请
  52. * @param MasterValidator $validator
  53. * @return array
  54. */
  55. public function apply(MasterValidator $validator){
  56. $params = $validator->check(request()->all(),'save');
  57. if(!is_array($params)){
  58. return message($params, false);
  59. }
  60. return $this->service->apply($this->userId);
  61. }
  62. /**
  63. * 法师列表
  64. * @return mixed
  65. */
  66. public function index(){
  67. return $this->service->getDataList($this->userId);
  68. }
  69. }