feat: 邮件通知

This commit is contained in:
xiaojunnuo
2023-06-25 15:30:18 +08:00
parent 64afebecd4
commit 937e3fac19
32 changed files with 790 additions and 88 deletions
@@ -10,7 +10,7 @@ export abstract class BaseController {
* 成功返回
* @param data 返回数据
*/
ok(data) {
ok(data: any) {
const res = {
...Constants.res.success,
data: undefined,
@@ -22,12 +22,21 @@ export abstract class BaseController {
}
/**
* 失败返回
* @param message
* @param msg
* @param code
*/
fail(msg, code) {
fail(msg: string, code: any) {
return {
code: code ? code : Constants.res.error.code,
msg: msg ? msg : Constants.res.error.code,
};
}
getUserId() {
const userId = this.ctx.user?.id;
if (userId == null) {
throw new Error('Token已过期');
}
return userId;
}
}
@@ -187,14 +187,19 @@ export abstract class BaseService<T> {
return await qb.getMany();
}
async checkUserId(id = 0, userId, userKey = 'userId') {
async checkUserId(
id: any = 0,
userId,
userKey = 'userId',
queryIdKey = 'id'
) {
// @ts-ignore
const res = await this.getRepository().findOne({
// @ts-ignore
select: { [userKey]: true },
// @ts-ignore
where: {
// @ts-ignore
id,
[queryIdKey]: id,
},
});
// @ts-ignore