Documentation
¶
Index ¶
- func AmountConvert(amount int) string
- func AmountToYuan(amount int) float64
- func CalcDiscountAmount(amount int, discount float64) int
- func CalculateRequestDuration(clientTime int64) (float64, error)
- func ConvertChineseToKeyword(chinese string) string
- func Downsample2to1Average(in []int16) []int16
- func EmailFormat(email string) string
- func EncryptMD5(input string) string
- func Error(c *gin.Context, code int, data interface{})
- func FormatPrompt(prompt string, parameter map[string]string) string
- func GenerateID(uid int) int
- func GenerateLoginToken(uid int) (string, error)
- func GenerateRealtimeToken(uid int, project int, device int) (string, error)
- func GenerateToken(len int, id ...int) string
- func GetCurrentUnix() int
- func GetCurrentUnixMilli() int
- func GetDate() string
- func GetLunarDate() string
- func GetTencentCloudLocalIP() (string, error)
- func GetTencentCloudPublicIP() (string, error)
- func GetTime() string
- func GetUUID() string
- func GetWeekday() string
- func IsLocalhost(ipStr string) bool
- func MobileFormat(str string) string
- func PCMToWAV(pcmData []byte, sampleRate, numChannels, bitsPerSample int) []byte
- func ParseID(uid int) int
- func ParseToken(len int, key string) ([]int, error)
- func RequestLog(c *gin.Context, status string, response string)
- func Sample48to16(in []int16) []int16
- func SendMail(to string, subject string, content string) bool
- func Success(c *gin.Context, code int, data interface{})
- func TimeFormat(unix int) string
- func TimeMinFormat(unix int) string
- func UpsampleAndStereo(in []int16) []int16
- func ValidateAuthorization(c *gin.Context) (bool, int)
- func ValidateDevice(c *gin.Context) string
- func ValidateHeader(c *gin.Context) (bool, int)
- func ValidateSource(c *gin.Context) string
- func Warning(c *gin.Context, code int, data interface{})
- type EmptyData
- type IPInfo
- type LoginClaims
- type RealtimeClaims
- type RequestLogData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AmountConvert ¶
AmountConvert converts an amount in cents to a string representation in yuan with two decimal places.
func AmountToYuan ¶
AmountToYuan converts an amount in cents to a float64 representation in yuan.
func CalcDiscountAmount ¶
CalcDiscountAmount calculates the discounted amount based on the original amount in cents and a discount rate.
func CalculateRequestDuration ¶
CalculateRequestDuration calculates the duration between the client time and the current server time.
func ConvertChineseToKeyword ¶
ConvertChineseToKeyword converts Chinese characters to a keyword format suitable for wakeup detection.
func EmailFormat ¶
EmailFormat masks part of the email address for privacy.
func EncryptMD5 ¶
EncryptMD5 generates an MD5 hash of the input string.
func Error ¶
Error sends an error response with a specific code and data.
func FormatPrompt ¶
FormatPrompt reads the system prompt file and replaces placeholders with provided parameters.
func GenerateID ¶
GenerateID generates an obfuscated ID using the Optimus algorithm.
func GenerateLoginToken ¶
GenerateToken creates a JWT token for a given user ID with a 15-day expiration.
func GenerateRealtimeToken ¶
GenerateRealtimeToken creates a JWT token for real-time communication with a 30-day expiration.
func GenerateToken ¶
GenerateToken creates an obfuscated API key using the Hashids algorithm.
func GetCurrentUnixMilli ¶
func GetCurrentUnixMilli() int
GetCurrentUnixMilli returns the current Unix timestamp in milliseconds.
func GetLunarDate ¶
func GetLunarDate() string
GetLunarDate returns a placeholder for the current lunar date.
func IsLocalhost ¶
IsLocalhost checks if the given IP address is a loopback address (localhost).
func PCMToWAV ¶
PCMToWAV converts raw PCM data to WAV format.
func ParseID ¶
ParseID decodes an obfuscated ID back to the original user ID.
func ParseToken ¶
ParseToken decodes an obfuscated API key back to the original ID(s).
func RequestLog ¶
RequestLog logs the details of the HTTP request and response.
func Sample48to16 ¶
Sample48to16 converts 48kHz audio samples to 16kHz by downsampling.
func SendMail ¶
SendMail sends an email to the specified recipient with the given subject and content.
func Success ¶
Success sends a successful response with a specific code and data.
func TimeFormat ¶
TimeFormat formats a Unix timestamp into a human-readable string.
func TimeMinFormat ¶
TimeMinFormat formats a Unix timestamp into a date string (YYYY-MM-DD).
func UpsampleAndStereo ¶
upsampleAndStereo converts 24kHz mono PCM to 48kHz stereo PCM
Types ¶
type EmptyData ¶
type EmptyData struct{}
EmptyData is an empty struct used as a placeholder or for responses with no data.
type IPInfo ¶
type LoginClaims ¶
type LoginClaims struct {
UID int `json:"user_id"`
jwt.RegisteredClaims
}
LoginClaims struct defines the structure for JWT claims used in authentication.
func ParseLoginToken ¶
func ParseLoginToken(tokenStr string) (*LoginClaims, error)
ParseToken validates a JWT token string and returns the claims if valid.
type RealtimeClaims ¶
type RealtimeClaims struct {
UID int `json:"user_id"`
ProjectID int `json:"project_id"`
DeviceID int `json:"device_id"`
jwt.RegisteredClaims
}
RealtimeClaims struct defines the structure for JWT claims used in real-time communication.
func ParseRealtimeToken ¶
func ParseRealtimeToken(tokenStr string) (*RealtimeClaims, error)
ParseRealtimeToken validates a JWT token string for real-time communication and returns the claims if valid.
Source Files
¶
- amount.go
- audio.go
- client.go
- cryption.go
- device.go
- email.go
- empty.go
- header.go
- phone.go
- pinyin.go
- prompt.go
- return.go
- sample.go
- time.go
- uuid.go