标签增加批量删除功能
This commit is contained in:
+50
@@ -7,10 +7,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.common.system.vo.DictModel;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.oConvertUtils;
|
||||
import com.jero.modules.enums.FixedFieldEnum;
|
||||
import com.jero.modules.system.entity.SysCategory;
|
||||
import com.jero.modules.system.model.TreeSelectModel;
|
||||
import com.jero.modules.system.service.ISysCategoryService;
|
||||
@@ -134,6 +136,7 @@ public class SysCategoryController {
|
||||
public Result<SysCategory> add(@RequestBody SysCategory sysCategory) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
try {
|
||||
sysCategory.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
sysCategoryService.addSysCategory(sysCategory);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
@@ -182,6 +185,25 @@ public class SysCategoryController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
// @RequiresPermissions("sys:category:list")
|
||||
@DeleteMapping(value = "/logicDelete")
|
||||
public Result<SysCategory> logicDelete(@RequestParam(name="id",required=true) String id) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
SysCategory sysCategory = sysCategoryService.getById(id);
|
||||
if(sysCategory==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
sysCategory.setDelFlag(CommonConstant.DEL_FLAG_1);
|
||||
result.success("删除成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param ids
|
||||
@@ -200,6 +222,34 @@ public class SysCategoryController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量逻辑删除
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
// @RequiresPermissions("sys:category:del")未改
|
||||
@DeleteMapping(value = "/logicDeleteBatch")
|
||||
public Result<SysCategory> logicDBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
if(ids==null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
}else {
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
for(String list:idList){
|
||||
SysCategory joinSystem=sysCategoryService.getById(list);
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(String.valueOf(joinSystem.getIsReadOnly()))) {
|
||||
if (FixedFieldEnum.FIXED_FIELD_ENUM.getValue().equals(joinSystem.getIsReadOnly())) {
|
||||
result.error500("包含固定字段,不可删除");
|
||||
} else {
|
||||
joinSystem.setDelFlag(CommonConstant.DEL_FLAG_1);
|
||||
result.success("批量删除成功!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
* @param id
|
||||
|
||||
+29
@@ -511,6 +511,35 @@ public class SysDictController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能:批量逻辑删除
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-批量字典", notes = "字典控制器-批量字典")
|
||||
@DeleteMapping(value = "/logicDeleteBatch")
|
||||
@CacheEvict(value= CacheConstant.SYS_DICT_CACHE, allEntries=true)
|
||||
public Result<SysDict> logicdeleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
Result<SysDict> result = new Result<SysDict>();
|
||||
if(oConvertUtils.isEmpty(ids)) {
|
||||
result.error500("参数不识别!");
|
||||
}else {
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
for(String list:idList){
|
||||
SysDict joinSystem=sysDictService.getById(list);
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(String.valueOf(joinSystem.getIsReadOnly()))) {
|
||||
if (FixedFieldEnum.FIXED_FIELD_ENUM.getValue().equals(joinSystem.getIsReadOnly())) {
|
||||
result.error500("包含固定字段,不可删除");
|
||||
} else {
|
||||
joinSystem.setDelFlag(CommonConstant.DEL_FLAG_1);
|
||||
result.success("批量删除成功!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能:刷新缓存
|
||||
* @date 修改时间 2021.4.8
|
||||
|
||||
+31
-1
@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -199,7 +200,36 @@ public class SysDictItemController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能:批量逻辑删除字典数据
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
//@RequiresPermissions("sys:dict:list")未改
|
||||
@RequestMapping(value = "/logicDeleteBatch", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true)
|
||||
public Result<SysDictItem> logicDeleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
Result<SysDictItem> result = new Result<SysDictItem>();
|
||||
if(ids==null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
}
|
||||
else {
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
for(String list:idList){
|
||||
SysDictItem joinSystem=sysDictItemService.getById(list);
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(String.valueOf(joinSystem.getIsReadOnly()))) {
|
||||
if (FixedFieldEnum.FIXED_FIELD_ENUM.getValue().equals(joinSystem.getIsReadOnly())) {
|
||||
result.error500("包含固定字段,不可删除");
|
||||
} else {
|
||||
joinSystem.setDelFlag(CommonConstant.DEL_FLAG_1);
|
||||
result.success("批量删除成功!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 字典值重复校验
|
||||
* @param sysDictItem
|
||||
|
||||
+5
@@ -2,6 +2,7 @@ package com.jero.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.jero.common.aspect.annotation.Dict;
|
||||
@@ -94,6 +95,10 @@ public class SysCategory implements Serializable,Comparable<SysCategory>{
|
||||
@Dict(dicCode = "attribute_type")
|
||||
private java.lang.String attributeType;
|
||||
|
||||
/**逻辑删除标识*/
|
||||
@TableLogic
|
||||
public Integer delFlag;
|
||||
|
||||
@Override
|
||||
public int compareTo(SysCategory o) {
|
||||
//比较条件我们定的是按照code的长度升序
|
||||
|
||||
Reference in New Issue
Block a user