pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;
import "../Table.sol";

contract CreateTable {
    TableFactory tableFactory = TableFactory(0x1001); 
    string constant KEY_NAME = "key";
    string constant KEY_VALUE = "key";
function create(string table_prefix) 
    public 
    {
        
        string memory TABLE_NAME =  string(abi.encodePacked(table_prefix, "_archives_file"));
        //创建表
        tableFactory.createTable(TABLE_NAME, KEY_NAME, "id,catalog_id,other_params,create_time,update_time");
        
        TABLE_NAME =  string(abi.encodePacked(table_prefix, "_file"));
        //创建表
        tableFactory.createTable(TABLE_NAME, KEY_NAME, "id,archive_file_id,other_params,create_time,update_time");
        
        TABLE_NAME =  string(abi.encodePacked(table_prefix, "_catalog"));
        //创建表
        tableFactory.createTable(TABLE_NAME, KEY_NAME, "id,parent_id,other_params,create_time,update_time");
        
        TABLE_NAME =  string(abi.encodePacked(table_prefix, "_application"));
        //创建表
        tableFactory.createTable(TABLE_NAME, KEY_NAME, "id,used_org_code,provider_audit_status,used_json_data,provider_json_data,application_json_data,create_time,update_time");
        
        TABLE_NAME =  string(abi.encodePacked(table_prefix, "_download_record"));
        //创建下载记录表
        tableFactory.createTable(TABLE_NAME, KEY_NAME, "id,weid,content_type,content_id,timestamp,application_id,watermark_data,create_time,sign");
        
        TABLE_NAME =  string(abi.encodePacked(table_prefix, "_decryption_record"));
        //创建解密记录表
        tableFactory.createTable(TABLE_NAME, KEY_NAME, "id,weid,sm9Hibe_id,content_type,content_id,timestamp,location,create_time,sign");
        
        TABLE_NAME =  string(abi.encodePacked(table_prefix, "_reading_record"));
        //创建阅读记录表
        tableFactory.createTable(TABLE_NAME, KEY_NAME, "id,weid,sm9Hibe_id,content_type,content_id,timestamp,duration,location,create_time,sign");
        
        TABLE_NAME =  string(abi.encodePacked(table_prefix, "_cert_record"));
        //创建证书审核记录表
        tableFactory.createTable(TABLE_NAME, KEY_NAME, "id,cert_id,user_id,org_id,audit_status,json_data,create_time");
        
    }
}
    