doomiwork 4.0.5 → 4.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -219,7 +219,7 @@ class controller {
219
219
  */
220
220
  async getDataById(req, dataKey, sqlCommand) {
221
221
  if (this.logger) this.logger.trace("准备获取dataconfig文件中对应的 %s 详细数据",dataKey)
222
- const detailinfo = getDetailInfo(dataKey);
222
+ const detailinfo = getDetailInfo(req, dataKey);
223
223
  if (!detailinfo) return { successed: false, errcode: -10, errmsg: `缺失${dataKey}对应的详情配置` };
224
224
  let beforeData = await this.beforeAccessDB(req, sqlCommand || this._daoModel.getByIdSql(), req.params.id, "detail", this);
225
225
  ////如果返回Null,则表示不加载数据了
@@ -255,7 +255,7 @@ class controller {
255
255
  let detailinfo, resultItem = { successed: true, data: req.body };
256
256
  ///是否需要将data中的key-value值到配置文件中进行转换
257
257
  if (mapping == true) {
258
- detailinfo = getDetailInfo(dataKey);
258
+ detailinfo = getDetailInfo(req, dataKey);
259
259
  if (!detailinfo) return { successed: false, errcode: -10, errmsg: `缺失${dataKey}对应的详情配置` };
260
260
  resultItem = View2Data(req, detailinfo.fields, "create");
261
261
  ///如果转换的验证过程中出现错误,则返回
@@ -307,7 +307,7 @@ class controller {
307
307
  let detailinfo, resultItem = { successed: true, data: req.body };
308
308
  ///是否需要将data中的key-value值到配置文件中进行转换
309
309
  if (mapping == true) {
310
- detailinfo = getDetailInfo(dataKey);
310
+ detailinfo = getDetailInfo(req, dataKey);
311
311
  if (!detailinfo) return { successed: false, errcode: -10, errmsg: `缺失${dataKey}对应的详情配置` };
312
312
  ///从Request中获取到用户提交的数据
313
313
  resultItem = View2Data(req, detailinfo.fields, "update");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doomiwork",
3
- "version": "4.0.5",
3
+ "version": "4.0.7",
4
4
  "description": "doomisoft nodejs web framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -114,6 +114,7 @@ module.exports.getListInfo = (req, dataKey, cfgType = 0, dao) => {
114
114
  //req.order =req.sort? utility.ifNull((req.body.order || req.query.order), ""):'';
115
115
  const dataConfig = dataconfig.getConfig(dataKey, cfgType);
116
116
  if (dataConfig && dataConfig.list) {
117
+ req.dataConfig = dataConfig
117
118
  let { sql, countsql, sqltype = 'sql', field, footer, search, sort: constsort } = dataConfig.list
118
119
  /**解析查询条件 */
119
120
  const searchCondition = this.getSearchCondition({ request: req, refer: search });
@@ -148,10 +149,11 @@ module.exports.getListInfo = (req, dataKey, cfgType = 0, dao) => {
148
149
  * 详细页面请求上下文中获取需要的信息
149
150
  * 如Page ,PageSize , Sort 等等
150
151
  */
151
- module.exports.getDetailInfo = (dataKey) => {
152
+ module.exports.getDetailInfo = (req,dataKey) => {
152
153
  if (dataKey) {
153
154
  const dataConfig = dataconfig.getConfig(dataKey);
154
155
  if (dataConfig && dataConfig.detail) {
156
+ req.dataConfig = dataConfig;
155
157
  const { primary, field: fields, primaryIsAutoIncrease } = dataConfig.detail;
156
158
  return { primary, fields, autoincrease: primaryIsAutoIncrease }
157
159
  }