企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 部分代码 ### 数据库链接 ``` Db, err = sqlx.Connect(`mysql`, `user:password@tcp(host:port)/database?charset=utf8&parseTime=true&loc=Local`) ``` ### utils ``` package utils //standard format type result struct { State stat `json:"state"` Msg string `json:"msg"` Data interface{} `json:"data"` } //page format //Message type list struct { Count int `json:"count"` Item interface{} `json:"item"` } type stat int const ( StSucc stat = 200 //正常 StFail stat = 300 //失败 StErrIpt stat = 310 //输入数据有误 StErrOpt stat = 320 //无数据返回 ) const ( FormatTime = "15:04:05" FormatDate = "2006-01-02" FormatDateTime = "2006-01-02 15:04:05" ) func newRes(st stat, msg string, data ...interface{}) *result { if len(data) > 0 { return &result{ State: st, Msg: msg, Data: data[0], } } return &result{ State: st, Msg: msg, } } func NewSucc(msg string, data ...interface{}) *result { return newRes(StSucc, msg, data...) } func NewFail(msg string, data ...interface{}) *result { return newRes(StFail, msg, data...) } func NewErr(st stat, msg string, data ...interface{}) *result { return newRes(st, msg, data...) } func NewList(msg string, item interface{}, count int) *result { return &result{ State: StSucc, Msg: msg, Data: list{ Item: item, Count: count, }, } } ```