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
68a3862e
Commit
68a3862e
authored
Jan 09, 2020
by
王昆
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'xggsve-uc' of gitlab.gongsibao.com:jiangyong/zhichan into xggsve-uc
parents
af0c15cf
e0685875
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
111 additions
and
103 deletions
+111
-103
xggsve-uc/app/base/service/impl/user/userSve.js
+111
-103
No files found.
xggsve-uc/app/base/service/impl/user/userSve.js
View file @
68a3862e
...
...
@@ -120,123 +120,131 @@ class UserService extends ServiceBase {
}
async
add
(
obj
)
{
var
roles
=
obj
.
roles
||
[];
var
org
=
obj
.
org
||
{};
var
saas_id
=
Number
(
obj
.
saas_id
||
0
);
var
ucid
=
this
.
trim
(
obj
.
ucid
);
var
ucname
=
this
.
trim
(
obj
.
ucname
);
var
password
=
this
.
trim
(
obj
.
password
);
var
uctype
=
Number
(
obj
.
uctype
||
1
);
var
uctypeId
=
this
.
trim
(
obj
.
uctypeId
);
var
mobile
=
this
.
trim
(
obj
.
mobile
);
var
realName
=
this
.
trim
(
obj
.
realName
);
var
isMain
=
obj
.
isMain
||
0
;
if
(
!
saas_id
)
{
return
system
.
getResult
(
null
,
"saas_id不存在"
);
}
try
{
var
roles
=
obj
.
roles
||
[];
var
org
=
obj
.
org
||
{};
var
saas_id
=
Number
(
obj
.
saas_id
||
0
);
var
ucid
=
this
.
trim
(
obj
.
ucid
);
var
ucname
=
this
.
trim
(
obj
.
ucname
);
var
password
=
this
.
trim
(
obj
.
password
);
var
uctype
=
Number
(
obj
.
uctype
||
1
);
var
uctypeId
=
this
.
trim
(
obj
.
uctypeId
);
var
mobile
=
this
.
trim
(
obj
.
mobile
);
var
realName
=
this
.
trim
(
obj
.
realName
);
var
isMain
=
obj
.
isMain
||
0
;
if
(
!
saas_id
)
{
return
system
.
getResult
(
null
,
"saas_id不存在"
);
}
var
exist
=
await
this
.
findOne
({
ucname
:
ucname
});
if
(
exist
)
{
return
system
.
getResult
(
null
,
`用户名【
${
ucname
}
】已存在`
);
}
var
exist
=
await
this
.
findOne
({
ucname
:
ucname
});
if
(
exist
)
{
return
system
.
getResult
(
null
,
`用户名【
${
ucname
}
】已存在`
);
}
var
user
=
{
saas_id
:
saas_id
,
ucid
:
ucid
,
ucname
:
ucname
,
password
:
await
this
.
getEncryptStr
(
password
),
uctype
:
uctype
,
uctypeId
:
uctypeId
,
org_id
:
org
.
id
||
0
,
isMain
:
isMain
,
orgpath
:
""
,
isEnabled
:
1
,
}
var
user
=
{
saas_id
:
saas_id
,
ucid
:
ucid
,
ucname
:
ucname
,
password
:
await
this
.
getEncryptStr
(
password
),
uctype
:
uctype
,
uctypeId
:
uctypeId
,
org_id
:
org
.
id
||
0
,
isMain
:
isMain
,
orgpath
:
""
,
isEnabled
:
1
,
}
var
orgpath
=
org
.
path
||
""
;
var
orgpath
=
org
.
path
||
""
;
var
info
=
{
mobile
:
mobile
,
realName
:
realName
,
}
var
info
=
{
mobile
:
mobile
,
realName
:
realName
,
}
var
self
=
this
;
user
=
await
self
.
db
.
transaction
(
async
function
(
t
)
{
// 创建商户
user
=
await
self
.
dao
.
create
(
user
,
t
);
info
.
id
=
user
.
id
;
var
self
=
this
;
user
=
await
self
.
db
.
transaction
(
async
function
(
t
)
{
// 创建商户
user
=
await
self
.
dao
.
create
(
user
,
t
);
info
.
id
=
user
.
id
;
info
=
await
self
.
userinfoDao
.
create
(
info
,
t
);
info
=
await
self
.
userinfoDao
.
create
(
info
,
t
);
if
(
roles
&&
roles
.
length
>
0
)
{
for
(
var
r
of
roles
)
{
r
.
user_id
=
user
.
id
;
if
(
roles
&&
roles
.
length
>
0
)
{
for
(
var
r
of
roles
)
{
r
.
user_id
=
user
.
id
;
}
await
self
.
userroleDao
.
bulkCreate
(
roles
,
t
);
}
await
self
.
userroleDao
.
bulkCreate
(
roles
,
t
);
}
if
(
user
.
uctype
===
1
)
{
orgpath
=
(
isMain
?
orgpath
:
orgpath
+
"/"
+
user
.
id
)
+
"/"
;
await
self
.
dao
.
update
({
id
:
user
.
id
,
orgpath
:
orgpath
},
t
);
}
user
.
orgpath
=
orgpath
;
return
user
;
});
if
(
user
.
uctype
===
1
)
{
orgpath
=
(
isMain
?
orgpath
:
orgpath
+
"/"
+
user
.
id
)
+
"/"
;
await
self
.
dao
.
update
({
id
:
user
.
id
,
orgpath
:
orgpath
},
t
);
}
user
.
orgpath
=
orgpath
;
return
user
;
});
return
system
.
getResultSuccess
(
user
);
return
system
.
getResultSuccess
(
user
);
}
catch
(
error
)
{
return
system
.
getResult
(
-
1
,
`系统错误 错误信息
${
error
}
`
);
}
}
async
upd
(
obj
)
{
var
id
=
obj
.
id
;
var
roles
=
obj
.
roles
||
[];
var
org
=
obj
.
org
||
{};
var
uctype
=
this
.
trim
(
obj
.
uctype
);
var
uctypeId
=
this
.
trim
(
obj
.
uctypeId
);
var
mobile
=
this
.
trim
(
obj
.
mobile
);
var
realName
=
this
.
trim
(
obj
.
realName
);
var
isMain
=
obj
.
isMain
||
0
;
var
user
=
{
id
:
id
,
uctype
:
uctype
,
uctypeId
:
uctypeId
,
org_id
:
org
.
id
||
""
,
orgpath
:
""
,
isMain
:
obj
.
isMain
||
0
,
}
if
(
Number
(
this
.
trim
(
user
.
uctype
))
===
1
)
{
user
.
orgpath
=
(
isMain
?
org
.
path
:
org
.
path
+
"/"
+
id
)
+
"/"
;
}
var
info
=
{
id
:
id
,
mobile
:
mobile
,
realName
:
realName
,
}
var
self
=
this
;
user
=
await
self
.
db
.
transaction
(
async
function
(
t
)
{
// 创建商户
await
self
.
dao
.
update
(
user
,
t
);
await
self
.
userinfoDao
.
update
(
info
,
t
);
await
self
.
userroleDao
.
delByUserId
(
id
,
t
);
if
(
roles
&&
roles
.
length
>
0
)
{
for
(
var
r
of
roles
)
{
r
.
user_id
=
id
;
}
await
self
.
userroleDao
.
bulkCreate
(
roles
,
t
);
try
{
var
id
=
obj
.
id
;
var
roles
=
obj
.
roles
||
[];
var
org
=
obj
.
org
||
{};
var
uctype
=
this
.
trim
(
obj
.
uctype
);
var
uctypeId
=
this
.
trim
(
obj
.
uctypeId
);
var
mobile
=
this
.
trim
(
obj
.
mobile
);
var
realName
=
this
.
trim
(
obj
.
realName
);
var
isMain
=
obj
.
isMain
||
0
;
var
user
=
{
id
:
id
,
uctype
:
uctype
,
uctypeId
:
uctypeId
,
org_id
:
org
.
id
||
null
,
orgpath
:
""
,
isMain
:
obj
.
isMain
||
0
,
}
return
user
;
});
return
system
.
getResultSuccess
(
user
);
if
(
Number
(
this
.
trim
(
user
.
uctype
))
===
1
)
{
user
.
orgpath
=
(
isMain
?
org
.
path
:
org
.
path
+
"/"
+
id
)
+
"/"
;
}
var
info
=
{
id
:
id
,
mobile
:
mobile
,
realName
:
realName
,
}
var
self
=
this
;
user
=
await
self
.
db
.
transaction
(
async
function
(
t
)
{
// 创建商户
await
self
.
dao
.
update
(
user
,
t
);
await
self
.
userinfoDao
.
update
(
info
,
t
);
await
self
.
userroleDao
.
delByUserId
(
id
,
t
);
if
(
roles
&&
roles
.
length
>
0
)
{
for
(
var
r
of
roles
)
{
r
.
user_id
=
id
;
}
await
self
.
userroleDao
.
bulkCreate
(
roles
,
t
);
}
return
user
;
});
return
system
.
getResultSuccess
(
user
);
}
catch
(
error
)
{
return
system
.
getResult
(
-
1
,
`系统错误 错误信息
${
error
}
`
);
}
}
async
info
(
params
)
{
...
...
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