GuaranteeValueDao.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\store;
  12. use app\common\dao\BaseDao;
  13. use app\common\model\store\GuaranteeValue;
  14. class GuaranteeValueDao extends BaseDao
  15. {
  16. protected function getModel(): string
  17. {
  18. return GuaranteeValue::class;
  19. }
  20. /**
  21. * 更改保证状态
  22. *
  23. * 本函数用于根据给定的保证ID更新保证的状态。它通过查询数据库找到对应ID的保证记录,
  24. * 然后将其状态更新为新提供的状态值。
  25. *
  26. * @param int $id 保证的唯一标识ID。此ID用于在数据库中定位特定的保证记录。
  27. * @param int $status 新的状态值。此值将被设置为指定保证记录的状态,以反映其新的状态。
  28. */
  29. public function chageStatus(int $id,int $status)
  30. {
  31. // 通过getModel方法获取数据库操作对象,并使用where语句定位到特定ID的保证记录,然后更新其状态为$status
  32. $this->getModel()::getDB()->where('guarantee_id',$id)->update(['status' => $status]);
  33. }
  34. /**
  35. * 清除关联的保证模板数据
  36. *
  37. * 本函数用于根据给定的模板ID,从数据库中删除与该模板相关的所有数据。
  38. * 这是数据维护操作的一部分,用于在模板更新或废弃时清理旧数据。
  39. *
  40. * @param int $id 保证模板的唯一标识ID
  41. */
  42. public function clear($id)
  43. {
  44. // 通过模型获取数据库实例,并基于guarantee_template_id删除相关数据
  45. $this->getModel()::getDB()->where('guarantee_template_id',$id)->delete();
  46. }
  47. }