20221210035551_create_wisdom_screen_table.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use app\model\Permission;
  5. use app\model\Grant;
  6. class CreateWisdomScreenTable extends Migrator
  7. {
  8. /**
  9. * Change Method.
  10. *
  11. * Write your reversible migrations using this method.
  12. *
  13. * More information on writing migrations is available here:
  14. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  15. *
  16. * The following commands can be used in this method and Phinx will
  17. * automatically reverse them when rolling back:
  18. *
  19. * createTable
  20. * renameTable
  21. * addColumn
  22. * renameColumn
  23. * addIndex
  24. * addForeignKey
  25. *
  26. * Remember to call "create()" or "update()" and NOT "save()" when working
  27. * with the Table class.
  28. *
  29. */
  30. public function change()
  31. {
  32. //智慧屏 数据表
  33. $menu = [
  34. 'pid' => 0,
  35. 'uri' => '',
  36. 'auth_name' => '智慧屏设置',
  37. 'is_menu' => 1,
  38. 'sort' => 50,
  39. 'relation' => '',
  40. 'icon'=>'layui-icon layui-icon-chart-screen'
  41. ];
  42. $pid = Permission::insertGetId($menu);
  43. $permission = new Permission();
  44. $child = $permission->saveAll([
  45. ['pid'=>$pid,'uri'=>'smartScreen/index','auth_name'=>'首页设置','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/index,smartScreen/recordingSwitch,smartScreen/getModularRead,smartScreen/saveModularRead,smartScreen/cate1,smartScreen/cate2,smartScreen/saveCate,smartScreen/editCate,smartScreen/delCate,smartScreen/addMaterial,smartScreen/add,smartScreen/fileupload,smartScreen/list,smartScreen/del,smartScreen/edit,smartScreen/edits,smartScreen/delCate1,smartScreen/delCate2,smartScreen/recovery,smartScreen/saveOrder'],
  46. ['pid'=>$pid,'uri'=>'smartScreen/content?type=introduce','auth_name'=>'公司简介(图文素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
  47. ['pid'=>$pid,'uri'=>'smartScreen/content?type=pattern','auth_name'=>'模式优势(图文素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
  48. ['pid'=>$pid,'uri'=>'smartScreen/content?type=platinum','auth_name'=>'铂金工程(在施工地)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
  49. ['pid'=>$pid,'uri'=>'smartScreen/content?type=boutique','auth_name'=>'精品设计(案例素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
  50. ['pid'=>$pid,'uri'=>'smartScreen/content?type=science','auth_name'=>'材料(图文素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
  51. ['pid'=>$pid,'uri'=>'smartScreen/content?type=major','auth_name'=>'大牌软装(图文素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
  52. ['pid'=>$pid,'uri'=>'smartScreen/content?type=customized','auth_name'=>'定制家具(图文素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
  53. ['pid'=>$pid,'uri'=>'smartScreen/content?type=realistic','auth_name'=>'实景样板房(图文素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
  54. ['pid'=>$pid,'uri'=>'smartScreen/content?type=praise','auth_name'=>'口碑及服务(客户好评)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content']
  55. ]);
  56. $ids = [(int)$pid];
  57. foreach ($child as $v) {
  58. $ids[] = (int)$v->id;
  59. }
  60. //
  61. $grant = Grant::find(1);
  62. $permission = array_merge(json_decode(json_encode($grant->permission), true), $ids);
  63. asort($permission);
  64. $grant->permission = $permission;
  65. $grant->save();
  66. //智慧屏首页
  67. $index = $this->table('smart_screen')->setComment('智慧屏模块');
  68. $index->addColumn('root_id', 'integer', ['limit' => 10, 'comment' => '店面id', 'null' => true, 'default' => 0])
  69. ->addColumn('title', 'string', ['limit' => 250, 'comment' => '模块标题', 'null' => true, 'default' => ''])
  70. ->addColumn('code', 'string', ['limit' => 250, 'comment' => '模块标识', 'null' => true, 'default' => ''])
  71. ->addColumn('background_img', 'string', ['limit' => 250, 'comment' => '背景图', 'null' => true, 'default' => ''])
  72. ->addColumn('lcon_img', 'string', ['limit' => 250, 'comment' => '图标', 'null' => true, 'default' => ''])
  73. ->addColumn('del', 'integer', ['limit' => 10, 'comment' => '1删除', 'null' => true, 'default' => 0])
  74. ->addColumn('addtime', 'timestamp', ['comment' => '添加时间', 'default' => 'CURRENT_TIMESTAMP', 'null' => true])
  75. ->create();
  76. //智慧屏分类表 三级
  77. $cate = $this->table('smart_screen_cate')->setComment('智慧屏分类');
  78. $cate->addColumn('root_id', 'integer', ['limit' => 10, 'comment' => '店面id', 'null' => true, 'default' => 0])
  79. ->addColumn('title', 'string', ['limit' => 250, 'comment' => '分类名称', 'null' => true, 'default' => ''])
  80. ->addColumn('code', 'string', ['limit' => 250, 'comment' => '所属模块', 'null' => true, 'default' => ''])
  81. ->addColumn('pid', 'integer', ['limit' => 10, 'comment' => '上级ID', 'null' => true, 'default' => 0])
  82. ->addColumn('del', 'integer', ['limit' => 10, 'comment' => '1删除', 'null' => true, 'default' => 0])
  83. ->addColumn('is_case', 'integer', ['limit' => 10, 'comment' => '是否案例 ,1是,0否', 'null' => true, 'default' => 0])
  84. ->addColumn('level', 'integer', ['limit' => 10, 'comment' => '级别1,2,3', 'null' => true, 'default' => 1])
  85. ->addColumn('addtime', 'timestamp', ['comment' => '添加时间', 'default' => 'CURRENT_TIMESTAMP', 'null' => true])
  86. ->create();
  87. //智慧屏内容表
  88. $table = $this->table('smart_screen_data')->setComment('智慧屏内容');
  89. $table->addColumn('root_id', 'integer', ['limit' => 10, 'comment' => '店面id', 'null' => true, 'default' => 0])
  90. ->addColumn('smart_screen_id', 'integer', ['limit' => 10, 'comment' => '所属智慧屏模块id', 'null' => true, 'default' => 0])
  91. ->addColumn('cate1', 'string', ['limit' => 250, 'comment' => '一级分类', 'null' => true, 'default' => ''])
  92. ->addColumn('cate2', 'string', ['limit' => 250, 'comment' => '二级分类', 'null' => true, 'default' => ''])
  93. ->addColumn('cate3', 'string', ['limit' => 250, 'comment' => '三级分类', 'null' => true, 'default' => ''])
  94. ->addColumn('title', 'string', ['limit' => 255, 'comment' => '标题', 'null' => true, 'default' => ''])
  95. ->addColumn('pics', 'string', ['limit' => 255, 'comment' => '图片/视频地址', 'null' => true, 'default' => ''])
  96. ->addColumn('cover', 'string', ['limit' => 255, 'comment' => '图片/视频封面图', 'null' => true, 'default' => ''])
  97. ->addColumn('desc', 'text', ['comment'=> '效果案例描述', 'null'=> true])
  98. ->addColumn('real_case', 'text', ['comment'=> '实景案例描述', 'null'=> true])
  99. ->addColumn('vr_case', 'text', ['comment'=> 'vr案例描述', 'null'=> true])
  100. ->addColumn('video_case', 'text', ['comment'=> '视频案例描述', 'null'=> true])
  101. ->addColumn('video_format', 'integer', ['limit' => 10, 'comment' => '视频格式,0全屏,1横屏', 'null' => true, 'default' => 0])
  102. ->addColumn('view_times', 'integer', ['limit' => 10, 'comment' => '浏览总次数', 'null' => true, 'default' => 0])
  103. ->addColumn('difference', 'integer', ['limit' => 10, 'comment' => '1视频,2图文,3vr', 'null' => true, 'default' => 2])
  104. ->addColumn('employee_id', 'integer', ['limit' => 10, 'comment' => '上传人员', 'null' => true, 'default' => 0])
  105. ->addColumn('publish', 'integer', ['limit' => 10, 'comment' => '1上架,0下架', 'null' => true, 'default' => 1])
  106. ->addColumn('type', 'integer', ['limit' => 10, 'comment' => '1必看,0推荐', 'null' => true, 'default' => 1])
  107. ->addColumn('del', 'integer', ['limit' => 10, 'comment' => '1删除', 'null' => true, 'default' => 0])
  108. ->addColumn('designer_id', 'integer', ['limit' => 10, 'comment' => '设计师id', 'null' => true, 'default' => 0])
  109. ->addColumn(Column::decimal('square',10,2)->setComment('面积')->setDefault(0))
  110. ->addColumn(Column::decimal('money',7,2)->setComment('jiage')->setDefault(0))
  111. ->addColumn('community_id', 'integer', ['limit' => 10, 'comment' => '小区id', 'null' => true, 'default' => 0])
  112. ->addColumn('decostyle_id', 'integer', ['limit' => 10, 'comment' => '风格id', 'null' => true, 'default' => 0])
  113. ->addColumn('housetype_id', 'integer', ['limit' => 10, 'comment' => '户型id', 'null' => true, 'default' => 0])
  114. ->addColumn('addtime', 'timestamp', ['comment' => '添加时间', 'default' => 'CURRENT_TIMESTAMP', 'null' => true])
  115. ->addColumn('updatetime', 'timestamp', ['comment' => '修改时间', 'default' => 'CURRENT_TIMESTAMP', 'null' => true])
  116. ->create();
  117. //智慧屏讲解记录
  118. // $record = $this->table('smart_screen_record')->setComment('智慧屏讲解记录');
  119. // $record->addColumn('root_id', 'integer', ['limit' => 10, 'comment' => '店面id', 'null' => true, 'default' => 0])
  120. // ->addColumn('employee_id', 'integer', ['limit' => 10, 'comment' => '讲解老师ID', 'null' => true, 'default' => 0])
  121. // ->addColumn('customer_id', 'integer', ['limit' => 10, 'comment' => '客户ID', 'null' => true, 'default' => 0])
  122. // ->addColumn('time', 'integer', ['limit' => 10, 'comment' => '讲解时长', 'null' => true, 'default' => 0])
  123. // ->addColumn('path', 'string', ['limit' => 255, 'comment' => '讲解录音文件', 'null' => true, 'default' => ''])
  124. // ->addColumn('del', 'integer', ['limit' => 10, 'comment' => '1删除', 'null' => true, 'default' => 0])
  125. // ->addColumn('addtime', 'timestamp', ['comment' => '讲解时间', 'default' => 'CURRENT_TIMESTAMP', 'null' => true])
  126. // ->create();
  127. }
  128. }