106 lines
2.7 KiB
TypeScript
106 lines
2.7 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, Post, Put, Query, UseGuards } from '@nestjs/common';
|
|
import { HqAuthGuard } from '../../common/guards/hq-auth.guard';
|
|
import { AdminStoresService } from './admin-stores.service';
|
|
import {
|
|
AdminStoreAccountsQueryDto,
|
|
AdminStoreMediaQueryDto,
|
|
AdminStoresQueryDto,
|
|
} from './dto/admin-query.dto';
|
|
import {
|
|
CreateStoreAccountDto,
|
|
CreateStoreDto,
|
|
CreateStoreMediaDto,
|
|
UpdateStoreAccountDto,
|
|
UpdateStoreDto,
|
|
UpdateStoreMediaDto,
|
|
UpdateStoreStatusDto,
|
|
} from './dto/admin-mutate.dto';
|
|
|
|
@Controller('admin/stores')
|
|
@UseGuards(HqAuthGuard)
|
|
export class AdminStoresController {
|
|
constructor(private readonly service: AdminStoresService) {}
|
|
|
|
@Get()
|
|
list(@Query() query: AdminStoresQueryDto) {
|
|
return this.service.listStores(query);
|
|
}
|
|
|
|
@Get(':id')
|
|
detail(@Param('id') id: string) {
|
|
return this.service.detailStore(BigInt(id));
|
|
}
|
|
|
|
@Post()
|
|
create(@Body() dto: CreateStoreDto) {
|
|
return this.service.createStore(dto);
|
|
}
|
|
|
|
@Put(':id')
|
|
update(@Param('id') id: string, @Body() dto: UpdateStoreDto) {
|
|
return this.service.updateStore(BigInt(id), dto);
|
|
}
|
|
|
|
@Put(':id/status')
|
|
updateStatus(@Param('id') id: string, @Body() dto: UpdateStoreStatusDto) {
|
|
return this.service.updateStoreStatus(BigInt(id), dto);
|
|
}
|
|
|
|
@Put(':id/audit')
|
|
audit(@Param('id') id: string, @Body() body: { approved: boolean; remark?: string }) {
|
|
return this.service.auditStore(BigInt(id), body);
|
|
}
|
|
}
|
|
|
|
@Controller('admin/store-accounts')
|
|
@UseGuards(HqAuthGuard)
|
|
export class AdminStoreAccountsController {
|
|
constructor(private readonly service: AdminStoresService) {}
|
|
|
|
@Get()
|
|
list(@Query() query: AdminStoreAccountsQueryDto) {
|
|
return this.service.listStoreAccounts(query);
|
|
}
|
|
|
|
@Get(':id')
|
|
detail(@Param('id') id: string) {
|
|
return this.service.detailStoreAccount(BigInt(id));
|
|
}
|
|
|
|
@Post()
|
|
create(@Body() dto: CreateStoreAccountDto) {
|
|
return this.service.createStoreAccount(dto);
|
|
}
|
|
|
|
@Put(':id')
|
|
update(@Param('id') id: string, @Body() dto: UpdateStoreAccountDto) {
|
|
return this.service.updateStoreAccount(BigInt(id), dto);
|
|
}
|
|
}
|
|
|
|
@Controller('admin/store-media')
|
|
@UseGuards(HqAuthGuard)
|
|
export class AdminStoreMediaController {
|
|
constructor(private readonly service: AdminStoresService) {}
|
|
|
|
@Get()
|
|
list(@Query() query: AdminStoreMediaQueryDto) {
|
|
return this.service.listStoreMedia(query);
|
|
}
|
|
|
|
@Post()
|
|
create(@Body() dto: CreateStoreMediaDto) {
|
|
return this.service.createStoreMedia(dto);
|
|
}
|
|
|
|
@Put(':id')
|
|
update(@Param('id') id: string, @Body() dto: UpdateStoreMediaDto) {
|
|
return this.service.updateStoreMedia(BigInt(id), dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
remove(@Param('id') id: string) {
|
|
return this.service.deleteStoreMedia(BigInt(id));
|
|
}
|
|
}
|