增加MyBatis的Map参数传递和返回实例,支持分页。
This commit is contained in:
@@ -12,6 +12,7 @@ import org.springframework.core.NamedThreadLocal;
|
|||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import com.jeesite.common.lang.ByteUtils;
|
||||||
import com.jeesite.common.lang.DateUtils;
|
import com.jeesite.common.lang.DateUtils;
|
||||||
import com.jeesite.common.lang.TimeUtils;
|
import com.jeesite.common.lang.TimeUtils;
|
||||||
import com.jeesite.common.service.BaseService;
|
import com.jeesite.common.service.BaseService;
|
||||||
@@ -61,10 +62,10 @@ public class LogInterceptor extends BaseService implements HandlerInterceptor {
|
|||||||
|
|
||||||
// 打印JVM信息。
|
// 打印JVM信息。
|
||||||
if (logger.isDebugEnabled()){
|
if (logger.isDebugEnabled()){
|
||||||
logger.debug("计时结束: {} 用时: {} URI: {} 最大内存: {}m 已分配内存: {}m 已分配内存中的剩余空间: {}m 最大可用内存: {}m",
|
Runtime runtime = Runtime.getRuntime();
|
||||||
DateUtils.formatDate(endTime, "hh:mm:ss.SSS"), TimeUtils.formatDateAgo(executeTime),
|
logger.debug("计时结束: {} 用时: {} URI: {} 总内存: {} 已用内存: {}",
|
||||||
request.getRequestURI(), Runtime.getRuntime().maxMemory()/1024/1024, Runtime.getRuntime().totalMemory()/1024/1024, Runtime.getRuntime().freeMemory()/1024/1024,
|
DateUtils.formatDate(endTime, "hh:mm:ss.SSS"), TimeUtils.formatDateAgo(executeTime), request.getRequestURI(),
|
||||||
(Runtime.getRuntime().maxMemory()-Runtime.getRuntime().totalMemory()+Runtime.getRuntime().freeMemory())/1024/1024);
|
ByteUtils.formatByteSize(runtime.totalMemory()), ByteUtils.formatByteSize(runtime.totalMemory()-runtime.freeMemory()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.jeesite.modules.test.dao;
|
package com.jeesite.modules.test.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.jeesite.common.dao.CrudDao;
|
import com.jeesite.common.dao.CrudDao;
|
||||||
import com.jeesite.common.mybatis.annotation.MyBatisDao;
|
import com.jeesite.common.mybatis.annotation.MyBatisDao;
|
||||||
import com.jeesite.modules.test.entity.TestData;
|
import com.jeesite.modules.test.entity.TestData;
|
||||||
@@ -15,4 +18,9 @@ import com.jeesite.modules.test.entity.TestData;
|
|||||||
@MyBatisDao
|
@MyBatisDao
|
||||||
public interface TestDataDao extends CrudDao<TestData> {
|
public interface TestDataDao extends CrudDao<TestData> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 演示Map参数和返回值,支持分页
|
||||||
|
*/
|
||||||
|
public List<Map<String, Object>> findListForMap(Map<String, Object> params);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -51,6 +51,16 @@ public class TestDataService extends CrudService<TestDataDao, TestData> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<TestData> findPage(Page<TestData> page, TestData testData) {
|
public Page<TestData> findPage(Page<TestData> page, TestData testData) {
|
||||||
|
|
||||||
|
// // 演示Map参数和返回值,支持分页
|
||||||
|
// Page<Map<String, Object>> pageMap = new Page<>();
|
||||||
|
// Map<String, Object> params = MapUtils.newHashMap();
|
||||||
|
// params.put("testInput", "123");
|
||||||
|
// params.put("page", pageMap);
|
||||||
|
// pageMap.setList(dao.findListForMap(params));
|
||||||
|
// System.out.println(pageMap.getList());
|
||||||
|
// System.out.println(pageMap.getCount());
|
||||||
|
|
||||||
return super.findPage(page, testData);
|
return super.findPage(page, testData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,4 +12,17 @@
|
|||||||
ORDER BY ${sqlMap.order.toSql()}
|
ORDER BY ${sqlMap.order.toSql()}
|
||||||
</select> -->
|
</select> -->
|
||||||
|
|
||||||
|
<!-- 演示Map参数和返回值,支持分页 -->
|
||||||
|
<select id="findListForMap" resultType="map">
|
||||||
|
SELECT * FROM test_data a
|
||||||
|
<where>
|
||||||
|
<if test="testInput != null and testInput != ''">
|
||||||
|
AND a.test_input = #{testInput}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
<if test="page != null and page.orderBy != null and page.orderBy != ''">
|
||||||
|
ORDER BY ${page.orderBy}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user