EditablePageModel.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class EditablePageModel extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 新增可编辑页面模块
  16. * @author csdeshang
  17. * @param array $data 参数内容
  18. * @return bool 布尔类型的返回结果
  19. */
  20. public function addEditablePageModel($data)
  21. {
  22. return Db::name('editable_page_model')->insertGetId($data);
  23. }
  24. /**
  25. * 删除一个可编辑页面模块
  26. * @author csdeshang
  27. * @param array $editable_page_model_id 可编辑页面模块id
  28. * @return bool 布尔类型的返回结果
  29. */
  30. public function delEditablePageModel($editable_page_model_id)
  31. {
  32. return Db::name('editable_page_model')->where('editable_page_model_id', $editable_page_model_id)->delete();
  33. }
  34. /**
  35. * 获取可编辑页面模块列表
  36. * @author csdeshang
  37. * @param array $condition 查询条件
  38. * @param obj $pagesize 分页页数
  39. * @param str $orderby 排序
  40. * @return array 二维数组
  41. */
  42. public function getEditablePageModelList($condition = array(), $pagesize = '', $orderby = 'editable_page_model_id desc')
  43. {
  44. if ($pagesize) {
  45. $result = Db::name('editable_page_model')->where($condition)->order($orderby)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  46. $this->page_info = $result;
  47. return $result->items();
  48. } else {
  49. return Db::name('editable_page_model')->where($condition)->order($orderby)->select()->toArray();
  50. }
  51. }
  52. public function getOneEditablePageModel($condition = array())
  53. {
  54. return Db::name('editable_page_model')->where($condition)->find();
  55. }
  56. /**
  57. * 更新可编辑页面模块记录
  58. * @author csdeshang
  59. * @param array $data 更新内容
  60. * @return bool
  61. */
  62. public function editEditablePageModel($condition, $data)
  63. {
  64. return Db::name('editable_page_model')->where($condition)->update($data);
  65. }
  66. }