mirror of
https://github.com/certd/certd.git
synced 2026-04-21 10:27:25 +08:00
feat: 邮件通知
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user