10 changed files with 168 additions and 18 deletions
-
4app/controller/substance/ResourceController.php
-
20app/controller/substance/ResourceDirController.php
-
19app/controller/substance/ShareController.php
-
7app/service/AuditService.php
-
31app/service/ResourceService.php
-
18app/service/ShareItemContentService.php
-
48app/service/ShareItemResourceService.php
-
27app/service/ShareItemService.php
-
2app/service/ShareService.php
-
6route/substance.php
@ -0,0 +1,18 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\service; |
||||
|
|
||||
|
use app\model\Content; |
||||
|
use app\model\Resource; |
||||
|
|
||||
|
class ShareItemContentService extends ShareItemService |
||||
|
{ |
||||
|
const TARGET_TYPE = 2; |
||||
|
|
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
$this->target_model = new Content(); |
||||
|
$this->target_service = new ContentService(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\service; |
||||
|
|
||||
|
use app\model\Resource; |
||||
|
|
||||
|
class ShareItemResourceService extends ShareItemService |
||||
|
{ |
||||
|
const TARGET_TYPE = 1; |
||||
|
|
||||
|
|
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
$this->target_model = new Resource(); |
||||
|
$this->target_service = new ResourceService(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return string |
||||
|
*/ |
||||
|
public function getShareReadUrl($item) |
||||
|
{ |
||||
|
$resource = $this->target_model->find($item->target_id); |
||||
|
|
||||
|
if ($resource->type == 1) { |
||||
|
//普通资源
|
||||
|
$url = (string)url('resource/read', |
||||
|
[ |
||||
|
'id' => $resource->id, |
||||
|
'in_share' => 1, |
||||
|
'share_id' => $item->share_id, |
||||
|
'share_item_id' => $item->id, |
||||
|
], |
||||
|
)->domain(true); |
||||
|
} elseif ($resource->type == 2) { |
||||
|
$url = (string)url('resource_dir/read', |
||||
|
[ |
||||
|
'id' => $resource->id, |
||||
|
'in_share' => 1, |
||||
|
'share_id' => $item->share_id, |
||||
|
'share_item_id' => $item->id, |
||||
|
], |
||||
|
)->domain(true); |
||||
|
} |
||||
|
return $url; |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue