Storeclass.php 2.5 KB

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