common

package
v0.0.0-...-1eded09 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: GPL-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Log      *logrus.Logger
	Mysqllog *logrus.Entry
	Mongolog *logrus.Entry
)

Functions

func CliLogger

func CliLogger()

func Compress

func Compress(src, dest string) error

Compress 将src压缩成dest (tar.gz) 注意:不能压缩自己

func CreateAccount

func CreateAccount(email string) (uid int64, err error)

func CreateStagingDev

func CreateStagingDev(email string) (uid int64, err error)

func DeCompress

func DeCompress(src, dest string) error

解压 tar.gz

func ExecCommand

func ExecCommand(commandName string) bool

func Exec_shell

func Exec_shell(s string) (string, error)

阻塞式的执行外部shell命令的函数,等待执行完毕并返回标准输出

func Exists

func Exists(path string) bool

Exists 判断文件夹是否存在

func ExportSqlData2File

func ExportSqlData2File(data []map[string]interface{}, table string, filePath string, haveId bool) error

exportSqlData2File 将sql数据按照特定方式导出到文件

func GetAccToken

func GetAccToken() (res string)

GetAccToken 签 acc Bearer token

func GetFunc

func GetFunc() string

func GetMapKeyValue

func GetMapKeyValue(data map[string]interface{}, haveId bool) (col string, val string, err error)

GetMapKeyValue 分别获取表的字段和字段的值

func GetTimeString

func GetTimeString() (t string)

func Interface2slice

func Interface2slice(i interface{}) (s []string)

func IsInt

func IsInt(value interface{}) bool

func Logger

func Logger() gin.HandlerFunc

func PrintFileList

func PrintFileList(fl []string)

func ReadDirectory

func ReadDirectory(dir string) (fl []string)

* 读取目录内的文件

func RemoveFile

func RemoveFile(dataDir string)

func Sort

func Sort(key []string)

func Strval

func Strval(value interface{}) string

Strval 将其他数据类型转换成string

func Validate

func Validate(data interface{}) (string, int)

func WriteBytes

func WriteBytes(filePath string, b []byte) error

func WriteStrings

func WriteStrings(filePath string, s string) error

WriteStrings 向文件中写入字符串

Types

type Config

type Config struct {
	AccessKey     string `json:"access_key"`
	SecretKey     string `json:"secret_key"`
	Zone          int    `json:"zone"`
	Bucket        string `json:"Bucket"`
	UseHTTPS      bool   `json:"use_https"`
	UseCdnDomains bool   `json:"use_cdn_domains"`
	Domain        string `json:"domain"`
}

func LoadBucketConfig

func LoadBucketConfig() *Config

type Database

type Database int
const (
	Mysql Database = 1 << iota
	Mongo
)

type Developer

type Developer struct {
	Email string `bson:"email" json:"email"` // 电子邮箱。唯一。
	Uid   int64  `bson:"uid" json:"uid"`     // 用户数字ID。唯一。
}

type DeveloperBasicInput

type DeveloperBasicInput struct {
	FullName        *string    `json:"fullName,omitempty"`
	PhoneNumber     *string    `json:"phoneNumber,omitempty"`
	Gender          Gender     `json:"gender,omitempty"`
	ImCategory      ImCategory `json:"imCategory,omitempty"`
	ImNumber        *string    `json:"imNumber,omitempty"`
	WebSite         *string    `json:"webSite,omitempty"`
	ContractAddress *string    `json:"contractAddress,omitempty"`
	LicenseVersion  *string    `json:"licenseVersion,omitempty"`
	CompanyName     *string    `json:"companyName,omitempty"`
}

type Gender

type Gender int

* 开发者身份,注册基本信息

const (
	GenderMale   Gender = 0
	GenderFemale Gender = 1
)

type ImCategory

type ImCategory int
const (
	QQ ImCategory = iota
	MSN
	GTalk
	Skype
	Other
)

type JsonResult

type JsonResult struct {
	Code    int                    `json:"code"`
	Data    Developer              `json:"data,omitempty"`
	Message string                 `json:"message,omitempty"`
	Extra   map[string]interface{} `json:"extra,omitempty"`
}

type QiNiuClient

type QiNiuClient struct {
	AccessKey     string `json:"access_key"`
	SecretKey     string `json:"secret_key"`
	Bucket        string `json:"bucket"` //
	Zone          int    `json:"zone"`   //0:华东, 1:华北, 2:华南, 3:北美
	UseHTTPS      bool   `json:"use_https"`
	UseCdnDomains bool   `json:"use_cdn_domains"`
	Domain        string `json:"domain"`
}

func NewClient

func NewClient(accessKey, secretKey, bucket string, Zone int, useHttps, useCdnDomains bool, domain string) *QiNiuClient

func (*QiNiuClient) SignDownloadPrivateToken

func (client *QiNiuClient) SignDownloadPrivateToken(url string) (data string)

func (*QiNiuClient) UploadFile2Bucket

func (client *QiNiuClient) UploadFile2Bucket(fileDir string, fileList []string) (successUrlList []string, err error)

type Token

type Token struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

type User

type User struct {
	Email    string `json:"email"`
	Phone    string `json:"phone"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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