package com.boman.web.core.service.fieldTranslator;

import com.alibaba.fastjson.JSONObject;
import com.boman.common.core.utils.StringUtils;
import com.boman.common.core.utils.fieldTranslator.IdCardUtils;
import com.boman.common.core.utils.obj.ObjectUtils;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * @author tjf
 * @Date: 2021/06/07/15:13
 */
@Service
public class FieldTranslatorServiceImpl implements IFieldTranslatorService{

    @Override
    public JSONObject idCardTranslator(JSONObject commitData) {
        Object idCard = commitData.get("id_card");
        Set<String> columnNameSet = commitData.keySet();
        if (columnNameSet.contains("birthday_user") && StringUtils.isBlank(String.valueOf(commitData.get("birthday_user")))){
            String birthday = IdCardUtils.getBirthday(String.valueOf(idCard));
            commitData.put("birthday_user",birthday);
        }
        if (columnNameSet.contains("gender_user") && StringUtils.isBlank(String.valueOf(commitData.get("gender_user")))){
            String sex = IdCardUtils.getSex(String.valueOf(idCard));
            commitData.put("gender_user",sex);
        }
        return commitData;
    }
}
