package com.zsc.edu.gateway.modules.iot.tsl.query;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zsc.edu.gateway.modules.iot.tsl.entity.Event;
import com.zsc.edu.gateway.modules.iot.tsl.entity.Serve;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.Objects;

/**
 * @author 15864
 */
@Data
public class ServeQuery {
    /**
     * 标识
     */
    public String identifier;

    /**
     * 名称
     */
    public String name;


    /**
     * 名称
     */
    public Long productId;

    public LambdaQueryWrapper<Serve> wrapper() {
        LambdaQueryWrapper<Serve> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.hasText(this.name), Serve::getName, this.name);
        queryWrapper.like(StringUtils.hasText(this.identifier), Serve::getIdentifier, this.identifier);
        queryWrapper.eq(Objects.nonNull(this.productId), Serve::getProductId, this.productId);
        return queryWrapper;
    }
}
