gormv2升级 第一阶段

This commit is contained in:
QM303176530
2020-08-23 15:13:23 +08:00
parent f130aec168
commit 363ff3ba70
40 changed files with 133 additions and 99 deletions

View File

@@ -7,6 +7,7 @@ import (
"gin-vue-admin/model/request"
"gin-vue-admin/utils"
uuid "github.com/satori/go.uuid"
"gorm.io/gorm"
)
// @title Register
@@ -19,7 +20,7 @@ import (
func Register(u model.SysUser) (err error, userInter model.SysUser) {
var user model.SysUser
// 判断用户名是否注册
notRegister := global.GVA_DB.Where("username = ?", u.Username).First(&user).RecordNotFound()
notRegister := errors.Is(global.GVA_DB.Where("username = ?", u.Username).First(&user).Error, gorm.ErrRecordNotFound)
// notRegister为false表明读取到了 不能注册
if !notRegister {
return errors.New("用户名已注册"), userInter
@@ -69,7 +70,7 @@ func ChangePassword(u *model.SysUser, newPassword string) (err error, userInter
// @return list interface{}
// @return total int
func GetUserInfoList(info request.PageInfo) (err error, list interface{}, total int) {
func GetUserInfoList(info request.PageInfo) (err error, list interface{}, total int64) {
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
db := global.GVA_DB.Model(&model.SysUser{})