Explorar el Código

添加is_deleted = 0

terry hace 2 años
padre
commit
23216436d9
Se han modificado 2 ficheros con 10 adiciones y 9 borrados
  1. 7 6
      app/system/dao/tenant.go
  2. 3 3
      app/system/dao/user.go

+ 7 - 6
app/system/dao/tenant.go

@@ -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
 }

+ 3 - 3
app/system/dao/user.go

@@ -38,11 +38,11 @@ func (User) TableName() string {
 }
 
 func (c *User) GetUser() 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 *User) GetUserByPwd() error {
-	return Db.Model(&c).Where("tenant_id = ? and account = ? and password = ?", c.TenantId, c.Account,
+	return Db.Model(&c).Where("tenant_id = ? and account = ? and password = ? and is_deleted = 0", c.TenantId, c.Account,
 		c.Password).Find(&c).Error
 }
 
@@ -78,7 +78,7 @@ func (c *User) UpdatePwd(pwd string) error {
 
 func (c *User) GetAll() ([]User, error) {
 	var users []User
-	err := Db.Model(&c).Find(&users).Error
+	err := Db.Model(&c).Where("is_deleted = 0").Find(&users).Error
 	return users, err
 }