卡片按钮新增、删除

pull/59/head
dxfeng 2 years ago
parent 16794bf98c
commit cd11f06b7f

@ -1,7 +1,9 @@
package com.engine.organization.mapper.personnelcard;
import com.engine.organization.entity.personnelcard.po.CardButtonPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/**
@ -16,4 +18,8 @@ public interface CardButtonMapper {
List<CardButtonPO> listEnableButton();
List<Long> listAllId();
int deleteByIds(@Param("ids")Collection<Long> ids);
}

@ -30,6 +30,12 @@
, t.create_time
, t.update_time
</sql>
<delete id="deleteByIds">
delete from jcl_org_cardbutton where id in
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="listAll" resultType="com.engine.organization.entity.personnelcard.po.CardButtonPO">
select
<include refid="baseColumns"/>
@ -41,5 +47,10 @@
<include refid="baseColumns"/>
from jcl_org_cardbutton t where t.delete_type = 0 and t.status = 1
</select>
<select id="listAllId" resultType="java.lang.Long">
select t.id
from jcl_org_cardbutton t
where t.delete_type = 0
</select>
</mapper>

@ -16,6 +16,7 @@ import com.engine.organization.service.CardAccessService;
import com.engine.organization.transmethod.SystemTransMethod;
import com.engine.organization.util.HasRightUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.general.Util;
@ -140,22 +141,30 @@ public class CardAccessServiceImpl extends Service implements CardAccessService
String tableName = "JCL_ORG_CARDBUTTON";
int rowNum = Util.getIntValue((String) params.get("rownum"));
int count = 0;
List<Long> allIds = getCardButtonMapper().listAllId();
for (int i = 0; i < rowNum; i++) {
String recordIndex = "_" + i;
Map<String, Object> recordData = new HashMap<>();
recordData.put("name", params.get("name") + recordIndex);
recordData.put("status", params.get("status") + recordIndex);
recordData.put("url", params.get("url") + recordIndex);
recordData.put("roles", params.get("roles") + recordIndex);
String id = Util.null2String(params.get("id") + recordIndex);
recordData.put("name", params.get("name" + recordIndex));
recordData.put("status", params.get("status" + recordIndex));
recordData.put("url", params.get("url" + recordIndex));
recordData.put("roles", params.get("roles" + recordIndex));
String id = Util.null2String(params.get("id" + recordIndex));
if (StringUtils.isNotBlank(id)) {
// 更新
count += MapperProxyFactory.getProxy(ExtMapper.class).updateTable(ExtendInfoParams.builder().tableName(tableName).id(Long.parseLong(id)).params(recordData).build());
long buttonId = Long.parseLong(id);
count += MapperProxyFactory.getProxy(ExtMapper.class).updateTable(ExtendInfoParams.builder().tableName(tableName).id(buttonId).params(recordData).build());
allIds.remove(buttonId);
} else {
//插入
recordData.put("sys_default", 1);
recordData.put("delete_type", 0);
count += MapperProxyFactory.getProxy(ExtMapper.class).insertTable(ExtendInfoParams.builder().tableName(tableName).params(recordData).build());
}
}
if (CollectionUtils.isNotEmpty(allIds)) {
count += getCardButtonMapper().deleteByIds(allIds);
}
return count;
}

Loading…
Cancel
Save