Navigation.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 数据层模型
  13. */
  14. class Navigation extends BaseModel
  15. {
  16. public $page_info;
  17. /**
  18. * 获取导航列表
  19. * @access public
  20. * @author csdeshang
  21. * @param array $condition 条件
  22. * @param int $pagesize 分页
  23. * @param string $order 排序
  24. * @return array
  25. */
  26. public function getNavigationList($condition, $pagesize = '', $order = 'nav_sort desc')
  27. {
  28. if ($pagesize) {
  29. $nav_list = Db::name('navigation')->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  30. $this->page_info = $nav_list;
  31. return $nav_list->items();
  32. } else {
  33. return Db::name('navigation')->where($condition)->order('nav_sort')->select()->toArray();
  34. }
  35. }
  36. /**
  37. * 新增导航
  38. * @access public
  39. * @author csdeshang
  40. * @param type $data 参数内容
  41. * @return bool
  42. */
  43. public function addNavigation($data)
  44. {
  45. $add_navigation = Db::name('navigation')->insert($data);
  46. return $add_navigation;
  47. }
  48. /**
  49. * 编辑导航
  50. * @access public
  51. * @author csdeshang
  52. * @param type $data 数据
  53. * @param type $condition 条件
  54. * @return bool
  55. */
  56. public function eidtNavigation($data, $condition)
  57. {
  58. return Db::name('navigation')->where($condition)->update($data);
  59. }
  60. /**
  61. * 获取单个导航
  62. * @access public
  63. * @author csdeshang
  64. * @param type $condition 条件
  65. * @return array
  66. */
  67. public function getOneNavigation($condition)
  68. {
  69. return Db::name('navigation')->where($condition)->find();
  70. }
  71. /**
  72. * 删除导航
  73. * @access public
  74. * @author csdeshang
  75. * @param type $condition 条件
  76. * @return bool
  77. */
  78. public function delNavigation($condition)
  79. {
  80. return Db::name('navigation')->where($condition)->delete();
  81. }
  82. }