| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace addons\TinyShop\api\modules\v1\controllers\common;
- use Yii;
- use yii\base\Model;
- use addons\TinyShop\common\models\common\Transmit;
- /**
- * 转发
- *
- * Class TransmitController
- * @package addons\TinyShop\api\modules\v1\controllers\common
- * @author jianyan74 <751393839@qq.com>
- */
- class TransmitController extends FollowController
- {
- /**
- * 不用进行登录验证的方法
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = ['create'];
- /**
- * @var Transmit
- */
- public $modelClass = Transmit::class;
- /**
- * @param $topic_id
- * @param $topic_type
- * @return Transmit|array|\yii\db\ActiveRecord|null
- */
- public function findByTopicId($topic_id, $topic_type)
- {
- return Yii::$app->tinyShopService->transmit->findByTopicId($topic_id, $topic_type, Yii::$app->user->identity->member_id);
- }
- /**
- * @param $id
- * @return Transmit|array|\yii\db\ActiveRecord|null
- */
- public function findById($id)
- {
- return Yii::$app->tinyShopService->transmit->findById($id, Yii::$app->user->identity->member_id);
- }
- /**
- * @param Transmit $model
- * @param $class
- * @param $num
- * @return mixed
- */
- public function callBack($model, $class, $num)
- {
- /** @var Model $class */
- return $class::updateAllCounters(['transmit_num' => $num], ['id' => $model->topic_id]);
- }
- }
|