![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
gin_知了实战
weixin_38107457
这个作者很懒,什么都没留下…
展开
-
内容区模糊查询
package newsimport ( "github.com/astaxie/beego" "github.com/astaxie/beego/orm" "ions_zhiliao/models/news" "fmt" "github.com/astaxie/beego/logs" "math" "ions_zhiliao/utils" "time" "strconv")type NewsController struct { beego.Controller}fu.原创 2021-08-03 17:55:00 · 241 阅读 · 0 评论 -
导入excel数据到数据库
go get github.com/Luxurioust/excelizego get -u github.com/Luxurioust/excelize需要goroot目录下的src中添加我提供的golang.org文件夹,解压后注意不要嵌套,依赖charset等原创 2021-08-03 17:53:00 · 108 阅读 · 0 评论 -
添加日志记录
main.go// 日志 logs.SetLogger(logs.AdapterMultiFile,`{"filename":"logs/ions.log","separate":["error","info"]}`)func (c *LoginController) Post(){ username := c.GetString("username") password := c.GetString("password") captcha :=c.GetString("captcha"原创 2021-07-29 22:13:26 · 90 阅读 · 0 评论 -
user模块所有代码
package userimport ( "github.com/astaxie/beego" "github.com/astaxie/beego/orm" "ions_zhiliao/models/auth" "math" "ions_zhiliao/utils" "strconv" "strings" "github.com/astaxie/beego/logs" "fmt")type UserController struct { beego.Controller}.原创 2021-07-28 23:10:35 · 150 阅读 · 0 评论 -
添加用户操作
func (u *UserController) DoAdd() { username := u.GetString("username") password := u.GetString("password") age,_ := u.GetInt("age") gender,_ := u.GetInt("gender") phone := u.GetString("phone") addr := u.GetString("addr") is_active,_ := u.GetInt("i.原创 2021-07-28 22:49:24 · 90 阅读 · 0 评论 -
uerlist 分页
func (c *UserController) Get(){ o := orm.NewOrm() qs := o.QueryTable("sys_user") users := []user.User{} // 每页显示的条数 pagePerNum := 2 // 当前页 currentPage,err := c.GetInt("page") if err != nil { // 说明没有获取到当前页 currentPage = 1 } offsetNum := pagePe.原创 2021-07-28 22:41:43 · 76 阅读 · 0 评论 -
userlist_列表返回
模型package userimport ( "github.com/astaxie/beego/orm" "time")// User 模型type User struct { Id int `orm:"pk;auto"` UserName string `orm:"unique;column(user_name);size(64);description(用户名)"` Password string `orm:"size(32);description(密码)"` Age原创 2021-07-27 23:41:35 · 234 阅读 · 0 评论 -
登录拦截功能实现
utils->loginfilter.gopackage utilsimport "github.com/astaxie/beego/context"func LoginFilter(c *context.Context) { // 获取session id := c.Input.Session("id") if id == nil{ // 说明未登录 c.Redirect(302,"/") }}main.go// 未登录请求拦截 beego.Insert原创 2021-07-27 22:36:33 · 154 阅读 · 0 评论 -
生成base64图片验证码(过程艰辛)
utils -> get_captcha.gogithub.com/mojocn/base64Captchapackage utilsimport ( "github.com/mojocn/base64Captcha" "image/color")type Captcha struct { Id string BS64 string}func GetCaptcha() (id string, base64 string, err error) { rgbaColo原创 2021-07-26 00:06:56 · 672 阅读 · 0 评论 -
[go_bug]beego 无法找到templatefile
can't find templatefile in the path:views/admin/login.tpl解决方法:原创 2021-07-25 22:39:23 · 1257 阅读 · 0 评论 -
[go_bug] malformed module path “embed“: missing dot in first p
github.com/mojocn/base64Captcha importsembed: malformed module path "embed": missing dot in first path element原创 2021-07-25 12:50:18 · 2519 阅读 · 0 评论