| | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.client.RestTemplate; |
| | | import com.java110.db.dao.IQueryServiceDAO; |
| | | import com.java110.utils.factory.ApplicationContextFactory; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.springframework.beans.BeansException; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.web.client.RestTemplateBuilder; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.context.ApplicationContextAware; |
| | | import org.springframework.http.converter.StringHttpMessageConverter; |
| | | |
| | | import java.nio.charset.Charset; |
| | | |
| | | public class TableToJson { |
| | | |
| | | //show create table c_orders 用这个语句获取 |
| | | public static final String createTableSql = "CREATE TABLE `machine_type` (\n" + |
| | | " `type_id` varchar(30) NOT NULL COMMENT '设备类型ID',\n" + |
| | | " `machine_type_cd` varchar(30) NOT NULL COMMENT '设备大类 详情看t_dict',\n" + |
| | | " `machine_type_name` varchar(30) NOT NULL COMMENT '设备类型名称',\n" + |
| | | public static final String createTableSql = "CREATE TABLE `parking_space` (\n" + |
| | | " `ps_id` varchar(30) NOT NULL COMMENT '车位ID',\n" + |
| | | " `b_id` varchar(30) NOT NULL COMMENT '业务Id',\n" + |
| | | " `community_id` varchar(30) NOT NULL COMMENT '小区ID',\n" + |
| | | " `num` varchar(12) NOT NULL COMMENT '车位编号',\n" + |
| | | " `pa_id` varchar(30) NOT NULL COMMENT '停车场ID',\n" + |
| | | " `state` varchar(4) NOT NULL COMMENT '车位状态 出售 S,出租 H ,空闲 F',\n" + |
| | | " `area` decimal(7,2) NOT NULL COMMENT '车位面积',\n" + |
| | | " `remark` varchar(300) DEFAULT NULL COMMENT '备注',\n" + |
| | | " `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',\n" + |
| | | " `status_cd` varchar(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效',\n" + |
| | | " KEY `idx_bm_machine_id` (`type_id`) USING BTREE\n" + |
| | | " `parking_type` varchar(3) NOT NULL DEFAULT '1' COMMENT '1:普通车位 2:子母车位 3:豪华车位'\n" + |
| | | ")"; |
| | | |
| | | public static void main(String[] args) { |
| | | String desc = "老人类型"; |
| | | String id = "typeId"; |
| | | String name = "govOldPersonType"; |
| | | String shareName = "cust"; //生成到那个服务下 |
| | | String shareColumn = "ca_id"; |
| | | String shareParam = "caId"; |
| | | |
| | | String desc = "车位"; |
| | | String id = "psId"; |
| | | String name = "parkingSpace"; |
| | | String shareName = "community"; //生成到那个服务下 |
| | | String shareColumn = "community_id"; |
| | | String shareParam = "communityId"; |
| | | //业务名称 desc 业务编码名称生成后类名 name 主键 id 需要放到那个服务 shareName |
| | | String newSql = createTableSql.substring(createTableSql.indexOf("(") + 1, createTableSql.lastIndexOf(")")); |
| | | String tableName = createTableSql.substring(createTableSql.indexOf("TABLE") + 5, createTableSql.indexOf("(")); |
| | |
| | | if ("KEY".equals(key)) { |
| | | continue; |
| | | } |
| | | if ("PRIMARY".equals(key)) { |
| | | continue; |
| | | } |
| | | if ("b_id".equals(key)) { |
| | | continue; |
| | | } |
| | |
| | | required.put("code", StringUtil.lineToHump(key)); |
| | | String comment = rowSql.contains("COMMENT") ? rowSql.substring(rowSql.indexOf("COMMENT '") + 9) : StringUtil.lineToHump(key); |
| | | comment = comment.trim(); |
| | | if(comment.contains(",")){ |
| | | if (comment.contains(",")) { |
| | | comment = comment.split(",")[0]; |
| | | } |
| | | if(comment.contains(" ")){ |
| | | if (comment.contains(" ")) { |
| | | comment = comment.split(" ")[0]; |
| | | } |
| | | |
| | |
| | | param.put("param", paramColumn); |
| | | param.put("required", requireds); |
| | | System.out.println(param.toJSONString()); |
| | | |
| | | } |
| | | |
| | | } |