diff --git a/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java b/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java index 2b49bf14..9212661c 100644 --- a/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java +++ b/src/com/engine/organization/entity/extend/bo/ExtendGroupBO.java @@ -22,13 +22,12 @@ public class ExtendGroupBO { public static List buildTypeTree(List extendGroupPOS) { - if (CollectionUtils.isEmpty(extendGroupPOS)) { + if(CollectionUtils.isEmpty(extendGroupPOS)){ return Collections.emptyList(); } List typeTreeVOS = extendGroupPOS.stream().map(e -> TypeTreeVO.builder() - .addChild(e.getId() >= 0) .canClick(true) .domid(String.valueOf(e.getId())) .hasGroup(isHasGroup(e.getId())) @@ -40,12 +39,10 @@ public class ExtendGroupBO { .build()).collect(Collectors.toList()); //获取非一级 - Map> collects = typeTreeVOS.stream().filter(item -> item.getPid() != null).collect(Collectors.groupingBy(TypeTreeVO::getPid)); + Map> collects = typeTreeVOS.stream().filter(item -> item.getPid() != null).collect(Collectors.groupingBy(TypeTreeVO :: getPid)); - return typeTreeVOS.stream().peek(e -> { - e.setChilds(collects.get(e.getKey())); - e.setHaschild(collects.get(e.getKey()) != null && collects.get(e.getKey()).size() > 0); - }).filter(item -> item.getPid() == null).collect(Collectors.toList()); + return typeTreeVOS.stream().peek(e -> {e.setChilds(collects.get(e.getKey())); e.setHaschild(collects.get(e.getKey()) != null && collects.get(e.getKey()).size() > 0); + e.setAddChild(collects.get(e.getKey()) != null && collects.get(e.getKey()).size() > 0);}).filter(item -> item.getPid() == null).collect(Collectors.toList()); } diff --git a/src/com/engine/organization/entity/extend/po/ExtendTitlePO.java b/src/com/engine/organization/entity/extend/po/ExtendTitlePO.java index 7aa2c96f..fee7e4ef 100644 --- a/src/com/engine/organization/entity/extend/po/ExtendTitlePO.java +++ b/src/com/engine/organization/entity/extend/po/ExtendTitlePO.java @@ -42,7 +42,7 @@ public class ExtendTitlePO { private String isShow; - private Integer creator; + private Long creator; private Integer deleteType; private Date createTime; private Date updateTime; diff --git a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java index fc963a71..18ee6c5f 100644 --- a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java +++ b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.java @@ -1,6 +1,7 @@ package com.engine.organization.mapper.extend; import com.engine.organization.entity.extend.po.ExtendGroupPO; +import com.engine.organization.entity.fieldset.param.FieldTypeTreeParam; import org.apache.ibatis.annotations.Param; import java.util.Collection; @@ -46,4 +47,11 @@ public interface ExtendGroupMapper { * @return */ String getGroupNameById(@Param("id") String id); + + + + void insertIgnoreNull(ExtendGroupPO extendGroupPO); + + + void update(@Param("id")Long id, @Param("name")String name); } diff --git a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml index 370e821c..a2b11df7 100644 --- a/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml +++ b/src/com/engine/organization/mapper/extend/ExtendGroupMapper.xml @@ -67,5 +67,71 @@ and t.id= #{id} + + INSERT INTO jcl_field_extendgroup + + + creator, + + + delete_type, + + + create_time, + + + update_time, + + + + extend_type, + + + group_name, + + + pid, + + + is_show, + + + + + #{creator}, + + + #{deleteType}, + + + #{createTime}, + + + #{updateTime}, + + + #{extendType}, + + + #{groupName}, + + + #{pid}, + + + #{isShow}, + + + + + + update jcl_field_extendgroup + + group_name=#{name}, + + WHERE id = #{id} AND delete_type = 0 + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/extend/ExtendInfoMapper.java b/src/com/engine/organization/mapper/extend/ExtendInfoMapper.java index fba88e97..16e5d2fe 100644 --- a/src/com/engine/organization/mapper/extend/ExtendInfoMapper.java +++ b/src/com/engine/organization/mapper/extend/ExtendInfoMapper.java @@ -1,5 +1,6 @@ package com.engine.organization.mapper.extend; +import com.engine.organization.entity.extend.po.ExtendGroupPO; import com.engine.organization.entity.extend.po.ExtendInfoPO; import org.apache.ibatis.annotations.Param; @@ -12,15 +13,10 @@ import java.util.List; * @version: 1.0 */ public interface ExtendInfoMapper { - /** - * 列表查询 - * - * @param extendType - * @param extendGroupId - * @param tableName - * @return - */ + List listFields(@Param("extendType") String extendType, @Param("extendGroupId") String extendGroupId, @Param("tableName") String tableName,@Param("operateType")String operateType); int countFieldsByGroupId(@Param("groupId") Long groupId); + + } diff --git a/src/com/engine/organization/service/FieldDefinedService.java b/src/com/engine/organization/service/FieldDefinedService.java index 07215b80..82f386ee 100644 --- a/src/com/engine/organization/service/FieldDefinedService.java +++ b/src/com/engine/organization/service/FieldDefinedService.java @@ -20,7 +20,6 @@ public interface FieldDefinedService { /** * 获取左侧树 - * * @param moduleTypeEnum * @return */ @@ -60,28 +59,12 @@ public interface FieldDefinedService { /** - * 新增类型树 - * + * 新增或编辑类型树 * @param moduleTypeEnum * @param fieldTypeTreeParam * @return */ - void addTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam); + void changeTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam); - /** - * 删除标题信息 - * - * @param param - * @return - */ - int deleteTitle(ExtendTitleSaveParam param); - - /** - * 获取自定义字段列表 - * - * @param param - * @return - */ - Map getFieldDefinedInfo(ExtendTitleSaveParam param); } diff --git a/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java b/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java index 6e237cc7..89d46f92 100644 --- a/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java +++ b/src/com/engine/organization/service/impl/FieldDefinedServiceImpl.java @@ -11,6 +11,7 @@ import com.engine.organization.entity.extend.po.ExtendGroupPO; import com.engine.organization.entity.extend.po.ExtendTitlePO; import com.engine.organization.entity.fieldset.param.FieldTypeTreeParam; import com.engine.organization.entity.fieldset.vo.TypeTreeVO; +import com.engine.organization.enums.DeleteTypeEnum; import com.engine.organization.enums.ModuleTypeEnum; import com.engine.organization.mapper.extend.ExtendGroupMapper; import com.engine.organization.mapper.extend.ExtendInfoMapper; @@ -20,6 +21,7 @@ import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.db.MapperProxyFactory; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; +import weaver.general.Util; import java.util.*; import java.util.stream.Collectors; @@ -121,7 +123,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ } if (null == extendTitle.getId()) { - extendTitle.setCreator(user.getUID()); + extendTitle.setCreator((long)user.getUID()); extendTitle.setCreateTime(new Date()); extendTitle.setDeleteType(0); getExtendTitleMapper().insertIgnoreNull(extendTitle); @@ -151,11 +153,10 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ extendTitle.setIsShow(param.getIsShow()); extendTitle.setTitle(param.getGroupName()); extendTitle.setShowOrder(null == extendTitlePO ? 0 : extendTitlePO.getShowOrder() + 1); - extendTitle.setCreator(user.getUID()); + extendTitle.setCreator((long)user.getUID()); extendTitle.setCreateTime(new Date()); extendTitle.setDeleteType(0); getExtendTitleMapper().insertIgnoreNull(extendTitle); - ids.add(extendTitle.getId()); datas.put("groupid", StringUtils.join(ids, ",")); @@ -163,26 +164,46 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ return datas; } - @Override - public void addTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { - buildExtentGroup(moduleTypeEnum, fieldTypeTreeParam); - } + public void changeTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { + if (fieldTypeTreeParam.getId() == null) { + ExtendGroupPO extendGroupPO = buildExtendGroupType(moduleTypeEnum, fieldTypeTreeParam); + MapperProxyFactory.getProxy(ExtendGroupMapper.class).insertIgnoreNull(extendGroupPO); + //默认新增title + ExtendTitlePO extendTitlePO = buildExtendTitleType(extendGroupPO); + MapperProxyFactory.getProxy(ExtendTitleMapper.class).insertIgnoreNull(extendTitlePO); + }else { + MapperProxyFactory.getProxy(ExtendGroupMapper.class).update(fieldTypeTreeParam.getId(),fieldTypeTreeParam.getName()); + } - @Override - public int deleteTitle(ExtendTitleSaveParam param) { - int countFields = getExtendInfoMapper().countFieldsByGroupId(param.getGroupType()); - OrganizationAssert.isTrue(countFields == 0, "当前分组下仍有字段信息,请删除字段信息后删除分组"); - return getExtendTitleMapper().deleteExtendTitleByIds(DeleteParam.builder().ids(param.getId().toString()).build().getIds()); } - @Override - public Map getFieldDefinedInfo(ExtendTitleSaveParam param) { - return null; + private ExtendTitlePO buildExtendTitleType(ExtendGroupPO extendGroupPO) { + return ExtendTitlePO.builder() + .groupId(extendGroupPO.getId()) + .title(extendGroupPO.getGroupName()) + .showOrder(1) + .isShow("1") + .creator((long) user.getUID()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .createTime(new Date()) + .updateTime(new Date()).build(); } - private void buildExtentGroup(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { + private ExtendGroupPO buildExtendGroupType(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { + return ExtendGroupPO.builder() + .extendType(moduleTypeEnum.getValue()) + .groupName(fieldTypeTreeParam.getName()) + .creator((long) user.getUID()) + .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) + .createTime(new Date()) + .updateTime(new Date()) + .pid(fieldTypeTreeParam.getParentid()) + .isShow(fieldTypeTreeParam.getIsShow() == null ? "1" : fieldTypeTreeParam.getIsShow()).build(); } + + + } diff --git a/src/com/engine/organization/web/FieldDefinedController.java b/src/com/engine/organization/web/FieldDefinedController.java index 2ed51ae1..4651fca6 100644 --- a/src/com/engine/organization/web/FieldDefinedController.java +++ b/src/com/engine/organization/web/FieldDefinedController.java @@ -34,7 +34,7 @@ public class FieldDefinedController { @Path("/{moduleTypeEnum}/getTree") @Produces(MediaType.APPLICATION_JSON) public ReturnResult getTree(@Context HttpServletRequest request, @Context HttpServletResponse response, - @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum) { + @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum) { try { User user = HrmUserVarify.getUser(request, response); return getFieldDefinedWrapper(user).getTree(moduleTypeEnum); @@ -57,30 +57,19 @@ public class FieldDefinedController { } @POST - @Path("/{moduleTypeEnum}/addTree") + @Path("/{moduleTypeEnum}/changeTree") @Produces(MediaType.APPLICATION_JSON) - public ReturnResult addTree(@Context HttpServletRequest request, @Context HttpServletResponse response, + public ReturnResult changeTree(@Context HttpServletRequest request, @Context HttpServletResponse response, @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum, @RequestBody FieldTypeTreeParam fieldTypeTreeParam) { try { User user = HrmUserVarify.getUser(request, response); - return getFieldDefinedWrapper(user).addTree(moduleTypeEnum, fieldTypeTreeParam); + return getFieldDefinedWrapper(user).changeTree(moduleTypeEnum,fieldTypeTreeParam); } catch (Exception e) { return ReturnResult.exceptionHandle(e.getMessage()); } } - @POST - @Path("/{moduleTypeEnum}/editTree") - @Produces(MediaType.APPLICATION_JSON) - public ReturnResult editTree(@Context HttpServletRequest request, @Context HttpServletResponse response, - @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum,@RequestBody FieldTypeTreeParam fieldTypeTreeParam) { - try { - User user = HrmUserVarify.getUser(request, response); - return getFieldDefinedWrapper(user).getTree(moduleTypeEnum); - } catch (Exception e) { - return ReturnResult.exceptionHandle(e.getMessage()); - } - } + @GET @Path("/getTabInfo") diff --git a/src/com/engine/organization/wrapper/FieldDefinedWrapper.java b/src/com/engine/organization/wrapper/FieldDefinedWrapper.java index 31353d3c..b8a39171 100644 --- a/src/com/engine/organization/wrapper/FieldDefinedWrapper.java +++ b/src/com/engine/organization/wrapper/FieldDefinedWrapper.java @@ -34,7 +34,6 @@ public class FieldDefinedWrapper extends Service { /** * 获取标题分组 - * * @param groupType * @return */ @@ -54,7 +53,6 @@ public class FieldDefinedWrapper extends Service { /** * 新建分组 - * * @param param * @return */ @@ -63,11 +61,13 @@ public class FieldDefinedWrapper extends Service { } - public ReturnResult addTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { - getFieldDefinedService(user).addTree(moduleTypeEnum, fieldTypeTreeParam); + public ReturnResult changeTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) { + getFieldDefinedService(user).changeTree(moduleTypeEnum,fieldTypeTreeParam); return ReturnResult.successed(); } + + public int deleteTitle(ExtendTitleSaveParam param) { return getFieldDefinedService(user).deleteTitle(param); }