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

net.wicp.tams.common.http.flink.SqlCmd Maven / Gradle / Ivy

The newest version!
/*
 * **********************************************************************
 * Copyright (c) 2022 .
 * All rights reserved.
 * 项目名称:common-apiext
 * 项目描述:工具
 * 版权说明:本软件属andy.zhou([email protected])所有。
 * ***********************************************************************
 */
package net.wicp.tams.common.http.flink;

import net.wicp.tams.common.apiext.StringUtil;
import net.wicp.tams.common.constant.dic.intf.IEnumCombobox;

/***
 * 是与否枚举
 * 
 * @author andy.zhou
 * 
 */
public enum SqlCmd implements IEnumCombobox {
	catalog_show("查看所有的catalogs", "show  catalogs"),
	
	catalog_get("使用catalog", "show current catalog"),

	catalog_set("使用catalog", "use catalog %s"),
	
	
	db_show("查看所有数据库", "show databases"),

	db_get("使用catalog", "show current database"),

	db_set("使用catalog", "use %s"),
	
	col_show("查看列", "show columns from %s"),

	tb_show("列出所有的表", "show tables"),
	
	tb_desc("列出所有的表的字段", "describe %s"),//与col_show效果一样
	
	
	view_show("列出所有的视图", "show views"),
	
	
	fun_show_user("查看用户定义的函数","show user functions"),
	
	fun_show_all("查看所有函数","show  functions"),

	//创建和删除db不走此路,因为不好处理db参数
	//create_db("创建库", "create database [catalog].[db] COMMENT 'from page' "), // sqlclient没有要求,sqlgateway有要求?

	//drop_tb("创建库", "drop table [catalog].[db].%s"),

	no("否");

	private final String desc;
	private final String formater;

	public String getFormater(String catalog, String db) {
		String tempsql = formater.replace("[catalog]", StringUtil.hasNull(catalog, ""));
		tempsql = StringUtil.isNull(db) ? tempsql.replace("\\.[db]", "") : tempsql.replace("[db]", db);
		return tempsql;
	}

	public String getSql(String catalog, String db, Object... params) {
		return String.format(getFormater(catalog, db), params);
	}

	private SqlCmd(String desc, String formater) {
		this.desc = desc;
		this.formater = formater;
	}

	private SqlCmd(String desc) {
		this.desc = desc;
		this.formater = null;
	}

	public String getDesc() {
		return desc;
	}

	public String getName() {
		return this.name();
	}

	@Override
	public String getDesc_zh() {
		return this.desc;
	}

	@Override
	public String getDesc_en() {
		return this.name();
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy