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

1.问题分析

原数据库

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

两种思路:

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

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

后端方法:

    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:

<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>

相关推荐

  1. 表情转换

    2024-06-10 09:50:02       43 阅读
  2. MapString,String 转换Map

    2024-06-10 09:50:02       39 阅读
  3. 深度学习中读取索引图并tensor

    2024-06-10 09:50:02       18 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-10 09:50:02       5 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-10 09:50:02       5 阅读
  3. 在Django里面运行非项目文件

    2024-06-10 09:50:02       4 阅读
  4. Python语言-面向对象

    2024-06-10 09:50:02       6 阅读

热门阅读

  1. 1341. 电影评分

    2024-06-10 09:50:02       18 阅读
  2. 如何学好量子计算机技术的两种思路

    2024-06-10 09:50:02       12 阅读
  3. 爬山算法详细介绍

    2024-06-10 09:50:02       20 阅读
  4. 4. 流程控制语句

    2024-06-10 09:50:02       17 阅读
  5. vscode 好用的插件

    2024-06-10 09:50:02       19 阅读
  6. 23种设计模式——创建型模式

    2024-06-10 09:50:02       20 阅读
  7. 2024年6月10日--6月16日(渲染+ue独立游戏)

    2024-06-10 09:50:02       22 阅读
  8. Terminal Multiplexer的使用

    2024-06-10 09:50:02       24 阅读
  9. 什么情况下需要用到动态IP

    2024-06-10 09:50:02       20 阅读
  10. node-mysql中占位符?的使用

    2024-06-10 09:50:02       20 阅读
  11. 007 CentOS 7.9 apache-tomcat-9.0.89安装及配置

    2024-06-10 09:50:02       18 阅读
  12. 设计模式-策略模式

    2024-06-10 09:50:02       19 阅读
  13. 密码学及其应用——安全邮件、公钥密码学和PKI

    2024-06-10 09:50:02       23 阅读