caipin 4 years ago
parent
commit
683722fc3c
3 changed files with 6 additions and 2 deletions
  1. 4 0
      dao/bid_account_dao.go
  2. 1 1
      models/cm_tree.go
  3. 1 1
      web/api/project_setting_auth_api.go

+ 4 - 0
dao/bid_account_dao.go

@@ -9,6 +9,7 @@ package dao
 import (
 	"encoding/json"
 	"errors"
+	"log"
 
 	"github.com/go-xorm/xorm"
 	"go.mod/lib"
@@ -59,6 +60,7 @@ func (d *BidAccountDao) Create(bidsectionId int, accountData *models.CmProjectAc
 	_, err = session.Exec("UPDATE cm_tree SET `accounts` = ? where id = ?", accounts, treeId)
 	if err != nil {
 		session.Rollback()
+		log.Println(err)
 		return errors.New("更新标段成员量出错")
 	}
 
@@ -72,12 +74,14 @@ func (d *BidAccountDao) Create(bidsectionId int, accountData *models.CmProjectAc
 		bidsectionIds[0].Id = bidsectionId
 		bidsectionIdsByte, err = json.Marshal(bidsectionIds)
 		if err != nil {
+			session.Rollback()
 			return err
 		}
 	} else {
 		// 2.获得已有的标段ID
 		err := json.Unmarshal([]byte(bidsectionIdsString), &bidsectionIds)
 		if err != nil {
+			session.Rollback()
 			return err
 		}
 		bidId := lib.BidsectionIds{}

+ 1 - 1
models/cm_tree.go

@@ -15,7 +15,7 @@ type CmTree struct {
 	Isfolder               int       `xorm:"not null default 1 comment('是否文件夹 1文件夹 0其他') TINYINT(1)"`
 	BidsectionId           int       `xorm:"comment('标段ID') INT(11)"`
 	ParentId               int       `xorm:"not null default 0 comment('父级ID') INT(11)"`
-	Ancounts               int       `xorm:"not null default 0 comment('账号数') TINYINT(4)"`
+	Accounts               int       `xorm:"not null default 0 comment('账号数') TINYINT(4)"`
 	Contracts              int       `xorm:"not null default 0 comment('合同数') TINYINT(4)"`
 	ContractsIncome        string    `xorm:"not null default 0.00 comment('合同收入总金额') DECIMAL(12,2)"`
 	ContractsReturned      string    `xorm:"not null default 0.00 comment('合同已收总金额') DECIMAL(12,2)"`

+ 1 - 1
web/api/project_setting_auth_api.go

@@ -94,7 +94,7 @@ func (c *ProjectSettingApi) PostBidAccountCreate() {
 	// 创建标段和账号的关系
 	err = c.ServiceBidAccount.Create(BidAccountData, projectIdInt)
 	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": ""})
+		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 	}
 	c.Ctx.JSON(iris.Map{