-- 10.1.init-message.sql

/*
将 paas.example.com 替换为 paas.学校域名.edu.cn
*/


-- 以下脚本为可选操作

/*
 * 若部署了消息服务产品
 * 可默认创建几个管理员帐号，以及初始授权
 */


-- 创建管理帐号

use user;

-- 消息平台管理

INSERT INTO `TB_B_USER` (`ID`, `DELETED`, 
  `UID`, `PASSWORD`, `NAME`, `NAME_SPELLING`, `FULL_NAME_SPELLING`, 
  `CERTIFICATE_TYPE_ID`, `CERTIFICATE_NUMBER`, `PHONE_NUMBER`, `EMAIL`,
  `GENDER_ID`, `NATION_ID`, `COUNTRY_ID`, `ADDRESS_ID`)
VALUES ('80', 0, 
  '80', 'messageadmin', '消息平台管理员', 'messageadmin', 'messageadmin', 
  '20001', '80', null, 'messageadmin@supwisdom.com',
  '30001', '40001', '50156', '310000');

INSERT INTO `TB_B_ACCOUNT` (`ID`, `DELETED`, `USER_ID`, 
  `ACCOUNT_NAME`, `ACCOUNT_EXPIRY_DATE`, `ORGANIZATION_ID`, `IDENTITY_TYPE_ID`, 
  `ACTIVATION`, `STATE`, `IS_DATA_CENTER`)
VALUES ('80', 0, '80', 
  'messageadmin', null, '1', '1',
  1, 'NORMAL', 0);

INSERT INTO `TB_B_SAFETY`(`ID`, `DELETED`, `USER_ID`, `SCORE`, `PASSWORD_SCORE`, `SECURE_EMAIL`, `SECURE_PHONE`)
VALUES ('80', 0, '80', '0', '0', null, null);

INSERT INTO `TB_B_ACCOUNT_ORGANIZATION` (`ID`, `DELETED`, 
  `ROOT_ORGANIZATION_ID`, `ACCOUNT_ID`, `ORGANIZATION_ID`)
VALUES ('80_1', 0, 
  '0', '80', '1');

INSERT INTO `TB_B_ACCOUNT_LABEL`(`ID`, `DELETED`, 
  `ACCOUNT_ID`, `LABEL_ID`)
VALUES ('80_1', 0, '80', '1');

commit;



-- 创建管理帐号的授权

use user_authz;


-- 消息平台管理

INSERT INTO `TB_ROLE` (`ID`, `COMPANY_ID`, `DELETED`, `ADD_ACCOUNT`, `ADD_TIME`, 
  `APPLICATION_ID`, `CODE`, `NAME`, `DESCRIPTION`, `ENABLED`, `EXTERNAL_ID`)
VALUES ('80', '1', 0, 'admin', '2020-07-01 00:00:00', 
  '1', 'message-admin', '消息平台管理员', '消息平台管理员', 1, '80');
INSERT INTO `TB_ROLE` (`ID`, `COMPANY_ID`, `DELETED`, `ADD_ACCOUNT`, `ADD_TIME`, 
  `APPLICATION_ID`, `CODE`, `NAME`, `DESCRIPTION`, `ENABLED`, `EXTERNAL_ID`)
VALUES ('81', '1', 0, 'admin', '2020-07-01 00:00:00', 
  '1', 'message-opt', '消息平台操作员', '消息平台操作员', 1, '81');

INSERT INTO `TB_GRANTED_ACCOUNT_ROLE` (`ID`, `COMPANY_ID`, `DELETED`,
  `ACCOUNT_ID`, `ROLE_ID`, 
  `GRANT_EXPIRED_DATE`)
VALUES ('80_80', '1', 0, 
  '80', '80',
  NULL);

INSERT INTO `TB_ROLE_USER` (`ID`, `COMPANY_ID`, `DELETED`, `ADD_ACCOUNT`, `ADD_TIME`,
  `ORIGIN_TYPE`, `ORIGIN_PK`, 
  `APPLICATION_ID`, `ROLE_ID`, `ACCOUNT_ID`, 
  `GRANT_EXPIRED_DATE`)
VALUES ('80_80', '1', 0, 'admin', '2019-07-01 00:00:00',
  NULL, NULL, 
  '1', '80', '80', 
  NULL);

commit;


