EditablePageConfig.php 3.4 KB

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