product verity
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { inject } from "inversify";
|
||||
import { controller, httpDelete, httpPatch, httpPost, requestBody, requestParam } from "inversify-express-utils";
|
||||
import { controller, httpDelete, httpGet, httpPatch, httpPost, httpPut, requestBody, requestParam } from "inversify-express-utils";
|
||||
|
||||
import { HttpStatus } from "../../../common";
|
||||
import { BaseController } from "../../../common/base/controller";
|
||||
@@ -12,14 +12,20 @@ import { CategoryService } from "../../category/category.service";
|
||||
import { CreateCategoryDTO } from "../../category/DTO/CreateCategory.dto";
|
||||
import { CreateCategoryAttDTO } from "../../category/DTO/createCategoryAtt.dto";
|
||||
import { CreateCategoryThemeDTO, UpdateCategoryVariantDTO } from "../../category/DTO/createCategoryTheme.dto";
|
||||
import { CreateThemeDTO } from "../../category/DTO/CreateTheme.dto";
|
||||
import { CreateThemeValueDTO } from "../../category/DTO/CreateThemeValue.dto";
|
||||
import { UpdateCategoryDTO } from "../../category/DTO/UpdateCategory.dto";
|
||||
import { UpdateCategoryAttDTO } from "../../category/DTO/updateCategoryAtt.dto";
|
||||
import { UpdateThemeDTO } from "../../category/DTO/UpdateTheme.dto";
|
||||
import { UpdateThemeValueDTO } from "../../category/DTO/UpdateThemeValue.dto";
|
||||
import { ThemeService } from "../../category/theme.service";
|
||||
import { PermissionEnum } from "../models/Abstraction/IPermission";
|
||||
|
||||
@ApiTags("Admin Category")
|
||||
@controller("/admin/category")
|
||||
export class AdminCategoryController extends BaseController {
|
||||
@inject(IOCTYPES.CategoryService) private categoryService: CategoryService;
|
||||
@inject(IOCTYPES.ThemeService) private themeService: ThemeService;
|
||||
|
||||
@ApiOperation("create a category ")
|
||||
@ApiResponse("return created category", HttpStatus.Created)
|
||||
@@ -134,4 +140,127 @@ export class AdminCategoryController extends BaseController {
|
||||
const data = await this.categoryService.updateCategoryAttributeS(createAttributeDto);
|
||||
return this.response({ data }, HttpStatus.Created);
|
||||
}
|
||||
|
||||
//#########################################theme endpoints
|
||||
@ApiOperation("Get all themes")
|
||||
@ApiResponse("get all themes", HttpStatus.Ok)
|
||||
@httpGet("/theme")
|
||||
public async getAllThemes() {
|
||||
const data = await this.themeService.getAllThemes();
|
||||
return this.response({ data });
|
||||
}
|
||||
|
||||
@ApiOperation("Get a theme with id")
|
||||
@ApiResponse("get a theme", HttpStatus.Ok)
|
||||
@ApiParam("id", "id of the theme", true)
|
||||
@httpGet("/theme/:id")
|
||||
public async getThemeById(@requestParam("id") id: string) {
|
||||
const data = await this.themeService.getThemeById(id);
|
||||
return this.response({ data });
|
||||
}
|
||||
|
||||
@ApiOperation("Create a new theme ==> need to login as admin")
|
||||
@ApiResponse("theme created successfully", HttpStatus.Created)
|
||||
@ApiModel(CreateThemeDTO)
|
||||
@ApiAuth()
|
||||
@httpPost(
|
||||
"/theme",
|
||||
Guard.authAdmin(),
|
||||
Guard.checkAdminPermissions([PermissionEnum.ADMIN]),
|
||||
ValidationMiddleware.validateInput(CreateThemeDTO),
|
||||
)
|
||||
public async createTheme(@requestBody() createDto: CreateThemeDTO) {
|
||||
const data = await this.themeService.createTheme(createDto);
|
||||
return this.response({ data }, HttpStatus.Created);
|
||||
}
|
||||
|
||||
@ApiOperation("Update a theme ==> need to login as admin")
|
||||
@ApiResponse("theme updated successfully", HttpStatus.Ok)
|
||||
@ApiAuth()
|
||||
@httpPut(
|
||||
"/theme",
|
||||
Guard.authAdmin(),
|
||||
Guard.checkAdminPermissions([PermissionEnum.ADMIN]),
|
||||
ValidationMiddleware.validateInput(UpdateThemeDTO),
|
||||
)
|
||||
public async updateTheme(@requestBody() updateDto: UpdateThemeDTO) {
|
||||
const data = await this.themeService.updateTheme(updateDto);
|
||||
return this.response({ data });
|
||||
}
|
||||
|
||||
@ApiOperation("Delete a theme ==> need to login as admin")
|
||||
@ApiResponse("theme deleted successfully", HttpStatus.Ok)
|
||||
@ApiParam("id", "id of the theme", true)
|
||||
@ApiAuth()
|
||||
@httpDelete("/theme/:id", Guard.authAdmin(), Guard.checkAdminPermissions([PermissionEnum.ADMIN]))
|
||||
public async deleteTheme(@requestParam("id") id: string) {
|
||||
const data = await this.themeService.deleteTheme(id);
|
||||
return this.response({ data });
|
||||
}
|
||||
|
||||
//#########################################theme value endpoints
|
||||
@ApiOperation("Get all theme values")
|
||||
@ApiResponse("get all theme values", HttpStatus.Ok)
|
||||
@httpGet("/theme-value")
|
||||
public async getAllThemeValues() {
|
||||
const data = await this.themeService.getAllThemeValues();
|
||||
return this.response({ data });
|
||||
}
|
||||
|
||||
@ApiOperation("Get theme values by theme id")
|
||||
@ApiResponse("get theme values by theme id", HttpStatus.Ok)
|
||||
@ApiParam("themeId", "id of the theme", true)
|
||||
@httpGet("/theme-value/:themeId/values")
|
||||
public async getThemeValuesByThemeId(@requestParam("themeId") themeId: string) {
|
||||
const data = await this.themeService.getThemeValuesByThemeId(themeId);
|
||||
return this.response({ data });
|
||||
}
|
||||
|
||||
@ApiOperation("Get a theme value with id")
|
||||
@ApiResponse("get a theme value", HttpStatus.Ok)
|
||||
@ApiParam("id", "id of the theme value", true)
|
||||
@httpGet("/theme-value/:id")
|
||||
public async getThemeValueById(@requestParam("id") id: string) {
|
||||
const data = await this.themeService.getThemeValueById(id);
|
||||
return this.response({ data });
|
||||
}
|
||||
|
||||
@ApiOperation("Create a new theme value ==> need to login as admin")
|
||||
@ApiResponse("theme value created successfully", HttpStatus.Created)
|
||||
@ApiAuth()
|
||||
@ApiModel(CreateThemeValueDTO)
|
||||
@httpPost(
|
||||
"/theme-value",
|
||||
Guard.authAdmin(),
|
||||
Guard.checkAdminPermissions([PermissionEnum.ADMIN]),
|
||||
ValidationMiddleware.validateInput(CreateThemeValueDTO),
|
||||
)
|
||||
public async createThemeValue(@requestBody() createDto: CreateThemeValueDTO) {
|
||||
const data = await this.themeService.createThemeValue(createDto);
|
||||
return this.response({ data }, HttpStatus.Created);
|
||||
}
|
||||
|
||||
@ApiOperation("Update a theme value ==> need to login as admin")
|
||||
@ApiResponse("theme value updated successfully", HttpStatus.Ok)
|
||||
@ApiAuth()
|
||||
@httpPut(
|
||||
"/theme-value",
|
||||
Guard.authAdmin(),
|
||||
Guard.checkAdminPermissions([PermissionEnum.ADMIN]),
|
||||
ValidationMiddleware.validateInput(UpdateThemeValueDTO),
|
||||
)
|
||||
public async updateThemeValue(@requestBody() updateDto: UpdateThemeValueDTO) {
|
||||
const data = await this.themeService.updateThemeValue(updateDto);
|
||||
return this.response({ data });
|
||||
}
|
||||
|
||||
@ApiOperation("Delete a theme value ==> need to login as admin")
|
||||
@ApiResponse("theme value deleted successfully", HttpStatus.Ok)
|
||||
@ApiParam("id", "id of the theme value", true)
|
||||
@ApiAuth()
|
||||
@httpDelete("/theme-value/:id", Guard.authAdmin(), Guard.checkAdminPermissions([PermissionEnum.ADMIN]))
|
||||
public async deleteThemeValue(@requestParam("id") id: string) {
|
||||
const data = await this.themeService.deleteThemeValue(id);
|
||||
return this.response({ data });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user