Agent.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\client\controller;
  3. use think\facade\Request;
  4. use app\event\FootPrints;
  5. use app\model\AgentArticle;
  6. use xiaohongwu\Vr;
  7. class Agent extends Base
  8. {
  9. /**
  10. * 获取详情
  11. */
  12. public function info($article_id)
  13. {
  14. $token = request()->token;
  15. $article = AgentArticle::field('id,title,content,file,type')->where(['root_id'=>$token['root_org'],'id' => $article_id, 'disable' => 0])->find();
  16. if (empty($article)) {
  17. $article = [
  18. 'title' => '该文章不存在',
  19. 'content' => '您访问的内容不存在',
  20. 'file' => '',
  21. 'type' => ''
  22. ];
  23. return json(['code' => 0, 'msg' => '获取成功', 'data' => $article]);
  24. }
  25. // 添加足迹
  26. if (!empty($token['uid']) && !$token['isEmployee']) {
  27. event(new FootPrints($token['uid'], $token['share_employee'] ?? 0, $token['share_org'] ?? 0, $article, 'agentArticle'));
  28. }
  29. $vrObj = new Vr();
  30. $article['file_img'] = $article['files'] = '';
  31. if($article['type']==3){
  32. $article['files'] = !empty($article['file'][0]) ? str_replace('https://'.config('app.ali_oss_bindurl').'/','',$article['file'][0]) :'';
  33. $article['file_img'] = !empty($article['file'][0]) ? $vrObj->getFirstImg(str_replace('https://'.config('app.ali_oss_bindurl').'/','',$article['file'][0])) : '';
  34. }
  35. return json(['code' => 0, 'msg' => '获取成功', 'data' => $article]);
  36. }
  37. }