Storesnscomment.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Storesnscomment extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 店铺动态评论列表
  16. * @access public
  17. * @author csdeshang
  18. * @param array $condition 条件
  19. * @param string $field 字段
  20. * @param string $order 排序
  21. * @param int $limit 限制
  22. * @param int $pagesize 分页
  23. * @return array
  24. */
  25. public function getStoresnscommentList($condition, $field = '*', $order = 'storesnscomm_id desc', $limit = 0, $pagesize = 0)
  26. {
  27. if ($pagesize) {
  28. $res = Db::name('storesnscomment')->where($condition)->field($field)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  29. $this->page_info = $res;
  30. return $res->items();
  31. } else {
  32. return Db::name('storesnscomment')->where($condition)->field($field)->order($order)->select()->toArray();
  33. }
  34. }
  35. /**
  36. * 店铺评论数量
  37. * @access public
  38. * @author csdeshang
  39. * @param type $condition 条件
  40. * @return type
  41. */
  42. public function getStoresnscommentCount($condition)
  43. {
  44. return Db::name('storesnscomment')->where($condition)->count();
  45. }
  46. /**
  47. * 获取单条评论
  48. * @access public
  49. * @author csdeshang
  50. * @param array $condition 条件
  51. * @param string $field 字段
  52. * @return array
  53. */
  54. public function getStoresnscommentInfo($condition, $field = '*')
  55. {
  56. return Db::name('storesnscomment')->where($condition)->field($field)->find();
  57. }
  58. /**
  59. * 保存店铺评论
  60. * @access public
  61. * @author csdeshang
  62. * @param array $data 数据
  63. * @return boolean
  64. */
  65. public function addStoresnscomment($data)
  66. {
  67. return Db::name('storesnscomment')->insertGetId($data);
  68. }
  69. /**
  70. * 更新店铺评论
  71. * @access public
  72. * @author csdeshang
  73. * @param type $update 更新数据
  74. * @param type $condition 条件
  75. * @return type
  76. */
  77. public function editStoresnscomment($update, $condition)
  78. {
  79. return Db::name('storesnscomment')->where($condition)->update($update);
  80. }
  81. /**
  82. * 删除店铺动态评论
  83. * @access public
  84. * @author csdeshang
  85. * @param array $condition 条件
  86. * @return boolean
  87. */
  88. public function delStoresnscomment($condition)
  89. {
  90. return Db::name('storesnscomment')->where($condition)->delete();
  91. }
  92. }