Documentation
¶
Index ¶
- Constants
- Variables
- func ConnectionString(providerType HxDbProviderType, userId string, password string, database string) string
- func ConvertFloatToCommaString(value float64) string
- func ConvertFloatToInt(value string) int
- func ConvertFloatToString(value float64) string
- func ConvertInt64ToCommaString(value int64) string
- func ConvertInt64ToString(value int64) string
- func ConvertIntToBool(value int) bool
- func ConvertIntToCommaString(value int) string
- func ConvertIntToFloat(value int) float64
- func ConvertIntToInt32(value int) int32
- func ConvertIntToInt64(value int) int64
- func ConvertIntToString(value int) string
- func ConvertIntToTimeUnix(value int) time.Time
- func ConvertStringToBool(value string) bool
- func ConvertStringToFloat32(value string) float32
- func ConvertStringToFloat64(value string) float64
- func ConvertStringToInt(value string) int
- func ConvertStringToInt64(value string) int64
- func ConvertStringToNumber(value string) float64
- func ConvertStringToTime(value string) time.Time
- func ConvertStringToTimeUnix(value string) time.Time
- func ConvertStringToTimeUnixFloat(value string) float64
- func ConvertStringToTimeUnixInt(value string) int64
- func ConvertToCommaString(value interface{}) string
- func ConvertValueToFloat64(v interface{}) float64
- func ConvertValueToInt(v interface{}) int
- func ConvertValueToInt64(v interface{}) int64
- func ConvertValueToString(v interface{}) string
- func ConvertValueToUInt64(v interface{}) uint64
- func DbPing(ctx context.Context)
- func GetCamelCase(s string) string
- func GetConnectionDataSourceString(providerType HxDbProviderType, database string) string
- func GetCountWithFilter(slice []map[string]any, key string, value any) int
- func GetDataByKeyNameWithCasing(data any, casing HxCasing) (map[string]any, error)
- func GetHxProviderDescription(provider HxDbProviderType) string
- func GetJsonWithCasing(data any, casing HxCasing) ([]byte, error)
- func GetMarshalIndentWithCasing(data any, casing HxCasing) ([]byte, error)
- func GetMarshalWithCasing(data any, casing HxCasing) ([]byte, error)
- func GetNameingCase(s string, casing HxCasing) string
- func GetNowDateOnlyString() string
- func GetNowDateString() string
- func GetNowDateTimeString() string
- func GetNowTimeOnlyString() string
- func GetNumberStringFromDateStr(value string) string
- func GetPascalCase(s string) string
- func GetQueryWherString(queryWhereString ...string) string
- func GetRegexpMatch(pattern string, str string) map[int]string
- func GetRequestFormValue(r *http.Request, key string) string
- func GetRequestFormValueIgnoreCase(r *http.Request, key string) string
- func GetSelectFilter(data []map[string]any, filter func(map[string]any) bool) []map[string]any
- func GetSelectGroupByCount(slice []map[string]any, groupByKey string) map[any]int
- func GetSnakeCase(s string) string
- func GetStringArrayFindKeyFromMapSlice(slice []map[string]any, findKey string) []string
- func GetStringJoinFindKey2FromMapSlice(slice []map[string]any, findKey string, sep string) string
- func GetStringJoinFindKeyFromMapSlice(slice []map[string]any, findKey string, sep string) string
- func IsDate(value string) bool
- func IsDatetime(value string) bool
- func IsDatetimeUnix(value string) bool
- func IsDatetimeUnixInt(value string) bool
- func IsFloat(value string) bool
- func IsInt(value string) bool
- func IsNullOrEmpty(value string) bool
- func IsNullOrWhiteSpace(value string) bool
- func IsNumber(value string) bool
- func IsRegexpMatch(pattern string, str string) bool
- func IsString(value string) bool
- func IsTime(value string) bool
- func Lower(str string) string
- func SetValueAppendFromMap(m map[string][]any, key string, value interface{})
- func SetValueFindKeyFromMapSlice(slice []map[string]any, findKey string, findValue any, setKey string, ...) bool
- func SubStr(str string, start int, end int) string
- func Trim(str string) string
- func Upper(str string) string
- type HxCasing
- type HxDbConfig
- type HxDbOracle
- func (h *HxDbOracle) BeginTransaction() (context.Context, error)
- func (h *HxDbOracle) Close() error
- func (h *HxDbOracle) Commit() error
- func (h *HxDbOracle) Connect(userID string, password string, database string) (context.Context, error)
- func (h *HxDbOracle) EndTransaction() error
- func (h *HxDbOracle) Field(colName string) (any, error)
- func (h *HxDbOracle) FieldByIndex(index int) (any, error)
- func (h *HxDbOracle) NextId(sequenceName string) (int64, error)
- func (h *HxDbOracle) NextRecord() (int, error)
- func (h *HxDbOracle) Open() (int, error)
- func (h *HxDbOracle) Query(query string, arg map[string]any) (int, error)
- func (h *HxDbOracle) QueryData(query string, arg map[string]any, queryWhereString ...string) ([]map[string]any, error)
- func (h *HxDbOracle) RecordCount() (int, error)
- func (h *HxDbOracle) RecordSet() ([]map[string]any, error)
- func (h *HxDbOracle) Rollback() error
- func (h *HxDbOracle) SetDebugMode(debug bool)
- func (h *HxDbOracle) WriteDebugMessage(str string)
- type HxDbProviderType
- type HxResultType
- type HxResultValue
- func (r *HxResultValue) CountEx() int
- func (res *HxResultValue) ToJsonBytes() ([]byte, error)
- func (res *HxResultValue) ToJsonBytesFromCaseingString(s string) ([]byte, error)
- func (res *HxResultValue) ToJsonBytesFromCaseingType(casing HxCasing) ([]byte, error)
- func (res *HxResultValue) ToJsonCamelCasingBytes() ([]byte, error)
- func (res *HxResultValue) ToJsonCaseBytes() ([]byte, error)
- func (res *HxResultValue) ToJsonNormalCaseBytes() ([]byte, error)
- func (res *HxResultValue) ToJsonPascalCasingBytes() ([]byte, error)
- func (res *HxResultValue) ToJsonResponseWriter(w http.ResponseWriter) bool
- func (res *HxResultValue) ToJsonSnakeCasingBytes() ([]byte, error)
- func (res *HxResultValue) ToJsonString() (string, error)
- func (r *HxResultValue) TypeEx() string
- type HxString
- func (s HxString) IsRegexpMatch(pattern string) bool
- func (s HxString) Lower() HxString
- func (s HxString) String() string
- func (s HxString) SubStr(start int, end int) HxString
- func (s HxString) ToBool() bool
- func (s HxString) ToFloat() float32
- func (s HxString) ToFloat64() float64
- func (s HxString) ToInt() int
- func (s HxString) ToInt64() int64
- func (s HxString) ToInt64ToCommaString() HxString
- func (s HxString) ToNumber() float64
- func (s HxString) ToRegexpMatch(pattern string) map[int]string
- func (s HxString) ToString() string
- func (s HxString) Trim() HxString
- func (s HxString) Upper() HxString
- type IHxDb
- type ResultOption
Constants ¶
const ( None HxResultType = iota Notice = 1 Warning = 2 Success = 3 Fail = 4 )
Variables ¶
var ( // HxDbProviderType 상수를 키(key)로, 설명을 값(value)으로 갖는 맵을 만듭니다. HxDbProviderDescriptions = map[HxDbProviderType]string{ Oracle: "Oracle Database Server", MSSQL: "Microsoft SQL Server", MySQL: "MySQL Server", MariaDB: "MariaDB Server", PostgreSQL: "PostgreSQL Server", SQLite: "SQLite Database", } HxDbProviderDefaultPort = map[HxDbProviderType]int{ Oracle: 1521, MSSQL: 1433, MySQL: 3306, MariaDB: 3306, PostgreSQL: 5432, SQLite: -1, } )
Functions ¶
func ConnectionString ¶
func ConnectionString(providerType HxDbProviderType, userId string, password string, database string) string
func ConvertFloatToInt ¶
func ConvertFloatToString ¶
func ConvertInt64ToString ¶
func ConvertIntToBool ¶
func ConvertIntToCommaString ¶
func ConvertIntToFloat ¶
func ConvertIntToInt32 ¶
func ConvertIntToInt64 ¶
func ConvertIntToString ¶
func ConvertIntToTimeUnix ¶
func ConvertStringToBool ¶
func ConvertStringToFloat32 ¶
func ConvertStringToFloat64 ¶
func ConvertStringToInt ¶
func ConvertStringToInt64 ¶
func ConvertStringToNumber ¶
func ConvertStringToTime ¶
func ConvertStringToTimeUnix ¶
func ConvertToCommaString ¶
func ConvertToCommaString(value interface{}) string
AddCommas 함수는 어떤 숫자 타입이든 받아 쉼표를 추가한 문자열로 반환합니다.
func ConvertValueToFloat64 ¶
func ConvertValueToFloat64(v interface{}) float64
func ConvertValueToInt64 ¶
func ConvertValueToInt64(v interface{}) int64
func ConvertValueToString ¶
func ConvertValueToString(v interface{}) string
func ConvertValueToUInt64 ¶
func ConvertValueToUInt64(v interface{}) uint64
func GetConnectionDataSourceString ¶
func GetConnectionDataSourceString(providerType HxDbProviderType, database string) string
func GetCountWithFilter ¶
슬라이스에서 특정 키와 값이 일치하는 맵의 개수를 셉니다.
func GetHxProviderDescription ¶
func GetHxProviderDescription(provider HxDbProviderType) string
func GetJsonWithCasing ¶
주어진 구조체를 선택한 표기법과 '원본 순서'의 JSON으로 변환합니다.
func GetMarshalWithCasing ¶
MarshalWithCasing은 주어진 구조체를 선택한 표기법의 JSON으로 변환합니다.
func GetNameingCase ¶
func GetNowDateOnlyString ¶
func GetNowDateOnlyString() string
func GetNowDateString ¶
func GetNowDateString() string
func GetNowDateTimeString ¶
func GetNowDateTimeString() string
func GetNowTimeOnlyString ¶
func GetNowTimeOnlyString() string
func GetQueryWherString ¶
func GetRequestFormValueIgnoreCase ¶
GetFormValueIgnoreCase는 http.Request에서 대소문자를 구분하지 않고 파라미터 값을 찾습니다. 일치하는 키가 없으면 빈 문자열을 반환합니다.
func GetSelectFilter ¶
상품 슬라이스와 '필터 함수'를 인자로 받습니다. 이 '필터 함수'는 상품 하나를 받아 조건을 만족하면 true를 반환합니다.
func GetSelectGroupByCount ¶
슬라이스에서 특정 키를 기준으로 그룹화하여 각 그룹의 개수를 셉니다. data: 원본 데이터 슬라이스 ([]map[string]any) groupByKey: 그룹화의 기준이 될 맵의 키 (string) 반환값: 그룹별 개수를 담은 맵 (map[any]int)
func GetSnakeCase ¶
GetSnakeCase는 문자열을 스네이크 케이스로 변환합니다. (e.g., UserID -> user_id)
func IsDatetime ¶
func IsDatetimeUnix ¶
func IsDatetimeUnixInt ¶
func IsNullOrEmpty ¶
func IsNullOrWhiteSpace ¶
func IsRegexpMatch ¶
func SetValueAppendFromMap ¶
add 함수는 맵, 키, 추가할 값을 받아 알아서 처리해줍니다.
func SetValueFindKeyFromMapSlice ¶
func SetValueFindKeyFromMapSlice(slice []map[string]any, findKey string, findValue any, setKey string, setValue any) bool
슬라이스에서 특정 조건에 맞는 맵을 찾아 값을 설정합니다. findKey, findValue: 찾으려는 맵을 식별하기 위한 조건 (예: "id", 10) setKey, setValue: 추가하거나 수정하려는 키와 값 반환값: 해당 맵을 찾아 수정했는지 여부 (bool)
Types ¶
type HxCasing ¶
type HxCasing int
Casing은 JSON 키 표기법을 나타내는 타입입니다.
func GetHxCasingFromString ¶
ParseHxCasing은 주어진 문자열을 HxCasing 타입으로 변환합니다. 일치하는 타입이 없으면 에러를 반환합니다.
type HxDbConfig ¶
type HxDbConfig struct {
Driver string `json:"driver" env:"DB_DRIVER" envDefault:"Oracle" description:"Database 드라이버"` // Oracle, MSSQL, MySQL, ... 등을 구분할 필드
User string `json:"user" env:"DB_USER" description:"User ID"`
Password string `json:"password" env:"DB_PASSWORD" description:"패스워드"`
Host string `json:"host" env:"DB_HOST" envDefault:"localhost" description:"Database 서버명(주소)"`
Port int `json:"port" env:"DB_PORT" description:"Database 접속 PORT"`
DBName string `json:"dbname" env:"DB_NAME" description:"DB Name or Service Name/ID(SID) or 추가 옵션"`
}
type HxDbOracle ¶
type HxDbOracle struct {
// contains filtered or unexported fields
}
HxDbOracle는 IHxDb 인터페이스를 구현하는 Oracle 전용 구조체입니다.
func (*HxDbOracle) BeginTransaction ¶
func (h *HxDbOracle) BeginTransaction() (context.Context, error)
트랜잭션 관련 메서드 (구현)
func (*HxDbOracle) Commit ¶
func (h *HxDbOracle) Commit() error
func (*HxDbOracle) Connect ¶
func (h *HxDbOracle) Connect(userID string, password string, database string) (context.Context, error)
Connect는 사용자 정보로 DSN을 만들어 Oracle DB에 연결합니다.
func (*HxDbOracle) EndTransaction ¶
func (h *HxDbOracle) EndTransaction() error
func (*HxDbOracle) Field ¶
func (h *HxDbOracle) Field(colName string) (any, error)
Field는 f와 동일한 기능을 합니다.
func (*HxDbOracle) FieldByIndex ¶
func (h *HxDbOracle) FieldByIndex(index int) (any, error)
FieldByIndex는 현재 레코드에서 인덱스로 컬럼 값을 가져옵니다. (Map에서는 순서가 보장되지 않으므로 주의)
func (*HxDbOracle) NextId ¶
func (h *HxDbOracle) NextId(sequenceName string) (int64, error)
next_id는 NextId 메서드를 호출하는 별칭(alias)입니다.
func (*HxDbOracle) NextRecord ¶
func (h *HxDbOracle) NextRecord() (int, error)
NextRecord는 next_record와 동일한 기능을 합니다.
func (*HxDbOracle) Open ¶
func (h *HxDbOracle) Open() (int, error)
Open은 Connect와 동일한 역할을 수행 (인터페이스 호환성을 위해)
func (*HxDbOracle) RecordCount ¶
func (h *HxDbOracle) RecordCount() (int, error)
RecordCount는 nf와 동일한 기능을 합니다.
func (*HxDbOracle) RecordSet ¶
func (h *HxDbOracle) RecordSet() ([]map[string]any, error)
RecordSet은 저장된 전체 레코드셋을 반환합니다.
func (*HxDbOracle) Rollback ¶
func (h *HxDbOracle) Rollback() error
func (*HxDbOracle) SetDebugMode ¶
func (h *HxDbOracle) SetDebugMode(debug bool)
func (*HxDbOracle) WriteDebugMessage ¶
func (h *HxDbOracle) WriteDebugMessage(str string)
type HxDbProviderType ¶
type HxDbProviderType string
const ( Oracle HxDbProviderType = "Oracle" MSSQL HxDbProviderType = "MS-SQL" MySQL HxDbProviderType = "MySQL" MariaDB HxDbProviderType = "MariaDB" PostgreSQL HxDbProviderType = "PostgreSQL" SQLite HxDbProviderType = "SQLite" OCI HxDbProviderType = "Oracle" )
func (HxDbProviderType) ToDescriptionEx ¶
func (drv HxDbProviderType) ToDescriptionEx() string
func (HxDbProviderType) ToStringEx ¶
func (drv HxDbProviderType) ToStringEx() string
HxDbProviderType 타입을 그냥 string 타입으로 변환해서 반환하면 됩니다.
type HxResultType ¶
type HxResultType int
func (HxResultType) MarshalJSON ¶
func (r HxResultType) MarshalJSON() ([]byte, error)
func (HxResultType) String ¶
func (r HxResultType) String() string
type HxResultValue ¶
type HxResultValue struct {
Result string `json:"result"`
Values any `json:"values"`
Message string `json:"message"`
Remark string `json:"remark"`
ResultType HxResultType `json:"ResultType"`
ValueType string `json:"ValueType"`
ValueCount int `json:"ValueCount"`
}
func CreateHxResponseResult ¶
func CreateHxResponseResult(resultType HxResultType, value any, message string, remark string) HxResultValue
func CreateHxResultValue ¶
func CreateHxResultValue(resultType HxResultType, value any, message string, remark string) HxResultValue
func (*HxResultValue) CountEx ¶
func (r *HxResultValue) CountEx() int
func (*HxResultValue) ToJsonBytes ¶
func (res *HxResultValue) ToJsonBytes() ([]byte, error)
func (*HxResultValue) ToJsonBytesFromCaseingString ¶
func (res *HxResultValue) ToJsonBytesFromCaseingString(s string) ([]byte, error)
func (*HxResultValue) ToJsonBytesFromCaseingType ¶
func (res *HxResultValue) ToJsonBytesFromCaseingType(casing HxCasing) ([]byte, error)
func (*HxResultValue) ToJsonCamelCasingBytes ¶
func (res *HxResultValue) ToJsonCamelCasingBytes() ([]byte, error)
func (*HxResultValue) ToJsonCaseBytes ¶
func (res *HxResultValue) ToJsonCaseBytes() ([]byte, error)
func (*HxResultValue) ToJsonNormalCaseBytes ¶
func (res *HxResultValue) ToJsonNormalCaseBytes() ([]byte, error)
func (*HxResultValue) ToJsonPascalCasingBytes ¶
func (res *HxResultValue) ToJsonPascalCasingBytes() ([]byte, error)
func (*HxResultValue) ToJsonResponseWriter ¶
func (res *HxResultValue) ToJsonResponseWriter(w http.ResponseWriter) bool
func (*HxResultValue) ToJsonSnakeCasingBytes ¶
func (res *HxResultValue) ToJsonSnakeCasingBytes() ([]byte, error)
func (*HxResultValue) ToJsonString ¶
func (res *HxResultValue) ToJsonString() (string, error)
func (*HxResultValue) TypeEx ¶
func (r *HxResultValue) TypeEx() string
type HxString ¶
type HxString string
func GetConvertStringToHxString ¶
string을 HxString으로 변환하는 함수
func GetConvertValueToHxString ¶
func GetConvertValueToHxString(value interface{}) HxString
func (HxString) IsRegexpMatch ¶
func (HxString) ToInt64ToCommaString ¶
type IHxDb ¶
type IHxDb interface {
// SetDebugMode는 디버그 모드를 활성화/비활성화합니다.
SetDebugMode(debug bool)
Connect(userID string, password string, database string) (context.Context, error)
//Open 데이터베이스 연결
Open() (int, error)
// Close는 데이터베이스 연결을 닫습니다.
Close() error
Query(query string, arg map[string]any) (int, error)
QueryData(query string, arg map[string]any, queryWhereString ...string) ([]map[string]any, error)
RecordCount() (int, error)
RecordSet() ([]map[string]any, error)
NextRecord() (int, error)
Field(colName string) (any, error)
FieldByIndex(index int) (any, error)
BeginTransaction() (context.Context, error)
EndTransaction() error
Commit() error
Rollback() error
NextId(sequenceName string) (int64, error)
// contains filtered or unexported methods
}
func CreateHxDb ¶
func CreateHxDb(provider HxDbProviderType) (IHxDb, error)
func NewHxDb ¶
func NewHxDb(provider HxDbProviderType) (IHxDb, error)
type ResultOption ¶
type ResultOption func(*HxResultValue)
옵션 함수의 타입을 정의
func WithMessage ¶
func WithMessage(message string) ResultOption
func WithOptionString ¶
func WithOptionString(remark string) ResultOption