| | |
| | | package service |
| | | |
| | | import ( |
| | | "basic.com/valib/bhomedbapi.git" |
| | | "basic.com/valib/logger.git" |
| | | "github.com/satori/go.uuid" |
| | | "strings" |
| | | "vamicro/system-service/models" |
| | | |
| | | "basic.com/valib/bhomedbapi.git" |
| | | "basic.com/valib/logger.git" |
| | | uuid "github.com/satori/go.uuid" |
| | | ) |
| | | |
| | | //初始化应用权限 |
| | | // 初始化应用权限 |
| | | func InitAppPermissions() { |
| | | var appApi bhomedbapi.AppApi |
| | | apps := appApi.FindAll("") |
| | |
| | | } |
| | | if a.Package == "search" { //统计查询 |
| | | sort = 2 |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '摄像机', 'SEARCH', 'search:camera', 1, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='search:camera');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '数据栈', 'SEARCH', 'search:stack', 2, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='search:stack');") |
| | | // sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '摄像机', 'SEARCH', 'search:camera', 1, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='search:camera');") |
| | | // sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '数据栈', 'SEARCH', 'search:stack', 2, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='search:stack');") |
| | | } else if a.Package == "cameraAccess" { //摄像机配置 |
| | | sort = 3 |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '摄像机信息', 'CAMERAACCESS', 'cameraAccess:cameraInfo', 1, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='cameraAccess:cameraInfo');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '独立场景', 'CAMERAACCESS', 'cameraAccess:selfRule', 2, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='cameraAccess:selfRule');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '联动场景', 'CAMERAACCESS', 'cameraAccess:linkRule', 3, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='cameraAccess:linkRule');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, 'AI任务', 'CAMERAACCESS', 'cameraAccess:aiTask', 2, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='cameraAccess:aiTask');") |
| | | // sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '联动场景', 'CAMERAACCESS', 'cameraAccess:linkRule', 3, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='cameraAccess:linkRule');") |
| | | } else if a.Package == "analysisPower" { //算力管理 |
| | | sort = 5 |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '设置', 'ANALYSISPOWER', 'analysisPower:set', 1, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='analysisPower:set');") |
| | |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '查看', 'LIBRARY', 'library:show', 2, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='library:show');") |
| | | } else if a.Package == "algorithmManage" { // 应用中心 |
| | | sort = 7 |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '已安装', 'ALGORITHMMANAGE', 'algorithmManage:installed', 1, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='algorithmManage:installed');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '离线升级/安装', 'ALGORITHMMANAGE', 'algorithmManage:insOffLine', 2, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='algorithmManage:insOffLine');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '应用中心购买', 'ALGORITHMMANAGE', 'algorithmManage:buy', 3, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='algorithmManage:buy');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '应用中心', 'ALGORITHMMANAGE', 'algorithmManage:main', 1, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='algorithmManage:main');") |
| | | |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '已激活', 'ALGORITHMMANAGE', 'algorithmManage:installed', 2, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='algorithmManage:installed');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '离线升级/安装', 'ALGORITHMMANAGE', 'algorithmManage:insOffLine', 3, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='algorithmManage:insOffLine');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '更新', 'ALGORITHMMANAGE', 'algorithmManage:buy', 4, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='algorithmManage:buy');") |
| | | } else if a.Package == "datapush" { //数据推送 |
| | | sort = 8 |
| | | } else if a.Package == "settings" { //系统设置 |
| | |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '键盘和语言', 'SETTINGS', 'settings:keyboard', 5, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='settings:keyboard');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '通用设置', 'SETTINGS', 'settings:common', 6, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='settings:common');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '设备信息', 'SETTINGS', 'settings:sysInfo', 7, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='settings:sysInfo');") |
| | | /*sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '权限管理', 'SETTINGS', 'settings:permission', 4, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='settings:permission');")*/ |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '授权管理', 'SETTINGS', 'settings:permission', 8, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='settings:permission');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '设备管理', 'SETTINGS', 'settings:device', 9, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='settings:device');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '检测内容', 'SETTINGS', 'settings:content', 10, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='settings:content');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '预警规则', 'SETTINGS', 'settings:rule', 11, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='settings:rule');") |
| | | |
| | | /*sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '广播设置', 'SETTINGS', 'settings:broadcast', 5, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='settings:broadcast');")*/ |
| | | } else if a.Package == "vindicate" { //系统维护 |
| | | sort = 10 |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '设备维护', 'VINDICATE', 'vindicate:device', 1, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='vindicate:device');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '数据库维护', 'VINDICATE', 'vindicate:db', 2, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='vindicate:db');") |
| | | // sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '设备维护', 'VINDICATE', 'vindicate:device', 1, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='vindicate:device');") |
| | | // sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '数据库维护', 'VINDICATE', 'vindicate:db', 2, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='vindicate:db');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '更新设置', 'VINDICATE', 'vindicate:update', 1, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='vindicate:update');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '系统清理', 'VINDICATE', 'vindicate:clear', 2, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='vindicate:clear');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '重启设置', 'VINDICATE', 'vindicate:restart', 3, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='vindicate:restart');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '备份还原', 'VINDICATE', 'vindicate:backup', 4, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='vindicate:backup');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '系统信息', 'VINDICATE', 'vindicate:sysinfo', 5, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='vindicate:sysinfo');") |
| | | |
| | | } else if a.Package == "syslog" { |
| | | sort = 11 |
| | | } else if a.Package == "knowledge" { |
| | | sort = 12 |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '设置', 'KNOWLEDGE', 'knowledge:set', 1, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='knowledge:set');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '查看', 'KNOWLEDGE', 'knowledge:show', 2, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='knowledge:show');") |
| | | |
| | | } else if a.Package == "dataStack" { |
| | | sort = 13 |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '数据栈信息', 'DATASTACK', 'dataStack:cameraInfo', 1, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='dataStack:cameraInfo');") |
| | | sqls = append(sqls, "INSERT INTO sys_menu(`id`,`parent_id`,`parent_ids`,`type`,`name`,`module`,`permission`,`sort`,`icon`,`url`,`enable`,`del_flag`) select '"+uuid.NewV4().String()+"', '"+a.Id+"', ',0,"+a.Id+",', 1, '独立场景', 'DATASTACK', 'dataStack:selfRule', 2, NULL, NULL, 1, 0 where not exists (select 1 from sys_menu where permission='dataStack:selfRule');") |
| | | |
| | | } |
| | | |
| | | menu := models.SysMenu{} |