// --------sys_dict_data  添加字典配置标签
COLUMN_KEY = 'dict_code';
function main() {
	// 验证用户权限
	'use api/user/acl/excerpt.js'

	const data = payload.get().body?.toObject();
	const newData = {};
	Object.keys(data).forEach((item) => {
		newData[camelToUnderscore(item)] = data[item];
	});
	const columnsArr = Object.keys(newData);
	let dataArr = Object.values(newData);
	const placeholders = [];

	columnsArr.push(COLUMN_KEY)
	columnsArr.push('proprietor_id')
	columnsArr.push('proprietor_name')

	dataArr.push(ex.suid().base58())
	dataArr.push(USER_INFO.user_id)
	dataArr.push(USER_INFO.nickname)

	dataArr.forEach(() => {
		placeholders.push('?');
	});
	placeholders.join(',');

	const columnsStr = columnsArr.join(',');
	const query = `INSERT INTO sys_dict_data (${columnsStr}) VALUES (${placeholders})`;
	const res = SQL.exec('system_sql', query, ...dataArr);

	if (res) {
		return okMsg(res);
	}
	return errMsg(507, '添加失败');
}
