package ink.wgink.pojo.dtos.permission;

import io.swagger.annotations.ApiModel;

import java.util.ArrayList;
import java.util.List;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: PermissionGroupDTO
 * @Description: 权限分组
 * @Author: WangGeng
 * @Date: 2021/2/19 11:45
 * @Version: 1.0
 **/
@ApiModel
public class PermissionGroupDTO {

    private String systemTag;
    private List<PermissionApiDTO> permissionApis;

    public String getSystemTag() {
        return systemTag == null ? "" : systemTag.trim();
    }

    public void setSystemTag(String systemTag) {
        this.systemTag = systemTag;
    }

    public List<PermissionApiDTO> getPermissionApis() {
        if (permissionApis == null) {
            return new ArrayList<>();
        }
        return permissionApis;
    }

    public void setPermissionApis(List<PermissionApiDTO> permissionApis) {
        this.permissionApis = permissionApis;
    }

    @ApiModel
    public static class PermissionApiDTO {
        private String systemTag;
        private String apiTag;
        private List<PermissionDTO> permissions;

        public String getSystemTag() {
            return systemTag == null ? "" : systemTag.trim();
        }

        public void setSystemTag(String systemTag) {
            this.systemTag = systemTag;
        }

        public String getApiTag() {
            return apiTag == null ? "" : apiTag.trim();
        }

        public void setApiTag(String apiTag) {
            this.apiTag = apiTag;
        }

        public List<PermissionDTO> getPermissions() {
            if (permissions == null) {
                return new ArrayList<>();
            }
            return permissions;
        }

        public void setPermissions(List<PermissionDTO> permissions) {
            this.permissions = permissions;
        }

        @Override
        public String toString() {
            final StringBuilder sb = new StringBuilder("{");
            sb.append("\"systemTag\":\"")
                    .append(systemTag).append('\"');
            sb.append(",\"apiTag\":\"")
                    .append(apiTag).append('\"');
            sb.append(",\"permissions\":")
                    .append(permissions);
            sb.append('}');
            return sb.toString();
        }
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"systemTag\":\"")
                .append(systemTag).append('\"');
        sb.append(",\"permissionApis\":")
                .append(permissionApis);
        sb.append('}');
        return sb.toString();
    }
}
