调整字典数据类型批量删除

This commit is contained in:
TinyAnts 2022-08-17 11:58:02 +08:00
parent 259db657e1
commit 3fa340c5b1
8 changed files with 33 additions and 33 deletions

View File

@ -103,7 +103,7 @@ public class DictDataController {
*/
@PostMapping("/del")
public Object del(@Validated(value = DictDataParam.delete.class) @RequestBody DictDataParam dictDataParam) {
iSettingDictDataService.del(dictDataParam.getId());
iSettingDictDataService.del(dictDataParam.getIds());
return AjaxResult.success();
}

View File

@ -99,7 +99,7 @@ public class DictTypeController {
*/
@PostMapping("/del")
public Object del(@Validated(value = DictTypeParam.delete.class) @RequestBody DictTypeParam dictTypeParam) {
iSettingDictTypeService.del(dictTypeParam.getId());
iSettingDictTypeService.del(dictTypeParam.getIds());
return AjaxResult.success();
}

View File

@ -60,8 +60,8 @@ public interface ISettingDictDataService {
* 字典数据删除
*
* @author fzr
* @param id 主键
* @param ids 主键
*/
void del(Integer id);
void del(List<Integer> ids);
}

View File

@ -60,8 +60,8 @@ public interface ISettingDictTypeService {
* 字典类型删除
*
* @author fzr
* @param id 主键
* @param ids 主键
*/
void del(Integer id);
void del(List<Integer> ids);
}

View File

@ -208,21 +208,17 @@ public class SettingDictDataServiceImpl implements ISettingDictDataService {
* 字典数据删除
*
* @author fzr
* @param id 主键
* @param ids 主键
*/
@Override
public void del(Integer id) {
DictData model = dictDataMapper.selectOne(new QueryWrapper<DictData>()
.eq("id", id)
.eq("is_delete", 0)
.last("limit 1"));
Assert.notNull(model, "字典数据不存在!");
model.setId(id);
model.setIsDelete(1);
model.setDeleteTime(System.currentTimeMillis() / 1000);
dictDataMapper.updateById(model);
public void del(List<Integer> ids) {
for (Integer id : ids) {
DictData model = new DictData();
model.setId(id);
model.setIsDelete(1);
model.setDeleteTime(System.currentTimeMillis() / 1000);
dictDataMapper.updateById(model);
}
}
}

View File

@ -189,21 +189,17 @@ public class SettingDictTypeServiceImpl implements ISettingDictTypeService {
* 字典类型删除
*
* @author fzr
* @param id 主键
* @param ids 主键
*/
@Override
public void del(Integer id) {
DictType model = dictTypeMapper.selectOne(new QueryWrapper<DictType>()
.select("id")
.eq("id", id)
.eq("is_delete", 0)
.last("limit 1"));
Assert.notNull(model, "字典类型不存在!");
model.setIsDelete(1);
model.setDeleteTime(System.currentTimeMillis() / 1000);
dictTypeMapper.updateById(model);
public void del(List<Integer> ids) {
for(Integer id : ids) {
DictType model = new DictType();
model.setId(id);
model.setIsDelete(1);
model.setDeleteTime(System.currentTimeMillis() / 1000);
dictTypeMapper.updateById(model);
}
}
}

View File

@ -10,6 +10,7 @@ import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* 字典数据参数
@ -25,9 +26,12 @@ public class DictDataParam implements Serializable {
public interface update{}
public interface delete{}
@IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class})
@IDMust(message = "id参数必传且需大于0", groups = {update.class})
private Integer id;
@NotNull(message = "ids参数缺失", groups = {DictDataParam.delete.class})
private List<Integer> ids;
@IDMust(message = "typeId参数必传且需大于0", groups = {create.class, update.class})
private Integer typeId;

View File

@ -9,6 +9,7 @@ import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* 字典类型参数
@ -27,6 +28,9 @@ public class DictTypeParam implements Serializable {
@IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class})
private Integer id;
@NotNull(message = "ids参数缺失", groups = {DictDataParam.delete.class})
private List<Integer> ids;
@NotNull(message = "dictName参数缺失", groups = {create.class, update.class})
@Length(max = 200, message = "名称不能超出200个字符", groups = {create.class, update.class})
private String dictName;