operDocJSON.jsp 3.47 KB

<%@ 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);
%>