| | |
| | | import org.dom4j.io.SAXReader; |
| | | import org.dom4j.io.XMLWriter; |
| | | import org.dom4j.tree.AbstractAttribute; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | public class ColumnUtil { |
| | | |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @description 根据属性获取sql中的驼峰字段 |
| | | * @date 15:44 2022/3/31 |
| | | * @param: property |
| | | * @return java.lang.String |
| | | **/ |
| | | public static String getColumnFromProperty(String property) { |
| | | StringBuffer buffer = new StringBuffer(); |
| | | List<String> temp = new ArrayList<>(); |
| | | for (int i = 0; i < property.length(); i++) { |
| | | //是否为大写 |
| | | if (property.charAt(i) >= 65 && property.charAt(i) <= 90) { |
| | | temp.add(property.charAt(i) + ""); |
| | | } else { |
| | | //消费之前的 |
| | | if (temp.size() > 0) { |
| | | buffer.append(("_" + StringUtil.concat(temp, "")).toLowerCase()); |
| | | temp.clear(); |
| | | } |
| | | buffer.append(property.charAt(i)); |
| | | } |
| | | } |
| | | |
| | | if (temp.size() > 0) { |
| | | buffer.append(("_" + StringUtil.concat(temp, "")).toLowerCase()); |
| | | temp.clear(); |
| | | } |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | |
| | | @SuppressWarnings("rawtypes") |
| | | public static void addColumnToMapper(String path, String columnName, String property, String type) { |
| | | File xmlPath = new File(path); |