package com.m2pool.lease.controller;


import com.m2pool.lease.annotation.LoginRequired;
import com.m2pool.lease.dto.*;
import com.m2pool.lease.service.LeaseShopService;
import com.m2pool.lease.vo.BaseVo;
import com.m2pool.lease.vo.ShopConfigVo;
import com.m2pool.lease.vo.ShopVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 店铺表 前端控制器
 * </p>
 *
 * @author yyb
 * @since 2025-08-05
 */
@Api(tags = "店铺控制器")
@LoginRequired
@RestController
@RequestMapping("/shop")
public class LeaseShopController {

    @Resource
    private LeaseShopService leaseShopService;

    /**
     * 新增店铺
     * @param shopVo 店铺信息
     * @return 操作结果
     */
    @ApiOperation("新增店铺")
    @PostMapping("/addShop")
    public Result<String> addShop(@RequestBody ShopVo shopVo) {

        return leaseShopService.addShop(shopVo);
    }


    /**
     * 修改店铺
     * @param shopVo 店铺信息
     * @return 操作结果
     */
    @ApiOperation("根据店铺id修改店铺")
    @PostMapping("/updateShop")
    public Result<String> updateShop(@RequestBody ShopVo shopVo) {
        return leaseShopService.updateShop(shopVo);
    }

    /**
     * 关闭/打开店铺
     * @param baseVo 店铺 ID
     * @return 操作结果
     */
    @ApiOperation("根据店铺id关闭店铺")
    @PostMapping("/closeShop")
    public Result<String> closeShop(@RequestBody BaseVo baseVo) {
        return leaseShopService.closeShop(baseVo);
    }

    /**
     * 根据用户邮箱查询店铺
     * @return 店铺信息
     */
    @ApiOperation("根据用户邮箱查询店铺")
    @GetMapping("/getShopByUserEmail")
    public Result<ShopDto> getShopByUserEmail() {
        return leaseShopService.getShopByUserEmail();
    }

    /**
     * 根据店铺id查询店铺
     * @param baseVo 店铺 ID
     * @return 店铺信息
     */
    @ApiOperation("根据店铺id查询店铺")
    @PostMapping("/getShopById")
    public Result<ShopDto> getShopById(@RequestBody BaseVo baseVo) {
        return leaseShopService.getShopById(baseVo);
    }



    /**
     * 删除店铺（逻辑删除）
     * @param baseVo 店铺 ID
     * @return 操作结果
     */
    @ApiOperation("删除店铺")
    @PostMapping("/deleteShop")
    public Result<String> deleteShop(@RequestBody BaseVo baseVo) {
        return leaseShopService.deleteShop(baseVo);
    }



    @ApiOperation("根据店铺id获取到商品列表")
    @PostMapping("/getProductListById")
    public Result<List<ShopNameDto>> getProductListById(@RequestBody BaseVo baseVo) {
        return leaseShopService.getProductListById(baseVo);
    }
    /**
     * 根据店铺id 查询配置信息列表
     * @param baseVo
     * @return 操作结果
     */
    @ApiOperation("钱包配置----根据店铺id查询收款钱包绑定信息列表")
    @PostMapping("/getShopConfig")
    public Result<List<ShopConfigDto>> getShopConfig(@RequestBody BaseVo baseVo) {
        return leaseShopService.getShopConfig(baseVo);
    }

    /**
     * 新增商铺配置 (新增配置时，如果没有指定商品，就默通用配置)
     * @param shopConfigVo 商铺配置信息
     * @return 操作结果
     */
    @ApiOperation("钱包配置---新增商铺收款钱包绑定配置(弃用，业务移到/product/updateProductListForShopWalletConfig 接口)")
    @PostMapping("/addShopConfig")
    @Deprecated
    public Result<String> addShopConfig(@RequestBody ShopConfigVo shopConfigVo) {
        return leaseShopService.addShopConfig(shopConfigVo);
    }



    /**
     * 修改配置
     * @param shopConfigVo 商铺配置信息
     * @return 操作结果
     */
    @ApiOperation("钱包配置----根据配置id 修改商铺收款钱包配置")
    @PostMapping("/updateShopConfig")
    public Result<String> updateShopConfig(@RequestBody ShopConfigVo shopConfigVo) {
        return leaseShopService.updateShopConfig(shopConfigVo);
    }

    /**
     * 删除配置（逻辑删除）
     * @param baseVo 配置 ID
     * @return 操作结果
     */
    @ApiOperation("钱包配置----根据配置id 删除商铺收款钱包配置")
    @PostMapping("/deleteShopConfig")
    public Result<String> deleteShopConfig(@RequestBody BaseVo baseVo) {
        return leaseShopService.deleteShopConfig(baseVo);
    }

    @ApiOperation("钱包配置（用于充值选择链和币种）----获取链(一级)和币(二级) 下拉列表（获取本系统支持的链和币种）")
    @PostMapping("/getChainAndList")
    public Result<List<ChainListDto>> getChainAndList(){
        return leaseShopService.getChainAndList();
    }

    @ApiOperation("钱包配置(用于下单选择商家支持的链和币种)----获取链(一级)和币(二级) 下拉列表（获取本商家支持的链和币种）")
    @PostMapping("/getChainAndListForSeller")
    public Result<List<ChainListDto>> getChainAndListForSeller(@RequestBody BaseVo baseVo){
        return leaseShopService.getChainAndListForSeller(baseVo);
    }


    @ApiOperation("钱包配置(用于修改卖家钱包地址)----获取链(一级)和币(二级) 下拉列表（获取本系统支持的链和币种）")
    @PostMapping("/getChainAndCoin")
    public Result<ChainListDto> getChainAndCoin(@RequestBody BaseVo baseVo){
        return leaseShopService.getChainAndCoin(baseVo);
    }
}

