Merge pull request #504 from go-admin-team/dev
1. 修复菜单的目录(#500) 1. 调整字段判断逻辑
This commit is contained in:
2 files changed
+33
-20
No files matched your search
@@ -55,8 +55,8 @@ func (s *ResetSysUserPwdReq) Generate(model *models.SysUser) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UpdateSysUserAvatarReq struct {
|
type UpdateSysUserAvatarReq struct {
|
||||||
UserId int `json:"userId" comment:"用户ID" vd:"required"` // 用户ID
|
UserId int `json:"userId" comment:"用户ID" vd:"len($)>0"` // 用户ID
|
||||||
Avatar string `json:"avatar" comment:"头像" vd:"required"`
|
Avatar string `json:"avatar" comment:"头像" vd:"len($)>0"`
|
||||||
common.ControlBy
|
common.ControlBy
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,8 +72,8 @@ func (s *UpdateSysUserAvatarReq) Generate(model *models.SysUser) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UpdateSysUserStatusReq struct {
|
type UpdateSysUserStatusReq struct {
|
||||||
UserId int `json:"userId" comment:"用户ID" vd:"required"` // 用户ID
|
UserId int `json:"userId" comment:"用户ID" vd:"$>0"` // 用户ID
|
||||||
Status string `json:"status" comment:"状态" vd:"required"`
|
Status string `json:"status" comment:"状态" vd:"len($)>0"`
|
||||||
common.ControlBy
|
common.ControlBy
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,18 +90,18 @@ func (s *UpdateSysUserStatusReq) Generate(model *models.SysUser) {
|
|||||||
|
|
||||||
type SysUserInsertReq struct {
|
type SysUserInsertReq struct {
|
||||||
UserId int `json:"userId" comment:"用户ID"` // 用户ID
|
UserId int `json:"userId" comment:"用户ID"` // 用户ID
|
||||||
Username string `json:"username" comment:"用户名" vd:"required"`
|
Username string `json:"username" comment:"用户名" vd:"len($)>0"`
|
||||||
Password string `json:"password" comment:"密码"`
|
Password string `json:"password" comment:"密码"`
|
||||||
NickName string `json:"nickName" comment:"昵称" vd:"required"`
|
NickName string `json:"nickName" comment:"昵称" vd:"len($)>0"`
|
||||||
Phone string `json:"phone" comment:"手机号" vd:"required"`
|
Phone string `json:"phone" comment:"手机号" vd:"len($)>0"`
|
||||||
RoleId int `json:"roleId" comment:"角色ID"`
|
RoleId int `json:"roleId" comment:"角色ID"`
|
||||||
Avatar string `json:"avatar" comment:"头像"`
|
Avatar string `json:"avatar" comment:"头像"`
|
||||||
Sex string `json:"sex" comment:"性别"`
|
Sex string `json:"sex" comment:"性别"`
|
||||||
Email string `json:"email" comment:"邮箱" vd:"required,email"`
|
Email string `json:"email" comment:"邮箱" vd:"len($)>0,email"`
|
||||||
DeptId int `json:"deptId" comment:"部门" vd:"required"`
|
DeptId int `json:"deptId" comment:"部门" vd:"len($)>0"`
|
||||||
PostId int `json:"postId" comment:"岗位"`
|
PostId int `json:"postId" comment:"岗位"`
|
||||||
Remark string `json:"remark" comment:"备注"`
|
Remark string `json:"remark" comment:"备注"`
|
||||||
Status string `json:"status" comment:"状态" vd:"required" default:"1"`
|
Status string `json:"status" comment:"状态" vd:"len($)>0" default:"1"`
|
||||||
common.ControlBy
|
common.ControlBy
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,17 +129,17 @@ func (s *SysUserInsertReq) GetId() interface{} {
|
|||||||
|
|
||||||
type SysUserUpdateReq struct {
|
type SysUserUpdateReq struct {
|
||||||
UserId int `json:"userId" comment:"用户ID"` // 用户ID
|
UserId int `json:"userId" comment:"用户ID"` // 用户ID
|
||||||
Username string `json:"username" comment:"用户名" vd:"required"`
|
Username string `json:"username" comment:"用户名" vd:"len($)>0"`
|
||||||
NickName string `json:"nickName" comment:"昵称" vd:"required"`
|
NickName string `json:"nickName" comment:"昵称" vd:"len($)>0"`
|
||||||
Phone string `json:"phone" comment:"手机号" vd:"required"`
|
Phone string `json:"phone" comment:"手机号" vd:"len($)>0"`
|
||||||
RoleId int `json:"roleId" comment:"角色ID"`
|
RoleId int `json:"roleId" comment:"角色ID"`
|
||||||
Avatar string `json:"avatar" comment:"头像"`
|
Avatar string `json:"avatar" comment:"头像"`
|
||||||
Sex string `json:"sex" comment:"性别"`
|
Sex string `json:"sex" comment:"性别"`
|
||||||
Email string `json:"email" comment:"邮箱" vd:"required,email"`
|
Email string `json:"email" comment:"邮箱" vd:"len($)>0,email"`
|
||||||
DeptId int `json:"deptId" comment:"部门" vd:"required"`
|
DeptId int `json:"deptId" comment:"部门" vd:"$>0"`
|
||||||
PostId int `json:"postId" comment:"岗位"`
|
PostId int `json:"postId" comment:"岗位"`
|
||||||
Remark string `json:"remark" comment:"备注"`
|
Remark string `json:"remark" comment:"备注"`
|
||||||
Status string `json:"status" comment:"状态" vd:"required" default:"1"`
|
Status string `json:"status" comment:"状态" default:"1"`
|
||||||
common.ControlBy
|
common.ControlBy
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,6 +183,6 @@ func (s *SysUserById) GenerateM() (common.ActiveRecord, error) {
|
|||||||
|
|
||||||
// PassWord 密码
|
// PassWord 密码
|
||||||
type PassWord struct {
|
type PassWord struct {
|
||||||
NewPassword string `json:"newPassword" vd:"required"`
|
NewPassword string `json:"newPassword" vd:"len($)>0"`
|
||||||
OldPassword string `json:"oldPassword" vd:"required"`
|
OldPassword string `json:"oldPassword" vd:"len($)>0"`
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
@@ -333,11 +332,25 @@ func (e *SysMenu) getByRoleName(roleName string) ([]models.SysMenu, error) {
|
|||||||
} else {
|
} else {
|
||||||
role.RoleKey = roleName
|
role.RoleKey = roleName
|
||||||
err = e.Orm.Debug().Model(&role).Where("role_key = ? ", roleName).Preload("SysMenu", func(db *gorm.DB) *gorm.DB {
|
err = e.Orm.Debug().Model(&role).Where("role_key = ? ", roleName).Preload("SysMenu", func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where(" menu_type in ('M','C')").Order("sort")
|
return db.Where(" menu_type in ('C')").Order("sort")
|
||||||
}).Find(&role).Error
|
}).Find(&role).Error
|
||||||
if role.SysMenu != nil {
|
if role.SysMenu != nil {
|
||||||
MenuList = *role.SysMenu
|
MenuList = *role.SysMenu
|
||||||
}
|
}
|
||||||
|
mIds := make([]int, 0)
|
||||||
|
for _, menu := range MenuList {
|
||||||
|
if menu.ParentId != 0 {
|
||||||
|
mIds = append(mIds, menu.ParentId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var data []models.SysMenu
|
||||||
|
err = e.Orm.Where(" menu_type in ('M') and menu_id in ?", mIds).Order("sort").Find(&data).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, datum := range data {
|
||||||
|
MenuList = append(MenuList, datum)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in new issue
Block a user