caipin 4 年之前
父節點
當前提交
10cc5fd66d
共有 2 個文件被更改,包括 20 次插入0 次删除
  1. 14 0
      dao/bid_account_dao.go
  2. 6 0
      services/bid_account_service.go

+ 14 - 0
dao/bid_account_dao.go

@@ -43,6 +43,20 @@ func (d *BidAccountDao) GetBidAccount(bidsectionId int, projectId int) []models.
 	}
 }
 
+//获得标段下的账号数据
+func (d *BidAccountDao) GetAccountId(projectId int, bidsectionId int, accountId int) *models.CmBidAccount {
+	data := &models.CmBidAccount{}
+	ok, err := d.engine.
+		Where("project_id=? and bidsection_id = ? and account_id= ? ", projectId, bidsectionId, accountId).
+		Get(data)
+	if ok && err == nil {
+		return data
+	} else {
+		data.Id = 0
+		return data
+	}
+}
+
 // 创建标段成员关系
 func (d *BidAccountDao) Create(bidsectionId int, accountData *models.CmProjectAccount, treeId int, projectId int) error {
 

+ 6 - 0
services/bid_account_service.go

@@ -91,6 +91,12 @@ func (s *bidAccountService) Create(viewBidAccount viewmodels.BidAccount, project
 	}
 	treeId := treeData.Id
 
+	// 4.检查账号是否已经添加过
+	bidAccountData := s.bidAccountDao.GetAccountId(projectId, bidsectionId, accountId)
+	if bidAccountData.Id != 0 {
+		return errors.New("已添加过该账号")
+	}
+
 	// 新增成员到标段
 	err = s.bidAccountDao.Create(bidsectionId, accountData, treeId, projectId)
 	if err != nil {