controller
@ApiOperation(value ="批量更改审核及删除状态", notes ="批量更改审核及删除状态")
@ApiResponses({@ApiResponse(code =200, message ="操作成功", response = ResponseBodyDto.class)})
@ApiImplicitParam(name="ids",value ="逗号拼接id",dataType ="String",paramType ="query",example ="1,2",required=true)
@RequestMapping(value ="/batchUpdateVessel", method = RequestMethod.GET)
@ResponseBody
public ResponseBodyDto batchUpdateVessel(String ids,String state,String isDelete) {
String[] idStr = ids.split(",");
List list =new ArrayList();
for (String id : idStr) {
list.add(id);
}
int result=vesselService.batchUpdateVessel(list,state,isDelete);
if(result>0){
for (String id : idStr) {
Vessel vessel1=vesselService.selectVesselDetail(Long.parseLong(id));
if (vessel1!=null){
elasticSearch.writeDataToES("vessel","docs", JSON.toJSONString(vessel1));
}
}
}
return new ResponseBodyDto<>(result);
}
service
int batchUpdateVessel(List list, String state,String isDelete);
mapper
int batchUpdateVessel(@Param("ids") List ids,@Param("state") String state,@Param("isDelete")String isDelete);
sql
update `vessel`
set `updated_at`= now(),
state = #{state,jdbcType=BIT}
is_delete = #{isDelete,jdbcType=BIT}
where `id` in
${item}