Class CategoryController

java.lang.Object
com.mt.ecommerce.product.controller.CategoryController

@RestController @RequestMapping("/category") public class CategoryController extends Object
Controller for managing product categories. Provides endpoints for adding, updating, deleting, and retrieving categories.
  • Constructor Details

    • CategoryController

      public CategoryController(CategoryService categoryService)
  • Method Details

    • addCategory

      @PreAuthorize("hasAnyAuthority(\'ROLE_VENDOR\', \'ROLE_ADMIN\')") @PostMapping(value="", consumes="application/json", produces="application/json") public CategoryBO addCategory(@RequestBody CategoryBO categoryBO, @AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails userDetails)
      Endpoint to add a new category. Accessible by users with ROLE_VENDOR or ROLE_ADMIN.
      Parameters:
      categoryBO - the category information to add
      userDetails - the authenticated user's details
      Returns:
      the added CategoryBO
    • updateCategory

      @PreAuthorize("hasAnyAuthority(\'ROLE_VENDOR\', \'ROLE_ADMIN\')") @PutMapping(value="", consumes="application/json", produces="application/json") public CategoryBO updateCategory(@RequestBody CategoryBO categoryBO, @AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails userDetails)
      Endpoint to update an existing category. Accessible by users with ROLE_VENDOR or ROLE_ADMIN.
      Parameters:
      categoryBO - the category information to update
      userDetails - the authenticated user's details
      Returns:
      the updated CategoryBO
    • deleteCategory

      @PreAuthorize("hasAnyAuthority(\'ROLE_VENDOR\', \'ROLE_ADMIN\')") @DeleteMapping(value="", consumes="application/json") public void deleteCategory(@RequestParam(name="categoryId") String categoryId, @RequestParam(name="vendorId") String vendorId, @AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails userDetails)
      Endpoint to delete a category. Accessible by users with ROLE_VENDOR or ROLE_ADMIN.
      Parameters:
      categoryId - the ID of the category to delete
      vendorId - the ID of the vendor
      userDetails - the authenticated user's details
    • getCategories

      @GetMapping(value="/unsecured/all", produces="application/json") public List<CategoryBO> getCategories(@RequestParam(name="vendorId") String vendorId, @RequestParam(name="pageNo",defaultValue="0") int pageNo, @RequestParam(name="size",defaultValue="10") int size)
      Endpoint to retrieve categories for a specific vendor with pagination. This endpoint is unsecured and can be accessed without authentication.
      Parameters:
      vendorId - the ID of the vendor
      pageNo - the page number for pagination (default is 0)
      size - the number of items per page (default is 10)
      Returns:
      a list of CategoryBO objects