表格状态码转换,其他索引串转成名字

1.问题分析

原数据库

关联指标为数字串的形式,每个小数对应的是另一张表index的属性,我们想知道对应指标的名称,怎么在这里下面这种形式呢?

两种思路:

1.修改在后端处理,把后端关联指标部分修改成图二的字符串。

2.修改在前端处理,图一这张表数据传到后端,相关联表也传到后端,图一这种数字字符串用spilt方法相切形成数组,循环匹配index在数组里面的数据。

后端方法:

java 复制代码
    public List<FaReviewQuestion> selectFaReviewQuestionList(FaReviewQuestion faReviewQuestion)
    {
        //查出faReviewQuestion条件查询得到的数据
        List<FaReviewQuestion> list=faReviewQuestionMapper.selectFaReviewQuestionList(faReviewQuestion);
        //遍历每一条数据
        for (FaReviewQuestion reviewQuestion : list) {
            //找到FaReviewQuestion对象的RuleIndex属性,并且使用split方法切割
            String indexs=reviewQuestion.getRuleIndex();
            String[] arrs=indexs.split(",");
            //定义一个字符串类型拼接字符串
            String newIndex="";
            //查询FaReviewRuleStudent表中index在数组中的数据使用的where index in (....) 动态sql或mybatisPlus,因为我这个表有特殊字符,所以用的动态sql
            List<FaReviewRuleStudent> list1=faReviewRuleStudentMapper.selectUsersByIds(Arrays.asList(arrs));
            for (FaReviewRuleStudent faReviewRuleStudent : list1) {
                //拼接每个指标的名称
                newIndex=newIndex+" "+faReviewRuleStudent.getName()+" ";
            }
            //把指标中的数字串替换为名称字符串
            reviewQuestion.setRuleIndex(newIndex);
        }
        return list;
    }

动态sql:

XML 复制代码
<select id="selectUsersByIds"  resultMap="FaReviewRuleStudentResult">
        SELECT * FROM fa_review_rule_student
        WHERE `index` IN
        <foreach collection="list" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
相关推荐
AI-好学者1 小时前
阶段一-图数据库基础与PropertyGraph模型
数据库·rag·knowledge graph·graphrag
其实防守也摸鱼3 小时前
运维--学习阶段问题解答(1)(自测)
linux·运维·服务器·数据库·学习·自动化·命令模式
懒鸟一枚3 小时前
深入理解 Linux 内存、Swap 交换分区与分页机制的关系
java·linux·数据库
龙仔7253 小时前
SQL Server 创建只读账号完整操作(分两种场景:SSMS图形界面 + T-SQL脚本)
数据库·sql·oracle
霁月的小屋3 小时前
生产环境中的事务实践——银行系统上线记(四)
数据库
Database_Cool_4 小时前
AI 应用数据底座首选:阿里云 PolarDB 为大模型 RAG 提供一体化支撑
数据库·阿里云
玖玥拾4 小时前
C# 语言进阶(十五)C# 游戏服务端 MySQL 数据库
服务器·开发语言·网络·数据库·mysql·c#
我命由我123455 小时前
执行 Gradle 指令报错,无法将“grep”项识别为 cmdlet、函数、脚本文件或可运行程序的名称
android·java·java-ee·android studio·android jetpack·android-studio·android runtime
考虑考虑5 小时前
Sentinel安装
java·后端·微服务
碎碎念_4925 小时前
SpringBoot + Vue 前后端分离从 0 到 1 完整环境配置流程
vue.js·spring boot·后端