update controllers
This commit is contained in:
@@ -5,13 +5,7 @@ import { CreateIconDto } from '../dto/create-icon.dto';
|
||||
import { UpdateIconDto } from '../dto/update-icon.dto';
|
||||
import { CreateGroupDto } from '../dto/create-group.dto';
|
||||
import { UpdateGroupDto } from '../dto/update-group.dto';
|
||||
import {
|
||||
ApiTags,
|
||||
ApiOperation,
|
||||
ApiParam,
|
||||
ApiBody,
|
||||
ApiBearerAuth,
|
||||
} from '@nestjs/swagger';
|
||||
import { ApiTags, ApiOperation, ApiParam, ApiBody, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { SuperAdminAuthGuard } from 'src/modules/auth/guards/superAdminAuth.guard';
|
||||
import { UseGuards } from '@nestjs/common';
|
||||
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
||||
@@ -22,14 +16,14 @@ export class IconsController {
|
||||
constructor(
|
||||
private readonly iconService: IconService,
|
||||
private readonly groupService: GroupService,
|
||||
) { }
|
||||
) {}
|
||||
|
||||
@Get('admin/groups/icons')
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Get all icons' })
|
||||
findAllPublicIcons() {
|
||||
return this.groupService.findAllPublic();
|
||||
return this.groupService.findAllGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,13 +81,15 @@ export class IconsController {
|
||||
@Get('super-admin/icons/groups')
|
||||
@UseGuards(SuperAdminAuthGuard)
|
||||
@ApiOperation({ summary: 'Get all icon groups' })
|
||||
findAllGroups() {
|
||||
return this.groupService.findAll();
|
||||
async findAllGroups() {
|
||||
console.log('find icona');
|
||||
const a = await this.groupService.findAllGroups();
|
||||
console.log(a);
|
||||
return a;
|
||||
}
|
||||
|
||||
@Get('super-admin/icons/groups/:id')
|
||||
@UseGuards(SuperAdminAuthGuard)
|
||||
|
||||
@ApiOperation({ summary: 'Get icon group by id' })
|
||||
@ApiParam({ name: 'id', required: true, type: String })
|
||||
findOneGroup(@Param('id') id: string) {
|
||||
|
||||
@@ -12,7 +12,7 @@ export class GroupService {
|
||||
constructor(
|
||||
private readonly groupRepository: GroupRepository,
|
||||
private readonly em: EntityManager,
|
||||
) { }
|
||||
) {}
|
||||
|
||||
async create(dto: CreateGroupDto): Promise<Group> {
|
||||
const data: RequiredEntityData<Group> = {
|
||||
@@ -24,10 +24,6 @@ export class GroupService {
|
||||
return group;
|
||||
}
|
||||
|
||||
async findAll(): Promise<Group[]> {
|
||||
return this.groupRepository.find({}, { populate: ['icons'] });
|
||||
}
|
||||
|
||||
async findOne(id: string): Promise<Group> {
|
||||
const group = await this.groupRepository.findOne({ id }, { populate: ['icons'] });
|
||||
if (!group) {
|
||||
@@ -54,8 +50,7 @@ export class GroupService {
|
||||
await this.em.removeAndFlush(group);
|
||||
}
|
||||
|
||||
findAllPublic(): Promise<Group[]> {
|
||||
return this.groupRepository.find({ deletedAt: null }, { populate: ['icons'] });
|
||||
findAllGroups(): Promise<Group[]> {
|
||||
return this.groupRepository.find({}, { populate: ['icons'] });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user