CommunityTopicDao.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\dao\community;
  12. use app\common\dao\BaseDao;
  13. use app\common\model\community\CommunityTopic;
  14. class CommunityTopicDao extends BaseDao
  15. {
  16. protected function getModel(): string
  17. {
  18. return CommunityTopic::class;
  19. }
  20. /**
  21. * 数量增加
  22. * @param int $id
  23. * @param string $filed
  24. * @param int $inc
  25. * @return mixed
  26. * @author wuhaotian
  27. * @email 442384644@qq.com
  28. * @date 2024/7/13
  29. */
  30. public function countInc(int $id, string $filed, int $inc = 1)
  31. {
  32. return $this->getModel()::getDb()->where($this->getPk(), $id)->inc($filed, $inc)->update();
  33. }
  34. /**
  35. * 数量减少
  36. * @param int $id
  37. * @param string $filed
  38. * @param int $dec
  39. * @return mixed|void
  40. * @author wuhaotian
  41. * @email 442384644@qq.com
  42. * @date 2024/7/13
  43. */
  44. public function countDec(int $id, string $filed, int $dec = 1)
  45. {
  46. try{
  47. return $this->getModel()::getDb()->where($this->getPk(), $id)->dec($filed, $dec)->update();
  48. }catch (\Exception $exception) {
  49. }
  50. }
  51. }