TransmitController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace addons\TinyShop\api\modules\v1\controllers\common;
  3. use Yii;
  4. use yii\base\Model;
  5. use addons\TinyShop\common\models\common\Transmit;
  6. /**
  7. * 转发
  8. *
  9. * Class TransmitController
  10. * @package addons\TinyShop\api\modules\v1\controllers\common
  11. * @author jianyan74 <751393839@qq.com>
  12. */
  13. class TransmitController extends FollowController
  14. {
  15. /**
  16. * 不用进行登录验证的方法
  17. * 例如: ['index', 'update', 'create', 'view', 'delete']
  18. * 默认全部需要验证
  19. *
  20. * @var array
  21. */
  22. protected $authOptional = ['create'];
  23. /**
  24. * @var Transmit
  25. */
  26. public $modelClass = Transmit::class;
  27. /**
  28. * @param $topic_id
  29. * @param $topic_type
  30. * @return Transmit|array|\yii\db\ActiveRecord|null
  31. */
  32. public function findByTopicId($topic_id, $topic_type)
  33. {
  34. return Yii::$app->tinyShopService->transmit->findByTopicId($topic_id, $topic_type, Yii::$app->user->identity->member_id);
  35. }
  36. /**
  37. * @param $id
  38. * @return Transmit|array|\yii\db\ActiveRecord|null
  39. */
  40. public function findById($id)
  41. {
  42. return Yii::$app->tinyShopService->transmit->findById($id, Yii::$app->user->identity->member_id);
  43. }
  44. /**
  45. * @param Transmit $model
  46. * @param $class
  47. * @param $num
  48. * @return mixed
  49. */
  50. public function callBack($model, $class, $num)
  51. {
  52. /** @var Model $class */
  53. return $class::updateAllCounters(['transmit_num' => $num], ['id' => $model->topic_id]);
  54. }
  55. }
粤ICP备19079148号