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
9bb96eab
Commit
9bb96eab
authored
May 28, 2020
by
孙亚楠
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'xggsve-uc' of gitlab.gongsibao.com:jiangyong/zhichan into xggsve-uc
parents
68bbad97
e64617cf
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
126 additions
and
70 deletions
+126
-70
xggsve-uc/app/base/api/impl/op/action.js
+5
-2
xggsve-uc/app/base/db/impl/user/saasplatformuserDao.js
+7
-6
xggsve-uc/app/base/service/impl/saas/saasbusinessSve.js
+19
-16
xggsve-uc/app/base/service/impl/user/saasplatformuserSve.js
+94
-45
xggsve-uc/app/base/service/sve.base.js
+1
-1
No files found.
xggsve-uc/app/base/api/impl/op/action.js
View file @
9bb96eab
...
@@ -183,8 +183,11 @@ class ActionAPI extends APIBase {
...
@@ -183,8 +183,11 @@ class ActionAPI extends APIBase {
case
"platformLogin"
:
case
"platformLogin"
:
opResult
=
await
this
.
saasplatformuserSve
.
login
(
action_body
);
opResult
=
await
this
.
saasplatformuserSve
.
login
(
action_body
);
break
;
break
;
case
"platformRegisterInner"
:
case
"platformUserSave"
:
opResult
=
await
this
.
saasplatformuserSve
.
registerInner
(
action_body
);
opResult
=
await
this
.
saasplatformuserSve
.
save
(
action_body
);
break
;
case
"platformUserPage"
:
opResult
=
await
this
.
saasplatformuserSve
.
pageByCondition
(
action_body
);
break
;
break
;
case
"platformResetPasswordInner"
:
case
"platformResetPasswordInner"
:
opResult
=
await
this
.
saasplatformuserSve
.
resetPasswordInner
(
action_body
);
opResult
=
await
this
.
saasplatformuserSve
.
resetPasswordInner
(
action_body
);
...
...
xggsve-uc/app/base/db/impl/user/saasplatformuserDao.js
View file @
9bb96eab
...
@@ -88,19 +88,21 @@ class SaasPlatformUserDao extends Dao {
...
@@ -88,19 +88,21 @@ class SaasPlatformUserDao extends Dao {
if
(
params
.
saas_id
)
{
if
(
params
.
saas_id
)
{
sql
.
push
(
"AND saas_id = :saas_id"
);
sql
.
push
(
"AND saas_id = :saas_id"
);
}
}
if
(
params
.
channel_id
)
{
sql
.
push
(
"AND channel_id = :channel_id"
);
}
if
(
params
.
ucname
)
{
if
(
params
.
ucname
)
{
sql
.
push
(
"AND ucname
LIKE
:ucname"
);
sql
.
push
(
"AND ucname
=
:ucname"
);
}
}
if
(
params
.
mobile
)
{
if
(
params
.
mobile
)
{
sql
.
push
(
"AND mobile
LIKE
:mobile"
);
sql
.
push
(
"AND mobile
=
:mobile"
);
}
}
if
(
params
.
realName
)
{
if
(
params
.
realName
)
{
sql
.
push
(
"AND realName LIKE :realName"
);
params
.
realNameLike
=
`%
${
params
.
realName
}
%`
;
sql
.
push
(
"AND realName LIKE :realNameLike"
);
}
}
if
(
params
.
createBegin
)
{
if
(
params
.
createBegin
)
{
sql
.
push
(
"AND created_at >= :createBegin"
);
sql
.
push
(
"AND created_at >= :createBegin"
);
}
}
...
@@ -108,7 +110,6 @@ class SaasPlatformUserDao extends Dao {
...
@@ -108,7 +110,6 @@ class SaasPlatformUserDao extends Dao {
if
(
params
.
createEnd
)
{
if
(
params
.
createEnd
)
{
sql
.
push
(
"AND created_at <= :createEnd"
);
sql
.
push
(
"AND created_at <= :createEnd"
);
}
}
if
(
params
.
isEnabled
===
0
||
params
.
isEnabled
===
1
)
{
if
(
params
.
isEnabled
===
0
||
params
.
isEnabled
===
1
)
{
sql
.
push
(
"AND isEnabled = :isEnabled"
);
sql
.
push
(
"AND isEnabled = :isEnabled"
);
}
}
...
...
xggsve-uc/app/base/service/impl/saas/saasbusinessSve.js
View file @
9bb96eab
...
@@ -23,35 +23,38 @@ class SaasBusinessService extends ServiceBase {
...
@@ -23,35 +23,38 @@ class SaasBusinessService extends ServiceBase {
let
passwd
=
this
.
trim
(
params
.
passwd
);
let
passwd
=
this
.
trim
(
params
.
passwd
);
let
realName
=
this
.
trim
(
params
.
realName
);
let
realName
=
this
.
trim
(
params
.
realName
);
try
{
try
{
let
exists
=
await
this
.
saasplatformuserDao
.
findOne
({
ucname
:
mobile
});
if
(
exists
)
{
return
system
.
getResult
(
null
,
`手机号[
${
mobile
}
]已存在`
)
}
let
sb
=
{
let
sb
=
{
name
:
companyName
,
name
:
companyName
,
domain
:
domain
,
domain
:
domain
,
managerMobile
:
mobile
,
managerMobile
:
mobile
,
};
};
if
(
saasid
)
{
if
(
saasid
)
{
exists
=
await
this
.
dao
.
findById
(
saasid
);
let
exists
=
await
this
.
dao
.
findById
(
saasid
);
if
(
exists
)
{
if
(
exists
)
{
return
system
.
getResult
(
null
,
`saas[
${
saasid
}
]已存在`
)
return
system
.
getResult
(
null
,
`saas[
${
saasid
}
]已存在`
)
}
}
sb
.
id
=
saasid
;
sb
.
id
=
saasid
;
}
}
sb
=
await
this
.
dao
.
create
(
sb
);
sb
=
await
this
.
dao
.
create
(
sb
);
let
user
=
await
this
.
saasplatformuserDao
.
create
({
ucname
:
mobile
,
realName
:
realName
,
password
:
await
this
.
getEncryptStr
(
passwd
),
isMian
:
true
,
saas_id
:
sb
.
id
,
isEnabled
:
true
,
});
sb
.
managerId
=
user
.
id
;
// 手机号存在,增加一个默认账号
await
sb
.
save
();
if
(
mobile
)
{
let
exists
=
await
this
.
saasplatformuserDao
.
findOne
({
ucname
:
mobile
});
if
(
exists
)
{
return
system
.
getResult
(
null
,
`手机号[
${
mobile
}
]已存在`
)
}
let
user
=
await
this
.
saasplatformuserDao
.
create
({
ucname
:
mobile
,
realName
:
realName
,
password
:
await
this
.
getEncryptStr
(
passwd
),
isMian
:
true
,
saas_id
:
sb
.
id
,
isEnabled
:
true
,
});
sb
.
managerId
=
user
.
id
;
await
sb
.
save
();
}
return
system
.
getResult
(
sb
);
return
system
.
getResult
(
sb
);
}
catch
(
error
)
{
}
catch
(
error
)
{
return
system
.
getResult
(
-
1
,
`系统错误 错误信息
${
error
.
stack
}
`
);
return
system
.
getResult
(
-
1
,
`系统错误 错误信息
${
error
.
stack
}
`
);
...
...
xggsve-uc/app/base/service/impl/user/saasplatformuserSve.js
View file @
9bb96eab
...
@@ -13,7 +13,7 @@ class SaasPlatformUserService extends ServiceBase {
...
@@ -13,7 +13,7 @@ class SaasPlatformUserService extends ServiceBase {
return
system
.
getResult
(
rs
);
return
system
.
getResult
(
rs
);
}
}
// 内部维护使用
// 内部维护使用
async
resetPasswordInner
(
params
)
{
async
resetPasswordInner
(
params
)
{
let
user
=
await
this
.
dao
.
findById
(
params
.
id
);
let
user
=
await
this
.
dao
.
findById
(
params
.
id
);
user
.
password
=
await
this
.
getEncryptStr
(
user
.
password
);
user
.
password
=
await
this
.
getEncryptStr
(
user
.
password
);
...
@@ -21,62 +21,21 @@ class SaasPlatformUserService extends ServiceBase {
...
@@ -21,62 +21,21 @@ class SaasPlatformUserService extends ServiceBase {
return
system
.
getResultSuccess
();
return
system
.
getResultSuccess
();
}
}
// 内部维护时使用
async
registerInner
(
params
)
{
let
ucname
=
this
.
trim
(
params
.
ucname
);
let
password
=
this
.
trim
(
params
.
password
);
let
realName
=
this
.
trim
(
params
.
realName
);
let
mobile
=
this
.
trim
(
params
.
mobile
);
let
saas_id
=
Number
(
params
.
saas_id
||
0
);
if
(
!
ucname
)
{
return
system
.
getResult
(
null
,
"请填写用户名"
);
}
if
(
!
password
)
{
return
system
.
getResult
(
null
,
"请填写密码"
);
}
let
pwd
=
await
this
.
getEncryptStr
(
password
);
console
.
log
(
`密码加密:
${
password
}
------->
${
pwd
}
`
);
let
saas
=
await
this
.
saasbusinessDao
.
findById
(
saas_id
);
if
(
!
saas
)
{
return
system
.
getResult
(
null
,
"saas不存在"
);
}
let
exists
=
await
this
.
dao
.
findOne
({
ucname
:
ucname
});
if
(
exists
)
{
return
system
.
getResult
(
null
,
`用户名[
${
ucname
}
]已存在`
);
}
let
user
=
{
ucname
:
ucname
,
mobile
:
mobile
,
realName
:
realName
,
password
:
pwd
,
saas_id
:
saas_id
,
isMain
:
true
,
isEnabled
:
true
,
}
user
=
await
this
.
dao
.
create
(
user
);
return
system
.
getResultSuccess
(
user
);
}
async
login
(
params
)
{
async
login
(
params
)
{
let
ucname
=
this
.
trim
(
params
.
ucname
);
let
ucname
=
this
.
trim
(
params
.
ucname
);
let
password
=
this
.
trim
(
params
.
password
);
let
password
=
this
.
trim
(
params
.
password
);
if
(
!
ucname
||
!
password
)
{
if
(
!
ucname
||
!
password
)
{
return
system
.
getResult
(
null
,
"用户名或密码错误"
);
return
system
.
getResult
(
null
,
"用户名或密码错误"
);
}
}
let
pwd
=
await
this
.
getEncryptStr
(
password
);
let
pwd
=
await
this
.
getEncryptStr
(
password
);
var
user
=
await
this
.
dao
.
byUcname
(
ucname
);
var
user
=
await
this
.
dao
.
byUcname
(
ucname
);
if
(
!
user
||
pwd
!=
user
.
password
)
{
if
(
!
user
||
pwd
!=
user
.
password
)
{
return
system
.
getResult
(
null
,
"用户名或密码错误"
);
return
system
.
getResult
(
null
,
"用户名或密码错误"
);
}
}
if
(
!
user
.
isEnabled
)
{
if
(
!
user
.
isEnabled
)
{
return
system
.
getResult
(
null
,
"用户已禁用"
);
return
system
.
getResult
(
null
,
"用户已禁用"
);
}
}
return
system
.
getResultSuccess
(
user
);
return
system
.
getResultSuccess
(
user
);
...
@@ -92,6 +51,84 @@ class SaasPlatformUserService extends ServiceBase {
...
@@ -92,6 +51,84 @@ class SaasPlatformUserService extends ServiceBase {
return
system
.
getResultSuccess
(
user
);
return
system
.
getResultSuccess
(
user
);
}
}
async
save
(
params
)
{
let
id
=
this
.
trim
(
params
.
id
);
let
ucname
=
this
.
trim
(
params
.
ucname
);
let
password
=
this
.
trim
(
params
.
password
);
let
realName
=
this
.
trim
(
params
.
realName
);
let
mobile
=
this
.
trim
(
params
.
mobile
);
let
channel_id
=
this
.
trim
(
params
.
channel_id
||
0
);
let
saas_id
=
this
.
trim
(
params
.
saas_id
||
0
);
let
saas
=
await
this
.
saasbusinessDao
.
findById
(
saas_id
);
if
(
!
saas
)
{
return
system
.
getResult
(
null
,
"saas不存在"
);
}
if
(
!
ucname
)
{
return
system
.
getResult
(
null
,
"请填写用户名"
);
}
let
user
;
if
(
id
)
{
user
=
await
this
.
dao
.
findById
(
id
);
}
else
{
user
=
{};
}
user
.
ucname
=
ucname
;
user
.
mobile
=
mobile
;
user
.
realName
=
realName
;
// 登录名验证
let
exists
=
await
this
.
dao
.
findOne
({
ucname
:
ucname
});
if
((
exists
&&
!
user
.
id
)
||
(
exists
&&
user
.
id
&&
user
.
id
!=
exists
.
id
))
{
return
system
.
getResult
(
null
,
`用户名[
${
ucname
}
]已存在`
);
}
let
encryptPassword
=
await
this
.
getEncryptStr
(
password
);
// 保存密码
if
(
user
.
id
)
{
// 传入密码为空或加密密码与数据库相同,不进行修改
if
(
encryptPassword
&&
encryptPassword
!=
user
.
password
)
{
user
.
password
=
encryptPassword
;
}
user
=
await
user
.
save
();
}
else
{
if
(
!
encryptPassword
)
{
return
system
.
getResult
(
null
,
"请填写密码"
);
}
user
.
saas_id
=
saas_id
;
user
.
channel_id
=
channel_id
;
user
.
isMain
=
false
;
user
.
isEnabled
=
true
;
user
.
password
=
encryptPassword
;
console
.
log
(
`密码加密:
${
password
}
------->
${
encryptPassword
}
`
);
user
=
await
this
.
dao
.
create
(
user
);
}
return
system
.
getResultSuccess
(
user
);
}
async
pageByCondition
(
params
)
{
var
result
=
{
count
:
0
,
rows
:
[]
};
var
currentPage
=
Number
(
params
.
currentPage
||
1
);
var
pageSize
=
Number
(
params
.
pageSize
||
10
);
var
total
=
await
this
.
dao
.
countByCondition
(
params
);
if
(
total
==
0
)
{
return
system
.
getResultSuccess
(
result
);
}
result
.
count
=
total
;
params
.
startRow
=
(
currentPage
-
1
)
*
pageSize
;
result
.
rows
=
await
this
.
dao
.
listByCondition
(
params
)
||
[];
if
(
result
.
rows
)
{
for
(
let
item
of
result
.
rows
)
{
this
.
handleDate
(
item
,
[
"created_at"
],
null
,
-
8
);
}
}
return
system
.
getResultSuccess
(
result
);
}
async
enabled
(
params
)
{
async
enabled
(
params
)
{
var
user
=
await
this
.
dao
.
findById
(
params
.
id
);
var
user
=
await
this
.
dao
.
findById
(
params
.
id
);
if
(
!
user
)
{
if
(
!
user
)
{
...
@@ -106,6 +143,17 @@ class SaasPlatformUserService extends ServiceBase {
...
@@ -106,6 +143,17 @@ class SaasPlatformUserService extends ServiceBase {
let
rs
=
await
this
.
dao
.
findMapByIds
(
params
.
ids
);
let
rs
=
await
this
.
dao
.
findMapByIds
(
params
.
ids
);
return
system
.
getResultSuccess
(
rs
);
return
system
.
getResultSuccess
(
rs
);
}
}
async
updPassword
(
params
)
{
let
user
=
await
this
.
findById
(
params
.
id
);
if
(
!
user
)
{
return
system
.
getResult
(
null
,
"用户不存在"
);
}
user
.
password
=
await
this
.
getEncryptStr
(
params
.
password
);
await
user
.
save
();
return
system
.
getResultSuccess
();
}
}
}
module
.
exports
=
SaasPlatformUserService
;
module
.
exports
=
SaasPlatformUserService
;
\ No newline at end of file
xggsve-uc/app/base/service/sve.base.js
View file @
9bb96eab
...
@@ -276,7 +276,7 @@ class ServiceBase {
...
@@ -276,7 +276,7 @@ class ServiceBase {
async
getEncryptStr
(
str
)
{
async
getEncryptStr
(
str
)
{
str
=
this
.
trim
(
str
);
str
=
this
.
trim
(
str
);
if
(
!
str
)
{
if
(
!
str
)
{
throw
new
Error
(
"字符串不能为空"
)
;
return
""
;
}
}
var
pwd
=
md5
(
str
+
"_"
+
settings
.
salt
);
var
pwd
=
md5
(
str
+
"_"
+
settings
.
salt
);
return
pwd
.
toString
().
toLowerCase
();
return
pwd
.
toString
().
toLowerCase
();
...
...
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