修复了WrapperUtils中的bug
parent
07beec4039
commit
912bf97e3f
|
@ -20,7 +20,7 @@ public class WrapperUtils {
|
||||||
* - 一般的参数会与直接使用{@link QueryWrapper#allEq(Map, boolean)}相同
|
* - 一般的参数会与直接使用{@link QueryWrapper#allEq(Map, boolean)}相同
|
||||||
* <p>
|
* <p>
|
||||||
* - 对于时间类({@link LocalDateTime}或{@link LocalDate}或{@link LocalTime}),
|
* - 对于时间类({@link LocalDateTime}或{@link LocalDate}或{@link LocalTime}),
|
||||||
* 会按照key的后缀处理,若为Start则处理为column >= key,End则处理为column <= key
|
* 会按照key的后缀处理,若为Start则处理为column >= value,End则处理为column <= value
|
||||||
*
|
*
|
||||||
* @param null2IsNull 若为真,将value为null的值在SQL中生成为IS NULL;否则值为null的参数不会在SQL中生成
|
* @param null2IsNull 若为真,将value为null的值在SQL中生成为IS NULL;否则值为null的参数不会在SQL中生成
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +37,7 @@ public class WrapperUtils {
|
||||||
if (key.endsWith("Start")) {
|
if (key.endsWith("Start")) {
|
||||||
wrapper.ge(key.substring(0, key.length() - 5), value);
|
wrapper.ge(key.substring(0, key.length() - 5), value);
|
||||||
} else if (key.endsWith("End")) {
|
} else if (key.endsWith("End")) {
|
||||||
wrapper.ge(key.substring(key.length() - 3), value);
|
wrapper.le(key.substring(0, key.length() - 3), value);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,17 @@ package cn.edu.hfut.rmdjzz.projectmanagement;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Staff;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Staff;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseMap;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.WrapperUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -25,19 +28,21 @@ public class MybatisPlusTests {
|
||||||
@Resource
|
@Resource
|
||||||
private ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
System.out.println(objectMapper.writeValueAsString(
|
staffService.page(new Page<Staff>(2, 1));
|
||||||
ResponseMap.ofSuccess("ok",
|
}
|
||||||
staffService.getOne(Wrappers.<Staff>query().last("limit 1"))
|
|
||||||
)
|
@SneakyThrows
|
||||||
));
|
@Test
|
||||||
Map<Object, Object> map = new HashMap<>();
|
public void wrapperTest() {
|
||||||
map.put("123", "456");
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put(894, 789);
|
map.put("time", "aaa");
|
||||||
System.out.println(objectMapper.writeValueAsString(
|
map.put("stimeStart", LocalDateTime.now());
|
||||||
ResponseMap.ofSuccess("ok", map)
|
map.put("null", null);
|
||||||
));
|
map.put("etimeEnd", LocalDate.now());
|
||||||
|
QueryWrapper<String> wrapper = WrapperUtils.<String>allEqAndTimeIntervalQueryWrapper(map, true);
|
||||||
|
System.out.println(wrapper.getCustomSqlSegment());
|
||||||
|
System.out.println(objectMapper.writeValueAsString(wrapper.getParamNameValuePairs()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue