package cn.ey.biz.module.system.api.delegation.dto;

import cn.ey.biz.common.util.json.JsonUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Size;
import java.util.List;

@Data
public class UserDelegationUnitDTO {

    @ApiModelProperty(value = "应用ID",required = true)
    @Size(max = 30, message = "应用ID长度不能超过30个字符")
    private String appId;

    @ApiModelProperty(value = "用户ID",required = true)
    private Long userId;

    @ApiModelProperty(value = "用户姓名", example = "Peter(131).Du",notes = "姓名内容组合")
    private String userName;

    @ApiModelProperty(value = "代理人GPN", example = "XE030018616")
    private String gpn;

    @ApiModelProperty(value = "代理人email", example = "xxx@ey.com")
    private String email;

    @ApiModelProperty(value = "分类", required = true, example = "01-rank,02-mu,03-subMu", notes = "参见 DelegationEnum 枚举类")
    @Size(max = 30, message = "分类长度不能超过30个字符")
    private String type;

    @ApiModelProperty(value = "关系描述", required = true, example = "关系描述json", notes = "选中代理单元value json值")
    private String relation;

    @ApiModelProperty(value = "关系描述",example = "[[\"1\",\"10\"],[\"2\",\"20\"]]")
    private List<String[]> relationData;

    /**
     * json 自动序列化使用
     */
    public List<String[]> getRelationData() {
        this.relationData = JsonUtils.parseArray(this.getRelation(), String[].class);
        return relationData;
    }

}
