package com.wzj.soopin.member.domain.bo;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wzj.soopin.member.domain.po.MemberAddress;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.dromara.common.core.domain.BaseBO;

/**
 * 会员收货地址 查询 对象
 *
 * @author zcc
 */
@Schema(description="会员收货地址 查询 对象")
@Data
public class MemberAddressBO extends BaseBO<MemberAddress> {



    private Long id;
    @Schema(description ="MEMBER_ID 精确匹配")
    private Long memberId;

    @Schema(description ="收货人名称 精确匹配")
    private String name;

    @Schema(description ="PHONE 精确匹配")
    private String phone;

    @Schema(description ="是否为默认 精确匹配")
    private Integer defaultStatus;

    @Schema(description ="邮政编码 精确匹配")
    private String postCode;

    @Schema(description ="省份/直辖市 精确匹配")
    private String province;

    @Schema(description ="城市 精确匹配")
    private String city;

    @Schema(description ="区 精确匹配")
    private String district;

    @Schema(description ="详细地址 精确匹配")
    private String detailAddress;

    @Schema(description ="是否默认 精确匹配")
    private Integer defaultFlag;

    @Override
    public LambdaQueryWrapper<MemberAddress> toWrapper() {
       return super.toWrapper().eq(city!=null,MemberAddress::getCity,city)
           .eq(district!=null,MemberAddress::getDistrict,district)
           .like(detailAddress!=null,MemberAddress::getDetailAddress,detailAddress)
           .eq(phone!=null,MemberAddress::getPhoneEncrypted,phone)
           .eq(province!=null,MemberAddress::getProvince,province)
           .eq(city!=null,MemberAddress::getCity,city)
           .eq(defaultFlag!=null,MemberAddress::getDefaultFlag,defaultFlag)
           .eq(memberId!=null,MemberAddress::getMemberId,memberId)
           .like(name!=null,MemberAddress::getName,name);

    }
}
