package com.oying.modules.pc.store.rest; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.oying.modules.pc.store.domain.StoreCategory; import com.oying.modules.pc.store.domain.dto.StoreCategoryCreateRequest; import com.oying.modules.pc.store.domain.dto.StoreCategoryQueryCriteria; import com.oying.modules.pc.store.domain.dto.StoreCategoryUpdateRequest; import com.oying.modules.pc.store.service.StoreCategoryService; import com.oying.utils.R; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; /** * @author lzp * @date 2025-04-24 **/ @Api(tags = "商品中心:店铺类目") @RestController @RequiredArgsConstructor @RequestMapping("/api/pc/storeCategory") public class StoreCategoryController { private final StoreCategoryService storeCategoryService; @GetMapping(value = "/list") @ApiOperation("查询") public ResponseEntity getStoreCategories(StoreCategoryQueryCriteria criteria) { return ResponseEntity.ok(R.success(storeCategoryService.queryAll(criteria))); } @GetMapping(value = "/page") @ApiOperation("查询") public ResponseEntity getStoreCategoriesByPage(StoreCategoryQueryCriteria criteria) { Page page = new Page<>(criteria.getPage(), criteria.getSize()); return ResponseEntity.ok(R.success(storeCategoryService.queryAll(criteria, page))); } @GetMapping(value = "/{categoryId}") @ApiOperation("查询") public ResponseEntity getStoreCategory(@PathVariable Long categoryId) { return ResponseEntity.ok(R.success(storeCategoryService.getById(categoryId))); } @PostMapping @ApiOperation("新增") // @PreAuthorize("@el.check('storeCategory:add')") public ResponseEntity createStoreCategory(@Validated @RequestBody StoreCategoryCreateRequest request) { StoreCategory storeCategory = new StoreCategory(); BeanUtil.copyProperties(request, storeCategory, CopyOptions.create().setIgnoreNullValue(true)); storeCategoryService.create(storeCategory); return ResponseEntity.status(HttpStatus.CREATED).build(); } @PutMapping @ApiOperation("修改") // @PreAuthorize("@el.check('storeCategory:edit')") public ResponseEntity updateStoreCategory(@Validated @RequestBody StoreCategoryUpdateRequest request) { StoreCategory storeCategory = new StoreCategory(); BeanUtil.copyProperties(request, storeCategory, CopyOptions.create().setIgnoreNullValue(true)); storeCategoryService.update(storeCategory); return ResponseEntity.noContent().build(); } @DeleteMapping @ApiOperation("删除") // @PreAuthorize("@el.check('storeCategory:del')") public ResponseEntity deleteStoreCategory(@ApiParam(value = "传ID数组[]") @RequestBody List ids) { storeCategoryService.deleteAll(ids); return ResponseEntity.noContent().build(); } }