•  数据库存储效果

  •  完整配置

    "birthday": {
        "tableId": 1,
        "extend": {
          "field": "idCard",
          "encDesMethod": "qt2db", //前端加密    qt db  qt2db
          "idCardBirthDay": true, //从身份证里面提取生日信息
          "idCardSex": true, //从身份证里面提取性别 1:男 0:女
          "idCardAreaCode": true //从身份证里面提取性别 提取行政区信息
        },
        "field": "birthday",
        "dataType": "varchar",
        "title": "生日",
        "remark": "生日",
        "name": "birthday",
        "alias": "birthday",
        "isList": false,
        "isDetail": true,
        "isEdit": false,
        "isAdd": false,
        "isData": true,
        "filter": {},
        "editPropertie": {
          "showMethod": "text"
        },
        "pagePropertie": {
          "showMethod": "text"
        },
        "maxLength": 100
      },
  •  局部配置

    {
    "columns": {
      "bdBbrIdcard": {
        "encDesMethod": "qt2db" //qt2db  qt  db
      },
      "bdTbrIdcard": {
        "encDesMethod": "qt2db" //qt2db  qt  db
      },
      "bdBbrDay": {
        "extend": {
    "encDesMethod": "qt2db", //前端加密    qt db  qt2db
    
          "field": "bdBbrIdcard",
          "idCardBirthDay": true //从身份证里面提取生日信息
        }
      },
      "bdTbrDay": {
        "extend": {
    "encDesMethod": "qt2db", //前端加密    qt db  qt2db
    
          "field": "bdTbrIdcard",
          "idCardBirthDay": true //从身份证里面提取生日信息
        }
      }
    }
    }
  •  后台实现源码

 /// <summary>
        /// 设置 列扩展信息 的值
        /// </summary>
        /// <param name="dicPK"></param>
        /// <param name="sqlColumn"></param>
        public void SetColumnExpand(PFGlobalParameter pf, Dictionary<string, object> dicPK, SqlColumn sqlColumn)
        {
            if (sqlColumn.Extend.Field == null)
            {
                sqlColumn.Extend.Field = ConvertUtil.Convert2CamelCase(sqlColumn.Extend.Alias, ColumnNameCase.LowerCamel);
            }
            if (!dicPK.ContainsKey(sqlColumn.Extend.Field)) return;

            // dic[$"{field}DecQt"] = temp;
            //  dic[$"{field}EnDbPswd"] = SetEnDbPswd(pf, null, temp);

            object sourceValue = dicPK[sqlColumn.Extend.Field];
            //处理 加密数据 给 特定数据赋值
            if (sqlColumn.Extend.EncDesMethod == EncDesMethod.Qt || sqlColumn.Extend.EncDesMethod == EncDesMethod.Qt2Db)
            {
                if (ValidateUtil.ValidateExistsValue(sourceValue))
                {
                    //if (dicPK.ContainsKey($"{sqlColumn.Extend.Field}DecQt"))
                    //{
                    //    sourceValue = dicPK[$"{sqlColumn.Extend.Field}DecQt"];
                    //}
                    //else
                    //{
                    //    throw new BizException(ErrorCodeConst.UN_KNOWN_99999.ErrorCode, $"【{sqlColumn.Extend.Field}DecQt】解密失败。");
                    //}

                    if (dicPK.ContainsKey($"{sqlColumn.Extend.Field}DecQt"))
                    {
                        sourceValue = dicPK[$"{sqlColumn.Extend.Field}DecQt"];
                    }
                    else
                    {
                        sourceValue = _desService.DecryptDefault(pf.OwnerId, pf.SysId, sourceValue.ToString());
                    }

                    if (sourceValue == null || string.IsNullOrEmpty(sourceValue.ToString()))
                    {
                        throw new BizException(ErrorCodeConst.UN_KNOWN_99999.ErrorCode, $"【{sqlColumn.Field}DecQt】解密失败。");
                    }

                }
            }

            if (ValidateUtil.ValidateExistsValue(sourceValue))
            {
                //IsPinYin IsPinYinFirst StartIndex
                if (sqlColumn.Extend.IsPinYin == true)
                {
                    dicPK[sqlColumn.Field] = ChineseUtil.GetPinyin(sourceValue.ToString());
                }
                else if (sqlColumn.Extend.IsPinYinFirst == true && sqlColumn.Extend.StartIndex != null && sqlColumn.Extend.Length != null)
                {
                    //获取拼音首字母
                    string sourceT = ChineseUtil.GetFirstPinyin(sourceValue.ToString());
                    dicPK[sqlColumn.Field] = SubstringUtil.Substring(sourceT, Convert.ToInt32(sqlColumn.Extend.StartIndex), Convert.ToInt32(sqlColumn.Extend.Length));
                }
                else if (sqlColumn.Extend.IsPinYinFirst == true)
                {
                    dicPK[sqlColumn.Field] = ChineseUtil.GetFirstPinyin(sourceValue.ToString());
                }
                else if (sqlColumn.Extend.StartIndex != null && sqlColumn.Extend.Length != null)
                {
                    dicPK[sqlColumn.Field] = SubstringUtil.Substring(sourceValue, Convert.ToInt32(sqlColumn.Extend.StartIndex), Convert.ToInt32(sqlColumn.Extend.Length));
                }
                else if (sqlColumn.Extend.IdCardAreaCode == true)
                {
                    dicPK[sqlColumn.Field] = IdCardUtil.GetCardIdInfo(sourceValue.ToString())?.AreaCode;
                }
                else if (sqlColumn.Extend.IdCardBirthDay == true)
                {
                    dicPK[sqlColumn.Field] = IdCardUtil.GetCardIdInfo(sourceValue.ToString())?.Birthday;
                }
                else if (sqlColumn.Extend.IdCardSex == true)
                {
                    dicPK[sqlColumn.Field] = IdCardUtil.GetCardIdInfo(sourceValue.ToString())?.Sex;
                }
            }
            else
            {
                dicPK[sqlColumn.Field] = sourceValue;
            }
        }

 前端身份证加密传递

 if (that.data.bdBbrIdcard) {
                dataT.bdBbrIdcard = that.$crypto.encryptByDES(that.data.bdBbrIdcard);
            }
            if (that.data.bdTbrIdcard) {
                dataT.bdTbrIdcard = that.$crypto.encryptByDES(that.data.bdTbrIdcard);
            }
文档更新时间: 2022-09-18 13:25   作者:admin