Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
29df0a1f
Commit
29df0a1f
authored
May 27, 2020
by
sxy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 去掉 appkey验证 修改 sysytem getObject
parent
854d8b12
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
107 additions
and
90 deletions
+107
-90
icp-deliver/app/base/controller/ctl.base.js
+31
-31
icp-deliver/app/base/controller/impl/bizchance/bizoptCtl.js
+11
-0
icp-deliver/app/base/db/impl/common/connection.js
+2
-2
icp-deliver/app/base/db/models/delivery/business_opportunity.js
+1
-1
icp-deliver/app/base/system.js
+59
-54
icp-deliver/app/config/localsettings.js
+2
-2
icp-deliver/package.json
+1
-0
No files found.
icp-deliver/app/base/controller/ctl.base.js
View file @
29df0a1f
...
@@ -30,57 +30,57 @@ class CtlBase {
...
@@ -30,57 +30,57 @@ class CtlBase {
return
system
.
getResult
(
rs
);
return
system
.
getResult
(
rs
);
}
}
async
refQuery
(
pobj
,
qobj
,
req
)
{
async
refQuery
(
pobj
,
qobj
,
req
)
{
pobj
.
refwhere
.
app_id
=
pobj
.
app_id
;
pobj
.
refwhere
.
app_id
=
pobj
.
app_id
;
pobj
.
refwhere
.
company_id
=
pobj
.
company_id
;
pobj
.
refwhere
.
company_id
=
pobj
.
company_id
;
let
rtn
=
await
this
.
service
.
refQuery
(
pobj
);
let
rtn
=
await
this
.
service
.
refQuery
(
pobj
);
return
rtn
return
rtn
}
}
async
setContextParams
(
pobj
,
qobj
,
req
)
{
async
setContextParams
(
pobj
,
qobj
,
req
)
{
let
custtags
=
req
.
headers
[
"x-consumetag"
]
?
req
.
headers
[
"x-consumetag"
].
split
(
"|"
):
null
;
let
custtags
=
req
.
headers
[
"x-consumetag"
]
?
req
.
headers
[
"x-consumetag"
].
split
(
"|"
)
:
null
;
let
lastindex
=
custtags
?
custtags
.
length
-
1
:
0
;
let
lastindex
=
custtags
?
custtags
.
length
-
1
:
0
;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
req
.
xctx
=
{
req
.
xctx
=
{
appkey
:
req
.
headers
[
"xappkey"
],
//用于系统管理区分应用,比如角色
appkey
:
req
.
headers
[
"xappkey"
],
//用于系统管理区分应用,比如角色
fromappkey
:
req
.
headers
[
"xfromappkey"
],
//来源APP,如果没有来源与appkey相同
fromappkey
:
req
.
headers
[
"xfromappkey"
],
//来源APP,如果没有来源与appkey相同
companyid
:
custtags
?
custtags
[
0
].
split
(
"_"
)[
1
]:
null
,
companyid
:
custtags
?
custtags
[
0
].
split
(
"_"
)[
1
]
:
null
,
fromcompanykey
:
req
.
headers
[
"xfromcompanykey"
],
//专用于自由用户注册,自由用户用于一定属于某个存在的公司
fromcompanykey
:
req
.
headers
[
"xfromcompanykey"
],
//专用于自由用户注册,自由用户用于一定属于某个存在的公司
password
:
custtags
?
custtags
[
lastindex
].
split
(
"_"
)[
1
]:
null
,
password
:
custtags
?
custtags
[
lastindex
].
split
(
"_"
)[
1
]
:
null
,
username
:
req
.
headers
[
"x-consumer-username"
],
username
:
req
.
headers
[
"x-consumer-username"
],
userid
:
req
.
headers
[
"x-consumer-custom-id"
],
userid
:
req
.
headers
[
"x-consumer-custom-id"
],
credid
:
req
.
headers
[
"x-credential-identifier"
],
credid
:
req
.
headers
[
"x-credential-identifier"
],
regrole
:
req
.
headers
[
"xregrole"
],
regrole
:
req
.
headers
[
"xregrole"
],
bizpath
:
req
.
headers
[
"xbizpath"
],
bizpath
:
req
.
headers
[
"xbizpath"
],
}
}
if
(
!
req
.
xctx
.
appkey
)
{
if
(
!
req
.
xctx
.
appkey
)
{
return
[
-
200
,
"请求头缺少应用x-app-key"
]
return
[
-
200
,
"请求头缺少应用x-app-key"
]
}
else
{
}
else
{
let
app
=
await
this
.
cacheManager
[
"AppCache"
].
cache
(
req
.
xctx
.
fromappkey
);
//
let app=await this.cacheManager["AppCache"].cache(req.xctx.fromappkey);
req
.
xctx
.
appid
=
app
.
id
;
//
req.xctx.appid=app.id;
if
(
!
pobj
.
app_id
){
//
if(!pobj.app_id){
pobj
.
app_id
=
app
.
id
;
//传递参数对象里注入app_id
//
pobj.app_id=app.id;//传递参数对象里注入app_id
}
//
}
}
}
//平台注册时,companyid,companykey都为空
//平台注册时,companyid,companykey都为空
//自由注册时,companykey不能为空
//自由注册时,companykey不能为空
// if(!req.xctx.companyid && !req.xctx.companykey){
// if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"]
// return [-200,"请求头缺少应用x-app-key"]
// }
// }
if
(
!
req
.
xctx
.
companyid
&&
req
.
xctx
.
fromcompanykey
&&
req
.
xctx
.
fromcompanykey
!=
"null"
)
{
if
(
!
req
.
xctx
.
companyid
&&
req
.
xctx
.
fromcompanykey
&&
req
.
xctx
.
fromcompanykey
!=
"null"
)
{
let
comptmp
=
await
this
.
cacheManager
[
"CompanyCache"
].
cache
(
req
.
xctx
.
fromcompanykey
);
let
comptmp
=
await
this
.
cacheManager
[
"CompanyCache"
].
cache
(
req
.
xctx
.
fromcompanykey
);
req
.
xctx
.
companyid
=
comptmp
.
id
;
req
.
xctx
.
companyid
=
comptmp
.
id
;
}
}
if
(
req
.
xctx
.
companyid
)
{
//在请求传递数据对象注入公司id
if
(
req
.
xctx
.
companyid
)
{
//在请求传递数据对象注入公司id
pobj
.
company_id
=
req
.
xctx
.
companyid
;
pobj
.
company_id
=
req
.
xctx
.
companyid
;
}
}
if
(
req
.
xctx
.
userid
)
{
//在请求传递数据对象注入公司id
if
(
req
.
xctx
.
userid
)
{
//在请求传递数据对象注入公司id
pobj
.
userid
=
req
.
xctx
.
userid
;
pobj
.
userid
=
req
.
xctx
.
userid
;
}
}
pobj
.
bizpath
=
req
.
xctx
.
bizpath
;
pobj
.
bizpath
=
req
.
xctx
.
bizpath
;
}
}
async
doexec
(
methodname
,
pobj
,
query
,
req
)
{
async
doexec
(
methodname
,
pobj
,
query
,
req
)
{
try
{
try
{
let
xarg
=
await
this
.
setContextParams
(
pobj
,
query
,
req
);
let
xarg
=
await
this
.
setContextParams
(
pobj
,
query
,
req
);
if
(
xarg
&&
xarg
[
0
]
<
0
)
{
if
(
xarg
&&
xarg
[
0
]
<
0
)
{
return
system
.
getResultFail
(...
xarg
);
return
system
.
getResultFail
(...
xarg
);
}
}
//从请求头里面取appkey_consumename
//从请求头里面取appkey_consumename
...
...
icp-deliver/app/base/controller/impl/bizchance/bizoptCtl.js
0 → 100644
View file @
29df0a1f
var
system
=
require
(
"../../../system"
)
const
http
=
require
(
"http"
)
const
querystring
=
require
(
'querystring'
);
var
settings
=
require
(
"../../../../config/settings"
);
const
CtlBase
=
require
(
"../../ctl.base"
);
class
BizOptCtl
extends
CtlBase
{
constructor
()
{
super
(
"bizchance"
,
CtlBase
.
getServiceName
(
BizOptCtl
));
}
}
module
.
exports
=
BizOptCtl
;
icp-deliver/app/base/db/impl/common/connection.js
View file @
29df0a1f
...
@@ -64,8 +64,8 @@ class DbFactory {
...
@@ -64,8 +64,8 @@ class DbFactory {
this
.
db
.
models
.
plugin
.
belongsTo
(
this
.
db
.
models
.
app
,
{
constraints
:
false
,
});
this
.
db
.
models
.
plugin
.
belongsTo
(
this
.
db
.
models
.
app
,
{
constraints
:
false
,
});
// 商机表 1:1 方案表
// 商机表 1:1 方案表
this
.
db
.
models
.
scheme
.
belongsTo
(
this
.
db
.
models
.
b
ussiness_opportunity
,
{
constraints
:
false
,
});
this
.
db
.
models
.
scheme
.
belongsTo
(
this
.
db
.
models
.
b
izopt
,
{
constraints
:
false
,
});
this
.
db
.
models
.
b
ussiness_opportunity
.
hasOne
(
this
.
db
.
models
.
scheme
,
{
constraints
:
false
,
});
this
.
db
.
models
.
b
izopt
.
hasOne
(
this
.
db
.
models
.
scheme
,
{
constraints
:
false
,
});
}
}
//async getCon(){,用于使用替换table模型内字段数据使用
//async getCon(){,用于使用替换table模型内字段数据使用
...
...
icp-deliver/app/base/db/models/delivery/business_opportunity.js
View file @
29df0a1f
...
@@ -5,7 +5,7 @@ const appconfig = system.getSysConfig();
...
@@ -5,7 +5,7 @@ const appconfig = system.getSysConfig();
* 商机表
* 商机表
*/
*/
module
.
exports
=
(
db
,
DataTypes
)
=>
{
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"b
ussiness_opportunity
"
,
{
return
db
.
define
(
"b
izopt
"
,
{
demand_code
:
{
// 需求编码
demand_code
:
{
// 需求编码
allowNull
:
false
,
allowNull
:
false
,
type
:
DataTypes
.
STRING
type
:
DataTypes
.
STRING
...
...
icp-deliver/app/base/system.js
View file @
29df0a1f
...
@@ -16,55 +16,55 @@ class System {
...
@@ -16,55 +16,55 @@ class System {
}
}
}
}
}
}
static
async
delReq
(
url
,
qdata
)
{
static
async
delReq
(
url
,
qdata
)
{
let
rtn
=
{}
let
rtn
=
{}
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
request
.
del
({
request
.
del
({
url
:
url
,
url
:
url
,
qs
:
qdata
qs
:
qdata
},
function
(
error
,
response
,
body
)
{
},
function
(
error
,
response
,
body
)
{
rtn
.
statusCode
=
response
.
statusCode
rtn
.
statusCode
=
response
.
statusCode
if
(
!
error
)
{
if
(
!
error
)
{
if
(
body
)
{
if
(
body
)
{
let
data
=
JSON
.
parse
(
body
)
let
data
=
JSON
.
parse
(
body
)
rtn
.
data
=
data
rtn
.
data
=
data
}
else
{
}
else
{
rtn
.
data
=
null
rtn
.
data
=
null
}
}
resv
(
rtn
);
resv
(
rtn
);
}
else
{
}
else
{
rej
(
error
)
rej
(
error
)
}
}
});
});
})
})
return
promise
;
return
promise
;
}
}
static
async
getReq
(
url
,
qdata
)
{
static
async
getReq
(
url
,
qdata
)
{
let
rtn
=
{}
let
rtn
=
{}
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
request
.
get
({
request
.
get
({
url
:
url
,
url
:
url
,
json
:
true
,
json
:
true
,
qs
:
qdata
qs
:
qdata
},
function
(
error
,
response
,
body
)
{
},
function
(
error
,
response
,
body
)
{
rtn
.
statusCode
=
response
.
statusCode
;
rtn
.
statusCode
=
response
.
statusCode
;
if
(
!
error
)
{
if
(
!
error
)
{
if
(
body
)
{
if
(
body
)
{
rtn
.
data
=
body
rtn
.
data
=
body
}
else
{
}
else
{
rtn
.
data
=
null
rtn
.
data
=
null
}
}
resv
(
rtn
);
resv
(
rtn
);
}
else
{
}
else
{
rej
(
error
);
rej
(
error
);
}
}
});
});
})
})
return
promise
;
return
promise
;
}
}
static
async
postJsonTypeReq
(
url
,
data
,
md
=
"POST"
)
{
static
async
postJsonTypeReq
(
url
,
data
,
md
=
"POST"
)
{
let
rtn
=
{}
let
rtn
=
{}
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
request
({
request
({
url
:
url
,
url
:
url
,
method
:
md
,
method
:
md
,
...
@@ -73,51 +73,51 @@ class System {
...
@@ -73,51 +73,51 @@ class System {
"content-type"
:
"application/json"
,
"content-type"
:
"application/json"
,
},
},
body
:
data
body
:
data
},
function
(
error
,
response
,
body
)
{
},
function
(
error
,
response
,
body
)
{
console
.
log
(
error
)
console
.
log
(
error
)
rtn
.
statusCode
=
response
.
statusCode
rtn
.
statusCode
=
response
.
statusCode
if
(
!
error
)
{
if
(
!
error
)
{
if
(
body
)
{
if
(
body
)
{
rtn
.
data
=
body
rtn
.
data
=
body
}
else
{
}
else
{
rtn
.
data
=
null
rtn
.
data
=
null
}
}
resv
(
rtn
);
resv
(
rtn
);
}
else
{
}
else
{
rej
(
error
)
rej
(
error
)
}
}
});
});
})
})
return
promise
;
return
promise
;
}
}
static
async
post3wFormTypeReq
(
url
,
data
)
{
static
async
post3wFormTypeReq
(
url
,
data
)
{
let
rtn
=
{}
let
rtn
=
{}
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
request
.
post
({
request
.
post
({
url
:
url
,
url
:
url
,
form
:
data
form
:
data
},
function
(
error
,
response
,
body
)
{
},
function
(
error
,
response
,
body
)
{
rtn
.
statusCode
=
response
.
statusCode
rtn
.
statusCode
=
response
.
statusCode
if
(
!
error
)
{
if
(
!
error
)
{
let
data
=
JSON
.
parse
(
body
)
let
data
=
JSON
.
parse
(
body
)
rtn
.
data
=
data
rtn
.
data
=
data
resv
(
rtn
);
resv
(
rtn
);
}
else
{
}
else
{
rej
(
error
)
rej
(
error
)
}
}
});
});
})
})
return
promise
;
return
promise
;
}
}
static
async
postMpFormTypeReq
(
url
,
formdata
)
{
static
async
postMpFormTypeReq
(
url
,
formdata
)
{
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
request
.
post
({
request
.
post
({
url
:
url
,
url
:
url
,
formData
:
formdata
formData
:
formdata
},
function
(
error
,
response
,
body
)
{
},
function
(
error
,
response
,
body
)
{
if
(
!
error
&&
response
.
statusCode
==
200
)
{
if
(
!
error
&&
response
.
statusCode
==
200
)
{
resv
(
body
);
resv
(
body
);
}
else
{
}
else
{
rej
(
error
)
rej
(
error
)
}
}
});
});
...
@@ -176,11 +176,16 @@ class System {
...
@@ -176,11 +176,16 @@ class System {
data
:
data
,
data
:
data
,
};
};
}
}
static
register
(
key
,
ClassObj
,
groupName
,
filename
)
{
static
register
(
key
,
ClassObj
,
groupName
,
filename
)
{
if
(
System
.
objTable
[
key
]
!=
null
)
{
if
(
System
.
objTable
[
key
]
!=
null
)
{
throw
new
Error
(
"相同key的对象已经存在"
);
throw
new
Error
(
"相同key的对象已经存在"
);
}
else
{
}
else
{
let
obj
=
new
ClassObj
(
groupName
,
filename
);
let
obj
;
if
(
ClassObj
.
name
===
"ServiceBase"
)
{
obj
=
new
ClassObj
(
groupName
,
filename
.
replace
(
"Sve"
,
"Dao"
));
}
else
{
obj
=
new
ClassObj
(
groupName
,
filename
);
}
System
.
objTable
[
key
]
=
obj
;
System
.
objTable
[
key
]
=
obj
;
}
}
...
@@ -208,22 +213,22 @@ class System {
...
@@ -208,22 +213,22 @@ class System {
if
(
System
.
objTable
[
objabspath
]
!=
null
)
{
if
(
System
.
objTable
[
objabspath
]
!=
null
)
{
return
System
.
objTable
[
objabspath
];
return
System
.
objTable
[
objabspath
];
}
else
{
}
else
{
var
ClassObj
=
null
;
var
ClassObj
=
null
;
try
{
try
{
ClassObj
=
require
(
objabspath
);
ClassObj
=
require
(
objabspath
);
}
catch
(
e
)
{
}
catch
(
e
)
{
// console.log(e)
// console.log(e)
let
fname
=
objsettings
[
packageName
+
"base"
];
let
fname
=
objsettings
[
packageName
+
"base"
];
ClassObj
=
require
(
fname
);
ClassObj
=
require
(
fname
);
}
}
if
(
ClassObj
.
name
==
"Dao"
)
{
if
(
ClassObj
.
name
==
"Dao"
)
{
let
modelname
=
filename
.
substring
(
0
,
filename
.
lastIndexOf
(
"Dao"
))
let
modelname
=
filename
.
substring
(
0
,
filename
.
lastIndexOf
(
"Dao"
))
return
System
.
register
(
objabspath
,
ClassObj
,
modelname
);
return
System
.
register
(
objabspath
,
ClassObj
,
modelname
);
}
}
if
(
ClassObj
.
name
.
indexOf
(
"Ctl"
)
>=
0
)
{
if
(
ClassObj
.
name
.
indexOf
(
"Ctl"
)
>=
0
)
{
console
.
log
(
ClassObj
.
name
);
console
.
log
(
ClassObj
.
name
);
}
}
return
System
.
register
(
objabspath
,
ClassObj
,
groupName
,
filename
);
return
System
.
register
(
objabspath
,
ClassObj
,
groupName
,
filename
);
}
}
}
}
...
...
icp-deliver/app/config/localsettings.js
View file @
29df0a1f
var
settings
=
{
var
settings
=
{
redis
:
{
redis
:
{
host
:
"
192.168.4.119
"
,
host
:
"
43.247.184.32
"
,
port
:
6379
,
port
:
8967
,
password
:
"Gongsibao2018"
,
password
:
"Gongsibao2018"
,
db
:
9
,
db
:
9
,
},
},
...
...
icp-deliver/package.json
View file @
29df0a1f
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
"description"
:
"h5framework"
,
"description"
:
"h5framework"
,
"main"
:
"main.js"
,
"main"
:
"main.js"
,
"scripts"
:
{
"scripts"
:
{
"dev"
:
"nodemon main.js"
,
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
},
"author"
:
"jy"
,
"author"
:
"jy"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment