判断是否为空然后赋值(ofNullable判断括号里是否为null,如果为null则返回orElse括号里的值,如果不为null返回ofNullable括号里的值):
Optional.ofNullable(seatService.findTotalPriceByType(cols.get(i))).orElse(0.0)
前端:
var status=2>1?0:1;
Model:
@GetMapping("/comment")
public String comment(Model model,String id){
model.addAttribute("id",id);
model.addAttribute("filmId",iFilmDateService.findById(id).get(0).getFilmId());
model.addAttribute("filmDate",iFilmDateService.findById(id).get(0).getDateStr());
return "film-comment";
}
var value='[[${filmId}]]';
Mybatis:
@Update({"<script>update film",
"<set>",
"<if test=\"entity.filmName !=null and entity.filmName !=''\">",
"film_name = #{entity.filmName},",
"</if>",
"<if test=\"entity.type !=null and entity.type !=''\">",
"type = #{entity.type},",
"</if>",
"<if test=\"entity.price !=null and entity.price !=''\">",
"price = #{entity.price},",
"</if>",
"<if test=\"entity.picUrl !=null and entity.picUrl !=''\">",
"pic_url = #{entity.picUrl},",
"</if>",
"<if test=\"entity.act !=null and entity.act !=''\">",
"act = #{entity.act},",
"</if>",
"<if test=\"entity.director !=null and entity.director !=''\">",
"director = #{entity.director},",
"</if>",
"<if test=\"entity.desc !=null and entity.desc !=''\">",
"desc = #{entity.desc},",
"</if>",
"</set>",
"where id=#{entity.id};",
"</script>"})
@Results({@Result(property = "filmName", column = "film_name"),
@Result(property = "picUrl", column = "pic_url")
})
@Select({"select","sum(price)","from","seat","where","type=#{type}","and","status=1",";"})