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

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

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

@ -26,6 +26,10 @@ public class HwWeb extends BaseEntity
@Excel(name = "json字符串") @Excel(name = "json字符串")
private String webJsonString; private String webJsonString;
/** 页面 */
@Excel(name = "页面")
private Long webCode;
public void setWebId(Long webId) public void setWebId(Long webId)
{ {
this.webId = webId; this.webId = webId;
@ -53,13 +57,23 @@ public class HwWeb extends BaseEntity
{ {
return webJsonString; return webJsonString;
} }
public void setWebCode(Long webCode)
{
this.webCode = webCode;
}
public Long getWebCode()
{
return webCode;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("webId", getWebId()) .append("webId", getWebId())
.append("webJson", getWebJson()) .append("webJson", getWebJson())
.append("webJsonString", getWebJsonString()) .append("webJsonString", getWebJsonString())
.toString(); .append("webCode", getWebCode())
.toString();
} }
} }

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

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

@ -26,11 +26,13 @@ public class HwWebServiceImpl implements IHwWebService
* @return haiweijson * @return haiweijson
*/ */
@Override @Override
public HwWeb selectHwWebByWebId(Long webId) public HwWeb selectHwWebByWebcode(Long webCode)
{ {
return hwWebMapper.selectHwWebByWebId(webId); HwWeb hwWeb = hwWebMapper.selectHwWebByWebcode(webCode);
return hwWeb;
} }
/** /**
* haiweijson * haiweijson
* *
@ -64,6 +66,12 @@ public class HwWebServiceImpl implements IHwWebService
@Override @Override
public int updateHwWeb(HwWeb hwWeb) 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); return hwWebMapper.updateHwWeb(hwWeb);
} }

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

Loading…
Cancel
Save