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();
|
}
|
|
}
|