|
@@ -124,8 +124,11 @@ export class QrCodeService {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 根据二维码或ID获取信息
|
|
* 根据二维码或ID获取信息
|
|
|
|
|
+ * @param qrCode 二维码
|
|
|
|
|
+ * @param id 二维码ID
|
|
|
|
|
+ * @param isAdmin 是否为后台查询,后台查询不判断 isVisible
|
|
|
*/
|
|
*/
|
|
|
- async getQrCodeInfo(qrCode?: string, id?: number): Promise<any> {
|
|
|
|
|
|
|
+ async getQrCodeInfo(qrCode?: string, id?: number, isAdmin: boolean = false): Promise<any> {
|
|
|
let entity: QrCode | null = null
|
|
let entity: QrCode | null = null
|
|
|
|
|
|
|
|
if (qrCode) {
|
|
if (qrCode) {
|
|
@@ -138,7 +141,11 @@ export class QrCodeService {
|
|
|
throw new Error('二维码不存在')
|
|
throw new Error('二维码不存在')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ let scanCount = entity.scanCount
|
|
|
let info = null
|
|
let info = null
|
|
|
|
|
+ let isVisible = true
|
|
|
|
|
+
|
|
|
|
|
+ // 根据类型获取信息
|
|
|
if (entity.qrType === QrType.PERSON) {
|
|
if (entity.qrType === QrType.PERSON) {
|
|
|
info = await this.personInfoRepository.findOne({ where: { qrCodeId: entity.id } })
|
|
info = await this.personInfoRepository.findOne({ where: { qrCodeId: entity.id } })
|
|
|
} else if (entity.qrType === QrType.PET) {
|
|
} else if (entity.qrType === QrType.PET) {
|
|
@@ -147,6 +154,14 @@ export class QrCodeService {
|
|
|
info = await this.goodsInfoRepository.findOne({ where: { qrCodeId: entity.id } })
|
|
info = await this.goodsInfoRepository.findOne({ where: { qrCodeId: entity.id } })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (!isAdmin && info && info.isVisible === false) {
|
|
|
|
|
+ scanCount = 0
|
|
|
|
|
+ info = null
|
|
|
|
|
+ isVisible = false
|
|
|
|
|
+ } else if (info) {
|
|
|
|
|
+ isVisible = info.isVisible ?? true
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 处理图片签名URL
|
|
// 处理图片签名URL
|
|
|
if (info && info.photoUrl) {
|
|
if (info && info.photoUrl) {
|
|
|
try {
|
|
try {
|
|
@@ -167,8 +182,10 @@ export class QrCodeService {
|
|
|
id: entity.id,
|
|
id: entity.id,
|
|
|
qrCode: entity.qrCode,
|
|
qrCode: entity.qrCode,
|
|
|
qrType: entity.qrType,
|
|
qrType: entity.qrType,
|
|
|
|
|
+ ...(isAdmin && { createdAt: entity.createdAt, updatedAt: entity.updatedAt }),
|
|
|
isActivated: entity.isActivated,
|
|
isActivated: entity.isActivated,
|
|
|
- scanCount: entity.scanCount,
|
|
|
|
|
|
|
+ scanCount,
|
|
|
|
|
+ isVisible,
|
|
|
info
|
|
info
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|