package com.product.org.admin.test;
|
|
import java.util.List;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
import com.product.common.utils.HttpTest;
|
|
|
public class TableTest extends HttpTest {
|
//{"msg":"视图已经存在:testView","code":"7095","status":"fail"}
|
//success 成功
|
//fail 失败 打印msg
|
public static void main(String[] args) {
|
//runSql();//运行sql
|
addViewInfo();//新增视图
|
//upViewInfo();//修改视图表信息
|
//upViewSql();//修改视图sql
|
//deleteTable();// 删除视图
|
//getViewTableInfo();//通过uuid获取视图信息及字段信息
|
//getViewTableAll();//获取所有视图信息
|
}
|
/**
|
* 测试sql运行
|
*/
|
public static void runSql() {
|
Map m=new HashMap();
|
m.put("view_sql", " SELECT uuid,product_name NAMES,product_shortcode shortcode,tricode,NULL client_type_uuid,1 type FROM product_sys_products UNION ALL SELECT uuid,module_name,module_shortcode,tricode,NULL client_type_uuid,2 type FROM product_sys_modules UNION ALL SELECT uuid,function_name,function_shortcode,tricode,NULL client_type_uuid,3 type FROM product_sys_functions UNION ALL " +
|
" SELECT uuid,button_name,null function_shortcode,function_uuid tricode,client_type_uuid,4 type FROM product_sys_function_buttons ");//运行的sql
|
//m.put("view_sql", " UPDATE product_sys_datamodel_table SET table_description = '视图描述' WHERE table_id = 163 ");//运行的sql
|
m.put("url/api", "/api/view/runSql/v1");
|
m.put("version","V1");
|
testPost(m);
|
}
|
/**
|
* 新增视图表
|
*/
|
public static void addViewInfo() {
|
Map m=new HashMap();
|
m.put("url/api", "/api/view/saveViewInfo/v1");
|
m.put("version","V1");
|
m.put("table_name", "module_function_views");//视图名en
|
m.put("table_description", "模块功能列表视图");//视图描述
|
//m.put("uuid", "");//视图uuid
|
m.put("table_base_view", "product_sys_datamodel_table product_sys_datamodel_field");//视图基础表
|
m.put("view_sql", " SELECT uuid,product_name NAMES,product_shortcode shortcode,tricode,NULL client_type_uuid,1 type FROM product_sys_products UNION ALL SELECT uuid,module_name,module_shortcode,tricode,NULL client_type_uuid,2 type FROM product_sys_modules UNION ALL SELECT uuid,function_name,function_shortcode,tricode,NULL client_type_uuid,3 type FROM product_sys_functions UNION ALL \r\n" +
|
"SELECT uuid,button_name,null function_shortcode,function_uuid tricode,client_type_uuid,4 type FROM product_sys_function_buttons ");//运行的sql
|
m.put("create_view_sql_status", "true");//是否保存sql
|
List fList = new ArrayList();
|
|
Map fieldMap=new HashMap();
|
fieldMap.put("field_name", "uuid");//字段名1
|
fieldMap.put("field_type","string");//类型
|
fieldMap.put("field_length","64");//长度
|
fieldMap.put("field_unit","0");//小数位
|
fieldMap.put("related_table","");
|
fList.add(fieldMap);
|
Map fieldMap2=new HashMap();
|
fieldMap2.put("field_name", "NAME");//字段名2
|
fieldMap2.put("field_type","string");//类型
|
fieldMap2.put("field_length","255");//长度
|
fieldMap2.put("field_unit","0");//小数位
|
fieldMap2.put("related_table","");
|
fList.add(fieldMap2);
|
Map fieldMap3=new HashMap();
|
fieldMap3.put("field_name", "shortcode");//字段名2
|
fieldMap3.put("field_type","string");//类型
|
fieldMap3.put("field_length","255");//长度
|
fieldMap3.put("field_unit","0");//小数位
|
fieldMap3.put("related_table","");
|
fList.add(fieldMap3);
|
Map fieldMap4=new HashMap();
|
fieldMap4.put("field_name", "tricode");//字段名2
|
fieldMap4.put("field_type","string");//类型
|
fieldMap4.put("field_length","800");//长度
|
fieldMap4.put("field_unit","0");//小数位
|
fieldMap4.put("related_table","");
|
fList.add(fieldMap4);
|
Map fieldMap5=new HashMap();
|
fieldMap5.put("field_name", "client_type_uuid");//字段名2
|
fieldMap5.put("field_type","string");//类型
|
fieldMap5.put("field_length","255");//长度
|
fieldMap5.put("field_unit","0");//小数位
|
fieldMap5.put("related_table","");
|
fList.add(fieldMap5);
|
Map fieldMap6=new HashMap();
|
fieldMap6.put("field_name", "type");//字段名2
|
fieldMap6.put("field_type","string");//类型
|
fieldMap6.put("field_length","255");//长度
|
fieldMap6.put("field_unit","0");//小数位
|
fieldMap6.put("related_table","");
|
fList.add(fieldMap6);
|
m.put("product_sys_datamodel_filed", fList);
|
testPost(m);
|
}
|
/**
|
* 修改视图表信息
|
*/
|
public static void upViewInfo() {
|
Map m=new HashMap();
|
m.put("url/api", "/api/view/saveViewInfo/v1");
|
m.put("version","V1");
|
m.put("table_name", "testView");//视图名
|
m.put("table_description", "修改视图");//视图描述
|
m.put("uuid", "19fe3ffe-87fc-4f6f-866e-a1fa0906ffcb");//视图uuid
|
testPost(m);
|
}
|
/**
|
* 修改视图sql
|
*/
|
public static void upViewSql() {
|
Map m=new HashMap();
|
m.put("url/api", "/api/view/saveViewInfo/v1");
|
m.put("version","V1");
|
m.put("table_name", "uptestViewSql");//视图名
|
m.put("table_description", "修改视图sql");//视图描述
|
m.put("uuid", "3717d6bf-9263-4039-ad6f-0cc482b711f1");//视图uuid
|
m.put("table_base_view", "product_sys_datamodel_table");//视图基础表
|
m.put("view_sql", " SELECT uuid FROM product_sys_datamodel_table ");//运行的sql
|
m.put("create_view_sql_status", "true");
|
List fList = new ArrayList();
|
|
Map fieldMap=new HashMap();
|
fieldMap.put("field_name", "uuid");//字段名1
|
fieldMap.put("field_type","string");//类型
|
fieldMap.put("field_length","64");//长度
|
fieldMap.put("field_unit","0");//小数位
|
fieldMap.put("related_table","product_sys_datamodel_table");
|
fList.add(fieldMap);
|
m.put("product_sys_datamodel_filed", fList);
|
testPost(m);
|
}
|
/**
|
* 删除视图
|
*/
|
public static void deleteTable(){
|
Map m=new HashMap();
|
m.put("url/api", "/api/view/deleteTable/v1");
|
m.put("version","V1");
|
m.put("uuid", "8994ea1b-48a9-4b7e-bb92-c2b554e5cffa");//视图uuid
|
testPost(m);
|
}
|
/**
|
* 获取视图信息及子表信息
|
*/
|
public static void getViewTableInfo(){
|
Map m=new HashMap();
|
m.put("url/api", "/api/view/getViewTableInfo/v1");
|
m.put("version","V1");
|
m.put("uuid", "a990c60c-8e71-41e8-a57d-cb0ed76febcd");//视图uuid
|
testPost(m);
|
}
|
/**
|
* 获取所有实现信息
|
*/
|
public static void getViewTableAll(){
|
Map m=new HashMap();
|
m.put("url/api", "/api/view/getViewTableAll/v1");
|
m.put("version","V1");
|
testPost(m);
|
}
|
}
|