您的位置:首页 > 房产 > 建筑 > 头像制作器在线制作_动漫制作专业可以升大专吗_凡科建站和华为云哪个好_近期重大新闻

头像制作器在线制作_动漫制作专业可以升大专吗_凡科建站和华为云哪个好_近期重大新闻

2025/4/10 10:08:18 来源:https://blog.csdn.net/weixin_62338568/article/details/146440031  浏览:    关键词:头像制作器在线制作_动漫制作专业可以升大专吗_凡科建站和华为云哪个好_近期重大新闻
头像制作器在线制作_动漫制作专业可以升大专吗_凡科建站和华为云哪个好_近期重大新闻

1.事务@EnableTransactionManagement       @Transactional

    /*** 新增菜品** @param dishDTO*/@Override@Transactionalpublic void saveWithFlavor(DishDTO dishDTO) {Dish dish = new Dish();BeanUtils.copyProperties(dishDTO, dish);dish.setStatus(StatusConstant.ENABLE);//保存菜品数据dishMapper.insert(dish);//获取inset语句生成的主键值菜品idLong dishId = dish.getId();List<DishFlavor> flavors = dishDTO.getFlavors();if (flavors != null && flavors.size() > 0) {flavors.forEach(dishFlavor -> {dishFlavor.setDishId(dishId);});//保存菜品口味数据dishFlavorMapper.insertBatch(flavors);}}

 useGenerateKeys='true' keyProperty='id'

 <insert id="insert" parameterType="com.sky.entity.Dish" useGeneratedKeys="true" keyProperty="id">insert into dish (name, category_id, price, image, description, status, create_time, create_user, update_time, update_user)values (#{name}, #{categoryId}, #{price}, #{image}, #{description}, #{status}, #{createTime}, #{createUser},#{updateTime}, #{updateUser})</insert>

insert into 表名(属性)vlaues(xxx,xxx,xxx...),(xxx,xxx,xxx...),(xxx,xxx,xxx...) 

foreach

 <insert id="insertBatch" parameterType="com.sky.entity.DishFlavor">insert into dish_flavor (dish_id, name, value) values<foreach collection="flavors" item="dishFlavor" separator=",">(#{dishFlavor.dishId},#{dishFlavor.name},#{dishFlavor.value})</foreach></insert>

 @RequestParam

 /*** 删除菜品** @param ids* @return*/@DeleteMapping()@ApiOperation("删除菜品")public Result deleteByIds(@RequestParam List<Long> ids) {log.info("删除菜品,id为:{}", ids);dishService.deleteByIds(ids);//清理缓存数据cleanCache("dish_*");return Result.success();}

 select * from 表名 where 属性 in (xx,xx,xx)

  <select id="getByDishIds" resultType="java.lang.Long" parameterType="com.sky.entity.SetmealDish">select  setmeal_id from setmeal_dish where dish_id in<foreach collection="dishIds" item="id" open="(" separator="," close=")">#{id}</foreach></select>

delete from 表名 where 属性=xxx

update 表名 set 属性=xxx where 属性=xxx 

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com