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": [
{
// 唯一验证(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": ""
}
]
//#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);
}
}
}
}
文档更新时间: 2022-10-26 09:11 作者:admin