package com.czg.controller.admin;

import com.czg.account.dto.freeding.FreeDineConfigEditDTO;
import com.czg.account.service.FreeDineConfigService;
import com.czg.account.vo.FreeDineConfigVO;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.annotation.SaCheckMainShop;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * 霸王餐相关
 * @author Administrator
 */
@RestController
@RequestMapping("/admin/freeDing")
public class FreeDingController {
    @Resource
    private FreeDineConfigService freeDineConfigService;

    /**
     * 获取当前店铺霸王餐配置信息列表
     * @return 霸王餐配置信息 （不存在会新建）
     */
    @SaAdminCheckPermission(parentName = "霸王餐",value = "freeDing:detail", name = "获取霸王餐配置信息")
    @GetMapping
    public CzgResult<FreeDineConfigVO> getConfig() {
        return CzgResult.success(freeDineConfigService.getConfig(StpKit.USER.getMainShopId()));
    }

    /**
     * 修改霸王餐配置信息
     * @param freeDineConfigEditDTO 修改信息
     * @return 霸王餐配置信息
     */
    @SaAdminCheckPermission(parentName = "霸王餐",value = "freeDing:edit", name = "修改霸王餐配置信息")
    @PutMapping
    @SaCheckMainShop
    public CzgResult<Boolean> edit(@RequestBody FreeDineConfigEditDTO freeDineConfigEditDTO) {
        return CzgResult.success(freeDineConfigService.edit(StpKit.USER.getMainShopId(), freeDineConfigEditDTO));
    }
}
