MasterController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 adviceList(){
  48. return $this->service->adviceList($this->userId);
  49. }
  50. /**
  51. * 打分
  52. * @return array
  53. */
  54. public function score(){
  55. return $this->service->score($this->userId);
  56. }
  57. /**
  58. * 法师申请
  59. * @param MasterValidator $validator
  60. * @return array
  61. */
  62. public function apply(MasterValidator $validator){
  63. $params = $validator->check(request()->all(),'save');
  64. if(!is_array($params)){
  65. return message($params, false);
  66. }
  67. return $this->service->apply($this->userId);
  68. }
  69. /**
  70. * 法师列表
  71. * @return mixed
  72. */
  73. public function index(){
  74. return $this->service->getDataList($this->userId);
  75. }
  76. }