#(一)SQL语句获取主键自增长的id
<-/ 通过此语句获取主键id,我的id是Long类型keyProperty中写主键列的字段名称,执行之后要插入的类id就会自动赋值->
SELECT LAST_INSERT_ID() AS id
<-这里写插入语句,平时怎么写,这里怎么写就可以了->
insert into shop_goods
id,
shop_id,
category_id,
barcode,
video_id,
name,
characteristic,
logistics_id,
paixu,
recommend_status,
status,
content,
original_price,
min_price,
pintuan_price,
min_score,
stores,
weight,
commission_type,
commission,
pingtuan,
date_start,
date_end,
add_user,
add_date,
update_user,
update_time,
#{id},
#{shopId},
#{categoryId},
#{barcode},
#{videoId},
#{name},
#{characteristic},
#{logisticsId},
#{paixu},
#{recommendStatus},
#{status},
#{content},
#{originalPrice},
#{minPrice},
#{pintuanPrice},
#{minScore},
#{stores},
#{weight},
#{commissionType},
#{commission},
#{pingtuan},
#{dateStart},
#{dateEnd},
#{addUser},
#{addDate},
#{updateUser},
#{updateTime},
#(二)service层取出id返回
public Long addGoods(Goods goods) {
//调用Mapper执行第一步的插入语句
goodsMapper.addGoods(goods);
//通过类的get方法获取返回的id值
Long id=goods.getId();
return id;
}