package com.zsc.edu.gateway.modules.system.query;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zsc.edu.gateway.modules.system.entity.Authority;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

/**
 * @author zhuang
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AuthorityQuery {
    /**
     * 编码，前缀匹配
     */
    public String code;

    /**
     * 名称，模糊查询
     */
    public String name;

    public LambdaQueryWrapper<Authority> wrapper() {
        LambdaQueryWrapper<Authority> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.hasText(this.name), Authority::getName, this.name);
        return queryWrapper;
    }
}
