@@ -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
+ }
+}
+
// 创建标段成员关系
func (d *BidAccountDao) Create(bidsectionId int, accountData *models.CmProjectAccount, treeId int, projectId int) error {
@@ -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 {