v3数据表更改
This commit is contained in:
@@ -12,14 +12,14 @@ export class AdminCitiesService {
|
||||
async list(query: AdminCitiesQueryDto) {
|
||||
const page = query.page ?? 1;
|
||||
const pageSize = query.pageSize ?? 20;
|
||||
const where: Prisma.CityWhereInput = {};
|
||||
const where: Prisma.CommonCityWhereInput = {};
|
||||
if (query.name) where.name = { contains: query.name };
|
||||
if (query.code) where.code = { contains: query.code };
|
||||
if (query.status) where.status = query.status as Prisma.EnumCityStatusFilter['equals'];
|
||||
if (query.partnerId) where.partnerId = BigInt(query.partnerId);
|
||||
|
||||
const [items, total] = await Promise.all([
|
||||
this.prisma.city.findMany({
|
||||
this.prisma.commonCity.findMany({
|
||||
where,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
skip: (page - 1) * pageSize,
|
||||
@@ -29,7 +29,7 @@ export class AdminCitiesService {
|
||||
_count: { select: { stores: true, orders: true } },
|
||||
},
|
||||
}),
|
||||
this.prisma.city.count({ where }),
|
||||
this.prisma.commonCity.count({ where }),
|
||||
]);
|
||||
return serializeBigInt({
|
||||
items: items.map((c) => ({
|
||||
@@ -45,7 +45,7 @@ export class AdminCitiesService {
|
||||
}
|
||||
|
||||
async detail(id: bigint) {
|
||||
const city = await this.prisma.city.findUnique({
|
||||
const city = await this.prisma.commonCity.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
partner: true,
|
||||
@@ -58,9 +58,9 @@ export class AdminCitiesService {
|
||||
}
|
||||
|
||||
async create(dto: CreateCityDto) {
|
||||
const exists = await this.prisma.city.findUnique({ where: { code: dto.code } });
|
||||
const exists = await this.prisma.commonCity.findUnique({ where: { code: dto.code } });
|
||||
if (exists) throw new BadRequestException('城市编码已存在');
|
||||
const city = await this.prisma.city.create({
|
||||
const city = await this.prisma.commonCity.create({
|
||||
data: {
|
||||
code: dto.code,
|
||||
name: dto.name,
|
||||
@@ -79,7 +79,7 @@ export class AdminCitiesService {
|
||||
}
|
||||
|
||||
async update(id: bigint, dto: UpdateCityDto) {
|
||||
const city = await this.prisma.city.update({
|
||||
const city = await this.prisma.commonCity.update({
|
||||
where: { id },
|
||||
data: {
|
||||
...(dto.name !== undefined ? { name: dto.name } : {}),
|
||||
|
||||
Reference in New Issue
Block a user