refactor: remove console logs, update SaleInvoicePayload interface, and enhance GoodCategoriesService response mapping
This commit is contained in:
@@ -25,9 +25,6 @@ export class JwtAuthGuard implements CanActivate {
|
||||
|
||||
const req = context.switchToHttp().getRequest<IWithJWTPayloadRequest>()
|
||||
|
||||
// Log headers to inspect whether Authorization is present
|
||||
|
||||
// Try token from cookie first, then from Authorization header (Bearer)
|
||||
let token: string | undefined = req.cookies?.accessToken
|
||||
if (!token) {
|
||||
const authHeader = (req.headers.authorization || req.headers.Authorization) as
|
||||
@@ -45,8 +42,6 @@ export class JwtAuthGuard implements CanActivate {
|
||||
secret: process.env.JWT_SECRET || 'secret',
|
||||
})
|
||||
|
||||
console.log(payload)
|
||||
|
||||
if (payload.type !== 'POS')
|
||||
throw new UnauthorizedException('Invalid or expired token')
|
||||
|
||||
|
||||
@@ -7,22 +7,32 @@ import { CreateGoodCategoryDto } from './dto/create-good-category.dto'
|
||||
export class GoodCategoriesService {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
async findAll(complex_id: string) {
|
||||
// console.log(account)
|
||||
|
||||
const categories = await this.prisma.goodCategory.findMany({
|
||||
where: {
|
||||
complex_id,
|
||||
},
|
||||
include: {
|
||||
goods: {
|
||||
include: {
|
||||
_count: true,
|
||||
_count: {
|
||||
select: {
|
||||
goods: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
omit: {
|
||||
account_id: true,
|
||||
complex_id: true,
|
||||
},
|
||||
})
|
||||
|
||||
return ResponseMapper.list(categories)
|
||||
return ResponseMapper.list(
|
||||
categories.map(category => {
|
||||
const { _count, ...rest } = category
|
||||
return {
|
||||
...rest,
|
||||
goods_count: Number(_count.goods),
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
findOne(categoryId: string, complex_id: string) {
|
||||
|
||||
@@ -52,7 +52,6 @@ export class GoodsService {
|
||||
},
|
||||
},
|
||||
}
|
||||
console.log(dataToCreate)
|
||||
|
||||
const good = await this.prisma.good.create({
|
||||
data: dataToCreate,
|
||||
@@ -62,7 +61,6 @@ export class GoodsService {
|
||||
deleted_at: true,
|
||||
},
|
||||
})
|
||||
console.log(good)
|
||||
|
||||
return ResponseMapper.create(good)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user