Report.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\model\ArticleComment;
  4. use app\common\model\ArticleIntro;
  5. use app\common\model\DatumComment;
  6. use app\common\model\DatumIntro;
  7. use app\common\model\ReportCase;
  8. use app\common\model\User;
  9. use app\common\model\UserForum;
  10. use app\common\model\UserReport;
  11. use app\common\model\VideoComment;
  12. use app\common\model\VideoIntro;
  13. use library\tools\Data;
  14. /**
  15. * @title 举报
  16. * @controller Report
  17. * @group base
  18. */
  19. class Report extends Base
  20. {
  21. public function initialize()
  22. {
  23. parent::initialize();
  24. parent::checkLogin();
  25. }
  26. /**
  27. * @title 获取举报类目
  28. * @desc 获取举报类目(共两级)
  29. * @author qc
  30. * @url /api/Report/getReportCase
  31. * @method GET
  32. * @header name:Authorization require:1 desc:Token
  33. * @return name:id type:int default:-- desc:id
  34. * @return name:title type:string default:0 desc:名称
  35. * @return name:children type:array default:0 desc:下级分类
  36. */
  37. public function getReportCase()
  38. {
  39. $list = ReportCase::where(['is_deleted'=>0])->field('id,title,pid')->order('sort desc')->select()->toArray();
  40. $list = make_tree($list);
  41. $this->success('ok',['list'=>$list]);
  42. }
  43. /**
  44. * @title 用户举报
  45. * @desc 用户举报
  46. * @author qc
  47. * @url /api/Report/userReport
  48. * @method POST
  49. * @header name:Authorization require:1 desc:Token
  50. * @param name:type type:int default:1 desc:举报类型(1视频2视频评论3会员,4资料,5图文6问题,7新闻8图文评论9新闻评论,10资料评论,11问题的回答,12问题||回答评论举报,13=>供应商产品,14供应商产品评论,15活动,16需求,17需求评论,18需求)
  51. * @param name:report_id type:int default:-- desc:举报内容的id
  52. * @param name:case_ids type:string default:-- desc:举报类目id串(逗号隔开)
  53. * @param name:content type:string default:-- desc:举报内容
  54. */
  55. public function userReport()
  56. {
  57. $type= input('post.type',1);
  58. $report_id = input('post.report_id');
  59. $case_ids = input('post.case_ids');
  60. $content = input('post.content');
  61. if(!$report_id) $this->error('请现在举报内容');
  62. if(!$case_ids) $this->error('请选择举报原因');
  63. //if(in_array($type,[2]) && !$content) $this->error('请输入举报内容');
  64. switch ($type)
  65. {
  66. case 1:
  67. $check_id = VideoIntro::where('id',$report_id)->value('id');
  68. if(!$check_id) $this->error('视频不存在');
  69. break;
  70. case 2:
  71. $check_id = VideoComment::where('id',$report_id)->value('id');
  72. if(!$check_id) $this->error('视频评论不存在');
  73. break;
  74. case 3:
  75. $check_id = User::where('id',$report_id)->value('id');
  76. if(!$check_id) $this->error('会员不存在');
  77. break;
  78. case 4:
  79. $check_id = DatumIntro::where('id',$report_id)->value('id');
  80. if(!$check_id) $this->error('资料不存在');
  81. break;
  82. case 5:
  83. $check_id = ArticleIntro::where('id',$report_id)->value('id');
  84. if(!$check_id) $this->error('图文不存在');
  85. break;
  86. case 6:
  87. $check_id = UserForum::where('id',$report_id)->value('id');
  88. if(!$check_id) $this->error('问答问题不存在');
  89. break;
  90. case 7:
  91. $check_id = \app\common\model\Press::where('id',$report_id)->value('id');
  92. if(!$check_id) $this->error('新闻不存在');
  93. break;
  94. case 8:
  95. $check_id = ArticleComment::where('id',$report_id)->value('id');
  96. if(!$check_id) $this->error('评论不存在');
  97. break;
  98. case 9:
  99. $check_id = \app\common\model\PressComment::where('id',$report_id)->value('id');
  100. if(!$check_id) $this->error('评论不存在');
  101. break;
  102. case 10:
  103. $check_id = DatumComment::where('id',$report_id)->value('id');
  104. if(!$check_id) $this->error('评论不存在');
  105. break;
  106. }
  107. UserReport::report($this->user_id,$type,$report_id,$case_ids,$content);
  108. $this->success('举报成功');
  109. }
  110. }