默认值处理 mapper_mkey_sql__responsefield
"savePrev": [
{
"requestModuleType": "batsave",
"defaultValue": "XQDEFUALT",
"dataName": "needId",
"opType": "default"
},
{
"requestModuleType": "batsave",
"defaultValue": "未知",
"dataName": "needName",
"opType": "default"
},
{
"requestModuleType": "batsave",
"defaultValue": "-",
"dataName": "invoicedLastDate",
"opType": "default"
},
{
"requestModuleType": "batsave",
"dataName": "confirmADate",
"dataTargetColName":"remark",
"defaultValue": "1900-01-01",
"opType": "reset",
"mapperReps":[
{
"value":"后期确认"
},
{
"value":"预计"
}
]
},
{
"requestModuleType": "batsave",
"dataName": "confirmAPrice",
"dataTargetColName":"remark",
"defaultValue": "0",
"opType": "reset",
"mapperReps":[
{
"value":"时间"
}
]
}
],
新增预处理 mapper_mkey_sql__responsefield
{
"responseField": {
"global": {
"dataFromType": "Database",
"show": "receive_id",
"auth": true
},
"manager": {
// #region 移除多余字段
//"bridgeColumnRemoves": "",
// #endregion 移除多余字段
// #region 5分钟内数据置顶 {date_diff_sort},
"order": "create_date desc",
"field": {
//"sort": {
// "createTime": {
// "column": "create_date",
// "dateDiffMinute": 5
// }
//}
}
// #endregion 5分钟内数据置顶
},
"manager_detail": {
// #region 移除多余字段
//"bridgeColumnRemoves": ""
// #endregion 移除多余字段
}
},
//#region 入库前把其它表数据作为当前操作表参数(注意列以当前表为准)
"savePrev": [
{
"requestModuleType":"add",
// 唯一验证(dataName为空时候生效)
"sqlUnique": "select count(receive_id) from mall_coupon_receive where coupon_id=@couponId and buyer_id=@_userId",
"errorText": "不能重复领取。",
"sqlSelect": "select coupon_id,coupon_type,coupon_name,img_url,start_date,end_date,price coupon_price,full_price,area_code,merc_id,description from mall_coupon where coupon_id=@couponId",
"dataFromColName": "",
////如果没设置,使用多列模式
"dataName": "",
// 数据库对象,如果没设置,使用sqlConfig.Base.ConnName
"connName": ""
},
{
"requestModuleType":"batsave",
//"requestModuleType":"batsave,add,edit,modify",
"sqlSelect": "select coupon_id,coupon_type,coupon_name,img_url,start_date,end_date,price coupon_price,full_price,area_code,merc_id,description from mall_coupon where coupon_id in @ids",
"dataFromColName": "couponId",
////如果没设置,使用多列模式
"dataName": "",
// 数据库对象,如果没设置,使用sqlConfig.Base.ConnName
"connName": ""
},
{
"sqlFromObject":"user",
"requestModuleType":"batsave",
//"requestModuleType":"batsave,add,edit,modify",
"dataFromColName": "createBy",
////如果没设置,使用多列模式
"dataName": "",
// 数据库对象,如果没设置,使用sqlConfig.Base.ConnName
"connName": "",
"mapperCols":[
//列映射信息 通常用于批量 key 表示目标 field, value表示来源 field
{
"key":"",
"value":"name", //显示名
},
{
"key":"",
"value":"path", //头像
},
{
"key":"",
"value":"realName", //真实姓名
},
{
"key":"",
"value":"userName", //账号名
}
]
}
]
//#endregion 入库前把其它表数据作为当前操作表参数(注意列以当前表为准)
}
\RG3.BO.DB\Services\DbExecuteService$SavePreValue.cs
private void SetSavePreValue(PFGlobalParameter pf, SqlConfig sqlConfig, JObject jObject, Dictionary<string, object> dictionaryUrl)
{
//获取预加载的数据 把已存在的数据赋予参数中
if (sqlConfig.SavePrev == null || sqlConfig.SavePrev.Count == 0) return;
IEnumerable<SqlOpPre> sops = sqlConfig.SavePrev.Where<SqlOpPre>(temp => { return !string.IsNullOrEmpty(temp.SqlSelect); });
if (sops.Count() == 0) return;
foreach (SqlOpPre sop in sops)
{
BCDbConnection dbConnection = null;
if (!string.IsNullOrWhiteSpace(sop.ConnName))
{
dbConnection = _dbConnectionProvider.GetConnection(pf, sop.ConnName);
}
else
{
dbConnection = _dbConnectionProvider.GetConnection(pf, sqlConfig.Base.ConnName);
}
if (string.IsNullOrEmpty(sop.DataName))
{
// 多列模式
Dictionary<string, object> dictionary = new Dictionary<string, object>();
JTokenUtil.ConvertJObjectToDictionary(jObject, dictionary, dictionaryUrl);
var dicD = _db.QueryDictionary(pf, dbConnection, sop.SqlSelect, dictionary).First();
foreach (var dic in dicD)
{
jObject[dic.Key] = new JValue(dic.Value);
jObject[RegexUtil.ConvertDownLine2CamelCase(dic.Key)] = new JValue(dic.Value);
}
}
else
{
//单列模式
var jarray = jObject.SelectToken(sop.DataFromColName);
if (jarray == null) continue;
if (!(jarray is JArray)) continue;
foreach (JObject jobj in jarray)
{
Dictionary<string, object> dictionary = new Dictionary<string, object>();
JTokenUtil.ConvertJObjectToDictionary(jobj, dictionary, dictionaryUrl);
jobj[sop.DataName] = _db.ExecuteScalar<string>(pf, dbConnection, sop.SqlSelect, dictionary);
}
}
}
}
批量入库预处理 新增列:RequestModuleType MapperCols sop.SqlFromObject == “user”
文档更新时间: 2024-10-03 08:46 作者:admin