Storesnscomment.php 2.9 KB

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