package com.yuchen.saas.park.service.service.door.communication.domain.card;

import com.yuchen.saas.park.service.service.door.communication.domain.CommandParameter;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.val;
import org.springframework.util.StringUtils;

import javax.annotation.Nullable;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.PositiveOrZero;
import java.util.HashMap;
import java.util.Map;

/**
 * 任选其一
 */
@Data
@AllArgsConstructor(staticName = "of")
@NoArgsConstructor
public class DeleteCardParameter implements CommandParameter {
    @PositiveOrZero
    private long userId;
    @Nullable
    private String no;

    @Override
    public Map<@NotBlank String, Object> encoding() {
        val map = new HashMap<String, Object>();

        if (userId > 0) {
            map.put("employeeNo", userId);
        }

        if (StringUtils.hasLength(no)) {
            map.put("cardNo", no);
        }

        return map;
    }
}
