|
| 1 | +package io.arex.agent.thirdparty.util.parse.sqlparse.action; |
| 2 | + |
| 3 | +import com.fasterxml.jackson.databind.node.ObjectNode; |
| 4 | +import io.arex.agent.thirdparty.util.JacksonHelperUtil; |
| 5 | +import io.arex.agent.thirdparty.util.parse.sqlparse.Parse; |
| 6 | +import io.arex.agent.thirdparty.util.parse.sqlparse.parse.CommonParse; |
| 7 | +import io.arex.agent.thirdparty.util.parse.sqlparse.parse.ExpressionParse; |
| 8 | +import io.arex.agent.thirdparty.util.parse.sqlparse.parse.JoinParse; |
| 9 | +import io.arex.agent.thirdparty.util.parse.sqlparse.parse.OrderByParse; |
| 10 | +import io.arex.agent.thirdparty.util.parse.sqlparse.parse.TableParse; |
| 11 | +import io.arex.agent.thirdparty.util.parse.sqlparse.constants.DbParseConstants; |
| 12 | +import net.sf.jsqlparser.statement.delete.Delete; |
| 13 | + |
| 14 | +/** |
| 15 | + * @author niyan |
| 16 | + * @date 2024/4/3 |
| 17 | + * @since 1.0.0 |
| 18 | + */ |
| 19 | +public class DeleteParse implements Parse<Delete> { |
| 20 | + |
| 21 | + private final ObjectNode sqlObjectNode; |
| 22 | + public DeleteParse() { |
| 23 | + sqlObjectNode = JacksonHelperUtil.getObjectNode(); |
| 24 | + // action parse |
| 25 | + sqlObjectNode.put(DbParseConstants.ACTION, DbParseConstants.DELETE); |
| 26 | + } |
| 27 | + @Override |
| 28 | + public ObjectNode parse(Delete parseObj) { |
| 29 | + |
| 30 | + // tables parse |
| 31 | + TableParse.parseDelTable(parseObj.getTables(), parseObj.getTable(), sqlObjectNode); |
| 32 | + |
| 33 | + // join parse |
| 34 | + JoinParse.parse(parseObj.getJoins(), sqlObjectNode); |
| 35 | + |
| 36 | + // where parse |
| 37 | + ExpressionParse.parseWhere(parseObj.getWhere(), sqlObjectNode); |
| 38 | + |
| 39 | + // orderBy parse |
| 40 | + OrderByParse.parse(parseObj.getOrderByElements(), sqlObjectNode); |
| 41 | + |
| 42 | + // limit parse |
| 43 | + CommonParse.parseLimit(parseObj.getLimit(), sqlObjectNode); |
| 44 | + |
| 45 | + return sqlObjectNode; |
| 46 | + } |
| 47 | +} |
0 commit comments