db

package
v0.0.0-...-e85b02a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

const ACCE164S = ` CREATE TABLE IF NOT EXISTS %s (

acce164_uuid uuid NOT NULL DEFAULT gen_random_uuid(),
account_id varchar NOT NULL,
account_domain varchar NOT NULL,
gateway_name varchar NOT NULL,
e164_number varchar NOT NULL,
acce164_isdefault bool NOT NULL DEFAULT false,
CONSTRAINT acce164_pkey PRIMARY KEY (acce164_uuid)

); COMMENT ON TABLE %s IS 'account e164 number for outgoing call'; ALTER TABLE %s ADD CONSTRAINT acce164_fk FOREIGN KEY (account_id,account_domain) REFERENCES %s(account_id,account_domain) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE %s ADD CONSTRAINT acce164_fk_1 FOREIGN KEY (gateway_name) REFERENCES %s(gateway_name) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE %s ADD CONSTRAINT acce164_fk_2 FOREIGN KEY (e164_number) REFERENCES %s(e164_number) ON DELETE CASCADE ON UPDATE CASCADE; `

const E164ACCS = ` CREATE TABLE IF NOT EXISTS %s (

e164acc_uuid uuid NOT NULL DEFAULT gen_random_uuid(),
gateway_name varchar NOT NULL,
e164_number varchar NOT NULL,
account_id varchar NULL DEFAULT '',
account_domain varchar NULL DEFAULT '',
fifo_name varchar NULL DEFAULT '',
e164acc_isfifo bool NOT NULL DEFAULT false,
CONSTRAINT e164acc_pkey PRIMARY KEY (e164acc_uuid)

); COMMENT ON TABLE %s IS 'gateway e164 receive incoming call, bridge account@domain or fifo fifo@fifoname in'; ALTER TABLE %s ADD CONSTRAINT e164acc_fk FOREIGN KEY (account_id,account_domain) REFERENCES %s(account_id,account_domain) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE %s ADD CONSTRAINT e164acc_fk_1 FOREIGN KEY (gateway_name) REFERENCES %s(gateway_name) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE %s ADD CONSTRAINT e164acc_fk_2 FOREIGN KEY (e164_number) REFERENCES %s(e164_number) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE %s ADD CONSTRAINT e164acc_fk_3 FOREIGN KEY (fifo_name) REFERENCES %s(fifo_name) ON DELETE CASCADE ON UPDATE CASCADE; `

const E164S = ` CREATE TABLE IF NOT EXISTS %s (

e164_uuid uuid NOT NULL DEFAULT gen_random_uuid(),
gateway_name varchar NOT NULL DEFAULT '',
e164_number varchar NOT NULL,
e164_enable bool NULL DEFAULT true,
e164_lockin bool NULL DEFAULT false,
e164_lockout bool NULL DEFAULT false,
CONSTRAINT e164s_pkey PRIMARY KEY (e164_uuid),
CONSTRAINT e164s_un UNIQUE (e164_number)

); COMMENT ON TABLE %s IS 'phone numbers of external gateway'; `

const FIFOS = ` CREATE TABLE IF NOT EXISTS %s (

fifo_uuid uuid NOT NULL DEFAULT gen_random_uuid(),
fifo_name varchar NOT NULL,
fifo_importance varchar NULL DEFAULT 0,
fifo_announce varchar NULL DEFAULT '',
fifo_holdmusic varchar NULL DEFAULT '',
CONSTRAINT fifos_pkey PRIMARY KEY (fifo_uuid),
CONSTRAINT fifos_un UNIQUE (fifo_name)

); COMMENT ON TABLE %s IS 'mod_fifo fifos'; `

const OUTGOINGCALLS = ` CREATE TABLE IF NOT EXISTS %s (

uuidjob uuid NOT NULL,
uuida uuid NOT NULL,
uuidb uuid NOT NULL,
id varchar NOT NULL DEFAULT '',
domain varchar NOT NULL DEFAULT '',
e164 varchar NOT NULL DEFAULT '',
gateway varchar NOT NULL DEFAULT '',
ani varchar NOT NULL DEFAULT '',
destination varchar NOT NULL DEFAULT '',
CONSTRAINT outgoingcalls_pkey PRIMARY KEY (uuidjob)

); COMMENT ON TABLE %s IS 'outgoingcalls bgapi command originate a bridge b'; `

Index

Constants

View Source
const ACCE164S = `` /* 855-byte string literal not displayed */
View Source
const ACCOUNTS = `` /* 533-byte string literal not displayed */
View Source
const BGJOBS = `` /* 303-byte string literal not displayed */
View Source
const BLACKLISTS = `` /* 296-byte string literal not displayed */

fs server --run table define

View Source
const CDR_LEG = `` /* 1209-byte string literal not displayed */

CDR_LEG mod_odbc_cdr table define

View Source
const CONFS = `` /* 332-byte string literal not displayed */

fs gateway -run table define

View Source
const DATABASE_DROP = `drop database if exists %s;`
View Source
const DBUSER_AUTH = "grant all privileges on database %s to %s"
View Source
const DB_CREATE = "create database %s with owner %s"
View Source
const DEFAULT_ACCE164S = `` /* 328-byte string literal not displayed */
View Source
const DEFAULT_ACCOUNTS = `` /* 200-byte string literal not displayed */
View Source
const DEFAULT_BLACKLISTS = `
insert into %s(blacklist_caller,blacklist_callee)values
('13012345678','1000'),
('1000','13012345678')
`
View Source
const DEFAULT_E164ACCES = `` /* 166-byte string literal not displayed */
View Source
const DEFAULT_E164S = `
insert into %s(gateway_name,e164_number)values
('myfsgateway','1000'),
('','10010'),
('','10086')
`
View Source
const DEFAULT_FIFOMEMBERS = `` /* 266-byte string literal not displayed */
View Source
const DEFAULT_FIFOS = `
insert into %s(fifo_name)values
('fifomember@fifos'),
('fifoconsumer@fifos')
`
View Source
const DEFAULT_GATEWAYS = `` /* 647-byte string literal not displayed */
View Source
const E164ACCS = `` /* 1030-byte string literal not displayed */
View Source
const E164S = `` /* 426-byte string literal not displayed */
View Source
const FIFOMEMBERS = `` /* 508-byte string literal not displayed */
View Source
const FIFOS = `` /* 368-byte string literal not displayed */
View Source
const GATEWAYS = `` /* 766-byte string literal not displayed */
View Source
const OUTGOINGCALLS = `` /* 451-byte string literal not displayed */
View Source
const USER_CREATE = "create user %s with password '%s'"

const USER_CREATE = "create user fsdba with password 'fsdba'" const DB_CREATE = "create database freeswitch with owner fsdba" const DBUSER_AUTH = "grant all privileges on database freeswitch to fsdba" const DATABASE_USER_DROP = `drop database if exists freeswitch; drop user if exists fsdba;`

View Source
const USER_DROP = `drop user if exists %s;`

Variables

This section is empty.

Functions

func CreateBgjob

func CreateBgjob(in Bgjob) error

CreateBgjob

func CreateCdrAleg

func CreateCdrAleg(in *CDRLEG) (e error)

CreateCdrAleg

func CreateCdrBleg

func CreateCdrBleg(in *CDRLEG) (e error)

CreateCdrBleg

func GetGatewaydb

func GetGatewaydb() *sqlx.DB

func GetServerdb

func GetServerdb() *sqlx.DB

func GetSwitchdb

func GetSwitchdb() *sqlx.DB

func GetTablesGatewayPrifex

func GetTablesGatewayPrifex() string

func GetTablesServerPrifex

func GetTablesServerPrifex() string

func Initdb

func Initdb()

func InsertCallDetailRecord

func InsertCallDetailRecord(isbleg bool, in *CDRLEG) error

InsertCallDetailRecord

func IsExistCallDetailRecordUuid

func IsExistCallDetailRecordUuid(isbleg bool, uuid string) (bool, error)

IsExistCallDetailRecordUuid

func IsExistCdrsAlegUuid

func IsExistCdrsAlegUuid(uuid string) (bool, error)

IsExistCdrsAlegUuid

func IsExistCdrsBlegUuid

func IsExistCdrsBlegUuid(uuid string) (bool, error)

IsExistCdrsBlegUuid

func SelectAccountsDistinctDomain

func SelectAccountsDistinctDomain() ([]string, error)

Types

type ACCE164

type ACCE164 struct {
	AEuuid    string `db:"acce164_uuid" json:"uuid"`
	Aid       string `db:"account_id" json:"id"`
	Adomain   string `db:"account_domain" json:"domain"`
	Gname     string `db:"gateway_name" json:"name"`
	Enumber   string `db:"e164_number" json:"number"`
	Isdefault bool   `db:"acce164_isdefault" json:"isdefault"`
}

acce164 struct

func DeleteAcce164sAcce164

func DeleteAcce164sAcce164(uuid string) (ACCE164, error)

DeleteAcce164sAcce164

func DeleteE164accsE164acc

func DeleteE164accsE164acc(uuid string) (ACCE164, error)

DeleteE164accsE164acc

func InsertAcce164s

func InsertAcce164s(in []ACCE164) ([]ACCE164, error)

InsertAcce164s

func SelectAcce164sWithCondition

func SelectAcce164sWithCondition(condition string) ([]ACCE164, error)

SelectAcce164sWithCondition

func UpdateAcce164sAcce164

func UpdateAcce164sAcce164(uuid string, in ACCE164) (ACCE164, error)

UpdateAcce164sAcce164

type Account

type Account struct {
	Auuid      string `db:"account_uuid" json:"uuid"`
	Aid        string `db:"account_id" json:"id"`
	Aname      string `db:"account_name" json:"name"`
	Aauth      string `db:"account_auth" json:"auth"`
	Apassword  string `db:"account_password" json:"password"`
	Aa1hash    string `db:"account_a1hash" json:"a1hash"`
	Agroup     string `db:"account_group" json:"group"`
	Adomain    string `db:"account_domain" json:"domain"`
	Aproxy     string `db:"account_proxy" json:"proxy"`
	Acacheable string `db:"account_cacheable" json:"cacheable"`
}

func DeleteAccountsAccount

func DeleteAccountsAccount(uuid string) (out Account, e error)

func GetAccountsAccount

func GetAccountsAccount(id, domain string) (*Account, error)

func InsertAccounts

func InsertAccounts(in []Account) (rt []Account, e error)

func SelectAccountsWithCondition

func SelectAccountsWithCondition(condition string) (rt []Account, e error)

func UpdateAccountsAccount

func UpdateAccountsAccount(uuid string, in Account) (out Account, e error)

type Bgjob

type Bgjob struct {
	Juuid    string `db:"job_uuid" json:"uuid"`
	Jcmd     string `db:"job_cmd" json:"cmd"`
	Jcmdarg  string `db:"job_cmdarg" json:"cmdarg"`
	Jcontent string `db:"job_content" json:"content"`
}

func DeleteBgjob

func DeleteBgjob(uuid string) (Bgjob, error)

DeleteBgjob

func SelectBgjobsWithCondition

func SelectBgjobsWithCondition(condition string) ([]Bgjob, error)

SelectBgjobsWithCondition

type Blacklist

type Blacklist struct {
	Buuid   string `db:"blacklist_uuid" json:"uuid"`
	Bcaller string `db:"blacklist_caller" json:"caller"`
	Bcallee string `db:"blacklist_callee" json:"callee"`
}

func DeleteBlacklistsBlacklist

func DeleteBlacklistsBlacklist(uuid string) (Blacklist, error)

DeleteBlacklistsBlacklist

func InsertBlacklists

func InsertBlacklists(in []Blacklist) ([]Blacklist, error)

InsertBlacklists

func IsExistBlacklist

func IsExistBlacklist(caller, callee string) (Blacklist, bool)

IsExistBlacklist

func SelectBlacklistsWithCondition

func SelectBlacklistsWithCondition(condition string) ([]Blacklist, error)

SelectBlacklistsWithCondition

func UpdateBlacklistsBlacklist

func UpdateBlacklistsBlacklist(uuid string, in Blacklist) (Blacklist, error)

UpdateBlacklistsBlacklist

type CDRLEG

type CDRLEG struct {
	UUID           string `db:"uuid" json:"uuid"`
	OtherUUID      string `db:"otheruuid" json:"otheruuid"`
	BondUUID       string `db:"bonduuid" json:"bonduuid"`
	Name           string `db:"name" json:"name"`
	Direction      string `db:"direction" json:"direction"`
	Sofiaprofile   string `db:"sofiaprofile" json:"sofiaprofile"`
	Indomain       string `db:"indomain" json:"indomain"`
	Ingateway      string `db:"ingateway" json:"ingateway"`
	Outdomain      string `db:"outdomain" json:"outdomain"`
	Outgateway     string `db:"outgateway" json:"outgateway"`
	Ani            string `db:"ani" json:"ani"`
	Destination    string `db:"destination" json:"destination"`
	Calleridname   string `db:"calleridname" json:"calleridname"`
	Calleridnumber string `db:"calleridnumber" json:"calleridnumber"`
	Calleeidname   string `db:"calleeidname" json:"calleeidname"`
	Calleeidnumber string `db:"calleeidnumber" json:"calleeidnumber"`
	App            string `db:"app" json:"app"`
	Appdata        string `db:"appdata" json:"appdata"`
	Appdialstatus  string `db:"dialstatus" json:"dialstatus"`
	Cause          string `db:"cause" json:"cause"`
	Q850           string `db:"q850" json:"q850"`
	Disposition    string `db:"disposition" json:"disposition"`
	Protocause     string `db:"protocause" json:"protocause"`
	Phrase         string `db:"phrase" json:"phrase"`
	Startepoch     string `db:"startepoch" json:"startepoch"`
	Answerepoch    string `db:"answerepoch" json:"answerepoch"`
	Endepoch       string `db:"endepoch" json:"endepoch"`
	Waitsec        string `db:"waitsec" json:"waitsec"`
	Billsec        string `db:"billsec" json:"billsec"`
	Duration       string `db:"duration" json:"duration"`
}

func SelectCallDetailRecordsWithCondition

func SelectCallDetailRecordsWithCondition(condition string) ([]CDRLEG, error)

SelectCallDetailRecordsWithCondition

type Conf

type Conf struct {
	Cuuid       string `db:"conf_uuid" json:"uuid"`
	Cfilename   string `db:"conf_filename" json:"filename"`
	Cprofile    string `db:"conf_profile" json:"profile"`
	Ccontent    string `db:"conf_content" json:"content"`
	Cnewcontent string `db:"conf_newcontent" json:"newcontent"`
}

func DeleteConfsConf

func DeleteConfsConf(uuid string) (Conf, error)

DeleteConfsConf

func GetConfsConfWithCondition

func GetConfsConfWithCondition(condition string) (Conf, error)

GetConfsConfWithCondition

func InsertConfs

func InsertConfs(in []Conf) ([]Conf, error)

InsertConfs

func InsertConfsConf

func InsertConfsConf(in Conf) (Conf, error)

InsertConfsConf

func SelectConfsWithCondition

func SelectConfsWithCondition(condition string) ([]Conf, error)

SelectConfsWithCondition

func UpdateConfsConf

func UpdateConfsConf(uuid string, in Conf) (Conf, error)

UpdateConfsConf

type E164

type E164 struct {
	Euuid    string `db:"e164_uuid" json:"uuid"`
	Gname    string `db:"gateway_name" json:"gname"`
	Enumber  string `db:"e164_number" json:"number"`
	Eenable  bool   `db:"e164_enable" json:"enable"`
	Elockin  bool   `db:"e164_lockin" json:"lockin"`
	Elockout bool   `db:"e164_lockout" json:"lockout"`
}

func DeleteE164sE164

func DeleteE164sE164(uuid string) (E164, error)

func InsertE164s

func InsertE164s(in []E164) ([]E164, error)

func IsExistE164

func IsExistE164(gateway string, number string) (E164, error)

func SelectE164sWithCondition

func SelectE164sWithCondition(condition string) ([]E164, error)

func UpdateE164sE164

func UpdateE164sE164(uuid string, in E164) (E164, error)

type E164ACC

type E164ACC struct {
	EAuuid  string `db:"e164acc_uuid" json:"uuid"`
	Gname   string `db:"gateway_name" json:"gname"`
	Enumber string `db:"e164_number" json:"number"`
	Aid     string `db:"account_id" json:"id"`
	Adomain string `db:"account_domain" json:"domain"`
	Fname   string `db:"fifo_name" json:"fname"`
	Isfifo  bool   `db:"e164acc_isfifo" json:"isfifo"`
}

e164acc struct

func InsertE164accs

func InsertE164accs(in []E164ACC) ([]E164ACC, error)

InsertE164accs

func SelectE164accsWithCondition

func SelectE164accsWithCondition(condition string) ([]E164ACC, error)

SelectE164accsWithCondition

func UpdateE164accsE164acc

func UpdateE164accsE164acc(uuid string, in E164ACC) (E164ACC, error)

UpdateE164accsE164acc

type Fifo

type Fifo struct {
	Fuuid       string `db:"fifo_uuid" json:"uuid"`
	Fname       string `db:"fifo_name" json:"name"`
	Fimportance string `db:"fifo_importance" json:"importance"`
	Fannounce   string `db:"fifo_announce" json:"announce"`
	Fholdmusic  string `db:"fifo_holdmusic" json:"holdmusic"`
}

func DeleteFifosFifo

func DeleteFifosFifo(uuid string) (Fifo, error)

DeleteFifosFifo

func InsertFifos

func InsertFifos(in []Fifo) ([]Fifo, error)

InsertFifos

func SelectFifos

func SelectFifos() ([]Fifo, error)

SelectFifos

func SelectFifosWithCondition

func SelectFifosWithCondition(condition string) ([]Fifo, error)

SelectFifosWithCondition

func UpdateFifosFifo

func UpdateFifosFifo(uuid string, in Fifo) (Fifo, error)

UpdateFifosFifo

type FifoMember

type FifoMember struct {
	Muuid    string `db:"fifomember_uuid" json:"uuid"`
	Fname    string `db:"fifo_name" json:"name"`
	Mstring  string `db:"member_string" json:"string"`
	Msimo    string `db:"member_simo" json:"simo"`
	Mtimeout string `db:"member_timeout" json:"timeout"`
	Mlag     string `db:"member_lag" json:"lag"`
}

func DeleteFifomembersFifomember

func DeleteFifomembersFifomember(uuid string) (FifoMember, error)

DeleteFifomembersFifomember

func InsertFifoMembers

func InsertFifoMembers(in []FifoMember) ([]FifoMember, error)

InsertFifoMembers

func SelectFifomembersWithCondition

func SelectFifomembersWithCondition(condition string) ([]FifoMember, error)

SelectFifomembersWithCondition

func UpdateFifomembersFifomember

func UpdateFifomembersFifomember(uuid string, in FifoMember) (FifoMember, error)

UpdateFifomembersFifomember

type Gateway

type Gateway struct {
	Guuid               string `db:"gateway_uuid" json:"uuid"`
	Pname               string `db:"profile_name" json:"pname"`
	Gname               string `db:"gateway_name" json:"gname"`
	Gusername           string `db:"gateway_username" json:"username"`
	Grealm              string `db:"gateway_realm" json:"realm"`
	Gfromuser           string `db:"gateway_fromuser" json:"fromuser"`
	Gfromdomain         string `db:"gateway_fromdomain" json:"fromdomain"`
	Gpassword           string `db:"gateway_password" json:"password"`
	Gextension          string `db:"gateway_extension" json:"extension"`
	Gproxy              string `db:"gateway_proxy" json:"proxy"`
	Gregisterproxy      string `db:"gateway_registerproxy" json:"registerproxy"`
	Gexpire             string `db:"gateway_expire" json:"expire"`
	Gregister           string `db:"gateway_register" json:"register"`
	Gcalleridinfrom     string `db:"gateway_calleridinfrom" json:"calleridinfrom"`
	Gextensionincontact string `db:"gateway_extensionincontact" json:"extensionincontact"`
	Goptionping         string `db:"gateway_optionping" json:"optionping"`
}

func DeleteGatewaysGateway

func DeleteGatewaysGateway(uuid string) (out Gateway, e error)

func InsertGateways

func InsertGateways(in []Gateway) (rt []Gateway, e error)

func SelectGatewaysWithCondition

func SelectGatewaysWithCondition(condition string) ([]Gateway, error)

func UpdateGatewaysGateway

func UpdateGatewaysGateway(uuid string, in Gateway) (out Gateway, e error)

type OUTGOINGCALL

type OUTGOINGCALL struct {
	Jobuuid     string `db:"uuidjob" json:"uuidjob"`
	Auuid       string `db:"uuida" json:"uuida"`
	Buuid       string `db:"uuidb" json:"uuidb"`
	Id          string `db:"id" json:"id"`
	Domain      string `db:"domain" json:"domain"`
	E164        string `db:"e164" json:"e164"`
	Gateway     string `db:"gateway" json:"gateway"`
	Ani         string `db:"ani" json:"ani"`
	Destination string `db:"destination" json:"destination"`
}

OUTGOINGCALL struct

func InsertOutgoingcalls

func InsertOutgoingcalls(in []OUTGOINGCALL) ([]OUTGOINGCALL, error)

InsertOutgoingcalls

func SelectOutgoingcallsWithCondition

func SelectOutgoingcallsWithCondition(condition string) ([]OUTGOINGCALL, error)

SelectOutgoingcallsWithCondition

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL