package com.agileboot.system.menu.dto;

import com.agileboot.common.mybatis.core.page.PageQuery;
import com.agileboot.system.menu.entity.SysMenu;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author valarchie
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class MenuQuery extends PageQuery<SysMenu> {
    // 直接交给前端筛选
//    private String menuName;
//    private Boolean isVisible;
//    private Integer status;
    private Boolean isButton;

    @Override
    public LambdaQueryWrapper<SysMenu> toQueryWrapper() {
        return Wrappers.lambdaQuery(SysMenu.class)
                .eq(isButton != null, SysMenu::getIsButton, isButton)
                .orderByDesc(SysMenu::getParentId);
    }
}
