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
af0c15cf
Commit
af0c15cf
authored
Jan 09, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
030a7d63
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
123 additions
and
15 deletions
+123
-15
.gitignore
+4
-0
xggsve-uc/app/base/api/impl/op/action.js
+15
-9
xggsve-uc/app/base/db/impl/role/roleDao.js
+18
-0
xggsve-uc/app/base/db/impl/user/userDao.js
+57
-0
xggsve-uc/app/base/service/impl/user/userSve.js
+29
-6
No files found.
.gitignore
0 → 100644
View file @
af0c15cf
node_modules/
.vscode/
.idea/
xggsve-uc/app/base/api/impl/op/action.js
View file @
af0c15cf
...
...
@@ -131,7 +131,7 @@ class ActionAPI extends APIBase {
return
system
.
getResult
(
null
,
`组织机构不存在`
);
}
}
opResult
=
this
.
userSve
.
add
(
action_body
);
opResult
=
await
this
.
userSve
.
add
(
action_body
);
break
;
case
"updUser"
:
if
(
action_body
.
uctype
===
1
)
{
...
...
@@ -140,28 +140,34 @@ class ActionAPI extends APIBase {
return
system
.
getResult
(
null
,
`组织机构不存在`
);
}
}
opResult
=
this
.
userSve
.
upd
(
action_body
);
opResult
=
await
this
.
userSve
.
upd
(
action_body
);
break
;
case
"userInfo"
:
opResult
=
this
.
userSve
.
info
(
action_body
);
opResult
=
await
this
.
userSve
.
info
(
action_body
);
break
;
case
"enabled"
:
opResult
=
this
.
userSve
.
enabled
(
action_body
);
opResult
=
await
this
.
userSve
.
enabled
(
action_body
);
break
;
case
"delUser"
:
opResult
=
this
.
userSve
.
delUser
(
action_body
);
opResult
=
await
this
.
userSve
.
delUser
(
action_body
);
break
;
case
"userPage"
:
opResult
=
this
.
userSve
.
pageByCondition
(
action_body
);
opResult
=
await
this
.
userSve
.
pageByCondition
(
action_body
);
break
;
case
"updPassword"
:
opResult
=
this
.
userSve
.
updPassword
(
action_body
);
opResult
=
await
this
.
userSve
.
updPassword
(
action_body
);
break
;
case
"login"
:
opResult
=
this
.
userSve
.
login
(
action_body
);
opResult
=
await
this
.
userSve
.
login
(
action_body
);
break
;
case
"loginByUcid"
:
opResult
=
this
.
userSve
.
loginByUcid
(
action_body
);
opResult
=
await
this
.
userSve
.
loginByUcid
(
action_body
);
break
;
case
"mapUserByIds"
:
opResult
=
await
this
.
userSve
.
mapByIds
(
action_body
);
break
;
case
"findUsers"
:
opResult
=
await
this
.
userSve
.
findUsers
(
action_body
);
break
;
}
return
opResult
;
...
...
xggsve-uc/app/base/db/impl/role/roleDao.js
View file @
af0c15cf
...
...
@@ -15,5 +15,22 @@ class RoleDao extends Dao {
}
return
await
this
.
customQuery
(
sql
.
join
(
" "
),
params
);
}
async
findIdsByCode
(
codes
,
saas_id
)
{
if
(
!
codes
||
codes
.
length
==
0
)
{
return
[];
}
let
sql
=
"SELECT id FROM uc_role WHERE code IN (:codes) AND saas_id = :saas_id"
;
let
list
=
await
this
.
customQuery
(
sql
,
{
codes
:
codes
,
saas_id
:
saas_id
});
let
rs
=
[];
if
(
!
list
)
{
return
rs
;
}
for
(
let
item
of
list
)
{
rs
.
push
(
item
.
id
);
}
return
rs
;
}
}
module
.
exports
=
RoleDao
;
\ No newline at end of file
xggsve-uc/app/base/db/impl/user/userDao.js
View file @
af0c15cf
...
...
@@ -135,5 +135,61 @@ class UserDao extends Dao {
sql
.
push
(
"AND t1.orgpath LIKE :orgpath"
);
}
}
async
findMapByIds
(
ids
)
{
let
result
=
{};
if
(
!
ids
||
ids
.
length
==
0
)
{
return
result
;
}
let
sql
=
[];
sql
.
push
(
"SELECT"
);
sql
.
push
(
"t1.id, t1.ucid, t1.ucname, t1.uctype, t1.org_id, t1.orgpath,"
);
sql
.
push
(
"t1.isMain, t1.saas_id, t1.isEnabled, t1.created_at,"
);
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 t1.id IN (:ids)"
);
var
list
=
await
this
.
customQuery
(
sql
.
join
(
" "
),
{
ids
:
ids
});
if
(
!
list
||
list
.
length
==
0
)
{
return
result
;
}
for
(
var
item
of
list
)
{
result
[
item
.
id
]
=
item
;
}
return
result
;
}
async
findUsers
(
params
)
{
let
sql
=
[];
sql
.
push
(
"SELECT"
);
sql
.
push
(
"t1.id, t1.ucid, t1.ucname, t1.uctype, t1.org_id, t1.orgpath,"
);
sql
.
push
(
"t1.isMain, t1.saas_id, t1.isEnabled, t1.created_at,"
);
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
(
"INNER JOIN uc_user_role t3 ON t1.id = t3.user_id"
);
sql
.
push
(
"WHERE 1 = 1 "
);
if
(
params
.
roleIds
&&
params
.
roleIds
.
length
>
0
)
{
sql
.
push
(
"AND t3.role_id IN (:roleIds)"
);
}
if
(
params
.
uctype
)
{
sql
.
push
(
"AND t1.uctype = :uctype"
);
}
if
(
params
.
saas_id
)
{
sql
.
push
(
"AND t1.saas_id = :saas_id"
);
}
sql
.
push
(
"GROUP BY t1.id"
);
var
list
=
await
this
.
customQuery
(
sql
.
join
(
" "
),
params
);
if
(
!
list
||
list
.
length
==
0
)
{
return
[];
}
return
list
;
}
}
module
.
exports
=
UserDao
;
\ No newline at end of file
xggsve-uc/app/base/service/impl/user/userSve.js
View file @
af0c15cf
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
)
const
settings
=
require
(
"../../../../config/settings"
)
class
UserService
extends
ServiceBase
{
constructor
()
{
super
(
"user"
,
ServiceBase
.
getDaoName
(
UserService
));
...
...
@@ -9,12 +10,14 @@ class UserService extends ServiceBase {
this
.
authSve
=
system
.
getObject
(
"service.auth.authSve"
);
this
.
roleDao
=
system
.
getObject
(
"db.role.roleDao"
);
}
/**
* 条件查询
* @param {*} params
* @param {*} params
*/
async
apiFindUserBySaasId
(
params
)
{
try
{
...
...
@@ -26,9 +29,9 @@ class UserService extends ServiceBase {
/**
* 根据path查询所有的用户
* @param {*} params
* @param {*} params
*/
async
apiQueryUserByPath
(
params
){
async
apiQueryUserByPath
(
params
)
{
try
{
return
await
this
.
queryUserByPath
(
params
);
}
catch
(
error
)
{
...
...
@@ -41,7 +44,7 @@ class UserService extends ServiceBase {
/**
* 条件查询
* @param {*} params
* @param {*} params
*/
async
findUserBySaasId
(
params
)
{
try
{
...
...
@@ -64,7 +67,7 @@ class UserService extends ServiceBase {
return
system
.
getResult
(
null
,
"用户已禁用"
);
}
if
(
uctype
&&
uctype
!=
user
.
uctype
)
{
if
(
uctype
&&
uctype
!=
user
.
uctype
)
{
return
system
.
getResult
(
null
,
"用户类型错误"
);
}
...
...
@@ -269,7 +272,7 @@ class UserService extends ServiceBase {
};
var
currentPage
=
Number
(
params
.
currentPage
||
1
);
var
pageSize
=
Number
(
params
.
pageSize
||
10
);
if
(
params
.
orgpath
)
{
if
(
params
.
orgpath
)
{
params
.
orgpath
=
params
.
orgpath
+
"%"
;
}
...
...
@@ -313,5 +316,24 @@ class UserService extends ServiceBase {
await
user
.
save
();
return
system
.
getResultSuccess
();
}
async
mapByIds
(
params
)
{
let
rs
=
await
this
.
dao
.
findMapByIds
(
params
.
ids
);
return
system
.
getResultSuccess
(
rs
);
}
async
findUsers
(
params
)
{
if
(
params
.
roleCodes
&&
params
.
roleCodes
.
length
>
0
)
{
var
roleIds
=
await
this
.
roleDao
.
findIdsByCode
(
params
.
roleCodes
,
params
.
saas_id
);
if
(
!
roleIds
)
{
return
[];
}
params
.
roleIds
=
roleIds
;
}
let
rs
=
await
this
.
dao
.
findUsers
(
params
);
return
system
.
getResultSuccess
(
rs
);
}
}
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