Commit 8c8a77ad authored by qinhaitao's avatar qinhaitao

feat: 🎸 配置信息

parent 2e6e259c
...@@ -269,6 +269,104 @@ ...@@ -269,6 +269,104 @@
] ]
} }
}, },
"share": {
"getShareInfo": {
"desc": "获取邀请信息",
"decorators":[
{
"type": "common",
"name": "checkParams",
"params": [
"activityId"
]
}
]
}
},
"login": {
"login":{
"desc":"登录接口, 初始化/更新用户信息",
"decorators":[
{
"type": "common",
"name": "checkParams",
"params": [
"activityId",
"userNick",
"avatar",
"isFollow"
]
},
{
"type": "common",
"name": "noCheckUser","params": [
"activityId"
]
},
{
"type": "common",
"name": "registeInfos",
"params": [
"vipInfo"
]
}
],
"main": [
{
"type": "common",
"service": "user",
"function": "doLogin",
"params": [
{ "type": "var", "value": "userInfo" },
{ "type": "var", "value": "vipInfo" },
{ "type": "var", "value": "activityInfo" }
],
"return": true
},
{
"type": "common",
"service": "access",
"function": "addAccess",
"params": [
{ "type": "var", "value": "commonUserDoLoginResult1" },
{ "type": "var", "value": "vipInfo" }
],
"return": true
}
]
}
},
"base": {
"getActivityBaseInfoById":{
"desc":"活动基本信息",
"decorators":[
{
"type": "common",
"name": "checkParams",
"params": [
"activityId"
]
},
{
"type": "common",
"name": "noCheckUser","params": [
"activityId"
]
}
],
"main": [
{
"type": "common",
"service": "base",
"function": "getBaseInfo",
"params": [
{ "type": "var", "value": "context.data.activityId" }
],
"return": true
}
]
}
},
"stat": { "stat": {
"addStat": { "addStat": {
"desc": "增加埋点记录", "desc": "增加埋点记录",
......
{ {
"name": "nunjucks-test", "name": "nunjucks-test",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-nunjucks-render": "^2.2.3", "gulp-nunjucks-render": "^2.2.3",
"gulp-rename": "^2.0.0" "gulp-rename": "^2.0.0"
}, },
"dependencies": { "dependencies": {
"fs-extra": "^9.0.1" "fs-extra": "^9.0.1"
}
} }
}
\ No newline at end of file
This diff is collapsed.
...@@ -14,9 +14,14 @@ export default class BaseController { ...@@ -14,9 +14,14 @@ export default class BaseController {
context: IContext<{ context: IContext<{
activityId: string activityId: string
}>, }>,
{ activityInfo }: IControllerInfos {}: IControllerInfos,
[baseService]: [CommonBaseService]
): Promise<IResult<IActivityInfo>> { ): Promise<IResult<IActivityInfo>> {
return resultsModel.success(activityInfo) const { activityId } = context.data
const activityInfo = await baseService.getBaseInfo(activityId)
return resultsModel.success({
...activityInfo
})
} }
/** /**
......
/** @format */
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import customDecorator from '../../decorator/custom'
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
import { CommonBaseService } from '../../service/common'
export default class BaseController {
/**
* 活动基本信息
*/
@commonDecorator.checkParams(['activityId'])
@commonDecorator.noCheckUser(['activityId'])
@services([CommonBaseService])
async getActivityBaseInfoById(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonBaseService]: [CommonBaseService]
) {
const commonBaseGetBaseInfoResult1 = await commonBaseService.getBaseInfo(context.data.activityId)
return resultsModel.success({
...commonBaseGetBaseInfoResult1
})
}
}
/** @format */
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import customDecorator from '../../decorator/custom'
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
import { CommonUserService, CommonAccessService } from '../../service/common'
export default class LoginController {
/**
* 登录接口, 初始化/更新用户信息
*/
@commonDecorator.checkParams(['activityId', 'userNick', 'avatar', 'isFollow'])
@commonDecorator.noCheckUser(['activityId'])
@commonDecorator.registeInfos(['vipInfo'])
@services([CommonUserService, CommonAccessService])
async login(
context: IContext<IParams>,
{ activityInfo, userInfo, vipInfo }: IControllerInfos,
[commonUserService, commonAccessService]: [CommonUserService, CommonAccessService]
) {
const commonUserDoLoginResult1 = await commonUserService.doLogin(userInfo, vipInfo, activityInfo)
const commonAccessAddAccessResult2 = await commonAccessService.addAccess(commonUserDoLoginResult1, vipInfo)
return resultsModel.success({
...commonUserDoLoginResult1,
...commonAccessAddAccessResult2
})
}
}
...@@ -40,7 +40,7 @@ export default class Share { ...@@ -40,7 +40,7 @@ export default class Share {
context: IContext<IParams>, context: IContext<IParams>,
{ userInfo, activityInfo, inviteUserInfo }: IdoHelpInfos, { userInfo, activityInfo, inviteUserInfo }: IdoHelpInfos,
[taskService, statService]: [CommonTaskService, CommonStatService] [taskService, statService]: [CommonTaskService, CommonStatService]
): Promise<IResult<boolean>> { ) {
const { openId } = context const { openId } = context
const result = await taskService.completeTask('invites', activityInfo, inviteUserInfo) const result = await taskService.completeTask('invites', activityInfo, inviteUserInfo)
......
...@@ -44,7 +44,7 @@ export default class Task { ...@@ -44,7 +44,7 @@ export default class Task {
context: IContext<IParams>, context: IContext<IParams>,
{ userInfo, activityInfo }: IControllerInfos, { userInfo, activityInfo }: IControllerInfos,
[taskService]: [CommonTaskService] [taskService]: [CommonTaskService]
): Promise<IResult<boolean>> { ) {
const { taskType } = context.data const { taskType } = context.data
// 更新user表 // 更新user表
......
...@@ -3,6 +3,10 @@ import CommonUserController from './controller/common/user.controller' ...@@ -3,6 +3,10 @@ import CommonUserController from './controller/common/user.controller'
const CommonUserControllerInstance = new CommonUserController() const CommonUserControllerInstance = new CommonUserController()
import CommonTaskController from './controller/common/task.controller' import CommonTaskController from './controller/common/task.controller'
const CommonTaskControllerInstance = new CommonTaskController() const CommonTaskControllerInstance = new CommonTaskController()
import CommonLoginController from './controller/common/login.controller'
const CommonLoginControllerInstance = new CommonLoginController()
import CommonBaseController from './controller/common/base.controller'
const CommonBaseControllerInstance = new CommonBaseController()
import CommonStatController from './controller/common/stat.controller' import CommonStatController from './controller/common/stat.controller'
const CommonStatControllerInstance = new CommonStatController() const CommonStatControllerInstance = new CommonStatController()
import CustomTest1Controller from './controller/custom/test1.controller' import CustomTest1Controller from './controller/custom/test1.controller'
...@@ -17,6 +21,8 @@ export default { ...@@ -17,6 +21,8 @@ export default {
commonTaskDocompletetask: CommonTaskControllerInstance.doCompleteTask, commonTaskDocompletetask: CommonTaskControllerInstance.doCompleteTask,
commonTaskReceivetaskrewards: CommonTaskControllerInstance.receiveTaskRewards, commonTaskReceivetaskrewards: CommonTaskControllerInstance.receiveTaskRewards,
commonTaskGetcollectgoodslist: CommonTaskControllerInstance.getCollectGoodsList, commonTaskGetcollectgoodslist: CommonTaskControllerInstance.getCollectGoodsList,
commonLoginLogin: CommonLoginControllerInstance.login,
commonBaseGetactivitybaseinfobyid: CommonBaseControllerInstance.getActivityBaseInfoById,
commonStatAddstat: CommonStatControllerInstance.addStat, commonStatAddstat: CommonStatControllerInstance.addStat,
commonStatGetstats: CommonStatControllerInstance.getStats, commonStatGetstats: CommonStatControllerInstance.getStats,
customTest1Addstat: CustomTest1ControllerInstance.addStat, customTest1Addstat: CustomTest1ControllerInstance.addStat,
......
...@@ -112,12 +112,7 @@ export default class TaskService extends UserService { ...@@ -112,12 +112,7 @@ export default class TaskService extends UserService {
* @returns {boolean} * @returns {boolean}
* @memberof TaskService * @memberof TaskService
*/ */
async completeTask( async completeTask(taskType: ITaskType, activityInfo: IActivityInfo, userInfo: IUserInfo, customRecord: Object = {}) {
taskType: ITaskType,
activityInfo: IActivityInfo,
userInfo: IUserInfo,
customRecord: Object = {}
): Promise<boolean | ICodeType> {
const today = getToday() const today = getToday()
const rewards = activityInfo?.tasks?.[taskType]?.value || 0 const rewards = activityInfo?.tasks?.[taskType]?.value || 0
const { const {
...@@ -134,7 +129,7 @@ export default class TaskService extends UserService { ...@@ -134,7 +129,7 @@ export default class TaskService extends UserService {
[`taskInfo.${today}.${taskType}`]: { ...record, createTime: Date.now() } [`taskInfo.${today}.${taskType}`]: { ...record, createTime: Date.now() }
} }
}) })
return result ? true : CODE_TYPES.ERROR_DO_TASK return result ? { ok: 1 } : CODE_TYPES.ERROR_DO_TASK
} }
// 根据下单下单记录,更新状态 // 根据下单下单记录,更新状态
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment