123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- namespace App\Http\Controllers\Api\V1\Specialist;
- use App\Models\SpecialistInfosAssociation;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Api\V1\BaseController;
- use App\Facades\SpecialistInfoFacade;
- use App\Models\SpecialistInfo;
- use App\Models\BrowseRecord;
- use App\Facades\BrowseRecordFacade;
- class SpecialistInfoController extends BaseController
- {
- /**
- * 专家来了,列表分页
- * @return array
- */
- public function index()
- {
- $commentTag = request('comment_tag');
- if ($commentTag){
- $commentTag = json_decode($commentTag);
- }
- $conditions = [
- 'first_id' => request('first_id'),
- 'second_id' => request('second_id') == 0 ? null : request('second_id'),
- 'tag_id' => request('tag_id'),
- 'comment_tag' => $commentTag,
- 'name'=>request("name","")
- ];
- $fields = ['*'];
- $sort = '`rank` desc, `id` desc';
- $page = request('page', 1);
- $limit = request('limit', 20);
- return SpecialistInfoFacade::getList($conditions, $fields, $sort, $page, $limit);
- }
- /**
- * 专家来了详情
- * @param $id
- * @return array
- */
- public function show($id)
- {
- $conditions = [
- 'id'=>$id
- ];
- $fields = ['*'];
- $result = SpecialistInfoFacade::findBy($conditions, $fields);
- //计数加1
- SpecialistInfo::where('id', $id)->increment('number_of_studies');
- $record = [
- 'uid' => $this->auth(),
- 'column' => BrowseRecord::COLUMN_3,
- 'object_id' => $id,
- 'repeat' => 'uid:'.$this->auth().' column:'.BrowseRecord::COLUMN_3.' object_id:'.$id
- ];
- //加入浏览记录
- try {
- BrowseRecordFacade::create($record);
- } catch (\Exception $e) {
- }
- return $result;
- }
- /**
- * 点赞
- * @param $id
- * @return array
- */
- public function thumbsUpNum($id)
- {
- return SpecialistInfoFacade::thumbsUpNum($id,$this->auth());
- }
- /**
- * 喜欢
- * @param $id
- * @return array
- */
- public function loveNum($id)
- {
- return SpecialistInfoFacade::loveNum($id,$this->auth());
- }
- /**
- * 留言
- * @param Request $request
- * @return array
- */
- public function leaveMessage(Request $request)
- {
- $id = $request->get("id",0);
- $message = $request->get("message",0);
- return SpecialistInfoFacade::leaveMessage($id,$this->auth(),$message);
- }
- /**
- * 得到专家信息关联列表
- * @param Request $request
- * @return array
- */
- public function specialistInfosAssociationList(Request $request)
- {
- $page = request('page', 1);
- $limit = request('limit', 20);
- $associationType = request('associationType', 20);
- return SpecialistInfoFacade::specialistInfosAssociationList($this->auth(),$associationType,$page,$limit);
- }
- /**
- * Store a newly created resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
- public function store(Request $request)
- {
- //
- }
- /**
- * Update the specified resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function update(Request $request, $id)
- {
- //
- }
- /**
- * Remove the specified resource from storage.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function destroy($id)
- {
- //
- }
- }
|