|
@@ -39,20 +39,20 @@ func (Tenant) TableName() string {
|
|
|
}
|
|
|
|
|
|
func (c *Tenant) Get() error {
|
|
|
- return Db.Model(&c).Where("id = ?", c.ID).Find(&c).Error
|
|
|
+ return Db.Model(&c).Where("id = ? and is_deleted = 0", c.ID).Find(&c).Error
|
|
|
}
|
|
|
|
|
|
func (c *Tenant) GetTenant() error {
|
|
|
- return Db.Model(&c).Where("tenant_id = ?", c.TenantId).Find(&c).Error
|
|
|
+ return Db.Model(&c).Where("tenant_id = ? and is_deleted = 0", c.TenantId).Find(&c).Error
|
|
|
}
|
|
|
|
|
|
func (c *Tenant) GetTenantByPasskey() error {
|
|
|
- return Db.Model(&c).Where("pass_key = ?", c.PassKey).Find(&c).Error
|
|
|
+ return Db.Model(&c).Where("pass_key = ? and is_deleted = 0", c.PassKey).Find(&c).Error
|
|
|
}
|
|
|
|
|
|
func (c *Tenant) IsExist() bool {
|
|
|
var count int
|
|
|
- _ = Db.Model(&c).Where("pass_key = ?", c.PassKey).Count(&c).Error
|
|
|
+ _ = Db.Model(&c).Where("pass_key = ? and is_deleted = 0", c.PassKey).Count(&c).Error
|
|
|
return count > 0
|
|
|
}
|
|
|
|
|
@@ -82,11 +82,12 @@ func (c *Tenant) Update() error {
|
|
|
|
|
|
func (c *Tenant) GetAll() ([]Tenant, error) {
|
|
|
var tenants []Tenant
|
|
|
- err := Db.Model(&c).Find(&tenants).Error
|
|
|
+ err := Db.Model(&c).Where("is_deleted = 0").Find(&tenants).Error
|
|
|
return tenants, err
|
|
|
}
|
|
|
|
|
|
func (c *Tenant) Remove() error {
|
|
|
- return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
|
|
|
+ return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.
|
|
|
+ UpdateTime,
|
|
|
"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
|
|
|
}
|