persistence
1 2 3 4 5 6 7 8 9 10 11 12 13 |
@Update({"<script>", "UPDATE hero", "<trim prefix='set' suffixOverrides=','>", "<if test='name!=null'>name=#{name},</if>", "<if test='email!=null'>email=#{email},</if>", "<if test='sex!=null'>sex=#{sex},</if>", "<if test='country!=null'>country=#{country},</if>", "<if test='address!=null'>address=#{address},</if>", "<if test='power!=null'>data_value3=#{power},</if>", "</trim>", "WHERE hero_id = #{hero_id}", "</script>"}) int updateHero(HeroVO hero); |
controller
1 2 3 4 5 6 7 8 9 |
@PutMapping("/hero") public ResultVO modifyHero(@RequestBody HeroVO hero) { int result = heroMapper.updateHero(hero); if ( result > 0) { return new ResultVO(0, "success"); } else { return new ResultVO(100, "fail"); } } |
postman 테스트