package com.agileboot.system.role.dto;

import cn.hutool.core.util.StrUtil;
import com.agileboot.common.mybatis.core.page.PageQuery;
import com.agileboot.system.role.entity.SysRole;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.Data;

/**
 * @author valarchie
 */
@Data
public class RoleQuery extends PageQuery<SysRole> {

    private String roleName;

    private String roleKey;

    private String status;

    @Override
    public LambdaQueryWrapper<SysRole> toQueryWrapper() {
        return Wrappers.lambdaQuery(SysRole.class)
                .eq(status != null, SysRole::getStatus, status)
                .eq(StrUtil.isNotEmpty(roleKey), SysRole::getRoleKey, roleKey)
                .like(StrUtil.isNotEmpty(roleName), SysRole::getRoleName, roleName);
    }
}
