|
|
@@ -5,14 +5,17 @@ import { QrCodeService } from './qr-code.service'
|
|
|
import { QrType } from '../entities/qr-code.entity'
|
|
|
import { PaginationResponse } from '../dto/common.dto'
|
|
|
import { AdminUpdatePersonInfoDto } from '../dto/person-info.dto'
|
|
|
+import { FileService } from './file.service'
|
|
|
|
|
|
export class PersonInfoService {
|
|
|
private personInfoRepository: Repository<PersonInfo>
|
|
|
private qrCodeService: QrCodeService
|
|
|
+ private fileService: FileService
|
|
|
|
|
|
constructor(app: FastifyInstance) {
|
|
|
this.personInfoRepository = app.dataSource.getRepository(PersonInfo)
|
|
|
this.qrCodeService = new QrCodeService(app)
|
|
|
+ this.fileService = new FileService(app)
|
|
|
}
|
|
|
|
|
|
async create(qrCode: string, data: Partial<PersonInfo>): Promise<PersonInfo> {
|
|
|
@@ -150,4 +153,27 @@ export class PersonInfoService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ async adminGetDetail(qrCodeId: number): Promise<PersonInfo | null> {
|
|
|
+ const personInfo = await this.personInfoRepository.findOne({
|
|
|
+ where: { qrCodeId }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (!personInfo) {
|
|
|
+ return null
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果有图片URL,生成带签名的URL
|
|
|
+ if (personInfo.photoUrl) {
|
|
|
+ try {
|
|
|
+ const signedUrl = await this.fileService.getSignedUrl(personInfo.photoUrl)
|
|
|
+ return { ...personInfo, photoUrl: signedUrl }
|
|
|
+ } catch (error) {
|
|
|
+ // 如果生成签名URL失败,返回原始数据
|
|
|
+ return personInfo
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return personInfo
|
|
|
+ }
|
|
|
}
|