doomiwork 2.7.1 → 2.9.1
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "doomiwork",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.1",
|
|
4
4
|
"description": "doomisoft nodejs web framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"author": "stephen.shen",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"doomi-helper": "^2.1
|
|
16
|
+
"doomi-helper": "^2.3.1",
|
|
17
17
|
"express": "^4.17.1",
|
|
18
18
|
"moment": "^2.29.1",
|
|
19
19
|
"mysql": "^2.18.1",
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* 解析上下文中对应dataconfig文件中的一些变量解析
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const uuid = require('node-uuid');
|
|
6
|
+
const moment = require('moment')
|
|
7
7
|
class KeywordParse
|
|
8
8
|
{
|
|
9
9
|
/*
|
|
@@ -12,8 +12,8 @@ class KeywordParse
|
|
|
12
12
|
*/
|
|
13
13
|
static parseKeyValue(req,str) {
|
|
14
14
|
if (!str) return str;
|
|
15
|
-
|
|
16
|
-
if (strItems.length
|
|
15
|
+
const strItems = str.split('.');
|
|
16
|
+
if (strItems.length===1)
|
|
17
17
|
{
|
|
18
18
|
switch(str.toLowerCase()){
|
|
19
19
|
case "userid()":
|
|
@@ -33,7 +33,7 @@ class KeywordParse
|
|
|
33
33
|
}
|
|
34
34
|
else
|
|
35
35
|
{
|
|
36
|
-
|
|
36
|
+
const collection;
|
|
37
37
|
if (strItems[0]=="" || strItems[1]=="") return str;
|
|
38
38
|
switch(strItems[0].toLowerCase())
|
|
39
39
|
{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const utility = require('doomi-helper').commonHelper
|
|
2
|
+
const keyParse = require('./keywordparse');
|
|
3
3
|
const dataconfig = require('../configuration/dataconfig').getCurrent();
|
|
4
|
+
const mysql = require('mysql');
|
|
4
5
|
class RequestParser {
|
|
5
6
|
/*
|
|
6
7
|
* 根据对应列表的配置(dataConfig.list.search),从请求上下文中获取用户进行搜索的参数信息
|
|
@@ -9,7 +10,7 @@ class RequestParser {
|
|
|
9
10
|
let paraCopy = option || {};
|
|
10
11
|
if (!paraCopy.request || !paraCopy.refer) return '';
|
|
11
12
|
if (!paraCopy.valueFrom) paraCopy.valueFrom = "all";
|
|
12
|
-
|
|
13
|
+
const request = paraCopy.request;
|
|
13
14
|
let retSearch = "";
|
|
14
15
|
paraCopy.refer.forEach(element=> {
|
|
15
16
|
retSearch = retSearch+this.parseAndReplaceSql(request, element.pattern,false);
|
|
@@ -22,14 +23,17 @@ class RequestParser {
|
|
|
22
23
|
static parseAndReplaceSql(req,sql,allowNull=true){
|
|
23
24
|
if (!sql) return '';
|
|
24
25
|
///定义正则准备查找sql中的特定关键字
|
|
25
|
-
|
|
26
|
+
const matched=sql.match(/@.*?@/g);
|
|
26
27
|
if (!matched || matched.length<=0) return sql;
|
|
27
28
|
var parseKeyWordIsNull = false;
|
|
28
29
|
matched.forEach(ele=>{
|
|
29
|
-
|
|
30
|
+
let matchValue = ele.substring(1,ele.length-1);
|
|
30
31
|
if (matchValue.indexOf(' ')>=0 || matchValue.indexOf(':')>=0 || matchValue.indexOf('=')>=0) return;
|
|
31
|
-
|
|
32
|
+
let keyValue =utility.ifNull(keyParse.parseKeyValue(req,ele.substring(1,ele.length-1)),'');
|
|
32
33
|
if(keyValue=='') parseKeyWordIsNull = true;
|
|
34
|
+
keyValue = mysql.escape(keyValue)
|
|
35
|
+
//keyValue = keyValue.replace(/'/g, "''")
|
|
36
|
+
keyValue = keyValue.substr(1, a.length - 2)
|
|
33
37
|
sql=sql.replace(ele,keyValue);
|
|
34
38
|
});
|
|
35
39
|
if (!allowNull && parseKeyWordIsNull) return '';
|
|
@@ -48,9 +52,9 @@ class RequestParser {
|
|
|
48
52
|
* 如Page ,PageSize , Sort 等等
|
|
49
53
|
*/
|
|
50
54
|
static getListInfo(req,cfgType=0,dao) {
|
|
51
|
-
|
|
55
|
+
const dataKey = utility.ifNull(req.dataKey, req.query.datakey);
|
|
52
56
|
///确认是否是需要导出Excel
|
|
53
|
-
|
|
57
|
+
const export2Excel =(req.query.exportexcel+"").toLowerCase()==="true";
|
|
54
58
|
req.page = req.query.page || req.body.page|| 1;
|
|
55
59
|
req.pageSize = req.query.rows || req.body.rows || 2000;
|
|
56
60
|
req.sort = req.query.sort || req.body.sort;
|
|
@@ -96,6 +100,7 @@ class RequestParser {
|
|
|
96
100
|
';SELECT FOUND_ROWS() AS total;';
|
|
97
101
|
/*** 如果存在汇总列的sql,则把SQL放置在最末尾 */
|
|
98
102
|
if(countsql){
|
|
103
|
+
req.countSql = true;
|
|
99
104
|
req.listSql+= this.appendSearchCondition2Count(
|
|
100
105
|
this.parseAndReplaceSql(req,countsql),
|
|
101
106
|
req.searchCondition)+';'
|
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
* 后台路由授权访问的Token验证
|
|
3
3
|
*/
|
|
4
4
|
const cache = require('doomi-helper').redisHelper.getInstance();
|
|
5
|
-
const logger = require('doomi-helper').logHelper.getInstance().getLogger('framework');
|
|
6
5
|
class TokenUtility {
|
|
7
6
|
static setToken(token, tokenObject, expire) {
|
|
8
7
|
if (typeof tokenObject != "string") tokenObject = JSON.stringify(tokenObject);
|
|
9
|
-
logger.trace('TokenUtility: set token ',tokenObject)
|
|
8
|
+
// logger.trace('TokenUtility: set token ',tokenObject)
|
|
10
9
|
return cache.set(token, tokenObject, expire);
|
|
11
10
|
}
|
|
12
11
|
///从缓存中获取用户
|
|
13
12
|
static getToken(token,isObject=true) {
|
|
14
13
|
return cache.get(token).then(result => {
|
|
15
|
-
logger.trace('TokenUtility getToken : ',result)
|
|
14
|
+
// logger.trace('TokenUtility getToken : ',result)
|
|
16
15
|
if (!result) return result;
|
|
17
16
|
var value = isObject?JSON.parse(result):result;
|
|
18
17
|
return value;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { commonHelper, stringHelper } = require('doomi-helper');
|
|
2
|
-
|
|
2
|
+
const keyParse = require('./keywordparse');
|
|
3
3
|
///值类型转换
|
|
4
4
|
class ViewHelper {
|
|
5
5
|
/*
|
|
@@ -38,8 +38,8 @@ class ViewHelper {
|
|
|
38
38
|
* 从请求上下文中获取数值,用于新增或修改
|
|
39
39
|
*/
|
|
40
40
|
static transferMapping2Name(req, fieldConfig, doWhat) {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
let model = {};
|
|
42
|
+
let tmpModel = {};
|
|
43
43
|
// var ingoreKey = req.query.ingoreNullKey != null && req.query.ingoreNullKey == 'true';
|
|
44
44
|
if (fieldConfig && Array.isArray(fieldConfig)) {
|
|
45
45
|
for (const element of fieldConfig){
|
|
@@ -65,10 +65,15 @@ class ViewHelper {
|
|
|
65
65
|
else
|
|
66
66
|
postValue = null;
|
|
67
67
|
}
|
|
68
|
+
if (!postValue && element.default) postValue = element.default;
|
|
68
69
|
///不允许为空值
|
|
69
70
|
if (element.required === true && !postValue) {
|
|
70
71
|
return { successed: false, errcode: 5, errmsg: '请填写必填字段内容', name: element.mapping }
|
|
71
72
|
}
|
|
73
|
+
//空值则不替换或不设置该字段
|
|
74
|
+
if (!postValue && element.ignorenull===true){
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
72
77
|
//验证值的类型是否正确,主要验证是否数字
|
|
73
78
|
if(element.type){
|
|
74
79
|
switch (element.type.toLowerCase()){
|