-- 智精灵空调平台参数（SYSTEM_DICT / SYSTEM_DICT_DATA）
-- 字典类型：CONDITIONER_PARAM

INSERT INTO `SYSTEM_DICT` (`CODE`, `NAME`, `REMARK`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`)
SELECT 'CONDITIONER_PARAM', '智精灵空调平台参数', 'base_url、username、password', 1, CURRENT_TIMESTAMP, NULL, NULL, 0
WHERE NOT EXISTS (
    SELECT 1 FROM `SYSTEM_DICT` WHERE `CODE` = 'CONDITIONER_PARAM' AND `DELETED` = 0
);

INSERT INTO `SYSTEM_DICT_DATA` (`DICT_ID`, `CODE`, `LABEL`, `REMARK`, `SORT`, `DISABLED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`)
SELECT d.`ID`, 'http://119.45.163.5:1125/zjl/API', 'base_url', 'API 根地址（不含末尾斜杠）', 1, 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0
FROM `SYSTEM_DICT` d
WHERE d.`CODE` = 'CONDITIONER_PARAM' AND d.`DELETED` = 0
  AND NOT EXISTS (
    SELECT 1 FROM `SYSTEM_DICT_DATA` x WHERE x.`DICT_ID` = d.`ID` AND x.`LABEL` = 'base_url' AND x.`DELETED` = 0
  );

INSERT INTO `SYSTEM_DICT_DATA` (`DICT_ID`, `CODE`, `LABEL`, `REMARK`, `SORT`, `DISABLED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`)
SELECT d.`ID`, 'admin', 'username', '登录用户名', 2, 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0
FROM `SYSTEM_DICT` d
WHERE d.`CODE` = 'CONDITIONER_PARAM' AND d.`DELETED` = 0
  AND NOT EXISTS (
    SELECT 1 FROM `SYSTEM_DICT_DATA` x WHERE x.`DICT_ID` = d.`ID` AND x.`LABEL` = 'username' AND x.`DELETED` = 0
  );

INSERT INTO `SYSTEM_DICT_DATA` (`DICT_ID`, `CODE`, `LABEL`, `REMARK`, `SORT`, `DISABLED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`)
SELECT d.`ID`, '12345678', 'password', '登录密码', 3, 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0
FROM `SYSTEM_DICT` d
WHERE d.`CODE` = 'CONDITIONER_PARAM' AND d.`DELETED` = 0
  AND NOT EXISTS (
    SELECT 1 FROM `SYSTEM_DICT_DATA` x WHERE x.`DICT_ID` = d.`ID` AND x.`LABEL` = 'password' AND x.`DELETED` = 0
  );
