返回 AiToEarn
realAuth.service.ts
根目录 / project / aitoearn-electron / server / src / modules / tools / realAuth.service.ts
1 /*
2 * @Author: nevin
3 * @Date: 2024-06-17 19:19:15
4 * @LastEditTime: 2025-04-27 14:06:39
5 * @LastEditors: nevin
6 * @Description:
7 */
8 import { Injectable } from '@nestjs/common';
9 import { InjectModel } from '@nestjs/mongoose';
10 import { Model } from 'mongoose';
11 import { RealAuth, SceneType } from 'src/db/schema/realAuth.schema';
12 import { AlicloudRealAuthService } from 'src/lib/realAuth/realAuth.service';
13
14 @Injectable()
15 export class RealAuthService {
16 constructor(
17 @InjectModel(RealAuth.name) private realAuthModel: Model<RealAuth>,
18 private readonly alicloudRealAuthService: AlicloudRealAuthService,
19 ) {}
20
21 /**
22 * 身份号认证
23 * @param identifyNum
24 * @param userName
25 */
26 async realNameAuth(
27 userId: string,
28 identifyNum: string,
29 userName: string,
30 sceneType?: SceneType,
31 ): Promise<boolean> {
32 const result = await this.realAuthModel.findOne({
33 identifyNum,
34 userName,
35 });
36 if (!!result) return true;
37
38 const res = await this.alicloudRealAuthService.realNameAuth(
39 identifyNum,
40 userName,
41 );
42
43 if (res) {
44 const realAuth = new this.realAuthModel({
45 userId: '1',
46 identifyNum,
47 userName,
48 sceneType,
49 });
50 realAuth.save();
51 }
52
53 console.log('-----', res);
54 return res;
55 }
56 }
57
57 lines TYPESCRIPT