package com.bohuikeji.frame.module.admin.entity.auth;

import com.bohuikeji.frame.module.admin.entity.sys.SysUser;
import com.bohuikeji.frame.module.admin.service.ITFranchiseeInformationService;

import java.util.StringJoiner;

/**
 * 加盟商权限处理
 * @author 10552
 */
public class FranAuth extends BaseAuth{
    private ITFranchiseeInformationService franchiseeInformationService;

    @Override
    public String getValue(SysUser user) {
        if(user.getRoleId().equals(1)){
            return coverListByStr(user.sql().selectObjs("select fran_id from t_franchisee_information"));
        }
        StringJoiner join=new StringJoiner(",");
        for (Object o : franchiseeInformationService.queryLow(user.getFranId())) {
            join.add(o.toString());
        }
        return join.toString();
        //return user.getFranId().toString();
        /*
        return "select fran_id from sys_user where user_id="+user.getUserId();*/
    }
    public FranAuth(ITFranchiseeInformationService franchiseeInformationService){
        this.franchiseeInformationService=franchiseeInformationService;
    }
}
