xin
2025-07-15 8a1d5d73f8dfb2b9613f905a4738a90468166bee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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<Object> 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<Long> ids) {
        storeCategoryService.deleteAll(ids);
        return ResponseEntity.noContent().build();
    }
}