feat(portal): 添加逻辑删除字段并优化删除操作

- 在HwWeb、HwWeb1、HwWebDocument、HwWebMenu等实体类中新增isDelete字段- 更新Mapper XML文件,支持isDelete字段的读取与写入
- 修改删除操作为更新isDelete状态,实现逻辑删除
- 查询时默认过滤已逻辑删除的数据
- 新增数据时默认设置isDelete为'0'
master
zangch@mesnac.com 2 months ago
parent fddaa652e0
commit f12b0f01b7

@ -30,6 +30,9 @@ public class HwWeb extends BaseEntity
@Excel(name = "页面")
private Long webCode;
/** 逻辑删除标志:'0'未删除,'1'已删除 */
private String isDelete;
public void setWebId(Long webId)
{
this.webId = webId;
@ -67,6 +70,14 @@ public class HwWeb extends BaseEntity
return webCode;
}
public String getIsDelete() {
return isDelete;
}
public void setIsDelete(String isDelete) {
this.isDelete = isDelete;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -74,6 +85,7 @@ public class HwWeb extends BaseEntity
.append("webJson", getWebJson())
.append("webJsonString", getWebJsonString())
.append("webCode", getWebCode())
.append("isDelete", getIsDelete())
.toString();
}
}

@ -6,7 +6,7 @@ import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* haiweijson hw_web
* haiweijson hw_web1
*
* @author ruoyi
* @date 2025-08-18
@ -34,6 +34,9 @@ public class HwWeb1 extends BaseEntity
private Long typeId;
/** 逻辑删除标志:'0'未删除,'1'已删除 */
private String isDelete;
public void setWebId(Long webId)
{
this.webId = webId;
@ -87,6 +90,13 @@ public class HwWeb1 extends BaseEntity
this.typeId = typeId;
}
public String getIsDelete() {
return isDelete;
}
public void setIsDelete(String isDelete) {
this.isDelete = isDelete;
}
@Override
public String toString() {
@ -97,6 +107,7 @@ public class HwWeb1 extends BaseEntity
.append("webCode", getWebCode())
.append("deviceId", getDeviceId())
.append("typeId", getTypeId())
.append("isDelete", getIsDelete())
.toString();
}
}

@ -40,6 +40,9 @@ public class HwWebDocument extends BaseEntity
/** 文件类型 */
private String type;
/** 逻辑删除标志:'0'未删除,'1'已删除 */
private String isDelete;
public void setDocumentId(String documentId)
{
this.documentId = documentId;
@ -102,6 +105,14 @@ public class HwWebDocument extends BaseEntity
this.type = type;
}
public String getIsDelete() {
return isDelete;
}
public void setIsDelete(String isDelete) {
this.isDelete = isDelete;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -111,8 +122,9 @@ public class HwWebDocument extends BaseEntity
.append("createTime", getCreateTime())
.append("webCode", getWebCode())
.append("secretKey", getSecretKey())
.append("json", getJson())
.append("type", getType())
.append("json", getJson())
.append("type", getType())
.append("isDelete", getIsDelete())
.toString();
}
}

@ -44,6 +44,9 @@ public class HwWebMenu extends TreeEntity
@Excel(name = "官网菜单类型")
private Long webMenuType;
/** 逻辑删除标志:'0'未删除,'1'已删除 */
private String isDelete;
public void setWebMenuId(Long webMenuId)
{
this.webMenuId = webMenuId;
@ -108,6 +111,14 @@ public class HwWebMenu extends TreeEntity
return webMenuType;
}
public String getIsDelete() {
return isDelete;
}
public void setIsDelete(String isDelete) {
this.isDelete = isDelete;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -119,6 +130,7 @@ public class HwWebMenu extends TreeEntity
.append("tenantId", getTenantId())
.append("webMenuPic", getWebMenuPic())
.append("webMenuType", getWebMenuType())
.append("isDelete", getIsDelete())
.toString();
}
}

@ -8,7 +8,7 @@ import com.ruoyi.common.core.web.domain.TreeEntity;
import java.util.List;
/**
* haiwei hw_web_menu
* haiwei hw_web_menu1
*
* @author zch
* @date 2025-08-18
@ -46,6 +46,9 @@ public class HwWebMenu1 extends TreeEntity
private String valuel;
/** 逻辑删除标志:'0'未删除,'1'已删除 */
private String isDelete;
public void setWebMenuId(Long webMenuId)
{
this.webMenuId = webMenuId;
@ -117,6 +120,14 @@ public class HwWebMenu1 extends TreeEntity
this.valuel = valuel;
}
public String getIsDelete() {
return isDelete;
}
public void setIsDelete(String isDelete) {
this.isDelete = isDelete;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -129,6 +140,7 @@ public class HwWebMenu1 extends TreeEntity
.append("webMenuPic", getWebMenuPic())
.append("webMenuType", getWebMenuType())
.append("valuel", getValuel())
.append("isDelete", getIsDelete())
.toString();
}
}

@ -71,10 +71,15 @@ public class HwWebServiceImpl implements IHwWebService
HwWeb codeWeb = new HwWeb();
//编号唯一
codeWeb.setWebCode(hwWeb.getWebCode());
if(hwWebMapper.selectHwWebList(codeWeb).isEmpty()){
return hwWebMapper.insertHwWeb(hwWeb);
List<HwWeb> exists = hwWebMapper.selectHwWebList(codeWeb);
if (!exists.isEmpty()) {
Long[] webIds = exists.stream().map(HwWeb::getWebId).toArray(Long[]::new);
hwWebMapper.deleteHwWebByWebIds(webIds);
}
return hwWebMapper.updateHwWeb(hwWeb);
// 插入新记录,避免复用旧主键
// hwWeb.setWebId(null);
hwWeb.setIsDelete("0");
return hwWebMapper.insertHwWeb(hwWeb);
}
/**

@ -76,14 +76,19 @@ public class HwWebServiceImpl1 implements IHwWebService1
public int updateHwWeb(HwWeb1 hwWeb1)
{
HwWeb1 codeWeb = new HwWeb1();
//编号唯一
// 编号、typeid、deviceID保证唯一
codeWeb.setWebCode(hwWeb1.getWebCode());
codeWeb.setTypeId(hwWeb1.getTypeId());
codeWeb.setDeviceId(hwWeb1.getDeviceId());
if(hwWebMapper1.selectHwWebList(codeWeb).isEmpty()){
return hwWebMapper1.insertHwWeb(hwWeb1);
List<HwWeb1> exists = hwWebMapper1.selectHwWebList(codeWeb);
if (!exists.isEmpty()) {
Long[] webIds = exists.stream().map(HwWeb1::getWebId).toArray(Long[]::new);
hwWebMapper1.deleteHwWebByWebIds(webIds);
}
return hwWebMapper1.updateHwWeb(hwWeb1);
// 插入新记录,避免复用旧主键
// hwWeb1.setWebId(null);
hwWeb1.setIsDelete("0");
return hwWebMapper1.insertHwWeb(hwWeb1);
}
/**

@ -13,17 +13,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="secretKey" column="secretKey" />
<result property="json" column="json" />
<result property="type" column="type" />
<result property="isDelete" column="is_delete" />
</resultMap>
<sql id="selectHwWebDocumentVo">
select document_id, tenant_id, document_address, create_time, web_code, secretKey ,
json,type
json, type,
is_delete
from hw_web_document
</sql>
<select id="selectHwWebDocumentList" parameterType="HwWebDocument" resultMap="HwWebDocumentResult">
<include refid="selectHwWebDocumentVo"/>
<where>
and is_delete = '0'
<if test="documentId != null "> and document_id = #{documentId}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="documentAddress != null and documentAddress != ''"> and document_address = #{documentAddress}</if>
@ -36,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectHwWebDocumentByDocumentId" parameterType="String" resultMap="HwWebDocumentResult">
<include refid="selectHwWebDocumentVo"/>
where document_id = #{documentId}
where is_delete = '0' and document_id = #{documentId}
</select>
<insert id="insertHwWebDocument" parameterType="HwWebDocument" useGeneratedKeys="true" keyProperty="documentId">
@ -50,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="secretKey != null">secretKey,</if>
<if test="json != null">json,</if>
<if test="type != null">type,</if>
is_delete,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="documentId != null">#{documentId},</if>
@ -60,6 +64,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="secretKey != null">#{secretKey},</if>
<if test="json != null">#{json},</if>
<if test="type != null">#{type},</if>
<choose>
<when test="isDelete != null and isDelete != ''">#{isDelete},</when>
<otherwise>'0',</otherwise>
</choose>
</trim>
</insert>
@ -78,14 +86,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where document_id = #{documentId}
</update>
<delete id="deleteHwWebDocumentByDocumentId" parameterType="String">
delete from hw_web_document where document_id = #{documentId}
</delete>
<update id="deleteHwWebDocumentByDocumentId" parameterType="String">
update hw_web_document set is_delete = '1' where document_id = #{documentId}
</update>
<delete id="deleteHwWebDocumentByDocumentIds" parameterType="String">
delete from hw_web_document where document_id in
<update id="deleteHwWebDocumentByDocumentIds" parameterType="String">
update hw_web_document set is_delete = '1' where document_id in
<foreach item="documentId" collection="array" open="(" separator="," close=")">
#{documentId}
</foreach>
</delete>
</update>
</mapper>

@ -9,15 +9,19 @@
<result property="webJson" column="web_json" />
<result property="webJsonString" column="web_json_string" />
<result property="webCode" column="web_code" />
<result property="isDelete" column="is_delete" />
</resultMap>
<sql id="selectHwWebVo">
select web_id, web_json, web_json_string, web_code from hw_web
select web_id, web_json, web_json_string, web_code,
is_delete
from hw_web
</sql>
<select id="selectHwWebList" parameterType="HwWeb" resultMap="HwWebResult">
<include refid="selectHwWebVo"/>
<where>
and is_delete = '0'
<if test="webId != null "> and web_id = #{webId}</if>
<if test="webJson != null and webJson != ''"> and web_json = #{webJson}</if>
<if test="webJsonString != null and webJsonString != ''"> and web_json_string = #{webJsonString}</if>
@ -27,7 +31,7 @@
<select id="selectHwWebByWebcode" parameterType="Long" resultMap="HwWebResult">
<include refid="selectHwWebVo"/>
where web_code = #{webCode}
where is_delete = '0' and web_code = #{webCode}
</select>
<insert id="insertHwWeb" parameterType="HwWeb" useGeneratedKeys="true" keyProperty="webId">
@ -36,11 +40,16 @@
<if test="webJson != null">web_json,</if>
<if test="webJsonString != null">web_json_string,</if>
<if test="webCode != null">web_code,</if>
is_delete,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="webJson != null">#{webJson},</if>
<if test="webJsonString != null">#{webJsonString},</if>
<if test="webCode != null">#{webCode},</if>
<choose>
<when test="isDelete != null and isDelete != ''">#{isDelete},</when>
<otherwise>'0',</otherwise>
</choose>
</trim>
</insert>
@ -54,14 +63,14 @@
where web_code = #{webCode}
</update>
<delete id="deleteHwWebByWebId" parameterType="Long">
delete from hw_web where web_id = #{webId}
</delete>
<update id="deleteHwWebByWebId" parameterType="Long">
update hw_web set is_delete = '1' where web_id = #{webId}
</update>
<delete id="deleteHwWebByWebIds" parameterType="String">
delete from hw_web where web_id in
<update id="deleteHwWebByWebIds" parameterType="String">
update hw_web set is_delete = '1' where web_id in
<foreach item="webId" collection="array" open="(" separator="," close=")">
#{webId}
</foreach>
</delete>
</update>
</mapper>

@ -11,17 +11,20 @@
<result property="webCode" column="web_code" />
<result property="deviceId" column="device_id" />
<result property="typeId" column="typeId" />
<result property="isDelete" column="is_delete" />
</resultMap>
<sql id="selectHwWebVo">
select web_id, web_json, web_json_string, web_code,
device_id,typeId
device_id, typeId,
is_delete
from hw_web1
</sql>
<select id="selectHwWebList" parameterType="HwWeb1" resultMap="HwWebResult1">
<include refid="selectHwWebVo"/>
<where>
and is_delete = '0'
<if test="webId != null "> and web_id = #{webId}</if>
<if test="webJson != null and webJson != ''"> and web_json = #{webJson}</if>
<if test="webJsonString != null and webJsonString != ''"> and web_json_string = #{webJsonString}</if>
@ -33,12 +36,12 @@
<select id="selectHwWebByWebcode" parameterType="Long" resultMap="HwWebResult1">
<include refid="selectHwWebVo"/>
where web_code = #{webCode}
where is_delete = '0' and web_code = #{webCode}
</select>
<select id="selectHwWebOne" parameterType="HwWeb1" resultMap="HwWebResult1">
<include refid="selectHwWebVo"/>
where web_code = #{webCode}
where is_delete = '0' and web_code = #{webCode}
and device_id = #{deviceId}
and typeId = #{typeId}
</select>
@ -51,6 +54,7 @@
<if test="webCode != null">web_code,</if>
<if test="deviceId != null">device_id,</if>
<if test="typeId != null">typeId,</if>
is_delete,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="webJson != null">#{webJson},</if>
@ -58,6 +62,10 @@
<if test="webCode != null">#{webCode},</if>
<if test="deviceId != null">#{deviceId},</if>
<if test="typeId != null">#{typeId},</if>
<choose>
<when test="isDelete != null and isDelete != ''">#{isDelete},</when>
<otherwise>'0',</otherwise>
</choose>
</trim>
</insert>
@ -75,14 +83,14 @@
and typeId = #{typeId}
</update>
<delete id="deleteHwWebByWebId" parameterType="Long">
delete from hw_web1 where web_id = #{webId}
</delete>
<update id="deleteHwWebByWebId" parameterType="Long">
update hw_web1 set is_delete = '1' where web_id = #{webId}
</update>
<delete id="deleteHwWebByWebIds" parameterType="String">
delete from hw_web1 where web_id in
<update id="deleteHwWebByWebIds" parameterType="String">
update hw_web1 set is_delete = '1' where web_id in
<foreach item="webId" collection="array" open="(" separator="," close=")">
#{webId}
</foreach>
</delete>
</update>
</mapper>

@ -13,15 +13,19 @@
<result property="tenantId" column="tenant_id" />
<result property="webMenuPic" column="web_menu__pic" />
<result property="webMenuType" column="web_menu_type" />
<result property="isDelete" column="is_delete" />
</resultMap>
<sql id="selectHwWebMenuVo">
select web_menu_id, parent, ancestors, status, web_menu_name, tenant_id, web_menu__pic, web_menu_type from hw_web_menu
select web_menu_id, parent, ancestors, status, web_menu_name, tenant_id, web_menu__pic, web_menu_type,
is_delete
from hw_web_menu
</sql>
<select id="selectHwWebMenuList" parameterType="HwWebMenu" resultMap="HwWebMenuResult">
<include refid="selectHwWebMenuVo"/>
<where>
and is_delete = '0'
<if test="parent != null "> and parent = #{parent}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
@ -34,7 +38,7 @@
<select id="selectHwWebMenuByWebMenuId" parameterType="Long" resultMap="HwWebMenuResult">
<include refid="selectHwWebMenuVo"/>
where web_menu_id = #{webMenuId}
where is_delete = '0' and web_menu_id = #{webMenuId}
</select>
<insert id="insertHwWebMenu" parameterType="HwWebMenu">
@ -48,6 +52,7 @@
<if test="tenantId != null">tenant_id,</if>
<if test="webMenuPic != null">web_menu__pic,</if>
<if test="webMenuType != null">web_menu_type,</if>
is_delete,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="webMenuId != null">#{webMenuId},</if>
@ -58,6 +63,10 @@
<if test="tenantId != null">#{tenantId},</if>
<if test="webMenuPic != null">#{webMenuPic},</if>
<if test="webMenuType != null">#{webMenuType},</if>
<choose>
<when test="isDelete != null and isDelete != ''">#{isDelete},</when>
<otherwise>'0',</otherwise>
</choose>
</trim>
</insert>
@ -75,14 +84,14 @@
where web_menu_id = #{webMenuId}
</update>
<delete id="deleteHwWebMenuByWebMenuId" parameterType="Long">
delete from hw_web_menu where web_menu_id = #{webMenuId}
</delete>
<update id="deleteHwWebMenuByWebMenuId" parameterType="Long">
update hw_web_menu set is_delete = '1' where web_menu_id = #{webMenuId}
</update>
<delete id="deleteHwWebMenuByWebMenuIds" parameterType="String">
delete from hw_web_menu where web_menu_id in
<update id="deleteHwWebMenuByWebMenuIds" parameterType="String">
update hw_web_menu set is_delete = '1' where web_menu_id in
<foreach item="webMenuId" collection="array" open="(" separator="," close=")">
#{webMenuId}
</foreach>
</delete>
</update>
</mapper>

@ -14,17 +14,21 @@
<result property="webMenuPic" column="web_menu__pic" />
<result property="webMenuType" column="web_menu_type" />
<result property="value" column="value" />
<result property="isDelete" column="is_delete" />
</resultMap>
<sql id="selectHwWebMenuVo">
select web_menu_id, parent, ancestors, status, web_menu_name, tenant_id, web_menu__pic,
value,
web_menu_type from hw_web_menu1
web_menu_type,
is_delete
from hw_web_menu1
</sql>
<select id="selectHwWebMenuList" parameterType="HwWebMenu1" resultMap="HwWebMenuResult1">
<include refid="selectHwWebMenuVo"/>
<where>
and is_delete = '0'
<if test="parent != null "> and parent = #{parent}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
@ -38,7 +42,7 @@
<select id="selectHwWebMenuByWebMenuId" parameterType="Long" resultMap="HwWebMenuResult1">
<include refid="selectHwWebMenuVo"/>
where web_menu_id = #{webMenuId}
where is_delete = '0' and web_menu_id = #{webMenuId}
</select>
<insert id="insertHwWebMenu" parameterType="HwWebMenu1">
@ -53,6 +57,7 @@
<if test="webMenuPic != null">web_menu__pic,</if>
<if test="webMenuType != null">web_menu_type,</if>
<if test="value != null">value,</if>
is_delete,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="webMenuId != null">#{webMenuId},</if>
@ -64,6 +69,10 @@
<if test="webMenuPic != null">#{webMenuPic},</if>
<if test="webMenuType != null">#{webMenuType},</if>
<if test="value != null">#{value},</if>
<choose>
<when test="isDelete != null and isDelete != ''">#{isDelete},</when>
<otherwise>'0',</otherwise>
</choose>
</trim>
</insert>
@ -82,14 +91,14 @@
where web_menu_id = #{webMenuId}
</update>
<delete id="deleteHwWebMenuByWebMenuId" parameterType="Long">
delete from hw_web_menu1 where web_menu_id = #{webMenuId}
</delete>
<update id="deleteHwWebMenuByWebMenuId" parameterType="Long">
update hw_web_menu1 set is_delete = '1' where web_menu_id = #{webMenuId}
</update>
<delete id="deleteHwWebMenuByWebMenuIds" parameterType="String">
delete from hw_web_menu1 where web_menu_id in
<update id="deleteHwWebMenuByWebMenuIds" parameterType="String">
update hw_web_menu1 set is_delete = '1' where web_menu_id in
<foreach item="webMenuId" collection="array" open="(" separator="," close=")">
#{webMenuId}
</foreach>
</delete>
</update>
</mapper>
Loading…
Cancel
Save