utility

package module
v0.0.0-...-312a6cb Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

README

Golang 的一些有用的utilities. 包括:

  • jwt.go 提供jwt相关操作
  • captcha.go 提供自动生成, 验证验证码(通过base64)
  • excel.go 提供excel导出
  • email.go 发送邮件
  • time.go 自定义的时间

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateExcel

func GenerateExcel() string

func GenerateStandardJwt

func GenerateStandardJwt(jwtData *JwtData) string

func GetNewCaptcha

func GetNewCaptcha() (string, string, error)

func ParseToken

func ParseToken(token string) (string, error)

func SendEmail

func SendEmail(target string) string

func VerifyCaptcha

func VerifyCaptcha(id string, code string) bool

func WriteXlsx

func WriteXlsx(sheet string, records interface{}) *excelize.File

Types

type Data

type Data struct {
	Name       string    `gorm:"not null" json:"name" xlsx:"姓名"`
	UpdatedAt  time.Time `gorm:"not null" json:"-" xlsx:"更新时间"`
	CreatedAt  time.Time `gorm:"not null" json:"-" xlsx:"创建时间"`
	StuID      string    `gorm:"primaryKey" json:"stu_id" xlsx:"学号"`
	Gender     string    `gorm:"not null" json:"gender" xlsx:"性别"`
	College    string    `gorm:"not null" json:"college" xlsx:"专业"`
	Campus     string    `gorm:"not null" json:"campus" xlsx:"学院"`
	Phone      string    `gorm:"not null" json:"phone" xlsx:"电话号"`
	QQ         string    `gorm:"not null" json:"qq" xlsx:"QQ"`
	Region     string    `gorm:"not null" json:"region" xlsx:"校区"`
	Want1      string    `gorm:"not null" json:"want1" xlsx:"第一志愿"`
	Want2      string    `gorm:"not null" json:"want2" xlsx:"第二志愿"`
	Profile    string    `gorm:"not null" json:"profile" xlsx:"简介"`
	Feedback   string    `gorm:"not null" json:"feedback" xlsx:"反馈"`
	IsModified bool      `gorm:"not null" json:"is_modified" xlsx:"是否修改"`
}

type JwtData

type JwtData struct {
	ID string `json:"id"`
	jwt.StandardClaims
}

type MailboxConf

type MailboxConf struct {
	// 邮件标题
	Title string
	// 邮件内容
	Body string
	// 收件人列表
	RecipientList []string
	// 发件人账号
	Sender string
	// 发件人密码,QQ邮箱这里配置授权码
	SPassword string
	// SMTP 服务器地址, QQ邮箱是smtp.qq.com
	SMTPAddr string
	// SMTP端口 QQ邮箱是25
	SMTPPort int
}

MailboxConf 邮箱配置

type Time

type Time struct {
	time.Time
}

自定义的时间

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

JSON 序列化

func (*Time) Scan

func (t *Time) Scan(v interface{}) error

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

JSON 反序列化

func (Time) Value

func (t Time) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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