SpecialistInfoController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. namespace App\Http\Controllers\Api\V1\Specialist;
  3. use App\Models\SpecialistInfosAssociation;
  4. use Illuminate\Http\Request;
  5. use App\Http\Controllers\Api\V1\BaseController;
  6. use App\Facades\SpecialistInfoFacade;
  7. use App\Models\SpecialistInfo;
  8. use App\Models\BrowseRecord;
  9. use App\Facades\BrowseRecordFacade;
  10. class SpecialistInfoController extends BaseController
  11. {
  12. /**
  13. * 专家来了,列表分页
  14. * @return array
  15. */
  16. public function index()
  17. {
  18. $commentTag = request('comment_tag');
  19. if ($commentTag){
  20. $commentTag = json_decode($commentTag);
  21. }
  22. $conditions = [
  23. 'first_id' => request('first_id'),
  24. 'second_id' => request('second_id') == 0 ? null : request('second_id'),
  25. 'tag_id' => request('tag_id'),
  26. 'comment_tag' => $commentTag,
  27. 'name'=>request("name","")
  28. ];
  29. $fields = ['*'];
  30. $sort = '`rank` desc, `id` desc';
  31. $page = request('page', 1);
  32. $limit = request('limit', 20);
  33. return SpecialistInfoFacade::getList($conditions, $fields, $sort, $page, $limit);
  34. }
  35. /**
  36. * 专家来了详情
  37. * @param $id
  38. * @return array
  39. */
  40. public function show($id)
  41. {
  42. $conditions = [
  43. 'id'=>$id
  44. ];
  45. $fields = ['*'];
  46. $result = SpecialistInfoFacade::findBy($conditions, $fields);
  47. //计数加1
  48. SpecialistInfo::where('id', $id)->increment('number_of_studies');
  49. $record = [
  50. 'uid' => $this->auth(),
  51. 'column' => BrowseRecord::COLUMN_3,
  52. 'object_id' => $id,
  53. 'repeat' => 'uid:'.$this->auth().' column:'.BrowseRecord::COLUMN_3.' object_id:'.$id
  54. ];
  55. //加入浏览记录
  56. try {
  57. BrowseRecordFacade::create($record);
  58. } catch (\Exception $e) {
  59. }
  60. return $result;
  61. }
  62. /**
  63. * 点赞
  64. * @param $id
  65. * @return array
  66. */
  67. public function thumbsUpNum($id)
  68. {
  69. return SpecialistInfoFacade::thumbsUpNum($id,$this->auth());
  70. }
  71. /**
  72. * 喜欢
  73. * @param $id
  74. * @return array
  75. */
  76. public function loveNum($id)
  77. {
  78. return SpecialistInfoFacade::loveNum($id,$this->auth());
  79. }
  80. /**
  81. * 留言
  82. * @param Request $request
  83. * @return array
  84. */
  85. public function leaveMessage(Request $request)
  86. {
  87. $id = $request->get("id",0);
  88. $message = $request->get("message",0);
  89. return SpecialistInfoFacade::leaveMessage($id,$this->auth(),$message);
  90. }
  91. /**
  92. * 得到专家信息关联列表
  93. * @param Request $request
  94. * @return array
  95. */
  96. public function specialistInfosAssociationList(Request $request)
  97. {
  98. $page = request('page', 1);
  99. $limit = request('limit', 20);
  100. $associationType = request('associationType', 20);
  101. return SpecialistInfoFacade::specialistInfosAssociationList($this->auth(),$associationType,$page,$limit);
  102. }
  103. /**
  104. * Store a newly created resource in storage.
  105. *
  106. * @param \Illuminate\Http\Request $request
  107. * @return \Illuminate\Http\Response
  108. */
  109. public function store(Request $request)
  110. {
  111. //
  112. }
  113. /**
  114. * Update the specified resource in storage.
  115. *
  116. * @param \Illuminate\Http\Request $request
  117. * @param int $id
  118. * @return \Illuminate\Http\Response
  119. */
  120. public function update(Request $request, $id)
  121. {
  122. //
  123. }
  124. /**
  125. * Remove the specified resource from storage.
  126. *
  127. * @param int $id
  128. * @return \Illuminate\Http\Response
  129. */
  130. public function destroy($id)
  131. {
  132. //
  133. }
  134. }