Getting Started =============== ## Installing To start using LxUtils, install Go and run `go get`: ```sh $ go get -u git.listensoft.net/tool/lxutils ``` ## Get a value Go. ```go package main import ( "fmt" "git.listensoft.net/tool/lxutils/lxCommon" "git.listensoft.net/tool/lxutils/lxDb" "git.listensoft.net/tool/lxutils/lxrun" "git.listensoft.net/tool/lxutils/lxzap" "github.com/gin-gonic/gin" "gorm.io/gorm" "time" ) func main() { //lxutils.Aa() lxrun.Run("prod", "8989", func() { //可执行定时器等等 fmt.Println("run cron、mq") }, router, lxzap.ZapLogConfig{ Level: "info", Filename: "zap.log", MaxSize: 2, MaxAge: 1000, MaxBackups: 10000, }, lxDb.DbConfig{ Host: "xxxxxxx", Port: "3306", User: "xxxxxx", Password: "xxxxx", Database: "etax", Charset: "utf8mb4", }, lxDb.RedisConfig{}) } func router(router *gin.Engine) { router.GET("/server", func(c *gin.Context) { lxzap.Log("测试log", c) lxDb.GetDB(c).Model(User{BaseModel: BaseModel{ID: 12}}).First(&User{}) lxCommon.Ok(c, "") }) } type BaseModel struct { ID int32 `gorm:"primary_key;comment:ID"` CreatedAt time.Time `gorm:"column:add_time;comment:创建时间"` UpdatedAt time.Time `gorm:"column:update_time;comment:更新时间"` DeletedAt gorm.DeletedAt `gorm:"comment:删除时间"` IsDeleted bool `gorm:"comment:是否删除"` } type User struct { BaseModel Mobile string `gorm:"index:idx_mobile;unique;type:varchar(11);not null;comment:手机号"` Password string `gorm:"type:varchar(100);not null;comment:密码"` NickName string `gorm:"type:varchar(20);comment:账号名称"` Birthday *time.Time `gorm:"type:datetime;comment:出生日期"` Gender string `gorm:"column:gender;default:male;type:varchar(6);comment:femail表示女,male表示男"` Role int `gorm:"column:role;default:1;type:int;comment:1表示普通用户,2表示管理员"` } ```