Class CategoryController
java.lang.Object
com.mt.ecommerce.product.controller.CategoryController
Controller for managing product categories.
Provides endpoints for adding, updating, deleting, and retrieving categories.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCategory
(CategoryBO categoryBO, org.springframework.security.core.userdetails.UserDetails userDetails) Endpoint to add a new category.void
deleteCategory
(String categoryId, String vendorId, org.springframework.security.core.userdetails.UserDetails userDetails) Endpoint to delete a category.getCategories
(String vendorId, int pageNo, int size) Endpoint to retrieve categories for a specific vendor with pagination.updateCategory
(CategoryBO categoryBO, org.springframework.security.core.userdetails.UserDetails userDetails) Endpoint to update an existing category.
-
Constructor Details
-
CategoryController
-
-
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 adduserDetails
- 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 updateuserDetails
- 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 deletevendorId
- the ID of the vendoruserDetails
- 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 vendorpageNo
- the page number for pagination (default is 0)size
- the number of items per page (default is 10)- Returns:
- a list of CategoryBO objects
-