EditablePageConfig.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  9. * 网站地址: https://www.valimart.net/
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 数据层模型
  14. */
  15. class EditablePageConfig extends BaseModel {
  16. public $page_info;
  17. public $store_id=0;
  18. /**
  19. * 新增可编辑页面配置
  20. * @author csdeshang
  21. * @param array $data 参数内容
  22. * @return bool 布尔类型的返回结果
  23. */
  24. public function addEditablePageConfig($data) {
  25. return Db::name('editable_page_config')->insertGetId($data);
  26. }
  27. /**
  28. * 新增可编辑页面配置
  29. * @author csdeshang
  30. * @param array $data 参数内容
  31. * @return bool 布尔类型的返回结果
  32. */
  33. public function addEditablePageConfigAll($data) {
  34. return Db::name('editable_page_config')->insertAll($data);
  35. }
  36. /**
  37. * 删除一个可编辑页面配置
  38. * @author csdeshang
  39. * @param array $condition 条件
  40. * @return bool 布尔类型的返回结果
  41. */
  42. public function delEditablePageConfig($condition) {
  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. if ($pagesize) {
  67. $result = Db::name('editable_page_config')->where($condition)->order($orderby)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  68. $this->page_info = $result;
  69. return $result->items();
  70. } else {
  71. return Db::name('editable_page_config')->where($condition)->order($orderby)->select()->toArray();
  72. }
  73. }
  74. public function getOneEditablePageConfig($condition = array()) {
  75. return Db::name('editable_page_config')->where($condition)->find();
  76. }
  77. /**
  78. * 更新可编辑页面配置记录
  79. * @author csdeshang
  80. * @param array $data 更新内容
  81. * @return bool
  82. */
  83. public function editEditablePageConfig($condition, $data) {
  84. return Db::name('editable_page_config')->where($condition)->update($data);
  85. }
  86. }
  87. ?>