|
| 1 | +package com.salesmanager.shop.store.api.v1.catalog; |
| 2 | + |
| 3 | +import javax.validation.Valid; |
| 4 | + |
| 5 | +import org.slf4j.Logger; |
| 6 | +import org.slf4j.LoggerFactory; |
| 7 | +import org.springframework.beans.factory.annotation.Autowired; |
| 8 | +import org.springframework.web.bind.annotation.PathVariable; |
| 9 | +import org.springframework.web.bind.annotation.PostMapping; |
| 10 | +import org.springframework.web.bind.annotation.PutMapping; |
| 11 | +import org.springframework.web.bind.annotation.RequestBody; |
| 12 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 13 | +import org.springframework.web.bind.annotation.ResponseStatus; |
| 14 | +import org.springframework.web.bind.annotation.RestController; |
| 15 | +import org.springframework.http.HttpStatus; |
| 16 | + |
| 17 | +import com.salesmanager.core.model.merchant.MerchantStore; |
| 18 | +import com.salesmanager.core.model.reference.language.Language; |
| 19 | +import com.salesmanager.shop.model.catalog.catalog.PersistableCatalog; |
| 20 | +import com.salesmanager.shop.model.catalog.catalog.ReadableCatalog; |
| 21 | +import com.salesmanager.shop.store.controller.catalog.facade.CatalogFacade; |
| 22 | + |
| 23 | +import io.swagger.annotations.Api; |
| 24 | +import io.swagger.annotations.ApiImplicitParam; |
| 25 | +import io.swagger.annotations.ApiImplicitParams; |
| 26 | +import io.swagger.annotations.ApiOperation; |
| 27 | +import io.swagger.annotations.SwaggerDefinition; |
| 28 | +import io.swagger.annotations.Tag; |
| 29 | +import springfox.documentation.annotations.ApiIgnore; |
| 30 | + |
| 31 | +@RestController |
| 32 | +@RequestMapping(value = "/api/v1") |
| 33 | +@Api(tags = {"Catalog management resource (Catalog Management Api)"}) |
| 34 | +@SwaggerDefinition(tags = { |
| 35 | + @Tag(name = "Catalog management resource", description = "Manage catalogs and attached products") |
| 36 | +}) |
| 37 | +public class CatalogApi { |
| 38 | + |
| 39 | + private static final Logger LOGGER = LoggerFactory.getLogger(CatalogApi.class); |
| 40 | + |
| 41 | + @Autowired |
| 42 | + private CatalogFacade catalogFacade; |
| 43 | + |
| 44 | + |
| 45 | +/* @GetMapping(value = "/content/folder", produces = MediaType.APPLICATION_JSON_VALUE) |
| 46 | + @ApiImplicitParams({ |
| 47 | + @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), |
| 48 | + @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en")}) |
| 49 | + public ContentFolder folder(@RequestParam(value = "path", required = false) String path, |
| 50 | + @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) throws Exception { |
| 51 | + String decodedPath = decodeContentPath(path); |
| 52 | + return contentFacade.getContentFolder(decodedPath, merchantStore); |
| 53 | + } |
| 54 | +
|
| 55 | +*/ |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + @PostMapping(value = "/private/catalog") |
| 60 | + @ResponseStatus(HttpStatus.OK) |
| 61 | + @ApiOperation(httpMethod = "POST", value = "Create catalog", notes = "", |
| 62 | + response = Void.class) |
| 63 | + @ApiImplicitParams({ |
| 64 | + @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), |
| 65 | + @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en")}) |
| 66 | + public ReadableCatalog createCatalog( |
| 67 | + @RequestBody @Valid PersistableCatalog catalog, |
| 68 | + @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) { |
| 69 | + |
| 70 | + return catalogFacade.saveCatalog(catalog, merchantStore); |
| 71 | + |
| 72 | + } |
| 73 | + |
| 74 | + @PutMapping(value = "/private/catalog/{id}") |
| 75 | + @ResponseStatus(HttpStatus.OK) |
| 76 | + @ApiOperation(httpMethod = "PUT", value = "Update catalog", notes = "", |
| 77 | + response = Void.class) |
| 78 | + @ApiImplicitParams({ |
| 79 | + @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), |
| 80 | + @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en")}) |
| 81 | + public void updateCatalog( |
| 82 | + @PathVariable Long id, |
| 83 | + @RequestBody @Valid PersistableCatalog catalog, |
| 84 | + @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) { |
| 85 | + |
| 86 | + catalog.setId(id); |
| 87 | + catalogFacade.saveCatalog(catalog, merchantStore); |
| 88 | + } |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | +/* @DeleteMapping(value = "/private/content/") |
| 93 | + @ApiOperation(httpMethod = "DETETE", value = "Deletes a file from CMS", notes = "Delete a file from server", |
| 94 | + response = Void.class) |
| 95 | + @ApiImplicitParams({ |
| 96 | + @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), |
| 97 | + @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en")}) |
| 98 | + public void deleteFile( |
| 99 | + @Valid ContentName name, |
| 100 | + @ApiIgnore MerchantStore merchantStore, |
| 101 | + @ApiIgnore Language language) { |
| 102 | + contentFacade.delete(merchantStore, name.getName(), name.getContentType()); |
| 103 | + }*/ |
| 104 | +} |
0 commit comments