All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fastchar.openapi.FastCharOpenAPIConfig Maven / Gradle / Ivy

The newest version!
package com.fastchar.openapi;

import com.fastchar.interfaces.IFastConfig;
import com.fastchar.utils.FastMD5Utils;
import com.fastchar.utils.FastStringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FastCharOpenAPIConfig implements IFastConfig {


    private String uiPrimaryColor;
    private String uiLogo;

    private String defaultApiGroup = "系统其他接口";

    private String openApiRoute = "/openapi";

    private String username;
    private String password;


    private final Map info = new HashMap<>();

    private final List> server = new ArrayList<>();

    private final Map contact = new HashMap<>();

    private final Map license = new HashMap<>();

    public FastCharOpenAPIConfig addServer(String url, String description) {
        Map serverItem = new HashMap<>();
        serverItem.put("url", url);
        serverItem.put("description", description);
        server.add(serverItem);
        return this;
    }

    public FastCharOpenAPIConfig setTitle(String title) {
        info.put("title", title);
        return this;
    }

    public String getTitle() {
        return FastStringUtils.defaultValue(info.get("title"), "OpenAPI");
    }

    public FastCharOpenAPIConfig setDescription(String description) {
        info.put("description", description);
        return this;
    }

    public FastCharOpenAPIConfig setVersion(String version) {
        info.put("version", version);
        return this;
    }


    public FastCharOpenAPIConfig setContactName(String name) {
        contact.put("name", name);
        return this;
    }

    public FastCharOpenAPIConfig setContactUrl(String url) {
        contact.put("url", url);
        return this;
    }

    public FastCharOpenAPIConfig setContactEmail(String email) {
        contact.put("email", email);
        return this;
    }

    public FastCharOpenAPIConfig setLicenseName(String name) {
        contact.put("name", name);
        return this;
    }

    public FastCharOpenAPIConfig setLicenseUrl(String url) {
        contact.put("url", url);
        return this;
    }


    public String getOpenApiVersion() {
        return "3.0";
    }

    public Map getInfo() {
        return info;
    }

    public List> getServer() {
        return server;
    }

    public Map getContact() {
        return contact;
    }

    public Map getLicense() {
        return license;
    }

    public String getUiPrimaryColor() {
        return uiPrimaryColor;
    }

    public FastCharOpenAPIConfig setUiPrimaryColor(String uiPrimaryColor) {
        this.uiPrimaryColor = uiPrimaryColor;
        return this;
    }

    public String getUiLogo() {
        return uiLogo;
    }

    public FastCharOpenAPIConfig setUiLogo(String uiLogo) {
        this.uiLogo = uiLogo;
        return this;
    }

    public String getOpenApiRoute() {
        return openApiRoute;
    }

    public FastCharOpenAPIConfig setOpenApiRoute(String openApiRoute) {
        this.openApiRoute = openApiRoute;
        return this;
    }

    public String getUsername() {
        return username;
    }

    public FastCharOpenAPIConfig setUsername(String username) {
        this.username = username;
        return this;
    }

    public String getPassword() {
        return password;
    }

    public FastCharOpenAPIConfig setPassword(String password) {
        this.password = password;
        return this;
    }

    public String getDefaultApiGroup() {
        return defaultApiGroup;
    }

    public FastCharOpenAPIConfig setDefaultApiGroup(String defaultApiGroup) {
        this.defaultApiGroup = defaultApiGroup;
        return this;
    }


    public boolean isNeedLogin() {
        return FastStringUtils.isNotEmpty(username) && FastStringUtils.isNotEmpty(password);
    }

    public String getLoginKey() {
        return "OpenAPI" + FastMD5Utils.MD5To16(username + password);
    }



}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy