package com.blueland.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blueland.bo.AppIdUserIdAppIdRoleIdDTO;
import com.blueland.bo.Role2userEntity;
import com.blueland.constant.Constant;
import com.blueland.dao.Role2userDao;
import com.blueland.model.TPfRole2user;
import com.blueland.service.IRole2userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Role2userServiceImpl extends ServiceImpl<Role2userDao, TPfRole2user> implements IRole2userService {

    @Autowired
    private Role2userDao role2userDao;

    @Override
    public List<AppIdUserIdAppIdRoleIdDTO> findListRoleId() {
        return role2userDao.findListRoleId("");
    }

    @Override
    public Long selectRoleUserByCode(String appId, String roleId, String postCode) {
        QueryWrapper<TPfRole2user> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(TPfRole2user:: getAppId, appId);
        queryWrapper.lambda().eq(TPfRole2user:: getRoleId, roleId);
        queryWrapper.lambda().eq(TPfRole2user:: getSTATUS, "Y");
        queryWrapper.lambda().eq(TPfRole2user:: getStaffPostCode, postCode);
        return this.baseMapper.selectCount(queryWrapper);
    }

    @Override
    public void deleteByAppId(String appId) {
        this.baseMapper.deleteByAppId(appId);
    }

    @Override
    public List<TPfRole2user> selectListByAppId(String appId) {
        return this.baseMapper.selectListByAppId(appId);
    }
}
