package com.engine.salary.entity.auth.dto;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@XStreamAlias("config")
public class AuthOptDTO {
    @XStreamAlias("name")
    @XStreamAsAttribute
    private String name;

    @XStreamAlias("key")
    @XStreamAsAttribute
    private String key;

    @XStreamImplicit(itemFieldName = "module")
    private List<Module> modules;

    @Data
    public static class Module {
        @XStreamAlias("name")
        @XStreamAsAttribute
        private String name;

        @XStreamAlias("key")
        @XStreamAsAttribute
        private String key;

        @XStreamImplicit(itemFieldName = "page")
        private List<Page> pages;

        @Data
        public static class Page {
            @XStreamAlias("name")
            @XStreamAsAttribute
            private String name;

            @XStreamAlias("key")
            @XStreamAsAttribute
            private String key;

            @XStreamAlias("limit")
            @XStreamAsAttribute
            private String limit;

            @XStreamImplicit(itemFieldName = "opt")
            private List<Opt> opts;

            @Data
            public static class Opt {
                @XStreamAlias("name")
                @XStreamAsAttribute
                private String name;

                @XStreamAlias("key")
                @XStreamAsAttribute
                private String key;

                @XStreamAlias("able")
                @XStreamAsAttribute
                private boolean able;
            }
        }
    }
}

