!94 表结构更新

Merge pull request !94 from dxfeng/feature/dxf
pull/95/MERGE
dxfeng 3 years ago committed by Gitee
commit db5fdd7606
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -23,7 +23,7 @@ public class ExtendGroupBO {
public static List<TypeTreeVO> buildTypeTree(List<ExtendGroupPO> extendGroupPOS) {
if(CollectionUtils.isEmpty(extendGroupPOS)){
if (CollectionUtils.isEmpty(extendGroupPOS)) {
return Collections.emptyList();
}
@ -42,10 +42,12 @@ public class ExtendGroupBO {
.build()).collect(Collectors.toList());
//获取非一级
Map<Long, List<TypeTreeVO>> collects = typeTreeVOS.stream().filter(item -> item.getPid() != null).collect(Collectors.groupingBy(TypeTreeVO :: getPid));
Map<Long, List<TypeTreeVO>> 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);
}).filter(item -> item.getPid() == null).collect(Collectors.toList());
}
@ -76,7 +78,7 @@ public class ExtendGroupBO {
break;
}
if (extendGroupPO.getId() < 0) {
if (extendGroupPO.getIsSystemDefault() == 0) {
} else if (null == extendGroupPO.getPid()) {
tableName += "EXT";

@ -108,6 +108,8 @@ public class ExtendInfoBO {
.browserShow(1)
.customValue(infoFieldParam.getFieldType().toString())
.showOrder(showOrder)
// 非系统初始化字段
.isSystemDefault(1)
.creator((long) user.getUID())
.deleteType(0)
.createTime(new Date())

@ -42,6 +42,8 @@ public class ExtendGroupPO {
private Integer showOrder;
private Integer isSystemDefault;
private Long creator;
private int deleteType;
private Date createTime;

@ -109,6 +109,8 @@ public class ExtendInfoPO {
*/
private Integer showOrder;
private Integer isSystemDefault;
private Long creator;
private int deleteType;
private Date createTime;

@ -41,6 +41,7 @@ public class ExtendTitlePO {
*/
private String isShow;
private Integer isSystemDefault;
private Long creator;
private Integer deleteType;

@ -5,6 +5,8 @@
<result column="id" property="id"/>
<result column="extend_type" property="extendType"/>
<result column="group_name" property="groupName"/>
<result column="show_order" property="showOrder"/>
<result column="is_system_default" property="isSystemDefault"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="create_time" property="createTime"/>
@ -19,6 +21,7 @@
, t.pid
, t.extend_type
, t.group_name
, t.is_system_default
, t.creator
, t.show_order
, t.delete_type
@ -101,6 +104,9 @@
<if test="showOrder != null ">
show_order,
</if>
<if test="isSystemDefault != null ">
is_system_default,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="creator != null">
@ -130,6 +136,9 @@
<if test="showOrder != null ">
#{showOrder},
</if>
<if test="isSystemDefault != null ">
#{isSystemDefault},
</if>
</trim>
</insert>

@ -3,6 +3,7 @@ package com.engine.organization.mapper.extend;
import com.engine.organization.entity.extend.po.ExtendInfoPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/**
@ -15,7 +16,7 @@ public interface ExtendInfoMapper {
List<ExtendInfoPO> listFields(@Param("extendType") String extendType, @Param("extendGroupId") String extendGroupId, @Param("tableName") String tableName, @Param("operateType") String operateType);
int countFieldsByGroupId(@Param("groupId") Long groupId);
int countFieldsByGroupId(@Param("tableName") String tableName, @Param("groupId") Long groupId);
int updateExtendInfo(ExtendInfoPO extendInfo);
@ -28,5 +29,11 @@ public interface ExtendInfoMapper {
List<Object> listFieldsByTableName(@Param("tableName") String tableName, @Param("fieldName") String fieldName);
int deleteExtendInfoByIds(@Param("ids") Collection<Long> ids);
void deleteTableColumn(@Param("tableName") String tableName, @Param("fieldName") String fieldName);
List<ExtendInfoPO> getExtendInfosByIds(@Param("ids") Collection<Long> ids);
}

@ -20,6 +20,7 @@
<result column="browser_show" property="browserShow"/>
<result column="custom_value" property="customValue"/>
<result column="show_order" property="showOrder"/>
<result column="is_system_default" property="isSystemDefault"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="create_time" property="createTime"/>
@ -48,6 +49,7 @@
, t.browser_show
, t.custom_value
, t.show_order
, t.is_system_default
, t.creator
, t.delete_type
, t.create_time
@ -121,6 +123,9 @@
<if test="showOrder != null ">
show_order,
</if>
<if test="isSystemDefault != null ">
is_system_default,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="creator != null">
@ -186,6 +191,9 @@
<if test="showOrder != null ">
#{showOrder},
</if>
<if test="isSystemDefault != null ">
#{isSystemDefault},
</if>
</trim>
</insert>
<update id="addTableColumn">
@ -205,6 +213,22 @@
WHERE id = #{id} AND delete_type = 0
</update>
<update id="deleteExtendInfoByIds">
UPDATE jcl_field_extendinfo
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</update>
<update id="deleteTableColumn">
ALTER TABLE ${tableName}
DROP
COLUMN
${fieldName};
</update>
<select id="listFields" resultMap="BaseResultMap">
SELECT
@ -231,6 +255,7 @@
from jcl_field_extendinfo t
where t.delete_type = 0
and extend_group_id = #{groupId}
and table_name = #{tableName}
</select>
<select id="getMaxId" resultType="java.lang.Long">
select max(id)
@ -241,6 +266,16 @@
select ${fieldName}
from ${tableName}
</select>
<select id="getExtendInfosByIds" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
from jcl_field_extendinfo t
where t.delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>

@ -7,6 +7,7 @@
<result column="title" property="title"/>
<result column="show_order" property="showOrder"/>
<result column="is_show" property="isShow"/>
<result column="is_system_default" property="isSystemDefault"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="create_time" property="createTime"/>
@ -22,6 +23,7 @@
, t.title
, t.show_order
, t.is_show
, t.is_system_default
, t.creator
, t.delete_type
, t.create_time
@ -57,6 +59,9 @@
<if test="isShow != null ">
is_show,
</if>
<if test="isSystemDefault != null ">
is_system_default,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="creator != null">
@ -84,6 +89,9 @@
<if test="isShow != null ">
#{isShow},
</if>
<if test="isSystemDefault != null ">
#{isSystemDefault},
</if>
</trim>
</insert>
<update id="updateExtendTitle" parameterType="com.engine.organization.entity.extend.po.ExtendTitlePO">

@ -66,6 +66,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
OrganizationAssert.notBlank(groupType, "分组信息有误,请确认");
Map<String, Object> datas = new HashMap<>();
Long groupId = Long.parseLong(groupType);
String tableName = ExtendGroupBO.getTableNameByGroupPO(getExtendGroupMapper().getGroupById(groupId));
List<ExtendTitlePO> extendTitleList = getExtendTitleMapper().getTitlesByGroupID(groupId);
List<Map<String, Object>> tabs = new ArrayList<>();
int idx = 1;
@ -75,8 +76,8 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
tab.put("title", extendTitle.getTitle());
tab.put("isShow", extendTitle.getIsShow());
tab.put("groupid", extendTitle.getId());
tab.put("viewAttr", extendTitle.getGroupId() < 0 ? 1 : 2);
tab.put("editable", getExtendInfoMapper().countFieldsByGroupId(extendTitle.getId()) == 0);
tab.put("viewAttr", extendTitle.getIsSystemDefault() == 0 ? 1 : 2);
tab.put("editable", getExtendInfoMapper().countFieldsByGroupId(tableName, extendTitle.getId()) == 0);
tabs.add(tab);
}
datas.put("status", "1");
@ -102,7 +103,6 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
for (int i = 0; i < records.size(); i++) {
// 存在ID则更新 不存在ID则增加
ExtendInfoFieldParam infoFieldParam = JSONObject.toJavaObject((JSONObject) records.get(i), ExtendInfoFieldParam.class);
// TODO
ExtendInfoPO extendInfo = ExtendInfoBO.convertFieldParam2ExtendInfo(user, infoFieldParam, extendGroup, extendGroupId, i + 1);
if (null != extendInfo.getId()) {
@ -113,6 +113,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
// 获取操作表最大id,生成字段名
Long maxId = getExtendInfoMapper().getMaxId();
extendInfo.setFieldName("field" + (maxId + 1));
extendInfo.setIsSystemDefault(1);
updateCount += getExtendInfoMapper().insertExtendInfo(extendInfo);
// 新增表结构
getExtendInfoMapper().addTableColumn(extendInfo.getTableName(), extendInfo.getFieldName(), extendInfo.getFieldType());
@ -152,6 +153,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
}
if (null == extendTitle.getId()) {
extendTitle.setIsSystemDefault(1);
extendTitle.setCreator((long) user.getUID());
extendTitle.setCreateTime(new Date());
extendTitle.setDeleteType(0);
@ -185,6 +187,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
extendTitle.setCreator((long) user.getUID());
extendTitle.setCreateTime(new Date());
extendTitle.setDeleteType(0);
extendTitle.setIsSystemDefault(1);
getExtendTitleMapper().insertIgnoreNull(extendTitle);
ids.add(extendTitle.getId());
@ -242,9 +245,8 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
String fieldIdRowKey;
int showOrder = extendInfoPO.getShowOrder();
boolean isUsed = false;
// TODO 去除脏数据后调整为extendInfoPO.getId() > 0
// 系统字段id<0
boolean isSysField = extendInfoPO.getExtendGroupId() < 0;
// 是否为系统字段
boolean isSysField = extendInfoPO.getIsSystemDefault() == 0;
if (isSysField) {
fieldIdRowKey = fieldId + "_hrm";
} else {
@ -253,9 +255,6 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
if (!isSysField) {
isUsed = ExtendInfoBO.fieldIsUsed(extendInfoPO.getTableName(), extendInfoPO.getFieldName());
}
// TODO 去除脏数据后调整为extendInfoPO.getId() > 0
boolean allowHide = extendInfoPO.getExtendGroupId() > 0;
boolean allowModify = extendInfoPO.getExtendGroupId() > 0;
BrowserComInfo BrowserComInfo = new BrowserComInfo();
List<Object> fieldTypeObj = new ArrayList<>();
@ -353,9 +352,9 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
//允许个人修改字段check框属性
Map<String, Object> checkPropsModifyInfo = new HashMap<>();
checkPropsEnableInfo.put("viewAttr", allowHide ? 2 : 1);
checkPropsModifyInfo.put("viewAttr", allowModify ? 2 : 1);
checkPropsRequiredInfo.put("viewAttr", allowHide ? 2 : 1);
checkPropsEnableInfo.put("viewAttr", !isSysField ? 2 : 1);
checkPropsModifyInfo.put("viewAttr", !isSysField ? 2 : 1);
checkPropsRequiredInfo.put("viewAttr", !isSysField ? 2 : 1);
checkPropsInfo.put("enable", checkPropsEnableInfo);
checkPropsInfo.put("required", checkPropsRequiredInfo);
@ -454,6 +453,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
e.setPid(fieldTypeTreeParam.getParentId());
e.setIsShow(fieldTypeTreeParam.getIsShow());
e.setShowOrder(showOrder + 1);
e.setIsSystemDefault(1);
e.setCreator((long) user.getUID());
e.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
e.setCreateTime(new Date());
@ -472,10 +472,21 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
@Override
public void deleteFieldDefined(ExtendFieldSearchParam param) {
Collection<Long> ids = param.getId();
Long groupId = param.getGroupId();
Long groupType = param.getGroupType();
ExtendGroupPO groupById = getExtendGroupMapper().getGroupById(groupType);
List<ExtendInfoPO> extendInfoList = getExtendInfoMapper().getExtendInfosByIds(ids);
// 删除数据
getExtendInfoMapper().deleteExtendInfoByIds(ids);
// 删除表结构
for (ExtendInfoPO extendInfoPO : extendInfoList) {
getExtendInfoMapper().deleteTableColumn(extendInfoPO.getTableName(), extendInfoPO.getFieldName());
// 明细表浏览按钮额外删除span字段
if (null != groupById.getPid() && 3 == extendInfoPO.getControlType()) {
getExtendInfoMapper().deleteTableColumn(extendInfoPO.getTableName(), extendInfoPO.getFieldName() + "span");
}
}
}
@ -490,6 +501,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
.title(extendGroupPO.getGroupName())
.showOrder(max)
.isShow("1")
.isSystemDefault(1)
.creator((long) user.getUID())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.createTime(new Date())
@ -502,6 +514,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
.extendType(moduleTypeEnum.getValue())
.groupName(fieldTypeTreeParam.getName())
.showOrder(++max)
.isSystemDefault(1)
.creator((long) user.getUID())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
.createTime(new Date())

@ -176,4 +176,17 @@ public class FieldDefinedController {
return ReturnResult.exceptionHandle(e.getMessage());
}
}
@POST
@Path("/{moduleTypeEnum}/del")
@Produces(MediaType.APPLICATION_JSON)
public ReturnResult deleteFieldDefined(@Context HttpServletRequest request, @Context HttpServletResponse response, @PathParam("moduleTypeEnum") ModuleTypeEnum moduleTypeEnum, @RequestBody ExtendFieldSearchParam param) {
try {
User user = HrmUserVarify.getUser(request, response);
getFieldDefinedWrapper(user).deleteFieldDefined(param);
return ReturnResult.successed();
} catch (Exception e) {
return ReturnResult.exceptionHandle(e.getMessage());
}
}
}

@ -35,6 +35,7 @@ public class FieldDefinedWrapper extends Service {
/**
*
*
* @param groupType
* @return
*/
@ -54,6 +55,7 @@ public class FieldDefinedWrapper extends Service {
/**
*
*
* @param param
* @return
*/
@ -63,12 +65,11 @@ public class FieldDefinedWrapper extends Service {
public ReturnResult changeTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) {
getFieldDefinedService(user).changeTree(moduleTypeEnum,fieldTypeTreeParam);
getFieldDefinedService(user).changeTree(moduleTypeEnum, fieldTypeTreeParam);
return ReturnResult.successed();
}
public int deleteTitle(Long id) {
return getFieldDefinedService(user).deleteTitle(id);
}
@ -91,4 +92,8 @@ public class FieldDefinedWrapper extends Service {
public Map<String, Object> getFieldDefinedInfo(ExtendFieldSearchParam param) {
return getFieldDefinedService(user).getFieldDefinedInfo(param);
}
public void deleteFieldDefined(ExtendFieldSearchParam param) {
getFieldDefinedService(user).deleteFieldDefined(param);
}
}

Loading…
Cancel
Save