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
abbc8392
Commit
abbc8392
authored
Mar 21, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
7093d07f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
93 deletions
+86
-93
xggsve-uc/app/base/api/impl/op/action.js
+25
-1
xggsve-uc/app/base/db/impl/user/saasmerchantuserDao.js
+4
-4
xggsve-uc/app/base/service/impl/user/saasmerchantappuserSve.js
+1
-1
xggsve-uc/app/base/service/impl/user/saasmerchantuserSve.js
+56
-87
No files found.
xggsve-uc/app/base/api/impl/op/action.js
View file @
abbc8392
...
...
@@ -11,6 +11,8 @@ class ActionAPI extends APIBase {
this
.
authSve
=
system
.
getObject
(
"service.auth.authSve"
);
this
.
saasplatformuserSve
=
system
.
getObject
(
"service.user.saasplatformuserSve"
);
this
.
saasmerchantuserSve
=
system
.
getObject
(
"service.user.saasmerchantuserSve"
);
this
.
saasmerchantappuserSve
=
system
.
getObject
(
"service.user.saasmerchantappuserSve"
);
}
/**
...
...
@@ -175,7 +177,29 @@ class ActionAPI extends APIBase {
case
"platforMapByIds"
:
opResult
=
await
this
.
saasplatformuserSve
.
mapByIds
(
action_body
);
break
;
// saas商户
case
"merchantLogin"
:
opResult
=
await
this
.
saasmerchantuserSve
.
login
(
action_body
);
break
;
case
"merchantSave"
:
opResult
=
await
this
.
saasmerchantuserSve
.
save
(
action_body
);
break
;
case
"merchantInfo"
:
opResult
=
await
this
.
saasmerchantuserSve
.
info
(
action_body
);
break
;
case
"merchantEnabled"
:
opResult
=
await
this
.
saasmerchantuserSve
.
enabled
(
action_body
);
break
;
case
"merchantPage"
:
opResult
=
await
this
.
saasmerchantuserSve
.
pageByCondition
(
action_body
);
break
;
case
"merchantPassword"
:
opResult
=
await
this
.
saasmerchantuserSve
.
updPassword
(
action_body
);
break
;
case
"merchantMapByIds"
:
opResult
=
await
this
.
saasmerchantuserSve
.
mapByIds
(
action_body
);
break
;
}
return
opResult
;
}
...
...
xggsve-uc/app/base/db/impl/user/saasmerchantuserDao.js
View file @
abbc8392
...
...
@@ -29,11 +29,11 @@ class SaasMerchantUserDao extends Dao {
return
await
this
.
customQuery
(
sql
.
join
(
" "
),
params
);
}
async
getByUcname
(
saasId
,
ucname
)
{
var
sql
=
"SELECT * FROM uc_user WHERE ucname = :ucname AND saas_
id = :saas
Id AND deleted_at IS NULL"
;
async
byUcname
(
ucname
,
merchantId
)
{
var
sql
=
"SELECT * FROM uc_user WHERE ucname = :ucname AND saas_
merchant_id = :merchant
Id AND deleted_at IS NULL"
;
var
list
=
await
this
.
customQuery
(
sql
,
{
ucname
:
ucname
,
saasId
:
saas
Id
,
merchantId
:
merchant
Id
,
});
if
(
!
list
||
list
.
length
==
0
)
{
return
null
;
...
...
@@ -112,7 +112,7 @@ class SaasMerchantUserDao extends Dao {
}
}
async
findM
apByIds
(
ids
,
attrs
)
{
async
m
apByIds
(
ids
,
attrs
)
{
let
result
=
{};
if
(
!
ids
||
ids
.
length
==
0
)
{
...
...
xggsve-uc/app/base/service/impl/user/saasmerchantappuserSvejs
→
xggsve-uc/app/base/service/impl/user/saasmerchantappuserSve
.
js
View file @
abbc8392
...
...
@@ -149,7 +149,7 @@ class SaasMerchantAppUserService extends ServiceBase {
var
total
=
await
this
.
dao
.
countByCondition
(
params
);
if
(
total
==
0
)
{
return
result
;
return
system
.
getResultSuccess
(
result
)
;
}
result
.
count
=
total
;
...
...
xggsve-uc/app/base/service/impl/user/saasmerchantuserSve.js
View file @
abbc8392
...
...
@@ -7,10 +7,8 @@ class SaasMerchantUserService extends ServiceBase {
super
(
"user"
,
ServiceBase
.
getDaoName
(
SaasMerchantUserService
));
}
async
login
(
obj
)
{
var
uctype
=
Number
(
obj
.
uctype
||
0
);
var
user
=
await
this
.
dao
.
getByUcname
(
obj
.
ucname
);
async
login
(
params
)
{
let
user
=
await
this
.
dao
.
byUcname
(
params
.
ucname
,
params
.
saas_merchant_id
);
// 验证登录合法
if
(
!
user
)
{
return
system
.
getResult
(
null
,
"用户名或密码错误"
);
...
...
@@ -19,99 +17,77 @@ class SaasMerchantUserService extends ServiceBase {
return
system
.
getResult
(
null
,
"用户已禁用"
);
}
if
(
uctype
&&
uctype
!=
user
.
uctype
)
{
return
system
.
getResult
(
null
,
"用户类型错误"
);
}
var
loginPwd
=
await
this
.
getEncryptStr
(
obj
.
password
);
let
loginPwd
=
await
this
.
getEncryptStr
(
params
.
password
);
if
(
loginPwd
!=
user
.
password
)
{
return
system
.
getResult
(
null
,
"用户名或密码错误"
);
}
await
this
.
setLoginUser
(
user
);
return
system
.
getResultSuccess
(
user
);
}
async
saveUser
(
obj
)
{
try
{
var
id
=
obj
.
id
;
var
roleIds
=
obj
.
roles
||
[];
var
org_id
=
this
.
trim
(
obj
.
org_id
);
let
roles
=
[];
for
(
let
roleId
of
roleIds
)
{
roles
.
push
({
role_id
:
roleId
});
}
if
(
!
obj
.
saas_id
)
{
return
system
.
getResult
(
null
,
"saas_id不存在"
);
}
let
user
=
{};
async
save
(
params
)
{
let
id
=
Number
(
params
.
id
||
0
);
let
saas_merchant_id
=
this
.
trim
(
params
.
saas_merchant_id
);
let
saas_id
=
this
.
trim
(
params
.
saas_id
);
let
ucname
=
this
.
trim
(
params
.
ucname
);
let
mobile
=
this
.
trim
(
params
.
mobile
);
let
realName
=
this
.
trim
(
params
.
realName
);
let
password
=
this
.
trim
(
params
.
password
);
let
isEnabled
=
Number
(
params
.
isEnabled
||
0
);
if
(
!
realName
)
{
return
system
.
getResult
(
null
,
"请输入用户姓名"
);
}
if
(
!
mobile
)
{
return
system
.
getResult
(
null
,
"请输入联系手机"
);
}
if
(
!
ucname
)
{
return
system
.
getResult
(
null
,
"请输入账号"
);
}
try
{
let
exists
=
await
this
.
dao
.
findOne
({
saas_merchant_id
:
saas_merchant_id
,
ucname
:
ucname
});
let
user
;
if
(
id
)
{
let
u
=
await
this
.
findById
(
id
);
if
(
u
)
{
user
.
id
=
u
.
id
;
if
(
exists
&&
exists
.
id
!=
id
)
{
return
system
.
getResult
(
null
,
`账号名称[
${
ucname
}
]已存在`
);
}
}
let
exist
=
await
this
.
findOne
({
ucname
:
obj
.
ucname
});
if
(
user
.
id
)
{
if
(
exist
&&
exist
.
id
!=
user
.
id
)
{
return
system
.
getResult
(
null
,
`用户名【
${
ucname
}
】已存在`
);
user
=
await
this
.
dao
.
findById
(
id
);
user
.
realName
=
realName
;
user
.
ucname
=
ucname
;
user
.
isEnabled
=
isEnabled
;
if
(
password
&&
password
!=
user
.
password
)
{
user
.
password
=
await
this
.
getEncryptStr
(
password
);
}
await
user
.
save
();
}
else
{
if
(
exist
)
{
return
system
.
getResult
(
null
,
`
用户名【
${
ucname
}
】
已存在`
);
if
(
exist
s
)
{
return
system
.
getResult
(
null
,
`
账号名称[
${
ucname
}
]
已存在`
);
}
user
.
password
=
await
this
.
getEncryptStr
(
obj
.
password
);
}
let
org
=
await
this
.
orgDao
.
findById
(
org_id
);
if
(
!
org
)
{
return
system
.
getResult
(
null
,
`组织机构不存在`
);
}
user
.
ucid
=
this
.
trim
(
obj
.
ucid
);
user
.
ucname
=
this
.
trim
(
obj
.
ucname
);
user
.
uctype
=
1
;
user
.
uctypeId
=
""
;
user
.
mobile
=
this
.
trim
(
obj
.
mobile
);
user
.
realName
=
this
.
trim
(
obj
.
realName
);
user
.
org_id
=
org_id
;
user
.
saas_id
=
this
.
trim
(
obj
.
saas_id
);
var
self
=
this
;
user
=
await
self
.
db
.
transaction
(
async
function
(
t
)
{
if
(
user
.
id
)
{
await
self
.
dao
.
update
(
user
,
t
);
}
else
{
// 创建商户
user
=
await
self
.
dao
.
create
(
user
,
t
);
if
(
!
saas_merchant_id
)
{
return
system
.
getResult
(
null
,
"请选择商户"
);
}
await
self
.
userroleDao
.
delByUserId
(
user
.
id
,
t
);
if
(
roles
&&
roles
.
length
>
0
)
{
for
(
var
r
of
roles
)
{
r
.
user_id
=
user
.
id
;
}
await
self
.
userroleDao
.
bulkCreate
(
roles
,
t
);
if
(
!
password
)
{
return
system
.
getResult
(
null
,
"请输入密码"
);
}
user
.
orgpath
=
org
.
path
+
"/"
+
user
.
id
+
"/"
;
await
self
.
dao
.
update
({
id
:
user
.
id
,
orgpath
:
user
.
orgpath
},
t
);
return
user
;
});
user
=
{
saas_id
:
saas_id
,
saas_merchant_id
:
saas_merchant_id
,
password
:
await
this
.
getEncryptStr
(
password
),
realName
:
realName
,
ucname
:
ucname
,
mobile
:
mobile
,
isEnabled
:
isEnabled
,
};
user
=
await
this
.
dao
.
model
.
create
(
user
);
}
return
system
.
getResultSuccess
(
user
);
}
catch
(
error
)
{
console
.
log
(
error
);
if
(
error
.
name
==
'SequelizeValidationError'
)
{
return
system
.
getResult
(
-
1
,
`用户名重复
`
);
return
system
.
getResult
(
null
,
`账号名称[
${
ucname
}
]已存在
`
);
}
return
system
.
getResult
(
-
1
,
`系统错误 错误信息
${
error
}
`
);
}
}
...
...
@@ -143,13 +119,9 @@ class SaasMerchantUserService extends ServiceBase {
};
var
currentPage
=
Number
(
params
.
currentPage
||
1
);
var
pageSize
=
Number
(
params
.
pageSize
||
10
);
if
(
params
.
orgpath
)
{
params
.
orgpath
=
params
.
orgpath
+
"%"
;
}
var
total
=
await
this
.
dao
.
countByCondition
(
params
);
if
(
total
==
0
)
{
return
result
;
return
system
.
getResultSuccess
(
result
)
;
}
result
.
count
=
total
;
...
...
@@ -159,13 +131,10 @@ class SaasMerchantUserService extends ServiceBase {
for
(
let
item
of
result
.
rows
)
{
this
.
handleDate
(
item
,
[
"created_at"
],
null
,
-
8
);
}
await
this
.
setRoles
(
result
.
rows
);
await
this
.
setOrg
(
result
.
rows
);
}
return
system
.
getResultSuccess
(
result
);
}
async
updPassword
(
params
)
{
var
user
=
await
this
.
findById
(
params
.
id
);
if
(
!
user
)
{
...
...
@@ -178,7 +147,7 @@ class SaasMerchantUserService extends ServiceBase {
}
async
mapByIds
(
params
)
{
let
rs
=
await
this
.
dao
.
findMapByIds
(
params
.
id
s
);
let
rs
=
await
this
.
dao
.
mapByIds
(
params
.
ids
,
params
.
attr
s
);
return
system
.
getResultSuccess
(
rs
);
}
}
...
...
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