package com.ruoyi.brewery.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.model.BreweryLoginUser;
import com.ruoyi.common.utils.SecurityUtils;

public class BreweryBaseController extends BaseController {

    /**
     * 检验当前操作的数据是否属于当前品牌方
     * @param ownerId 数据品牌方id
     */
    protected void validateOwner(Long ownerId) {
        BreweryLoginUser loginUser = SecurityUtils.getBreweryLoginUser();
        if (loginUser == null) {
            throw new IllegalArgumentException("未登录");
        }
        if (!loginUser.getBreweryId().equals(ownerId)) {
            throw new IllegalArgumentException("无权操作其他租户数据");
        }
    }
}
