抖音小程序

AdController.php 760B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\Controllers\Controller;
  4. use App\Service\AdService;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Validation\Rule;
  7. class AdController extends Controller
  8. {
  9. public function getAdPlacement(Request $request) {
  10. $validator = \Validator::make($request->all(),[
  11. 'app_id' => 'required|string',
  12. 'type' => ['nullable', Rule::in([1, 2, 3, 4, 5, 6])],
  13. ]);
  14. if ($validator->fails()) {
  15. return self::returnValue($validator->getMessageBag(), 1102);
  16. }
  17. $appId = $request->input('app_id');
  18. $type = $request->input('type', 2);
  19. $data = AdService::getAdPlacement($appId, $type);
  20. return self::returnValue($data);
  21. }
  22. }