package shop.alien.store.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.entity.store.vo.StoreGroupPackageVO;
import shop.alien.store.service.StoreGroupPackageService;

/**
 * <p>
 * 八大类团购套餐表 前端控制器
 * </p>
 *
 * @author ssk
 * @since 2025-04-29
 */
@Api(tags = {"八大类团购套餐表"})
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/storeGroupPackage")
@RequiredArgsConstructor
public class StoreGroupPackageController {

    private final StoreGroupPackageService storeGroupPackageService;

    @ApiOperation("创建团购-二期")
    @PostMapping("/addGroup")
    public R<StoreGroupPackageVO> addGroup(@RequestBody StoreGroupPackageVO storeGroupPackageVO) {
        log.info("StoreGroupPackageController.addGroup?storeGroupPackageVO={}", storeGroupPackageVO.toString());
        try {
            StoreGroupPackageVO packageVO = storeGroupPackageService.addGroup(storeGroupPackageVO);
            return R.data(packageVO);
        } catch (Exception e) {
            return R.fail(e.getMessage());
        }
    }

    @ApiOperation("创建团购（酒店）-二期")
    @PostMapping("/addHotelGroup")
    public R<StoreGroupPackageVO> addHotelGroup(@RequestBody StoreGroupPackageVO storeGroupPackageVO) {
        log.info("StoreGroupPackageController.addHotelGroup,storeGroupPackageVO={}", storeGroupPackageVO.toString());
        try {
            StoreGroupPackageVO packageVO = storeGroupPackageService.addHotelGroup(storeGroupPackageVO);
            return R.data(packageVO);
        } catch (Exception e) {
            return R.fail(e.getMessage());
        }
    }
}
