| | |
| | | |
| | | 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 `owner_car_open_user` (\n" + |
| | | " `open_user_id` varchar(30) NOT NULL COMMENT 'app用户ID',\n" + |
| | | " `open_id` varchar(128) NOT NULL COMMENT '微信或支付宝开放ID',\n" + |
| | | " `car_num` varchar(32) NOT NULL COMMENT '车牌号',\n" + |
| | | " `open_type` varchar(12) NOT NULL DEFAULT 'WECHAT' COMMENT '微信WECHAT 支付宝 ALI',\n" + |
| | | " `nickname` varchar(255) DEFAULT NULL COMMENT '昵称',\n" + |
| | | " `headimgurl` varchar(255) DEFAULT NULL COMMENT '微信头像',\n" + |
| | | public static final String createTableSql = "CREATE TABLE `user_storehouse` (\n" + |
| | | " `us_id` varchar(30) NOT NULL COMMENT '主键ID',\n" + |
| | | " `b_id` varchar(30) NOT NULL COMMENT '业务Id',\n" + |
| | | " `res_id` varchar(30) NOT NULL COMMENT '资源ID',\n" + |
| | | " `res_name` varchar(100) NOT NULL COMMENT '资源名称',\n" + |
| | | " `store_id` varchar(30) NOT NULL COMMENT '商户ID',\n" + |
| | | " `stock` varchar(100) DEFAULT NULL COMMENT '库存数',\n" + |
| | | " `user_id` varchar(30) NOT NULL COMMENT '用户ID',\n" + |
| | | " `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',\n" + |
| | | " `status_cd` varchar(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,0, 在用 1失效',\n" + |
| | | " PRIMARY KEY (`open_user_id`)\n" + |
| | | " `status_cd` varchar(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考t_dict表,0, 在用 1失效',\n" + |
| | | " `mini_stock` varchar(100) DEFAULT NULL COMMENT '最小计量总数',\n" + |
| | | " `res_code` varchar(50) DEFAULT NULL COMMENT '资源编码'\n" + |
| | | ")"; |
| | | |
| | | public static void main(String[] args) { |
| | | String desc = "车辆微信关系"; |
| | | String id = "openUserId"; |
| | | String name = "ownerCarOpenUser"; |
| | | String shareName = "user"; //生成到那个服务下 |
| | | String shareColumn = "open_user_id"; |
| | | String shareParam = "openUserId"; |
| | | |
| | | String desc = "用户物品"; |
| | | String id = "usId"; |
| | | String name = "userStorehouse"; |
| | | String shareName = "store"; //生成到那个服务下 |
| | | 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("required", requireds); |
| | | System.out.println(param.toJSONString()); |
| | | } |
| | | |
| | | } |