Storeclass.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Storeclass extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 取店铺类别列表
  16. * @access public
  17. * @author csdeshang
  18. * @param type $condition 条件
  19. * @param type $pagesize 分页
  20. * @param type $limit 限制
  21. * @param type $order 排序
  22. * @return type
  23. */
  24. public function getStoreclassList($condition = array(), $pagesize = '', $limit = 0, $order = 'storeclass_sort asc,storeclass_id asc')
  25. {
  26. if ($pagesize) {
  27. $list = Db::name('storeclass')->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  28. $this->page_info = $list;
  29. return $list->items();
  30. } else {
  31. return Db::name('storeclass')->where($condition)->order($order)->limit($limit)->select()->toArray();
  32. }
  33. }
  34. /**
  35. * 取得单条信息
  36. * @access public
  37. * @author csdeshang
  38. * @param type $condition 条件
  39. * @return type
  40. */
  41. public function getStoreclassInfo($condition = array())
  42. {
  43. return Db::name('storeclass')->where($condition)->find();
  44. }
  45. /**
  46. * 删除类别
  47. * @access public
  48. * @author csdeshang
  49. * @param type $condition 条件
  50. * @return type
  51. */
  52. public function delStoreclass($condition = array())
  53. {
  54. return Db::name('storeclass')->where($condition)->delete();
  55. }
  56. /**
  57. * 增加店铺分类
  58. * @access public
  59. * @author csdeshang
  60. * @param array $data 数据
  61. * @return bool
  62. */
  63. public function addStoreclass($data)
  64. {
  65. return Db::name('storeclass')->insertGetId($data);
  66. }
  67. /**
  68. * 更新分类
  69. * @access public
  70. * @author csdeshang
  71. * @param array $data 数据
  72. * @param array $condition 条件
  73. * @return bool
  74. */
  75. public function editStoreclass($data = array(), $condition = array())
  76. {
  77. return Db::name('storeclass')->where($condition)->update($data);
  78. }
  79. }