package com.ruoyi.ibs.grid.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ibs.dashboard.domain.entity.LoanContractDueWarn;
import com.ruoyi.ibs.grid.domain.entity.LicenseAuthorization965;
import com.ruoyi.ibs.grid.mapper.LicenseAuthorization965Mapper;
import com.ruoyi.ibs.grid.service.TabPersonalService;

import org.springframework.stereotype.Service;

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

@Service
public class TabPersonalServiceImpl implements TabPersonalService {


    @Resource
    private LicenseAuthorization965Mapper licenseAuthorization965Mapper;

    @Override
    public List<LicenseAuthorization965> selectLicenseAuthorization965t(String dt) {
        LambdaQueryWrapper<LicenseAuthorization965> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(LicenseAuthorization965::getDt,dt);
        if("manager".equalsIgnoreCase(SecurityUtils.userRole())){
            queryWrapper.eq(LicenseAuthorization965::getManagerId,SecurityUtils.getUsername());
        }
        if("outlet".equalsIgnoreCase(SecurityUtils.userRole())){
            queryWrapper.eq(LicenseAuthorization965::getOrgCode,SecurityUtils.getDeptId().toString());
        }
        queryWrapper.orderByAsc(LicenseAuthorization965::getAuthorizeId);
        return licenseAuthorization965Mapper.selectList(queryWrapper);
    }
}
