package com.sptg.permissions.biz.service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.sptg.common.core.beans.PageBean;
import com.sptg.permissions.api.dto.AccountDto;
import com.sptg.permissions.api.entity.DeviceAdminUser;

/**
 * title: DeviceAdminUserService
 * description:
 *
 *                  
 *                
 */
public interface DeviceAdminUserService extends IService<DeviceAdminUser> {

    /**
     * 分页查询
     * @param pageBean 分页条件
     * @return Page<DeviceAdminUser>
     */
    Page<DeviceAdminUser> pagingQuery(PageBean<DeviceAdminUser, AccountDto> pageBean);

    /**
     * 校验登录名是否已存在
     * @param loginName 登录名称
     * @return boolean
     */
    default boolean checkLoginNameIsExist(String loginName){
        Wrapper<DeviceAdminUser> wrapper = new EntityWrapper<>();
        wrapper.eq("login_name",loginName);
        return this.selectCount(wrapper) > 0;
    }

    /**
     * 根据登录名查询
     * @param loginName 登录名
     * @return DeviceAdminUser
     */
    default DeviceAdminUser selectByLoginName(String loginName){
        Wrapper<DeviceAdminUser> wrapper = new EntityWrapper<>();
        wrapper.eq("login_name",loginName);
        return this.selectOne(wrapper);
    }

}
