惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Schneier on Security
The Last Watchdog
The Last Watchdog
Cyberwarzone
Cyberwarzone
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
L
Lohrmann on Cybersecurity
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
The Cloudflare Blog
V
V2EX
博客园_首页
博客园 - 聂微东
Vercel News
Vercel News
人人都是产品经理
人人都是产品经理
G
GRAHAM CLULEY
T
Tenable Blog
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
L
LINUX DO - 最新话题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
SecWiki News
SecWiki News
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
T
Troy Hunt's Blog
博客园 - 【当耐特】
Forbes - Security
Forbes - Security
H
Hacker News: Front Page
A
About on SuperTechFans
B
Blog RSS Feed
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
D
DataBreaches.Net
P
Privacy & Cybersecurity Law Blog
Schneier on Security
Schneier on Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Jina AI
Jina AI
D
Docker
P
Proofpoint News Feed

博客园 - timseng

ai辅助升级前端安全更新(贼快!hh openclaw的token又耗完了,先不冲了,记录下折腾踩坑过程 (如果需要协助安装500,帮忙卸载250[doge]) VS Code我的配置(持续更新) 推广:flowable工作流引擎就是高级版本的数据库而已(一) springboot升级3x导致邮件发送失败:错误1 jakarta.mail.NoSuchProviderException: smtp nice du更好的du分析文件占用工具ncdu 使用MITMProxy转发https请求到本地、保存鉴权给本地请求(二) 前端发布shell脚本 virtualBox环境Ubuntu升级后太卡,转debian很丝滑 收藏:加不加「/」?Nginx location 路径与 proxy_pass 的规律 使用visjs分析flowable流程数据 浏览器标签页多行显示:使用Floorp浏览器 最先进的跨平台 Firefox 衍生品 开源之光 开源WAF:ModSecurity探究与部署 mysql备份恢复云端之核心:更新扫描MySQL库里的所有表的UPDATE_TIME,若发生变动就mysqldump 使用MITMProxy转发请求到本地、保存鉴权给本地请求 这款Ubuntu的默认壁纸水母是真漂亮啊 笑死!'m not going to tell you who, but I know someone who recently locked himself out of the system he was using for an article covering iptables by forgetting the SSH rule. itext的PdfPCell中设置行间距失败的问题 Java递归函数计算递归次数出错
动态条件实现java
timseng · 2024-07-12 · via 博客园 - timseng

提交页面设计

json数据格式

[
    {
        "name": "规则1",
        "action": {
            "with": [
                {
                    "type": "SHOW",
                    "targets": [
                        "xd_hh_158444776217"
                    ]
                },
                {
                    "type": "HIDE",
                    "targets": [
                        "xd_hh_158772314112"
                    ]
                }
            ],
            "other": [
                {
                    "type": "HIDE",
                    "targets": [
                        "xd_hh_158444776217"
                    ]
                },
                {
                    "type": "SHOW",
                    "targets": [
                        "xd_hh_158772314112"
                    ]
                }
            ]
        },
        "condition": {
            "groupMode": true,
            "conditionList": [
                {
                    "mode": true,
                    "conditionList": [
                        {
                            "key": "xd_hh_162172344044",
                            "value": [
                                {
                                    "key": "16",
                                    "value": "16"
                                }
                            ],
                            "expression": "in"
                        }
                    ]
                }
            ]
        }
    }
]

java解析

  public Set<String> getRuleHideShowList(String rule,Map<String, Object> variables,Boolean returnHide)
      throws ErrorResponseException {
    Set<String> showIds = new HashSet<>();
    Set<String> hideIds = new HashSet<>();

    if(StrUtil.isNotBlank(rule)){

      List<FormRuleDto> formRuleDtoList = CommonUtil.toArray(rule, FormRuleDto.class);
      // 遍历每个规则
      for (FormRuleDto formRuleDto : formRuleDtoList) {
        Boolean with=null;
        FormRuleConditionDto formRuleConditionDto=formRuleDto.getCondition();
        for (FormRuleConditionItemDto formRuleConditionItemDto : formRuleConditionDto.getConditionList()) {

          Boolean getConditionListExpressionValue=null;
          for (FormRuleConditionItemItemDto formRuleConditionItemItemDto : formRuleConditionItemDto.getConditionList()) {
            boolean expressionValue=false;
            String key = formRuleConditionItemItemDto.getKey();
            Object value = formRuleConditionItemItemDto.getValue();
            String expression = formRuleConditionItemItemDto.getExpression();
            if(Objects.equals(expression, "in")){
              Object keyValue =variables.get(key);
              expressionValue=Objects.equals(value,keyValue);
            }else if(Objects.equals(expression, "notin"))
{ Object keyValue =variables.get(key);
expressionValue=!Objects.equals(value,keyValue);
}else
{ log.error("该动态表单表达式暂未支持,请联系管理员:{}", new Gson().toJson(rule)); ErrorResponseException exception = new ErrorResponseException(HttpStatus.NOT_FOUND); exception.setDetail("该动态表单表达式暂未支持,请联系管理员:" + expression); throw exception; } // if(formRuleConditionItemDto.getMode()){ if(getConditionListExpressionValue==null){ getConditionListExpressionValue=expressionValue; }else{ getConditionListExpressionValue=getConditionListExpressionValue && expressionValue; } }else{ // if(getConditionListExpressionValue==null){ getConditionListExpressionValue=expressionValue; }else{ getConditionListExpressionValue=getConditionListExpressionValue || expressionValue; } } } // if(formRuleConditionDto.getGroupMode()){ if(with==null){ with=getConditionListExpressionValue; }else{ with=with && getConditionListExpressionValue; } }else{ // if(with==null){ with=getConditionListExpressionValue; }else{ with=with || getConditionListExpressionValue; } } } // 获取所有action子节点 FormRuleActionDto action=formRuleDto.getAction(); if(with!=null && action!=null){ if(with){ List<FormRuleActionItemDto> actionWith= action.getWith(); for (FormRuleActionItemDto actionItemDto : actionWith) { if(Objects.equals(actionItemDto.getType(), "SHOW")){ showIds.addAll(actionItemDto.getTargets()); } if(Objects.equals(actionItemDto.getType(), "HIDE")){ hideIds.addAll(actionItemDto.getTargets()); } } }else{ List<FormRuleActionItemDto> actionOther= action.getOther(); for (FormRuleActionItemDto actionItemDto : actionOther) { if(Objects.equals(actionItemDto.getType(), "SHOW")){ showIds.addAll(actionItemDto.getTargets()); } if(Objects.equals(actionItemDto.getType(), "HIDE")){ hideIds.addAll(actionItemDto.getTargets()); } } } } } } if(returnHide){ return hideIds; }else{ return showIds; } }

支撑pdo

import lombok.Data;

@Data
public class FormRuleDto {
  String name;
  FormRuleActionDto action;
  FormRuleConditionDto condition;
}

import lombok.Data;

@Data
public class FormRuleConditionItemItemDto {
  String key;
  Object value;
  String expression;

}
import java.util.List;
import lombok.Data;

@Data
public class FormRuleConditionItemDto {
  Boolean mode;
  List<FormRuleConditionItemItemDto> conditionList;

}
import java.util.List;
import lombok.Data;

@Data
public class FormRuleConditionDto {
  Boolean groupMode;
  List<FormRuleConditionItemDto> conditionList;

}
import java.util.List;
import lombok.Data;

@Data
public class FormRuleActionItemDto {
  //  SHOW HIDE
  String type;
  List<String> targets;

}
import java.util.List;
import lombok.Data;

@Data
public class FormRuleActionDto {
  List<FormRuleActionItemDto> with;
  List<FormRuleActionItemDto> other;

}

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.xd.flow.engine.bo.flow.NodeUser;
import lombok.SneakyThrows;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
public class CommonUtil {

  /**
   * 1-26
   * 数字转大写英文字符
   *
   * @param num
   * @return
   */
  public static String numberToLetter(int num) {
    if (num <= 0) {
      return null;
    }
    String letter = "";
    num--;
    do {
      if (letter.length() > 0) {
        num--;
      }
      letter = ((char) (num % 26 + (int) 'A')) + letter;
      num = (int) ((num - num % 26) / 26);
    } while (num > 0);

    return letter;
  }

  @SneakyThrows
  public static <T> List<T> toArray(String json, Class<T> tClass) {
    Type type = TypeToken.getParameterized(ArrayList.class, tClass).getType();
    return new Gson().fromJson(json, type);
//    return JSON.parseArray(json, tClass);
  }

  @SneakyThrows
  public static <T> T toObj(String json, Class<T> tClass) {
    if (StrUtil.isBlank(json)) {
      return null;
    }
    return new Gson().fromJson(json, tClass);
  }

  @SneakyThrows
  public static String toJson(Object obj) {
    return new Gson().toJson(obj);
  }
}

该版本只支持in表达式可拓展startWith endWith contains等,动作支持hide show可拓展为其他动作