...
|
...
|
@@ -8,6 +8,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/partnerInfo/command"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/partnerInfo/query"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
|
|
|
"time"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -16,7 +17,7 @@ type PartnerInfoService struct { |
|
|
}
|
|
|
|
|
|
// 创建客户价值
|
|
|
func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(command *command.CreatePartnerInfoCommand) (data interface{}, err error) {
|
|
|
func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(command *command.CreatePartnerInfoCommand) (data *domain.PartnerInfo, err error) {
|
|
|
var (
|
|
|
count int64
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
...
|
...
|
@@ -56,7 +57,7 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(command *command |
|
|
}
|
|
|
|
|
|
// 返回客户价值
|
|
|
func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(command *query.GetPartnerInfoQuery) (data interface{}, err error) {
|
|
|
func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(command *query.GetPartnerInfoQuery) (data *domain.PartnerInfo, err error) {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
)
|
...
|
...
|
@@ -75,7 +76,7 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(command *query.GetP |
|
|
if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{"transactionContext": transactionContext}); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
data, err = PartnerInfoRepository.FindOne(map[string]interface{}{"Id": command.Id})
|
|
|
data, err = PartnerInfoRepository.FindOne(utils.ObjectJsonToMap(command))
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -87,12 +88,12 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(command *query.GetP |
|
|
}
|
|
|
|
|
|
// 更新客户价值
|
|
|
func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(updatePartnerInfoCommand *command.UpdatePartnerInfoCommand) (data interface{}, err error) {
|
|
|
func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(command *command.UpdatePartnerInfoCommand) (data *domain.PartnerInfo, err error) {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
PartnerInfo *domain.PartnerInfo
|
|
|
)
|
|
|
if err = updatePartnerInfoCommand.ValidateCommand(); err != nil {
|
|
|
if err = command.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
...
|
...
|
@@ -107,12 +108,12 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(updatePartnerInf |
|
|
if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{"transactionContext": transactionContext}); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
PartnerInfo, err = PartnerInfoRepository.FindOne(map[string]interface{}{"Id": updatePartnerInfoCommand.Id})
|
|
|
PartnerInfo, err = PartnerInfoRepository.FindOne(map[string]interface{}{"Id": command.Id})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if PartnerInfo == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updatePartnerInfoCommand.Id)))
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(command.Id)))
|
|
|
}
|
|
|
//if count, PartnerInfos, err := PartnerInfoRepository.Find(map[string]interface{}{
|
|
|
// "PartnerInfoName": updatePartnerInfoCommand.PartnerInfoName,
|
...
|
...
|
@@ -124,7 +125,7 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(updatePartnerInf |
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "标签不可重复名称")
|
|
|
// }
|
|
|
//}
|
|
|
if err := PartnerInfo.Update(tool_funs.SimpleStructToMap(updatePartnerInfoCommand)); err != nil {
|
|
|
if err := PartnerInfo.Update(tool_funs.SimpleStructToMap(command)); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
...
|
...
|
@@ -136,12 +137,12 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(updatePartnerInf |
|
|
}
|
|
|
|
|
|
// 移除客户价值
|
|
|
func (PartnerInfoService *PartnerInfoService) RemovePartnerInfo(removePartnerInfoCommand *command.RemovePartnerInfoCommand) (data interface{}, err error) {
|
|
|
func (PartnerInfoService *PartnerInfoService) RemovePartnerInfo(command *command.RemovePartnerInfoCommand) (data *domain.PartnerInfo, err error) {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
PartnerInfo *domain.PartnerInfo
|
|
|
)
|
|
|
if err = removePartnerInfoCommand.ValidateCommand(); err != nil {
|
|
|
if err = command.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
if err = transactionContext.StartTransaction(); err != nil {
|
...
|
...
|
@@ -156,12 +157,12 @@ func (PartnerInfoService *PartnerInfoService) RemovePartnerInfo(removePartnerInf |
|
|
if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{"transactionContext": transactionContext}); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
PartnerInfo, err = PartnerInfoRepository.FindOne(map[string]interface{}{"Id": removePartnerInfoCommand.Id})
|
|
|
PartnerInfo, err = PartnerInfoRepository.FindOne(map[string]interface{}{"Id": command.Id})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if PartnerInfo == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removePartnerInfoCommand.Id)))
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(command.Id)))
|
|
|
}
|
|
|
if data, err = PartnerInfoRepository.Remove(PartnerInfo); err != nil {
|
|
|
return nil, err
|
...
|
...
|
@@ -171,13 +172,13 @@ func (PartnerInfoService *PartnerInfoService) RemovePartnerInfo(removePartnerInf |
|
|
}
|
|
|
|
|
|
// 返回客户价值列表
|
|
|
func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQuery *query.ListPartnerInfoQuery) (data interface{}, err error) {
|
|
|
func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(command *query.ListPartnerInfoQuery) (data interface{}, err error) {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
PartnerInfos []*domain.PartnerInfo
|
|
|
count int64
|
|
|
)
|
|
|
if err = listPartnerInfoQuery.ValidateQuery(); err != nil {
|
|
|
if err = command.ValidateQuery(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
...
|
...
|
@@ -192,7 +193,7 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue |
|
|
if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{"transactionContext": transactionContext}); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if count, PartnerInfos, err = PartnerInfoRepository.Find(tool_funs.SimpleStructToMap(listPartnerInfoQuery)); err != nil {
|
|
|
if count, PartnerInfos, err = PartnerInfoRepository.Find(tool_funs.SimpleStructToMap(command)); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if err = transactionContext.CommitTransaction(); err != nil {
|
...
|
...
|
|