HeadlineController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: hp
  5. * Date: 2017/11/20
  6. * Time: 16:17
  7. */
  8. namespace App\Http\Controllers\Channel\Promotion;
  9. use App\Http\Controllers\Channel\BaseController;
  10. use App\Http\Controllers\Channel\Promotion\Transformers\HeadlinelTransformer;
  11. use App\Modules\Promotion\Services\PromotionService;
  12. use DB;
  13. use Illuminate\Http\Request;
  14. class HeadlineController extends BaseController
  15. {
  16. /**
  17. * @apiDefine promotion 推广
  18. */
  19. /**
  20. * @apiVersion 1.0.0
  21. * @api {GET} promotion/headlines 获取推广标题列表
  22. * @apiGroup promotion
  23. * @apiName getPromotionHeadlines
  24. * @apiParam{String}type 类型(1:男频、2:女频)
  25. *
  26. * @apiSuccess {Number} id 标题ID.
  27. * @apiSuccess {String} title 标题内容.
  28. * @apiSuccessExample {json} Success-Response:
  29. *
  30. * {
  31. * "code": 0,
  32. * "msg": "",
  33. *
  34. * "data": [
  35. * {
  36. * "id": 1,
  37. * "title": "sfsd"
  38. * },
  39. * {
  40. * "id": 2,
  41. * "title": "sfsd"
  42. * }
  43. * ]
  44. * }
  45. */
  46. function getPromotionHeadlines(Request $request)
  47. {
  48. $type = $request->has('type') ? $request->input('type') : '';
  49. if (empty($type)) {
  50. return response()->error("PARAM_EMPTY");
  51. }
  52. $promotionHeadlinesResult = PromotionService::getAllHeadlines($type);
  53. return response()->collection(new HeadlinelTransformer(), $promotionHeadlinesResult);
  54. }
  55. }