package com.starry.admin.modules.shop.controller;

import com.starry.admin.modules.shop.module.entity.ShopUiSettingEntity;
import com.starry.admin.modules.shop.service.IShopUiSettingService;
import com.starry.common.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 店铺设置Controller
 *
 * @author admin
 * @since 2025-06-11
 */
@Api(tags = "店铺UI设置", description = "店铺UI设置相关接口，包括查询和修改操作")
@RestController
@RequestMapping("/play/setting")
public class ShopUiSettingController {
    @Resource
    private IShopUiSettingService shopUiSettingService;

    /**
     * 获取店铺设置详细信息
     */
    @ApiOperation(value = "获取店铺设置信息", notes = "获取店铺UI设置详细信息")
    @ApiResponses({@ApiResponse(code = 200, message = "操作成功", response = ShopUiSettingEntity.class)})
    @GetMapping(value = "/info")
    public R getInfo() {
        return R.ok(shopUiSettingService.selectShopUiSettingInfo());
    }

    /**
     * 修改店铺设置
     */
    @ApiOperation(value = "修改店铺设置", notes = "修改店铺UI设置信息")
    @ApiResponses({@ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "修改失败，包含详细错误信息")})
    @PostMapping(value = "/update")
    public R update(@ApiParam(value = "店铺UI设置信息", required = true) @RequestBody ShopUiSettingEntity shopUiSetting) {
        boolean success = shopUiSettingService.update(shopUiSetting);
        if (success) {
            return R.ok();
        }
        return R.error("修改失败");
    }

}
