Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RestController
- @Secured("hasRole('ADMIN')")
- @RequestMapping(value = "/api/v1")
- public class ApiController {
- @Autowired
- private PageService pageService;
- @Autowired
- private ImageService imageService;
- @Autowired
- private ConfigService configService;
- @Autowired
- private CategoryService categoryService;
- @Autowired
- private UploadFileService uploadFileService;
- private static final Logger LOGGER = LogManager.getLogger(ApiController.class);
- @PostMapping(value = "/categories/load", produces = MediaType.APPLICATION_JSON_VALUE)
- private Response categoriesLoad(Response response) {
- response.setSuccess("OK");
- response.addData("categories", categoryService.getAll());
- return response;
- }
- @PostMapping(value = "/category/add", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
- private Response categoryAdd(Response response, CategoryAddForm categoryFormAdd) {
- categoryService.add(response, categoryFormAdd);
- return response;
- }
- @PostMapping(value = "/category/info", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
- private Response categoryInfo(Response response, @RequestParam("categoryId") Integer categoryId) {
- categoryService.info(response, categoryId);
- return response;
- }
- @PostMapping(value = "/category/save", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
- private Response categorySave(Response response, CategorySaveForm categorySaveForm) {
- categoryService.save(response, categorySaveForm);
- return response;
- }
- @PostMapping(value = "/category/remove", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
- private Response categoryRemove(Response response, @RequestParam("categoryId") Integer categoryId) {
- categoryService.remove(response, categoryId);
- return response;
- }
- @PostMapping(value = "/category/load", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
- private Response categoryLoad(Response response, CategoryLoadForm categoryLoad) {
- categoryService.load(response, categoryLoad);
- return response;
- }
- @PostMapping(value = "/image/add", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
- private Response imageAdd(Response response, ImageAddForm imageAddForm) {
- imageService.add(response, imageAddForm);
- return response;
- }
- @PostMapping(value = "/page/add", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
- private Response pageAdd(Response response, PageAddForm pageAddForm) {
- pageService.add(response, pageAddForm);
- return response;
- }
- @PostMapping(value = "/upload/image", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
- private Response uploadImage(Response response, @RequestParam("file") MultipartFile file, HttpServletRequest request) {
- uploadFileService.upload(response, file);
- return response;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement