修复了WrapperUtils中的bug
parent
07beec4039
commit
912bf97e3f
|
@ -20,7 +20,7 @@ public class WrapperUtils {
|
|||
* - 一般的参数会与直接使用{@link QueryWrapper#allEq(Map, boolean)}相同
|
||||
* <p>
|
||||
* - 对于时间类({@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中生成
|
||||
*/
|
||||
|
@ -37,7 +37,7 @@ public class WrapperUtils {
|
|||
if (key.endsWith("Start")) {
|
||||
wrapper.ge(key.substring(0, key.length() - 5), value);
|
||||
} else if (key.endsWith("End")) {
|
||||
wrapper.ge(key.substring(key.length() - 3), value);
|
||||
wrapper.le(key.substring(0, key.length() - 3), value);
|
||||
}
|
||||
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.service.IStaffService;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseMap;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.WrapperUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.SneakyThrows;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -25,19 +28,21 @@ public class MybatisPlusTests {
|
|||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
public void test() {
|
||||
System.out.println(objectMapper.writeValueAsString(
|
||||
ResponseMap.ofSuccess("ok",
|
||||
staffService.getOne(Wrappers.<Staff>query().last("limit 1"))
|
||||
)
|
||||
));
|
||||
Map<Object, Object> map = new HashMap<>();
|
||||
map.put("123", "456");
|
||||
map.put(894, 789);
|
||||
System.out.println(objectMapper.writeValueAsString(
|
||||
ResponseMap.ofSuccess("ok", map)
|
||||
));
|
||||
staffService.page(new Page<Staff>(2, 1));
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
public void wrapperTest() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("time", "aaa");
|
||||
map.put("stimeStart", LocalDateTime.now());
|
||||
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