transform core api codes into this project, update modules as admin/pos context modules

This commit is contained in:
2026-03-07 11:25:11 +03:30
parent b949500482
commit 8c5f1d4d49
167 changed files with 26975 additions and 1837 deletions
@@ -0,0 +1,73 @@
import { GoodOmit } from '@/generated/prisma/models'
import { PrismaService } from '@/prisma/prisma.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
import { CreateGoodDto } from './dto/create-good.dto'
@Injectable()
export class GoodsService {
constructor(private prisma: PrismaService) {}
private readonly goodOmit = {
complex_id: true,
barcode: true,
base_sale_price: true,
is_default_guild_good: true,
local_sku: true,
guild_id: true,
} as GoodOmit
async findAll(guildId: string) {
const [goods, count] = await this.prisma.$transaction([
this.prisma.good.findMany({
where: {
guild_id: guildId,
is_default_guild_good: true,
},
omit: this.goodOmit,
}),
this.prisma.good.count(),
])
return ResponseMapper.paginate(goods, {
count,
})
}
async findOne(guild_id: string, id: string) {
const good = await this.prisma.good.findUnique({
where: {
guild_id,
id,
is_default_guild_good: true,
},
omit: this.goodOmit,
})
return ResponseMapper.single(good)
}
async create(guild_id: string, data: CreateGoodDto) {
const { category_id, ...rest } = data
const good = await this.prisma.good.create({
data: {
guild: {
connect: {
id: guild_id,
},
},
category: {
connect: {
id: category_id,
},
},
...rest,
is_default_guild_good: true,
},
omit: this.goodOmit,
})
return ResponseMapper.create(good)
}
}