BeanDetailController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App\Http\Controllers\V1;
  3. use App\Repositories\BeanRepository;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Support\Facades\Validator;
  6. use Illuminate\Validation\Rule;
  7. /**
  8. * Created by PhpStorm.
  9. * User: durong
  10. * Date: 2019/6/19
  11. * Time: 下午12:25
  12. */
  13. class BeanDetailController extends Controller
  14. {
  15. public function __construct(BeanRepository $beanRepository)
  16. {
  17. $this->beanRepository = $beanRepository;
  18. }
  19. //获取指定时间彩虹豆收支明细
  20. public function beanDetail(Request $request)
  21. {
  22. $validator = Validator::make($request->all(), [
  23. 'type' => ['required',Rule::in([0,1,2,3])],
  24. ]);
  25. if ($validator->fails()) {
  26. return $this->jsonError($validator->errors()->first());
  27. }
  28. $beanDetail = $this->beanRepository->beanDetail($request->all());
  29. if ($beanDetail){
  30. return $this->jsonSuccess($beanDetail);
  31. }else{
  32. return $this->jsonSuccess();
  33. }
  34. }
  35. //排行榜
  36. public function rankingList(Request $request)
  37. {
  38. $validator = Validator::make($request->all(), [
  39. 'type' => ['required',Rule::in([0,1, 2])],
  40. ]);
  41. if ($validator->fails()) {
  42. return $this->jsonError($validator->errors()->first());
  43. }
  44. $top_most = $this->beanRepository->rankingList($request->all());
  45. if ($top_most){
  46. return $this->jsonSuccess($top_most);
  47. }else{
  48. return $this->jsonSuccess();
  49. }
  50. }
  51. //星球首页
  52. public function starHome(Request $request)
  53. {
  54. $star_home = $this->beanRepository->starHome($request->all());
  55. if ($star_home){
  56. return $this->jsonSuccess($star_home);
  57. }else{
  58. return $this->jsonSuccess();
  59. }
  60. }
  61. }