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

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") @PostMapping("/del")
public Object del(@Validated(value = DictDataParam.delete.class) @RequestBody DictDataParam dictDataParam) { public Object del(@Validated(value = DictDataParam.delete.class) @RequestBody DictDataParam dictDataParam) {
iSettingDictDataService.del(dictDataParam.getId()); iSettingDictDataService.del(dictDataParam.getIds());
return AjaxResult.success(); return AjaxResult.success();
} }

View File

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

View File

@ -60,8 +60,8 @@ public interface ISettingDictDataService {
* 字典数据删除 * 字典数据删除
* *
* @author fzr * @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 * @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 * @author fzr
* @param id 主键 * @param ids 主键
*/ */
@Override @Override
public void del(Integer id) { public void del(List<Integer> ids) {
DictData model = dictDataMapper.selectOne(new QueryWrapper<DictData>() for (Integer id : ids) {
.eq("id", id) DictData model = new DictData();
.eq("is_delete", 0) model.setId(id);
.last("limit 1")); model.setIsDelete(1);
model.setDeleteTime(System.currentTimeMillis() / 1000);
Assert.notNull(model, "字典数据不存在!"); dictDataMapper.updateById(model);
}
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 * @author fzr
* @param id 主键 * @param ids 主键
*/ */
@Override @Override
public void del(Integer id) { public void del(List<Integer> ids) {
DictType model = dictTypeMapper.selectOne(new QueryWrapper<DictType>() for(Integer id : ids) {
.select("id") DictType model = new DictType();
.eq("id", id) model.setId(id);
.eq("is_delete", 0) model.setIsDelete(1);
.last("limit 1")); model.setDeleteTime(System.currentTimeMillis() / 1000);
dictTypeMapper.updateById(model);
Assert.notNull(model, "字典类型不存在!"); }
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.DecimalMin;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* 字典数据参数 * 字典数据参数
@ -25,9 +26,12 @@ public class DictDataParam implements Serializable {
public interface update{} public interface update{}
public interface delete{} public interface delete{}
@IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class}) @IDMust(message = "id参数必传且需大于0", groups = {update.class})
private Integer id; private Integer id;
@NotNull(message = "ids参数缺失", groups = {DictDataParam.delete.class})
private List<Integer> ids;
@IDMust(message = "typeId参数必传且需大于0", groups = {create.class, update.class}) @IDMust(message = "typeId参数必传且需大于0", groups = {create.class, update.class})
private Integer typeId; private Integer typeId;

View File

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