Commit e011f991 by s_guodong

设置total

parent 23c485dd
...@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import java.lang.reflect.Field;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -181,6 +182,7 @@ public abstract class AbstractCommonResource<V extends BaseVO> { ...@@ -181,6 +182,7 @@ public abstract class AbstractCommonResource<V extends BaseVO> {
ResponseSet responseSet = getCommonService().executeRule(baseVO, ruleArr); ResponseSet responseSet = getCommonService().executeRule(baseVO, ruleArr);
Object data = responseSet.getData(); Object data = responseSet.getData();
ReflectUtil.setValue2RespondVo(t, respondVoClass, data, baseVO.getClass()); ReflectUtil.setValue2RespondVo(t, respondVoClass, data, baseVO.getClass());
setTotal(t, baseVO);
responseSet.setData(t); responseSet.setData(t);
return new RespondRoot<>(responseSet); return new RespondRoot<>(responseSet);
} }
...@@ -206,6 +208,7 @@ public abstract class AbstractCommonResource<V extends BaseVO> { ...@@ -206,6 +208,7 @@ public abstract class AbstractCommonResource<V extends BaseVO> {
ResponseSet responseSet = getCommonService().executeCheck(baseVO, ruleArr); ResponseSet responseSet = getCommonService().executeCheck(baseVO, ruleArr);
Object data = responseSet.getData(); Object data = responseSet.getData();
ReflectUtil.setValue2RespondVo(t, respondVoClass, data, baseVO.getClass()); ReflectUtil.setValue2RespondVo(t, respondVoClass, data, baseVO.getClass());
setTotal(t, baseVO);
responseSet.setData(t); responseSet.setData(t);
return new RespondRoot<>(responseSet); return new RespondRoot<>(responseSet);
} }
...@@ -289,4 +292,25 @@ public abstract class AbstractCommonResource<V extends BaseVO> { ...@@ -289,4 +292,25 @@ public abstract class AbstractCommonResource<V extends BaseVO> {
} }
/**
* 设置分页查询返回total
*
* @param t
* @param baseVO
*/
private void setTotal(Object t, BaseVO baseVO) {
Long total = baseVO.getTotal();
if (total != null) {
Class<?> superclass = t.getClass().getSuperclass();
Field totalField = null;
try {
totalField = superclass.getDeclaredField("total");
totalField.setAccessible(true);
totalField.set(t, String.valueOf(total));
} catch (Exception e) {
}
}
}
} }
...@@ -15,5 +15,5 @@ import java.io.Serializable; ...@@ -15,5 +15,5 @@ import java.io.Serializable;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@Data @Data
public class RespondBaseVo implements Serializable { public class RespondBaseVo implements Serializable {
private String total;
} }
...@@ -13,7 +13,7 @@ public class BaseVO { ...@@ -13,7 +13,7 @@ public class BaseVO {
protected String id; protected String id;
protected String cifno; protected String cifno;
protected String pageId; protected String pageId;
public long total; public Long total;
protected Map<String, Object> params; protected Map<String, Object> params;
protected Map<String, Object> root; protected Map<String, Object> root;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment