ShippingTemplateRegionDao.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\common\dao\store\shipping;
  3. use think\facade\Db;
  4. use app\common\dao\BaseDao;
  5. use app\common\model\store\shipping\ShippingTemplateRegion as model;
  6. class ShippingTemplateRegionDao extends BaseDao
  7. {
  8. /**
  9. * @Author:Qinii
  10. * @Date: 2020/5/8
  11. * @return string
  12. */
  13. protected function getModel(): string
  14. {
  15. return model::class;
  16. }
  17. /**
  18. * @Author:Qinii
  19. * @Date: 2020/5/8
  20. * @param $field
  21. * @param $value
  22. * @param null $except
  23. * @return bool
  24. */
  25. public function merFieldExists($field, $value, $except = null)
  26. {
  27. return ($this->getModel())::getDB()->when($except, function ($query, $except) use ($field) {
  28. $query->where($field, '<>', $except);
  29. })->where($field, $value)->count() > 0;
  30. }
  31. /**
  32. * 批量删除
  33. * @Author:Qinii
  34. * @Date: 2020/5/8
  35. * @param array $id
  36. * @param array $temp_id
  37. */
  38. public function batchRemove(array $id,array $temp_id)
  39. {
  40. if($id)
  41. ($this->getModel())::getDB()->where($this->getPk(),'in',$id)->delete();
  42. if($temp_id)
  43. ($this->getModel())::getDB()->where('temp_id','in',$temp_id)->delete();
  44. }
  45. /**
  46. * @Author:Qinii
  47. * @Date: 2020/5/13
  48. * @param array $data
  49. * @return mixed
  50. */
  51. public function insertAll(array $data)
  52. {
  53. return ($this->getModel()::getDB())->insertAll($data);
  54. }
  55. }