From d8ac88cfb72e3aac3a89c3cfe77774be3024a24c Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 11 八月 2023 17:54:43 +0800
Subject: [PATCH] update
---
model/authority.go | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/model/authority.go b/model/authority.go
index b05889b..7de6325 100644
--- a/model/authority.go
+++ b/model/authority.go
@@ -7,8 +7,8 @@
type (
Authority struct {
- AuthorityId uint `json:"authorityId" gorm:"not null;unique;primary_key;comment:瑙掕壊ID;size:90"` // 瑙掕壊ID
- AuthorityName string `json:"authorityName" gorm:"comment:瑙掕壊鍚�"` // 瑙掕壊鍚�
+ Id uint `json:"id" gorm:"column:id;autoIncrement;not null;unique;primary_key;comment:瑙掕壊ID;size:90"` // 瑙掕壊ID
+ AuthorityName string `json:"authorityName" gorm:"comment:瑙掕壊鍚�"` // 瑙掕壊鍚�
Users []User `json:"-" gorm:"many2many:user_authority;"`
Menus []Menu `json:"menus" gorm:"many2many:authority_menus;"`
DefaultRouter string `json:"defaultRouter" gorm:"comment:榛樿鑿滃崟;default:dashboard"` // 榛樿鑿滃崟(榛樿dashboard)
@@ -22,7 +22,7 @@
)
func (Authority) TableName() string {
- return "sys_authorities"
+ return "authorities"
}
func NewSysAuthoritySearch() *SysAuthoritySearch {
@@ -33,8 +33,8 @@
func (slf *SysAuthoritySearch) build() *gorm.DB {
var db = slf.Orm.Model(&Authority{})
- if slf.AuthorityId != 0 {
- db = db.Where("authority_id = ?", slf.AuthorityId)
+ if slf.Id != 0 {
+ db = db.Where("id = ?", slf.Id)
}
return db
@@ -62,6 +62,11 @@
}
func (slf *SysAuthoritySearch) SetAuthorityId(id uint) *SysAuthoritySearch {
- slf.AuthorityId = id
+ slf.Id = id
return slf
}
+
+func (slf *SysAuthoritySearch) SetMenuAuthority(auth *Authority) error {
+ var db = slf.build()
+ return db.Model(auth).Association("Menus").Append(auth.Menus)
+}
--
Gitblit v1.8.0