Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taobao-mini-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinhaitao
taobao-mini-template
Commits
137dfd58
Commit
137dfd58
authored
Nov 04, 2020
by
qinhaitao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor:
💡
login
parent
51ec8a9c
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
23 deletions
+48
-23
index.d.ts
v2.0/dist/index.d.ts
+2
-2
user.service.d.ts
v2.0/dist/service/user.service.d.ts
+1
-0
user.service.js
v2.0/dist/service/user.service.js
+31
-12
user.service.js.map
v2.0/dist/service/user.service.js.map
+1
-1
login.controller.ts
v2.0/src/controller/login.controller.ts
+2
-7
user.service.ts
v2.0/src/service/user.service.ts
+11
-1
No files found.
v2.0/dist/index.d.ts
View file @
137dfd58
...
...
@@ -27,12 +27,12 @@ declare const _default: {
list
:
IAwards
[];
}
>>
;
receiveObjectPrize
:
(
context
:
IContext
<
import
(
"./controller/awards.controller"
).
IReceiveOjectParams
>
,
{
activityInfo
}:
import
(
"./controller/awards.controller"
).
IReceivePrizeControllerInfos
,
[
awardSer
]:
[
import
(
"./service"
).
AwardsService
])
=>
Promise
<
IResult
<
boolean
>>
;
receiveEnamePrize
:
(
context
:
IContext
<
import
(
"./controller/awards.controller"
).
IReceiveEnameParams
>
,
{
awardInfo
,
session
}:
import
(
"./controller/awards.controller"
).
IReceivePrizeControllerInfos
,
[
awardSer
]:
[
import
(
"./service"
).
AwardsService
])
=>
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
string
|
boolean
|
object
|
string
[]
|
object
[]
|
number
[],
false
>
|
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
IAwards
|
import
(
"taobao-mini-sdk/lib/utils/codetypes"
).
CodeType
,
true
>>
;
receiveEnamePrize
:
(
context
:
IContext
<
import
(
"./controller/awards.controller"
).
IReceiveEnameParams
>
,
{
awardInfo
,
session
}:
import
(
"./controller/awards.controller"
).
IReceivePrizeControllerInfos
,
[
awardSer
]:
[
import
(
"./service"
).
AwardsService
])
=>
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
string
|
boolean
|
object
|
string
[]
|
number
[]
|
object
[],
false
>
|
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
import
(
"taobao-mini-sdk/lib/utils/codetypes"
).
CodeType
|
IAwards
,
true
>>
;
doHelp
:
(
context
:
IContext
<
{
activityId
:
string
;
inviteId
:
string
;
}
>
,
{
userInfo
,
activityInfo
,
inviteUserInfo
}:
import
(
"./controller/share.controller"
).
IdoHelpInfos
,
[
taskService
,
statService
]:
[
import
(
"./service"
).
TaskService
,
import
(
"./service"
).
StatService
])
=>
Promise
<
IResult
<
boolean
>>
;
getStats
:
(
context
:
IContext
<
import
(
"./controller/stat.controller"
).
IGetStatsParams
>
)
=>
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
string
|
boolean
|
object
|
string
[]
|
object
[]
|
number
[],
false
>
|
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
any
,
true
>>
;
getStats
:
(
context
:
IContext
<
import
(
"./controller/stat.controller"
).
IGetStatsParams
>
)
=>
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
string
|
boolean
|
object
|
string
[]
|
number
[]
|
object
[],
false
>
|
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
any
,
true
>>
;
addStat
:
(
context
:
IContext
<
import
(
"./controller/stat.controller"
).
IAddStatsParams
>
,
{
userInfo
}:
IControllerInfos
,
[
statService
]:
[
import
(
"./service"
).
StatService
])
=>
Promise
<
import
(
"taobao-mini-sdk/lib/utils/resultmodel"
).
Result
<
boolean
,
true
>>
;
getRankList
:
(
context
:
IContext
<
{
activityId
:
string
;
...
...
v2.0/dist/service/user.service.d.ts
View file @
137dfd58
...
...
@@ -19,6 +19,7 @@ declare class UserService extends BaseService {
* @returns 若用户不存在,返回null; 用户存在,返回用户信息(object对象)
*/
getUserInfoByOpenId
(
openId
:
string
):
Promise
<
IUserInfo
>
;
doLogin
(
userInfo
:
IUserInfo
,
vipInfo
:
IVipInfo
,
activityInfo
:
IActivityInfo
):
Promise
<
IUserInfo
>
;
/**
* 初始化用户数据
*
...
...
v2.0/dist/service/user.service.js
View file @
137dfd58
...
...
@@ -120,6 +120,25 @@ var UserService = /** @class */ (function (_super) {
});
});
};
UserService
.
prototype
.
doLogin
=
function
(
userInfo
,
vipInfo
,
activityInfo
)
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
return
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
case
0
:
if
(
!!
userInfo
)
return
[
3
/*break*/
,
2
];
return
[
4
/*yield*/
,
this
.
initUserData
(
vipInfo
,
activityInfo
)];
case
1
:
userInfo
=
_a
.
sent
();
return
[
3
/*break*/
,
4
];
case
2
:
return
[
4
/*yield*/
,
this
.
updateUserData
(
vipInfo
,
userInfo
,
activityInfo
)];
case
3
:
userInfo
=
_a
.
sent
();
_a
.
label
=
4
;
case
4
:
return
[
2
/*return*/
,
userInfo
];
}
});
});
};
/**
* 初始化用户数据
*
...
...
@@ -130,17 +149,17 @@ var UserService = /** @class */ (function (_super) {
*/
UserService
.
prototype
.
initUserData
=
function
(
vipInfo
,
activityInfo
)
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
_a
,
openId
,
data
,
activityId
,
isFollow
,
avatar
,
inviteId
,
userNick
,
today
,
tasks
,
follow
,
member
,
user
;
var
_
b
,
_c
;
return
__generator
(
this
,
function
(
_
d
)
{
switch
(
_
d
.
label
)
{
var
_a
,
openId
,
data
,
activityId
,
isFollow
,
avatar
,
inviteId
,
userNick
,
today
,
tasks
,
_b
,
follow
,
_c
,
member
,
user
;
var
_
d
,
_e
;
return
__generator
(
this
,
function
(
_
f
)
{
switch
(
_
f
.
label
)
{
case
0
:
_a
=
this
.
context
,
openId
=
_a
.
openId
,
data
=
_a
.
data
;
activityId
=
data
.
activityId
,
isFollow
=
data
.
isFollow
,
avatar
=
data
.
avatar
,
inviteId
=
data
.
inviteId
,
userNick
=
data
.
userNick
;
today
=
utils_1
.
getToday
();
console
.
log
(
"----------"
+
today
+
"----------"
,
today
);
tasks
=
activityInfo
.
tasks
;
follow
=
tasks
.
follow
,
member
=
tasks
.
member
;
_b
=
tasks
.
follow
,
follow
=
_b
===
void
0
?
{}
:
_b
,
_c
=
tasks
.
member
,
member
=
_c
===
void
0
?
{}
:
_c
;
user
=
{
activityId
:
activityId
,
avatar
:
avatar
,
...
...
@@ -158,12 +177,12 @@ var UserService = /** @class */ (function (_super) {
follow
:
{
flag
:
!!
isFollow
},
login
:
(
_
b
=
{},
_
b
[
today
]
=
1
,
_
b
),
taskInfo
:
(
_
c
=
{},
_
c
[
today
]
=
{},
_
c
),
login
:
(
_
d
=
{},
_
d
[
today
]
=
1
,
_
d
),
taskInfo
:
(
_
e
=
{},
_
e
[
today
]
=
{},
_
e
),
createTime
:
Date
.
now
(),
createDay
:
today
,
updateTime
:
Date
.
now
()
...
...
@@ -178,7 +197,7 @@ var UserService = /** @class */ (function (_super) {
}
return
[
4
/*yield*/
,
this
.
userdao
.
insertOne
(
user
)];
case
1
:
_
d
.
sent
();
_
f
.
sent
();
return
[
2
/*return*/
,
user
];
}
});
...
...
v2.0/dist/service/user.service.js.map
View file @
137dfd58
This diff is collapsed.
Click to expand it.
v2.0/src/controller/login.controller.ts
View file @
137dfd58
...
...
@@ -28,14 +28,9 @@ export default class User {
):
Promise
<
IResult
<
{
openId
:
string
}
>>
{
const
{
openId
}
=
context
if
(
!
userInfo
)
{
userInfo
=
await
userService
.
initUserData
(
vipInfo
,
activityInfo
)
}
else
{
userInfo
=
await
userService
.
updateUserData
(
vipInfo
,
userInfo
,
activityInfo
)
}
const
updatedUserInfo
=
await
userService
.
doLogin
(
userInfo
,
vipInfo
,
activityInfo
)
// access表
await
accessService
.
addAccess
(
userInfo
)
await
accessService
.
addAccess
(
u
pdatedU
serInfo
)
return
resultsModel
.
success
({
openId
...
...
v2.0/src/service/user.service.ts
View file @
137dfd58
...
...
@@ -11,6 +11,7 @@ import { getToday, formatUpdateUserProjection } from '../utils'
import
{
isNewVip
}
from
'../utils/common/userUpdate'
import
{
formatUserNick
}
from
'../utils/common/format'
import
{
getShopVip
,
formatVipCbUrl
}
from
'../utils/common/vip'
import
{
userInfo
}
from
'os'
class
UserService
extends
BaseService
{
userdao
:
IBaseDao
constructor
(
context
:
IContext
<
IParams
>
)
{
...
...
@@ -40,6 +41,15 @@ class UserService extends BaseService {
return
record
}
async
doLogin
(
userInfo
:
IUserInfo
,
vipInfo
:
IVipInfo
,
activityInfo
:
IActivityInfo
)
{
if
(
!
userInfo
)
{
userInfo
=
await
this
.
initUserData
(
vipInfo
,
activityInfo
)
}
else
{
userInfo
=
await
this
.
updateUserData
(
vipInfo
,
userInfo
,
activityInfo
)
}
return
userInfo
}
/**
* 初始化用户数据
*
...
...
@@ -54,7 +64,7 @@ class UserService extends BaseService {
const
today
=
getToday
()
console
.
log
(
`----------
${
today
}
----------`
,
today
)
const
{
tasks
}
=
activityInfo
const
{
follow
,
member
}
=
tasks
const
{
follow
=
{}
as
ITaskConfig
,
member
=
{}
as
ITaskConfig
}
=
tasks
const
user
:
IUserInfo
=
{
activityId
,
avatar
,
...
...
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