修复Mybatis 更新BUG

v1.4.1
Parker 4 years ago
parent 1a331c7c27
commit 2b31db2988

@ -3,7 +3,6 @@ package org.opsli.api.web.test;
import io.swagger.annotations.ApiOperation;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.test.TestModel;
import org.opsli.common.annotation.ApiRestController;
import org.springframework.web.bind.annotation.GetMapping;
@ -13,9 +12,15 @@ import org.springframework.web.bind.annotation.GetMapping;
* @Author: Parker
* @CreateTime: 2020-09-13 17:40
* @Description:
*
* API @GetMapping @PostMapping
* Mapping Controller
*
*
*
*
*/
@ApiRestController("/test")
public interface ITestApi {
public interface TestApi {
@ApiOperation(value = "发送邮件", notes = "发送邮件")

@ -3,6 +3,7 @@ package org.opsli.core.conf.mybatis;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ReflectUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.binding.MapperMethod;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlCommandType;
@ -111,14 +112,23 @@ public class AutoFillInterceptor implements Interceptor {
* @param arg
*/
public void updateFill(Object arg) {
/**
* TODO
*
*
*
*/
Field[] fields = ReflectUtil.getFields(arg.getClass());
// 2020-09-19
// 修改这儿 有可能会拿到一个 MapperMethod需要特殊处理
Field[] fields;
if (arg instanceof MapperMethod.ParamMap) {
MapperMethod.ParamMap<?> paramMap = (MapperMethod.ParamMap<?>) arg;
if (paramMap.containsKey("et")) {
arg = paramMap.get("et");
} else {
arg = paramMap.get("param1");
}
if (arg == null) {
return;
}
fields = ReflectUtil.getFields(arg.getClass());
} else {
fields = ReflectUtil.getFields(arg.getClass());
}
for (Field f : fields) {
f.setAccessible(true);
switch (f.getName()) {

@ -30,7 +30,7 @@ import java.util.Collection;
*/
@Service
// 开启热数据标示 不加不生效
@EnableHotData
//@EnableHotData
public class TestServiceImpl extends CrudServiceImpl<TestMapper, TestModel, TestEntity> implements ITestService {
@Autowired(required = false)

@ -5,7 +5,7 @@ import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.wrapper.test.TestModel;
import org.opsli.api.web.test.ITestApi;
import org.opsli.api.web.test.TestApi;
import org.opsli.common.annotation.ApiRestController;
import org.opsli.core.base.concroller.BaseRestController;
import org.opsli.core.cache.pushsub.enums.CacheType;
@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit;
*/
@ApiRestController("/test")
public class TestRestRestController extends BaseRestController<TestModel, TestEntity, ITestService>
implements ITestApi {
implements TestApi {
private Random random = new Random();

@ -0,0 +1,30 @@
package org.opsli.modulars.test.web;
import org.opsli.api.base.result.ResultVo;
import org.opsli.api.web.test.TestApi;
import org.opsli.api.wrapper.test.TestModel;
import org.opsli.common.annotation.ApiRestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
/**
* @BelongsProject: opsli-boot
* @BelongsPackage: org.opsli.modulars.test.web
* @Author: Parker
* @CreateTime: 2020-09-13 17:40
* @Description:
*/
@ApiRestController("/test2")
public class TestRestRestController2{
@Autowired
TestApi testApi;
@GetMapping("/insert2")
public ResultVo insert(){
return testApi.insert(new TestModel());
}
}
Loading…
Cancel
Save