今天遇到的这个问题到最后真的是怕我自己给气哭了,唉,大致如下:
这是controller层代码,前端传的值都有,但是去调用updateWechatBulkNotification
时,修改失败,也不报错,通过查看控制台日志发现,返回受影响的行数为0
@PostMapping("/updateRemarks")
public AjaxResult updateRemarks(@RequestBody String data) {
JSONObject jsonObject = JSONObject.parseObject(data);
String appkey = jsonObject.getString("appkey");
List<WechatBulkNotification> list = jsonObject.getJSONArray("list").toList(WechatBulkNotification.class);
LoginUser loginUser = SecurityUtils.getLoginUser();
list.forEach(wechatBulkNotification -> {
if(wechatBulkNotification.getwbnId()!=null){
wechatBulkNotification.setId(wechatBulkNotification.getwbnId());
wechatBulkNotification.setAppKey(appkey);
wechatBulkNotification.setUpdateBy(loginUser.getUserId().toString());
wechatBulkNotificationService.updateWechatBulkNotification(wechatBulkNotification);
}
});
return AjaxResult.success();
}
接着再来看下xml里面的代码
看着也没有问题,经过百般研究,最后问题出在了id
,id不对导致的,我传的id在wechat_xxxx表里面查询不到,唉
<update id="updateWechatBulkNotification" parameterType="BulkNotif">
update tification
<trim prefix="SET" suffixOverrides=",">
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="nick != null">nick = #{nick},</if>
<if test="wxid != null">id = #{wxid},</if>
<if test="type != null">type = #{type},</if>
<if test="intervalTime != null">interval_time = #{intervalTime},</if>
<if test="appkey != null">key = #{appkey},</if>
<if test="salespersonName != null">salesperson_name = #{salespersonName},</if>
<if test="threeSegmentCode != null">three_segment_code = #{threeSegmentCode},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>