Example #1
0
//添加会员组
func (u *User) Save() bool {
	user := new(User)

	user.Email = u.Email
	user.Username = u.Username
	user.Password = utils.Md5(u.Password)
	user.Encrypt = utils.RandomString(6)
	user.Nickname = u.Nickname
	user.Mobile = u.Mobile
	user.Birthday = u.Birthday
	user.Regip = utils.GetClientIP()
	user.Regdate = time.Now().Format("2006-01-02 15:04:04")
	user.Lastdate = time.Now().Format("2006-01-02 15:04:04")
	user.Lastip = utils.GetClientIP()
	user.Loginnum = 0
	user.Groupid = u.Groupid
	user.Areaid = u.Areaid
	user.Amount = 0
	user.Point = u.Point
	user.Ismessage = u.Ismessage
	user.Islock = u.Islock
	user.Vip = u.Vip
	user.Overduedate = u.Overduedate
	user.Status = u.Status
	user.Createtime = time.Now().Format("2006-01-02 15:04:04")

	has, err := DB_Write.Table("user").Insert(user)
	if err != nil {
		revel.WARN.Println(has)
		revel.WARN.Printf("错误: %v", err)
		return false
	}
	return true
}
Example #2
0
File: admin.go Project: qmdx/GoCMS
// 更新登陆时间
func (a *Admin) UpdateLoginTime(Id int64) bool {
	admin := new(Admin)

	admin.Lastloginip = utils.GetClientIP()
	admin.Lastlogintime = time.Now().Format("2006-01-02 15:04:04")

	has, err := Engine.Id(Id).Cols("lastloginip", "lastlogintime").Update(admin)
	if err != nil {
		revel.WARN.Println(has)
		revel.WARN.Printf("错误: %v", err)
		return false
	}

	return true
}
Example #3
0
File: logs.go Project: qmdx/GoCMS
//添加日志记录
func (L *Logs) Save(Admin_Info *Admin, c *revel.Controller, Desc string) bool {
	logs := new(Logs)

	logs.Uid = Admin_Info.Id
	logs.Module = c.Name
	logs.Url = c.Action
	logs.Action = c.MethodName
	logs.Ip = utils.GetClientIP()
	logs.Desc = Desc
	logs.Createtime = time.Now().Format("2006-01-02 15:04:04")

	has, err := Engine.Insert(logs)
	if err != nil {
		revel.WARN.Println(has)
		revel.WARN.Printf("错误: %v", err)
		return false
	}
	return true
}
Example #4
0
//添加评论
func (c *Comment) Save() bool {
	comment := new(Comment)

	comment.Replyid = c.Replyid
	comment.Content = c.Content
	comment.Uid = c.Uid
	comment.Agree = 0
	comment.Against = 0
	comment.Ip = utils.GetClientIP()
	comment.Createtime = time.Now().Format("2006-01-02 15:04:04")

	has, err := DB_Write.Table("comment").Insert(comment)
	if err != nil {
		revel.WARN.Println(has)
		revel.WARN.Printf("错误: %v", err)
		return false
	}
	return true
}
Example #5
0
File: admin.go Project: qmdx/GoCMS
//添加管理员
func (a *Admin) Save() bool {

	admin := new(Admin)
	admin.Username = a.Username
	admin.Password = utils.Md5(a.Password)
	admin.Roleid = a.Roleid
	admin.Lastloginip = utils.GetClientIP()
	admin.Email = a.Email
	admin.Realname = a.Realname
	admin.Lang = a.Lang
	admin.Lastlogintime = "0000-00-00 00:00:00"
	admin.Status = a.Status
	admin.Createtime = time.Now().Format("2006-01-02 15:04:04")

	has, err := Engine.Insert(admin)
	if err != nil {
		revel.WARN.Println(has)
		revel.WARN.Printf("错误: %v", err)
		return false
	}
	return true
}