| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.client.RestTemplate; |
| | | import com.java110.core.context.Environment; |
| | | import com.java110.core.factory.Java110TransactionalFactory; |
| | | import com.java110.db.dao.IQueryServiceDAO; |
| | | import com.java110.dto.order.OrderItemDto; |
| | |
| | | import com.java110.utils.util.DateUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.apache.ibatis.executor.Executor; |
| | | import org.apache.ibatis.mapping.BoundSql; |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.mapping.ParameterMapping; |
| | | import org.apache.ibatis.mapping.SqlCommandType; |
| | | import org.apache.ibatis.mapping.*; |
| | | import org.apache.ibatis.plugin.*; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.apache.ibatis.session.Configuration; |
| | |
| | | Map<String, Object> sqlValue = new HashMap<>(); |
| | | //获取sql语句 |
| | | String sql = showSql(configuration, boundSql, sqlValue, sqlCommandType); |
| | | restTemplate = ApplicationContextFactory.getBean("restTemplate", RestTemplate.class); |
| | | if(Environment.isStartBootWay()){ |
| | | restTemplate = ApplicationContextFactory.getBean("outRestTemplate", RestTemplate.class); |
| | | }else { |
| | | restTemplate = ApplicationContextFactory.getBean("restTemplate", RestTemplate.class); |
| | | } |
| | | switch (sqlCommandType) { |
| | | case INSERT: |
| | | dealInsertSql(mappedStatement, parameter, sql, sqlValue); |
| | |
| | | */ |
| | | private void dealDeleteSql(MappedStatement mappedStatement, Object parameter, String sql, Map<String, Object> sqlValue) { |
| | | |
| | | String tmpTable = sql.substring(sql.indexOf("into") + 4, sql.indexOf("(")).trim(); |
| | | String tmpTable = sql.substring(sql.indexOf("from") + 4, sql.indexOf("where")).trim(); |
| | | String tmpTableHasT = tmpTable; |
| | | if(tmpTable.indexOf(" ") > 0){ |
| | | tmpTable = tmpTable.substring(0,tmpTable.indexOf(" ")); |
| | |
| | | String url = ServiceConstant.SERVICE_ORDER_URL + "/order/oIdApi/createOrderItem"; |
| | | HttpHeaders httpHeaders = new HttpHeaders(); |
| | | HttpEntity httpEntity = new HttpEntity(orderItemDto.toString(), httpHeaders); |
| | | if(Environment.isStartBootWay()){ |
| | | url = ServiceConstant.BOOT_SERVICE_ORDER_URL + "/order/oIdApi/createOrderItem"; |
| | | } |
| | | ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | |
| | | private void dealUpdateSql(MappedStatement mappedStatement, Object parameter, String sql, Map<String, Object> sqlValue) { |
| | | //RestTemplate restTemplate = ApplicationContextFactory.getBean("restTemplate", RestTemplate.class); |
| | | |
| | | String tmpTable = sql.substring(sql.indexOf("update") + 6, sql.indexOf("set")).trim(); |
| | | String tmpTable = sql.substring(sql.indexOf("update") + 6, sql.indexOf("set ")).trim(); |
| | | |
| | | String tmpTableHasT = tmpTable; |
| | | |
| | |
| | | String url = ServiceConstant.SERVICE_ORDER_URL + "/order/oIdApi/createOrderItem"; |
| | | HttpHeaders httpHeaders = new HttpHeaders(); |
| | | HttpEntity httpEntity = new HttpEntity(orderItemDto.toString(), httpHeaders); |
| | | ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class); |
| | | ResponseEntity<String> responseEntity = null; |
| | | if(Environment.isStartBootWay()){ |
| | | url = ServiceConstant.BOOT_SERVICE_ORDER_URL + "/order/oIdApi/createOrderItem"; |
| | | } |
| | | responseEntity = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | throw new IllegalArgumentException("注册事务回滚日志失败" + responseEntity); |
| | |
| | | String url = ServiceConstant.SERVICE_ORDER_URL + "/order/oIdApi/createOrderItem"; |
| | | HttpHeaders httpHeaders = new HttpHeaders(); |
| | | HttpEntity httpEntity = new HttpEntity(orderItemDto.toString(), httpHeaders); |
| | | if(Environment.isStartBootWay()){ |
| | | url = ServiceConstant.BOOT_SERVICE_ORDER_URL + "/order/oIdApi/createOrderItem"; |
| | | } |
| | | ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | |
| | | String[] tmpKeys = tmpKey.split(","); |
| | | |
| | | // if (values.size() < tmpKeys.length) { |
| | | // throw new IllegalArgumentException("sql 错误 key 和value 个数不等" + sql); |
| | | // throw new IllegalArgumentException("sql 错误 key P和value 个数不等" + sql); |
| | | // } |
| | | for (int keyIndex = 0; keyIndex < tmpKeys.length; keyIndex++) { |
| | | String key = tmpKeys[keyIndex].trim(); |