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
e66a731d
Commit
e66a731d
authored
Mar 24, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
46b00a80
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
199 deletions
+76
-199
xggsve-uc/app/base/api/impl/op/action.js
+0
-0
xggsve-uc/app/base/db/impl/user/saasmerchantappletuserDao.js
+5
-5
xggsve-uc/app/base/db/models/user/saasmerchantappletuser.js
+4
-7
xggsve-uc/app/base/service/impl/user/saasmerchantappletuserSve.js
+67
-0
xggsve-uc/app/base/service/impl/user/saasmerchantappuserSve.js
+0
-187
No files found.
xggsve-uc/app/base/api/impl/op/action.js
View file @
e66a731d
This diff is collapsed.
Click to expand it.
xggsve-uc/app/base/db/impl/user/saasmerchantappuserDao.js
→
xggsve-uc/app/base/db/impl/user/saasmerchantapp
let
userDao.js
View file @
e66a731d
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
SaasMerchantAppUserDao
extends
Dao
{
class
SaasMerchantApp
let
UserDao
extends
Dao
{
constructor
()
{
super
(
Dao
.
getModelName
(
SaasMerchantAppUserDao
));
super
(
Dao
.
getModelName
(
SaasMerchantApp
let
UserDao
));
}
async
byOpenId
(
openid
,
saasMerchantId
)
{
var
sql
=
"SELECT * FROM uc_user WHERE openid = :openid AND saas_merchant_id = :saasMerchantId AND deleted_at IS NULL"
;
var
sql
=
`SELECT * FROM
${
this
.
model
.
tableName
}
WHERE openid = :openid AND saas_merchant_id = :saasMerchantId AND deleted_at IS NULL`
;
var
list
=
await
this
.
customQuery
(
sql
,
{
openid
:
openid
,
saasMerchantId
:
saasMerchantId
,
...
...
@@ -18,4 +18,4 @@ class SaasMerchantAppUserDao extends Dao {
}
}
module
.
exports
=
SaasMerchantAppUserDao
;
\ No newline at end of file
module
.
exports
=
SaasMerchantAppletUserDao
;
\ No newline at end of file
xggsve-uc/app/base/db/models/user/saasmerchantappuser.js
→
xggsve-uc/app/base/db/models/user/saasmerchantapp
let
user.js
View file @
e66a731d
...
...
@@ -2,16 +2,13 @@ const system = require("../../../system");
const
settings
=
require
(
"../../../../config/settings"
);
const
uiconfig
=
system
.
getUiConfig2
(
settings
.
appKey
);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"saasmerchantuser"
,
{
return
db
.
define
(
"saasmerchant
applet
user"
,
{
openid
:
DataTypes
.
STRING
,
ucname
:
DataTypes
.
STRING
,
mobile
:
DataTypes
.
STRING
,
realName
:
DataTypes
.
STRING
,
nickName
:
DataTypes
.
STRING
,
avatarUrl
:
DataTypes
.
STRING
,
password
:
DataTypes
.
STRING
,
isMain
:
{
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
true
},
isEnabled
:
{
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
true
...
...
@@ -25,7 +22,7 @@ module.exports = (db, DataTypes) => {
freezeTableName
:
true
,
//freezeTableName: true,
// define the table's name
tableName
:
'saas_
platform
_user'
,
tableName
:
'saas_
merchant_applet
_user'
,
validate
:
{
},
...
...
xggsve-uc/app/base/service/impl/user/saasmerchantappletuserSve.js
0 → 100644
View file @
e66a731d
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
)
const
settings
=
require
(
"../../../../config/settings"
)
class
SaasMerchantAppletUserService
extends
ServiceBase
{
constructor
()
{
super
(
"user"
,
ServiceBase
.
getDaoName
(
SaasMerchantAppletUserService
));
}
async
appletLogin
(
obj
)
{
let
saas_merchant_id
=
obj
.
saas_merchant_id
;
let
saas_id
=
obj
.
saas_id
;
let
openid
=
obj
.
openid
;
let
nickName
=
this
.
trim
(
obj
.
nickName
);
let
avatarUrl
=
this
.
trim
(
obj
.
avatarUrl
);
if
(
!
saas_merchant_id
)
{
return
system
.
getResult
(
null
,
"登录失败,商户信息错误"
);
}
if
(
!
openid
)
{
return
system
.
getResult
(
null
,
"登录信息获取失败"
);
}
let
user
=
await
this
.
dao
.
byOpenId
(
openid
,
saas_merchant_id
);
if
(
!
user
)
{
user
=
{
openid
:
openid
,
nickName
:
nickName
,
avatarUrl
:
avatarUrl
,
saas_merchant_id
:
saas_merchant_id
,
saas_id
:
saas_id
,
mobile
:
""
,
ucname
:
""
,
password
:
""
,
isEnabled
:
true
,
};
user
=
await
this
.
dao
.
model
.
create
(
user
);
}
else
{
if
(
avatarUrl
)
{
user
.
avatarUrl
=
avatarUrl
;
await
this
.
dao
.
update
({
id
:
user
.
id
,
avatarUrl
:
avatarUrl
,
});
}
if
(
nickName
)
{
this
.
dao
.
update
({
id
:
user
.
id
,
nickName
:
nickName
});
}
}
return
system
.
getResultSuccess
(
user
);
}
async
info
(
params
)
{
let
user
=
await
this
.
dao
.
byOpenId
(
params
.
openid
,
params
.
merchant_id
);
return
system
.
getResultSuccess
(
user
);
}
async
mapByIds
(
params
)
{
let
rs
=
await
this
.
dao
.
findMapByIds
(
params
.
ids
);
return
system
.
getResultSuccess
(
rs
);
}
}
module
.
exports
=
SaasMerchantAppletUserService
;
\ No newline at end of file
xggsve-uc/app/base/service/impl/user/saasmerchantappuserSve.js
deleted
100644 → 0
View file @
46b00a80
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
)
const
settings
=
require
(
"../../../../config/settings"
)
class
SaasMerchantAppUserService
extends
ServiceBase
{
constructor
()
{
super
(
"user"
,
ServiceBase
.
getDaoName
(
SaasMerchantAppUserService
));
}
async
login
(
obj
)
{
var
uctype
=
Number
(
obj
.
uctype
||
0
);
var
user
=
await
this
.
dao
.
getByUcname
(
obj
.
ucname
);
// 验证登录合法
if
(
!
user
)
{
return
system
.
getResult
(
null
,
"用户名或密码错误"
);
}
if
(
!
user
.
isEnabled
)
{
return
system
.
getResult
(
null
,
"用户已禁用"
);
}
if
(
uctype
&&
uctype
!=
user
.
uctype
)
{
return
system
.
getResult
(
null
,
"用户类型错误"
);
}
var
loginPwd
=
await
this
.
getEncryptStr
(
obj
.
password
);
if
(
loginPwd
!=
user
.
password
)
{
return
system
.
getResult
(
null
,
"用户名或密码错误"
);
}
await
this
.
setLoginUser
(
user
);
return
system
.
getResultSuccess
(
user
);
}
async
saveUser
(
obj
)
{
try
{
var
id
=
obj
.
id
;
var
roleIds
=
obj
.
roles
||
[];
var
org_id
=
this
.
trim
(
obj
.
org_id
);
let
roles
=
[];
for
(
let
roleId
of
roleIds
)
{
roles
.
push
({
role_id
:
roleId
});
}
if
(
!
obj
.
saas_id
)
{
return
system
.
getResult
(
null
,
"saas_id不存在"
);
}
let
user
=
{};
if
(
id
)
{
let
u
=
await
this
.
findById
(
id
);
if
(
u
)
{
user
.
id
=
u
.
id
;
}
}
let
exist
=
await
this
.
findOne
({
ucname
:
obj
.
ucname
});
if
(
user
.
id
)
{
if
(
exist
&&
exist
.
id
!=
user
.
id
)
{
return
system
.
getResult
(
null
,
`用户名【
${
ucname
}
】已存在`
);
}
}
else
{
if
(
exist
)
{
return
system
.
getResult
(
null
,
`用户名【
${
ucname
}
】已存在`
);
}
user
.
password
=
await
this
.
getEncryptStr
(
obj
.
password
);
}
let
org
=
await
this
.
orgDao
.
findById
(
org_id
);
if
(
!
org
)
{
return
system
.
getResult
(
null
,
`组织机构不存在`
);
}
user
.
ucid
=
this
.
trim
(
obj
.
ucid
);
user
.
ucname
=
this
.
trim
(
obj
.
ucname
);
user
.
uctype
=
1
;
user
.
uctypeId
=
""
;
user
.
mobile
=
this
.
trim
(
obj
.
mobile
);
user
.
realName
=
this
.
trim
(
obj
.
realName
);
user
.
org_id
=
org_id
;
user
.
saas_id
=
this
.
trim
(
obj
.
saas_id
);
var
self
=
this
;
user
=
await
self
.
db
.
transaction
(
async
function
(
t
)
{
if
(
user
.
id
)
{
await
self
.
dao
.
update
(
user
,
t
);
}
else
{
// 创建商户
user
=
await
self
.
dao
.
create
(
user
,
t
);
}
await
self
.
userroleDao
.
delByUserId
(
user
.
id
,
t
);
if
(
roles
&&
roles
.
length
>
0
)
{
for
(
var
r
of
roles
)
{
r
.
user_id
=
user
.
id
;
}
await
self
.
userroleDao
.
bulkCreate
(
roles
,
t
);
}
user
.
orgpath
=
org
.
path
+
"/"
+
user
.
id
+
"/"
;
await
self
.
dao
.
update
({
id
:
user
.
id
,
orgpath
:
user
.
orgpath
},
t
);
return
user
;
});
return
system
.
getResultSuccess
(
user
);
}
catch
(
error
)
{
console
.
log
(
error
);
if
(
error
.
name
==
'SequelizeValidationError'
)
{
return
system
.
getResult
(
-
1
,
`用户名重复`
);
}
return
system
.
getResult
(
-
1
,
`系统错误 错误信息
${
error
}
`
);
}
}
async
info
(
params
)
{
var
id
=
Number
(
params
.
id
||
0
);
var
user
=
await
this
.
dao
.
getById
(
id
);
if
(
!
user
)
{
return
system
.
getResult
(
null
,
"用户不存在"
);
}
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
,
rows
:
[]
};
var
currentPage
=
Number
(
params
.
currentPage
||
1
);
var
pageSize
=
Number
(
params
.
pageSize
||
10
);
if
(
params
.
orgpath
)
{
params
.
orgpath
=
params
.
orgpath
+
"%"
;
}
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
);
}
await
this
.
setRoles
(
result
.
rows
);
await
this
.
setOrg
(
result
.
rows
);
}
return
system
.
getResultSuccess
(
result
);
}
async
updPassword
(
params
)
{
var
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
();
}
async
mapByIds
(
params
)
{
let
rs
=
await
this
.
dao
.
findMapByIds
(
params
.
ids
);
return
system
.
getResultSuccess
(
rs
);
}
}
module
.
exports
=
SaasMerchantAppUserService
;
\ 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