package com.sy.coinage.core.controller;

import com.sy.coinage.core.exception.RetException;
import com.sy.coinage.core.vo.CacheUserVO;

public class BaseController {

    /**
     * 验证是否相同租户数据
     *
     * @param user
     * @param tenantId
     */
    protected void validTenant(CacheUserVO user, Integer tenantId) {
        if (user.getTenantId() != null && user.getTenantId() > 0 && tenantId != null
                        && user.getTenantId().intValue() != tenantId.intValue()) {
            throw new RetException("无数据操作权限");
        }
    }

    protected void validAdmin(CacheUserVO user) {
        if (user.getTenantId() != null && user.getTenantId() > 0) {
            throw new RetException("无数据操作权限");
        }
    }

}
