Commit 4e7816dd authored by 刘基明's avatar 刘基明

类型参数校验

parent 252e22eb
......@@ -52,6 +52,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
......@@ -160,6 +161,8 @@ public class ThemeManager {
if (CollectionUtils.isEmpty(req.getContent())) {
throw new BizException("正文内容不能为空");
}
//校验参数
checkAttachment(req.getContent());
// 保存主题表
ThemeEntity themeEntity = new ThemeEntity();
......@@ -169,8 +172,7 @@ public class ThemeManager {
checkContent(req);
themeEntity.setContent(JsonUtil.toJson(req.getContent()));
//附件校验
checkAttachment(req.getContent());
if (StringUtils.isBlank(req.getEditThemeId())) {
// 新建
......@@ -207,9 +209,13 @@ public class ThemeManager {
*/
private void checkAttachment(List<ThemeContentReq> themeAttachments) {
for (ThemeContentReq content : themeAttachments) {
if (content.getType() == null) {
if (content.getType() == null ) {
throw new IllegalArgumentException("主题内容ThemeContentReq缺少类型");
}
Set<String> types = Arrays.stream(RelTypeEnum.values()).map(o->o.type).collect(Collectors.toSet());
if (!types.contains(content.getType())){
throw new IllegalArgumentException("主题内容ThemeContentReq类型错误");
}
if (content.getType().equals(RelTypeEnum.FUND.type)) {
if (content.getProductType() == null) {
throw new IllegalArgumentException("附件产品FUND缺少类型");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment