zepengdev
2025-06-04 e8109eee3549d43fc4de2fe4286e29a4152f824d
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
package com.oying.modules.pc.store.rest;
 
import com.oying.utils.R;
import com.oying.modules.pc.common.id.StoreIdGenerator;
import com.oying.modules.pc.store.domain.Store;
import com.oying.modules.pc.store.domain.dto.*;
import com.oying.modules.pc.store.service.StoreService;
import com.oying.utils.SecurityUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
 
import java.time.ZonedDateTime;
 
/**
 * 店铺
 *
 * @author lzp
 * @date 2025-04-22
 */
@RestController
@RequestMapping("/api/pc/store")
@RequiredArgsConstructor
public class StoreController {
 
    private final StoreService storeService;
 
    @GetMapping(value = "/page")
    public R<?> getStoresByPage(StoreQueryCriteria criteria) {
        return R.success(storeService.queryByPage(criteria));
    }
 
    @GetMapping(value = "/list")
    public R<?> getStores(StoreQueryCriteria criteria) {
        return R.success(storeService.queryAll(criteria));
    }
 
    @GetMapping(value = "/{storeId}")
    public R<?> getStoreById(@PathVariable("storeId") Long storeId) {
        return R.success(storeService.getById(storeId));
    }
 
    @GetMapping(value = "/{storeId}/details")
    public R<?> getStoreDetailsById(@PathVariable("storeId") Long storeId) {
        return R.success(storeService.getById(storeId));
    }
 
    @PostMapping(value = "/createEmpty")
    public R<?> createEmpty(@RequestBody StoreCreateRequest request) {
        Store store = new Store();
        store.setStoreId(StoreIdGenerator.getId());
        store.setMerchantId(SecurityUtils.getCurrentUserId());
        storeService.save(store);
        return R.success();
    }
 
    /**
     * 修改店铺信息
     */
    @PostMapping(value = "/{storeId}")
    public R<?> update(@PathVariable("storeId") Long storeId, @RequestBody Store store) {
        store.setStoreId(storeId);
        storeService.updateById(store);
        return R.success();
    }
 
}