feat(portal): 添加网页编号并优化相关功能

- 在 HwWeb 模型中添加 webCode 字段,用于表示页面编号
- 修改 HwWebController 中的 getInfo 方法,使用 webCode 作为参数
- 更新 HwWebMapper 接口中的 selectHwWebByWebId 方法,改为 selectHwWebByWebcode
- 修改 HwWebMapper.xml 中的 SQL 语句,支持 webCode 的查询和插入
- 优化 HwWebServiceImpl 中的 updateHwWeb 方法,实现编号唯一性校验
- 更新 IHwWebService接口中的方法定义
master
zch 2 days ago
parent 61a340b47b
commit 382476a4f7

@ -64,10 +64,10 @@ public class HwWebController extends BaseController
* haiweijson
*/
//@RequiresPermissions("portalhwWeb:query")
@GetMapping(value = "/{webId}")
public AjaxResult getInfo(@PathVariable("webId") Long webId)
@GetMapping(value = "/{webCode}")
public AjaxResult getInfo(@PathVariable("webCode") Long webCode)
{
return success(hwWebService.selectHwWebByWebId(webId));
return success(hwWebService.selectHwWebByWebcode(webCode));
}
/**
@ -89,7 +89,8 @@ public class HwWebController extends BaseController
@PutMapping
public AjaxResult edit(@RequestBody HwWeb hwWeb)
{
return toAjax(hwWebService.updateHwWeb(hwWeb));
int i = hwWebService.updateHwWeb(hwWeb);
return toAjax(i);
}
/**

@ -7,7 +7,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* haiweijson hw_web
*
*
* @author ruoyi
* @date 2025-08-18
*/
@ -26,40 +26,54 @@ public class HwWeb extends BaseEntity
@Excel(name = "json字符串")
private String webJsonString;
public void setWebId(Long webId)
/** 页面 */
@Excel(name = "页面")
private Long webCode;
public void setWebId(Long webId)
{
this.webId = webId;
}
public Long getWebId()
public Long getWebId()
{
return webId;
}
public void setWebJson(String webJson)
public void setWebJson(String webJson)
{
this.webJson = webJson;
}
public String getWebJson()
public String getWebJson()
{
return webJson;
}
public void setWebJsonString(String webJsonString)
public void setWebJsonString(String webJsonString)
{
this.webJsonString = webJsonString;
}
public String getWebJsonString()
public String getWebJsonString()
{
return webJsonString;
}
public void setWebCode(Long webCode)
{
this.webCode = webCode;
}
public Long getWebCode()
{
return webCode;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("webId", getWebId())
.append("webJson", getWebJson())
.append("webJsonString", getWebJsonString())
.toString();
.append("webId", getWebId())
.append("webJson", getWebJson())
.append("webJsonString", getWebJsonString())
.append("webCode", getWebCode())
.toString();
}
}

@ -17,7 +17,7 @@ public interface HwWebMapper
* @param webId haiweijson
* @return haiweijson
*/
public HwWeb selectHwWebByWebId(Long webId);
public HwWeb selectHwWebByWebcode(Long webCode);
/**
* haiweijson

@ -17,7 +17,7 @@ public interface IHwWebService
* @param webId haiweijson
* @return haiweijson
*/
public HwWeb selectHwWebByWebId(Long webId);
public HwWeb selectHwWebByWebcode(Long webCode);
/**
* haiweijson

@ -26,11 +26,13 @@ public class HwWebServiceImpl implements IHwWebService
* @return haiweijson
*/
@Override
public HwWeb selectHwWebByWebId(Long webId)
public HwWeb selectHwWebByWebcode(Long webCode)
{
return hwWebMapper.selectHwWebByWebId(webId);
HwWeb hwWeb = hwWebMapper.selectHwWebByWebcode(webCode);
return hwWeb;
}
/**
* haiweijson
*
@ -64,6 +66,12 @@ public class HwWebServiceImpl implements IHwWebService
@Override
public int updateHwWeb(HwWeb hwWeb)
{
HwWeb codeWeb = new HwWeb();
//编号唯一
codeWeb.setWebCode(hwWeb.getWebCode());
if(hwWebMapper.selectHwWebList(codeWeb).isEmpty()){
return hwWebMapper.insertHwWeb(hwWeb);
}
return hwWebMapper.updateHwWeb(hwWeb);
}

@ -1,42 +1,47 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.portal.mapper.HwWebMapper">
<resultMap type="HwWeb" id="HwWebResult">
<result property="webId" column="web_id" />
<result property="webJson" column="web_json" />
<result property="webJsonString" column="web_json_string" />
<result property="webCode" column="web_code" />
</resultMap>
<sql id="selectHwWebVo">
select web_id, web_json, web_json_string from hw_web
select web_id, web_json, web_json_string, web_code from hw_web
</sql>
<select id="selectHwWebList" parameterType="HwWeb" resultMap="HwWebResult">
<include refid="selectHwWebVo"/>
<where>
<where>
<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>
<if test="webCode != null "> and web_code = #{webCode}</if>
</where>
</select>
<select id="selectHwWebByWebId" parameterType="Long" resultMap="HwWebResult">
<select id="selectHwWebByWebcode" parameterType="Long" resultMap="HwWebResult">
<include refid="selectHwWebVo"/>
where web_id = #{webId}
where web_code = #{webCode}
</select>
<insert id="insertHwWeb" parameterType="HwWeb" useGeneratedKeys="true" keyProperty="webId">
insert into hw_web
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="webJson != null">web_json,</if>
<if test="webJsonString != null">web_json_string,</if>
</trim>
<if test="webCode != null">web_code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="webJson != null">#{webJson},</if>
<if test="webJsonString != null">#{webJsonString},</if>
</trim>
<if test="webCode != null">#{webCode},</if>
</trim>
</insert>
<update id="updateHwWeb" parameterType="HwWeb">
@ -44,8 +49,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=",">
<if test="webJson != null">web_json = #{webJson},</if>
<if test="webJsonString != null">web_json_string = #{webJsonString},</if>
<if test="webCode != null">web_code = #{webCode},</if>
</trim>
where web_id = #{webId}
where web_code = #{webCode}
</update>
<delete id="deleteHwWebByWebId" parameterType="Long">
@ -53,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteHwWebByWebIds" parameterType="String">
delete from hw_web where web_id in
delete from hw_web where web_id in
<foreach item="webId" collection="array" open="(" separator="," close=")">
#{webId}
</foreach>

Loading…
Cancel
Save