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
d82701cc
Commit
d82701cc
authored
Jan 07, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
6c66c2eb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
426 additions
and
1117 deletions
+426
-1117
igirl-channel/app/base/api/api.base.js
+12
-35
igirl-channel/app/base/api/apidoc.base.js
+2
-3
igirl-channel/app/base/api/impl/action/opLog.js
+1
-1
igirl-channel/app/base/api/impl/auth/accessAuth.js
+68
-0
igirl-channel/app/base/controller/ctl.base.js
+0
-135
igirl-channel/app/base/controller/impl/auth/userCtl.js
+0
-84
igirl-channel/app/base/controller/impl/common/oplogCtl.js
+0
-81
igirl-channel/app/base/controller/impl/common/pushlogCtl.js
+0
-81
igirl-channel/app/base/db/cache.base.js
+11
-0
igirl-channel/app/base/db/cache/appTokenByHostsCache.js
+30
-0
igirl-channel/app/base/db/cache/appUserPinByChannelUserId.js
+30
-0
igirl-channel/app/base/db/task.base.js
+1
-1
igirl-channel/app/base/service/impl/common/oplogSve.js
+7
-3
igirl-channel/app/base/service/impl/common/pushlogSve.js
+0
-2
igirl-channel/app/base/service/impl/dborder/orderSve.js
+1
-1
igirl-channel/app/base/service/impl/trademark/utilscontentfilterSve.js
+0
-135
igirl-channel/app/base/service/impl/trademark/utilstmSve.js
+0
-0
igirl-channel/app/base/service/impl/trademark/utilstmTransactionSve.js
+0
-0
igirl-channel/app/base/service/impl/trademark/utilstmtasktradeSve.js
+0
-245
igirl-channel/app/base/service/impl/utilsSve/utilsuserSve.js
+29
-0
igirl-channel/app/base/system.js
+7
-0
igirl-channel/app/base/utils/businessManager/opPlatformUtils.js
+18
-0
igirl-channel/app/base/utils/businessManager/pushUtils.js
+1
-1
igirl-channel/app/base/utils/redisClient.js
+0
-1
igirl-channel/app/base/utils/restClient.js
+1
-0
igirl-channel/app/config/environment.js
+1
-1
igirl-channel/app/config/objsettings.js
+1
-1
igirl-channel/app/config/routes/api.js
+58
-8
igirl-channel/app/config/routes/vue-ui.js
+28
-28
igirl-channel/app/config/routes/web.js
+0
-59
igirl-channel/app/config/settings.js
+8
-1
igirl-channel/app/config/socket.server.js
+0
-189
igirl-channel/app/front/entry/public/apidoc/user/user.md
+111
-0
igirl-channel/main.js
+0
-21
No files found.
igirl-channel/app/base/api/api.base.js
View file @
d82701cc
...
...
@@ -6,10 +6,9 @@ const md5 = require("MD5");
class
APIBase
{
constructor
()
{
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
logCtl
=
system
.
getObject
(
"web.common.oplogCtl"
);
this
.
oplogSve
=
system
.
getObject
(
"service.common.oplogSve"
);
this
.
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
this
.
toolSve
=
system
.
getObject
(
"service.trademark.toolSve"
);
this
.
exTime
=
2
*
3600
;
//缓存过期时间,2
小时
this
.
exTime
=
6
*
3600
;
//缓存过期时间,6
小时
}
getUUID
()
{
var
uuid
=
uuidv4
();
...
...
@@ -151,7 +150,7 @@ class APIBase {
if
(
rtn
&&
!
rtn
.
requestId
)
{
rtn
.
requestId
=
requestid
;
}
this
.
oplogSve
.
createDb
({
this
.
logCtl
.
createDb
({
appid
:
req
.
app
.
id
,
appkey
:
req
.
app
.
uappKey
,
requestId
:
requestid
,
...
...
@@ -165,7 +164,7 @@ class APIBase {
return
rtn
;
}
catch
(
e
)
{
console
.
log
(
e
.
stack
,
"api调用出现异常,请联系管理员.........."
)
this
.
oplogSve
.
createDb
({
this
.
logCtl
.
createDb
({
appid
:
req
.
app
.
id
,
appkey
:
req
.
app
.
uappKey
,
requestId
:
requestid
,
...
...
@@ -195,42 +194,19 @@ class APIBase {
//-----------------------新的模式------------------开始
async
doexecMethod
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
var
requestid
=
req
.
headers
[
"request-id"
]
||
this
.
getUUID
();
if
(
!
req
.
headers
[
"request-id"
])
{
req
.
headers
[
"request-id"
]
=
requestid
;
}
req
.
requestId
=
this
.
getUUID
();
try
{
if
(
pobj
.
actionType
==
"createChannelUser"
)
{
if
(
!
pobj
.
isUser
)
{
system
.
getResult
(
null
,
"isUser is empty"
);
}
if
(
pobj
.
isUser
!=
"yes"
)
{
system
.
getResult
(
null
,
"isUser value must yes"
);
}
}
// //验证accesskey或验签
// var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
// if (isPassResult.status != 0) {
// isPassResult.requestId = "";
// return isPassResult;
// }
if
(
pobj
.
actionType
==
"createChannelUser"
)
{
var
encryptResult
=
await
this
.
toolSve
.
encryptStr
(
req
.
app
,
req
.
user
.
channelUserId
);
if
(
encryptResult
.
status
!=
0
)
{
system
.
getResult
(
null
,
"encrypt channelUserId is error"
);
}
req
.
user
.
encryptChannelUserId
=
encryptResult
.
data
;
return
system
.
getResultSuccess
(
req
.
user
);
}
//创建用户
req
.
requestId
=
requestid
;
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
if
(
rtn
&&
!
rtn
.
requestId
)
{
rtn
.
requestId
=
requestid
;
}
this
.
oplogSve
.
createDb
({
this
.
logCtl
.
createDb
({
appid
:
req
.
app
.
id
,
appkey
:
req
.
app
.
uappKey
,
requestId
:
req
uesti
d
,
requestId
:
req
.
requestI
d
,
op
:
req
.
classname
+
"/"
+
methodname
,
content
:
JSON
.
stringify
(
pobj
),
resultInfo
:
JSON
.
stringify
(
rtn
),
...
...
@@ -238,13 +214,14 @@ class APIBase {
agent
:
req
.
uagent
,
opTitle
:
"api服务提供方appKey:"
+
settings
.
appKey
,
});
rtn
.
requestId
=
req
.
requestId
;
return
rtn
;
}
catch
(
e
)
{
console
.
log
(
e
.
stack
,
"api调用出现异常,请联系管理员.........."
)
this
.
oplogSve
.
createDb
({
this
.
logCtl
.
createDb
({
appid
:
req
.
app
.
id
,
appkey
:
req
.
app
.
uappKey
,
requestId
:
req
uesti
d
,
requestId
:
req
.
requestI
d
,
op
:
req
.
classname
+
"/"
+
methodname
,
content
:
JSON
.
stringify
(
pobj
),
resultInfo
:
JSON
.
stringify
(
e
.
stack
),
...
...
@@ -255,7 +232,7 @@ class APIBase {
this
.
logCtl
.
error
({
appid
:
req
.
app
.
id
,
appkey
:
req
.
app
.
uappKey
,
requestId
:
req
uesti
d
,
requestId
:
req
.
requestI
d
,
op
:
pobj
.
classname
+
"/"
+
methodname
,
content
:
e
.
stack
,
clientIp
:
pobj
.
clientIp
,
...
...
@@ -263,7 +240,7 @@ class APIBase {
optitle
:
"api调用出现异常,请联系管理员"
,
});
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,error:"
+
e
.
stack
);
rtnerror
.
requestId
=
req
uesti
d
;
rtnerror
.
requestId
=
req
.
requestI
d
;
return
rtnerror
;
}
}
...
...
igirl-channel/app/base/api/apidoc.base.js
View file @
d82701cc
...
...
@@ -7,8 +7,7 @@ class APIBase extends DocBase {
constructor
()
{
super
();
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
logCtl
=
system
.
getObject
(
"web.common.oplogCtl"
);
this
.
oplogSve
=
system
.
getObject
(
"service.common.oplogSve"
);
this
.
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
}
getUUID
()
{
var
uuid
=
uuidv4
();
...
...
@@ -97,7 +96,7 @@ class APIBase extends DocBase {
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
rtn
.
requestid
=
requestid
;
this
.
oplogSve
.
createDb
({
this
.
logCtl
.
createDb
({
appid
:
req
.
headers
[
"app_id"
]
||
""
,
appkey
:
req
.
headers
[
"accesskey"
]
||
""
,
requestId
:
requestid
,
...
...
igirl-channel/app/base/api/impl/action/opLog.js
View file @
d82701cc
var
APIBase
=
require
(
"../../api.base"
);
var
system
=
require
(
"../../../system"
);
const
logCtl
=
system
.
getObject
(
"
web.common.oplogCtl
"
);
const
logCtl
=
system
.
getObject
(
"
service.common.oplogSve
"
);
class
opLog
extends
APIBase
{
constructor
()
{
...
...
igirl-channel/app/base/api/impl/auth/accessAuth.js
View file @
d82701cc
...
...
@@ -4,7 +4,73 @@ class AccessAuthAPI extends APIBase {
constructor
()
{
super
();
this
.
opPlatformUtils
=
system
.
getObject
(
"util.businessManager.opPlatformUtils"
);
this
.
utilsuserSve
=
system
.
getObject
(
"service.utilsSve.utilsuserSve"
);
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async
springBoard
(
pobj
,
qobj
,
req
)
{
if
(
!
pobj
.
actionProcess
)
{
return
system
.
getResult
(
null
,
"actionProcess参数不能为空"
);
}
if
(
!
pobj
.
actionType
)
{
return
system
.
getResult
(
null
,
"actionType参数不能为空"
);
}
var
result
=
null
;
switch
(
pobj
.
actionProcess
)
{
case
"jd"
:
//京东
result
=
await
this
.
opActionProcess
(
pobj
.
actionProcess
,
pobj
.
actionType
,
pobj
.
actionBody
,
pobj
,
req
);
break
;
case
"1688"
:
//1688
result
=
await
this
.
opActionProcess
(
pobj
.
actionProcess
,
pobj
.
actionType
,
pobj
.
actionBody
,
pobj
,
req
);
break
;
case
"gsbhome"
:
//gsb_homepage
result
=
await
this
.
opActionProcess
(
pobj
.
actionProcess
,
pobj
.
actionType
,
pobj
.
actionBody
,
pobj
,
req
);
break
;
default
:
result
=
system
.
getResult
(
null
,
"actionProcess参数错误"
);
break
;
}
return
result
;
}
async
opActionProcess
(
action_process
,
action_type
,
action_body
,
pobj
,
req
)
{
var
opResult
=
null
;
switch
(
action_type
)
{
// sy
case
"test"
:
//测试
opResult
=
system
.
getResultSuccess
(
null
,
"测试成功"
);
break
;
case
"loginUserByChannelUserId"
:
var
userpin
=
this
.
getUUID
();
opResult
=
await
this
.
utilsuserSve
.
loginUserByChannelUserId
(
action_body
,
action_process
,
userpin
,
req
);
if
(
opResult
.
status
==
0
)
{
return
system
.
getResultSuccess
({
userpin
:
userpin
})
}
break
;
default
:
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
break
;
}
return
opResult
;
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
*/
async
getAppTokenByHosts
(
pobj
,
qobj
,
req
)
{
var
token
=
this
.
getUUID
();
var
opResult
=
await
this
.
opPlatformUtils
.
getReqTokenByHosts
(
pobj
.
actionBody
.
app_hosts
,
token
);
if
(
opResult
.
status
!=
0
)
{
return
opResult
;
}
return
system
.
getResultSuccess
({
token
:
token
})
}
async
getToken
(
pobj
,
qobj
,
req
)
{
var
appkey
=
pobj
.
appkey
;
var
secret
=
pobj
.
secret
;
...
...
@@ -30,5 +96,6 @@ class AccessAuthAPI extends APIBase {
async
authByCode
(
pobj
,
qobj
,
req
)
{
return
await
this
.
opPlatformUtils
.
authByCode
(
qobj
.
code
);
}
}
module
.
exports
=
AccessAuthAPI
;
\ No newline at end of file
igirl-channel/app/base/controller/ctl.base.js
deleted
100644 → 0
View file @
6c66c2eb
const
system
=
require
(
"../system"
);
const
settings
=
require
(
"../../config/settings"
);
class
CtlBase
{
constructor
(
gname
,
sname
)
{
this
.
serviceName
=
sname
;
this
.
service
=
system
.
getObject
(
"service."
+
gname
+
"."
+
sname
);
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
md5
=
require
(
"MD5"
);
}
encryptPasswd
(
passwd
)
{
if
(
!
passwd
)
{
throw
new
Error
(
"请输入密码"
);
}
var
md5
=
this
.
md5
(
passwd
+
"_"
+
settings
.
salt
);
return
md5
.
toString
().
toLowerCase
();
}
notify
(
req
,
msg
)
{
if
(
req
.
session
)
{
req
.
session
.
bizmsg
=
msg
;
}
}
async
findOne
(
queryobj
,
qobj
)
{
var
rd
=
await
this
.
service
.
findOne
(
qobj
);
return
system
.
getResult
(
rd
,
null
);
}
async
findAndCountAll
(
queryobj
,
obj
,
req
)
{
obj
.
codepath
=
req
.
codepath
;
if
(
req
.
session
.
user
)
{
obj
.
uid
=
req
.
session
.
user
.
id
;
obj
.
appid
=
req
.
session
.
user
.
app_id
;
obj
.
onlyCode
=
req
.
session
.
user
.
unionId
;
obj
.
account_id
=
req
.
session
.
user
.
account_id
;
obj
.
ukstr
=
req
.
session
.
user
.
app_id
+
"¥"
+
req
.
session
.
user
.
id
+
"¥"
+
req
.
session
.
user
.
nickName
+
"¥"
+
req
.
session
.
user
.
headUrl
;
}
var
apps
=
await
this
.
service
.
findAndCountAll
(
obj
);
return
system
.
getResult
(
apps
,
null
);
}
async
refQuery
(
queryobj
,
qobj
)
{
var
rd
=
await
this
.
service
.
refQuery
(
qobj
);
return
system
.
getResult
(
rd
,
null
);
}
async
bulkDelete
(
queryobj
,
ids
)
{
var
rd
=
await
this
.
service
.
bulkDelete
(
ids
);
return
system
.
getResult
(
rd
,
null
);
}
async
delete
(
queryobj
,
qobj
)
{
var
rd
=
await
this
.
service
.
delete
(
qobj
);
return
system
.
getResult
(
rd
,
null
);
}
async
create
(
queryobj
,
qobj
,
req
)
{
if
(
req
&&
req
.
session
&&
req
.
session
.
app
)
{
qobj
.
app_id
=
req
.
session
.
app
.
id
;
qobj
.
onlyCode
=
req
.
session
.
user
.
unionId
;
if
(
req
.
codepath
)
{
qobj
.
codepath
=
req
.
codepath
;
}
}
var
rd
=
await
this
.
service
.
create
(
qobj
);
return
system
.
getResult
(
rd
,
null
);
}
async
createLog
(
queryobj
,
qobj
,
req
)
{
if
(
req
&&
req
.
session
&&
req
.
session
.
app
)
{
qobj
.
app_id
=
req
.
session
.
app
.
id
;
qobj
.
onlyCode
=
req
.
session
.
user
.
unionId
;
if
(
req
.
codepath
)
{
qobj
.
codepath
=
req
.
codepath
;
}
}
var
tmpParam
=
qobj
||
queryobj
;
var
rd
=
await
this
.
service
.
create
(
tmpParam
);
return
system
.
getResult
(
rd
,
null
);
}
async
update
(
queryobj
,
qobj
,
req
)
{
if
(
req
&&
req
.
session
&&
req
.
session
.
user
)
{
qobj
.
onlyCode
=
req
.
session
.
user
.
unionId
;
}
if
(
req
.
codepath
)
{
qobj
.
codepath
=
req
.
codepath
;
}
var
rd
=
await
this
.
service
.
update
(
qobj
);
return
system
.
getResult
(
rd
,
null
);
}
static
getServiceName
(
ClassObj
)
{
return
ClassObj
[
"name"
].
substring
(
0
,
ClassObj
[
"name"
].
lastIndexOf
(
"Ctl"
)).
toLowerCase
()
+
"Sve"
;
}
async
initNewInstance
(
queryobj
,
req
)
{
return
system
.
getResult
({},
null
);
}
async
findById
(
oid
)
{
var
rd
=
await
this
.
service
.
findById
(
oid
);
return
system
.
getResult
(
rd
,
null
);
}
async
timestampConvertDate
(
time
)
{
if
(
time
==
null
)
{
return
""
;
}
var
date
=
new
Date
(
Number
(
time
*
1000
));
var
y
=
1900
+
date
.
getYear
();
var
m
=
"0"
+
(
date
.
getMonth
()
+
1
);
var
d
=
"0"
+
date
.
getDate
();
return
y
+
"-"
+
m
.
substring
(
m
.
length
-
2
,
m
.
length
)
+
"-"
+
d
.
substring
(
d
.
length
-
2
,
d
.
length
);
}
async
universalTimeConvertLongDate
(
time
)
{
if
(
time
==
null
)
{
return
""
;
}
var
d
=
new
Date
(
time
);
return
d
.
getFullYear
()
+
'-'
+
(
d
.
getMonth
()
+
1
)
+
'-'
+
d
.
getDate
()
+
' '
+
d
.
getHours
()
+
':'
+
d
.
getMinutes
()
+
':'
+
d
.
getSeconds
();
}
async
universalTimeConvertShortDate
(
time
)
{
if
(
time
==
null
)
{
return
""
;
}
var
d
=
new
Date
(
time
);
return
d
.
getFullYear
()
+
'-'
+
(
d
.
getMonth
()
+
1
)
+
'-'
+
d
.
getDate
();
}
async
doexec
(
methodname
,
pobj
,
query
,
req
)
{
try
{
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
return
rtn
;
}
catch
(
e
)
{
console
.
log
(
e
.
stack
);
// this.logCtl.error({
// optitle: "Ctl调用出错",
// op: pobj.classname + "/" + methodname,
// content: e.stack,
// clientIp: pobj.clientIp
// });
return
system
.
getResultFail
(
-
200
,
"Ctl出现异常,请联系管理员"
);
}
}
}
module
.
exports
=
CtlBase
;
igirl-channel/app/base/controller/impl/auth/userCtl.js
deleted
100644 → 0
View file @
6c66c2eb
var
system
=
require
(
"../../../system"
)
const
http
=
require
(
"http"
)
const
querystring
=
require
(
'querystring'
);
var
settings
=
require
(
"../../../../config/settings"
);
const
CtlBase
=
require
(
"../../ctl.base"
);
var
cacheBaseComp
=
null
;
class
UserCtl
extends
CtlBase
{
constructor
()
{
super
(
"auth"
,
CtlBase
.
getServiceName
(
UserCtl
));
}
/**
* 开放平台回调处理
* @param {*} req
*/
async
authByCode
(
req
)
{
var
opencode
=
req
.
query
.
code
;
var
user
=
await
this
.
service
.
authByCode
(
opencode
);
if
(
user
)
{
req
.
session
.
user
=
user
;
}
else
{
req
.
session
.
user
=
null
;
}
//缓存opencode,方便本应用跳转到其它应用
// /auth?code=xxxxx,缓存没有意义,如果需要跳转到其它应用,需要调用
//平台开放的登录方法,返回 <待跳转的目标地址>/auth?code=xxxxx
//this.cacheManager["OpenCodeCache"].cacheOpenCode(user.id,opencode);
return
user
;
}
async
navSysSetting
(
pobj
,
qobj
,
req
)
{
//开始远程登录,返回code
var
jumpobj
=
await
this
.
service
.
navSysSetting
(
req
.
session
.
user
);
if
(
jumpobj
)
{
return
system
.
getResultSuccess
(
jumpobj
);
}
return
system
.
getResultFail
();
}
async
loginUser
(
qobj
,
pobj
,
req
)
{
return
super
.
findById
(
req
.
session
.
user
.
id
);
}
async
initNewInstance
(
queryobj
,
req
)
{
var
rtn
=
{};
rtn
.
roles
=
[];
if
(
rtn
)
{
return
system
.
getResultSuccess
(
rtn
);
}
return
system
.
getResultFail
();
}
async
checkLogin
(
gobj
,
qobj
,
req
)
{
//当前如果缓存中存在user,还是要检查当前user所在的域名,如果不和来访一致,则退出重新登录
if
(
req
.
session
.
user
)
{
var
x
=
null
;
if
(
req
.
session
.
user
.
Roles
)
{
x
=
req
.
session
.
user
.
Roles
.
map
(
r
=>
{
return
r
.
code
});
}
var
tmp
=
{
id
:
req
.
session
.
user
.
id
,
userName
:
req
.
session
.
user
.
userName
,
nickName
:
req
.
session
.
user
.
nickName
,
mobile
:
req
.
session
.
user
.
mobile
,
isAdmin
:
req
.
session
.
user
.
isAdmin
,
created_at
:
req
.
session
.
user
.
created_at
,
email
:
req
.
session
.
user
.
email
,
headUrl
:
req
.
session
.
user
.
headUrl
,
roles
:
x
?
x
.
join
(
","
)
:
""
}
return
system
.
getResult
(
tmp
,
"用户登录"
,
req
);
}
else
{
req
.
session
.
user
=
null
;
//req.session.destroy();
return
system
.
getResult
(
null
,
"用户未登录"
,
req
);
}
}
async
exit
(
pobj
,
qobj
,
req
)
{
req
.
session
.
user
=
null
;
req
.
session
.
destroy
();
return
system
.
getResultSuccess
({
"env"
:
settings
.
env
});
}
}
module
.
exports
=
UserCtl
;
igirl-channel/app/base/controller/impl/common/oplogCtl.js
deleted
100644 → 0
View file @
6c66c2eb
var
system
=
require
(
"../../../system"
)
var
settings
=
require
(
"../../../../config/settings"
);
const
CtlBase
=
require
(
"../../ctl.base"
);
const
uuidv4
=
require
(
'uuid/v4'
);
var
moment
=
require
(
"moment"
);
class
OplogCtl
extends
CtlBase
{
constructor
()
{
super
(
"common"
,
CtlBase
.
getServiceName
(
OplogCtl
));
//this.appS=system.getObject("service.appSve");
}
async
initNewInstance
(
qobj
)
{
var
u
=
uuidv4
();
var
aid
=
u
.
replace
(
/
\-
/g
,
""
);
var
rd
=
{
name
:
""
,
appid
:
aid
}
return
system
.
getResultSuccess
(
rd
,
null
);
}
async
debug
(
obj
)
{
obj
.
logLevel
=
"debug"
;
return
this
.
createLog
(
obj
);
}
async
info
(
obj
)
{
obj
.
logLevel
=
"info"
;
return
this
.
createLog
(
obj
);
}
async
warn
(
obj
)
{
obj
.
logLevel
=
"warn"
;
return
this
.
createLog
(
obj
);
}
async
error
(
obj
)
{
obj
.
logLevel
=
"error"
;
return
this
.
createLog
(
obj
);
}
async
fatal
(
obj
)
{
obj
.
logLevel
=
"fatal"
;
return
this
.
createLog
(
obj
);
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async
getBusUid_Ctl
(
prefix
)
{
prefix
=
(
prefix
||
""
);
if
(
prefix
)
{
prefix
=
prefix
.
toUpperCase
();
}
var
prefixlength
=
prefix
.
length
;
var
subLen
=
8
-
prefixlength
;
var
uidStr
=
""
;
if
(
subLen
>
0
)
{
uidStr
=
await
this
.
getUidInfo_Ctl
(
subLen
,
60
);
}
var
timStr
=
moment
().
format
(
"YYYYMMDDHHmm"
);
return
prefix
+
timStr
+
uidStr
;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async
getUidInfo_Ctl
(
len
,
radix
)
{
var
chars
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
.
split
(
''
);
//长度62,到yz长度为长36
var
uuid
=
[],
i
;
radix
=
radix
||
chars
.
length
;
if
(
len
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
uuid
[
i
]
=
chars
[
0
|
Math
.
random
()
*
radix
];
}
else
{
var
r
;
uuid
[
8
]
=
uuid
[
13
]
=
uuid
[
18
]
=
uuid
[
23
]
=
'-'
;
uuid
[
14
]
=
'4'
;
for
(
i
=
0
;
i
<
36
;
i
++
)
{
if
(
!
uuid
[
i
])
{
r
=
0
|
Math
.
random
()
*
16
;
uuid
[
i
]
=
chars
[(
i
==
19
)
?
(
r
&
0x3
)
|
0x8
:
r
];
}
}
}
return
uuid
.
join
(
''
);
}
}
module
.
exports
=
OplogCtl
;
igirl-channel/app/base/controller/impl/common/pushlogCtl.js
deleted
100644 → 0
View file @
6c66c2eb
var
system
=
require
(
"../../../system"
)
var
settings
=
require
(
"../../../../config/settings"
);
const
CtlBase
=
require
(
"../../ctl.base"
);
const
uuidv4
=
require
(
'uuid/v4'
);
var
moment
=
require
(
"moment"
);
class
PushlogCtl
extends
CtlBase
{
constructor
()
{
super
(
"common"
,
CtlBase
.
getServiceName
(
PushlogCtl
));
//this.appS=system.getObject("service.appSve");
}
async
initNewInstance
(
qobj
)
{
var
u
=
uuidv4
();
var
aid
=
u
.
replace
(
/
\-
/g
,
""
);
var
rd
=
{
name
:
""
,
appid
:
aid
}
return
system
.
getResultSuccess
(
rd
,
null
);
}
async
debug
(
obj
)
{
obj
.
logLevel
=
"debug"
;
return
this
.
create
(
obj
);
}
async
info
(
obj
)
{
obj
.
logLevel
=
"info"
;
return
this
.
create
(
obj
);
}
async
warn
(
obj
)
{
obj
.
logLevel
=
"warn"
;
return
this
.
create
(
obj
);
}
async
error
(
obj
)
{
obj
.
logLevel
=
"error"
;
return
this
.
create
(
obj
);
}
async
fatal
(
obj
)
{
obj
.
logLevel
=
"fatal"
;
return
this
.
create
(
obj
);
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async
getBusUid_Ctl
(
prefix
)
{
prefix
=
(
prefix
||
""
);
if
(
prefix
)
{
prefix
=
prefix
.
toUpperCase
();
}
var
prefixlength
=
prefix
.
length
;
var
subLen
=
8
-
prefixlength
;
var
uidStr
=
""
;
if
(
subLen
>
0
)
{
uidStr
=
await
this
.
getUidInfo_Ctl
(
subLen
,
60
);
}
var
timStr
=
moment
().
format
(
"YYYYMMDDHHmm"
);
return
prefix
+
timStr
+
uidStr
;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async
getUidInfo_Ctl
(
len
,
radix
)
{
var
chars
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
.
split
(
''
);
//长度62,到yz长度为长36
var
uuid
=
[],
i
;
radix
=
radix
||
chars
.
length
;
if
(
len
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
uuid
[
i
]
=
chars
[
0
|
Math
.
random
()
*
radix
];
}
else
{
var
r
;
uuid
[
8
]
=
uuid
[
13
]
=
uuid
[
18
]
=
uuid
[
23
]
=
'-'
;
uuid
[
14
]
=
'4'
;
for
(
i
=
0
;
i
<
36
;
i
++
)
{
if
(
!
uuid
[
i
])
{
r
=
0
|
Math
.
random
()
*
16
;
uuid
[
i
]
=
chars
[(
i
==
19
)
?
(
r
&
0x3
)
|
0x8
:
r
];
}
}
}
return
uuid
.
join
(
''
);
}
}
module
.
exports
=
PushlogCtl
;
igirl-channel/app/base/db/cache.base.js
View file @
d82701cc
...
...
@@ -34,6 +34,17 @@ class CacheBase {
this
.
redisClient
.
sadd
(
this
.
cacheCacheKeyPrefix
,
[
cachekey
+
"|"
+
this
.
desc
]);
return
objval
;
}
else
{
this
.
redisClient
.
set
(
cachekey
,
cacheValue
,
ex
);
return
JSON
.
parse
(
cacheValue
);
}
}
async
getCache
(
inputkey
,
ex
)
{
const
cachekey
=
this
.
prefix
+
inputkey
;
var
cacheValue
=
await
this
.
redisClient
.
get
(
cachekey
);
if
(
!
cacheValue
||
cacheValue
==
"undefined"
||
cacheValue
==
"null"
)
{
return
system
.
getResultFail
(
system
.
cacheInvalidation
,
"cache is invalidation"
)
}
else
{
this
.
redisClient
.
set
(
cachekey
,
cacheValue
,
ex
);
return
JSON
.
parse
(
cacheValue
);
}
}
...
...
igirl-channel/app/base/db/cache/appTokenByHostsCache.js
0 → 100644
View file @
d82701cc
const
CacheBase
=
require
(
"../cache.base"
);
const
system
=
require
(
"../../system"
);
const
settings
=
require
(
"../../../config/settings"
);
class
AppTokenByHostsCache
extends
CacheBase
{
constructor
()
{
super
();
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
}
desc
()
{
return
"应用中缓存访问token"
;
}
prefix
()
{
return
settings
.
cacheprefix
+
"_accesskey:"
;
}
async
buildCacheVal
(
cachekey
,
inputkey
,
val
,
ex
,
...
items
)
{
var
app_hosts
=
val
;
if
(
!
app_hosts
)
{
return
system
.
getResult
(
null
,
"app_hosts can not be empty"
);
}
var
acckapp
=
await
this
.
restClient
.
execPost
({
app_hosts
:
app_hosts
},
settings
.
centerAppUrl
()
+
"auth/accessAuth/getTokenByHosts"
);
var
result
=
acckapp
.
stdout
;
console
.
log
(
acckapp
.
stdout
,
"AppTokenByHostsCache............. acckapp.stdout.........."
)
if
(
result
)
{
var
tmp
=
JSON
.
parse
(
result
);
return
tmp
;
}
return
system
.
getResult
(
null
,
"data is empty"
);
}
}
module
.
exports
=
AppTokenByHostsCache
;
igirl-channel/app/base/db/cache/appUserPinByChannelUserId.js
0 → 100644
View file @
d82701cc
const
CacheBase
=
require
(
"../cache.base"
);
const
system
=
require
(
"../../system"
);
const
settings
=
require
(
"../../../config/settings"
);
class
AppUserPinByChannelUserId
extends
CacheBase
{
constructor
()
{
super
();
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
}
desc
()
{
return
"应用中缓存访问token"
;
}
prefix
()
{
return
settings
.
cacheprefix
+
"_userPin:"
;
}
async
buildCacheVal
(
cachekey
,
inputkey
,
val
,
ex
,
...
items
)
{
var
app_hosts
=
val
;
if
(
!
app_hosts
)
{
return
system
.
getResult
(
null
,
"app_hosts can not be empty"
);
}
var
acckapp
=
await
this
.
restClient
.
execPost
(
val
,
settings
.
centerAppUrl
()
+
"auth/accessAuth/loginUserByChannelUserId"
);
var
result
=
acckapp
.
stdout
;
console
.
log
(
acckapp
.
stdout
,
"AppTokenByHostsCache............. acckapp.stdout.........."
)
if
(
result
)
{
var
tmp
=
JSON
.
parse
(
result
);
return
tmp
;
}
return
system
.
getResult
(
null
,
"data is empty"
);
}
}
module
.
exports
=
AppUserPinByChannelUserId
;
igirl-channel/app/base/db/task.base.js
View file @
d82701cc
const
system
=
require
(
"../system"
)
const
logCtl
=
system
.
getObject
(
"
web.common.oplogCtl
"
);
const
logCtl
=
system
.
getObject
(
"
service.common.oplogSve
"
);
class
TaskBase
{
constructor
(
className
){
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
...
...
igirl-channel/app/base/service/impl/common/oplogSve.js
View file @
d82701cc
...
...
@@ -8,10 +8,15 @@ class OplogService extends ServiceBase {
this
.
opLogUrl
=
settings
.
apiconfig
.
opLogUrl
();
this
.
opLogEsIsAdd
=
settings
.
apiconfig
.
opLogEsIsAdd
();
}
async
error
(
qobj
)
{
this
.
create
(
qobj
);
}
async
info
(
qobj
)
{
this
.
create
(
qobj
);
}
async
create
(
qobj
)
{
if
(
!
qobj
||
!
qobj
.
op
||
qobj
.
op
.
indexOf
(
"metaCtl/getUiConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"userCtl/checkLogin"
)
>=
0
||
qobj
.
op
.
indexOf
(
"oplogCtl"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getDicConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRouteConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRsConfig"
)
>=
0
)
{
...
...
@@ -49,7 +54,6 @@ class OplogService extends ServiceBase {
async
createDb
(
qobj
)
{
if
(
!
qobj
||
!
qobj
.
op
||
qobj
.
op
.
indexOf
(
"metaCtl/getUiConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"userCtl/checkLogin"
)
>=
0
||
qobj
.
op
.
indexOf
(
"oplogCtl"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getDicConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRouteConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRsConfig"
)
>=
0
)
{
...
...
@@ -59,7 +63,7 @@ class OplogService extends ServiceBase {
qobj
.
optitle
=
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
":"
+
qobj
.
optitle
;
//解决日志大于4000写入的问题
if
(
qobj
.
content
.
length
>
4980
)
{
qobj
.
content
=
qobj
.
content
.
substring
(
0
,
4980
);
qobj
.
content
=
qobj
.
content
.
substring
(
0
,
4980
);
}
this
.
dao
.
create
(
qobj
);
}
catch
(
e
)
{
...
...
igirl-channel/app/base/service/impl/common/pushlogSve.js
View file @
d82701cc
...
...
@@ -11,7 +11,6 @@ class PushlogService extends ServiceBase {
async
create
(
qobj
)
{
if
(
!
qobj
||
!
qobj
.
op
||
qobj
.
op
.
indexOf
(
"metaCtl/getUiConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"userCtl/checkLogin"
)
>=
0
||
qobj
.
op
.
indexOf
(
"oplogCtl"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getDicConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRouteConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRsConfig"
)
>=
0
)
{
...
...
@@ -49,7 +48,6 @@ class PushlogService extends ServiceBase {
async
createDb
(
qobj
)
{
if
(
!
qobj
||
!
qobj
.
op
||
qobj
.
op
.
indexOf
(
"metaCtl/getUiConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"userCtl/checkLogin"
)
>=
0
||
qobj
.
op
.
indexOf
(
"oplogCtl"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getDicConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRouteConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRsConfig"
)
>=
0
)
{
...
...
igirl-channel/app/base/service/impl/dborder/orderSve.js
View file @
d82701cc
...
...
@@ -5,7 +5,7 @@ const settings = require("../../../../config/settings");
class
OrderService
extends
ServiceBase
{
constructor
()
{
super
(
"dborder"
,
ServiceBase
.
getDaoName
(
OrderService
));
this
.
logCtl
=
system
.
getObject
(
"
web.common.oplogCtl
"
);
this
.
logCtl
=
system
.
getObject
(
"
service.common.oplogSve
"
);
this
.
orderflowDao
=
system
.
getObject
(
"db.dborder.orderflowDao"
);
this
.
appproductDao
=
system
.
getObject
(
"db.dbapp.appproductDao"
);
this
.
ordertmproductDao
=
system
.
getObject
(
"db.dborder.ordertmproductDao"
);
...
...
igirl-channel/app/base/service/impl/trademark/utilscontentfilterSve.js
deleted
100644 → 0
View file @
6c66c2eb
var
System
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
const
logCtl
=
System
.
getObject
(
"web.common.oplogCtl"
);
//内容过滤查询
class
UtilsTmService
{
constructor
(){
this
.
reqEsAddr
=
settings
.
reqEsAddr
();
}
async
getSynonymsList
(
obj
,
opName
){
var
result
=
{
code
:
1
,
message
:
"success"
,
data
:
[]
};
var
name
=
obj
.
name
==
null
||
obj
.
name
==
""
||
obj
.
name
==
"undefined"
?
""
:
obj
.
name
;
if
(
name
==
""
){
result
.
code
=-
101
;
result
.
message
=
"name参数有误"
;
return
result
;
}
var
reqUrl
=
this
.
reqEsAddr
+
"bigdata_synonyms_filter/_search"
;
var
params
=
{
"query"
:
{
"term"
:
{
"name"
:
name
}
},
"from"
:
0
,
"size"
:
200
,
"_source"
:
[
"name"
]
};
var
tResult
=
await
this
.
returnResult
(
params
,
reqUrl
,
opName
,
"getSynonymsList"
);
if
(
tResult
.
status
!=
0
){
result
.
code
=-
200
;
result
.
message
=
"查询错误"
;
return
result
;
}
var
tArry
=
[
name
];
if
(
tResult
.
data
.
length
>
0
){
for
(
var
i
=
0
;
i
<
tResult
.
data
.
length
;
i
++
)
{
var
tmp
=
tResult
.
data
[
i
];
if
(
tmp
!=
null
&&
tmp
!=
""
&&
tmp
.
name
!=
null
&&
tmp
.
name
!=
""
){
for
(
var
j
=
0
;
j
<
tmp
.
name
.
length
;
j
++
)
{
var
tmpName
=
tmp
.
name
[
j
];
var
indexLength
=
tArry
.
findIndex
(
v
=>
v
===
tmpName
);
if
(
indexLength
<
0
){
tArry
.
push
(
tmpName
);
}
}
}
}
}
result
.
data
=
tArry
;
return
result
;
}
async
getSimilarList
(
obj
,
opName
){
var
result
=
{
code
:
1
,
message
:
"success"
,
data
:
[]
};
var
name
=
obj
.
name
==
null
||
obj
.
name
==
""
||
obj
.
name
==
"undefined"
?
""
:
obj
.
name
;
if
(
name
==
""
){
result
.
code
=-
101
;
result
.
message
=
"name参数有误"
;
return
result
;
}
var
reqUrl
=
this
.
reqEsAddr
+
"bigdata_similar_filter/_search"
;
var
params
=
{
"query"
:
{
"term"
:
{
"name"
:
name
}
},
"from"
:
0
,
"size"
:
200
,
"_source"
:
[
"name"
]
};
var
tResult
=
await
this
.
returnResult
(
params
,
reqUrl
,
opName
,
"getSimilarList"
);
if
(
tResult
.
status
!=
0
){
result
.
code
=-
200
;
result
.
message
=
"查询错误"
;
return
result
;
}
var
tArry
=
[
name
];
if
(
tResult
.
data
.
length
>
0
){
for
(
var
i
=
0
;
i
<
tResult
.
data
.
length
;
i
++
)
{
var
tmp
=
tResult
.
data
[
i
];
if
(
tmp
!=
null
&&
tmp
!=
""
&&
tmp
.
name
!=
null
&&
tmp
.
name
!=
""
){
for
(
var
j
=
0
;
j
<
tmp
.
name
.
length
;
j
++
)
{
var
tmpName
=
tmp
.
name
[
j
];
var
indexLength
=
tArry
.
findIndex
(
v
=>
v
===
tmpName
);
if
(
indexLength
<
0
){
tArry
.
push
(
tmpName
);
}
}
}
}
}
result
.
data
=
tArry
;
return
result
;
}
async
returnResult
(
params
,
reqUrl
,
opClassName
,
opMethod
){
var
rc
=
System
.
getObject
(
"util.execClient"
);
var
rtn
=
null
;
try
{
rtn
=
await
rc
.
execPost
(
params
,
reqUrl
);
var
j
=
JSON
.
parse
(
rtn
.
stdout
);
if
(
j
.
status
!=
undefined
){
//执行查询有错
//日志记录
logCtl
.
error
({
optitle
:
"ES内容过滤查询opClassName="
+
opClassName
+
",opMethod="
+
opMethod
+
"ES执行异常error"
,
op
:
"base/service/impl/tmutilsSve.js"
,
content
:
rtn
.
stdout
,
clientIp
:
""
});
return
System
.
getResult2
(
null
,
null
,
null
,
"查询出错"
);
}
return
System
.
getResult3
(
j
.
hits
,
null
);
}
catch
(
e
){
//日志记录
logCtl
.
error
({
optitle
:
"ES内容过滤查询opClassName="
+
opClassName
+
",opMethod="
+
opMethod
+
"操作异常异常error"
,
op
:
"base/service/impl/tmutilsSve.js"
,
content
:
e
.
stack
,
clientIp
:
""
});
return
System
.
getResult2
(
null
,
null
,
null
,
"查询异常"
);
}
}
}
module
.
exports
=
UtilsTmService
;
igirl-channel/app/base/service/impl/trademark/utilstmSve.js
deleted
100644 → 0
View file @
6c66c2eb
This diff is collapsed.
Click to expand it.
igirl-channel/app/base/service/impl/trademark/utilstmTransactionSve.js
deleted
100644 → 0
View file @
6c66c2eb
This diff is collapsed.
Click to expand it.
igirl-channel/app/base/service/impl/trademark/utilstmtasktradeSve.js
deleted
100644 → 0
View file @
6c66c2eb
var
System
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
const
logCtl
=
System
.
getObject
(
"web.common.oplogCtl"
);
//商标查询操作
class
UtilsTmTaskTradeService
{
constructor
()
{
// this.tmFlowUrl = settings.apiconfig.tmFlowUrl();
// this.tmNclUrl = settings.apiconfig.tmNclUrl();
// this.nclUrl = settings.apiconfig.nclUrl();
this
.
tmSearchUrl
=
settings
.
apiconfig
.
tmSearchUrl
();
this
.
opTmTransactionUrl
=
settings
.
apiconfig
.
opTmTransactionUrl
();
this
.
tmTransactionUrl
=
settings
.
apiconfig
.
tmTransactionUrl
();
this
.
trademarktransactionDao
=
System
.
getObject
(
"db.trademarktransactionDao"
);
this
.
orderSve
=
System
.
getObject
(
"service.orderSve"
);
}
async
getAuditList
(
pageIndex
,
pageSize
)
{
//publish_status===:tm_transaction_publish_status": { "audit": "审核中", "fail": "审核不通过", "success": "审核通过", "uppershelf": "上架", "lowershelf": "下架" }
var
whereObj
=
{
publish_status
:
"audit"
};
return
this
.
trademarktransactionDao
.
getPageList
(
pageIndex
,
pageSize
,
whereObj
,
[[
"created_at"
,
'desc'
]],
null
);
}
buildDate
(
date
)
{
var
date
=
new
Date
(
date
);
var
time
=
Date
.
parse
(
date
);
time
=
time
/
1000
;
return
time
;
}
convertDate
(
time
)
{
//es时间戳转换时间
if
(
time
==
null
)
{
return
""
;
}
var
date
=
new
Date
(
Number
(
time
*
1000
));
var
y
=
1900
+
date
.
getYear
();
var
m
=
"0"
+
(
date
.
getMonth
()
+
1
);
var
d
=
"0"
+
date
.
getDate
();
return
y
+
"-"
+
m
.
substring
(
m
.
length
-
2
,
m
.
length
)
+
"-"
+
d
.
substring
(
d
.
length
-
2
,
d
.
length
);
}
async
opAuditData
()
{
var
self
=
this
;
var
rc
=
System
.
getObject
(
"util.execClient"
);
var
list
=
await
self
.
getAuditList
(
1
,
1000
);
if
(
!
list
||
list
.
rows
.
length
==
0
)
{
return
"no"
;
}
var
codeList
=
[];
for
(
let
i
=
0
;
i
<
list
.
rows
.
length
;
i
++
)
{
const
codeItem
=
list
.
rows
[
i
];
if
(
codeItem
)
{
codeList
.
push
(
codeItem
.
code
);
}
if
(
codeList
.
length
==
200
)
{
await
self
.
opEsQuery
(
list
.
rows
,
codeList
,
self
,
rc
);
codeList
=
[];
}
}
if
(
codeList
.
length
>
0
)
{
await
self
.
opEsQuery
(
list
.
rows
,
codeList
,
self
,
rc
);
}
}
//订单付款提醒任务(针对未付款订单)
async
orderPaymentReminder
(){
return
this
.
orderSve
.
orderPaymentReminder
();
}
async
opEsQuery
(
auditData
,
codeList
,
self
,
rc
)
{
var
params
=
{
"query"
:
{
"terms"
:
{
"tm_regist_num"
:
codeList
}
},
"from"
:
0
,
"size"
:
500
,
"_source"
:
[
"pic_url"
,
"tm_name"
,
"tm_name_en"
,
"tm_regist_num"
,
"ncl_one_codes"
,
"applicant_cn"
,
"original_regist_notice_day"
,
"tm_end_day"
,
"ncl_two_codes"
,
"cn_count"
,
"en_name_count"
]
};
var
esData
=
await
self
.
returnResult
(
params
,
this
.
tmSearchUrl
,
"UtilsTmTaskTradeService"
,
"opEsQuery"
);
if
(
esData
.
status
==
0
&&
esData
.
data
.
length
>
0
)
{
await
self
.
addEsData
(
auditData
,
esData
.
data
,
self
,
rc
);
}
}
async
addEsData
(
auditData
,
esTmList
,
self
,
rc
)
{
var
addDbList
=
[];
var
rtn
=
null
;
for
(
let
b
=
0
;
b
<
esTmList
.
length
;
b
++
)
{
const
esItem
=
esTmList
[
b
];
var
auditList
=
auditData
.
filter
(
a
=>
a
.
code
==
esItem
.
tm_regist_num
);
if
(
!
auditList
||
auditList
.
length
==
0
)
{
continue
;
}
var
params
=
{
created_at
:
self
.
buildDate
(
auditList
[
0
].
created_at
),
tm_regist_num
:
esItem
.
tm_regist_num
,
en_name
:
esItem
.
tm_name_en
,
en_name_count
:
esItem
.
en_name_count
,
en_name_standard
:
esItem
.
tm_name_en
,
tm_name
:
esItem
.
tm_name
,
tm_name_standard
:
esItem
.
tm_name
,
tm_name_count
:
Number
(
esItem
.
cn_count
||
"0"
)
+
Number
(
esItem
.
en_name_count
||
"0"
),
cn_count
:
esItem
.
cn_count
,
pic_url
:
esItem
.
pic_url
,
pic_url_user
:
auditList
[
0
].
pic_url
||
""
,
is_transaction
:
1
,
//--------------------db----是否可以交易
ncl_one_codes
:
esItem
.
ncl_one_codes
,
platform_quoted_price
:
auditList
[
0
].
platform_quoted_price
,
tm_heat
:
0
,
tm_introduction
:
auditList
[
0
].
tm_introduction
,
};
try
{
await
self
.
putDbData
(
esItem
,
auditData
,
addDbList
,
self
);
var
esParams
=
{
"query"
:
{
"bool"
:
{
"must"
:
[
{
"term"
:
{
"ncl_one_codes"
:
esItem
.
ncl_one_codes
}
},
{
"term"
:
{
"tm_regist_num"
:
esItem
.
tm_regist_num
}
}
]
}
},
"from"
:
0
,
"size"
:
1
,
"_source"
:
[
"tm_name"
]
};
var
queryEs
=
await
self
.
returnResult
(
esParams
,
this
.
tmTransactionUrl
,
"UtilsTmTaskTradeService"
,
"addEsData"
);
if
(
queryEs
.
status
==
0
&&
queryEs
.
data
&&
queryEs
.
data
.
length
==
0
)
{
await
rc
.
execPost
(
params
,
self
.
opTmTransactionUrl
);
}
}
catch
(
e
)
{
logCtl
.
error
({
optitle
:
"往ES中插入数据或更新商标交易中的商标异常error"
,
op
:
"/igirl-web/app/base/service/impl/utilstmtasktradeSve.js/addEsData.js"
,
content
:
e
.
stack
,
clientIp
:
""
});
}
}
if
(
addDbList
.
length
>
0
)
{
await
this
.
trademarktransactionDao
.
model
.
bulkCreate
(
addDbList
);
}
}
async
putDbData
(
esItem
,
auditData
,
addDbList
,
self
)
{
//更新数据库
var
putIndex
=
auditData
.
findIndex
(
f
=>
f
.
code
===
esItem
.
tm_regist_num
);
if
(
putIndex
<
0
)
{
return
;
}
var
filterTmList
=
auditData
.
filter
(
f
=>
f
.
code
===
esItem
.
tm_regist_num
&&
f
.
ncl_one_code
===
esItem
.
ncl_one_codes
);
if
(
filterTmList
&&
filterTmList
.
length
>
0
)
{
var
addParams
=
{
code
:
esItem
.
tm_regist_num
,
ncl_one_code
:
esItem
.
ncl_one_codes
,
name
:
esItem
.
tm_name
,
excelName
:
esItem
.
tm_name
,
tm_applier
:
esItem
.
applicant_cn
,
tm_group
:
JSON
.
stringify
(
esItem
.
ncl_two_codes
),
pic_url
:
auditData
[
putIndex
].
pic_url
||
esItem
.
pic_url
,
business_quoted_price
:
auditData
[
putIndex
].
business_quoted_price
,
platform_quoted_price
:
auditData
[
putIndex
].
platform_quoted_price
,
tm_structure_name
:
auditData
[
putIndex
].
tm_structure_name
,
tm_introduction
:
auditData
[
putIndex
].
tm_introduction
,
publish_status
:
"uppershelf"
,
createcompany_id
:
auditList
[
0
].
createcompany_id
,
createuser_id
:
auditList
[
0
].
createuser_id
,
notes
:
"add_new"
,
};
if
(
esItem
.
original_regist_notice_day
&&
esItem
.
original_regist_notice_day
!=
null
)
{
addParams
.
tm_start_day
=
self
.
convertDate
(
esItem
.
original_regist_notice_day
);
}
if
(
esItem
.
tm_end_day
&&
esItem
.
tm_end_day
!=
null
)
{
addParams
.
tm_end_day
=
self
.
convertDate
(
esItem
.
tm_end_day
);
}
addDbList
.
push
(
addParams
);
return
;
}
//大类是有值,则新增数据到db
auditData
[
putIndex
].
ncl_one_code
=
esItem
.
ncl_one_codes
;
var
setField
=
{
ncl_one_code
:
esItem
.
ncl_one_codes
,
name
:
esItem
.
tm_name
,
tm_applier
:
esItem
.
applicant_cn
,
tm_group
:
JSON
.
stringify
(
esItem
.
ncl_two_codes
),
pic_url
:
auditData
[
putIndex
].
pic_url
||
esItem
.
pic_url
,
publish_status
:
"uppershelf"
};
if
(
esItem
.
original_regist_notice_day
&&
esItem
.
original_regist_notice_day
!=
null
)
{
setField
.
tm_start_day
=
self
.
convertDate
(
esItem
.
original_regist_notice_day
);
}
if
(
esItem
.
tm_end_day
&&
esItem
.
tm_end_day
!=
null
)
{
setField
.
tm_end_day
=
self
.
convertDate
(
esItem
.
tm_end_day
);
}
var
sqlWhere
=
{
where
:
{
id
:
auditData
[
putIndex
].
id
}
};
var
tmpR
=
await
self
.
trademarktransactionDao
.
updateByWhere
(
setField
,
sqlWhere
);
return
;
}
async
returnResult
(
params
,
reqUrl
,
opClassName
,
opMethod
)
{
var
rc
=
System
.
getObject
(
"util.execClient"
);
var
rtn
=
null
;
try
{
rtn
=
await
rc
.
execPost
(
params
,
reqUrl
);
var
j
=
JSON
.
parse
(
rtn
.
stdout
);
if
(
j
.
status
!=
undefined
)
{
//执行查询有错
//日志记录
logCtl
.
error
({
optitle
:
"商标交易ES查询商标信息opClassName="
+
opClassName
+
",opMethod="
+
opMethod
+
"ES执行异常error"
,
op
:
"base/service/impl/tmutilsSve.js"
,
content
:
rtn
.
stdout
,
clientIp
:
""
});
return
System
.
getResult2
(
null
,
null
,
null
,
"查询出错"
);
}
return
System
.
getResult3
(
j
.
hits
,
null
);
}
catch
(
e
)
{
//日志记录
logCtl
.
error
({
optitle
:
"ES查询商标信息opClassName="
+
opClassName
+
",opMethod="
+
opMethod
+
"操作异常异常error"
,
op
:
"base/service/impl/tmutilsSve.js"
,
content
:
e
.
stack
,
clientIp
:
""
});
return
System
.
getResult2
(
null
,
null
,
null
,
"查询异常"
);
}
}
}
module
.
exports
=
UtilsTmTaskTradeService
;
igirl-channel/app/base/service/impl/utilsSve/utilsuserSve.js
0 → 100644
View file @
d82701cc
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
const
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
//商标查询操作
class
UtilsUserSve
{
constructor
()
{
this
.
opPlatformUtils
=
system
.
getObject
(
"util.businessManager.opPlatformUtils"
);
}
async
loginUserByChannelUserId
(
action_body
,
action_process
,
userpin
,
req
)
{
action_body
.
appInfo
=
req
.
appInfo
;
var
opResult
=
null
;
switch
(
action_process
)
{
case
"gsbhome"
:
opResult
=
await
this
.
getDefaultUserInfo
(
action_body
,
userpin
);
break
;
default
:
opResult
=
system
.
getResult
(
null
,
"action_process参数错误"
);
break
;
}
return
opResult
;
}
async
getDefaultUserInfo
(
action_body
,
userpin
)
{
var
userinfo
=
await
this
.
opPlatformUtils
.
getReqUserPinByChannelUserId
(
action_body
,
userpin
);
return
userinfo
;
}
}
module
.
exports
=
UtilsUserSve
;
igirl-channel/app/base/system.js
View file @
d82701cc
...
...
@@ -291,7 +291,14 @@ Date.prototype.Format = function (fmt) { //author: meizz
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
RegExp
.
$1
.
length
==
1
)
?
(
o
[
k
])
:
((
"00"
+
o
[
k
]).
substr
((
""
+
o
[
k
]).
length
)));
return
fmt
;
}
System
.
exTime
=
4
*
3600
;
//缓存过期时间,4小时
System
.
objTable
=
{};
//缓存失效
System
.
cacheInvalidation
=
-
88
;
System
.
noLogin
=
-
99
;
//访问token失效,请重新获取
System
.
tokenFail
=
1000
;
//appKey授权有误
...
...
igirl-channel/app/base/utils/businessManager/opPlatformUtils.js
View file @
d82701cc
...
...
@@ -151,6 +151,24 @@ class OpPlatformUtils {
}
return
system
.
getResultSuccess
(
restResult
.
data
);
}
//-----新的方式
async
getReqTokenByHosts
(
appHosts
,
tokenValue
)
{
if
(
!
appHosts
)
{
return
system
.
getResult
(
null
,
"appHosts can not be empty"
);
}
var
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
var
result
=
await
cacheManager
[
"AppTokenByHostsCache"
].
cache
(
tokenValue
,
appHosts
,
system
.
exTime
);
return
result
;
}
async
getReqUserPinByChannelUserId
(
actionBody
,
userPinValue
)
{
if
(
!
actionBody
.
channelUserId
)
{
return
system
.
getResult
(
null
,
"actionBody.channelUserId can not be empty"
);
}
var
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
var
result
=
await
cacheManager
[
"AppUserPinByChannelUserId"
].
cache
(
userPinValue
,
actionBody
,
system
.
exTime
);
return
result
;
}
}
module
.
exports
=
OpPlatformUtils
;
igirl-channel/app/base/utils/businessManager/pushUtils.js
View file @
d82701cc
...
...
@@ -4,7 +4,7 @@ const md5 = require("MD5");
class
PushUtils
{
constructor
()
{
this
.
logCtl
=
system
.
getObject
(
"
web.common.oplogCtl
"
);
this
.
logCtl
=
system
.
getObject
(
"
service.common.oplogSve
"
);
this
.
merchantpushlogSve
=
system
.
getObject
(
"service.merchant.merchantpushlogSve"
);
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
merchantpushSve
=
system
.
getObject
(
"service.merchant.merchantpushSve"
);
...
...
igirl-channel/app/base/utils/redisClient.js
View file @
d82701cc
...
...
@@ -3,7 +3,6 @@ const redis = require("redis");
const
settings
=
require
(
"../../config/settings"
);
const
bluebird
=
require
(
"bluebird"
);
bluebird
.
promisifyAll
(
redis
);
// const logCtl=system.getObject("web.oplogCtl");
class
RedisClient
{
constructor
()
{
const
redisConfig
=
settings
.
redis
();
...
...
igirl-channel/app/base/utils/restClient.js
View file @
d82701cc
...
...
@@ -88,6 +88,7 @@ class RestClient {
}
async
execPost
(
subData
,
url
)
{
let
cmd
=
this
.
FetchPostCmd
(
subData
,
url
);
console
.
log
(
cmd
,
"cmd............"
);
var
result
=
await
this
.
exec
(
cmd
,
{
maxBuffer
:
10000
*
1024
});
...
...
igirl-channel/app/config/environment.js
View file @
d82701cc
...
...
@@ -11,7 +11,7 @@ var errorHandler = require('errorhandler');
var
settings
=
require
(
'./settings'
);
var
system
=
require
(
'../base/system'
);
var
routes
=
require
(
'./routes'
);
const
logCtl
=
system
.
getObject
(
"
web.common.oplogCtl
"
);
const
logCtl
=
system
.
getObject
(
"
service.common.oplogSve
"
);
const
clientRedis
=
system
.
getObject
(
"util.redisClient"
).
client
;
//const tm=system.getObject("db.taskManager");
module
.
exports
=
function
(
app
)
{
...
...
igirl-channel/app/config/objsettings.js
View file @
d82701cc
var
path
=
require
(
'path'
);
var
basepath
=
path
.
normalize
(
path
.
join
(
__dirname
,
'../..'
));
var
settings
=
{
web
:
path
.
join
(
basepath
,
"app/base/controller/impl"
),
//
web:path.join(basepath,"app/base/controller/impl"),
api
:
path
.
join
(
basepath
,
"app/base/api/impl"
),
util
:
path
.
join
(
basepath
,
"app/base/utils"
),
service
:
path
.
join
(
basepath
,
"app/base/service/impl"
),
...
...
igirl-channel/app/config/routes/api.js
View file @
d82701cc
var
url
=
require
(
"url"
);
var
system
=
require
(
"../../base/system"
);
// var userSve = system.getObject("service.auth.userSve");
module
.
exports
=
function
(
app
)
{
// app.get("/auth", async function (req, res) {
// if (!req.query.opencode) {
// return system.getResult(null, "opencode参数不能为空");
// }
// return await userSve.authByCode(opencode);
// });
app
.
get
(
'/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
methodName
=
req
.
params
[
"method"
];
...
...
@@ -63,6 +56,63 @@ module.exports = function (app) {
//-----------------------新的模式------------------开始
app
.
all
(
"/web/*"
,
async
function
(
req
,
res
,
next
)
{
var
result
=
system
.
getResult
(
null
,
"req method must is post"
);
if
(
req
.
method
!=
"POST"
)
{
res
.
end
(
JSON
.
stringify
(
result
));
return
;
}
if
(
!
req
.
body
.
actionType
)
{
result
.
msg
=
"actionType can not be empty"
;
res
.
end
(
JSON
.
stringify
(
result
));
return
;
}
if
(
req
.
body
.
actionType
==
"getAppTokenByHosts"
)
{
req
.
body
.
actionBody
.
app_hosts
=
req
.
host
;
next
();
return
;
}
var
token
=
req
.
headers
[
"token"
]
||
""
;
if
(
!
token
)
{
result
.
msg
=
"req headers token can not be empty"
;
res
.
end
(
JSON
.
stringify
(
result
));
return
;
}
var
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
var
result
=
await
cacheManager
[
"AppTokenByHostsCache"
].
getCache
(
token
,
system
.
exTime
);
if
(
result
.
status
!=
0
)
{
res
.
end
(
JSON
.
stringify
(
result
));
return
result
;
}
req
.
appInfo
=
result
.
data
;
req
.
body
.
actionProcess
=
req
.
appInfo
.
app_code
;
var
lst
=
[
"subTmOrder"
,
"getTmOrderList"
,
"getTmOrderInfo"
,
"getTmApplyInfo"
,
"getTmNclList"
,
"getNeedInfo"
,
"tmConfirm"
,
"updateTmInfo"
,
"updateNclInfo"
,
"updateContacts"
,
"updateCustomerInfo"
,
"addOrderAndDelivery"
,
"updateOrderPayStatus"
];
if
(
lst
.
indexOf
(
req
.
body
.
actionType
)
>=
0
)
{
var
userpin
=
req
.
headers
[
"userpin"
]
||
""
;
if
(
!
userpin
)
{
result
.
msg
=
"req headers userpin can not be empty"
;
res
.
end
(
JSON
.
stringify
(
result
));
return
;
}
else
{
var
result
=
await
cacheManager
[
"AppUserPinByChannelUserId"
].
getCache
(
userpin
,
system
.
exTime
);
if
(
result
.
status
!=
0
)
{
res
.
end
(
JSON
.
stringify
(
result
));
return
result
;
}
req
.
userInfo
=
result
.
data
;
}
}
//需要用户登录
next
();
});
app
.
get
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
methodName
=
req
.
params
[
"method"
];
...
...
@@ -103,8 +153,8 @@ module.exports = function (app) {
params
.
push
(
gname
);
params
.
push
(
methodName
);
params
.
push
(
req
.
query
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"api."
+
classPath
);
...
...
igirl-channel/app/config/routes/vue-ui.js
View file @
d82701cc
...
...
@@ -2,36 +2,36 @@ var fs=require("fs");
var
settings
=
require
(
"../settings"
);
var
glob
=
require
(
"glob"
);
var
system
=
require
(
'../../base/system'
);
var
bizcompCache
=
{};
async
function
asycReadFile
(
path
){
var
p
=
new
Promise
(
function
(
reslv
,
reject
){
fs
.
readFile
(
path
,
function
(
err
,
r
){
if
(
err
){
reject
(
err
);
}
else
{
reslv
(
r
);
}
});
});
return
p
;
}
async
function
buildComponent
(
compname
){
if
(
bizcompCache
[
compname
]
&&
settings
.
env
==
"prod"
){
return
bizcompCache
[
compname
];
}
else
{
var
htmlpath
=
settings
.
basepath
+
"/app/front/vues/pages/"
+
compname
+
"/"
+
compname
+
".html"
;
var
jspath
=
settings
.
basepath
+
"/app/front/vues/pages/"
+
compname
+
"/"
+
compname
+
".js"
;
//
var bizcompCache={};
//
async function asycReadFile(path){
//
var p=new Promise(function(reslv,reject){
//
fs.readFile(path,function(err,r){
//
if(err){
//
reject(err);
//
}else{
//
reslv(r);
//
}
//
});
//
});
//
return p;
//
}
//
async function buildComponent(compname){
//
if(bizcompCache[compname] && settings.env=="prod"){
//
return bizcompCache[compname];
//
}else{
//
var htmlpath=settings.basepath+"/app/front/vues/pages/"+compname+"/"+compname+".html";
//
var jspath=settings.basepath+"/app/front/vues/pages/"+compname+"/"+compname+".js";
var
html
=
await
asycReadFile
(
htmlpath
);
var
tmpl
=
html
.
toString
(
"utf-8"
);
var
js
=
await
asycReadFile
(
jspath
);
var
jsstr
=
js
.
toString
(
"utf-8"
);
jsstr
=
jsstr
.
replace
(
"${tmpl}"
,
tmpl
);
bizcompCache
[
compname
]
=
jsstr
;
return
jsstr
;
}
//
var html= await asycReadFile(htmlpath);
//
var tmpl=html.toString("utf-8");
//
var js= await asycReadFile(jspath);
//
var jsstr=js.toString("utf-8");
//
jsstr=jsstr.replace("${tmpl}",tmpl);
//
bizcompCache[compname]=jsstr;
//
return jsstr;
//
}
}
//
}
module
.
exports
=
function
(
app
)
{
app
.
get
(
'/vue/comp/base'
,
function
(
req
,
res
){
var
vuePath
=
settings
.
basepath
+
"/app/front/vues/base"
;
...
...
igirl-channel/app/config/routes/web.js
deleted
100644 → 0
View file @
6c66c2eb
var
url
=
require
(
"url"
);
var
system
=
require
(
"../../base/system"
);
// var userCtl = system.getObject("web.auth.userCtl");
module
.
exports
=
function
(
app
)
{
app
.
get
(
"/"
,
async
function
(
req
,
res
)
{
res
.
render
(
"index"
,
{
appinfo
:
null
,
app
:
null
});
// console.log(req.hostname);
// var appinfo=await metaCtl.getAppInfo(req);
// if(!appinfo){
// res.render("index",{appinfo:null,app:null});
// }else{
// res.render("index",appinfo);
// }
});
app
.
get
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
classPath
=
gname
+
"."
+
classPath
;
var
params
=
[];
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"web."
+
classPath
);
if
(
invokeObj
[
"doexec"
])
{
p
=
invokeObj
[
"doexec"
].
apply
(
invokeObj
,
params
);
}
p
.
then
(
r
=>
{
res
.
end
(
JSON
.
stringify
(
r
));
});
});
app
.
post
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
var
params
=
[];
classPath
=
gname
+
"."
+
classPath
;
var
tClientIp
=
system
.
get_client_ip
(
req
);
req
.
body
.
clientIp
=
tClientIp
;
req
.
body
.
agent
=
req
.
headers
[
"user-agent"
];
req
.
body
.
classname
=
classPath
;
params
.
push
(
methodName
);
params
.
push
(
req
.
query
);
params
.
push
(
req
.
body
);
params
.
push
(
req
);
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"web."
+
classPath
);
if
(
invokeObj
[
"doexec"
])
{
p
=
invokeObj
[
"doexec"
].
apply
(
invokeObj
,
params
);
}
p
.
then
(
r
=>
{
res
.
end
(
JSON
.
stringify
(
r
));
});
});
};
igirl-channel/app/config/settings.js
View file @
d82701cc
...
...
@@ -16,7 +16,7 @@ var settings = {
appKey
:
"201911061250"
,
secret
:
"f99d413b767f09b5dff0b3610366cc46"
,
salt
:
"%iatpD1gcxz7iF#B"
,
cacheprefix
:
"
jd
"
,
cacheprefix
:
"
centerChannel
"
,
usertimeout
:
3600
,
//单位秒
basepath
:
path
.
normalize
(
path
.
join
(
__dirname
,
'../..'
)),
port
:
process
.
env
.
NODE_PORT
||
4003
,
...
...
@@ -27,6 +27,13 @@ var settings = {
return
"https://open.gongsibao.com/"
;
}
},
centerAppUrl
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
return
"http://centerapp.apps.com:4010/"
;
}
else
{
return
"https://centerapp/"
;
}
},
reqTransferurl
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
return
"http://192.168.18.61:3003/"
;
...
...
igirl-channel/app/config/socket.server.js
deleted
100644 → 0
View file @
6c66c2eb
var
Server
=
require
(
'socket.io'
);
var
System
=
require
(
'../base/system'
);
var
redisClient
=
System
.
getObject
(
"util.redisClient"
);
const
logCtl
=
System
.
getObject
(
"web.common.oplogCtl"
);
const
notifyCtl
=
System
.
getObject
(
"web.socketNotifyCtl"
);
const
msgHistoryService
=
System
.
getObject
(
"service.msghistorySve"
);
class
MsgHandler
{
constructor
(
server
,
client
){
this
.
server
=
server
;
this
.
client
=
client
;
this
.
init
();
}
notifyClient
(
ukchannel
,
msg
){
var
msgH
=
{
msgType
:
"system"
,
sender
:
"s¥s¥s¥s"
,
target
:
msg
.
to
,
content
:
msg
.
content
};
msgHistoryService
.
create
(
msgH
).
then
((
m
)
=>
{
redisClient
.
publish
(
ukchannel
,
JSON
.
stringify
(
msg
));
}).
catch
(
e
=>
{
console
.
log
(
e
);
logCtl
.
info
({
optitle
:
"socket.server.js->notifyClient接口调用异常error:"
,
op
:
"chatmsg"
,
content
:
e
.
stack
,
clientIp
:
null
,
agent
:
""
,
});
});
}
init
(){
var
self
=
this
;
//转发通信消息
this
.
client
.
on
(
"chatmsg"
,
msg
=>
{
const
from
=
msg
.
from
;
const
to
=
msg
.
to
;
const
msgContent
=
msg
.
content
;
var
arrs
=
to
.
split
(
"¥"
);
var
tochannel
=
arrs
[
0
]
+
"¥"
+
arrs
[
1
];
//发布消息
//持久化消息
var
msgH
=
{
msgType
:
"single"
,
sender
:
msg
.
from
,
target
:
msg
.
to
,
content
:
msg
.
content
};
msgHistoryService
.
create
(
msgH
).
then
((
m
)
=>
{
redisClient
.
publish
(
tochannel
,
JSON
.
stringify
(
msg
));
}).
catch
(
e
=>
{
console
.
log
(
e
);
logCtl
.
info
({
optitle
:
"socket.server.js->发布消息->持久化消息接口调用异常error:"
,
op
:
"chatmsg"
,
content
:
e
,
clientIp
:
null
,
agent
:
""
,
});
});
//self.server.users[to].emit("chatmsg",msg);
});
this
.
client
.
on
(
"mryzmsg"
,
async
msg
=>
{
try
{
const
from
=
msg
.
from
;
const
to
=
msg
.
to
;
const
msgContent
=
msg
.
content
;
var
fromArrs
=
from
.
split
(
"¥"
);
var
toArrs
=
to
.
split
(
"¥"
);
var
fromId
=
Number
(
fromArrs
[
1
]);
var
toId
=
Number
(
toArrs
[
1
]);
var
fromChannel
=
fromArrs
[
0
]
+
"¥"
+
fromArrs
[
1
];
var
toChannel
=
toArrs
[
0
]
+
"¥"
+
toArrs
[
1
];
// 消息对象
var
msgH
=
{
msgType
:
msg
.
msgType
||
"mryzSingle"
,
sender
:
from
,
senderId
:
fromId
,
target
:
msg
.
to
,
targetId
:
toId
,
content
:
msgContent
,
isRead
:
false
,
businessLicense_id
:
msg
.
businessLicense_id
||
0
,
};
msgH
=
await
msgHistoryService
.
saveMsg
(
msgH
);
redisClient
.
publish
(
fromChannel
,
JSON
.
stringify
(
msgH
));
if
(
fromChannel
!=
toChannel
)
{
redisClient
.
publish
(
toChannel
,
JSON
.
stringify
(
msgH
));
}
}
catch
(
e
)
{
console
.
error
(
e
);
logCtl
.
info
({
optitle
:
"socket.server.js->发布每日易照消息->持久化每日易照消息接口调用异常error:"
,
op
:
"mryzmsg"
,
content
:
e
,
clientIp
:
null
,
agent
:
""
,
});
}
//self.server.users[to].emit("chatmsg",msg);
});
//响应消息处理
this
.
client
.
on
(
"replymsg"
,(
msg
,
fn
)
=>
{
var
p
=
null
;
var
invokeObj
=
System
.
getObject
(
"web."
+
msg
.
cls
);
console
.
log
(
invokeObj
);
if
(
invokeObj
[
msg
.
method
]){
p
=
invokeObj
[
msg
.
method
].
apply
(
invokeObj
,[
msg
.
data
]);
}
p
.
then
(
r
=>
{
fn
(
r
);
}).
then
(()
=>
{
logCtl
.
info
({
optitle
:
"socket.server.js->响应消息处理->接口调用info:"
,
op
:
msg
.
cls
+
"/"
+
msg
.
method
,
content
:
JSON
.
stringify
(
msg
.
data
),
clientIp
:
null
,
agent
:
""
,
});
}).
catch
(
err
=>
{
logCtl
.
error
({
optitle
:
"socket.server.js->响应消息处理->接口调用异常error:"
,
op
:
msg
.
cls
+
"/"
+
msg
.
method
,
content
:
JSON
.
stringify
(
msg
.
data
),
clientIp
:
null
,
agent
:
""
,
});
})
});
}
}
class
SocketServer
{
constructor
(
httpServer
){
this
.
server
=
Server
(
httpServer
,{
serveClient
:
false
,
});
this
.
users
=
{};
this
.
init
();
this
.
onlines
=
0
;
}
init
(){
var
self
=
this
;
//挂载到web应用的控制器
notifyCtl
.
setSocketServer
(
self
);
//订阅广播频道
redisClient
.
subscribe
(
"brc"
,
self
);
//中间件可以在链接事件发出前调用一次
this
.
server
.
use
((
socket
,
next
)
=>
{
next
();
});
this
.
server
.
on
(
'connection'
,
function
(
client
){
console
.
log
(
"connection.....socket"
);
//链接登录事件
client
.
on
(
'login'
,
function
(
data
){
console
.
log
(
"login...........................................................success"
);
console
.
log
(
data
);
console
.
log
(
client
.
remoteAddress
);
var
uk
=
data
.
appid
+
"¥"
+
data
.
id
;
client
.
uk
=
uk
;
client
.
uid
=
data
.
id
;
client
.
username
=
data
.
nickName
;
client
.
appname
=
data
.
appname
;
client
.
appkey
=
data
.
appkey
;
client
.
sex
=
data
.
sex
;
client
.
imgUrl
=
data
.
imgUrl
;
self
.
users
[
uk
]
=
new
MsgHandler
(
self
,
client
);
//订阅uk私人频道
var
ss
=
redisClient
.
subscribe
(
uk
,
self
);
//加入redisClient列表
redisClient
.
sadd
(
"onlineset"
+
"¥"
+
data
.
appkey
,[
uk
+
"¥"
+
data
.
nickName
+
"¥"
+
data
.
imgUrl
]).
then
(
n
=>
{
//当前在线
self
.
onlines
=
n
;
redisClient
.
publish
(
"brc"
,
JSON
.
stringify
({
"type"
:
"online"
,
"content"
:
n
}));
});
});
//链接断开事件
client
.
on
(
'disconnect'
,
async
function
(
r
){
console
.
log
(
"connection.........................................dismiss............."
);
if
(
client
.
uk
)
{
await
redisClient
.
srem
(
"onlineset"
+
"¥"
+
client
.
appkey
,
client
.
uk
+
"¥"
+
client
.
username
+
"¥"
+
client
.
imgUrl
);
await
redisClient
.
publish
(
"brc"
,
JSON
.
stringify
({
"type"
:
"online"
,
"content"
:(
self
.
onlines
--
)}));
delete
self
.
users
[
client
.
uk
];
redisClient
.
unsubscribe
(
client
.
uk
);
//redisClient.unsubscribe("brc");
console
.
log
(
client
.
uk
+
"¥"
+
client
.
username
+
"¥"
+
client
.
imgUrl
);
}
});
});
}
}
module
.
exports
=
SocketServer
;
igirl-channel/app/front/entry/public/apidoc/user/user.md
0 → 100755
View file @
d82701cc
<a
name=
"menu"
>
目录
</a>
1.
[
短信验证码
](
#smsCode
)
1.
[
登录
](
#login
)
1.
[
当前用户信息查询
](
#loginUser
)
1.
[
获取菜单
](
#getMenu
)
## **<a name="smsCode"> 短信验证码</a>**
[
返回到目录
](
#menu
)
##### URL
[
/web/auth/userCtl/smsCode
]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
| 参数 | 必选 | 类型 | 说明|
| -------- | -------- | ------------|---------|
|
**mobile**
| 是 | String | 手机号码|
#### 返回结果
```
javascript
{
"status"
:
0
,
"msg"
:
"success"
,
}
```
## **<a name="login"> 登录</a>**
[
返回到目录
](
#menu
)
##### URL
[
/web/auth/userCtl/login
]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
| 参数 | 必选 | 类型 | 说明|
| -------- | -------- | ------------|---------|
|
**loginName**
| 是 | String | 登录名|
|
**password**
| 是 | String | 密码 |
|
**captchaKey**
| 是 | String | 图片验证码key |
|
**captchaCode**
| 是 | String | 图片验证码填入值 |
#### 返回结果
```
javascript
{
"status"
:
0
,
"msg"
:
"success"
,
"data"
:
{
"xggadminsid"
:
"3cb49932-fa02-44f0-90db-9f06fe02e5c7"
// 登录key
}
}
```
## **<a name="currentUser"> 当前用户信息查询</a>**
[
返回到目录
](
#menu
)
##### URL
[
/web/auth/userCtl/currentUser
]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 返回结果
```
javascript
{
"status"
:
0
,
"msg"
:
"success"
,
}
```
## **<a name="getMenu"> 获取菜单</a>**
[
返回到目录
](
#menu
)
##### URL
[
/web/auth/userCtl/getMenu
]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 返回结果
```
javascript
[
{
"name"
:
"首页"
,
"path"
:
"/"
,
"submenu"
:
[]
},
{
"name"
:
"商户中心"
,
"path"
:
"/merchants"
,
"submenu"
:
[
{
"name"
:
"客户管理"
,
"team"
:
[
{
"name"
:
"商户信息"
,
"path"
:
"/merchants/businessInformation"
},
...
]
}
]
},
...
]
```
igirl-channel/main.js
View file @
d82701cc
...
...
@@ -3,31 +3,10 @@ var express = require('express');
var
app
=
express
();
var
setttings
=
require
(
"./app/config/settings"
);
var
environment
=
require
(
'./app/config/environment'
);
// var SocketServer=require("./app/config/socket.server");
//const cluster = require('cluster');
//const numCPUs = require('os').cpus().length;
// all environments
environment
(
app
);
//初始化环境
// 错误处理中间件应当在路由加载之后才能加载
// if (cluster.isMaster) {
// console.log(`Master ${process.pid} is running`);
//
// // Fork workers.
// for (let i = 0; i < numCPUs; i++) {
// cluster.fork();
// }
// cluster.on('exit', (worker, code, signal) => {
// console.log(`worker ${worker.process.pid} died`);
// });
// }else{
// var server = http.createServer(app);
// var socketServer = new SocketServer(server);
// server.listen(setttings.port, function(){
// console.log('Express server listening on port ' + app.get('port'));
// });
// }
var
server
=
http
.
createServer
(
app
);
//var socketServer = new SocketServer(server);
server
.
listen
(
setttings
.
port
,
function
(){
console
.
log
(
'Express server listening on port '
+
app
.
get
(
'port'
));
});
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