CmsContentTemplateSetRepository.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. namespace App\Repositories;
  3. use App\Models\CmsContentTemplateSet;
  4. use Symfony\Component\HttpKernel\Exception\HttpException;
  5. class CmsContentTemplateSetRepository {
  6. public function __construct(CmsContentTemplateSet $cmsContentTemplateSet) {
  7. $this->cmsContentTemplateSet = $cmsContentTemplateSet;
  8. }
  9. /**
  10. * banner配置
  11. */
  12. public function bannerSet($request)
  13. {
  14. $rules = json_decode($request['rule'],true);
  15. if (is_array($rules)){
  16. if (count($rules)>10) {
  17. throw new HttpException(500, '最多只能添加10个banner海报');
  18. }
  19. $subject = [
  20. 'tpl_id' => $request['tpl_id'],
  21. 'rule' => $request['rule'],
  22. 'area_type' => $request['area_type'],
  23. 'status' => $request['status'],
  24. ];
  25. if (!$this->cmsContentTemplateSet->create($subject)) {
  26. throw new HttpException(500, '添加失败');
  27. }
  28. }else{
  29. throw new HttpException(500, '参数格式有误');
  30. }
  31. }
  32. /**
  33. * 专题广告配置
  34. */
  35. public function advertisementSet($request)
  36. {
  37. $rules = json_decode($request['rule'],true);
  38. if (is_array($rules)){
  39. $subject = [
  40. 'tpl_id' => $request['tpl_id'],
  41. 'rule' => $request['rule'],
  42. 'area_type' => $request['area_type'],
  43. 'status' => $request['status'],
  44. ];
  45. if (!$this->cmsContentTemplateSet->create($subject)) {
  46. throw new HttpException(500, '添加失败');
  47. }
  48. }else{
  49. throw new HttpException(500, '参数格式有误');
  50. }
  51. }
  52. /**
  53. * 商品楼层配置
  54. */
  55. public function floorSet($request)
  56. {
  57. $rules = json_decode($request['rule'],true);
  58. if (is_array($rules)){
  59. $subject = [
  60. 'tpl_id' => $request['tpl_id'],
  61. 'rule' => $request['rule'],
  62. 'area_type' => $request['area_type'],
  63. 'status' => $request['status'],
  64. ];
  65. if (!$this->cmsContentTemplateSet->create($subject)) {
  66. throw new HttpException(500, '添加失败');
  67. }
  68. }else{
  69. throw new HttpException(500, '参数格式有误');
  70. }
  71. }
  72. /**
  73. * 分类专题配置
  74. */
  75. public function categorySet($request)
  76. {
  77. $rules = json_decode($request['rule'],true);
  78. if (is_array($rules)){
  79. $subject = [
  80. 'tpl_id' => $request['tpl_id'],
  81. 'rule' => $request['rule'],
  82. 'area_type' => $request['area_type'],
  83. 'status' => $request['status'],
  84. ];
  85. if (!$this->cmsContentTemplateSet->create($subject)) {
  86. throw new HttpException(500, '添加失败');
  87. }
  88. }else{
  89. throw new HttpException(500, '参数格式有误');
  90. }
  91. }
  92. }