operDocJSON.jsp
3.47 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<%@ page language="java" contentType="application/json" pageEncoding="UTF-8"%>
<%@page import="net.sf.json.*"%>
<%@ page import="java.util.*" %>
<%@ page import="weaver.general.*" %>
<%@ page import="weaver.hrm.*" %>
<jsp:useBean id="DocServiceForMobile" class="weaver.docs.webservices.DocServiceForMobile" scope="page" />
<jsp:useBean id="docReplyServiceForMobile" class="weaver.docs.webservices.reply.DocReplyServiceForMobile" scope="page" />
<%
out.clearBuffer();
User user = HrmUserVarify.getUser (request , response) ;
if(user==null) {
Map result = new HashMap();
//未登录或登录超时
result.put("result", "200001");
result.put("error", "未登录或登录超");
JSONObject jo = JSONObject.fromObject(result);
out.println(jo);
return;
}
response.setContentType("application/json;charset=UTF-8");
//操作方式 deletedoc:删除文档 addshare:新增共享 docollect:收藏 undocollect:取消收藏 createdoc:取消收藏
String operation = Util.null2String(request.getParameter("operation"));
if(!operation.equals("addshare")
&&!operation.equals("deletedoc")
&&!operation.equals("docollect")
&&!operation.equals("undocollect")
&&!operation.equals("createdoc")
){
Map result = new HashMap();
//operation参数未设置正确
result.put("result", "200002");
result.put("error", "operation参数未设置正确");
JSONObject jo = JSONObject.fromObject(result);
out.println(jo);
return;
}
String newdocreply = Util.null2String(request.getParameter("newdocreply"));
String documentid = Util.null2String(request.getParameter("documentid"));
String shareuserids = Util.null2String(request.getParameter("shareuserids"));
int replyid = Util.getIntValue(request.getParameter("replyid"));
int replytype = Util.getIntValue(request.getParameter("replytype"));
Map result =null;
if(operation.equals("addshare")){
result = DocServiceForMobile.addShare(documentid,shareuserids,user);
}else if(operation.equals("deletedoc")){
result = DocServiceForMobile.deleteDoc(documentid,user);
}else if(operation.equals("docollect")){
String favobjid = Util.null2String(request.getParameter("favobjid"));
String favtype = Util.null2String(request.getParameter("favtype"));
String favid = Util.null2String(request.getParameter("favid"));
Map<String,String> params = new HashMap<String,String>();
params.put("favobjid",favobjid);
params.put("favtype",favtype);
params.put("favid",favid);
if("".equals(favtype)){ //老的接口,是没有这些参数的,为了兼容老的数据
params.put("favobjid",documentid);
params.put("favtype","1"); //1,文档收藏
params.put("favid","-1"); //默认的目录,我的收藏
}
result = DocServiceForMobile.doCollect(user,params);
}else if(operation.equals("undocollect")){
String favobjid = Util.null2String(request.getParameter("favobjid"));
String favtype = Util.null2String(request.getParameter("favtype"));
if("".equals(favtype)){ //老的接口,是没有这些参数的,为了兼容老的数据
favobjid = documentid;
favtype = "1";
}
result = DocServiceForMobile.undoCollect(favobjid,favtype,user);
}else if(operation.equals("createdoc")){
if(newdocreply.equals("1"))
{
result = docReplyServiceForMobile.saveReply(request,user);
}
else
{
result = DocServiceForMobile.createDoc(request,user);
}
}else if(operation.equals("saveReply")){
result = docReplyServiceForMobile.saveReply(request,user);
}
JSONObject jo = JSONObject.fromObject(result);
out.println(jo);
%>