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