mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 07:50:25 +08:00 
			
		
		
		
	初步完成高防相关管理对象
This commit is contained in:
		
							
								
								
									
										42
									
								
								internal/db/models/user_ad_instance_dao.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								internal/db/models/user_ad_instance_dao.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
package models
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	_ "github.com/go-sql-driver/mysql"
 | 
			
		||||
	"github.com/iwind/TeaGo/Tea"
 | 
			
		||||
	"github.com/iwind/TeaGo/dbs"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	UserADInstanceStateEnabled  = 1 // 已启用
 | 
			
		||||
	UserADInstanceStateDisabled = 0 // 已禁用
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type UserADInstanceDAO dbs.DAO
 | 
			
		||||
 | 
			
		||||
func NewUserADInstanceDAO() *UserADInstanceDAO {
 | 
			
		||||
	return dbs.NewDAO(&UserADInstanceDAO{
 | 
			
		||||
		DAOObject: dbs.DAOObject{
 | 
			
		||||
			DB:     Tea.Env,
 | 
			
		||||
			Table:  "edgeUserADInstances",
 | 
			
		||||
			Model:  new(UserADInstance),
 | 
			
		||||
			PkName: "id",
 | 
			
		||||
		},
 | 
			
		||||
	}).(*UserADInstanceDAO)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var SharedUserADInstanceDAO *UserADInstanceDAO
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	dbs.OnReady(func() {
 | 
			
		||||
		SharedUserADInstanceDAO = NewUserADInstanceDAO()
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// EnableUserADInstance 启用条目
 | 
			
		||||
func (this *UserADInstanceDAO) EnableUserADInstance(tx *dbs.Tx, id uint64) error {
 | 
			
		||||
	_, err := this.Query(tx).
 | 
			
		||||
		Pk(id).
 | 
			
		||||
		Set("state", UserADInstanceStateEnabled).
 | 
			
		||||
		Update()
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user