Commit 137dfd58 authored by qinhaitao's avatar qinhaitao

refactor: 💡 login

parent 51ec8a9c
...@@ -27,12 +27,12 @@ declare const _default: { ...@@ -27,12 +27,12 @@ declare const _default: {
list: IAwards[]; list: IAwards[];
}>>; }>>;
receiveObjectPrize: (context: IContext<import("./controller/awards.controller").IReceiveOjectParams>, { activityInfo }: import("./controller/awards.controller").IReceivePrizeControllerInfos, [awardSer]: [import("./service").AwardsService]) => Promise<IResult<boolean>>; 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<{ doHelp: (context: IContext<{
activityId: string; activityId: string;
inviteId: string; inviteId: string;
}>, { userInfo, activityInfo, inviteUserInfo }: import("./controller/share.controller").IdoHelpInfos, [taskService, statService]: [import("./service").TaskService, import("./service").StatService]) => Promise<IResult<boolean>>; }>, { 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>>; 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<{ getRankList: (context: IContext<{
activityId: string; activityId: string;
......
...@@ -19,6 +19,7 @@ declare class UserService extends BaseService { ...@@ -19,6 +19,7 @@ declare class UserService extends BaseService {
* @returns 若用户不存在,返回null; 用户存在,返回用户信息(object对象) * @returns 若用户不存在,返回null; 用户存在,返回用户信息(object对象)
*/ */
getUserInfoByOpenId(openId: string): Promise<IUserInfo>; getUserInfoByOpenId(openId: string): Promise<IUserInfo>;
doLogin(userInfo: IUserInfo, vipInfo: IVipInfo, activityInfo: IActivityInfo): Promise<IUserInfo>;
/** /**
* 初始化用户数据 * 初始化用户数据
* *
......
...@@ -120,6 +120,25 @@ var UserService = /** @class */ (function (_super) { ...@@ -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) { ...@@ -130,17 +149,17 @@ var UserService = /** @class */ (function (_super) {
*/ */
UserService.prototype.initUserData = function (vipInfo, activityInfo) { UserService.prototype.initUserData = function (vipInfo, activityInfo) {
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var _a, openId, data, activityId, isFollow, avatar, inviteId, userNick, today, tasks, follow, member, user; var _a, openId, data, activityId, isFollow, avatar, inviteId, userNick, today, tasks, _b, follow, _c, member, user;
var _b, _c; var _d, _e;
return __generator(this, function (_d) { return __generator(this, function (_f) {
switch (_d.label) { switch (_f.label) {
case 0: case 0:
_a = this.context, openId = _a.openId, data = _a.data; _a = this.context, openId = _a.openId, data = _a.data;
activityId = data.activityId, isFollow = data.isFollow, avatar = data.avatar, inviteId = data.inviteId, userNick = data.userNick; activityId = data.activityId, isFollow = data.isFollow, avatar = data.avatar, inviteId = data.inviteId, userNick = data.userNick;
today = utils_1.getToday(); today = utils_1.getToday();
console.log("----------" + today + "----------", today); console.log("----------" + today + "----------", today);
tasks = activityInfo.tasks; 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 = { user = {
activityId: activityId, activityId: activityId,
avatar: avatar, avatar: avatar,
...@@ -158,12 +177,12 @@ var UserService = /** @class */ (function (_super) { ...@@ -158,12 +177,12 @@ var UserService = /** @class */ (function (_super) {
follow: { follow: {
flag: !!isFollow flag: !!isFollow
}, },
login: (_b = {}, login: (_d = {},
_b[today] = 1, _d[today] = 1,
_b), _d),
taskInfo: (_c = {}, taskInfo: (_e = {},
_c[today] = {}, _e[today] = {},
_c), _e),
createTime: Date.now(), createTime: Date.now(),
createDay: today, createDay: today,
updateTime: Date.now() updateTime: Date.now()
...@@ -178,7 +197,7 @@ var UserService = /** @class */ (function (_super) { ...@@ -178,7 +197,7 @@ var UserService = /** @class */ (function (_super) {
} }
return [4 /*yield*/, this.userdao.insertOne(user)]; return [4 /*yield*/, this.userdao.insertOne(user)];
case 1: case 1:
_d.sent(); _f.sent();
return [2 /*return*/, user]; return [2 /*return*/, user];
} }
}); });
......
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/service/user.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAAwC;AACxC,+CAAwC;AACxC,4BAAoC;AACpC,kCAA+D;AAC/D,yDAAqD;AACrD,iDAAuD;AACvD,2CAAgE;AAChE;IAA0B,+BAAW;IAEnC,qBAAY,OAA0B;QAAtC,YACE,kBAAM,OAAO,CAAC,SAEf;QADC,KAAI,CAAC,OAAO,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,iBAAY,CAAC,CAAA;;IACnD,CAAC;IACD;;;OAGG;IACG,iCAAW,GAAjB;;;;;;wBACM,KAAmB,IAAI,CAAC,OAAO,EAA7B,MAAM,YAAA,EAAE,IAAI,UAAA,CAAiB;wBAC7B,UAAU,GAAK,IAAI,WAAT,CAAS;wBACZ,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAY,EAAE,MAAM,QAAA,EAAE,UAAU,YAAA,EAAE,CAAC,EAAA;;wBAAtE,MAAM,GAAG,SAA6D;wBAC1E,sBAAO,MAAM,EAAA;;;;KACd;IAED;;;;;OAKG;IACG,yCAAmB,GAAzB,UAA0B,MAAc;;;;;;wBAChC,UAAU,GAAK,IAAI,CAAC,OAAO,CAAC,IAAI,WAAtB,CAAsB;wBACzB,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAY,EAAE,MAAM,Q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C;IAEK,gCAAU,GAAhB,UACE,OAA+D,EAC/D,OAAe,EACf,gBAAwB;;;;;;wBAEhB,WAAW,GAAK,OAAO,CAAC,IAAI,YAAjB,CAAiB;wBAC7B,qBAAM,gBAAU,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,IAAI,oBAAc,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC,EAAA;4BAAnG,sBAAO,SAA4F,EAAA;;;;KACpG;IACH,kBAAC;AAAD,CAAC,AA/OD,CAA0B,sBAAW,GA+OpC;AAED,kBAAe,WAAW,CAAA"}
\ No newline at end of file \ No newline at end of file
...@@ -28,14 +28,9 @@ export default class User { ...@@ -28,14 +28,9 @@ export default class User {
): Promise<IResult<{ openId: string }>> { ): Promise<IResult<{ openId: string }>> {
const { openId } = context const { openId } = context
if (!userInfo) { const updatedUserInfo = await userService.doLogin(userInfo, vipInfo, activityInfo)
userInfo = await userService.initUserData(vipInfo, activityInfo)
} else {
userInfo = await userService.updateUserData(vipInfo, userInfo, activityInfo)
}
// access表 // access表
await accessService.addAccess(userInfo) await accessService.addAccess(updatedUserInfo)
return resultsModel.success({ return resultsModel.success({
openId openId
......
...@@ -11,6 +11,7 @@ import { getToday, formatUpdateUserProjection } from '../utils' ...@@ -11,6 +11,7 @@ import { getToday, formatUpdateUserProjection } from '../utils'
import { isNewVip } from '../utils/common/userUpdate' import { isNewVip } from '../utils/common/userUpdate'
import { formatUserNick } from '../utils/common/format' import { formatUserNick } from '../utils/common/format'
import { getShopVip, formatVipCbUrl } from '../utils/common/vip' import { getShopVip, formatVipCbUrl } from '../utils/common/vip'
import { userInfo } from 'os'
class UserService extends BaseService { class UserService extends BaseService {
userdao: IBaseDao userdao: IBaseDao
constructor(context: IContext<IParams>) { constructor(context: IContext<IParams>) {
...@@ -40,6 +41,15 @@ class UserService extends BaseService { ...@@ -40,6 +41,15 @@ class UserService extends BaseService {
return record 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 { ...@@ -54,7 +64,7 @@ class UserService extends BaseService {
const today = getToday() const today = getToday()
console.log(`----------${today}----------`, today) console.log(`----------${today}----------`, today)
const { tasks } = activityInfo const { tasks } = activityInfo
const { follow, member } = tasks const { follow = {} as ITaskConfig, member = {} as ITaskConfig } = tasks
const user: IUserInfo = { const user: IUserInfo = {
activityId, activityId,
avatar, avatar,
......
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