Browse Source

暂时处理返回的时间格式

lichunlei 1 year ago
parent
commit
a66d0974ac

+ 26 - 0
src/main/java/com/kxs/adminap/filter/RMap.java

@@ -0,0 +1,26 @@
+package com.kxs.adminap.filter;
+
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
+
+public class RMap extends HashMap {
+
+	private static final long serialVersionUID = 1L;
+
+	@Override
+	public Object put(Object key, Object value) {
+		if(value != null) {
+			String type = value.getClass().getSimpleName();
+			if(type.equals("LocalDateTime")) {
+				LocalDateTime time = (LocalDateTime) value;
+				String format = time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+				return super.put(key, format);
+			}else {
+				return super.put(key, value);
+			}
+		}
+		return super.put(key, value);
+	}
+}

+ 1 - 1
src/main/resources/xml/main/UsersMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.kxs.adminap.dao.main.UsersMapper">
-  <resultMap id="MyMap" type="java.util.Map" />
+  <resultMap id="MyMap" type="com.kxs.adminap.filter.RMap" />
   <resultMap id="Count" type="java.lang.Integer" />
   <resultMap id="Sum" type="java.lang.Object" />
   <resultMap id="BaseResultMap" type="com.kxs.adminap.model.main.Users">