diff --git a/src/com/api/organization/web/JclOrgController.java b/src/com/api/organization/web/JclOrgController.java new file mode 100644 index 00000000..ab099d3b --- /dev/null +++ b/src/com/api/organization/web/JclOrgController.java @@ -0,0 +1,12 @@ +package com.api.organization.web; + +import javax.ws.rs.Path; + +/** + * @author:dxfeng + * @createTime: 2022/08/02 + * @version: 1.0 + */ +@Path("/bs/hrmorganization") +public class JclOrgController extends com.engine.organization.web.JclOrgController { +} diff --git a/src/com/engine/organization/web/JclOrgController.java b/src/com/engine/organization/web/JclOrgController.java new file mode 100644 index 00000000..266f5935 --- /dev/null +++ b/src/com/engine/organization/web/JclOrgController.java @@ -0,0 +1,60 @@ +package com.engine.organization.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.organization.util.response.ReturnResult; +import com.engine.organization.wrapper.JclOrgWrapper; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2022/08/02 + * @version: 1.0 + */ +public class JclOrgController { + + public JclOrgWrapper getJclOrgWrapper(User user) { + return ServiceUtil.getService(JclOrgWrapper.class, user); + } + + @GET + @Path("/getJclOrgId") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getJclOrgId(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + String id = Util.null2String(map.get("id")); + String type = Util.null2String(map.get("type")); + return ReturnResult.successed(getJclOrgWrapper(user).getJclOrgId(id, type)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } + + @GET + @Path("/getEcOrgId") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult getEcOrgId(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + String id = Util.null2String(map.get("id")); + String type = Util.null2String(map.get("type")); + return ReturnResult.successed(getJclOrgWrapper(user).getEcOrgId(id, type)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } +} diff --git a/src/com/engine/organization/wrapper/JclOrgWrapper.java b/src/com/engine/organization/wrapper/JclOrgWrapper.java new file mode 100644 index 00000000..d6745d86 --- /dev/null +++ b/src/com/engine/organization/wrapper/JclOrgWrapper.java @@ -0,0 +1,55 @@ +package com.engine.organization.wrapper; + +import com.engine.organization.entity.company.po.CompPO; +import com.engine.organization.entity.department.po.DepartmentPO; +import com.engine.organization.util.OrganizationWrapper; +import com.engine.organization.util.relation.EcHrmRelationUtil; +import org.apache.commons.lang3.StringUtils; + +/** + * @author:dxfeng + * @createTime: 2022/08/02 + * @version: 1.0 + */ +public class JclOrgWrapper extends OrganizationWrapper { + + + public String getEcOrgId(String jclId, String type) { + if (StringUtils.isAnyBlank(jclId, type)) { + return null; + } + switch (type) { + case "1": + return EcHrmRelationUtil.getEcCompanyId(jclId); + case "2": + return EcHrmRelationUtil.getEcDepartmentId(jclId); + case "3": + default: + return ""; + } + } + + public String getJclOrgId(String ecId, String type) { + if (StringUtils.isAnyBlank(ecId, type)) { + return null; + } + String jclOrgId = ""; + switch (type) { + case "1": + CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(ecId); + if (null != jclCompanyId) { + jclOrgId = jclCompanyId.getId().toString(); + } + break; + case "2": + DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(ecId); + if (null != jclDepartmentId) { + jclOrgId = jclDepartmentId.getId().toString(); + } + case "3": + default: + break; + } + return jclOrgId; + } +}