package com.ruoyi.brewery.controller;

import com.ruoyi.bar.domain.WyBarIcon;
import com.ruoyi.bar.service.IWyBarIconService;
import com.ruoyi.brewery.domain.WyBeer;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

@Api(tags = "啤酒币相关接口")
@RestController
@RequestMapping("/brewery/beerCoin")
public class BeerCoinController extends BaseController {
    @Resource
    private IWyBarIconService wyBarIconService;

    /**
     * 查询持有啤酒币的门店
     */
    @ApiOperation("查询持有啤酒币的门店")
    @PreAuthorize("@bss.hasPermi('brewery:beerCoin:bars')")
    @GetMapping("/bars")
    public TableDataInfo bars()
    {

        startPage();
        final WyBarIcon wyBarIcon = new WyBarIcon();
        wyBarIcon.setBreweryId(SecurityUtils.getBreweryLoginUser().getBreweryId());
        final List<WyBarIcon> wyBarIcons = wyBarIconService.selectWyBarIconListWithData(wyBarIcon);
        return getDataTable(wyBarIcons);
    }

    /**
     * 酒厂啤酒币数据统计
     */
    @ApiOperation("酒厂啤酒币数据统计")
    @PreAuthorize("@bss.hasPermi('brewery:beerCoin:statistics')")
    @GetMapping("/statistics")
    public AjaxResult statistics()
    {
        final HashMap<String, Integer> hashMap = wyBarIconService.selectBarIconDataByBreweryId(SecurityUtils.getBreweryLoginUser().getBreweryId());
        return AjaxResult.success(hashMap);
    }
}
