You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
4.0 KiB
137 lines
4.0 KiB
package com.fr.plugin.it.handler; |
|
|
|
import com.fr.decision.authority.AuthorityContext; |
|
import com.fr.decision.authority.data.personnel.DepRole; |
|
import com.fr.decision.fun.impl.BaseHttpHandler; |
|
import com.fr.decision.webservice.bean.user.DepartmentPostBean; |
|
import com.fr.json.JSONObject; |
|
import com.fr.plugin.it.dbAccessProvider.DataBean; |
|
import com.fr.plugin.it.dbAccessProvider.DbController; |
|
import com.fr.plugin.it.utils.*; |
|
import com.fr.plugin.transform.FunctionRecorder; |
|
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
|
import com.fr.web.core.A.D; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
import javax.servlet.http.HttpServletResponse; |
|
import java.util.List; |
|
|
|
@FunctionRecorder |
|
public class TestHander extends BaseHttpHandler { |
|
|
|
public TestHander() { |
|
} |
|
|
|
@Override |
|
public RequestMethod getMethod() { |
|
return RequestMethod.GET; |
|
} |
|
|
|
@Override |
|
public String getPath() { |
|
return "/test"; |
|
} |
|
|
|
@Override |
|
public boolean isPublic() { |
|
return true; |
|
} |
|
|
|
@Override |
|
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception { |
|
|
|
String type = req.getParameter("type"); |
|
|
|
if(type.equals("query2")){ |
|
String orgCode = req.getParameter("orgCode"); |
|
DataBean db = DbController.getOrg(orgCode); |
|
|
|
if(db == null){ |
|
ResponseUtils.failedResponse(res,"系统中无此机构!"); |
|
return; |
|
} |
|
|
|
if(db!=null){ |
|
String did = Utils.replaceNullStr(db.getDid(),""); |
|
String id = Utils.replaceNullStr(db.getId(),""); |
|
String code = Utils.replaceNullStr(db.getCode(),""); |
|
String pid = Utils.replaceNullStr(db.getPid(),""); |
|
String type2 = Utils.replaceNullStr(db.getType(),""); |
|
|
|
ResponseUtils.failedResponse(res,"did:"+did+";id:"+id+";code:"+code+";pid:"+pid+";type2:"+type2); |
|
return; |
|
} |
|
} |
|
|
|
if(type.equals("query")){ |
|
String orgCode = req.getParameter("orgCode"); |
|
String id = req.getParameter("id"); |
|
if(Utils.isNotNullStr(orgCode)){ |
|
DataBean db = DbController.getOrg(orgCode); |
|
|
|
id = db.getDid(); |
|
} |
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
jsonObject.put("isP",FRDepartmentUtils.hasChildren(id)); |
|
|
|
ResponseUtils.response(res,jsonObject); |
|
return; |
|
} |
|
|
|
if(type.equals("delete")){ |
|
List<DataBean> db = DbController.getAllOrg(); |
|
|
|
for(DataBean dba : db){ |
|
FRUtils.FRLogInfo("orgCode:"+dba.getCode()); |
|
DbController.deleteOrg(dba.getId()); |
|
} |
|
|
|
return; |
|
} |
|
|
|
String xmlResponse = ""; |
|
String orgCode = req.getParameter("id"); |
|
String orgCode2 = orgCode; |
|
String orgName = req.getParameter("name"); |
|
String pCode = req.getParameter("pid"); |
|
String pId = ""; |
|
|
|
if("1".equals(pCode)){ |
|
pId = "decision-dep-root"; |
|
}else{ |
|
pId = DbController.getOrg(pCode).getDid(); |
|
} |
|
|
|
if(Utils.isNullStr(pId)){ |
|
xmlResponse = ResponseTemplate.xmlTemplate("N","请先添加上级机构!",""); |
|
ResponseUtils.responseXml(res,xmlResponse); |
|
return; |
|
} |
|
|
|
try { |
|
DepartmentPostBean dpb = FRDepartmentUtils.addDP(pId,orgName); |
|
DataBean dataBean = new DataBean(); |
|
dataBean.setDid(dpb.getId()); |
|
dataBean.setCode(orgCode); |
|
DbController.add(dataBean); |
|
} catch (Exception e) { |
|
String message = e.getMessage(); |
|
if(Utils.isNullStr(message)){ |
|
message = "添加机构异常!"; |
|
} |
|
FRUtils.FRLogError("添加机构异常!"); |
|
xmlResponse = ResponseTemplate.xmlTemplate("N",message,""); |
|
ResponseUtils.responseXml(res,xmlResponse); |
|
return; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|