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
71207cb3
Commit
71207cb3
authored
Nov 24, 2020
by
qinhaitao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
🎸
集卡接口
parent
e50a7390
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
76 additions
and
19 deletions
+76
-19
package.json
v2.0/package.json
+1
-2
card.controller.ts
v2.0/src/controller/card.controller.ts
+33
-0
customUser.ts
v2.0/src/customUser.ts
+7
-0
user.service.ts
v2.0/src/service/common/user.service.ts
+17
-10
dao.d.ts
v2.0/src/typings/dao.d.ts
+1
-1
user.d.ts
v2.0/src/typings/user.d.ts
+10
-6
initCustomUser.ts
v2.0/src/utils/common/initCustomUser.ts
+5
-0
index.ts
v2.0/src/utils/index.ts
+2
-0
No files found.
v2.0/package.json
View file @
71207cb3
...
...
@@ -16,8 +16,7 @@
},
"scripts"
:
{
"start"
:
"tsc"
,
"mock"
:
"cd mockServer && npm start"
,
"preinstall"
:
"cd mockServer && yarn"
"mock"
:
"cd mockServer && npm start"
},
"config"
:
{
"notNeedLogin"
:
[]
...
...
v2.0/src/controller/card.controller.ts
0 → 100644
View file @
71207cb3
/** @format */
import
{
services
,
checkParams
,
preCheck
,
preUpdate
}
from
'../decorator/common'
import
{
resultsModel
}
from
'../sdk'
import
{
CommonUserService
,
CommonGameService
}
from
'../service/common'
import
{
checkActivityTime
,
checkJoinId
,
checkUserInfo
,
checkVip
,
checkGameTimes
,
checkOpenPrizeStatus
}
from
'../utils/common/check'
import
{
updateUserInfo
,
reduceGameTimes
}
from
'../utils/common/update'
export
interface
ISumitGameControllerInfos
extends
IControllerInfos
{
joinInfo
:
IJoinRecord
}
export
default
class
Card
{
@
checkParams
([
'activityId'
])
@
services
([
CommonGameService
])
async
getCollectCardInfo
(
context
:
IContext
<
IParams
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
gameService
]:
[
CommonGameService
]
)
{
// const joinResult = await gameService.addJoinRecord(userInfo)
// return resultsModel.success({
// ...joinResult
// })
}
}
v2.0/src/customUser.ts
0 → 100644
View file @
71207cb3
/** @format */
export
const
customInitUserInfo
:
ICustomUserInfo
=
{
gameTimes
:
0
,
maxScore
:
0
,
totalScore
:
0
}
v2.0/src/service/common/user.service.ts
View file @
71207cb3
...
...
@@ -7,11 +7,11 @@
import
{
BaseDao
}
from
'../../sdk'
import
BaseService
from
'./base.service'
import
{
USER_DB_NAME
}
from
'../../db'
import
{
getToday
,
formatUpdateUserProjection
}
from
'../../utils'
import
{
customInitUserInfo
}
from
'../../customUser'
import
{
getToday
,
formatUpdateUserProjection
,
initCustomUser
}
from
'../../utils'
import
{
isNewVip
}
from
'../../utils/common/userUpdate'
import
{
formatUserNick
,
formatUpdatedDataByProjection
}
from
'../../utils/common/format'
import
{
setNewFollowUserData
,
setNewVipUserData
}
from
'../../utils/common/userUpdate'
import
{
getShopVip
,
formatVipCbUrl
}
from
'../../utils/common/vip'
import
{
get
}
from
'mpath'
...
...
@@ -45,7 +45,8 @@ class UserService extends BaseService {
async
doLogin
(
userInfo
:
IUserInfo
,
vipInfo
:
IVipInfo
,
activityInfo
:
IActivityInfo
)
{
if
(
!
userInfo
)
{
userInfo
=
await
this
.
initUserData
(
vipInfo
,
activityInfo
)
const
customUserInfo
=
initCustomUser
(
this
.
context
,
customInitUserInfo
)
userInfo
=
await
this
.
initUserData
(
vipInfo
,
activityInfo
,
customUserInfo
)
}
else
{
userInfo
=
await
this
.
updateUserData
(
vipInfo
,
userInfo
,
activityInfo
)
}
...
...
@@ -60,22 +61,22 @@ class UserService extends BaseService {
* @returns
* @memberof UserService
*/
async
initUserData
(
vipInfo
:
IVipInfo
,
activityInfo
:
IActivityInfo
)
{
async
initUserData
(
vipInfo
:
IVipInfo
,
activityInfo
:
IActivityInfo
,
customUserInfo
:
ICustomUserInfo
)
{
const
{
openId
,
data
}
=
this
.
context
const
{
activityId
,
isFollow
,
avatar
,
inviteId
,
userNick
}
=
data
const
today
=
getToday
()
console
.
log
(
`----------
${
today
}
----------`
,
today
)
const
{
tasks
}
=
activityInfo
const
{
follow
=
{}
as
ITaskConfig
,
member
=
{}
as
ITaskConfig
}
=
tasks
const
user
:
IUserInfo
=
{
const
user
:
I
Common
UserInfo
=
{
activityId
,
avatar
,
inviteId
,
userNick
,
openId
,
gameTimes
:
0
,
totalScore
:
0
,
maxScore
:
0
,
//
gameTimes: 0,
//
totalScore: 0,
//
maxScore: 0,
// 待领取次数初始化, 根据需自定义添加
remainTimes
:
{
follow
:
isFollow
?
follow
.
value
:
0
,
...
...
@@ -118,9 +119,15 @@ class UserService extends BaseService {
user
.
taskInfo
[
today
].
member
=
[{
createTime
:
Date
.
now
()
}]
}
await
this
.
userdao
.
insertOne
(
user
)
await
this
.
userdao
.
insertOne
({
...
user
,
...
customUserInfo
})
return
user
return
{
...
user
,
...
customUserInfo
}
}
async
updateUserData
(
vipInfo
:
IVipInfo
,
userInfo
:
IUserInfo
,
activityInfo
:
IActivityInfo
):
Promise
<
IUserInfo
>
{
...
...
v2.0/src/typings/dao.d.ts
View file @
71207cb3
...
...
@@ -20,7 +20,7 @@ interface IBaseDao {
* 插入单条数据
* @param document
*/
insertOne
(
document
:
any
):
Promise
<
string
>
insertOne
<
T
>
(
document
:
T
):
Promise
<
string
>
/**
* 插入多条数据
* @param documents 插入对象
...
...
v2.0/src/typings/user.d.ts
View file @
71207cb3
/** @format */
type
IUserInfo
=
ICustomUserInfo
&
ICommonUserInfo
interface
IUserInfo
{
interface
ICustomUserInfo
{
// 游戏类
gameTimes
?:
number
maxScore
?:
number
totalScore
?:
number
updateScoreTime
?:
number
}
interface
ICommonUserInfo
{
_id
?:
string
id
?:
string
activityId
:
string
...
...
@@ -16,11 +25,6 @@ interface IUserInfo {
remainTimes
?:
IRemainTimesInfo
taskInfo
?:
object
login
?:
object
// 游戏类
gameTimes
?:
number
maxScore
?:
number
totalScore
?:
number
updateScoreTime
?:
number
}
interface
IRemainTimesInfo
{
...
...
v2.0/src/utils/common/initCustomUser.ts
0 → 100644
View file @
71207cb3
/** @format */
export
const
initCustomUser
=
(
context
:
IContext
<
IParams
>
,
customUserInfo
:
ICustomUserInfo
)
=>
{
return
customUserInfo
}
v2.0/src/utils/index.ts
View file @
71207cb3
...
...
@@ -27,3 +27,5 @@ export * from './common/userUpdate'
export
*
from
'./common/format'
export
*
from
'./common/doHandler'
export
*
from
'./common/initCustomUser'
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