From 20ca649b9f0fa0af0361024149dee6833858c2fa Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期二, 15 八月 2023 17:12:27 +0800
Subject: [PATCH] fix
---
service/serviceFeeManage.go | 63 +++++++++++++++++++------------
1 files changed, 39 insertions(+), 24 deletions(-)
diff --git a/service/serviceFeeManage.go b/service/serviceFeeManage.go
index a52e8c6..49fa66c 100644
--- a/service/serviceFeeManage.go
+++ b/service/serviceFeeManage.go
@@ -1,41 +1,34 @@
package service
import (
+ "aps_crm/constvar"
"aps_crm/model"
"aps_crm/pkg/ecode"
+ "aps_crm/pkg/mysqlx"
)
type FeeManageService struct{}
func (FeeManageService) AddServiceFeeManage(serviceFeeManage *model.ServiceFeeManage) int {
- err := model.NewServiceFeeManageSearch(nil).Create(serviceFeeManage)
+
+ tx := mysqlx.GetDB().Begin()
+
+ err := model.NewClientSearch(tx).Create(serviceFeeManage.Client)
if err != nil {
+ tx.Rollback()
+ return ecode.ClientExist
+ }
+
+ serviceFeeManage.ClientId = serviceFeeManage.Client.Id
+ err = model.NewServiceFeeManageSearch(tx).Create(serviceFeeManage)
+ if err != nil {
+ tx.Rollback()
return ecode.ServiceFeeManageExist
}
+ tx.Commit()
+
return ecode.OK
-}
-
-func (FeeManageService) DeleteServiceFeeManage(id int) int {
- _, err := model.NewServiceFeeManageSearch(nil).SetId(id).Find()
- if err != nil {
- return ecode.ServiceFeeManageNotExist
- }
-
- err = model.NewServiceFeeManageSearch(nil).SetId(id).Delete()
- if err != nil {
- return ecode.ServiceFeeManageNotExist
- }
- return ecode.OK
-}
-
-func (FeeManageService) GetServiceFeeManageList() ([]*model.ServiceFeeManage, int) {
- list, err := model.NewServiceFeeManageSearch(nil).FindAll()
- if err != nil {
- return nil, ecode.ServiceFeeManageListErr
- }
-
- return list, ecode.OK
}
func (FeeManageService) UpdateServiceFeeManage(serviceFeeManage *model.ServiceFeeManage) int {
@@ -45,7 +38,7 @@
return ecode.ServiceFeeManageNotExist
}
- tx := model.NewContactSearch().Orm.Begin()
+ tx := mysqlx.GetDB().Begin()
err = model.NewServiceFeeManageSearch(tx).SetId(serviceFeeManage.Id).Update(serviceFeeManage)
if err != nil {
@@ -64,3 +57,25 @@
return ecode.OK
}
+
+func (FeeManageService) DeleteServiceFeeManage(ids []int) int {
+ // delete client
+ err := model.NewServiceFeeManageSearch(nil).SetIds(ids).Delete()
+ if err != nil {
+ return ecode.ServiceFeeManageDeleteErr
+ }
+ return ecode.OK
+}
+
+func (FeeManageService) GetServiceFeeManageList(page, pageSize int, queryClass constvar.ServiceFeeQueryClass, keywordType constvar.ServiceFeeKeywordType, keyword string) ([]*model.ServiceFeeManage, int64, int) {
+ // get contact list
+ contacts, total, err := model.NewServiceFeeManageSearch(nil).
+ SetQueryClass(queryClass).
+ SetKeywordType(keywordType).
+ SetKeyword(keyword).
+ SetPage(page, pageSize).FindAll()
+ if err != nil {
+ return nil, 0, ecode.ServiceFeeManageListErr
+ }
+ return contacts, total, ecode.OK
+}
--
Gitblit v1.8.0