2019独角兽企业重金招聘Python工程师标准>>>
1.mySql 批量插入数据库语句格式:
INSERT INTO
[表名]([列名],[列名])
VALUES
([列值],[列值])),
([列值],[列值])),
([列值],[列值]));
例如:
INSERT INTO
items(name,city,price,number,picture)
VALUES
('耐克运动鞋','广州',500,1000,'003.jpg'),
('耐克运动鞋2','广州2',500,1000,'002.jpg');
实体类:
public class WetSortVillage {
private Integer id;
private Integer areaId;
private String areaName;
private Integer streetId;
private String village;
private String street;
private Integer villageId;
private Integer households;//户数
private Integer kegStationNum;//桶站数
private Integer workerNum;//分类员数量
private Integer status;//有效状态 1:开启 2关闭 默认添加就是开启
}
mapper:
public interface WetSortVillageMapper {
@InsertProvider(type=SQLProvider.class,method="insertSortVillagesByParam")
public int insertSortVillagesByParam(List
}
SQLProvider.java :
public String insertSortVillagesByParam(Map map){
StringBuilder sb = new StringBuilder();
List
sb.append("INSERT INTO t_wet_sort_village ");
sb.append("(area_id,street_id,village_id,households,");
sb.append("keg_station_num,worker_num,status)");
sb.append(" VALUES ");
int length = list.size();
MessageFormat mf = new MessageFormat("(#'{'list[{0}].areaId},#'{'list[{0}].streetId},#'{'list[{0}].villageId},#'{'list[{0}].households}"
+ ",#'{'list[{0}].kegStationNum},#'{'list[{0}].workerNum},#'{'list[{0}].status})");
for(int i=0;i
if (i < length - 1) {
sb.append(",");
}
}
return sb.toString();
}