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
eba45937
Commit
eba45937
authored
Sep 13, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
790664d4
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
236 additions
and
200 deletions
+236
-200
im-center/app/base/api/api.base.js
+47
-56
im-center/app/base/controller/ctl.base.js
+32
-49
im-center/app/base/db/impl/common/connection.js
+143
-0
im-center/app/base/db/models/msg/msghistory.js
+2
-2
im-center/app/base/db/models/msg/msgnotice.js
+2
-0
im-center/app/base/system.js
+1
-1
im-center/app/config/routes/api.js
+0
-84
im-center/app/config/routes/web.js
+0
-1
im-center/app/config/settings.js
+6
-6
im-center/app/config/socket.server2.js
+3
-1
No files found.
im-center/app/base/api/api.base.js
View file @
eba45937
const
system
=
require
(
"../system"
);
const
system
=
require
(
"../system"
);
const
uuidv4
=
require
(
'uuid/v4'
);
const
uuidv4
=
require
(
'uuid/v4'
);
const
settings
=
require
(
"../../config/settings"
);
const
settings
=
require
(
"../../config/settings"
);
class
APIBase
{
class
APIBase
{
constructor
()
{
constructor
()
{
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
logClient
=
system
.
getObject
(
"util.logClient"
);
this
.
logClient
=
system
.
getObject
(
"util.logClient"
);
}
getUUID
()
{
var
uuid
=
uuidv4
();
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
return
u
;
}
async
setContextParams
(
pobj
,
qobj
,
req
)
{
let
custtags
=
req
.
headers
[
"x-consumetag"
]
?
req
.
headers
[
"x-consumetag"
].
split
(
"|"
)
:
null
;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
req
.
xctx
=
{
appkey
:
req
.
headers
[
"xappkey"
],
//用于系统管理区分应用,比如角色
companyid
:
custtags
?
custtags
[
0
].
split
(
"_"
)[
1
]
:
null
,
password
:
custtags
?
custtags
[
1
].
split
(
"_"
)[
1
]
:
null
,
username
:
req
.
headers
[
"x-consumer-username"
],
credid
:
req
.
headers
[
"x-credential-identifier"
],
companykey
:
req
.
headers
[
"x-company-key"
],
//专用于自由用户注册,自由用户用于一定属于某个存在的公司
codename
:
req
.
headers
[
"xcodename"
],
codetitle
:
req
.
headers
[
"xcodetitle"
]
?
decodeURI
(
req
.
headers
[
"xcodetitle"
])
:
''
,
}
}
getUUID
()
{
if
(
!
req
.
xctx
.
appkey
)
{
var
uuid
=
uuidv4
();
return
[
-
200
,
"请求头缺少应用x-app-key"
]
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
}
else
{
return
u
;
let
app
=
await
this
.
cacheManager
[
"AppCache"
].
cache
(
req
.
xctx
.
appkey
);
req
.
xctx
.
appid
=
app
.
id
;
pobj
.
app_id
=
app
.
id
;
//传递参数对象里注入app_id
}
}
async
setContextParams
(
pobj
,
qobj
,
req
)
{
if
(
req
.
xctx
.
companyid
)
{
//在请求传递数据对象注入公司id
let
custtags
=
req
.
headers
[
"x-consumetag"
]?
req
.
headers
[
"x-consumetag"
].
split
(
"|"
):
null
;
pobj
.
company_id
=
req
.
xctx
.
companyid
;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
}
req
.
xctx
=
{
}
appkey
:
req
.
headers
[
"xappkey"
],
//用于系统管理区分应用,比如角色
async
doexec
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
companyid
:
custtags
?
custtags
[
0
].
split
(
"_"
)[
1
]:
null
,
try
{
password
:
custtags
?
custtags
[
1
].
split
(
"_"
)[
1
]:
null
,
let
xarg
=
await
this
.
setContextParams
(
pobj
,
query
,
req
);
username
:
req
.
headers
[
"x-consumer-username"
],
if
(
xarg
&&
xarg
[
0
]
<
0
)
{
credid
:
req
.
headers
[
"x-credential-identifier"
],
return
system
.
getResultFail
(...
xarg
);
companykey
:
req
.
headers
[
"x-company-key"
],
//专用于自由用户注册,自由用户用于一定属于某个存在的公司
codename
:
req
.
headers
[
"xcodename"
],
codetitle
:
req
.
headers
[
"xcodetitle"
]?
decodeURI
(
req
.
headers
[
"xcodetitle"
]):
''
,
}
if
(
!
req
.
xctx
.
appkey
){
return
[
-
200
,
"请求头缺少应用x-app-key"
]
}
else
{
let
app
=
await
this
.
cacheManager
[
"AppCache"
].
cache
(
req
.
xctx
.
appkey
);
req
.
xctx
.
appid
=
app
.
id
;
pobj
.
app_id
=
app
.
id
;
//传递参数对象里注入app_id
}
//平台注册时,companyid,companykey都为空
//自由注册时,companykey不能为空
// if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"]
// }
if
(
!
req
.
xctx
.
companyid
&&
req
.
xctx
.
companykey
){
let
comptmp
=
await
this
.
cacheManager
[
"CompanyCache"
].
cache
(
req
.
xctx
.
companykey
);
req
.
xctx
.
companyid
=
comptmp
.
id
;
}
if
(
req
.
xctx
.
companyid
){
//在请求传递数据对象注入公司id
pobj
.
company_id
=
req
.
xctx
.
companyid
;
}
}
}
async
doexec
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
try
{
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
let
xarg
=
await
this
.
setContextParams
(
pobj
,
query
,
req
);
this
.
logClient
.
log
(
pobj
,
req
,
rtn
)
if
(
xarg
&&
xarg
[
0
]
<
0
){
return
rtn
;
return
system
.
getResultFail
(...
xarg
);
}
catch
(
e
)
{
}
this
.
logClient
.
log
(
pobj
,
req
,
null
,
e
.
stack
)
console
.
log
(
e
.
stack
,
"api调用异常--error..................."
);
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,请联系管理员"
);
this
.
logClient
.
log
(
pobj
,
req
,
rtn
)
return
rtnerror
;
return
rtn
;
}
catch
(
e
)
{
this
.
logClient
.
log
(
pobj
,
req
,
null
,
e
.
stack
)
console
.
log
(
e
.
stack
,
"api调用异常--error..................."
);
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,请联系管理员"
);
return
rtnerror
;
}
}
}
}
}
}
module
.
exports
=
APIBase
;
module
.
exports
=
APIBase
;
im-center/app/base/controller/ctl.base.js
View file @
eba45937
...
@@ -8,11 +8,6 @@ class CtlBase {
...
@@ -8,11 +8,6 @@ class CtlBase {
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
logClient
=
system
.
getObject
(
"util.logClient"
);
this
.
logClient
=
system
.
getObject
(
"util.logClient"
);
}
}
getUUID
()
{
var
uuid
=
uuidv4
();
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
return
u
;
}
static
getServiceName
(
ClassObj
)
{
static
getServiceName
(
ClassObj
)
{
return
ClassObj
[
"name"
].
substring
(
0
,
ClassObj
[
"name"
].
lastIndexOf
(
"Ctl"
)).
toLowerCase
()
+
"Sve"
;
return
ClassObj
[
"name"
].
substring
(
0
,
ClassObj
[
"name"
].
lastIndexOf
(
"Ctl"
)).
toLowerCase
()
+
"Sve"
;
...
@@ -29,14 +24,18 @@ class CtlBase {
...
@@ -29,14 +24,18 @@ class CtlBase {
const
up
=
await
this
.
service
.
delete
(
pobj
);
const
up
=
await
this
.
service
.
delete
(
pobj
);
return
system
.
getResult
(
up
);
return
system
.
getResult
(
up
);
}
}
async
bulkDelete
(
ids
)
{
var
en
=
await
this
.
service
.
bulkDelete
(
ids
);
return
system
.
getResult
(
en
);
}
async
findAndCountAll
(
pobj
,
qobj
,
req
)
{
async
findAndCountAll
(
pobj
,
qobj
,
req
)
{
//设置查询条件
//设置查询条件
console
.
log
(
pobj
)
const
rs
=
await
this
.
service
.
findAndCountAll
(
pobj
);
const
rs
=
await
this
.
service
.
findAndCountAll
(
pobj
);
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
...
@@ -56,78 +55,63 @@ class CtlBase {
...
@@ -56,78 +55,63 @@ class CtlBase {
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"
],
codename
:
req
.
headers
[
"xcodename"
],
codetitle
:
req
.
headers
[
"xcodetitle"
]
?
decodeURI
(
req
.
headers
[
"xcodetitle"
])
:
''
,
opath
:
req
.
headers
[
'xopath'
],
opath
:
req
.
headers
[
'xopath'
],
ptags
:
req
.
headers
[
'xptags'
],
ptags
:
req
.
headers
[
'xptags'
],
codename
:
req
.
headers
[
"xcodename"
],
codetitle
:
req
.
headers
[
"xcodetitle"
]
?
decodeURI
(
req
.
headers
[
"xcodetitle"
])
:
''
,
}
}
//添加组织结构路径,如果是上级,取上级
if
(
req
.
xctx
.
ptags
&&
req
.
xctx
.
ptags
!=
""
)
{
if
(
req
.
xctx
.
ptags
&&
req
.
xctx
.
ptags
!=
""
)
{
pobj
.
opath
=
req
.
xctx
.
ptags
pobj
.
opath
=
req
.
xctx
.
ptags
}
else
{
}
else
{
if
(
!
pobj
.
opath
||
pobj
.
opath
==
""
)
{
pobj
.
opath
=
req
.
xctx
.
opath
pobj
.
opath
=
req
.
xctx
.
opath
}
}
}
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都为空
//自由注册时,companykey不能为空
// if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"]
// }
if
(
!
req
.
xctx
.
companyid
&&
req
.
xctx
.
fromcompanykey
&&
req
.
xctx
.
fromcompanykey
!=
"null"
&&
req
.
xctx
.
fromcompanykey
!=
"undefined"
)
{
let
comptmp
=
await
this
.
cacheManager
[
"CompanyCache"
].
cache
(
req
.
xctx
.
fromcompanykey
);
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
;
}
if
(
req
.
xctx
.
username
)
{
//在请求传递数据对象注入公司名称
pobj
.
username
=
req
.
xctx
.
username
;
pobj
.
username
=
req
.
xctx
.
username
;
}
}
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
// var consumeName=req.headers[""]
// var appkey=
// if( this.session["appkey_consumename"]) {
// }else{
// //从头里取,从redis中取出缓存对象赋值到控制基类的session属性
// //appkey_consumename
// this.session={};
// }
//req.session=redis缓存的上下文对象
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
//this.logClient.log(pobj, req, rtn, null
)
this
.
logClient
.
log
(
pobj
,
req
,
rtn
)
return
rtn
;
return
rtn
;
}
catch
(
e
)
{
}
catch
(
e
)
{
//this.logClient.log(pobj, req, null, e.stack)
this
.
logClient
.
log
(
pobj
,
req
,
null
,
e
.
stack
);
console
.
log
(
e
.
stack
,
"出现异常,请联系管理员......."
);
console
.
log
(
e
.
stack
,
"出现异常,请联系管理员......."
);
return
system
.
getResultFail
(
-
200
,
e
.
message
?
e
.
message
:
"出现异常,请联系管理员"
);
return
system
.
getResultFail
(
-
200
,
"出现异常,请联系管理员"
);
}
}
}
}
}
}
module
.
exports
=
CtlBase
;
module
.
exports
=
CtlBase
;
/*
地址:http://192.168.1.128:401/api/queueAction/producer/springBoard
请求方式:post
参数:
{
"actionType": "produceLogsData",// Y 功能名称
"actionBody": {
"opTitle": "",// N 操作的业务标题
"identifyCode": "logs001",// Y 操作的业务标识
"messageBody": {//日志的描述信息
"opUrl": "http://192.168.1.189:4012/api/test/testApi/springBoard",// N 操作的业务Url
"message": ""// Y 日志消息描述
}
}
}
logs-sytxpublic-msgq-service--日志服务
*/
\ No newline at end of file
im-center/app/base/db/impl/common/connection.js
0 → 100644
View file @
eba45937
const
Sequelize
=
require
(
'sequelize'
);
const
settings
=
require
(
"../../../../config/settings"
)
const
fs
=
require
(
"fs"
)
const
path
=
require
(
"path"
);
var
glob
=
require
(
"glob"
);
const
Op
=
Sequelize
.
Op
class
DbFactory
{
constructor
()
{
const
dbConfig
=
settings
.
database
();
this
.
db
=
new
Sequelize
(
dbConfig
.
dbname
,
dbConfig
.
user
,
dbConfig
.
password
,
{
...
dbConfig
.
config
,
operatorsAliases
:
{
$eq
:
Op
.
eq
,
$ne
:
Op
.
ne
,
$gte
:
Op
.
gte
,
$gt
:
Op
.
gt
,
$lte
:
Op
.
lte
,
$lt
:
Op
.
lt
,
$not
:
Op
.
not
,
$in
:
Op
.
in
,
$notIn
:
Op
.
notIn
,
$is
:
Op
.
is
,
$like
:
Op
.
like
,
$notLike
:
Op
.
notLike
,
$iLike
:
Op
.
iLike
,
$notILike
:
Op
.
notILike
,
$regexp
:
Op
.
regexp
,
$notRegexp
:
Op
.
notRegexp
,
$iRegexp
:
Op
.
iRegexp
,
$notIRegexp
:
Op
.
notIRegexp
,
$between
:
Op
.
between
,
$notBetween
:
Op
.
notBetween
,
$overlap
:
Op
.
overlap
,
$contains
:
Op
.
contains
,
$contained
:
Op
.
contained
,
$adjacent
:
Op
.
adjacent
,
$strictLeft
:
Op
.
strictLeft
,
$strictRight
:
Op
.
strictRight
,
$noExtendRight
:
Op
.
noExtendRight
,
$noExtendLeft
:
Op
.
noExtendLeft
,
$and
:
Op
.
and
,
$or
:
Op
.
or
,
$any
:
Op
.
any
,
$all
:
Op
.
all
,
$values
:
Op
.
values
,
$col
:
Op
.
col
}
});
this
.
db
.
Sequelize
=
Sequelize
;
this
.
db
.
Op
=
Sequelize
.
Op
;
this
.
initModels
();
this
.
initRelations
();
}
async
initModels
()
{
var
self
=
this
;
var
modelpath
=
path
.
normalize
(
path
.
join
(
__dirname
,
'../..'
))
+
"/models/"
;
var
models
=
glob
.
sync
(
modelpath
+
"/**/*.js"
);
console
.
log
(
models
.
length
);
models
.
forEach
(
function
(
m
)
{
console
.
log
(
m
);
self
.
db
.
import
(
m
);
});
console
.
log
(
"init models...."
);
}
async
initRelations
()
{
}
//async getCon(){,用于使用替换table模型内字段数据使用
getCon
()
{
var
that
=
this
;
// await this.db.authenticate().then(()=>{
// console.log('Connection has been established successfully.');
// }).catch(err => {
// console.error('Unable to connect to the database:', err);
// throw err;
// });
//同步模型
if
(
settings
.
env
==
"dev"
)
{
//console.log(pa);
// pconfigObjs.forEach(p=>{
// console.log(p.get({plain:true}));
// });
// await this.db.models.user.create({nickName:"dev","description":"test user",openId:"testopenid",unionId:"testunionid"})
// .then(function(user){
// var acc=that.db.models.account.build({unionId:"testunionid",nickName:"dev"});
// acc.save().then(a=>{
// user.setAccount(a);
// });
// });
}
return
this
.
db
;
}
}
module
.
exports
=
DbFactory
;
// const dbf=new DbFactory();
// dbf.getCon().then((db)=>{
// //console.log(db);
// // db.models.user.create({nickName:"jy","description":"cccc",openId:"xxyy",unionId:"zz"})
// // .then(function(user){
// // var acc=db.models.account.build({unionId:"zz",nickName:"jy"});
// // acc.save().then(a=>{
// // user.setAccount(a);
// // });
// // console.log(user);
// // });
// // db.models.user.findAll().then(function(rs){
// // console.log("xxxxyyyyyyyyyyyyyyyyy");
// // console.log(rs);
// // })
// });
// const User = db.define('user', {
// firstName: {
// type: Sequelize.STRING
// },
// lastName: {
// type: Sequelize.STRING
// }
// });
// db
// .authenticate()
// .then(() => {
// console.log('Co+nnection has been established successfully.');
//
// User.sync(/*{force: true}*/).then(() => {
// // Table created
// return User.create({
// firstName: 'John',
// lastName: 'Hancock'
// });
// });
//
// })
// .catch(err => {
// console.error('Unable to connect to the database:', err);
// });
//
// User.findAll().then((rows)=>{
// console.log(rows[0].firstName);
// });
im-center/app/base/db/models/msg/msghistory.js
View file @
eba45937
const
system
=
require
(
"../../system"
);
const
system
=
require
(
"../../
../
system"
);
const
settings
=
require
(
"../../../config/settings"
);
const
settings
=
require
(
"../../../
../
config/settings"
);
const
appconfig
=
system
.
getSysConfig
();
const
appconfig
=
system
.
getSysConfig
();
module
.
exports
=
(
db
,
DataTypes
)
=>
{
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"msghistory"
,
{
return
db
.
define
(
"msghistory"
,
{
...
...
im-center/app/base/db/models/msg/msgnotice.js
View file @
eba45937
const
system
=
require
(
"../../../system"
);
const
settings
=
require
(
"../../../../config/settings"
);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"msgnotice"
,
{
return
db
.
define
(
"msgnotice"
,
{
fromuser
:
DataTypes
.
STRING
,
//需要在后台补充
fromuser
:
DataTypes
.
STRING
,
//需要在后台补充
...
...
im-center/app/base/system.js
View file @
eba45937
...
@@ -231,7 +231,7 @@ class System {
...
@@ -231,7 +231,7 @@ class System {
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
);
}
}
...
...
im-center/app/config/routes/api.js
View file @
eba45937
var
url
=
require
(
"url"
);
var
url
=
require
(
"url"
);
var
System
=
require
(
"../../base/system"
);
var
System
=
require
(
"../../base/system"
);
const
chnelapi
=
System
.
getObject
(
"api.common.channels"
)
const
userS
=
System
.
getObject
(
"service.auth.userSve"
)
const
roleS
=
System
.
getObject
(
"service.auth.roleSve"
)
const
companyS
=
System
.
getObject
(
"service.common.companySve"
)
const
settings
=
require
(
"../settings.js"
)
const
settings
=
require
(
"../settings.js"
)
let
channelCache
=
{};
let
channelCache
=
{};
module
.
exports
=
function
(
app
)
{
module
.
exports
=
function
(
app
)
{
app
.
post
(
"/autologin"
,
async
function
(
req
,
res
,
next
)
{
try
{
console
.
log
(
req
.
body
)
let
appkey
=
req
.
body
.
appkey
.
trim
()
if
(
!
appkey
)
{
let
rd
=
System
.
getResult
(
null
,
"没有资质宝appkey,请联系资质宝服务提供方"
)
res
.
end
(
JSON
.
stringify
(
rd
))
return
}
let
companykey
=
req
.
body
.
companykey
.
trim
()
if
(
!
companykey
)
{
let
rd
=
System
.
getResult
(
null
,
"没有公司宝的租户companykey,请联系资质宝服务提供方"
)
res
.
end
(
JSON
.
stringify
(
rd
))
return
}
//let cooktoken = req.cookies["accessToken"]
let
cooktoken
=
req
.
body
.
accesskey
console
.
log
(
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>........................................"
)
console
.
log
(
cooktoken
)
let
tv
=
cooktoken
let
sourceUser
=
System
.
verify
(
tv
,
settings
.
publickey
())
let
openid
=
sourceUser
.
employee
let
userName
=
openid
let
nickName
=
sourceUser
.
name
let
unid
=
sourceUser
.
unionid
let
fixedcodes
=
[
"资质宝交付员"
,
'资质宝业务员'
]
let
rolecodes
=
sourceUser
.
roles
?
sourceUser
.
roles
:
[]
let
rcs
=
rolecodes
.
filter
(
rc
=>
{
if
(
fixedcodes
.
indexOf
(
rc
)
>=
0
)
{
return
true
}
else
{
return
false
}
})
if
(
rcs
.
length
==
0
)
{
let
rd
=
System
.
getResult
(
null
,
"当前登录人没有资质宝访问权限"
)
res
.
end
(
JSON
.
stringify
(
rd
))
return
}
//先按照openid去查看是否已经存在
let
uf
=
await
userS
.
dao
.
model
.
findOne
({
where
:
{
openid
:
openid
}
})
if
(
!
uf
)
{
//按照公司companykey查询出要注册公司的所在公司,取公司id
let
company
=
await
companyS
.
dao
.
model
.
findOne
({
where
:
{
companykey
:
companykey
}
})
//构造注册用户对象,需要设置默认角色,默认角色需要按照rolecode查询出角色
let
rolesfind
=
await
roleS
.
dao
.
model
.
findAll
({
where
:
{
code
:
{
[
roleS
.
db
.
Op
.
in
]:
rcs
},
company_id
:
company
.
id
}
})
//根据rolecode--,设置组织路径
let
opath
=
''
let
isSalesman
=
false
let
isDelivery
=
false
if
(
rcs
[
0
]
==
"资质宝业务员"
)
{
opath
=
"root10/bizgroup01/g1members/"
+
userName
isSalesman
=
true
}
else
{
opath
=
"root10/dlivergroup/dgroupmembers/"
+
userName
isDelivery
=
true
}
//调用pmregister
let
reguser
=
{
company_id
:
company
.
id
,
userName
:
userName
,
nickName
:
nickName
,
roles
:
rolesfind
.
map
(
r
=>
r
.
id
),
opath
:
opath
,
openid
:
openid
,
isSalesman
:
isSalesman
,
isDelivery
:
isDelivery
,
isAllocated
:
true
,
skilltags
:
'icp,edi'
}
uf
=
await
userS
.
registerByTantent
(
reguser
)
}
let
rtnobj
=
await
userS
.
loginApp
(
appkey
,
userName
)
let
rtntmp
=
System
.
getResult
({
openurl
:
rtnobj
.
homePage
+
"?code="
+
rtnobj
.
code
})
let
rtn
=
JSON
.
stringify
(
rtntmp
)
res
.
end
(
rtn
)
}
catch
(
e
)
{
res
.
end
(
JSON
.
stringify
(
System
.
getResult
(
null
,
e
.
message
)))
}
})
app
.
post
(
"*"
,
async
function
(
req
,
res
,
next
)
{
app
.
post
(
"*"
,
async
function
(
req
,
res
,
next
)
{
console
.
log
(
"---- 进来了- ----"
)
console
.
log
(
"---- 进来了- ----"
)
try
{
try
{
...
...
im-center/app/config/routes/web.js
View file @
eba45937
var
url
=
require
(
"url"
);
var
url
=
require
(
"url"
);
var
system
=
require
(
"../../base/system"
);
var
system
=
require
(
"../../base/system"
);
var
metaCtl
=
system
.
getObject
(
"web.common.metaCtl"
);
module
.
exports
=
function
(
app
)
{
module
.
exports
=
function
(
app
)
{
app
.
get
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
app
.
get
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
classPath
=
req
.
params
[
"qname"
];
...
...
im-center/app/config/settings.js
View file @
eba45937
...
@@ -17,7 +17,7 @@ var settings = {
...
@@ -17,7 +17,7 @@ var settings = {
salt
:
"%iatpD1gcxz7iF#B"
,
salt
:
"%iatpD1gcxz7iF#B"
,
defaultpwd
:
"gsb2020"
,
defaultpwd
:
"gsb2020"
,
basepath
:
path
.
normalize
(
path
.
join
(
__dirname
,
'../..'
)),
basepath
:
path
.
normalize
(
path
.
join
(
__dirname
,
'../..'
)),
port
:
process
.
env
.
NODE_PORT
||
8
0
,
port
:
process
.
env
.
NODE_PORT
||
900
0
,
logindex
:
"center_manage"
,
logindex
:
"center_manage"
,
appname
:
"center_manage"
,
appname
:
"center_manage"
,
publickey
:
function
()
{
publickey
:
function
()
{
...
@@ -62,11 +62,11 @@ var settings = {
...
@@ -62,11 +62,11 @@ var settings = {
}
}
},
},
pushUrl
:
function
()
{
pushUrl
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
if
(
this
.
env
==
"dev"
)
{
return
"http://192.168.18.101:4018/api/queueAction/producer/springBoard"
;
return
"http://192.168.18.101:4018/api/queueAction/producer/springBoard"
;
}
else
{
}
else
{
return
"http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard"
;
return
"http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard"
;
}
}
},
},
pmappname
:
"center-app"
,
pmappname
:
"center-app"
,
pmappid
:
1
,
pmappid
:
1
,
...
...
im-center/app/config/socket.server2.js
View file @
eba45937
...
@@ -61,9 +61,11 @@ class SocketServer {
...
@@ -61,9 +61,11 @@ class SocketServer {
constructor
(
httpServer
)
{
constructor
(
httpServer
)
{
this
.
server
=
Server
(
httpServer
,
{
this
.
server
=
Server
(
httpServer
,
{
serveClient
:
false
,
serveClient
:
false
,
cookie
:
true
});
});
// this.server.adapter(redisAdapter({ pubClient: redisClient.client, subClient: redisClient.subclient }));
// this.server.adapter(redisAdapter({ pubClient: redisClient.client, subClient: redisClient.subclient }));
this
.
server
.
engine
.
generateId
=
(
req
)
=>
{
this
.
server
.
engine
.
generateId
=
(
req
)
=>
{
console
.
log
(
req
.
headers
)
return
"custom:id:"
+
this
.
getUUID
();
// custom id must be unique
return
"custom:id:"
+
this
.
getUUID
();
// custom id must be unique
}
}
this
.
init
()
this
.
init
()
...
@@ -87,7 +89,7 @@ class SocketServer {
...
@@ -87,7 +89,7 @@ class SocketServer {
});
});
//链接断开事件
//链接断开事件
client
.
on
(
'disconnect'
,
async
function
(
r
)
{
client
.
on
(
'disconnect'
,
async
function
(
r
)
{
console
.
log
(
"connection.........................................dismiss............."
);
console
.
log
(
"connection.........................................dismiss............."
,
client
.
id
,
r
);
});
});
});
});
}
}
...
...
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