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
4e8ca5d1
Commit
4e8ca5d1
authored
Nov 30, 2019
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
cc7b6390
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
99 additions
and
46 deletions
+99
-46
xggsve-uc/app/base/api/impl/op/action.js
+15
-9
xggsve-uc/app/base/db/impl/auth/authDao.js
+14
-2
xggsve-uc/app/base/db/impl/user/userDao.js
+8
-3
xggsve-uc/app/base/db/impl/user/userroleDao.js
+3
-2
xggsve-uc/app/base/db/models/user/userrole.js
+1
-1
xggsve-uc/app/base/service/impl/auth/authSve.js
+6
-7
xggsve-uc/app/base/service/impl/org/orgSve.js
+14
-2
xggsve-uc/app/base/service/impl/user/userSve.js
+38
-20
No files found.
xggsve-uc/app/base/api/impl/op/action.js
View file @
4e8ca5d1
...
...
@@ -76,7 +76,7 @@ class ActionAPI extends APIBase {
case
"findById"
:
opResult
=
await
this
.
orgSve
.
apiFindById
(
action_body
);
break
;
case
"
b
yPid"
:
case
"
orgB
yPid"
:
opResult
=
await
this
.
orgSve
.
apiByPid
(
action_body
);
break
;
case
"orgTree"
:
...
...
@@ -96,7 +96,7 @@ class ActionAPI extends APIBase {
case
"authInfo"
:
opResult
=
this
.
authSve
.
info
(
action_body
);
break
;
case
"
b
yPid"
:
case
"
authB
yPid"
:
opResult
=
this
.
authSve
.
byPid
(
action_body
);
break
;
case
"delAuth"
:
...
...
@@ -122,27 +122,33 @@ class ActionAPI extends APIBase {
break
;
// 用户
case
"addUser"
:
if
(
action_body
.
uctype
===
1
)
{
action_body
.
org
=
await
this
.
orgSve
.
findById
(
Number
(
action_body
.
org_id
));
if
(
!
action_body
.
org
)
{
opResult
=
system
.
getResult
(
null
,
`组织机构不存在`
);
}
else
{
opResult
=
this
.
userSve
.
add
(
action_body
);
return
system
.
getResult
(
null
,
`组织机构不存在`
);
}
}
opResult
=
this
.
userSve
.
add
(
action_body
);
break
;
case
"updUser"
:
if
(
action_body
.
uctype
===
1
)
{
action_body
.
org
=
await
this
.
orgSve
.
findById
(
Number
(
action_body
.
org_id
));
if
(
!
action_body
.
org
)
{
opResult
=
system
.
getResult
(
null
,
`当前SAAS不能删除`
);
}
else
{
opResult
=
this
.
userSve
.
upd
(
action_body
);
return
system
.
getResult
(
null
,
`组织机构不存在`
);
}
}
opResult
=
this
.
userSve
.
upd
(
action_body
);
break
;
case
"userInfo"
:
opResult
=
this
.
userSve
.
info
(
action_body
);
break
;
case
"enabled"
:
opResult
=
this
.
userSve
.
enabled
(
action_body
);
break
;
case
"delUser"
:
opResult
=
this
.
userSve
.
delUser
(
action_body
);
break
;
case
"
listUser
"
:
case
"
userPage
"
:
opResult
=
this
.
userSve
.
pageByCondition
(
action_body
);
break
;
}
...
...
xggsve-uc/app/base/db/impl/auth/authDao.js
View file @
4e8ca5d1
...
...
@@ -5,8 +5,19 @@ class AuthDao extends Dao {
super
(
Dao
.
getModelName
(
AuthDao
));
}
async
all
()
{
return
this
.
customQuery
(
"SELECT * FROM uc_auth WHERE deleted_at IS NULL"
);
async
all
(
saas_id
,
attrs
)
{
attrs
=
attrs
||
"*"
;
var
sql
=
[];
sql
.
push
(
"SELECT"
);
sql
.
push
(
attrs
);
sql
.
push
(
"FROM uc_auth"
);
sql
.
push
(
"WHERE deleted_at IS NULL"
);
var
params
=
{};
if
(
saas_id
)
{
sql
.
push
(
"AND saas_id = :saas_id"
);
params
.
saas_id
=
saas_id
;
}
return
this
.
customQuery
(
sql
.
join
(
" "
),
params
);
}
}
module
.
exports
=
AuthDao
;
\ No newline at end of file
xggsve-uc/app/base/db/impl/user/userDao.js
View file @
4e8ca5d1
...
...
@@ -38,7 +38,7 @@ class UserDao extends Dao {
sql
.
push
(
"count(1) as num"
);
sql
.
push
(
"FROM uc_user t1"
);
sql
.
push
(
"INNER JOIN uc_user_info t2 ON t1.id = t2.id"
);
sql
.
push
(
"WHERE
1 = 1
"
);
sql
.
push
(
"WHERE
t1.deleted_at IS NULL
"
);
var
list
=
await
this
.
customQuery
(
sql
.
join
(
" "
),
params
);
if
(
!
list
||
list
.
length
==
0
)
{
...
...
@@ -58,7 +58,7 @@ class UserDao extends Dao {
sql
.
push
(
"t2.mobile, t2.realName"
);
sql
.
push
(
"FROM uc_user t1"
);
sql
.
push
(
"INNER JOIN uc_user_info t2 ON t1.id = t2.id"
);
sql
.
push
(
"WHERE
1 = 1
"
);
sql
.
push
(
"WHERE
t1.deleted_at IS NULL
"
);
this
.
setCondition
(
sql
,
params
);
...
...
@@ -67,7 +67,7 @@ class UserDao extends Dao {
return
await
this
.
customQuery
(
sql
.
join
(
" "
),
params
);
}
setCondition
(
params
,
sql
)
{
setCondition
(
sql
,
params
)
{
if
(
!
params
||
!
sql
)
{
return
;
}
...
...
@@ -98,6 +98,10 @@ class UserDao extends Dao {
if
(
params
.
createEnd
)
{
sql
.
push
(
"AND t1.created_at <= :createEnd"
);
}
if
(
params
.
isEnabled
===
0
||
params
.
isEnabled
===
1
)
{
sql
.
push
(
"AND t1.isEnabled = :isEnabled"
);
}
}
}
module
.
exports
=
UserDao
;
\ No newline at end of file
xggsve-uc/app/base/db/impl/user/userroleDao.js
View file @
4e8ca5d1
...
...
@@ -12,8 +12,9 @@ class UserroleDao extends Dao {
},
t
)
||
[];
}
async
listByUserId
(
user_id
,
t
)
{
var
sql
=
"SELECT * FROM uc_user_role WHERE user_id = :user_id"
;
async
listByUserId
(
user_id
,
attrs
,
t
)
{
attrs
=
attrs
||
"*"
;
var
sql
=
"SELECT "
+
attrs
+
" FROM uc_user_role WHERE user_id = :user_id"
;
return
await
this
.
customQuery
(
sql
,
{
user_id
:
user_id
},
t
)
||
[];
...
...
xggsve-uc/app/base/db/models/user/userrole.js
View file @
4e8ca5d1
...
...
@@ -4,7 +4,7 @@ const uiconfig = system.getUiConfig2(settings.appKey);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"userrole"
,
{
user_id
:
DataTypes
.
INTEGER
,
org
_id
:
DataTypes
.
INTEGER
,
role
_id
:
DataTypes
.
INTEGER
,
},
{
paranoid
:
true
,
//假的删除
underscored
:
true
,
...
...
xggsve-uc/app/base/service/impl/auth/authSve.js
View file @
4e8ca5d1
...
...
@@ -12,7 +12,7 @@ class AuthService extends ServiceBase {
var
pid
=
Number
(
obj
.
pid
||
0
);
if
(
!
saas_id
)
{
return
system
.
getResult
(
null
,
"
请指定saas_id
"
);
return
system
.
getResult
(
null
,
"
saas_id不存在
"
);
}
if
(
pid
===
0
)
{
...
...
@@ -47,7 +47,7 @@ class AuthService extends ServiceBase {
}
var
auth
=
await
this
.
findById
(
id
);
if
(
!
saas_id
)
{
return
system
.
getResult
(
null
,
"
请指定saas_id
"
);
return
system
.
getResult
(
null
,
"
saas_id不存在
"
);
}
if
(
saas_id
!=
auth
.
saas_id
)
{
...
...
@@ -68,11 +68,11 @@ class AuthService extends ServiceBase {
var
list
=
await
this
.
dao
.
findAll
({
pid
:
obj
.
pid
||
0
,
});
return
list
;
return
system
.
getResultSuccess
(
list
)
;
}
async
tree
()
{
var
all
=
await
this
.
dao
.
all
();
async
tree
(
params
)
{
var
all
=
await
this
.
dao
.
all
(
params
.
saas_id
,
"id, pid, menuType, name, icon, path"
);
var
pmap
=
{};
for
(
var
item
of
all
)
{
...
...
@@ -87,8 +87,7 @@ class AuthService extends ServiceBase {
for
(
var
item
of
all
)
{
item
.
childs
=
pmap
[
item
.
id
]
||
[];
}
return
system
.
getResultSuccess
(
pmap
[
0
]);
return
system
.
getResultSuccess
(
pmap
[
0
][
0
]);
}
async
info
(
obj
)
{
...
...
xggsve-uc/app/base/service/impl/org/orgSve.js
View file @
4e8ca5d1
...
...
@@ -110,13 +110,25 @@ class OrgService extends ServiceBase {
try
{
var
pid
=
Number
(
params
.
pid
||
0
);
params
.
orgname
=
this
.
trim
(
params
.
orgname
);
params
.
saas_id
=
Number
(
params
.
saas_id
||
0
);
if
(
!
params
.
saas_id
){
return
system
.
getResult
(
-
1
,
`saas_id不存在`
)}
if
(
!
params
.
orgname
){
return
system
.
getResult
(
-
1
,
`参数错误 组织名称不能为空`
)}
let
_orgByName
=
await
this
.
findOne
({
orgname
:
params
.
orgname
});
let
_orgByName
=
await
this
.
findOne
({
orgname
:
params
.
orgname
,
saas_id
:
params
.
saas_id
});
if
(
_orgByName
){
return
system
.
getResult
(
-
1
,
`参数错误 组织名称已经存在`
);
}
let
path
=
""
;
if
(
pid
===
0
){
if
(
pid
===
0
){
// 验证是否存在其他权限
var
exist
=
await
this
.
findCount
({
where
:
{
saas_id
:
saas_id
}
});
if
(
exist
)
{
return
system
.
getResult
(
null
,
"菜单根目录已经存在"
);
}
path
=
`/
${
params
.
orgname
}
`
;
}
else
{
let
_org
=
await
this
.
findOne
({
id
:
pid
});
...
...
xggsve-uc/app/base/service/impl/user/userSve.js
View file @
4e8ca5d1
...
...
@@ -39,7 +39,7 @@ class UserService extends ServiceBase {
async
add
(
obj
)
{
var
roles
=
obj
.
roles
||
[];
var
org
=
obj
.
org
;
var
org
=
obj
.
org
||
{}
;
var
saas_id
=
Number
(
obj
.
saas_id
||
0
);
var
ucid
=
this
.
trim
(
obj
.
ucid
);
var
ucname
=
this
.
trim
(
obj
.
ucname
);
...
...
@@ -50,7 +50,7 @@ class UserService extends ServiceBase {
var
isMain
=
obj
.
isMain
||
0
;
if
(
!
saas_id
)
{
return
system
.
getResult
(
null
,
"
请指定saas_id
"
);
return
system
.
getResult
(
null
,
"
saas_id不存在
"
);
}
var
exist
=
await
this
.
findOne
({
...
...
@@ -66,13 +66,13 @@ class UserService extends ServiceBase {
ucname
:
ucname
,
password
:
await
this
.
getEncryptStr
(
password
),
uctype
:
uctype
,
org_id
:
org
.
id
,
org_id
:
org
.
id
||
0
,
isMain
:
isMain
,
orgpath
:
""
,
isEnabled
:
1
,
}
var
orgpath
=
org
.
path
;
var
orgpath
=
org
.
path
||
""
;
var
info
=
{
mobile
:
mobile
,
...
...
@@ -94,14 +94,14 @@ class UserService extends ServiceBase {
await
self
.
userroleDao
.
bulkCreate
(
roles
,
t
);
}
if
(
!
isMain
)
{
orgpath
=
orgpath
+
"/"
+
user
.
id
;
}
user
.
orgpath
=
orgpath
;
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
;
});
...
...
@@ -111,7 +111,7 @@ class UserService extends ServiceBase {
async
upd
(
obj
)
{
var
id
=
obj
.
id
;
var
roles
=
obj
.
roles
||
[];
var
org
=
obj
.
org
;
var
org
=
obj
.
org
||
{}
;
var
uctype
=
this
.
trim
(
obj
.
uctype
);
var
mobile
=
this
.
trim
(
obj
.
mobile
);
var
realName
=
this
.
trim
(
obj
.
realName
);
...
...
@@ -119,11 +119,13 @@ class UserService extends ServiceBase {
var
user
=
{
id
:
id
,
org_id
:
org
.
id
,
orgpath
:
isMain
?
org
.
path
:
org
.
path
+
"/"
+
id
,
org_id
:
org
.
id
||
""
,
orgpath
:
""
,
isMain
:
obj
.
isMain
||
0
,
}
if
(
user
.
uctype
===
1
)
{
user
.
orgpath
=
isMain
?
org
.
path
:
org
.
path
+
"/"
+
id
;
}
var
info
=
{
id
:
id
,
mobile
:
mobile
,
...
...
@@ -159,11 +161,21 @@ class UserService extends ServiceBase {
user
.
mobile
=
info
.
mobile
;
user
.
realName
=
info
.
realName
;
user
.
roles
=
await
this
.
userroleDao
.
listByUserId
(
id
);
user
.
roles
=
await
this
.
userroleDao
.
listByUserId
(
id
,
"user_id, role_id"
);
this
.
handleDate
(
user
,
[
"created_at"
],
null
,
-
8
);
return
system
.
getResultSuccess
(
user
);
}
async
enabled
(
params
)
{
var
user
=
await
this
.
dao
.
findById
(
params
.
id
);
if
(
!
user
)
{
return
system
.
getResult
(
null
,
"用户不存在"
);
}
user
.
isEnabled
=
Number
(
params
.
enabled
||
0
)
==
0
?
false
:
true
;
await
user
.
save
();
return
system
.
getResultSuccess
();
}
async
pageByCondition
(
params
)
{
var
result
=
{
count
:
0
,
...
...
@@ -180,17 +192,24 @@ class UserService extends ServiceBase {
result
.
count
=
total
;
params
.
startRow
=
(
currentPage
-
1
)
*
pageSize
;
result
.
rows
=
await
this
.
dao
.
listByCondition
(
params
)
||
[];
if
(
result
.
rows
)
{
for
(
var
item
of
result
.
rows
)
{
this
.
handleDate
(
item
,
[
"created_at"
],
null
,
-
8
);
}
}
return
system
.
getResultSuccess
(
result
);
}
async
delUser
(
params
)
{
await
this
.
delete
({
id
:
params
.
id
});
var
user
=
await
this
.
findById
(
params
.
id
);
if
(
!
user
)
{
return
system
.
getResultSuccess
();
}
if
(
user
.
saas_id
!=
params
.
saas_id
)
{
return
system
.
getResult
(
null
,
"权限不足"
);
}
await
this
.
delete
({
id
:
params
.
id
});
return
system
.
getResultSuccess
();
}
}
module
.
exports
=
UserService
;
\ No newline at end of file
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