mirror of
https://github.com/tiger1103/gfast.git
synced 2026-09-21 10:12:59 +00:00
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
// ============================================================================
|
|
// This is auto-generated by gf cli tool only once. Fill this file as you wish.
|
|
// ============================================================================
|
|
|
|
package dao
|
|
|
|
import (
|
|
"context"
|
|
"gfast/app/system/dao/internal"
|
|
"gfast/app/system/model"
|
|
"github.com/gogf/gf/errors/gerror"
|
|
"github.com/gogf/gf/frame/g"
|
|
"github.com/gogf/gf/os/gtime"
|
|
)
|
|
|
|
// sysUserDao is the manager for logic model data accessing
|
|
// and custom defined data operations functions management. You can define
|
|
// methods on it to extend its functionality as you wish.
|
|
type sysUserDao struct {
|
|
internal.SysUserDao
|
|
}
|
|
|
|
var (
|
|
// SysUser is globally public accessible object for table sys_user operations.
|
|
SysUser = sysUserDao{
|
|
internal.SysUser,
|
|
}
|
|
)
|
|
|
|
// Fill with you ideas below.
|
|
|
|
//通过用户名获取用户信息
|
|
func (d *sysUserDao) FindByUsername(ctx context.Context, username string) (user *model.LoginUserRes, err error) {
|
|
user = &model.LoginUserRes{}
|
|
err = d.Ctx(ctx).Fields(user).Where(d.Columns.UserName, username).Scan(user)
|
|
if err != nil {
|
|
g.Log().Error(err)
|
|
err = gerror.New("获取用户信息失败")
|
|
}
|
|
return
|
|
}
|
|
|
|
//更新用户登陆信息
|
|
func (d *sysUserDao) UpLoginInfo(id uint64, ip string) {
|
|
_, err := d.WherePri(id).Unscoped().Update(g.Map{
|
|
d.Columns.LastLoginIp: ip,
|
|
d.Columns.LastLoginTime: gtime.Now(),
|
|
})
|
|
if err != nil {
|
|
g.Log().Error(err)
|
|
}
|
|
}
|