nested exception is org.apache.ibatis.binding.BindingException: Parameter 'major' not found. Available parameters are [majorList, param1]
我在写批量修改的时候遇到的问题,我这里给了@Param但是还是会出现这个问题。其他代码都没问题
majorMapper.java
List<Major> batchUpdateMajor(@Param("majorList") List<Major> majorList)
majorMapper.xml
<update id="batchUpdateMajor" parameterType="com.guli.collegemanagetrailing.entity.Major">
UPDATE `major`
<trim prefix="SET" suffixOverrides=",">
<if test="major.majorName != null and major.majorName != ''">
`major_name` = #{major.majorName},
</if>
<if test="major.collegeId != null">
`college_id` = #{major.collegeId},
</if>
<if test="major.number != null">
`number` = #{major.number},
</if>
<if test="major.status != null">
`status` = #{major.status},
</if>
</trim>
<where>
<foreach collection="majorList" item="major" separator="OR">
<if test="major.id != null">
`id` = #{major.id}
</if>
</foreach>
</where>
</update>
collegeServiceImpl.java
@Override
@Transactional
public void deleteCollege(Integer id) {
if (NumberUtils.isEmpty(id)) {
throw new CustomException(ResultEnum.notParamError.getCode(),ResultEnum.notParamError.getMessage());
}
College collegeById = collegeMapper.getCollegeById(id);
if (ObjectUtils.isEmpty(collegeById)) {
throw new CustomException(ResultEnum.collegeNotExist.getCode(),ResultEnum.collegeNotExist.getMessage());
}
// 删除学院前先查询有没有专业绑定,如果有专业绑定当前学院则把专业的collegeId改为0
List<Major> majorListById = collegeMapper.getMajorListById(id);
if (!ObjectUtils.isEmpty(majorListById) || !Objects.equals(majorListById.size(),StatusCode.userStatus.getStatus())) {
// 批量修改专业的学院id
for (Major major : majorListById) {
major.setCollegeId(StatusCode.userStatus.getStatus());
}
majorMapper.batchUpdateMajor(majorListById);
}
Integer deleteCollege = collegeMapper.deleteCollege(id);
if (!Objects.equals(deleteCollege,StatusCode.recordCount.getStatus())) {
throw new CustomException(ResultEnum.deleteAllUnSuccessful.getCode(),ResultEnum.deleteUnSuccessful.getMessage());
}
}