package com.muyu.rule.common.engine;

import cn.hutool.core.util.DesensitizedUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.muyu.etl.domain.DataValue;
import com.muyu.rule.common.basic.abstracts.DataEngineDataSetActuator;
import com.muyu.rule.common.domain.DataValueRows;


/**
 * @Author：张承志
 * @Package：com.muyu.rule.server.basic.engine.row
 * @Project：cloud-etl-rule
 * @name：数据集指定字段进行脱敏
 * @Date：2024/8/30 11:13
 */

public class ENGINE_DataSet_ytrrt_S2 extends DataEngineDataSetActuator {

    @Override
    public void run() {

        DataValueRows dataValueRows = get();
        DataValue[][] dataValues = dataValueRows.getDataValue();
        String key1 = dataValueRows.getKey();
        JSONObject jsonObject = JSON.parseObject(key1);
        String key = (String)jsonObject.get("key");

        for (DataValue[] value : dataValues) {
            for (DataValue dataValue1 : value) {
                if (dataValue1.getKey().equals(key)){
                    dataValue1.setValue(DesensitizedUtil.mobilePhone((String) dataValue1.getValue()));
                }
            }
        }
    }
}
