字典支持多选删除

pull/308/head
Elune 2020-03-09 09:16:18 +08:00
parent 9f33cc07bc
commit 4054ac7bc8
3 changed files with 12 additions and 11 deletions

View File

@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Set;
/**
* @author Zheng Jie
@ -80,10 +81,10 @@ public class DictController {
@Log("删除字典")
@ApiOperation("删除字典")
@DeleteMapping(value = "/{id}")
@DeleteMapping
@PreAuthorize("@el.check('dict:del')")
public ResponseEntity<Object> delete(@PathVariable Long id){
dictService.delete(id);
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids){
dictService.delete(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -9,6 +9,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author Zheng Jie
@ -53,9 +54,9 @@ public interface DictService {
/**
*
* @param id /
* @param ids /
*/
void delete(Long id);
void delete(Set<Long> ids);
/**
*

View File

@ -23,10 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @author Zheng Jie
@ -87,8 +84,10 @@ public class DictServiceImpl implements DictService {
@Override
@CacheEvict(allEntries = true)
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
dictRepository.deleteById(id);
public void delete(Set<Long> ids) {
for (Long id : ids) {
dictRepository.deleteById(id);
}
}
@Override