作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…

…ion-cooperation into dev
正在显示 27 个修改的文件 包含 992 行增加205 行删除
... ... @@ -11,7 +11,7 @@ import (
type CreateContractUndertakerFeedbackCommand struct {
// 合约承接方反馈内容附件
FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment"`
FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment,omitempty"`
// 合约承接方反馈内容
FeedbackContent string `cname:"合约承接方反馈内容" json:"feedbackContent" valid:"Required"`
// 共创合约编号
... ...
... ... @@ -86,7 +86,7 @@ type CreateCooperationContractCommand struct {
// 共创合约名称
CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName" valid:"Required"`
// 共创模式编码
CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber,omitempty"`
CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber" valid:"Required"`
// 共创合约发起人uid
SponsorUid string `cname:"共创合约发起人uid" json:"sponsorUid,omitempty"`
// 业绩分红激励规则列表
... ... @@ -108,7 +108,14 @@ type CreateCooperationContractCommand struct {
}
func (createCooperationContractCommand *CreateCooperationContractCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
// 激励规则自定义校验
if len(createCooperationContractCommand.DividendsIncentivesRules) == 0 && len(createCooperationContractCommand.MoneyIncentivesRules) == 0 {
validation.Error("激励规则不能为空")
}
// 承接人列表校验
if len(createCooperationContractCommand.Undertakers) == 0 {
validation.Error("承接人不能为空")
}
}
func (createCooperationContractCommand *CreateCooperationContractCommand) ValidateCommand() error {
... ...
... ... @@ -42,7 +42,31 @@ type UpdateCooperationContractCommand struct {
}
func (updateCooperationContractCommand *UpdateCooperationContractCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
// 激励规则自定义校验
if len(updateCooperationContractCommand.DividendsIncentivesRules) <= 0 && len(updateCooperationContractCommand.MoneyIncentivesRules) <= 0 {
validation.Error("激励规则不能为空")
} else {
for i, _ := range updateCooperationContractCommand.DividendsIncentivesRules {
if updateCooperationContractCommand.DividendsIncentivesRules[i].DividendsIncentivesRuleId == "" {
updateCooperationContractCommand.DividendsIncentivesRules[i].DividendsIncentivesRuleId = "0"
}
}
for j, _ := range updateCooperationContractCommand.MoneyIncentivesRules {
if updateCooperationContractCommand.MoneyIncentivesRules[j].MoneyIncentivesRuleId == "" {
updateCooperationContractCommand.MoneyIncentivesRules[j].MoneyIncentivesRuleId = "0"
}
}
}
// 承接人列表校验
if len(updateCooperationContractCommand.Undertakers) <= 0 {
validation.Error("承接人不能为空")
} else {
for i, _ := range updateCooperationContractCommand.Undertakers {
if updateCooperationContractCommand.Undertakers[i].UndertakerId == "" {
updateCooperationContractCommand.Undertakers[i].UndertakerId = "0"
}
}
}
}
func (updateCooperationContractCommand *UpdateCooperationContractCommand) ValidateCommand() error {
... ...
... ... @@ -166,7 +166,6 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
referrerDomain = data
}
}
// 获取业务员
var salesmanDomain *domain.Salesman
salesmanUid, _ := strconv.ParseInt(undertaker.SalesmanId, 10, 64)
... ... @@ -179,6 +178,17 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
}
}
// 解析附件
var attachments []*domain.Attachment
for _, attachment := range undertaker.ContractAttachment {
attachments = append(attachments, &domain.Attachment{
FileType: attachment.FileType,
Name: attachment.Name,
Url: attachment.Url,
FileSize: attachment.FileSize,
})
}
undertakers = append(undertakers, &domain.Undertaker{
UndertakerId: 0,
UserId: undertakerDomain.UserId,
... ... @@ -192,9 +202,9 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
UserType: undertakerDomain.UserType,
Referrer: referrerDomain,
Salesman: salesmanDomain,
Status: 0,
Status: undertakerDomain.Status,
Company: company,
ContractAttachment: nil,
ContractAttachment: attachments,
})
}
... ... @@ -282,6 +292,12 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
if cooperationMode == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationContractCommand.CooperationModeNumber))
} else {
incentivesType := 0
if len(dividendsIncentivesRules) > 0 {
incentivesType = domain.TYPE_DIVIDNEDS_INCENTIVES
} else if len(moneyIncentivesRules) > 0 {
incentivesType = domain.TYPE_MONEY_INCENTIVES
}
newCooperationContract := &domain.CooperationContract{
CooperationContractDescription: createCooperationContractCommand.CooperationContractDescription,
CooperationContractName: createCooperationContractCommand.CooperationContractName,
... ... @@ -297,6 +313,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
Operator: operator,
DividendsIncentivesRules: dividendsIncentivesRules,
MoneyIncentivesRules: moneyIncentivesRules,
IncentivesType: int32(incentivesType),
Undertakers: undertakers,
RelevantPeople: relevantPeople,
OperateTime: time.Now(),
... ... @@ -314,7 +331,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
} else {
cooperationContractRepository = value
}
// 保存共创合约
if cooperationContract, err := cooperationContractRepository.Save(newCooperationContract); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -795,6 +812,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
Company: relevantDomain.Company,
})
}
// 更新合约相关人
cooperationContract.RelevantPeople = relevantPeople
... ...
... ... @@ -10,7 +10,7 @@ import (
type UpdateCooperationContractChangeLogCommand struct {
// 共创合约修改记录id
CooperationContractChangeLogId string `cname:"共创合约修改记录ID" json:"cooperationContractChangeLogId" valid:"Required"`
CooperationContractChangeLogId int64 `cname:"共创合约修改记录ID" json:"cooperationContractChangeLogId" valid:"Required"`
// 激励规则
IncentivesRule string `cname:"激励规则" json:"incentivesRule" valid:"Required"`
// 激励规则明细
... ...
... ... @@ -225,10 +225,27 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
defer func() {
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractChangeLogRepository = value
}
if count, cooperationContractChangeLogs, err := cooperationContractChangeLogRepository.Find(tool_funs.SimpleStructToMap(searchCooperationContractChangeLogQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": cooperationContractChangeLogs,
},
}, nil
}
return nil, nil
}
// UpdateCooperationContractChangeLog 更新共创合约变更日志
... ... @@ -259,7 +276,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationContractChangeLog == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractChangeLogCommand.CooperationContractChangeLogId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(updateCooperationContractChangeLogCommand.CooperationContractChangeLogId, 10)))
}
if err := cooperationContractChangeLog.Update(tool_funs.SimpleStructToMap(updateCooperationContractChangeLogCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ...
... ... @@ -24,6 +24,8 @@ type ConfirmMoneyIncentivesEstimateCommand struct {
UserId int64 `cname:"用户ID" json:"userId" valid:"Required"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"`
// 动作,1预算,2确定预算
Action int32 `cname:"确定金额激励分红动作" json:"action" valid:"Required"`
}
func (estimateMoneyIncentivesCommand *ConfirmMoneyIncentivesEstimateCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -14,6 +14,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
"strconv"
"time"
)
... ... @@ -373,15 +374,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
_ = transactionContext.RollbackTransaction()
}()
orderGoodIds, _ := utils.SliceAtoi(confirmDividendsIncentivesEstimateCommand.OrderGoodIds)
// 用户REST服务初始化
//var userService service.UserService
//if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//} else {
// userService = value
//}
orderGoodIds, err := utils.SliceAtoi(confirmDividendsIncentivesEstimateCommand.OrderGoodIds)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 公司REST服务初始化
var companyService service.CompanyService
... ... @@ -564,7 +560,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
Org: organization,
Company: company,
Operator: nil,
OperateTime: time.Now(),
OperateTime: time.Time{},
IsCanceled: false,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
... ... @@ -575,13 +571,12 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
}
}
var dividendsEstimatesSaved []*domain.DividendsEstimate
for _, dividendsEstimate := range dividendsEstimates {
if dividendsEstimateSaved, err := dividendsEstimateRepository.Save(dividendsEstimate); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimateSaved)
}
log.Logger.Info("新增的分红预算单", map[string]interface{}{
"dividendsEstimates": dividendsEstimates,
})
dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -721,7 +716,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
Org: organization,
Company: company,
Operator: nil,
OperateTime: time.Now(),
OperateTime: time.Time{},
IsCanceled: false,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
... ... @@ -729,17 +724,21 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
}
dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
}
var dividendsEstimatesSaved []*domain.DividendsEstimate
for _, dividendsEstimate := range dividendsEstimates {
if dividendsEstimateSaved, err := dividendsEstimateRepository.Save(dividendsEstimate); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimateSaved)
}
dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if confirmMoneyIncentivesEstimateCommand.Action == 1 { // 只预算,不入库
return dividendsEstimatesSaved, nil
} else if confirmMoneyIncentivesEstimateCommand.Action == 2 { // 确定预算
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return dividendsEstimatesSaved, nil
}
return dividendsEstimatesSaved, nil
}
}
... ...
... ... @@ -4,6 +4,11 @@ import (
"time"
)
const (
TYPE_DIVIDNEDS_INCENTIVES = iota + 1
TYPE_MONEY_INCENTIVES
)
// CooperationContract 共创项目合约实体
type CooperationContract struct {
// 共创合约ID
... ...
... ... @@ -65,6 +65,7 @@ type DividendsEstimate struct {
type DividendsEstimateRepository interface {
Save(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error)
SaveMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error)
UpdateMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error)
Remove(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error)
FindOne(queryOptions map[string]interface{}) (*DividendsEstimate, error)
... ...
... ... @@ -89,69 +89,76 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
DividendsAmount: undertakerDividendsAmount,
})
}
// 判断业务员在当前阶段是否已经分红
salesmanEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
"undertakerUid": undertaker.Salesman.UserId,
"companyId": contract.Company.CompanyId,
"orgId": contract.Org.OrgId,
})
if err != nil {
return nil, err
}
if salesmanEstimated {
return nil, fmt.Errorf("业务员 " + undertaker.Salesman.UserName + " 已分红")
} else {
undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.SalesmanPercentage / 100)
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Salesman.UserId,
UserBaseId: undertaker.Salesman.UserBaseId,
Org: undertaker.Salesman.Org,
Orgs: undertaker.Salesman.Orgs,
Department: undertaker.Salesman.Department,
Roles: undertaker.Salesman.Roles,
UserInfo: undertaker.Salesman.UserInfo,
UserType: undertaker.Salesman.UserType,
UserName: undertaker.Salesman.UserName,
UserPhone: undertaker.Salesman.UserPhone,
Company: undertaker.Salesman.Company,
},
DividendsParticipateType: domain.MONEY_INCENTIVES,
DividendsStage: stage,
DividendsAmount: undertakerDividendsAmount,
if undertaker.Salesman.UserId != 0 {
salesmanEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
"undertakerUid": undertaker.Salesman.UserId,
"companyId": contract.Company.CompanyId,
"orgId": contract.Org.OrgId,
})
if err != nil {
return nil, err
}
if salesmanEstimated {
return nil, fmt.Errorf("业务员 " + undertaker.Salesman.UserName + " 已分红")
} else {
undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.SalesmanPercentage / 100)
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Salesman.UserId,
UserBaseId: undertaker.Salesman.UserBaseId,
Org: undertaker.Salesman.Org,
Orgs: undertaker.Salesman.Orgs,
Department: undertaker.Salesman.Department,
Roles: undertaker.Salesman.Roles,
UserInfo: undertaker.Salesman.UserInfo,
UserType: undertaker.Salesman.UserType,
UserName: undertaker.Salesman.UserName,
UserPhone: undertaker.Salesman.UserPhone,
Company: undertaker.Salesman.Company,
},
DividendsParticipateType: domain.MONEY_INCENTIVES,
DividendsStage: stage,
DividendsAmount: undertakerDividendsAmount,
})
}
}
// 判断关联业务员在当前阶段是否已经分红
referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
"undertakerUid": undertaker.Referrer.UserId,
"companyId": contract.Company.CompanyId,
"orgId": contract.Org.OrgId,
})
if err != nil {
return nil, err
}
if referrerEstimated {
return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红")
} else {
undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.ReferrerPercentage / 100)
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Referrer.UserId,
UserBaseId: undertaker.Referrer.UserBaseId,
Org: undertaker.Referrer.Org,
Orgs: undertaker.Referrer.Orgs,
Department: undertaker.Referrer.Department,
Roles: undertaker.Referrer.Roles,
UserInfo: undertaker.Referrer.UserInfo,
UserType: undertaker.Referrer.UserType,
UserName: undertaker.Referrer.UserName,
UserPhone: undertaker.Referrer.UserPhone,
Company: undertaker.Referrer.Company,
},
DividendsParticipateType: domain.MONEY_INCENTIVES,
DividendsStage: stage,
DividendsAmount: undertakerDividendsAmount,
if undertaker.Referrer.UserId != 0 {
referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
"undertakerUid": undertaker.Referrer.UserId,
"companyId": contract.Company.CompanyId,
"orgId": contract.Org.OrgId,
})
if err != nil {
return nil, err
}
if referrerEstimated {
return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红")
} else {
undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.ReferrerPercentage / 100)
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Referrer.UserId,
UserBaseId: undertaker.Referrer.UserBaseId,
Org: undertaker.Referrer.Org,
Orgs: undertaker.Referrer.Orgs,
Department: undertaker.Referrer.Department,
Roles: undertaker.Referrer.Roles,
UserInfo: undertaker.Referrer.UserInfo,
UserType: undertaker.Referrer.UserType,
UserName: undertaker.Referrer.UserName,
UserPhone: undertaker.Referrer.UserPhone,
Company: undertaker.Referrer.Company,
},
DividendsParticipateType: domain.MONEY_INCENTIVES,
DividendsStage: stage,
DividendsAmount: undertakerDividendsAmount,
})
}
}
}
return dividendsEstimateDetails, nil
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationContractRelevant struct {
tableName string `comment:"共创合约相关人" pg:"cooperation_contract_relevants,alias:cooperation_contract_relevant"`
// 共创合约相关人id
CooperationContractRelevantId int64 `comment:"共创合约相关人id" pg:"pk:cooperation_contract_relevant_id"`
CooperationContractRelevantId int64 `comment:"共创合约相关人id" pg:",pk:cooperation_contract_relevant_id"`
// 共创合约编号
CooperationContractNumber string `comment:"共创合约编号"`
// 合约人userId
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationContractUndertaker struct {
tableName string `comment:"共创合约承接人" pg:"cooperation_contract_undertakers,alias:cooperation_contract_undertaker"`
// 共创合约承接人id
CooperationContractUndertakerId int64 `comment:"共创合约承接人id" pg:"pk:cooperation_contract_undertaker_id"`
CooperationContractUndertakerId int64 `comment:"共创合约承接人id" pg:",pk:cooperation_contract_undertaker_id"`
// 共创合约编号
CooperationContractNumber string `comment:"共创合约编号"`
// 共创合约承接人uid
... ...
... ... @@ -60,35 +60,39 @@ func TransformToCooperationContractDomainModelFromPgModels(
var relevantPeopleDomain []*domain.Relevant
for _, relevant := range relevantPeople {
relevantPeopleDomain = append(relevantPeopleDomain, &domain.Relevant{
UserId: relevant.UserId,
UserBaseId: relevant.UserBaseId,
Org: relevant.Org,
Orgs: relevant.Orgs,
Department: relevant.Department,
Roles: relevant.Roles,
UserInfo: relevant.UserInfo,
UserType: relevant.UserType,
Status: relevant.Status,
Company: relevant.Company,
RelevantId: relevant.CooperationContractRelevantId,
CooperationContractNumber: relevant.CooperationContractNumber,
UserId: relevant.UserId,
UserBaseId: relevant.UserBaseId,
Org: relevant.Org,
Orgs: relevant.Orgs,
Department: relevant.Department,
Roles: relevant.Roles,
UserInfo: relevant.UserInfo,
UserType: relevant.UserType,
Status: relevant.Status,
Company: relevant.Company,
})
}
// 承接人列表
var undertakersDomain []*domain.Undertaker
for _, undertaker := range undertakers {
undertakersDomain = append(undertakersDomain, &domain.Undertaker{
UserId: undertaker.UserId,
UserBaseId: undertaker.UserBaseId,
Org: undertaker.Org,
Orgs: undertaker.Orgs,
Department: undertaker.Department,
Roles: undertaker.Roles,
Referrer: undertaker.Referrer,
Salesman: undertaker.Salesman,
UserInfo: undertaker.UserInfo,
UserType: undertaker.UserType,
Status: undertaker.Status,
Company: undertaker.Company,
ContractAttachment: undertaker.ContractAttachment,
UndertakerId: undertaker.CooperationContractUndertakerId,
CooperationContractNumber: undertaker.CooperationContractNumber,
UserId: undertaker.UserId,
UserBaseId: undertaker.UserBaseId,
Org: undertaker.Org,
Orgs: undertaker.Orgs,
Department: undertaker.Department,
Roles: undertaker.Roles,
Referrer: undertaker.Referrer,
Salesman: undertaker.Salesman,
UserInfo: undertaker.UserInfo,
UserType: undertaker.UserType,
Status: undertaker.Status,
Company: undertaker.Company,
ContractAttachment: undertaker.ContractAttachment,
})
}
return &domain.CooperationContract{
... ...
... ... @@ -24,6 +24,7 @@ func (repository *CooperationContractChangeLogRepository) nextIdentify() (int64,
id, err := IdWorker.NextId()
return id, err
}
func (repository *CooperationContractChangeLogRepository) Save(cooperationContractChangeLog *domain.CooperationContractChangeLog) (*domain.CooperationContractChangeLog, error) {
sqlBuildFields := []string{
"incentives_rule",
... ... @@ -72,7 +73,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra
cooperationContractChangeLog.Company,
cooperationContractChangeLog.Operator,
cooperationContractChangeLog.UpdatedAt,
cooperationContractChangeLog.DeletedAt,
nil,
cooperationContractChangeLog.CreatedAt,
); err != nil {
return cooperationContractChangeLog, err
... ... @@ -100,7 +101,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra
cooperationContractChangeLog.Company,
cooperationContractChangeLog.Operator,
cooperationContractChangeLog.UpdatedAt,
cooperationContractChangeLog.DeletedAt,
nil,
cooperationContractChangeLog.CreatedAt,
cooperationContractChangeLog.Identify(),
); err != nil {
... ... @@ -109,6 +110,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra
}
return cooperationContractChangeLog, nil
}
func (repository *CooperationContractChangeLogRepository) Remove(cooperationContractChangeLog *domain.CooperationContractChangeLog) (*domain.CooperationContractChangeLog, error) {
tx := repository.transactionContext.PgTx
cooperationContractChangeLogModel := new(models.CooperationContractChangeLog)
... ... @@ -118,6 +120,7 @@ func (repository *CooperationContractChangeLogRepository) Remove(cooperationCont
}
return cooperationContractChangeLog, nil
}
func (repository *CooperationContractChangeLogRepository) FindOne(queryOptions map[string]interface{}) (*domain.CooperationContractChangeLog, error) {
tx := repository.transactionContext.PgTx
cooperationContractChangeLogModel := new(models.CooperationContractChangeLog)
... ... @@ -136,11 +139,18 @@ func (repository *CooperationContractChangeLogRepository) FindOne(queryOptions m
return transform.TransformToCooperationContractChangeLogDomainModelFromPgModels(cooperationContractChangeLogModel)
}
}
func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.CooperationContractChangeLog, error) {
tx := repository.transactionContext.PgTx
var cooperationContractChangeLogModels []*models.CooperationContractChangeLog
cooperationContractChangeLogs := make([]*domain.CooperationContractChangeLog, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractChangeLogModels), queryOptions)
if operationType, ok := queryOptions["operationType"]; ok && operationType.(int32) != 0 {
query.Where("operation_type = ?", operationType)
}
if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
query.Where("cooperation_contract_number ilike ?", fmt.Sprintf("%%%s%%", cooperationContractNumber))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ... @@ -162,6 +172,7 @@ func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[
return int64(count), cooperationContractChangeLogs, nil
}
}
func NewCooperationContractChangeLogRepository(transactionContext *pgTransaction.TransactionContext) (*CooperationContractChangeLogRepository, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
... ...
... ... @@ -10,6 +10,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/transform"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
"time"
)
... ... @@ -100,6 +101,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
); err != nil {
return cooperationContract, err
}
// 新增相关人
var relevantPeopleModel []*models.CooperationContractRelevant
for _, relevant := range cooperationContract.RelevantPeople {
... ... @@ -115,14 +117,18 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
UserType: relevant.UserType,
Status: relevant.Status,
Company: relevant.Company,
UpdatedAt: time.Now(),
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Time{},
CreatedAt: time.Now(),
})
}
if len(relevantPeopleModel) > 0 {
if _, err := tx.Model(&relevantPeopleModel).Insert(); err != nil {
if result, err := tx.Model(&relevantPeopleModel).Insert(); err != nil {
return nil, err
} else {
log.Logger.Info("新增的相关人", map[string]interface{}{
"relevantPeopleModel": result,
})
}
}
... ... @@ -159,6 +165,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
var dividendsIncentivesRulesModel []*models.DividendsIncentivesRule
for _, rule := range cooperationContract.DividendsIncentivesRules {
dividendsIncentivesRulesModel = append(dividendsIncentivesRulesModel, &models.DividendsIncentivesRule{
DividendsIncentivesRuleId: 0,
CooperationContractNumber: cooperationContract.CooperationContractNumber,
ReferrerPercentage: rule.ReferrerPercentage,
SalesmanPercentage: rule.SalesmanPercentage,
... ... @@ -183,6 +190,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
var moneyIncentivesRulesModel []*models.MoneyIncentivesRule
for _, rule := range cooperationContract.MoneyIncentivesRules {
moneyIncentivesRulesModel = append(moneyIncentivesRulesModel, &models.MoneyIncentivesRule{
MoneyIncentivesRuleId: 0,
CooperationContractNumber: cooperationContract.CooperationContractNumber,
MoneyIncentivesAmount: rule.MoneyIncentivesAmount,
MoneyIncentivesStage: rule.MoneyIncentivesStage,
... ... @@ -278,20 +286,21 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
var cooperationContractRelevantPeopleToAddModels []*models.CooperationContractRelevant
for _, relevantDomain := range cooperationContractRelevantPeopleToAdd {
cooperationContractRelevantPeopleToAddModels = append(cooperationContractRelevantPeopleToAddModels, &models.CooperationContractRelevant{
CooperationContractNumber: relevantDomain.CooperationContractNumber,
UserId: relevantDomain.UserId,
UserBaseId: relevantDomain.UserBaseId,
Org: relevantDomain.Org,
Orgs: relevantDomain.Orgs,
Department: relevantDomain.Department,
Roles: relevantDomain.Roles,
UserInfo: relevantDomain.UserInfo,
UserType: relevantDomain.UserType,
Status: relevantDomain.Status,
Company: relevantDomain.Company,
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Now(),
CooperationContractRelevantId: 0,
CooperationContractNumber: relevantDomain.CooperationContractNumber,
UserId: relevantDomain.UserId,
UserBaseId: relevantDomain.UserBaseId,
Org: relevantDomain.Org,
Orgs: relevantDomain.Orgs,
Department: relevantDomain.Department,
Roles: relevantDomain.Roles,
UserInfo: relevantDomain.UserInfo,
UserType: relevantDomain.UserType,
Status: relevantDomain.Status,
Company: relevantDomain.Company,
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Now(),
})
}
// 添加相关人
... ... @@ -333,8 +342,13 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
}
}
}
if _, err := tx.Model(&relevantModelsToDelete).Delete(); err != nil {
return nil, err
log.Logger.Info("待删除的相关人", map[string]interface{}{
"待删除的相关人": relevantModelsToDelete,
})
if len(relevantModelsToDelete) > 0 {
if _, err := tx.Model(&relevantModelsToDelete).Delete(); err != nil {
return nil, err
}
}
/************************* 更新承接人 ****************************/
... ... @@ -383,6 +397,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
CreatedAt: time.Now(),
})
}
log.Logger.Info("待添加的承接人", map[string]interface{}{
"待添加的承接人": cooperationContractUndertakersToAddModels,
})
// 添加承接人
if len(cooperationContractUndertakersToAddModels) > 0 {
if _, err := tx.Model(&cooperationContractUndertakersToAddModels).Insert(); err != nil {
... ... @@ -406,6 +423,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
}
}
}
log.Logger.Info("待更新的承接人", map[string]interface{}{
"待更新的承接人": undertakerModelsToUpdate,
})
if len(undertakerModelsToUpdate) > 0 {
if _, err := tx.Model(&undertakerModelsToUpdate).WherePK().Update(); err != nil {
return nil, err
... ... @@ -422,8 +442,13 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
}
}
}
if _, err := tx.Model(&undertakerModelsToDelete).Delete(); err != nil {
return nil, err
log.Logger.Info("待删除的承接人", map[string]interface{}{
"待删除的承接人": undertakerModelsToDelete,
})
if len(undertakerModelsToDelete) > 0 {
if _, err := tx.Model(&undertakerModelsToDelete).Delete(); err != nil {
return nil, err
}
}
/************************ 更新分红激励规则 **************************/
... ... @@ -471,6 +496,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
})
}
// 添加分红激励规则
log.Logger.Info("待添加的分红激励规则", map[string]interface{}{
"dividendsIncentivesRulesToAddModels": dividendsIncentivesRulesToAddModels,
})
if len(dividendsIncentivesRulesToAddModels) > 0 {
if _, err := tx.Model(&dividendsIncentivesRulesToAddModels).Insert(); err != nil {
return nil, err
... ... @@ -493,6 +521,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
}
}
}
log.Logger.Info("待更新的分红激励规则", map[string]interface{}{
"dividendsRuleModelsToUpdate": dividendsRuleModelsToUpdate,
})
if len(dividendsRuleModelsToUpdate) > 0 {
if _, err := tx.Model(&dividendsRuleModelsToUpdate).WherePK().Update(); err != nil {
return nil, err
... ... @@ -509,8 +540,11 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
}
}
}
if _, err := tx.Model(&dividendsIncentivesRuleModelsToDelete).Delete(); err != nil {
return nil, err
log.Logger.Info("待删除的分红激励规则", map[string]interface{}{})
if len(dividendsIncentivesRuleModelsToDelete) > 0 {
if _, err := tx.Model(&dividendsIncentivesRuleModelsToDelete).WherePK().Delete(); err != nil {
return nil, err
}
}
/********************** 更新金额激励规则 **************************/
... ... @@ -558,6 +592,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
})
}
// 添加金额激励规则
log.Logger.Info("待添加的金额激励规则", map[string]interface{}{
"moneyIncentivesRulesToAddModels": moneyIncentivesRulesToAddModels,
})
if len(moneyIncentivesRulesToAddModels) > 0 {
if _, err := tx.Model(&moneyIncentivesRulesToAddModels).Insert(); err != nil {
return nil, err
... ... @@ -580,6 +617,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
}
}
}
log.Logger.Info("待更新的金额激励规则", map[string]interface{}{
"moneyRuleModelsToUpdate": moneyRuleModelsToUpdate,
})
if len(moneyRuleModelsToUpdate) > 0 {
if _, err := tx.Model(&moneyRuleModelsToUpdate).WherePK().Update(); err != nil {
return nil, err
... ... @@ -596,12 +636,23 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
}
}
}
if _, err := tx.Model(&moneyIncentivesRuleModelsToDelete).Delete(); err != nil {
return nil, err
log.Logger.Info("待删除的金额激励规则", map[string]interface{}{
"moneyIncentivesRuleModelsToDelete": moneyIncentivesRuleModelsToDelete,
})
if len(moneyIncentivesRuleModelsToDelete) > 0 {
if _, err := tx.Model(&moneyIncentivesRuleModelsToDelete).WherePK().Delete(); err != nil {
return nil, err
}
}
}
return cooperationContract, nil
// 返回新增的合约
cooperationContractSaved, err := repository.FindOne(map[string]interface{}{
"cooperationContractId":cooperationContract.CooperationContractId,
})
if err != nil {
return nil, err
}
return cooperationContractSaved, nil
}
func (repository *CooperationContractRepository) UpdateOne(cooperationContract *domain.CooperationContract) (*domain.CooperationContract, error) {
... ... @@ -693,7 +744,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom
if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
return nil, err
} else {
if _, err := tx.Model(&cooperationContractUndertakerModels).Delete(); err != nil {
if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil {
return nil, err
}
}
... ... @@ -703,7 +754,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom
if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
return nil, err
} else {
if _, err := tx.Model(&cooperationContractRelevantModels).Delete(); err != nil {
if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil {
return nil, err
}
}
... ... @@ -730,8 +781,10 @@ func (repository *CooperationContractRepository) BatchRemove(cooperationContract
if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
return nil, err
} else {
if _, err := tx.Model(&dividendsIncentivesRuleModels).WherePK().Delete(); err != nil {
return nil, err
if len(dividendsIncentivesRuleModels) > 0 {
if _, err := tx.Model(&dividendsIncentivesRuleModels).WherePK().Delete(); err != nil {
return nil, err
}
}
}
// 获取金额激励规则列表
... ... @@ -740,8 +793,10 @@ func (repository *CooperationContractRepository) BatchRemove(cooperationContract
if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
return nil, err
} else {
if _, err := tx.Model(&moneyIncentivesRuleModels).WherePK().Delete(); err != nil {
return nil, err
if len(moneyIncentivesRuleModels) > 0 {
if _, err := tx.Model(&moneyIncentivesRuleModels).WherePK().Delete(); err != nil {
return nil, err
}
}
}
// 获取承接人列表
... ... @@ -750,8 +805,10 @@ func (repository *CooperationContractRepository) BatchRemove(cooperationContract
if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
return nil, err
} else {
if _, err := tx.Model(&cooperationContractUndertakerModels).Delete(); err != nil {
return nil, err
if len(cooperationContractUndertakerModels) > 0 {
if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil {
return nil, err
}
}
}
// 获取相关人列表
... ... @@ -760,8 +817,10 @@ func (repository *CooperationContractRepository) BatchRemove(cooperationContract
if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
return nil, err
} else {
if _, err := tx.Model(&cooperationContractRelevantModels).Delete(); err != nil {
return nil, err
if len(cooperationContractRelevantModels) > 0 {
if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil {
return nil, err
}
}
}
}
... ...
... ... @@ -162,6 +162,46 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
return dividendsEstimate, nil
}
func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*domain.DividendsEstimate) ([]*domain.DividendsEstimate, error) {
tx := repository.transactionContext.PgTx
var dividendsEstimateModels []*models.DividendsEstimate
for _, dividendsEstimate := range dividendsEstimates {
dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{
DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus,
DividendsAmount: dividendsEstimate.DividendsAmount,
DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber,
DividendsEstimateTime: dividendsEstimate.DividendsEstimateTime,
DividendsParticipateType: dividendsEstimate.DividendsParticipateType,
DividendsType: dividendsEstimate.DividendsType,
DividendsTypeName: dividendsEstimate.DividendsTypeName,
OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum,
CooperationContractNumber: dividendsEstimate.CooperationContractNumber,
DividendsUser: dividendsEstimate.DividendsUser,
DividendsStage: dividendsEstimate.DividendsStage,
Org: dividendsEstimate.Org,
Company: dividendsEstimate.Company,
Operator: dividendsEstimate.Operator,
OperateTime: dividendsEstimate.OperateTime,
IsCanceled: dividendsEstimate.IsCanceled,
CreatedAt: dividendsEstimate.CreatedAt,
DeletedAt: dividendsEstimate.DeletedAt,
UpdatedAt: dividendsEstimate.UpdatedAt,
})
}
if _, err := tx.Model(&dividendsEstimateModels).Insert(); err != nil {
return nil, err
}
dividendsEstimatesSaved := []*domain.DividendsEstimate{}
for _, dividendsEstimateModel := range dividendsEstimateModels {
if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil {
return dividendsEstimates, err
} else {
dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimate)
}
}
return dividendsEstimatesSaved, nil
}
func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []*domain.DividendsEstimate) ([]*domain.DividendsEstimate, error) {
tx := repository.transactionContext.PgTx
var dividendsEstimateModels []*models.DividendsEstimate
... ... @@ -192,7 +232,15 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []*
if _, err := tx.Model(&dividendsEstimateModels).WherePK().Update(); err != nil {
return nil, err
}
return dividendsEstimates, nil
dividendsEstimatesUpdated := []*domain.DividendsEstimate{}
for _, dividendsEstimateModel := range dividendsEstimateModels {
if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil {
return dividendsEstimates, err
} else {
dividendsEstimatesUpdated = append(dividendsEstimatesUpdated, dividendsEstimate)
}
}
return dividendsEstimatesUpdated, nil
}
func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain.DividendsEstimate) (*domain.DividendsEstimate, error) {
... ...
... ... @@ -118,94 +118,266 @@ func (translator *UserTranslator) ToRelevantFromRepresentation(user *UserDetail)
}
func (translator *UserTranslator) ToReferrerFromRepresentation(user *UserDetail) (*domain.Referrer, error) {
var orgs []*domain.Org
for _, org := range user.UserOrg {
orgs = append(orgs, &domain.Org{
OrgId: org.OrgID,
OrgName: org.OrgName,
Company: &domain.Company{
CompanyId: user.Company.CompanyId,
CompanyLogo: "",
CompanyName: user.Company.CompanyName,
},
})
}
var roles []*domain.Role
for _, role := range user.UserRole {
roles = append(roles, &domain.Role{
RoleId: int64(role.RoleID),
RoleName: role.RoleName,
})
}
return &domain.Referrer{
UserId: user.UserId,
UserBaseId: user.UserBaseId,
Roles: nil,
Orgs: nil,
Org: nil,
Department: nil,
Company: nil,
UserInfo: nil,
UserType: 0,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Roles: roles,
Orgs: orgs,
Org: &domain.Org{
OrgId: user.Org.OrgId,
OrgName: user.Org.OrgName,
Company: nil,
},
Department: &domain.Department{
DepartmentId: user.Department.DepartmentId,
DepartmentName: user.Department.DepartmentName,
DepartmentNumber: "",
IsOrganization: false,
},
Company: &domain.Company{
CompanyId: user.Company.CompanyId,
CompanyLogo: "",
CompanyName: user.Company.CompanyName,
},
UserInfo: nil,
UserType: user.UserType,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
}, nil
}
func (translator *UserTranslator) ToUndertakerFromRepresentation(user *UserDetail) (*domain.Undertaker, error) {
var orgs []*domain.Org
for _, org := range user.UserOrg {
orgs = append(orgs, &domain.Org{
OrgId: org.OrgID,
OrgName: org.OrgName,
Company: &domain.Company{
CompanyId: user.Company.CompanyId,
CompanyLogo: "",
CompanyName: user.Company.CompanyName,
},
})
}
var roles []*domain.Role
for _, role := range user.UserRole {
roles = append(roles, &domain.Role{
RoleId: int64(role.RoleID),
RoleName: role.RoleName,
})
}
return &domain.Undertaker{
UserId: user.UserId,
UserBaseId: user.UserBaseId,
Org: nil,
Orgs: nil,
Department: nil,
Roles: nil,
UserInfo: nil,
UserType: 0,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Status: 0,
Company: nil,
UserId: user.UserId,
UserBaseId: user.UserBaseId,
Org: &domain.Org{
OrgId: user.Org.OrgId,
OrgName: user.Org.OrgName,
Company: nil,
},
Orgs: orgs,
Department: &domain.Department{
DepartmentId: user.Department.DepartmentId,
DepartmentName: user.Department.DepartmentName,
DepartmentNumber: "",
IsOrganization: false,
},
Roles: roles,
UserInfo: &domain.UserInfo{
UserAvatar: user.UserInfo.Avatar,
UserEmail: user.UserInfo.Email,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
UserAccount: "",
},
UserType: user.UserType,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Status: user.EnableStatus,
Company: &domain.Company{
CompanyId: user.Company.CompanyId,
CompanyLogo: "",
CompanyName: user.Company.CompanyName,
},
ContractAttachment: nil,
}, nil
}
func (translator *UserTranslator) ToSalesmanFromRepresentation(user *UserDetail) (*domain.Salesman, error) {
var orgs []*domain.Org
for _, org := range user.UserOrg {
orgs = append(orgs, &domain.Org{
OrgId: org.OrgID,
OrgName: org.OrgName,
Company: &domain.Company{
CompanyId: user.Company.CompanyId,
CompanyLogo: "",
CompanyName: user.Company.CompanyName,
},
})
}
var roles []*domain.Role
for _, role := range user.UserRole {
roles = append(roles, &domain.Role{
RoleId: int64(role.RoleID),
RoleName: role.RoleName,
})
}
return &domain.Salesman{
UserId: user.UserId,
UserBaseId: user.UserBaseId,
Roles: nil,
Orgs: nil,
Org: nil,
Department: nil,
Company: nil,
UserInfo: nil,
UserType: 0,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Roles: roles,
Orgs: orgs,
Org: &domain.Org{
OrgId: user.Org.OrgId,
OrgName: user.Org.OrgName,
Company: nil,
},
Department: &domain.Department{
DepartmentId: user.Department.DepartmentId,
DepartmentName: user.Department.DepartmentName,
DepartmentNumber: "",
IsOrganization: false,
},
Company: &domain.Company{
CompanyId: user.Company.CompanyId,
CompanyLogo: "",
CompanyName: user.Company.CompanyName,
},
UserInfo: &domain.UserInfo{
UserAvatar: user.UserInfo.Avatar,
UserEmail: user.UserInfo.Email,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
UserAccount: "",
},
UserType: user.UserType,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
}, nil
}
func (translator *UserTranslator) ToOperatorFromRepresentation(user *UserDetail) (*domain.User, error) {
var orgs []*domain.Org
for _, org := range user.UserOrg {
orgs = append(orgs, &domain.Org{
OrgId: org.OrgID,
OrgName: org.OrgName,
Company: &domain.Company{
CompanyId: user.Company.CompanyId,
CompanyLogo: "",
CompanyName: user.Company.CompanyName,
},
})
}
var roles []*domain.Role
for _, role := range user.UserRole {
roles = append(roles, &domain.Role{
RoleId: int64(role.RoleID),
RoleName: role.RoleName,
})
}
return &domain.User{
UserId: user.UserId,
UserBaseId: user.UserBaseId,
Org: nil,
Orgs: nil,
Department: nil,
Roles: nil,
Org: &domain.Org{
OrgId: user.Org.OrgId,
OrgName: user.Org.OrgName,
Company: nil,
},
Orgs: orgs,
Department: &domain.Department{
DepartmentId: user.Department.DepartmentId,
DepartmentName: user.Department.DepartmentName,
DepartmentNumber: "",
IsOrganization: false,
},
Roles: roles,
UserInfo: &domain.UserInfo{
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
UserAvatar: user.UserInfo.Avatar,
},
UserType: 0,
UserType: user.UserType,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Status: 0,
Company: nil,
Status: user.EnableStatus,
Company: &domain.Company{
CompanyId: user.Company.CompanyId,
CompanyLogo: "",
CompanyName: user.Company.CompanyName,
},
}, nil
}
func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*domain.User, error) {
var orgs []*domain.Org
for _, org := range user.UserOrg {
orgs = append(orgs, &domain.Org{
OrgId: org.OrgID,
OrgName: org.OrgName,
Company: &domain.Company{
CompanyId: user.Company.CompanyId,
CompanyLogo: "",
CompanyName: user.Company.CompanyName,
},
})
}
var roles []*domain.Role
for _, role := range user.UserRole {
roles = append(roles, &domain.Role{
RoleId: int64(role.RoleID),
RoleName: role.RoleName,
})
}
return &domain.User{
UserId: user.UserId,
UserBaseId: user.UserBaseId,
Org: nil,
Orgs: nil,
Department: nil,
Roles: nil,
Org: &domain.Org{
OrgId: user.Org.OrgId,
OrgName: user.Org.OrgName,
Company: nil,
},
Orgs: orgs,
Department: &domain.Department{
DepartmentId: user.Department.DepartmentId,
DepartmentName: user.Department.DepartmentName,
DepartmentNumber: "",
IsOrganization: false,
},
Roles: roles,
UserInfo: &domain.UserInfo{
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
UserAvatar: user.UserInfo.Avatar,
},
UserType: 0,
UserType: user.UserType,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Status: 0,
Company: nil,
Status: user.EnableStatus,
Company: &domain.Company{
CompanyId: user.Company.CompanyId,
CompanyLogo: "",
CompanyName: user.Company.CompanyName,
},
}, nil
}
... ...
package controllers
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/service"
)
type CooperationContractChangeLogController struct {
BaseController
}
func (controller *CooperationContractChangeLogController) CreateCooperationContractChangeLog() {
cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil)
createCooperationContractChangeLogCommand := &command.CreateCooperationContractChangeLogCommand{}
_ = controller.Unmarshal(createCooperationContractChangeLogCommand)
header := controller.GetRequestHeader(controller.Ctx)
createCooperationContractChangeLogCommand.CompanyId = header.CompanyId
createCooperationContractChangeLogCommand.OrgId = header.OrgId
createCooperationContractChangeLogCommand.UserId = header.UserId
createCooperationContractChangeLogCommand.UserBaseId = header.UserBaseId
data, err := cooperationContractChangeLogService.CreateCooperationContractChangeLog(createCooperationContractChangeLogCommand)
controller.Response(data, err)
}
func (controller *CooperationContractChangeLogController) UpdateCooperationContractChangeLog() {
cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil)
updateCooperationContractChangeLogCommand := &command.UpdateCooperationContractChangeLogCommand{}
_ = controller.Unmarshal(updateCooperationContractChangeLogCommand)
header := controller.GetRequestHeader(controller.Ctx)
updateCooperationContractChangeLogCommand.CompanyId = header.CompanyId
updateCooperationContractChangeLogCommand.OrgId = header.OrgId
updateCooperationContractChangeLogCommand.UserId = header.UserId
updateCooperationContractChangeLogCommand.UserBaseId = header.UserBaseId
cooperationContractChangeLogId, _ := controller.GetInt64(":cooperationContractChangeLogId")
updateCooperationContractChangeLogCommand.CooperationContractChangeLogId = cooperationContractChangeLogId
data, err := cooperationContractChangeLogService.UpdateCooperationContractChangeLog(updateCooperationContractChangeLogCommand)
controller.Response(data, err)
}
func (controller *CooperationContractChangeLogController) GetCooperationContractChangeLog() {
cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil)
getCooperationContractChangeLogQuery := &query.GetCooperationContractChangeLogQuery{}
header := controller.GetRequestHeader(controller.Ctx)
getCooperationContractChangeLogQuery.CompanyId = header.CompanyId
getCooperationContractChangeLogQuery.OrgId = header.OrgId
getCooperationContractChangeLogQuery.UserId = header.UserId
getCooperationContractChangeLogQuery.UserBaseId = header.UserBaseId
cooperationContractChangeLogId, _ := controller.GetInt64(":cooperationContractChangeLogId")
getCooperationContractChangeLogQuery.CooperationContractChangeLogId = cooperationContractChangeLogId
data, err := cooperationContractChangeLogService.GetCooperationContractChangeLog(getCooperationContractChangeLogQuery)
controller.Response(data, err)
}
func (controller *CooperationContractChangeLogController) RemoveCooperationContractChangeLog() {
cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil)
removeCooperationContractChangeLogCommand := &command.RemoveCooperationContractChangeLogCommand{}
_ = controller.Unmarshal(removeCooperationContractChangeLogCommand)
header := controller.GetRequestHeader(controller.Ctx)
removeCooperationContractChangeLogCommand.CompanyId = header.CompanyId
removeCooperationContractChangeLogCommand.OrgId = header.OrgId
removeCooperationContractChangeLogCommand.UserId = header.UserId
removeCooperationContractChangeLogCommand.UserBaseId = header.UserBaseId
cooperationContractChangeLogId, _ := controller.GetInt64(":cooperationContractChangeLogId")
removeCooperationContractChangeLogCommand.CooperationContractChangeLogId = cooperationContractChangeLogId
data, err := cooperationContractChangeLogService.RemoveCooperationContractChangeLog(removeCooperationContractChangeLogCommand)
controller.Response(data, err)
}
func (controller *CooperationContractChangeLogController) ListCooperationContractChangeLog() {
cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil)
listCooperationContractChangeLogQuery := &query.ListCooperationContractChangeLogQuery{}
header := controller.GetRequestHeader(controller.Ctx)
listCooperationContractChangeLogQuery.CompanyId = header.CompanyId
listCooperationContractChangeLogQuery.OrgId = header.OrgId
listCooperationContractChangeLogQuery.UserId = header.UserId
listCooperationContractChangeLogQuery.UserBaseId = header.UserBaseId
pageSize, _ := controller.GetInt64("pageSize")
listCooperationContractChangeLogQuery.PageSize = pageSize
pageNumber, _ := controller.GetInt64("pageNumber")
listCooperationContractChangeLogQuery.PageNumber = pageNumber
data, err := cooperationContractChangeLogService.ListCooperationContractChangeLog(listCooperationContractChangeLogQuery)
controller.Response(data, err)
}
func (controller *CooperationContractChangeLogController) SearchCooperationContractChangeLog() {
cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil)
searchCooperationContractChangeLogQuery := &query.SearchCooperationContractChangeLogQuery{}
_ = controller.Unmarshal(searchCooperationContractChangeLogQuery)
header := controller.GetRequestHeader(controller.Ctx)
searchCooperationContractChangeLogQuery.CompanyId = header.CompanyId
searchCooperationContractChangeLogQuery.OrgId = header.OrgId
searchCooperationContractChangeLogQuery.UserId = header.UserId
searchCooperationContractChangeLogQuery.UserBaseId = header.UserBaseId
data, err := cooperationContractChangeLogService.SearchCooperationContractChangeLog(searchCooperationContractChangeLogQuery)
controller.Response(data, err)
}
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego/controllers"
)
func init() {
web.Router("/cooperation-contract-change-logs/", &controllers.CooperationContractChangeLogController{}, "Post:CreateCooperationContractChangeLog") // 新增共创合约变更记录(预留)
web.Router("/cooperation-contract-change-logs/:cooperationContractChangeLogId", &controllers.CooperationContractChangeLogController{}, "Put:UpdateCooperationContractChangeLog") // 编辑共创合约变更记录(预留)
web.Router("/cooperation-contract-change-logs/:cooperationContractChangeLogId", &controllers.CooperationContractChangeLogController{}, "Get:GetCooperationContractChangeLog") // 获取共创合约变更记录详情(预留)
web.Router("/cooperation-contract-change-logs/:cooperationContractChangeLogId", &controllers.CooperationContractChangeLogController{}, "Delete:RemoveCooperationContractChangeLog") // 移除共创合约变更记录(预留)
web.Router("/cooperation-contract-change-logs/", &controllers.CooperationContractChangeLogController{}, "Get:ListCooperationContractChangeLog") // 返回共创合约变更记录列表
web.Router("/cooperation-contract-change-logs/search", &controllers.CooperationContractChangeLogController{}, "Post:SearchCooperationContractChangeLog") // 查询共创合约变更记录
}
... ...
package cooperation_contract_change_log
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/beego/beego/v2/server/web"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego"
)
func TestCooperationContractChangeLog(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Beego Port CooperationContractChangeLog Correlations Test Case Suite")
}
var handler http.Handler
var server *httptest.Server
var _ = BeforeSuite(func() {
handler = web.BeeApp.Handlers
server = httptest.NewServer(handler)
})
var _ = AfterSuite(func() {
server.Close()
})
... ...
package cooperation_contract_change_log
import (
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
)
var _ = Describe("创建共创合约变更日志", func() {
Describe("提交数据创建共创合约变更日志", func() {
Context("提交正确的新共创合约变更日志数据", func() {
It("返回共创合约变更日志数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"incentivesRule": "string",
"incentivesRuleDetail": "string",
"operationType": "int32",
"undertakers": "string",
"cooperationContractNumber": "string",
"companyId": "int64",
"orgId": "int64",
"userId": "int64",
}
httpExpect.POST("/cooperation-contract-change-logs/").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("cooperationContractChangeLogId").ValueNotEqual("cooperationContractChangeLogId", BeZero())
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package cooperation_contract_change_log
import (
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
)
var _ = Describe("返回共创合约变更日志", func() {
var cooperationContractChangeLogId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&cooperationContractChangeLogId),
"INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id",
"testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("根据cooperationContractChangeLogId参数返回共创合约变更日志", func() {
Context("传入有效的cooperationContractChangeLogId", func() {
It("返回共创合约变更日志数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/cooperation-contract-change-logs/{cooperationContractChangeLogId}").
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package cooperation_contract_change_log
import (
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
)
var _ = Describe("返回共创合约变更日志列表", func() {
var cooperationContractChangeLogId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&cooperationContractChangeLogId),
"INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id",
"testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("根据参数返回共创合约变更日志列表", func() {
Context("传入有效的参数", func() {
It("返回共创合约变更日志数据列表", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/cooperation-contract-change-logs/").
WithQuery("offset", "int").
WithQuery("limit", "int").
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("count").ValueEqual("count", 1).
ContainsKey("cooperationContractChangeLogs").Value("cooperationContractChangeLogs").Array()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package cooperation_contract_change_log
import (
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
)
var _ = Describe("移除共创合约变更日志", func() {
var cooperationContractChangeLogId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&cooperationContractChangeLogId),
"INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id",
"testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("根据参数移除共创合约变更日志", func() {
Context("传入有效的cooperationContractChangeLogId", func() {
It("返回被移除共创合约变更日志的数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.DELETE("/cooperation-contract-change-logs/{cooperationContractChangeLogId}").
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package cooperation_contract_change_log
import (
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
)
var _ = Describe("共创合约变更记录搜索", func() {
var cooperationContractChangeLogId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&cooperationContractChangeLogId),
"INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id",
"testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("共创合约变更记录搜索", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"operationType": "int32",
"cooperationContractNumber": "string",
"pageSize": "int32",
"pageNumber": "int32",
"companyId": "int64",
"orgId": "int64",
"userId": "int64",
}
httpExpect.POST("/cooperation-contract-change-logs/search").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package cooperation_contract_change_log
import (
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
)
var _ = Describe("更新共创合约变更日志", func() {
var cooperationContractChangeLogId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&cooperationContractChangeLogId),
"INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id",
"testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("提交数据更新共创合约变更日志", func() {
Context("提交正确的共创合约变更日志数据", func() {
It("返回更新后的共创合约变更日志数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"incentivesRule": "string",
"incentivesRuleDetail": "string",
"operationType": "int32",
"undertakers": "string",
"cooperationContractNumber": "string",
"companyId": "int64",
"orgId": "int64",
"userId": "int64",
}
httpExpect.PUT("/cooperation-contract-change-logs/{cooperationContractChangeLogId}").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("cooperationContractChangeLogId").ValueEqual("cooperationContractChangeLogId", cooperationContractChangeLogId)
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...