
INSERT INTO `sys_dict`( `createOn`, `updateOn`, `description`, `label`, `sort`, `type`, `value`) VALUES ( now(), now(), '服务机构权限', '在线撰写功能', 1, 'SERVICEORGAUTH', 'SA1');
INSERT INTO `sys_dict`( `createOn`, `updateOn`, `description`, `label`, `sort`, `type`, `value`) VALUES ( now(), now(), '服务机构权限', '共享模版权限', 2, 'SERVICEORGAUTH', 'SA2');
INSERT INTO `sys_dict`( `createOn`, `updateOn`, `description`, `label`, `sort`, `type`, `value`) VALUES ( now(), now(), '服务机构权限', '知识库权限', 3, 'SERVICEORGAUTH', 'SA3');
INSERT INTO `sys_dict`( `createOn`, `updateOn`, `description`, `label`, `sort`, `type`, `value`) VALUES ( now(), now(), '服务机构权限', '现场勘查功能', 4, 'SERVICEORGAUTH', 'SA4');
INSERT INTO `sys_dict`( `createOn`, `updateOn`, `description`, `label`, `sort`, `type`, `value`) VALUES ( now(), now(), '服务机构权限', '线下支付功能', 5, 'SERVICEORGAUTH', 'SA5');
INSERT INTO `sys_dict`( `createOn`, `updateOn`, `description`, `label`, `sort`, `type`, `value`) VALUES ( now(), now(), '服务机构权限', '共享专家权限', 6, 'SERVICEORGAUTH', 'SA6');
INSERT INTO `sys_dict`( `createOn`, `updateOn`, `description`, `label`, `sort`, `type`, `value`) VALUES ( now(), now(), '服务机构权限', '自营财务权限', 7, 'SERVICEORGAUTH', 'SA7');


CREATE TABLE `risk_serviceorg_auth` (
  `oid` bigint(20) NOT NULL COMMENT '主键ID',
	`createOn` datetime DEFAULT NULL COMMENT '创建时间',
  `updateOn` datetime DEFAULT NULL COMMENT '修改时间',
  `authType` varchar(20) DEFAULT NULL COMMENT '权限名',
  `authValue` varchar(20) DEFAULT NULL COMMENT '权限值',
  `org_id` bigint(20) DEFAULT NULL COMMENT '服务机构ID',
  PRIMARY KEY (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

ALTER TABLE `risk_serviceorg_auth`
MODIFY COLUMN `oid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID' FIRST;


INSERT INTO `risk_serviceorg_auth`( `createOn`, `updateOn`, `authType`, `authValue`, `org_id`)
select now(),
 now(),
 m.abc,
 '1',
  m.oid
	from
(select b.abc, a.oid
from risk_serviceorg a ,(select 'SA1' AS abc UNION
select 'SA2' AS abc UNION
select 'SA3' AS abc UNION
select 'SA4' AS abc UNION
select 'SA5' AS abc UNION
select 'SA6' AS abc UNION
select 'SA7' AS abc)b
where a.serviceOrgType = '1'
  AND a.selfSupport = '1'
	order by a.oid,b.abc)m;



INSERT INTO `risk_serviceorg_auth`( `createOn`, `updateOn`, `authType`, `authValue`, `org_id`)
select now(),
 now(),
 m.abc,
 '0',
  m.oid
	from
(select b.abc, a.oid
from risk_serviceorg a ,(select 'SA1' AS abc UNION
select 'SA2' AS abc UNION
select 'SA3' AS abc UNION
select 'SA4' AS abc UNION
select 'SA5' AS abc UNION
select 'SA6' AS abc UNION
select 'SA7' AS abc)b
where a.serviceOrgType = '1'
  AND (a.selfSupport = '2'or a.selfSupport  is null)
	order by a.oid,b.abc)m;


update risk_serviceorg_auth set authValue = 1 where authType = 'SA4'
and org_id in (select oid from risk_serviceorg where serviceOrgType = 1
and selfSupport = 2 and openTK = 1);


ALTER TABLE `risk_serviceorg`
DROP COLUMN `openTK`,
CHANGE COLUMN `selfSupport` `serviceMode` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '服务模式' ;


update risk_activity set gov = 0 where gov is null;
update risk_activity set isBackup = 0 where isBackup is null;

INSERT INTO `risk_menu`(`oid`, `createOn`, `updateOn`, `menuCode`, `menuDesc`, `menuName`, `parent_id`, `menuType`) VALUES (1010404, now(), NULL, '', '1', '活动列表', 10104, '2');

INSERT INTO `risk_systemconfig`( `createOn`, `updateOn`, `syskey`, `sysvalue`, `description`) VALUES (now(),now(), 'ops_manage_email', 'luopeng@bcxin.com.cn', '运维管理邮箱');