表结构更新

pull/94/MERGE^2
dxfeng 3 years ago
parent c8604a8e40
commit 445507d10d

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

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

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

@ -3,6 +3,7 @@ package com.engine.organization.mapper.extend;
import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.entity.extend.po.ExtendInfoPO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List; 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); 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); int updateExtendInfo(ExtendInfoPO extendInfo);
@ -28,5 +29,11 @@ public interface ExtendInfoMapper {
List<Object> listFieldsByTableName(@Param("tableName") String tableName, @Param("fieldName") String fieldName); 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);
} }

@ -205,6 +205,22 @@
WHERE id = #{id} AND delete_type = 0 WHERE id = #{id} AND delete_type = 0
</update> </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 id="listFields" resultMap="BaseResultMap">
SELECT SELECT
@ -231,6 +247,7 @@
from jcl_field_extendinfo t from jcl_field_extendinfo t
where t.delete_type = 0 where t.delete_type = 0
and extend_group_id = #{groupId} and extend_group_id = #{groupId}
and table_name = #{tableName}
</select> </select>
<select id="getMaxId" resultType="java.lang.Long"> <select id="getMaxId" resultType="java.lang.Long">
select max(id) select max(id)
@ -241,6 +258,16 @@
select ${fieldName} select ${fieldName}
from ${tableName} from ${tableName}
</select> </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> </mapper>

@ -66,6 +66,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
OrganizationAssert.notBlank(groupType, "分组信息有误,请确认"); OrganizationAssert.notBlank(groupType, "分组信息有误,请确认");
Map<String, Object> datas = new HashMap<>(); Map<String, Object> datas = new HashMap<>();
Long groupId = Long.parseLong(groupType); Long groupId = Long.parseLong(groupType);
String tableName = ExtendGroupBO.getTableNameByGroupPO(getExtendGroupMapper().getGroupById(groupId));
List<ExtendTitlePO> extendTitleList = getExtendTitleMapper().getTitlesByGroupID(groupId); List<ExtendTitlePO> extendTitleList = getExtendTitleMapper().getTitlesByGroupID(groupId);
List<Map<String, Object>> tabs = new ArrayList<>(); List<Map<String, Object>> tabs = new ArrayList<>();
int idx = 1; int idx = 1;
@ -76,7 +77,7 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
tab.put("isShow", extendTitle.getIsShow()); tab.put("isShow", extendTitle.getIsShow());
tab.put("groupid", extendTitle.getId()); tab.put("groupid", extendTitle.getId());
tab.put("viewAttr", extendTitle.getGroupId() < 0 ? 1 : 2); tab.put("viewAttr", extendTitle.getGroupId() < 0 ? 1 : 2);
tab.put("editable", getExtendInfoMapper().countFieldsByGroupId(extendTitle.getId()) == 0); tab.put("editable", getExtendInfoMapper().countFieldsByGroupId(tableName, extendTitle.getId()) == 0);
tabs.add(tab); tabs.add(tab);
} }
datas.put("status", "1"); datas.put("status", "1");
@ -102,7 +103,6 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
for (int i = 0; i < records.size(); i++) { for (int i = 0; i < records.size(); i++) {
// 存在ID则更新 不存在ID则增加 // 存在ID则更新 不存在ID则增加
ExtendInfoFieldParam infoFieldParam = JSONObject.toJavaObject((JSONObject) records.get(i), ExtendInfoFieldParam.class); ExtendInfoFieldParam infoFieldParam = JSONObject.toJavaObject((JSONObject) records.get(i), ExtendInfoFieldParam.class);
// TODO
ExtendInfoPO extendInfo = ExtendInfoBO.convertFieldParam2ExtendInfo(user, infoFieldParam, extendGroup, extendGroupId, i + 1); ExtendInfoPO extendInfo = ExtendInfoBO.convertFieldParam2ExtendInfo(user, infoFieldParam, extendGroup, extendGroupId, i + 1);
if (null != extendInfo.getId()) { if (null != extendInfo.getId()) {
@ -472,10 +472,21 @@ public class FieldDefinedServiceImpl extends Service implements FieldDefinedServ
@Override @Override
public void deleteFieldDefined(ExtendFieldSearchParam param) { public void deleteFieldDefined(ExtendFieldSearchParam param) {
Collection<Long> ids = param.getId(); Collection<Long> ids = param.getId();
Long groupId = param.getGroupId();
Long groupType = param.getGroupType(); 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");
}
}
} }

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

Loading…
Cancel
Save