| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace app\common\dao\product;
- use app\common\dao\BaseDao;
- use app\common\model\product\ShareModel;
- use app\entity\CommonEntity;
- use app\entity\data\product\ShareEntity;
- class ShareDao extends BaseDao
- {
- /**
- * @return string
- */
- protected function getModel(): string
- {
- return ShareModel::class;
- }
- /**
- * 根据 shareId 获取分享实体
- * @param int $shareId
- * @return CommonEntity
- */
- public function getShareEntityByShareId(int $shareId): CommonEntity
- {
- $shareData = [];
- try {
- /** @var ShareModel $model */
- $model = $this->getModel();
- $shareDataRes = $model::getDB()
- ->where('id', '=', $shareId)
- ->find();
- if (!empty($shareDataRes)) {
- $shareData = $shareDataRes->toArray();
- }
- } catch (\Exception $e) {
- }
- return ShareEntity::newInstance($shareData);
- }
- }
|