feat(admin): country drag-sort + always-available member detail sync
- Country 加 sort_order(默认 0 保持 id 序);PATCH /countries/sort 批量保存 顺序(对齐 /tags/sort 模式);findAll 与公开 /public/countries 均按 sortOrder 排序 - CountriesView 表格改为可拖拽行列表:拖动松开即全量保存新顺序,失败回滚 - 商品编辑弹窗成员展开面板:同步详情按钮常驻(已同步显示 重新同步详情), 不再只在未同步态出现 - goods.service.spec 的 FamilyRecomputeService mock 补齐 syncFamilyTags 等 方法(全量并行时其他套件的扫名归族会把本套件夹具收进族,create/update 会调用到,mock 缺方法导致偶发 TypeError) - api 164/164、admin typecheck+22/22+构建全绿
This commit is contained in:
@@ -8,13 +8,29 @@ import {
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { CreateCountryDto } from './dto/create-country.dto';
|
||||
import { UpdateCountryDto } from './dto/update-country.dto';
|
||||
import { ReorderCountriesDto } from './dto/reorder-countries.dto';
|
||||
|
||||
@Injectable()
|
||||
export class CountriesService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
findAll() {
|
||||
return this.prisma.country.findMany({ orderBy: { id: 'asc' } });
|
||||
return this.prisma.country.findMany({
|
||||
orderBy: [{ sortOrder: 'asc' }, { id: 'asc' }],
|
||||
});
|
||||
}
|
||||
|
||||
/** 批量保存拖拽后的顺序(全量提交,sortOrder = 目标下标) */
|
||||
async reorder(dto: ReorderCountriesDto) {
|
||||
await this.prisma.$transaction(
|
||||
dto.items.map((item) =>
|
||||
this.prisma.country.update({
|
||||
where: { id: BigInt(item.id) },
|
||||
data: { sortOrder: item.sortOrder },
|
||||
}),
|
||||
),
|
||||
);
|
||||
return this.findAll();
|
||||
}
|
||||
|
||||
async findOne(id: bigint) {
|
||||
|
||||
Reference in New Issue
Block a user