package com.ruoyi.system.domain.dto;

import com.fasterxml.jackson.annotation.JsonCreator;

import java.util.List;

public class Coordinate {
    private Integer x;
    private Integer y;
    // getters/setters

    // 方法 2：定义接受数组的构造函数
    @JsonCreator
    public Coordinate(List<Integer> array) {
        if (array.size() >= 2) {
            this.x = array.get(0);
            this.y = array.get(1);
        } else {
            throw new IllegalArgumentException("坐标必须为 [x, y] 格式");
        }
    }

    public Integer getX() {
        return x;
    }

    public void setX(Integer x) {
        this.x = x;
    }

    public Integer getY() {
        return y;
    }

    public void setY(Integer y) {
        this.y = y;
    }
}