EditablePageModel.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 数据层模型
  13. */
  14. class EditablePageModel extends BaseModel {
  15. public $page_info;
  16. /**
  17. * 新增可编辑页面模块
  18. * @author csdeshang
  19. * @param array $data 参数内容
  20. * @return bool 布尔类型的返回结果
  21. */
  22. public function addEditablePageModel($data) {
  23. return Db::name('editable_page_model')->insertGetId($data);
  24. }
  25. /**
  26. * 删除一个可编辑页面模块
  27. * @author csdeshang
  28. * @param array $editable_page_model_id 可编辑页面模块id
  29. * @return bool 布尔类型的返回结果
  30. */
  31. public function delEditablePageModel($editable_page_model_id) {
  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. if ($pagesize) {
  44. $result = Db::name('editable_page_model')->where($condition)->order($orderby)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  45. $this->page_info = $result;
  46. return $result->items();
  47. } else {
  48. return Db::name('editable_page_model')->where($condition)->order($orderby)->select()->toArray();
  49. }
  50. }
  51. public function getOneEditablePageModel($condition = array()) {
  52. return Db::name('editable_page_model')->where($condition)->find();
  53. }
  54. /**
  55. * 更新可编辑页面模块记录
  56. * @author csdeshang
  57. * @param array $data 更新内容
  58. * @return bool
  59. */
  60. public function editEditablePageModel($condition, $data) {
  61. return Db::name('editable_page_model')->where($condition)->update($data);
  62. }
  63. }