houyaf 3 gadi atpakaļ
vecāks
revīzija
02344ad416
1 mainītis faili ar 9 papildinājumiem un 1 dzēšanām
  1. 9 1
      repositories/system/account_repo.go

+ 9 - 1
repositories/system/account_repo.go

@@ -125,7 +125,7 @@ func (d *AccountRepo) GetById(ocId int64, accountId int64)(*viewmodels.AccountIn
 	}
 }
 
-func (d *AccountRepo) GetList(ocId int64) ([]viewmodels.AccountInfo, error) {
+func (d *AccountRepo) GetList(m map[string]interface{}) ([]viewmodels.AccountInfo, error) {
 	sqlSelect := ` SELECT   A.oc_id,
                             B.oc_type_id,
                             B.oc_name,
@@ -149,6 +149,10 @@ func (d *AccountRepo) GetList(ocId int64) ([]viewmodels.AccountInfo, error) {
                   LEFT JOIN oc      AS B ON (A.oc_id = B.oc_id ) `
 	sqlWhere := ` WHERE A.deleted_flag = 0  `
 	
+	if ocId, ok := m["ocId"]; ok {
+		sqlWhere += " AND A.oc_id = " + fmt.Sprintf("%d", ocId)
+	}
+	
 	datalist := make([]viewmodels.AccountInfo, 0)
 	err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Asc("account_id").Find(&datalist)
 	if err != nil {
@@ -191,6 +195,7 @@ func (d *AccountRepo) Delete(m map[string]interface{}) error {
 
 func (d *AccountRepo) IsUserNameExist(ocId int64, accountName string) (bool, error) {
 	count, err := d.engine.
+		Where("oc_id = ?", ocId).
 		Where("deleted_flag = 0").
 		Where("account_name = ?", accountName).
 		Count(new(datamodels.Account))
@@ -202,6 +207,7 @@ func (d *AccountRepo) IsUserNameExist(ocId int64, accountName string) (bool, err
 
 func (d *AccountRepo) IsUserPhoneExist(ocId int64, accountPhone string)(bool, error){
 	count, err := d.engine.
+		Where("oc_id = ?", ocId).
 		Where("deleted_flag = 0").
 		Where("account_phone = ?", accountPhone).
 		Count(new(datamodels.Account))
@@ -214,6 +220,7 @@ func (d *AccountRepo) IsUserPhoneExist(ocId int64, accountPhone string)(bool, er
 
 func (d *AccountRepo) IsStaffNoExist(ocId int64, staffNo string)(bool, error){
 	count, err := d.engine.
+		Where("oc_id = ?", ocId).
 		Where("deleted_flag = 0").
 		Where("account_staff_no = ?", staffNo).
 		Count(new(datamodels.Account))
@@ -225,6 +232,7 @@ func (d *AccountRepo) IsStaffNoExist(ocId int64, staffNo string)(bool, error){
 
 func (d *AccountRepo) IsEmailExist(ocId int64, email string)(bool, error) {
 	count, err := d.engine.
+		Where("oc_id = ?", ocId).
 		Where("deleted_flag = 0").
 		Where("account_email = ?", email).
 		Count(new(datamodels.Account))