package com.ruoyi.bar;

import com.ruoyi.bar.domain.WyBar;
import com.ruoyi.bar.service.IWyBarService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.model.BarLoginUser;
import com.ruoyi.common.utils.SecurityUtils;

import javax.annotation.Resource;

public class BarBaseController extends BaseController {
    @Resource
    private IWyBarService wyBarService;

    protected void validateBarAuth() {
        BarLoginUser loginUser = SecurityUtils.getBarLoginUser();
        if (loginUser == null) {
            throw new RuntimeException("用户未登录，请先登录");
        }
        if (loginUser.getBarId() == null || loginUser.getBarId() == 0) {
            throw new RuntimeException("门店尚未入住，请先完成入住");
        }
        WyBar wyBar = wyBarService.selectWyBarById(loginUser.getBarId());
        if (wyBar == null || wyBar.getAuthState() != 1) {
            throw new RuntimeException("门店未认证，请先完成认证");
        }
    }
}
