EditablePageConfig.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class EditablePageConfig extends BaseModel
  12. {
  13. public $page_info;
  14. public $store_id = 0;
  15. /**
  16. * 新增可编辑页面配置
  17. * @author csdeshang
  18. * @param array $data 参数内容
  19. * @return bool 布尔类型的返回结果
  20. */
  21. public function addEditablePageConfig($data)
  22. {
  23. return Db::name('editable_page_config')->insertGetId($data);
  24. }
  25. /**
  26. * 新增可编辑页面配置
  27. * @author csdeshang
  28. * @param array $data 参数内容
  29. * @return bool 布尔类型的返回结果
  30. */
  31. public function addEditablePageConfigAll($data)
  32. {
  33. return Db::name('editable_page_config')->insertAll($data);
  34. }
  35. /**
  36. * 删除一个可编辑页面配置
  37. * @author csdeshang
  38. * @param array $condition 条件
  39. * @return bool 布尔类型的返回结果
  40. */
  41. public function delEditablePageConfig($condition)
  42. {
  43. //删除图片
  44. $editable_page_config_id_list = Db::name('editable_page_config')->where($condition)->column('editable_page_config_id');
  45. if ($editable_page_config_id_list) {
  46. $upload_condition = array();
  47. $upload_condition[] = array('upload_type', '=', 7);
  48. $upload_condition[] = array('item_id', 'in', $editable_page_config_id_list);
  49. $file_name_list = Db::name('upload')->where($upload_condition)->column('file_name');
  50. foreach ($file_name_list as $file_name) {
  51. @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_EDITABLE_PAGE . DIRECTORY_SEPARATOR . $file_name);
  52. }
  53. model('upload')->delUpload($upload_condition);
  54. }
  55. return Db::name('editable_page_config')->where($condition)->delete();
  56. }
  57. /**
  58. * 获取可编辑页面配置列表
  59. * @author csdeshang
  60. * @param array $condition 查询条件
  61. * @param obj $pagesize 分页页数
  62. * @param str $orderby 排序
  63. * @return array 二维数组
  64. */
  65. public function getEditablePageConfigList($condition = array(), $pagesize = '', $orderby = 'editable_page_config_sort_order asc')
  66. {
  67. if ($pagesize) {
  68. $result = Db::name('editable_page_config')->where($condition)->order($orderby)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  69. $this->page_info = $result;
  70. return $result->items();
  71. } else {
  72. return Db::name('editable_page_config')->where($condition)->order($orderby)->select()->toArray();
  73. }
  74. }
  75. public function getOneEditablePageConfig($condition = array())
  76. {
  77. return Db::name('editable_page_config')->where($condition)->find();
  78. }
  79. /**
  80. * 更新可编辑页面配置记录
  81. * @author csdeshang
  82. * @param array $data 更新内容
  83. * @return bool
  84. */
  85. public function editEditablePageConfig($condition, $data)
  86. {
  87. return Db::name('editable_page_config')->where($condition)->update($data);
  88. }
  89. }