| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.binding.MapperMethod; |
| | | import org.apache.ibatis.executor.Executor; |
| | | import org.apache.ibatis.logging.Log; |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.mapping.SqlCommandType; |
| | | import org.apache.ibatis.plugin.*; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ReflectionUtils; |
| | | |
| | | import java.lang.reflect.Constructor; |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Method; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; |
| | | SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType(); |
| | | Object target = invocation.getArgs()[1]; |
| | | |
| | | if(target instanceof MapperMethod.ParamMap) { |
| | | try { |
| | | target = ((MapperMethod.ParamMap) target).get("param1"); |
| | |
| | | /** |
| | | * 给属性赋值 |
| | | */ |
| | | private void setFieldValue(Field field, Object target, Object value) throws Exception { |
| | | private void setFieldValue(Field field, Object target, Object value) { |
| | | try { |
| | | field.setAccessible(true); |
| | | field.set(target, value); |
| | | field.setAccessible(false); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取属性值 |
| | | */ |
| | | private Object getFieldValue(Field field, Object target) throws Exception { |
| | | private Object getFieldValue(Field field, Object target) { |
| | | try { |
| | | field.setAccessible(true); |
| | | Object value = field.get(target); |
| | | field.setAccessible(false); |
| | | return value; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |