Browse Source

teamwok扩展属性服务

luojing 5 years ago
parent
commit
194e33c557

+ 19 - 1
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/factory/CustomExtFieldReleFactory.java

@@ -69,7 +69,7 @@ public class CustomExtFieldReleFactory extends AbstractFactory {
 	}
 
 	/**
-	 * 根据关联ID列示扩展属性ID信息列表
+	 * 根据关联ID列示扩展属性信息列表
 	 * @param correlationId
 	 * @return
 	 * @throws Exception
@@ -86,6 +86,24 @@ public class CustomExtFieldReleFactory extends AbstractFactory {
 		return em.createQuery(cq.where(p)).getResultList();
 	}
 	
+	/**
+	 * 根据扩展属性类型列示扩展属性信息列表
+	 * @param type
+	 * @return
+	 * @throws Exception
+	 */
+	public List<CustomExtFieldRele> listFieldReleObjByType( String type ) throws Exception {
+		if( StringUtils.isEmpty( type ) ){
+			throw new Exception("type can not be empty!");
+		}
+		EntityManager em = this.entityManagerContainer().get(CustomExtFieldRele.class);
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<CustomExtFieldRele> cq = cb.createQuery(CustomExtFieldRele.class);
+		Root<CustomExtFieldRele> root = cq.from(CustomExtFieldRele.class);
+		Predicate p = cb.equal( root.get(CustomExtFieldRele_.type), type );
+		return em.createQuery(cq.where(p)).getResultList();
+	}
+	
 	/**
 	 * 根据关联ID列示扩展属性ID信息列表
 	 * @param correlationId

+ 20 - 1
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/jaxrs/extfield/CustomExtFieldReleAction.java

@@ -94,7 +94,7 @@ public class CustomExtFieldReleAction extends StandardJaxrsAction {
 	@Path("list/{correlationId}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void listFieldsWithProject(@Suspended final AsyncResponse asyncResponse, 
+	public void listFieldsWithCorrelation(@Suspended final AsyncResponse asyncResponse, 
 			@Context HttpServletRequest request,
 			@JaxrsParameterDescribe("关联ID") @PathParam("correlationId") String correlationId ) {
 		ActionResult<List<ActionListWithCorrelation.Wo>> result = new ActionResult<>();
@@ -108,6 +108,25 @@ public class CustomExtFieldReleAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 	
+	@JaxrsMethodDescribe(value = "根据扩展属性类型查询扩展属性信息列表.", action = ActionListWithType.class)
+	@GET
+	@Path("listPublicFields/{type}")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void listFieldsWithType(@Suspended final AsyncResponse asyncResponse, 
+			@Context HttpServletRequest request,
+			@JaxrsParameterDescribe("扩展属性类型") @PathParam("type") String type ) {
+		ActionResult<List<ActionListWithType.Wo>> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);	
+		try {
+			result = new ActionListWithType().execute( request, effectivePerson, type );
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+	
 	@JaxrsMethodDescribe(value = "创建或者更新一个扩展属性关联信息.", action = ActionSave.class)
 	@POST
 	@Path("relevance")

+ 17 - 0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/service/CustomExtFieldReleQueryService.java

@@ -65,6 +65,23 @@ public class CustomExtFieldReleQueryService {
 			throw e;
 		}
 	}
+	
+	/**
+	 * 根据扩展属性类型查询扩展属性关联信息
+	 * @param type
+	 * @return
+	 * @throws Exception
+	 */
+	public List<CustomExtFieldRele> listReleWithType( String type ) throws Exception {
+		if (StringUtils.isEmpty(type)) {
+			return new ArrayList<>();
+		}
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			return customExtFieldReleService.listReleWithType(emc, type);
+		} catch (Exception e) {
+			throw e;
+		}
+	}
 
 	public String getExtFieldDisplayName(String projectId, String extFieldName) throws Exception {
 		if( StringUtils.isEmpty( projectId )  ){

+ 12 - 0
o2server/x_teamwork_assemble_control/src/main/java/com/x/teamwork/assemble/control/service/CustomExtFieldReleService.java

@@ -51,6 +51,18 @@ class CustomExtFieldReleService {
 		}
 	}
 	
+	/**
+	 * 根据扩展属性类型查询扩展属性关联信息
+	 * @param emc
+	 * @param type
+	 * @return
+	 * @throws Exception 
+	 */
+	protected List<CustomExtFieldRele> listReleWithType(EntityManagerContainer emc, String type ) throws Exception {
+		Business business = new Business( emc );
+		return business.customExtFieldReleFactory().listFieldReleObjByType( type );
+	}
+	
 	/**
 	 * 根据扩展属性ID删除项目扩展属性信息
 	 * @param emc