123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <?php
- use think\migration\Migrator;
- use think\migration\db\Column;
- use app\model\Permission;
- use app\model\Grant;
- class CreateWisdomScreenTable extends Migrator
- {
- /**
- * Change Method.
- *
- * Write your reversible migrations using this method.
- *
- * More information on writing migrations is available here:
- * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
- *
- * The following commands can be used in this method and Phinx will
- * automatically reverse them when rolling back:
- *
- * createTable
- * renameTable
- * addColumn
- * renameColumn
- * addIndex
- * addForeignKey
- *
- * Remember to call "create()" or "update()" and NOT "save()" when working
- * with the Table class.
- *
- */
- public function change()
- {
- //智慧屏 数据表
- $menu = [
- 'pid' => 0,
- 'uri' => '',
- 'auth_name' => '智慧屏设置',
- 'is_menu' => 1,
- 'sort' => 50,
- 'relation' => '',
- 'icon'=>'layui-icon layui-icon-chart-screen'
- ];
- $pid = Permission::insertGetId($menu);
- $permission = new Permission();
- $child = $permission->saveAll([
- ['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'],
- ['pid'=>$pid,'uri'=>'smartScreen/content?type=introduce','auth_name'=>'公司简介(图文素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
- ['pid'=>$pid,'uri'=>'smartScreen/content?type=pattern','auth_name'=>'模式优势(图文素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
- ['pid'=>$pid,'uri'=>'smartScreen/content?type=platinum','auth_name'=>'铂金工程(在施工地)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
- ['pid'=>$pid,'uri'=>'smartScreen/content?type=boutique','auth_name'=>'精品设计(案例素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
- ['pid'=>$pid,'uri'=>'smartScreen/content?type=science','auth_name'=>'材料(图文素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
- ['pid'=>$pid,'uri'=>'smartScreen/content?type=major','auth_name'=>'大牌软装(图文素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
- ['pid'=>$pid,'uri'=>'smartScreen/content?type=customized','auth_name'=>'定制家具(图文素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
- ['pid'=>$pid,'uri'=>'smartScreen/content?type=realistic','auth_name'=>'实景样板房(图文素材)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content'],
- ['pid'=>$pid,'uri'=>'smartScreen/content?type=praise','auth_name'=>'口碑及服务(客户好评)','is_menu'=>1,'sort'=>50,'relation'=>'smartScreen/content']
- ]);
- $ids = [(int)$pid];
- foreach ($child as $v) {
- $ids[] = (int)$v->id;
- }
- //
- $grant = Grant::find(1);
- $permission = array_merge(json_decode(json_encode($grant->permission), true), $ids);
- asort($permission);
- $grant->permission = $permission;
- $grant->save();
- //智慧屏首页
- $index = $this->table('smart_screen')->setComment('智慧屏模块');
- $index->addColumn('root_id', 'integer', ['limit' => 10, 'comment' => '店面id', 'null' => true, 'default' => 0])
- ->addColumn('title', 'string', ['limit' => 250, 'comment' => '模块标题', 'null' => true, 'default' => ''])
- ->addColumn('code', 'string', ['limit' => 250, 'comment' => '模块标识', 'null' => true, 'default' => ''])
- ->addColumn('background_img', 'string', ['limit' => 250, 'comment' => '背景图', 'null' => true, 'default' => ''])
- ->addColumn('lcon_img', 'string', ['limit' => 250, 'comment' => '图标', 'null' => true, 'default' => ''])
- ->addColumn('del', 'integer', ['limit' => 10, 'comment' => '1删除', 'null' => true, 'default' => 0])
- ->addColumn('addtime', 'timestamp', ['comment' => '添加时间', 'default' => 'CURRENT_TIMESTAMP', 'null' => true])
- ->create();
- //智慧屏分类表 三级
- $cate = $this->table('smart_screen_cate')->setComment('智慧屏分类');
- $cate->addColumn('root_id', 'integer', ['limit' => 10, 'comment' => '店面id', 'null' => true, 'default' => 0])
- ->addColumn('title', 'string', ['limit' => 250, 'comment' => '分类名称', 'null' => true, 'default' => ''])
- ->addColumn('code', 'string', ['limit' => 250, 'comment' => '所属模块', 'null' => true, 'default' => ''])
- ->addColumn('pid', 'integer', ['limit' => 10, 'comment' => '上级ID', 'null' => true, 'default' => 0])
- ->addColumn('del', 'integer', ['limit' => 10, 'comment' => '1删除', 'null' => true, 'default' => 0])
- ->addColumn('is_case', 'integer', ['limit' => 10, 'comment' => '是否案例 ,1是,0否', 'null' => true, 'default' => 0])
- ->addColumn('level', 'integer', ['limit' => 10, 'comment' => '级别1,2,3', 'null' => true, 'default' => 1])
- ->addColumn('addtime', 'timestamp', ['comment' => '添加时间', 'default' => 'CURRENT_TIMESTAMP', 'null' => true])
- ->create();
- //智慧屏内容表
- $table = $this->table('smart_screen_data')->setComment('智慧屏内容');
- $table->addColumn('root_id', 'integer', ['limit' => 10, 'comment' => '店面id', 'null' => true, 'default' => 0])
- ->addColumn('smart_screen_id', 'integer', ['limit' => 10, 'comment' => '所属智慧屏模块id', 'null' => true, 'default' => 0])
- ->addColumn('cate1', 'string', ['limit' => 250, 'comment' => '一级分类', 'null' => true, 'default' => ''])
- ->addColumn('cate2', 'string', ['limit' => 250, 'comment' => '二级分类', 'null' => true, 'default' => ''])
- ->addColumn('cate3', 'string', ['limit' => 250, 'comment' => '三级分类', 'null' => true, 'default' => ''])
- ->addColumn('title', 'string', ['limit' => 255, 'comment' => '标题', 'null' => true, 'default' => ''])
- ->addColumn('pics', 'string', ['limit' => 255, 'comment' => '图片/视频地址', 'null' => true, 'default' => ''])
- ->addColumn('cover', 'string', ['limit' => 255, 'comment' => '图片/视频封面图', 'null' => true, 'default' => ''])
- ->addColumn('desc', 'text', ['comment'=> '效果案例描述', 'null'=> true])
- ->addColumn('real_case', 'text', ['comment'=> '实景案例描述', 'null'=> true])
- ->addColumn('vr_case', 'text', ['comment'=> 'vr案例描述', 'null'=> true])
- ->addColumn('video_case', 'text', ['comment'=> '视频案例描述', 'null'=> true])
- ->addColumn('video_format', 'integer', ['limit' => 10, 'comment' => '视频格式,0全屏,1横屏', 'null' => true, 'default' => 0])
- ->addColumn('view_times', 'integer', ['limit' => 10, 'comment' => '浏览总次数', 'null' => true, 'default' => 0])
- ->addColumn('difference', 'integer', ['limit' => 10, 'comment' => '1视频,2图文,3vr', 'null' => true, 'default' => 2])
- ->addColumn('employee_id', 'integer', ['limit' => 10, 'comment' => '上传人员', 'null' => true, 'default' => 0])
- ->addColumn('publish', 'integer', ['limit' => 10, 'comment' => '1上架,0下架', 'null' => true, 'default' => 1])
- ->addColumn('type', 'integer', ['limit' => 10, 'comment' => '1必看,0推荐', 'null' => true, 'default' => 1])
- ->addColumn('del', 'integer', ['limit' => 10, 'comment' => '1删除', 'null' => true, 'default' => 0])
- ->addColumn('designer_id', 'integer', ['limit' => 10, 'comment' => '设计师id', 'null' => true, 'default' => 0])
- ->addColumn(Column::decimal('square',10,2)->setComment('面积')->setDefault(0))
- ->addColumn(Column::decimal('money',7,2)->setComment('jiage')->setDefault(0))
- ->addColumn('community_id', 'integer', ['limit' => 10, 'comment' => '小区id', 'null' => true, 'default' => 0])
- ->addColumn('decostyle_id', 'integer', ['limit' => 10, 'comment' => '风格id', 'null' => true, 'default' => 0])
- ->addColumn('housetype_id', 'integer', ['limit' => 10, 'comment' => '户型id', 'null' => true, 'default' => 0])
- ->addColumn('addtime', 'timestamp', ['comment' => '添加时间', 'default' => 'CURRENT_TIMESTAMP', 'null' => true])
- ->addColumn('updatetime', 'timestamp', ['comment' => '修改时间', 'default' => 'CURRENT_TIMESTAMP', 'null' => true])
- ->create();
- //智慧屏讲解记录
- // $record = $this->table('smart_screen_record')->setComment('智慧屏讲解记录');
- // $record->addColumn('root_id', 'integer', ['limit' => 10, 'comment' => '店面id', 'null' => true, 'default' => 0])
- // ->addColumn('employee_id', 'integer', ['limit' => 10, 'comment' => '讲解老师ID', 'null' => true, 'default' => 0])
- // ->addColumn('customer_id', 'integer', ['limit' => 10, 'comment' => '客户ID', 'null' => true, 'default' => 0])
- // ->addColumn('time', 'integer', ['limit' => 10, 'comment' => '讲解时长', 'null' => true, 'default' => 0])
- // ->addColumn('path', 'string', ['limit' => 255, 'comment' => '讲解录音文件', 'null' => true, 'default' => ''])
- // ->addColumn('del', 'integer', ['limit' => 10, 'comment' => '1删除', 'null' => true, 'default' => 0])
- // ->addColumn('addtime', 'timestamp', ['comment' => '讲解时间', 'default' => 'CURRENT_TIMESTAMP', 'null' => true])
- // ->create();
- }
- }
|