正在显示
17 个修改的文件
包含
55 行增加
和
42 行删除
@@ -3,24 +3,24 @@ module gitlab.fjmaimaimai.com/mmm-go/partner | @@ -3,24 +3,24 @@ module gitlab.fjmaimaimai.com/mmm-go/partner | ||
3 | go 1.14 | 3 | go 1.14 |
4 | 4 | ||
5 | require ( | 5 | require ( |
6 | - github.com/Shopify/sarama v1.26.4 | 6 | + github.com/Shopify/sarama v1.38.1 |
7 | github.com/ajg/form v1.5.1 // indirect | 7 | github.com/ajg/form v1.5.1 // indirect |
8 | github.com/astaxie/beego v1.12.3 | 8 | github.com/astaxie/beego v1.12.3 |
9 | github.com/dgrijalva/jwt-go v3.2.0+incompatible | 9 | github.com/dgrijalva/jwt-go v3.2.0+incompatible |
10 | github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect | 10 | github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect |
11 | github.com/gavv/httpexpect v2.0.0+incompatible | 11 | github.com/gavv/httpexpect v2.0.0+incompatible |
12 | - github.com/gin-gonic/gin v1.5.0 | ||
13 | - github.com/go-pg/pg/v10 v10.0.0-beta.2 | 12 | + github.com/gin-gonic/gin v1.9.1 |
13 | + github.com/go-pg/pg/v10 v10.11.2 | ||
14 | github.com/imkira/go-interpol v1.1.0 // indirect | 14 | github.com/imkira/go-interpol v1.1.0 // indirect |
15 | github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect | 15 | github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect |
16 | github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 | 16 | github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 |
17 | github.com/moul/http2curl v1.0.0 // indirect | 17 | github.com/moul/http2curl v1.0.0 // indirect |
18 | - github.com/onsi/ginkgo v1.15.0 | ||
19 | - github.com/onsi/gomega v1.10.5 | ||
20 | - github.com/sergi/go-diff v1.1.0 // indirect | ||
21 | - github.com/shopspring/decimal v1.2.0 | 18 | + github.com/onsi/ginkgo v1.16.5 |
19 | + github.com/onsi/gomega v1.30.0 | ||
20 | + github.com/sergi/go-diff v1.3.1 // indirect | ||
21 | + github.com/shopspring/decimal v1.3.1 | ||
22 | github.com/tiptok/gocomm v1.0.5 | 22 | github.com/tiptok/gocomm v1.0.5 |
23 | - github.com/valyala/fasthttp v1.19.0 // indirect | 23 | + github.com/valyala/fasthttp v1.50.0 // indirect |
24 | github.com/xeipuuv/gojsonschema v1.2.0 // indirect | 24 | github.com/xeipuuv/gojsonschema v1.2.0 // indirect |
25 | github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect | 25 | github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect |
26 | github.com/yudai/gojsondiff v1.0.0 // indirect | 26 | github.com/yudai/gojsondiff v1.0.0 // indirect |
partner
已删除
100755 → 0
不能预览此文件类型
@@ -2,6 +2,9 @@ package domain_service | @@ -2,6 +2,9 @@ package domain_service | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "strings" | ||
6 | + "time" | ||
7 | + | ||
5 | "github.com/tiptok/gocomm/xa/eda" | 8 | "github.com/tiptok/gocomm/xa/eda" |
6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" |
7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
@@ -14,8 +17,6 @@ import ( | @@ -14,8 +17,6 @@ import ( | ||
14 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" | 17 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" |
15 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | 18 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" |
16 | protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/auth" | 19 | protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/auth" |
17 | - "strings" | ||
18 | - "time" | ||
19 | ) | 20 | ) |
20 | 21 | ||
21 | type PgLoginService struct { | 22 | type PgLoginService struct { |
@@ -182,7 +183,7 @@ func (svr *PgLoginService) PartnerLogin(phone string, password string) (err erro | @@ -182,7 +183,7 @@ func (svr *PgLoginService) PartnerLogin(phone string, password string) (err erro | ||
182 | return | 183 | return |
183 | } | 184 | } |
184 | 185 | ||
185 | -//管理层登录 | 186 | +// 管理层登录 |
186 | func (svr *PgLoginService) ManagerLogin(phone string, password string) (err error) { | 187 | func (svr *PgLoginService) ManagerLogin(phone string, password string) (err error) { |
187 | if len(svr.Users) == 0 { | 188 | if len(svr.Users) == 0 { |
188 | //子账号 | 189 | //子账号 |
@@ -198,7 +199,7 @@ func (svr *PgLoginService) ManagerLogin(phone string, password string) (err erro | @@ -198,7 +199,7 @@ func (svr *PgLoginService) ManagerLogin(phone string, password string) (err erro | ||
198 | return | 199 | return |
199 | } | 200 | } |
200 | 201 | ||
201 | -//合伙人统计信息 | 202 | +// 合伙人统计信息 |
202 | func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { | 203 | func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { |
203 | response := make(map[string]interface{}) | 204 | response := make(map[string]interface{}) |
204 | response["id"] = protocolx.AdminTypePartner | 205 | response["id"] = protocolx.AdminTypePartner |
@@ -564,7 +565,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error { | @@ -564,7 +565,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error { | ||
564 | // 用户在正常公司存在且无效或者存在非高管或者不存在、合伙人在正常公司存在且无效或者不存在、合伙人在游客公司不存在、注册合伙人到游客公司 | 565 | // 用户在正常公司存在且无效或者存在非高管或者不存在、合伙人在正常公司存在且无效或者不存在、合伙人在游客公司不存在、注册合伙人到游客公司 |
565 | if !isGuestPartner && (isUser && !isUserAvailable || isUser && !isUserSenior || !isUser) && (isPartner && !isPartnerAvailable || !isPartner) { | 566 | if !isGuestPartner && (isUser && !isUserAvailable || isUser && !isUserSenior || !isUser) && (isPartner && !isPartnerAvailable || !isPartner) { |
566 | id := time.Now().Unix() | 567 | id := time.Now().Unix() |
567 | - errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{ | 568 | + m := &models.PartnerInfo{ |
568 | Id: id, | 569 | Id: id, |
569 | CompanyId: int64(constant.DEFAULT_GUEST_COMPANY), | 570 | CompanyId: int64(constant.DEFAULT_GUEST_COMPANY), |
570 | PartnerName: phone, | 571 | PartnerName: phone, |
@@ -581,14 +582,16 @@ func (svr *PgLoginService) RegistryUser(phone string) error { | @@ -581,14 +582,16 @@ func (svr *PgLoginService) RegistryUser(phone string) error { | ||
581 | UpdateAt: time.Now(), | 582 | UpdateAt: time.Now(), |
582 | PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}}, | 583 | PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}}, |
583 | Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}}, | 584 | Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}}, |
584 | - }) | 585 | + } |
586 | + _, errPartner = svr.transactionContext.PgDd.Model(m).Insert() | ||
585 | } | 587 | } |
586 | 588 | ||
587 | // 合伙人不存在、用户存在、非高管(普通用户)-> 注册用户 | 589 | // 合伙人不存在、用户存在、非高管(普通用户)-> 注册用户 |
588 | // 合伙人不存在、用户不存在(游客)-> 注册用户 | 590 | // 合伙人不存在、用户不存在(游客)-> 注册用户 |
589 | if errPartner != nil && errUser == nil { | 591 | if errPartner != nil && errUser == nil { |
590 | id := time.Now().Unix() | 592 | id := time.Now().Unix() |
591 | - errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{ | 593 | + |
594 | + m := &models.PartnerInfo{ | ||
592 | Id: id, | 595 | Id: id, |
593 | CompanyId: int64(constant.DEFAULT_GUEST_COMPANY), | 596 | CompanyId: int64(constant.DEFAULT_GUEST_COMPANY), |
594 | PartnerName: phone, | 597 | PartnerName: phone, |
@@ -605,7 +608,8 @@ func (svr *PgLoginService) RegistryUser(phone string) error { | @@ -605,7 +608,8 @@ func (svr *PgLoginService) RegistryUser(phone string) error { | ||
605 | UpdateAt: time.Now(), | 608 | UpdateAt: time.Now(), |
606 | PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}}, | 609 | PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}}, |
607 | Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}}, | 610 | Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}}, |
608 | - }) | 611 | + } |
612 | + _, errPartner = svr.transactionContext.PgDd.Model(&m).Insert() | ||
609 | } | 613 | } |
610 | 614 | ||
611 | return errPartner | 615 | return errPartner |
@@ -688,7 +692,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { | @@ -688,7 +692,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { | ||
688 | // 注册用户 | 692 | // 注册用户 |
689 | if errUser != nil && errPartner != nil { | 693 | if errUser != nil && errPartner != nil { |
690 | id := time.Now().Unix() | 694 | id := time.Now().Unix() |
691 | - errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{ | 695 | + m := &models.PartnerInfo{ |
692 | Id: id, | 696 | Id: id, |
693 | CompanyId: int64(constant.DEFAULT_GUEST_COMPANY), | 697 | CompanyId: int64(constant.DEFAULT_GUEST_COMPANY), |
694 | PartnerName: phone, | 698 | PartnerName: phone, |
@@ -705,7 +709,8 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { | @@ -705,7 +709,8 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { | ||
705 | UpdateAt: time.Now(), | 709 | UpdateAt: time.Now(), |
706 | PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}}, | 710 | PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}}, |
707 | Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}}, | 711 | Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}}, |
708 | - }) | 712 | + } |
713 | + _, errPartner = svr.transactionContext.PgDd.Model(m).Insert() | ||
709 | } | 714 | } |
710 | 715 | ||
711 | // 删除用户 | 716 | // 删除用户 |
@@ -3,6 +3,7 @@ package pg | @@ -3,6 +3,7 @@ package pg | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | "fmt" | 5 | "fmt" |
6 | + | ||
6 | "github.com/go-pg/pg/v10" | 7 | "github.com/go-pg/pg/v10" |
7 | "github.com/go-pg/pg/v10/orm" | 8 | "github.com/go-pg/pg/v10/orm" |
8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" |
@@ -38,7 +39,7 @@ func init() { | @@ -38,7 +39,7 @@ func init() { | ||
38 | (*models.PartnerCategoryInfo)(nil), | 39 | (*models.PartnerCategoryInfo)(nil), |
39 | (*models.Users)(nil), | 40 | (*models.Users)(nil), |
40 | } { | 41 | } { |
41 | - err := DB.CreateTable(model, &orm.CreateTableOptions{ | 42 | + err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ |
42 | Temp: false, | 43 | Temp: false, |
43 | IfNotExists: true, | 44 | IfNotExists: true, |
44 | FKConstraints: true, | 45 | FKConstraints: true, |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + | ||
5 | "github.com/go-pg/pg/v10" | 6 | "github.com/go-pg/pg/v10" |
6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" |
@@ -23,12 +24,12 @@ func (repository *BusinessBonusRepository) Save(dm *domain.BusinessBonus) (*doma | @@ -23,12 +24,12 @@ func (repository *BusinessBonusRepository) Save(dm *domain.BusinessBonus) (*doma | ||
23 | return nil, err | 24 | return nil, err |
24 | } | 25 | } |
25 | if dm.Identify() == nil { | 26 | if dm.Identify() == nil { |
26 | - if err = tx.Insert(m); err != nil { | 27 | + if _, err = tx.Model(m).Returning("*").Insert(); err != nil { |
27 | return nil, err | 28 | return nil, err |
28 | } | 29 | } |
29 | return dm, nil | 30 | return dm, nil |
30 | } | 31 | } |
31 | - if err = tx.Update(m); err != nil { | 32 | + if _, err = tx.Model(m).Update(m); err != nil { |
32 | return nil, err | 33 | return nil, err |
33 | } | 34 | } |
34 | return dm, nil | 35 | return dm, nil |
@@ -22,12 +22,12 @@ func (repository *CompanyRepository) Save(dm *domain.Company) (*domain.Company, | @@ -22,12 +22,12 @@ func (repository *CompanyRepository) Save(dm *domain.Company) (*domain.Company, | ||
22 | return nil, err | 22 | return nil, err |
23 | } | 23 | } |
24 | if dm.Id == 0 { | 24 | if dm.Id == 0 { |
25 | - if err = tx.Insert(m); err != nil { | 25 | + if _, err = tx.Model(m).Returning("*").Insert(); err != nil { |
26 | return nil, err | 26 | return nil, err |
27 | } | 27 | } |
28 | return dm, nil | 28 | return dm, nil |
29 | } | 29 | } |
30 | - if err = tx.Update(m); err != nil { | 30 | + if _, err = tx.Model(m).Update(m); err != nil { |
31 | return nil, err | 31 | return nil, err |
32 | } | 32 | } |
33 | return dm, nil | 33 | return dm, nil |
@@ -21,12 +21,12 @@ func (repository *ImCustomerServiceRepository) Save(dm *domain.ImCustomerService | @@ -21,12 +21,12 @@ func (repository *ImCustomerServiceRepository) Save(dm *domain.ImCustomerService | ||
21 | return nil, err | 21 | return nil, err |
22 | } | 22 | } |
23 | if dm.Identify() == nil { | 23 | if dm.Identify() == nil { |
24 | - if err = tx.Insert(m); err != nil { | 24 | + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil { |
25 | return nil, err | 25 | return nil, err |
26 | } | 26 | } |
27 | return dm, nil | 27 | return dm, nil |
28 | } | 28 | } |
29 | - if err = tx.Update(m); err != nil { | 29 | + if _, err = tx.Model(m).Update(m); err != nil { |
30 | return nil, err | 30 | return nil, err |
31 | } | 31 | } |
32 | return dm, nil | 32 | return dm, nil |
@@ -21,12 +21,12 @@ func (repository *ImInfoRepository) Save(dm *domain.ImInfo) (*domain.ImInfo, err | @@ -21,12 +21,12 @@ func (repository *ImInfoRepository) Save(dm *domain.ImInfo) (*domain.ImInfo, err | ||
21 | return nil, err | 21 | return nil, err |
22 | } | 22 | } |
23 | if dm.Identify() == nil { | 23 | if dm.Identify() == nil { |
24 | - if err = tx.Insert(m); err != nil { | 24 | + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil { |
25 | return nil, err | 25 | return nil, err |
26 | } | 26 | } |
27 | return dm, nil | 27 | return dm, nil |
28 | } | 28 | } |
29 | - if err = tx.Update(m); err != nil { | 29 | + if _, err = tx.Model(m).Update(m); err != nil { |
30 | return nil, err | 30 | return nil, err |
31 | } | 31 | } |
32 | return dm, nil | 32 | return dm, nil |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "encoding/json" | 4 | "encoding/json" |
5 | + | ||
5 | "github.com/go-pg/pg/v10" | 6 | "github.com/go-pg/pg/v10" |
6 | "github.com/go-pg/pg/v10/orm" | 7 | "github.com/go-pg/pg/v10/orm" |
7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
@@ -28,12 +29,12 @@ func (repository *OrderBaseRepository) Save(dm *domain.OrderBase) (*domain.Order | @@ -28,12 +29,12 @@ func (repository *OrderBaseRepository) Save(dm *domain.OrderBase) (*domain.Order | ||
28 | // return dm, err | 29 | // return dm, err |
29 | //} | 30 | //} |
30 | //m.Id = dm.Id | 31 | //m.Id = dm.Id |
31 | - if err = tx.Insert(m); err != nil { | 32 | + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil { |
32 | return nil, err | 33 | return nil, err |
33 | } | 34 | } |
34 | return dm, nil | 35 | return dm, nil |
35 | } | 36 | } |
36 | - if err = tx.Update(m); err != nil { | 37 | + if _, err = tx.Model(m).Update(m); err != nil { |
37 | return nil, err | 38 | return nil, err |
38 | } | 39 | } |
39 | return dm, nil | 40 | return dm, nil |
@@ -25,12 +25,12 @@ func (repository *OrderGoodRepository) Save(dm *domain.OrderGood) (*domain.Order | @@ -25,12 +25,12 @@ func (repository *OrderGoodRepository) Save(dm *domain.OrderGood) (*domain.Order | ||
25 | // return dm, err | 25 | // return dm, err |
26 | //} | 26 | //} |
27 | //m.Id = dm.Id | 27 | //m.Id = dm.Id |
28 | - if err = tx.Insert(m); err != nil { | 28 | + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil { |
29 | return nil, err | 29 | return nil, err |
30 | } | 30 | } |
31 | return dm, nil | 31 | return dm, nil |
32 | } | 32 | } |
33 | - if err = tx.Update(m); err != nil { | 33 | + if _, err = tx.Model(m).Update(m); err != nil { |
34 | return nil, err | 34 | return nil, err |
35 | } | 35 | } |
36 | return dm, nil | 36 | return dm, nil |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + | ||
5 | "github.com/go-pg/pg/v10" | 6 | "github.com/go-pg/pg/v10" |
6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" |
@@ -23,12 +24,12 @@ func (repository *PartnerCategoryInfoRepository) Save(dm *domain.PartnerCategory | @@ -23,12 +24,12 @@ func (repository *PartnerCategoryInfoRepository) Save(dm *domain.PartnerCategory | ||
23 | return nil, err | 24 | return nil, err |
24 | } | 25 | } |
25 | if dm.Identify() == nil { | 26 | if dm.Identify() == nil { |
26 | - if err = tx.Insert(m); err != nil { | 27 | + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil { |
27 | return nil, err | 28 | return nil, err |
28 | } | 29 | } |
29 | return dm, nil | 30 | return dm, nil |
30 | } | 31 | } |
31 | - if err = tx.Update(m); err != nil { | 32 | + if _, err = tx.Model(m).Update(m); err != nil { |
32 | return nil, err | 33 | return nil, err |
33 | } | 34 | } |
34 | return dm, nil | 35 | return dm, nil |
@@ -27,12 +27,12 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) (*domain.P | @@ -27,12 +27,12 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) (*domain.P | ||
27 | // return dm, err | 27 | // return dm, err |
28 | //} | 28 | //} |
29 | //m.Id = dm.Id | 29 | //m.Id = dm.Id |
30 | - if err = tx.Insert(m); err != nil { | 30 | + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil { |
31 | return nil, err | 31 | return nil, err |
32 | } | 32 | } |
33 | return dm, nil | 33 | return dm, nil |
34 | } | 34 | } |
35 | - if err = tx.Update(m); err != nil { | 35 | + if _, err = tx.Model(m).Update(m); err != nil { |
36 | return nil, err | 36 | return nil, err |
37 | } | 37 | } |
38 | return dm, nil | 38 | return dm, nil |
@@ -25,12 +25,12 @@ func (repository *PartnerSubAccountRepository) Save(dm *domain.PartnerSubAccount | @@ -25,12 +25,12 @@ func (repository *PartnerSubAccountRepository) Save(dm *domain.PartnerSubAccount | ||
25 | return dm, err | 25 | return dm, err |
26 | } | 26 | } |
27 | m.Id = dm.Id | 27 | m.Id = dm.Id |
28 | - if err = tx.Insert(m); err != nil { | 28 | + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil { |
29 | return nil, err | 29 | return nil, err |
30 | } | 30 | } |
31 | return dm, nil | 31 | return dm, nil |
32 | } | 32 | } |
33 | - if err = tx.Update(m); err != nil { | 33 | + if _, err = tx.Model(m).Update(m); err != nil { |
34 | return nil, err | 34 | return nil, err |
35 | } | 35 | } |
36 | return dm, nil | 36 | return dm, nil |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + | ||
5 | "github.com/tiptok/gocomm/common" | 6 | "github.com/tiptok/gocomm/common" |
6 | . "github.com/tiptok/gocomm/pkg/orm/pgx" | 7 | . "github.com/tiptok/gocomm/pkg/orm/pgx" |
7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
@@ -23,12 +24,12 @@ func (repository *SysMessageConsumeRepository) Save(dm *domain.SysMessageConsume | @@ -23,12 +24,12 @@ func (repository *SysMessageConsumeRepository) Save(dm *domain.SysMessageConsume | ||
23 | return nil, err | 24 | return nil, err |
24 | } | 25 | } |
25 | if dm.Identify() == nil { | 26 | if dm.Identify() == nil { |
26 | - if err = tx.Insert(m); err != nil { | 27 | + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil { |
27 | return nil, err | 28 | return nil, err |
28 | } | 29 | } |
29 | return dm, nil | 30 | return dm, nil |
30 | } | 31 | } |
31 | - if err = tx.Update(m); err != nil { | 32 | + if _, err = tx.Model(m).Update(m); err != nil { |
32 | return nil, err | 33 | return nil, err |
33 | } | 34 | } |
34 | return dm, nil | 35 | return dm, nil |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + | ||
5 | "github.com/tiptok/gocomm/common" | 6 | "github.com/tiptok/gocomm/common" |
6 | . "github.com/tiptok/gocomm/pkg/orm/pgx" | 7 | . "github.com/tiptok/gocomm/pkg/orm/pgx" |
7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
@@ -23,7 +24,7 @@ func (repository *SysMessageProduceRepository) Save(dm *domain.SysMessageProduce | @@ -23,7 +24,7 @@ func (repository *SysMessageProduceRepository) Save(dm *domain.SysMessageProduce | ||
23 | return nil, err | 24 | return nil, err |
24 | } | 25 | } |
25 | 26 | ||
26 | - if err = tx.Insert(m); err != nil { | 27 | + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil { |
27 | return nil, err | 28 | return nil, err |
28 | } | 29 | } |
29 | return dm, nil | 30 | return dm, nil |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + | ||
5 | "github.com/go-pg/pg/v10" | 6 | "github.com/go-pg/pg/v10" |
6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" |
@@ -23,12 +24,12 @@ func (repository *UsersRepository) Save(dm *domain.Users) (*domain.Users, error) | @@ -23,12 +24,12 @@ func (repository *UsersRepository) Save(dm *domain.Users) (*domain.Users, error) | ||
23 | return nil, err | 24 | return nil, err |
24 | } | 25 | } |
25 | if dm.Identify() == nil { | 26 | if dm.Identify() == nil { |
26 | - if err = tx.Insert(m); err != nil { | 27 | + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil { |
27 | return nil, err | 28 | return nil, err |
28 | } | 29 | } |
29 | return dm, nil | 30 | return dm, nil |
30 | } | 31 | } |
31 | - if err = tx.Update(m); err != nil { | 32 | + if _, err = tx.Model(m).Update(m); err != nil { |
32 | return nil, err | 33 | return nil, err |
33 | } | 34 | } |
34 | return dm, nil | 35 | return dm, nil |
-
请 注册 或 登录 后发表评论