data.jsp
3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<%@page import="com.weaver.formmodel.util.StringHelper"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="weaver.general.Util"%>
<%@ page import="java.net.URLDecoder" %>
<%@ page import="java.io.UnsupportedEncodingException" %>
<%@ page import="com.engine.mobilemode.biz.json.MJSONObject" %>
<%@ page import="com.engine.mobilemode.biz.json.MJSONArray" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/mobilemode/mobile/base.jsp"%>
<%
int pageNo = Util.getIntValue(request.getParameter("pageNo"), 1);
int pageSize = Util.getIntValue(request.getParameter("pageSize"), 10);
int ctype = Util.getIntValue(request.getParameter("ctype"), -1);
String searchKey = Util.null2String(request.getParameter("searchKey"));
try {
searchKey = URLDecoder.decode(searchKey, "utf-8");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
List<MJSONObject> originDatas = new ArrayList<MJSONObject>();
originDatas.add(MJSONObject.fromObject("{'id':'1','type':'1','avatar':'/mobilemode/mobile/demo/plugin/UserAvatar/avatar.jpg', 'title':'热烈欢迎朱锟加入EBU技术中心','content':'2015梦想羊帆起航,EBU携手SME共创未来…', 'cat':'人事新闻', 'date':'2017-08-09','tel':'18888888888', 'email':'admin@admin.com'}"));
originDatas.add(MJSONObject.fromObject("{'id':'2','type':'2','avatar':'/mobilemode/mobile/demo/plugin/UserAvatar/avatar.jpg', 'title':'2012年6月份泛微销售业绩排行榜','content':'EBU携手SME共创未来…', 'cat':'公司新闻', 'date':'2017-07-09','tel':'18888888888', 'email':'admin@admin.com'}"));
originDatas.add(MJSONObject.fromObject("{'id':'3','type':'1','avatar':'/mobilemode/mobile/demo/plugin/UserAvatar/avatar.jpg', 'title':'热烈欢迎靳志远加入SME事业本部','content':'2015梦想羊帆起航,EBU携手SME共创未来…', 'cat':'人事新闻', 'date':'2017-06-09','tel':'18888888888', 'email':'admin@admin.com'}"));
originDatas.add(MJSONObject.fromObject("{'id':'4','type':'2','avatar':'/mobilemode/mobile/demo/plugin/UserAvatar/avatar.jpg', 'title':'2012年3月份泛微销售业绩排行榜','content':'', 'cat':'公司新闻', 'date':'2017-08-09','tel':'18888888888', 'email':'admin@admin.com'}"));
originDatas.add(MJSONObject.fromObject("{'id':'5','type':'0','avatar':'/mobilemode/mobile/demo/plugin/UserAvatar/avatar.jpg', 'title':'泛微OA签约上海电驱动股份有限公司','content':'梦想羊帆起航,EBU携手SME共创未来…', 'cat':'签约新闻', 'date':'2017-08-10','tel':'18888888888', 'email':'admin@admin.com'}"));
originDatas.add(MJSONObject.fromObject("{'id':'6','type':'2','avatar':'/mobilemode/mobile/demo/plugin/UserAvatar/avatar.jpg', 'title':'2012年4月份泛微销售业绩排行榜','content':'', 'cat':'公司新闻', 'date':'2017-07-22'}"));
originDatas.add(MJSONObject.fromObject("{'id':'7','type':'3','avatar':'/mobilemode/mobile/demo/plugin/UserAvatar/avatar.jpg', 'title':'2015年5月产品改进建议奖','content':'最多建议奖:奖金总额500元, 由每个月建议数(未经处理的客户建议不计)最多者获取', 'cat':'产品建议', 'date':'2017-08-09','tel':'18888888888', 'email':'admin@admin.com'}"));
int startIndex = (pageNo - 1) * pageSize;
int endIndex = startIndex + pageSize;
List<MJSONObject> datas = new ArrayList<MJSONObject>();
for(MJSONObject obj : originDatas){
int type = obj.getInteger("type");
if(ctype == -1){
datas.add(obj);
}else if(ctype == type){
datas.add(obj);
}
}
List<MJSONObject> result = new ArrayList<MJSONObject>();
for(MJSONObject obj : datas){
String title = obj.getString("title");
if(StringHelper.isNotEmpty(searchKey)){
if(title.indexOf(searchKey) != -1){
result.add(obj);
}
}else{
result.add(obj);
}
}
int size = result.size();
MJSONObject json = new MJSONObject();
json.put("totalSize", size);
json.put("datas", MJSONArray.fromObject(result.subList(startIndex, endIndex > size ? size : endIndex)));
out.print(json);
%>