package org.jeecg.modules.userRole.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.modules.userRole.entity.TbUserRole;
import org.jeecg.modules.userRole.mapper.TbUserRoleMapper;
import org.jeecg.modules.userRole.service.ITbUserRoleService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: tb_user_role
 * @Author: jeecg-boot
 * @Date:   2024-12-07
 * @Version: V1.0
 */
@Service
public class TbUserRoleServiceImpl extends ServiceImpl<TbUserRoleMapper, TbUserRole> implements ITbUserRoleService {

    @Override
    public Map getRoleInfo(String userId) {
//.eq(TbUserRole::getAuditStatus, 1)
        LambdaQueryWrapper<TbUserRole> queryWrapper1 = new LambdaQueryWrapper<>();
        queryWrapper1.eq(TbUserRole::getUserId, userId).
                eq(TbUserRole::getRole, 0);
        TbUserRole boss = this.getOne(queryWrapper1);
        LambdaQueryWrapper<TbUserRole> queryWrapper2 = new LambdaQueryWrapper<>();
        queryWrapper2.eq(TbUserRole::getUserId, userId).
                eq(TbUserRole::getRole, 1);
        TbUserRole company = this.getOne(queryWrapper2);
        LambdaQueryWrapper<TbUserRole> queryWrapper3 = new LambdaQueryWrapper<>();
        queryWrapper3.eq(TbUserRole::getUserId, userId).
                eq(TbUserRole::getRole, 2);
        TbUserRole worker = this.getOne(queryWrapper3);

        Map<String, TbUserRole> map = new HashMap<>();
//          返回用人方个人身份信息
        map.put("boss", boss);
        //   返回用人方企业身份信息
        map.put("company", company);

        map.put("worker", worker);

        return map;

    }

}
