批量新增
mapper.xml
<insert id="insertBatch" parameterType="com.ehl.ecds.emerg.dailyManagement.po.EcEmergDrillParticipating" >
insert into ec_emerg_drill_participating
values
<foreach collection="tList" item="item" index="index" separator=",">
((SELECT REPLACE(UUID(), '-', '') AS id), #{
item.drillId,jdbcType=VARCHAR},
#{
item.deptId,jdbcType=INTEGER},#{
item.authDeptId,jdbcType=INTEGER})
</foreach>
</insert>
mapper.java
int insertBatch(@Param("tList") List<EcEmergDrillParticipating> list);
service.java
public JSONObject addDrill(HttpServletRequest request, EcEmergDrill ecEmergDrill) throws OtherException {
ecEmergDrillMapper.insert(ecEmergDrill);
String[] depts = ecEmergDrill.getDepts().split(",");
List<EcEmergDrillParticipating> r_list = new LinkedList<>();
for(int i=0;i<depts.length;i++){
EcEmergDrillParticipating edp = new EcEmergDrillParticipating();
edp.setDrillId(ecEmergDrill.getId());
edp.setDeptId(Integer.valueOf(depts[i]));
edp.setAuthDeptId(sysDeptMgrMapper.selectTopId(Integer.valueOf(depts[i])));
r_list.add(edp);
}
JSONObject out = OutputJSON.newInstance();
return out;
}
controller.java
@RequestMapping(value = "/addDrill", method = {
RequestMethod.GET, RequestMethod.POST })
@ResponseBody</