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 {
...
@@ -76,7 +76,7 @@ class ActionAPI extends APIBase {
case
"findById"
:
case
"findById"
:
opResult
=
await
this
.
orgSve
.
apiFindById
(
action_body
);
opResult
=
await
this
.
orgSve
.
apiFindById
(
action_body
);
break
;
break
;
case
"
b
yPid"
:
case
"
orgB
yPid"
:
opResult
=
await
this
.
orgSve
.
apiByPid
(
action_body
);
opResult
=
await
this
.
orgSve
.
apiByPid
(
action_body
);
break
;
break
;
case
"orgTree"
:
case
"orgTree"
:
...
@@ -96,7 +96,7 @@ class ActionAPI extends APIBase {
...
@@ -96,7 +96,7 @@ class ActionAPI extends APIBase {
case
"authInfo"
:
case
"authInfo"
:
opResult
=
this
.
authSve
.
info
(
action_body
);
opResult
=
this
.
authSve
.
info
(
action_body
);
break
;
break
;
case
"
b
yPid"
:
case
"
authB
yPid"
:
opResult
=
this
.
authSve
.
byPid
(
action_body
);
opResult
=
this
.
authSve
.
byPid
(
action_body
);
break
;
break
;
case
"delAuth"
:
case
"delAuth"
:
...
@@ -122,27 +122,33 @@ class ActionAPI extends APIBase {
...
@@ -122,27 +122,33 @@ class ActionAPI extends APIBase {
break
;
break
;
// 用户
// 用户
case
"addUser"
:
case
"addUser"
:
if
(
action_body
.
uctype
===
1
)
{
action_body
.
org
=
await
this
.
orgSve
.
findById
(
Number
(
action_body
.
org_id
));
action_body
.
org
=
await
this
.
orgSve
.
findById
(
Number
(
action_body
.
org_id
));
if
(
!
action_body
.
org
)
{
if
(
!
action_body
.
org
)
{
opResult
=
system
.
getResult
(
null
,
`组织机构不存在`
);
return
system
.
getResult
(
null
,
`组织机构不存在`
);
}
else
{
}
opResult
=
this
.
userSve
.
add
(
action_body
);
}
}
opResult
=
this
.
userSve
.
add
(
action_body
);
break
;
break
;
case
"updUser"
:
case
"updUser"
:
if
(
action_body
.
uctype
===
1
)
{
action_body
.
org
=
await
this
.
orgSve
.
findById
(
Number
(
action_body
.
org_id
));
action_body
.
org
=
await
this
.
orgSve
.
findById
(
Number
(
action_body
.
org_id
));
if
(
!
action_body
.
org
)
{
if
(
!
action_body
.
org
)
{
opResult
=
system
.
getResult
(
null
,
`当前SAAS不能删除`
);
return
system
.
getResult
(
null
,
`组织机构不存在`
);
}
else
{
}
opResult
=
this
.
userSve
.
upd
(
action_body
);
}
}
opResult
=
this
.
userSve
.
upd
(
action_body
);
break
;
break
;
case
"userInfo"
:
case
"userInfo"
:
opResult
=
this
.
userSve
.
info
(
action_body
);
opResult
=
this
.
userSve
.
info
(
action_body
);
break
;
break
;
case
"enabled"
:
opResult
=
this
.
userSve
.
enabled
(
action_body
);
break
;
case
"delUser"
:
case
"delUser"
:
opResult
=
this
.
userSve
.
delUser
(
action_body
);
break
;
break
;
case
"
listUser
"
:
case
"
userPage
"
:
opResult
=
this
.
userSve
.
pageByCondition
(
action_body
);
opResult
=
this
.
userSve
.
pageByCondition
(
action_body
);
break
;
break
;
}
}
...
...
xggsve-uc/app/base/db/impl/auth/authDao.js
View file @
4e8ca5d1
...
@@ -5,8 +5,19 @@ class AuthDao extends Dao {
...
@@ -5,8 +5,19 @@ class AuthDao extends Dao {
super
(
Dao
.
getModelName
(
AuthDao
));
super
(
Dao
.
getModelName
(
AuthDao
));
}
}
async
all
()
{
async
all
(
saas_id
,
attrs
)
{
return
this
.
customQuery
(
"SELECT * FROM uc_auth WHERE deleted_at IS NULL"
);
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
;
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 {
...
@@ -38,7 +38,7 @@ class UserDao extends Dao {
sql
.
push
(
"count(1) as num"
);
sql
.
push
(
"count(1) as num"
);
sql
.
push
(
"FROM uc_user t1"
);
sql
.
push
(
"FROM uc_user t1"
);
sql
.
push
(
"INNER JOIN uc_user_info t2 ON t1.id = t2.id"
);
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
);
var
list
=
await
this
.
customQuery
(
sql
.
join
(
" "
),
params
);
if
(
!
list
||
list
.
length
==
0
)
{
if
(
!
list
||
list
.
length
==
0
)
{
...
@@ -58,7 +58,7 @@ class UserDao extends Dao {
...
@@ -58,7 +58,7 @@ class UserDao extends Dao {
sql
.
push
(
"t2.mobile, t2.realName"
);
sql
.
push
(
"t2.mobile, t2.realName"
);
sql
.
push
(
"FROM uc_user t1"
);
sql
.
push
(
"FROM uc_user t1"
);
sql
.
push
(
"INNER JOIN uc_user_info t2 ON t1.id = t2.id"
);
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
);
this
.
setCondition
(
sql
,
params
);
...
@@ -67,7 +67,7 @@ class UserDao extends Dao {
...
@@ -67,7 +67,7 @@ class UserDao extends Dao {
return
await
this
.
customQuery
(
sql
.
join
(
" "
),
params
);
return
await
this
.
customQuery
(
sql
.
join
(
" "
),
params
);
}
}
setCondition
(
params
,
sql
)
{
setCondition
(
sql
,
params
)
{
if
(
!
params
||
!
sql
)
{
if
(
!
params
||
!
sql
)
{
return
;
return
;
}
}
...
@@ -98,6 +98,10 @@ class UserDao extends Dao {
...
@@ -98,6 +98,10 @@ class UserDao extends Dao {
if
(
params
.
createEnd
)
{
if
(
params
.
createEnd
)
{
sql
.
push
(
"AND t1.created_at <= :createEnd"
);
sql
.
push
(
"AND t1.created_at <= :createEnd"
);
}
}
if
(
params
.
isEnabled
===
0
||
params
.
isEnabled
===
1
)
{
sql
.
push
(
"AND t1.isEnabled = :isEnabled"
);
}
}
}
}
}
module
.
exports
=
UserDao
;
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 {
...
@@ -12,8 +12,9 @@ class UserroleDao extends Dao {
},
t
)
||
[];
},
t
)
||
[];
}
}
async
listByUserId
(
user_id
,
t
)
{
async
listByUserId
(
user_id
,
attrs
,
t
)
{
var
sql
=
"SELECT * FROM uc_user_role WHERE user_id = :user_id"
;
attrs
=
attrs
||
"*"
;
var
sql
=
"SELECT "
+
attrs
+
" FROM uc_user_role WHERE user_id = :user_id"
;
return
await
this
.
customQuery
(
sql
,
{
return
await
this
.
customQuery
(
sql
,
{
user_id
:
user_id
user_id
:
user_id
},
t
)
||
[];
},
t
)
||
[];
...
...
xggsve-uc/app/base/db/models/user/userrole.js
View file @
4e8ca5d1
...
@@ -4,7 +4,7 @@ const uiconfig = system.getUiConfig2(settings.appKey);
...
@@ -4,7 +4,7 @@ const uiconfig = system.getUiConfig2(settings.appKey);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"userrole"
,
{
return
db
.
define
(
"userrole"
,
{
user_id
:
DataTypes
.
INTEGER
,
user_id
:
DataTypes
.
INTEGER
,
org
_id
:
DataTypes
.
INTEGER
,
role
_id
:
DataTypes
.
INTEGER
,
},
{
},
{
paranoid
:
true
,
//假的删除
paranoid
:
true
,
//假的删除
underscored
:
true
,
underscored
:
true
,
...
...
xggsve-uc/app/base/service/impl/auth/authSve.js
View file @
4e8ca5d1
...
@@ -12,7 +12,7 @@ class AuthService extends ServiceBase {
...
@@ -12,7 +12,7 @@ class AuthService extends ServiceBase {
var
pid
=
Number
(
obj
.
pid
||
0
);
var
pid
=
Number
(
obj
.
pid
||
0
);
if
(
!
saas_id
)
{
if
(
!
saas_id
)
{
return
system
.
getResult
(
null
,
"
请指定saas_id
"
);
return
system
.
getResult
(
null
,
"
saas_id不存在
"
);
}
}
if
(
pid
===
0
)
{
if
(
pid
===
0
)
{
...
@@ -47,7 +47,7 @@ class AuthService extends ServiceBase {
...
@@ -47,7 +47,7 @@ class AuthService extends ServiceBase {
}
}
var
auth
=
await
this
.
findById
(
id
);
var
auth
=
await
this
.
findById
(
id
);
if
(
!
saas_id
)
{
if
(
!
saas_id
)
{
return
system
.
getResult
(
null
,
"
请指定saas_id
"
);
return
system
.
getResult
(
null
,
"
saas_id不存在
"
);
}
}
if
(
saas_id
!=
auth
.
saas_id
)
{
if
(
saas_id
!=
auth
.
saas_id
)
{
...
@@ -68,11 +68,11 @@ class AuthService extends ServiceBase {
...
@@ -68,11 +68,11 @@ class AuthService extends ServiceBase {
var
list
=
await
this
.
dao
.
findAll
({
var
list
=
await
this
.
dao
.
findAll
({
pid
:
obj
.
pid
||
0
,
pid
:
obj
.
pid
||
0
,
});
});
return
list
;
return
system
.
getResultSuccess
(
list
)
;
}
}
async
tree
()
{
async
tree
(
params
)
{
var
all
=
await
this
.
dao
.
all
();
var
all
=
await
this
.
dao
.
all
(
params
.
saas_id
,
"id, pid, menuType, name, icon, path"
);
var
pmap
=
{};
var
pmap
=
{};
for
(
var
item
of
all
)
{
for
(
var
item
of
all
)
{
...
@@ -87,8 +87,7 @@ class AuthService extends ServiceBase {
...
@@ -87,8 +87,7 @@ class AuthService extends ServiceBase {
for
(
var
item
of
all
)
{
for
(
var
item
of
all
)
{
item
.
childs
=
pmap
[
item
.
id
]
||
[];
item
.
childs
=
pmap
[
item
.
id
]
||
[];
}
}
return
system
.
getResultSuccess
(
pmap
[
0
][
0
]);
return
system
.
getResultSuccess
(
pmap
[
0
]);
}
}
async
info
(
obj
)
{
async
info
(
obj
)
{
...
...
xggsve-uc/app/base/service/impl/org/orgSve.js
View file @
4e8ca5d1
...
@@ -110,13 +110,25 @@ class OrgService extends ServiceBase {
...
@@ -110,13 +110,25 @@ class OrgService extends ServiceBase {
try
{
try
{
var
pid
=
Number
(
params
.
pid
||
0
);
var
pid
=
Number
(
params
.
pid
||
0
);
params
.
orgname
=
this
.
trim
(
params
.
orgname
);
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
,
`参数错误 组织名称不能为空`
)}
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
){
if
(
_orgByName
){
return
system
.
getResult
(
-
1
,
`参数错误 组织名称已经存在`
);
return
system
.
getResult
(
-
1
,
`参数错误 组织名称已经存在`
);
}
}
let
path
=
""
;
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
}
`
;
path
=
`/
${
params
.
orgname
}
`
;
}
else
{
}
else
{
let
_org
=
await
this
.
findOne
({
id
:
pid
});
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 {
...
@@ -39,7 +39,7 @@ class UserService extends ServiceBase {
async
add
(
obj
)
{
async
add
(
obj
)
{
var
roles
=
obj
.
roles
||
[];
var
roles
=
obj
.
roles
||
[];
var
org
=
obj
.
org
;
var
org
=
obj
.
org
||
{}
;
var
saas_id
=
Number
(
obj
.
saas_id
||
0
);
var
saas_id
=
Number
(
obj
.
saas_id
||
0
);
var
ucid
=
this
.
trim
(
obj
.
ucid
);
var
ucid
=
this
.
trim
(
obj
.
ucid
);
var
ucname
=
this
.
trim
(
obj
.
ucname
);
var
ucname
=
this
.
trim
(
obj
.
ucname
);
...
@@ -50,7 +50,7 @@ class UserService extends ServiceBase {
...
@@ -50,7 +50,7 @@ class UserService extends ServiceBase {
var
isMain
=
obj
.
isMain
||
0
;
var
isMain
=
obj
.
isMain
||
0
;
if
(
!
saas_id
)
{
if
(
!
saas_id
)
{
return
system
.
getResult
(
null
,
"
请指定saas_id
"
);
return
system
.
getResult
(
null
,
"
saas_id不存在
"
);
}
}
var
exist
=
await
this
.
findOne
({
var
exist
=
await
this
.
findOne
({
...
@@ -66,13 +66,13 @@ class UserService extends ServiceBase {
...
@@ -66,13 +66,13 @@ class UserService extends ServiceBase {
ucname
:
ucname
,
ucname
:
ucname
,
password
:
await
this
.
getEncryptStr
(
password
),
password
:
await
this
.
getEncryptStr
(
password
),
uctype
:
uctype
,
uctype
:
uctype
,
org_id
:
org
.
id
,
org_id
:
org
.
id
||
0
,
isMain
:
isMain
,
isMain
:
isMain
,
orgpath
:
""
,
orgpath
:
""
,
isEnabled
:
1
,
isEnabled
:
1
,
}
}
var
orgpath
=
org
.
path
;
var
orgpath
=
org
.
path
||
""
;
var
info
=
{
var
info
=
{
mobile
:
mobile
,
mobile
:
mobile
,
...
@@ -94,14 +94,14 @@ class UserService extends ServiceBase {
...
@@ -94,14 +94,14 @@ class UserService extends ServiceBase {
await
self
.
userroleDao
.
bulkCreate
(
roles
,
t
);
await
self
.
userroleDao
.
bulkCreate
(
roles
,
t
);
}
}
if
(
!
isMain
)
{
if
(
user
.
uctype
===
1
)
{
orgpath
=
orgpath
+
"/"
+
user
.
id
;
orgpath
=
isMain
?
orgpath
:
orgpath
+
"/"
+
user
.
id
;
}
user
.
orgpath
=
orgpath
;
await
self
.
dao
.
update
({
await
self
.
dao
.
update
({
id
:
user
.
id
,
id
:
user
.
id
,
orgpath
:
orgpath
orgpath
:
orgpath
},
t
);
},
t
);
}
user
.
orgpath
=
orgpath
;
return
user
;
return
user
;
});
});
...
@@ -111,7 +111,7 @@ class UserService extends ServiceBase {
...
@@ -111,7 +111,7 @@ class UserService extends ServiceBase {
async
upd
(
obj
)
{
async
upd
(
obj
)
{
var
id
=
obj
.
id
;
var
id
=
obj
.
id
;
var
roles
=
obj
.
roles
||
[];
var
roles
=
obj
.
roles
||
[];
var
org
=
obj
.
org
;
var
org
=
obj
.
org
||
{}
;
var
uctype
=
this
.
trim
(
obj
.
uctype
);
var
uctype
=
this
.
trim
(
obj
.
uctype
);
var
mobile
=
this
.
trim
(
obj
.
mobile
);
var
mobile
=
this
.
trim
(
obj
.
mobile
);
var
realName
=
this
.
trim
(
obj
.
realName
);
var
realName
=
this
.
trim
(
obj
.
realName
);
...
@@ -119,11 +119,13 @@ class UserService extends ServiceBase {
...
@@ -119,11 +119,13 @@ class UserService extends ServiceBase {
var
user
=
{
var
user
=
{
id
:
id
,
id
:
id
,
org_id
:
org
.
id
,
org_id
:
org
.
id
||
""
,
orgpath
:
isMain
?
org
.
path
:
org
.
path
+
"/"
+
id
,
orgpath
:
""
,
isMain
:
obj
.
isMain
||
0
,
isMain
:
obj
.
isMain
||
0
,
}
}
if
(
user
.
uctype
===
1
)
{
user
.
orgpath
=
isMain
?
org
.
path
:
org
.
path
+
"/"
+
id
;
}
var
info
=
{
var
info
=
{
id
:
id
,
id
:
id
,
mobile
:
mobile
,
mobile
:
mobile
,
...
@@ -159,11 +161,21 @@ class UserService extends ServiceBase {
...
@@ -159,11 +161,21 @@ class UserService extends ServiceBase {
user
.
mobile
=
info
.
mobile
;
user
.
mobile
=
info
.
mobile
;
user
.
realName
=
info
.
realName
;
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
);
this
.
handleDate
(
user
,
[
"created_at"
],
null
,
-
8
);
return
system
.
getResultSuccess
(
user
);
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
)
{
async
pageByCondition
(
params
)
{
var
result
=
{
var
result
=
{
count
:
0
,
count
:
0
,
...
@@ -180,17 +192,24 @@ class UserService extends ServiceBase {
...
@@ -180,17 +192,24 @@ class UserService extends ServiceBase {
result
.
count
=
total
;
result
.
count
=
total
;
params
.
startRow
=
(
currentPage
-
1
)
*
pageSize
;
params
.
startRow
=
(
currentPage
-
1
)
*
pageSize
;
result
.
rows
=
await
this
.
dao
.
listByCondition
(
params
)
||
[];
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
);
return
system
.
getResultSuccess
(
result
);
}
}
async
delUser
(
params
)
{
async
delUser
(
params
)
{
await
this
.
delete
({
var
user
=
await
this
.
findById
(
params
.
id
);
id
:
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
();
return
system
.
getResultSuccess
();
}
}
}
}
module
.
exports
=
UserService
;
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