Commit 59323d0c authored by qinhaitao's avatar qinhaitao

feat: 🎸 commonSer 命名

parent a300ba28
......@@ -2,7 +2,7 @@
import { services, checkParams, registeInfos } from '../decorator/common'
import { resultsModel } from '../sdk'
import { AwardsService } from '../service/common'
import { CommonAwardsService } from '../service/common'
import preCheck from '../decorator/common/preCheck'
import {
checkActivityTime,
......@@ -20,11 +20,11 @@ export default class AwardsController {
* 我的奖品列表
*/
@checkParams(['activityId'])
@services([AwardsService])
@services([CommonAwardsService])
async getMyPrizeList(
context: IContext<IParams>,
{ activityInfo }: IControllerInfos,
[awardSer]: [AwardsService]
[awardSer]: [CommonAwardsService]
): Promise<IResult<{ list: IAwards[] }>> {
const result = await awardSer.getMyPrizeList(activityInfo)
return resultsModel.success(result)
......@@ -34,12 +34,12 @@ export default class AwardsController {
* 领取实物
*/
@checkParams(['activityId', 'id', 'name', 'phone', 'province', 'city', 'area', 'addressDetail', 'streetName'])
@services([AwardsService])
@services([CommonAwardsService])
@preCheck([checkPrizeExpired, checkValidObjectPrize])
async receiveObjectPrize(
context: IContext<IParams>,
{ activityInfo }: IReceivePrizeControllerInfos,
[awardSer]: [AwardsService]
[awardSer]: [CommonAwardsService]
): Promise<IResult<boolean>> {
let { province, city, area, streetName, addressDetail, id, name, phone } = context.data
......@@ -61,12 +61,12 @@ export default class AwardsController {
*/
@checkParams(['activityId', 'id'])
@registeInfos(['session'])
@services([AwardsService])
@services([CommonAwardsService])
@preCheck([checkPrizeExpired, checkValidEnamePrize])
async receiveEnamePrize(
context: IContext<IParams>,
{ awardInfo, session }: IReceivePrizeControllerInfos,
[awardSer]: [AwardsService]
[awardSer]: [CommonAwardsService]
) {
let { id } = context.data
......@@ -79,12 +79,12 @@ export default class AwardsController {
* 概率抽奖
*/
@checkParams(['activityId', 'prizeDataType'])
@services([AwardsService])
@services([CommonAwardsService])
@preCheck([checkActivityTime])
async drawLotteryPrize(
context: IContext<IParams>,
{ userInfo }: IControllerInfos,
[awardSer]: [AwardsService]
[awardSer]: [CommonAwardsService]
): Promise<
IResult<{
id?: string
......
......@@ -2,14 +2,14 @@
import { services, checkParams, registeInfos, noCheckUser } from '../decorator/common'
import { resultsModel } from '../sdk'
import { BaseService } from '../service/common'
import { CommonBaseService } from '../service/common'
export default class BaseController {
/**
* 活动基本信息
*/
@checkParams(['activityId'])
@noCheckUser
@services([BaseService])
@services([CommonBaseService])
async getActivityBaseInfoById(
context: IContext<{
activityId: string
......@@ -24,11 +24,11 @@ export default class BaseController {
*/
@checkParams(['itemIds'])
@registeInfos(['session'])
@services([BaseService])
@services([CommonBaseService])
async getItemListByItemIds(
context: IContext<IParams>,
{ session }: IControllerInfos,
[baseService]: [BaseService]
[baseService]: [CommonBaseService]
): Promise<IResult<{ list: ITaoBaoItems[] }>> {
const { itemIds } = context.data
......
......@@ -2,7 +2,7 @@
import { services, checkParams, preCheck, preUpdate } from '../decorator/common'
import { resultsModel } from '../sdk'
import { UserService, GameService } from '../service/common'
import { CommonUserService, CommonGameService } from '../service/common'
import { checkActivityTime, checkJoinId, checkUserInfo, checkVip } from '../utils/common/check'
import { updateUserInfo } from '../utils/common/update'
......@@ -17,11 +17,11 @@ export default class Game {
* needKeys 根据需求自取字段 格式: { gameTimes: 1 }
*/
@checkParams(['activityId', 'needKeys'])
@services([UserService])
@services([CommonUserService])
async getGameInfo(
context: IContext<IParams>,
{ userInfo, activityInfo }: IControllerInfos,
[userService]: [UserService]
[userService]: [CommonUserService]
) {
const { needKeys } = context.data
const gameInfoResult = await userService.getUserInfo(needKeys)
......@@ -31,7 +31,7 @@ export default class Game {
}
@checkParams(['activityId'])
@services([GameService])
@services([CommonGameService])
@preCheck([checkActivityTime, checkVip, checkUserInfo({ gameTimes: { $gte: 3 } }, '游戏次数不足,做点任务吧')])
@preUpdate([
updateUserInfo({
......@@ -42,7 +42,7 @@ export default class Game {
async startGame(
context: IContext<IParams>,
{ userInfo, activityInfo }: IControllerInfos,
[gameService]: [GameService]
[gameService]: [CommonGameService]
) {
const joinResult = await gameService.addJoinRecord(userInfo)
......@@ -52,12 +52,12 @@ export default class Game {
}
@checkParams(['activityId', 'id', 'score'])
@services([GameService])
@services([CommonGameService])
@preCheck([checkJoinId])
async submitGame(
context: IContext<IParams>,
{ userInfo, joinInfo }: ISumitGameControllerInfos,
[gameService]: [GameService]
[gameService]: [CommonGameService]
) {
const { id, score } = context.data
const result = await gameService.submitGame(id, score, userInfo, joinInfo)
......
......@@ -2,7 +2,7 @@
import { services, checkParams, registeInfos, preUpdate } from '../decorator/common'
import { resultsModel } from '../sdk'
import { UserService, AccessService } from '../service/common'
import { CommonUserService, CommonAccessService } from '../service/common'
import { noCheckUser } from '../decorator/common'
export default class LoginController {
/**
......@@ -15,11 +15,11 @@ export default class LoginController {
@checkParams(['activityId', 'userNick', 'avatar', 'isFollow'])
@noCheckUser
@registeInfos(['vipInfo'])
@services([UserService, AccessService])
@services([CommonUserService, CommonAccessService])
async login(
context: IContext<IParams>,
{ userInfo, activityInfo, vipInfo }: IControllerInfos,
[userService, accessService]: [UserService, AccessService]
[userService, accessService]: [CommonUserService, CommonAccessService]
): Promise<IResult<{ openId: string; firstLoginToday: boolean; newUser: boolean }>> {
const updatedUserInfo = await userService.doLogin(userInfo, vipInfo, activityInfo)
// access表
......
......@@ -2,7 +2,7 @@
import { services, preCheck, registeInfos, preUpdate, checkParams } from '../decorator/common/'
import { resultsModel } from '../sdk'
import { UserService, StatService, TaskService } from '../service/common'
import { CommonUserService, CommonStatService, CommonTaskService } from '../service/common'
import { STAT_TYPE } from '../constants'
import { checkActivityTime, checkInviteId, checkHelpRecord, checkNewVip } from '../utils/common/check'
import { updateVip } from '../utils/common/update/'
......@@ -15,7 +15,7 @@ export default class Share {
* 获取邀请信息
*/
@checkParams(['activityId'])
@services([UserService])
@services([CommonUserService])
async getShareInfo(
context: IContext<IParams>,
{ userInfo }: IControllerInfos
......@@ -33,13 +33,13 @@ export default class Share {
*/
@checkParams(['activityId', 'inviteId'])
@registeInfos(['vipInfo'])
@services([TaskService, StatService])
@services([CommonTaskService, CommonStatService])
@preCheck([checkActivityTime, checkInviteId, checkNewVip, checkHelpRecord])
@preUpdate([updateVip])
async doHelp(
context: IContext<IParams>,
{ userInfo, activityInfo, inviteUserInfo }: IdoHelpInfos,
[taskService, statService]: [TaskService, StatService]
[taskService, statService]: [CommonTaskService, CommonStatService]
): Promise<IResult<boolean>> {
const { openId } = context
......
......@@ -2,7 +2,7 @@
import { resultsModel } from '../sdk'
import { checkParams, services } from '../decorator/common'
import { StatService } from '../service/common'
import { CommonStatService } from '../service/common'
/** @format */
export default class StatController {
......@@ -10,8 +10,8 @@ export default class StatController {
* 增加埋点记录
*/
@checkParams(['activityId', 'type'])
@services([StatService])
async addStat(context: IContext<IParams>, { userInfo }: IControllerInfos, [statService]: [StatService]) {
@services([CommonStatService])
async addStat(context: IContext<IParams>, { userInfo }: IControllerInfos, [statService]: [CommonStatService]) {
const { type } = context.data
const result = await statService.addStat(type, userInfo)
return resultsModel.success(result)
......@@ -20,8 +20,8 @@ export default class StatController {
* 统计数据
*/
@checkParams(['activityId', 'startDay', 'endDay'])
@services([StatService])
async getStats(context: IContext<IParams>, {}: IControllerInfos, [statService]: [StatService]) {
@services([CommonStatService])
async getStats(context: IContext<IParams>, {}: IControllerInfos, [statService]: [CommonStatService]) {
const { activityId, startDay, endDay } = context.data
const xlsxData = await statService.getStats(activityId, startDay, endDay)
......
......@@ -2,7 +2,7 @@
import { checkParams, services, registeInfos, preCheck } from '../decorator/common'
import { resultsModel } from '../sdk'
import { TaskService, BaseService } from '../service/common'
import { CommonTaskService, CommonBaseService } from '../service/common'
import { ITaskInfo } from '../service/common/task.service'
import { checkActivityTime, checkTaskLimit, checkExchangeCreditsTask, checkRemainTimes } from '../utils/common/check/'
import { preUpdate } from '../decorator/common'
......@@ -14,13 +14,13 @@ export default class Task {
*/
@checkParams(['activityId'])
@registeInfos(['vipInfo'])
@services([TaskService])
@services([CommonTaskService])
@preCheck([checkActivityTime])
@preUpdate([updateVip, updateSignTask, updateOrderGoods])
async getTaskList(
context: IContext<IParams>,
{ userInfo, activityInfo }: IControllerInfos,
[taskService]: [TaskService]
[taskService]: [CommonTaskService]
): Promise<IResult<{ list: ITaskInfo[] }>> {
// 读取B端 tasks字段配置自动生成任务列表
const result = await taskService.initTaskList(userInfo, activityInfo)
......@@ -38,12 +38,12 @@ export default class Task {
*/
@checkParams(['activityId', 'taskType'])
@registeInfos(['session'])
@services([TaskService])
@services([CommonTaskService])
@preCheck([checkActivityTime, checkTaskLimit, checkExchangeCreditsTask])
async doCompleteTask(
context: IContext<IParams>,
{ userInfo, activityInfo }: IControllerInfos,
[taskService]: [TaskService]
[taskService]: [CommonTaskService]
): Promise<IResult<boolean>> {
const { taskType } = context.data
......@@ -58,12 +58,12 @@ export default class Task {
* 领取的奖励增加的key值 如: gameTimes 前端传入
*/
@checkParams(['activityId', 'taskType', 'rewardsKey'])
@services([TaskService])
@services([CommonTaskService])
@preCheck([checkActivityTime, checkRemainTimes])
async receiveTaskRewards(
context: IContext<IParams>,
{ userInfo }: IControllerInfos,
[taskService]: [TaskService]
[taskService]: [CommonTaskService]
): Promise<IResult<{ rewards: number }>> {
const { rewardsKey } = context.data
const { taskType } = context.data
......@@ -78,17 +78,17 @@ export default class Task {
*/
@checkParams(['activityId', 'itemIds'])
@registeInfos(['session'])
@services([BaseService, TaskService])
@services([CommonBaseService, CommonTaskService])
async getCollectGoodsList(
context: IContext<IParams>,
{ session, userInfo }: IControllerInfos,
[baseService, taskService]: [BaseService, TaskService]
[commonBaseService, commonTaskService]: [CommonBaseService, CommonTaskService]
) {
const { itemIds } = context.data
const list = await baseService.getItemListByIds(itemIds, session)
const list = await commonBaseService.getItemListByIds(itemIds, session)
const listWithCollectStatus = await taskService.getItemListWithCollectStatus(list, userInfo)
const listWithCollectStatus = await commonTaskService.getItemListWithCollectStatus(list, userInfo)
return resultsModel.success(listWithCollectStatus)
}
......
......@@ -2,7 +2,7 @@
import { services, checkParams, registeInfos } from '../decorator/common'
import { resultsModel } from '../sdk'
import { UserService } from '../service/common'
import { CommonUserService } from '../service/common'
interface IRankList {
userNick: string
......@@ -23,11 +23,11 @@ export default class User {
* 获取会员信息
*/
@checkParams(['activityId'])
@services([UserService])
@services([CommonUserService])
async getVipInfo(
context: IContext<IParams>,
{ activityInfo }: IControllerInfos,
[userService]: [UserService]
[userService]: [CommonUserService]
): Promise<IResult<IVipInfo>> {
// 拼接回调参数
const result = await userService.getShopVip(context, activityInfo)
......@@ -39,8 +39,8 @@ export default class User {
* 获取排行榜
*/
@checkParams(['activityId', 'key', 'timeKey'])
@services([UserService])
async getRankList(context: IContext<IParams>, { userInfo }: IControllerInfos, [userService]: [UserService]) {
@services([CommonUserService])
async getRankList(context: IContext<IParams>, { userInfo }: IControllerInfos, [userService]: [CommonUserService]) {
const { key, timeKey, limit = 200 } = context.data
const rankInfo = await userService.getMyRankInfo(key, timeKey, userInfo)
......
/** @format */
import { isEmpty, merge } from 'lodash'
import { UserService } from '../../service/common'
import { recordErrorLog } from '../../utils/common/logger'
import { resultsModel } from '../../sdk'
import { CODE_TYPES } from '../../errorCode'
......
/** @format */
import { UserService, BaseService } from '../../service/common'
import { CommonUserService, CommonBaseService } from '../../service/common'
import { getSellerSession } from '../../utils'
import { formatVipCbUrl, getShopVip } from '../../utils/common/vip'
import { CODE_TYPES } from '../../errorCode'
......@@ -9,10 +9,10 @@ export type IInfo = 'session' | 'vipInfo'
async function initBaseInfo(context: IContext<IParams>, baseInfos: ICheckControllerInfos, needInfos: IInfo[]) {
const handler = context?.cloud?.dataspace?.context?.handler
const userService = new UserService(context)
const userService = new CommonUserService(context)
if (!baseInfos.activityInfo) {
const baseService = new BaseService(context)
const baseService = new CommonBaseService(context)
// 活动基本情况
const activityInfo = await baseService.getBaseInfo(context.data.activityId)
if (!activityInfo) return CODE_TYPES.ERROR_NO_ACTIVITY
......
......@@ -4,7 +4,7 @@ import { logFn, recordErrorLog } from '../../utils'
import { resultsModel } from '../../sdk'
import { CODE_TYPES } from '../../constants'
import { doHandler } from '../../utils/'
import { UserService, BaseService } from '../../service/common'
import { CommonUserService, CommonBaseService } from '../../service/common'
type Constructor = new (...args: any[]) => {}
......@@ -12,7 +12,7 @@ async function formatBaseInfos(context: IContext<IParams>, baseInfos: ICheckCont
// 如果未调用registeInfos 则 重新注入userInfo和 activityInfo
if (!baseInfos.registed) {
if (!baseInfos.activityInfo && !baseInfos.noCheckActivity) {
const baseService = new BaseService(context)
const baseService = new CommonBaseService(context)
// 活动基本情况
const activityInfo = await baseService.getBaseInfo(context.data.activityId)
if (!activityInfo) return CODE_TYPES.ERROR_NO_ACTIVITY
......@@ -21,7 +21,7 @@ async function formatBaseInfos(context: IContext<IParams>, baseInfos: ICheckCont
// 默认注入活动和用户信息并校验
if (!baseInfos.userInfo) {
const userService = new UserService(context)
const userService = new CommonUserService(context)
const userInfo = await userService.getUserInfo()
if (!userInfo && !baseInfos.noCheckUser) return CODE_TYPES.ERROR_NO_USER
baseInfos.userInfo = userInfo
......
/** @format */
import AccessService from './access.service'
import BaseService from './base.service'
import UserService from './user.service'
import AwardsService from './awards.service'
import TaskService from './task.service'
import StatService from './stat.service'
import GameService from './game.service'
import CommonAccessService from './access.service'
import CommonBaseService from './base.service'
import CommonUserService from './user.service'
import CommonAwardsService from './awards.service'
import CommonTaskService from './task.service'
import CommonStatService from './stat.service'
import CommonGameService from './game.service'
const common = {
AccessService,
BaseService,
UserService,
AwardsService,
TaskService,
StatService,
GameService
CommonAccessService,
CommonBaseService,
CommonUserService,
CommonAwardsService,
CommonTaskService,
CommonStatService,
CommonGameService
}
export default common
export {
AccessService,
BaseService,
UserService,
AwardsService,
TaskService,
StatService,
GameService
CommonAccessService,
CommonBaseService,
CommonUserService,
CommonAwardsService,
CommonTaskService,
CommonStatService,
CommonGameService
}
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