package ink.wgink.pojo.dtos.permission;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

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

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: PermissionSystemApiDTO
 * @Description: 系统api
 * @Author: WangGeng
 * @Date: 2021/2/24 16:35
 * @Version: 1.0
 **/
@ApiModel
public class SystemApiDTO {

    @ApiModelProperty(name = "systemTag", value = "系统标识")
    private String systemTag;
    @ApiModelProperty(name = "apis", value = "接口列表")
    private List<ApiDTO> apis;

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

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

    public List<ApiDTO> getApis() {
        if (apis == null) {
            return new ArrayList<>();
        }
        return apis;
    }

    public void setApis(List<ApiDTO> apis) {
        this.apis = apis;
    }

    @ApiModel
    public static class ApiDTO {
        @ApiModelProperty(name = "api", value = "接口")
        private String api;
        @ApiModelProperty(name = "apiName", value = "接口名称")
        private String apiName;
        @ApiModelProperty(name = "apiTag", value = "api标识")
        private String apiTag;

        public ApiDTO(String api, String apiName, String apiTag) {
            this.api = api;
            this.apiName = apiName;
            this.apiTag = apiTag;
        }

        public String getApi() {
            return api == null ? "" : api.trim();
        }

        public void setApi(String api) {
            this.api = api;
        }

        public String getApiName() {
            return apiName == null ? "" : apiName.trim();
        }

        public void setApiName(String apiName) {
            this.apiName = apiName;
        }

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

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

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

}
