add 动态消息-删除、批量删除
This commit is contained in:
@@ -61,6 +61,8 @@ public class FieldCommon {
|
||||
public static final String ID = "id";
|
||||
// 标准编号
|
||||
public static final String STANDARD_NUMBER = "standard_number";
|
||||
// 新增页面标准编号
|
||||
public static final String STANDARD_NUMBER_TEMP = "standard_number_temp";
|
||||
// 年代号
|
||||
public static final String YEAR_NUMBER = "year_number";
|
||||
// 标准名称
|
||||
|
||||
@@ -19,6 +19,7 @@ public class ResultCommon {
|
||||
public static final String EXIST_STANDARD_NUMBER = "message.exists.standard.number"; // 标准编号已经存在
|
||||
public static final String NOT_EXIST_PARAM = "message.no.exists.param"; // 参数{0}不存在
|
||||
public static final String NO_PERMISSION = "message.no.permission"; // 没有数据操作权限
|
||||
public static final String SELECT_DATA = "message.select.data"; // 请选择数据
|
||||
|
||||
public static final String RMR_SET_QUALITY_OVER_TEN = "es.rmr.setQuality.overTen"; // 请最多选择10条
|
||||
|
||||
|
||||
+3
-3
@@ -799,15 +799,15 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
public void setStandardNumber(Map<String, Object> parameterMap) {
|
||||
// 标准类别
|
||||
String standardClass = (String) parameterMap.get(FieldCommon.STANDARD_CLASS);
|
||||
// 法规编号不能为空
|
||||
String standardNumber = (String) parameterMap.get(FieldCommon.STANDARD_NUMBER);
|
||||
// 法规编号不能为空(新增页面)
|
||||
String standardNumber = (String) parameterMap.get(FieldCommon.STANDARD_NUMBER_TEMP);
|
||||
// 年代号
|
||||
String yearNumber = (String) parameterMap.get(FieldCommon.YEAR_NUMBER);
|
||||
if (StringUtils.isBlank(standardClass)) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, FieldCommon.STANDARD_CLASS);
|
||||
}
|
||||
if (StringUtils.isBlank(standardNumber)) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_STANDARD_NUMBER, "");
|
||||
throw new JeroBootException(ResultCommon.EMPTY_STANDARD_NUMBER);
|
||||
}
|
||||
if (StringUtils.isBlank(yearNumber)) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, FieldCommon.YEAR_NUMBER);
|
||||
|
||||
+6
-33
@@ -2,9 +2,9 @@ package com.jero.modules.laws.standard.controller;
|
||||
|
||||
import java.util.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.MessageUtils;
|
||||
import com.jero.modules.laws.common.constant.ResultCommon;
|
||||
import com.jero.modules.laws.standard.entity.LawsNewsFeed;
|
||||
@@ -15,7 +15,6 @@ import com.jero.common.system.base.controller.JeroController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
@@ -115,10 +114,10 @@ public class LawsNewsFeedController extends JeroController<LawsNewsFeed, ILawsNe
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<T> delete(@RequestBody Map<String, String> map) {
|
||||
if (!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))) {
|
||||
return Result.error("请选择数据!");
|
||||
throw new JeroBootException(ResultCommon.SELECT_DATA);
|
||||
}
|
||||
lawsNewsFeedService.deleteById(map.get("id"));
|
||||
return Result.OK("删除成功!");
|
||||
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,10 +131,10 @@ public class LawsNewsFeedController extends JeroController<LawsNewsFeed, ILawsNe
|
||||
@PostMapping(value = "/deleteBatch")
|
||||
public Result<T> deleteBatch(@RequestBody Map<String, String> map) {
|
||||
if (!map.containsKey("ids") || StringUtils.isEmpty(map.get("ids"))) {
|
||||
return Result.error("请选择数据!");
|
||||
throw new JeroBootException(ResultCommon.SELECT_DATA);
|
||||
}
|
||||
this.lawsNewsFeedService.deleteByIds(Arrays.asList(map.get("ids").split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,35 +146,9 @@ public class LawsNewsFeedController extends JeroController<LawsNewsFeed, ILawsNe
|
||||
@AutoLog(value = "动态消息-通过id查询")
|
||||
@ApiOperation(value = "动态消息-通过id查询", notes = "动态消息-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<LawsNewsFeed> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
public Result<LawsNewsFeed> queryById(@RequestParam(name = "id") String id) {
|
||||
LawsNewsFeed lawsNewsFeed = lawsNewsFeedService.queryById(id);
|
||||
if (lawsNewsFeed == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(lawsNewsFeed);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param lawsNewsFeed
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, LawsNewsFeed lawsNewsFeed) {
|
||||
return super.exportXls(request, lawsNewsFeed, LawsNewsFeed.class, "动态消息");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<LawsNewsFeed> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, LawsNewsFeed.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+25
-3
@@ -2,6 +2,7 @@ package com.jero.modules.laws.standard.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.modules.laws.common.constant.FieldCommon;
|
||||
import com.jero.modules.laws.common.constant.ResultCommon;
|
||||
@@ -21,6 +22,9 @@ import com.jero.common.exception.JeroBootException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -144,7 +148,13 @@ public class LawsNewsFeedServiceImpl extends ServiceImpl<LawsNewsFeedMapper, Law
|
||||
*/
|
||||
@Override
|
||||
public void deleteById(String id) {
|
||||
removeById(id);
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
LawsNewsFeed lawsNewsFeed = getById(id);
|
||||
if (!loginUser.getId().equals(lawsNewsFeed.getWriter())
|
||||
&& !loginUser.getRoleIds().contains(FieldCommon.ROLE_ADMIN_ID)) {
|
||||
throw new JeroBootException(ResultCommon.NO_PERMISSION);
|
||||
}
|
||||
removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +165,15 @@ public class LawsNewsFeedServiceImpl extends ServiceImpl<LawsNewsFeedMapper, Law
|
||||
*/
|
||||
@Override
|
||||
public void deleteByIds(List<String> ids) {
|
||||
removeByIds(ids);
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
List<LawsNewsFeed> newsFeedList = listByIds(ids);
|
||||
List<String> writerList = newsFeedList.stream().map(LawsNewsFeed::getWriter)
|
||||
.distinct().collect(Collectors.toList());
|
||||
if ((writerList.size() > 1 || !loginUser.getId().equals(writerList.get(0)))
|
||||
&& !loginUser.getRoleIds().contains(FieldCommon.ROLE_ADMIN_ID)) {
|
||||
throw new JeroBootException(ResultCommon.NO_PERMISSION);
|
||||
}
|
||||
removeByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,6 +184,10 @@ public class LawsNewsFeedServiceImpl extends ServiceImpl<LawsNewsFeedMapper, Law
|
||||
*/
|
||||
@Override
|
||||
public LawsNewsFeed queryById(String id) {
|
||||
return getById(id);
|
||||
LawsNewsFeed lawsNewsFeed = getById(id);
|
||||
if (Objects.isNull(lawsNewsFeed)) {
|
||||
throw new JeroBootException(ResultCommon.NO_CORRESPONDING_DATA_FOUND);
|
||||
}
|
||||
return lawsNewsFeed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user