作者 陈志颖

feat:添加共创项目功能

正在显示 52 个修改的文件 包含 2669 行增加217 行删除
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  6 + "reflect"
  7 + "strings"
  8 +
  9 + "github.com/beego/beego/v2/core/validation"
  10 +)
  11 +
  12 +type CreateCooperationContractCommand struct {
  13 + // 共创合约描述
  14 + CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription" valid:"Required"`
  15 + // 共创合约编号
  16 + CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber" valid:"Required"`
  17 + // 共创项目编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001
  18 + CooperationProjectNumber string `cname:"共创项目编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001" json:"cooperationProjectNumber" valid:"Required"`
  19 + // 共创合约发起部门编码
  20 + DepartmentNumber string `cname:"共创合约发起部门编码" json:"departmentNumber" valid:"Required"`
  21 + // 共创合约承接对象,1员工,2共创用户,3公开
  22 + CooperationContractUndertakerType []int32 `cname:"共创合约承接对象,1员工,2共创用户,3公开" json:"cooperationContractUndertakerType" valid:"Required"`
  23 + // 共创合约名称
  24 + CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName" valid:"Required"`
  25 + // 共创模式编码,手动输入,唯一确定
  26 + CooperationModeNumber string `cname:"共创模式编码,手动输入,唯一确定" json:"cooperationModeNumber" valid:"Required"`
  27 + // 共创合约发起人uid
  28 + SponsorUid string `cname:"共创合约发起人uid" json:"sponsorUid,omitempty"`
  29 + // 业绩分红激励规则列表
  30 + DividendsIncentivesRules []*domain.DividendsIncentivesRule `cname:"业绩分红激励规则列表" json:"dividendsIncentivesRules,omitempty"`
  31 + // 金额激励规则列表
  32 + MoneyIncentivesRules []*domain.MoneyIncentivesRule `cname:"金额激励规则列表" json:"moneyIncentivesRules,omitempty"`
  33 + // 承接方列表
  34 + Undertakers []*domain.Undertaker `cname:"承接方列表" json:"undertakers,omitempty"`
  35 + // 相关人列表
  36 + Relevants []*domain.Relevant `cname:"相关人列表" json:"relevants,omitempty"`
  37 + // 公司ID,通过集成REST上下文获取
  38 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  39 + // 组织机构ID
  40 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  41 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  42 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  43 +}
  44 +
  45 +func (createCooperationContractCommand *CreateCooperationContractCommand) Valid(validation *validation.Validation) {
  46 + validation.SetError("CustomValid", "未实现的自定义认证")
  47 +}
  48 +
  49 +func (createCooperationContractCommand *CreateCooperationContractCommand) ValidateCommand() error {
  50 + valid := validation.Validation{}
  51 + b, err := valid.Valid(createCooperationContractCommand)
  52 + if err != nil {
  53 + return err
  54 + }
  55 + if !b {
  56 + elem := reflect.TypeOf(createCooperationContractCommand).Elem()
  57 + for _, validErr := range valid.Errors {
  58 + field, isExist := elem.FieldByName(validErr.Field)
  59 + if isExist {
  60 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  61 + } else {
  62 + return fmt.Errorf(validErr.Message)
  63 + }
  64 + }
  65 + }
  66 + return nil
  67 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type RemoveCooperationContractCommand struct {
  12 + // 共创合约ID
  13 + CooperationContractId int64 `cname:"共创合约ID" json:"cooperationContractId,string" valid:"Required"`
  14 + // 公司ID,通过集成REST上下文获取
  15 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  16 + // 组织机构ID
  17 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  18 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  19 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  20 +}
  21 +
  22 +func (removeCooperationContractCommand *RemoveCooperationContractCommand) Valid(validation *validation.Validation) {
  23 + validation.SetError("CustomValid", "未实现的自定义认证")
  24 +}
  25 +
  26 +func (removeCooperationContractCommand *RemoveCooperationContractCommand) ValidateCommand() error {
  27 + valid := validation.Validation{}
  28 + b, err := valid.Valid(removeCooperationContractCommand)
  29 + if err != nil {
  30 + return err
  31 + }
  32 + if !b {
  33 + elem := reflect.TypeOf(removeCooperationContractCommand).Elem()
  34 + for _, validErr := range valid.Errors {
  35 + field, isExist := elem.FieldByName(validErr.Field)
  36 + if isExist {
  37 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  38 + } else {
  39 + return fmt.Errorf(validErr.Message)
  40 + }
  41 + }
  42 + }
  43 + return nil
  44 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type UpdateCooperationContractCommand struct {
  12 + // 共创合约id
  13 + CooperationContractId string `cname:"共创合约id" json:"cooperationContractId" valid:"Required"`
  14 + // 共创合约描述
  15 + CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription" valid:"Required"`
  16 + // 共创合约编号
  17 + CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber" valid:"Required"`
  18 + // 共创项目编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001
  19 + CooperationProjectNumber string `cname:"共创项目编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001" json:"cooperationProjectNumber" valid:"Required"`
  20 + // 部门编码
  21 + DepartmentNumber string `cname:"部门编码" json:"departmentNumber" valid:"Required"`
  22 + // 共创合约承接对象,1员工,2共创用户,3公开
  23 + CooperationContractUndertakerType []int32 `cname:"共创合约承接对象,1员工,2共创用户,3公开" json:"cooperationContractUndertakerType" valid:"Required"`
  24 + // 共创合约名称
  25 + CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName" valid:"Required"`
  26 + // 共创模式编码,手动输入,唯一确定
  27 + CooperationModeNumber string `cname:"共创模式编码,手动输入,唯一确定" json:"cooperationModeNumber" valid:"Required"`
  28 + // 共创合约发起人uid
  29 + SponsorUid string `cname:"共创合约发起人uid" json:"sponsorUid,omitempty"`
  30 + // 公司ID,通过集成REST上下文获取
  31 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  32 + // 组织机构ID
  33 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  34 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  35 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  36 +}
  37 +
  38 +func (updateCooperationContractCommand *UpdateCooperationContractCommand) Valid(validation *validation.Validation) {
  39 + validation.SetError("CustomValid", "未实现的自定义认证")
  40 +}
  41 +
  42 +func (updateCooperationContractCommand *UpdateCooperationContractCommand) ValidateCommand() error {
  43 + valid := validation.Validation{}
  44 + b, err := valid.Valid(updateCooperationContractCommand)
  45 + if err != nil {
  46 + return err
  47 + }
  48 + if !b {
  49 + elem := reflect.TypeOf(updateCooperationContractCommand).Elem()
  50 + for _, validErr := range valid.Errors {
  51 + field, isExist := elem.FieldByName(validErr.Field)
  52 + if isExist {
  53 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  54 + } else {
  55 + return fmt.Errorf(validErr.Message)
  56 + }
  57 + }
  58 + }
  59 + return nil
  60 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type GetCooperationContractQuery struct {
  12 + // 共创合约ID
  13 + CooperationContractId int64 `cname:"共创合约ID" json:"cooperationContractId,string" valid:"Required"`
  14 + // 发起人uid
  15 + SponsorUid string `cname:"发起人uid" json:"sponsorUid,omitempty"`
  16 + // 公司ID,通过集成REST上下文获取
  17 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  18 + // 组织机构ID
  19 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  20 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  21 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  22 +}
  23 +
  24 +func (getCooperationContractQuery *GetCooperationContractQuery) Valid(validation *validation.Validation) {
  25 + validation.SetError("CustomValid", "未实现的自定义认证")
  26 +}
  27 +
  28 +func (getCooperationContractQuery *GetCooperationContractQuery) ValidateQuery() error {
  29 + valid := validation.Validation{}
  30 + b, err := valid.Valid(getCooperationContractQuery)
  31 + if err != nil {
  32 + return err
  33 + }
  34 + if !b {
  35 + elem := reflect.TypeOf(getCooperationContractQuery).Elem()
  36 + for _, validErr := range valid.Errors {
  37 + field, isExist := elem.FieldByName(validErr.Field)
  38 + if isExist {
  39 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  40 + } else {
  41 + return fmt.Errorf(validErr.Message)
  42 + }
  43 + }
  44 + }
  45 + return nil
  46 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type ListCooperationContractQuery struct {
  12 + // 查询偏离量
  13 + Offset int `cname:"查询偏离量" json:"offset" valid:"Required"`
  14 + // 查询限制
  15 + Limit int `cname:"查询限制" json:"limit" valid:"Required"`
  16 + // 公司ID,通过集成REST上下文获取
  17 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  18 + // 组织机构ID
  19 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  20 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  21 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  22 +}
  23 +
  24 +func (listCooperationContractQuery *ListCooperationContractQuery) Valid(validation *validation.Validation) {
  25 + validation.SetError("CustomValid", "未实现的自定义认证")
  26 +}
  27 +
  28 +func (listCooperationContractQuery *ListCooperationContractQuery) ValidateQuery() error {
  29 + valid := validation.Validation{}
  30 + b, err := valid.Valid(listCooperationContractQuery)
  31 + if err != nil {
  32 + return err
  33 + }
  34 + if !b {
  35 + elem := reflect.TypeOf(listCooperationContractQuery).Elem()
  36 + for _, validErr := range valid.Errors {
  37 + field, isExist := elem.FieldByName(validErr.Field)
  38 + if isExist {
  39 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  40 + } else {
  41 + return fmt.Errorf(validErr.Message)
  42 + }
  43 + }
  44 + }
  45 + return nil
  46 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type SearchCooperationContractQuery struct {
  12 + // 页面大小
  13 + PageSize int32 `cname:"页面大小" json:"pageSize" valid:"Required"`
  14 + // 页面大小
  15 + PageNumber int32 `cname:"页面大小" json:"pageNumber" valid:"Required"`
  16 + // 共创合约编号
  17 + CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber" valid:"Required"`
  18 + // 发起人姓名
  19 + SponsorName string `cname:"发起人姓名" json:"sponsorName,omitempty"`
  20 + // 公司ID,通过集成REST上下文获取
  21 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  22 + // 组织机构ID
  23 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  24 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  25 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  26 +}
  27 +
  28 +func (searchCooperationContractQuery *SearchCooperationContractQuery) Valid(validation *validation.Validation) {
  29 + validation.SetError("CustomValid", "未实现的自定义认证")
  30 +}
  31 +
  32 +func (searchCooperationContractQuery *SearchCooperationContractQuery) ValidateQuery() error {
  33 + valid := validation.Validation{}
  34 + b, err := valid.Valid(searchCooperationContractQuery)
  35 + if err != nil {
  36 + return err
  37 + }
  38 + if !b {
  39 + elem := reflect.TypeOf(searchCooperationContractQuery).Elem()
  40 + for _, validErr := range valid.Errors {
  41 + field, isExist := elem.FieldByName(validErr.Field)
  42 + if isExist {
  43 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  44 + } else {
  45 + return fmt.Errorf(validErr.Message)
  46 + }
  47 + }
  48 + }
  49 + return nil
  50 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type SearchCooperationContractByUndertakerQuery struct {
  12 + // 共创合约名称
  13 + CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName,omitempty"`
  14 + // 项目发起人姓名
  15 + SponsorName string `cname:"项目发起人姓名" json:"sponsorName,omitempty"`
  16 + // 公司ID,通过集成REST上下文获取
  17 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  18 + // 组织机构ID
  19 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  20 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  21 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  22 +}
  23 +
  24 +func (searchCooperationContractByUndertakerQuery *SearchCooperationContractByUndertakerQuery) Valid(validation *validation.Validation) {
  25 + validation.SetError("CustomValid", "未实现的自定义认证")
  26 +}
  27 +
  28 +func (searchCooperationContractByUndertakerQuery *SearchCooperationContractByUndertakerQuery) ValidateQuery() error {
  29 + valid := validation.Validation{}
  30 + b, err := valid.Valid(searchCooperationContractByUndertakerQuery)
  31 + if err != nil {
  32 + return err
  33 + }
  34 + if !b {
  35 + elem := reflect.TypeOf(searchCooperationContractByUndertakerQuery).Elem()
  36 + for _, validErr := range valid.Errors {
  37 + field, isExist := elem.FieldByName(validErr.Field)
  38 + if isExist {
  39 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  40 + } else {
  41 + return fmt.Errorf(validErr.Message)
  42 + }
  43 + }
  44 + }
  45 + return nil
  46 +}
  1 +package service
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/linmadan/egglib-go/core/application"
  6 + "github.com/linmadan/egglib-go/utils/tool_funs"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/query"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 +)
  12 +
  13 +// 共创合约服务
  14 +type CooperationContractService struct {
  15 +}
  16 +
  17 +// 创建共创合约服务
  18 +func (cooperationContractService *CooperationContractService) CreateCooperationContract(createCooperationContractCommand *command.CreateCooperationContractCommand) (interface{}, error) {
  19 + if err := createCooperationContractCommand.ValidateCommand(); err != nil {
  20 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  21 + }
  22 + transactionContext, err := factory.CreateTransactionContext(nil)
  23 + if err != nil {
  24 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  25 + }
  26 + if err := transactionContext.StartTransaction(); err != nil {
  27 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  28 + }
  29 + defer func() {
  30 + transactionContext.RollbackTransaction()
  31 + }()
  32 + newCooperationContract := &domain.CooperationContract{
  33 + CooperationContractDescription: createCooperationContractCommand.CooperationContractDescription,
  34 + CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber,
  35 + CooperationProjectNumber: createCooperationContractCommand.CooperationProjectNumber,
  36 + DepartmentNumber: createCooperationContractCommand.DepartmentNumber,
  37 + CooperationContractUndertakerType: createCooperationContractCommand.CooperationContractUndertakerType,
  38 + CooperationContractName: createCooperationContractCommand.CooperationContractName,
  39 + CooperationModeNumber: createCooperationContractCommand.CooperationModeNumber,
  40 + SponsorUid: createCooperationContractCommand.SponsorUid,
  41 + DividendsIncentivesRules: createCooperationContractCommand.DividendsIncentivesRules,
  42 + MoneyIncentivesRules: createCooperationContractCommand.MoneyIncentivesRules,
  43 + Undertakers: createCooperationContractCommand.Undertakers,
  44 + Relevants: createCooperationContractCommand.Relevants,
  45 + CompanyId: createCooperationContractCommand.CompanyId,
  46 + OrgId: createCooperationContractCommand.OrgId,
  47 + UserId: createCooperationContractCommand.UserId,
  48 + }
  49 + var cooperationContractRepository domain.CooperationContractRepository
  50 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  51 + "transactionContext": transactionContext,
  52 + }); err != nil {
  53 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  54 + } else {
  55 + cooperationContractRepository = value
  56 + }
  57 + if cooperationContract, err := cooperationContractRepository.Save(newCooperationContract); err != nil {
  58 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  59 + } else {
  60 + if err := transactionContext.CommitTransaction(); err != nil {
  61 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  62 + }
  63 + return cooperationContract, nil
  64 + }
  65 +}
  66 +
  67 +// 返回共创合约服务
  68 +func (cooperationContractService *CooperationContractService) GetCooperationContract(getCooperationContractQuery *query.GetCooperationContractQuery) (interface{}, error) {
  69 + if err := getCooperationContractQuery.ValidateQuery(); err != nil {
  70 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  71 + }
  72 + transactionContext, err := factory.CreateTransactionContext(nil)
  73 + if err != nil {
  74 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  75 + }
  76 + if err := transactionContext.StartTransaction(); err != nil {
  77 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  78 + }
  79 + defer func() {
  80 + transactionContext.RollbackTransaction()
  81 + }()
  82 + var cooperationContractRepository domain.CooperationContractRepository
  83 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  84 + "transactionContext": transactionContext,
  85 + }); err != nil {
  86 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  87 + } else {
  88 + cooperationContractRepository = value
  89 + }
  90 + cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": getCooperationContractQuery.CooperationContractId})
  91 + if err != nil {
  92 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  93 + }
  94 + if cooperationContract == nil {
  95 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCooperationContractQuery.CooperationContractId)))
  96 + } else {
  97 + if err := transactionContext.CommitTransaction(); err != nil {
  98 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  99 + }
  100 + return cooperationContract, nil
  101 + }
  102 +}
  103 +
  104 +// 返回共创合约服务列表
  105 +func (cooperationContractService *CooperationContractService) ListCooperationContract(listCooperationContractQuery *query.ListCooperationContractQuery) (interface{}, error) {
  106 + if err := listCooperationContractQuery.ValidateQuery(); err != nil {
  107 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  108 + }
  109 + transactionContext, err := factory.CreateTransactionContext(nil)
  110 + if err != nil {
  111 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  112 + }
  113 + if err := transactionContext.StartTransaction(); err != nil {
  114 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  115 + }
  116 + defer func() {
  117 + transactionContext.RollbackTransaction()
  118 + }()
  119 + var cooperationContractRepository domain.CooperationContractRepository
  120 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  121 + "transactionContext": transactionContext,
  122 + }); err != nil {
  123 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  124 + } else {
  125 + cooperationContractRepository = value
  126 + }
  127 + if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(listCooperationContractQuery)); err != nil {
  128 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  129 + } else {
  130 + if err := transactionContext.CommitTransaction(); err != nil {
  131 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  132 + }
  133 + return map[string]interface{}{
  134 + "count": count,
  135 + "cooperationContracts": cooperationContracts,
  136 + }, nil
  137 + }
  138 +}
  139 +
  140 +// 移除共创合约服务
  141 +func (cooperationContractService *CooperationContractService) RemoveCooperationContract(removeCooperationContractCommand *command.RemoveCooperationContractCommand) (interface{}, error) {
  142 + if err := removeCooperationContractCommand.ValidateCommand(); err != nil {
  143 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  144 + }
  145 + transactionContext, err := factory.CreateTransactionContext(nil)
  146 + if err != nil {
  147 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  148 + }
  149 + if err := transactionContext.StartTransaction(); err != nil {
  150 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  151 + }
  152 + defer func() {
  153 + transactionContext.RollbackTransaction()
  154 + }()
  155 + var cooperationContractRepository domain.CooperationContractRepository
  156 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  157 + "transactionContext": transactionContext,
  158 + }); err != nil {
  159 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  160 + } else {
  161 + cooperationContractRepository = value
  162 + }
  163 + cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": removeCooperationContractCommand.CooperationContractId})
  164 + if err != nil {
  165 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  166 + }
  167 + if cooperationContract == nil {
  168 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCooperationContractCommand.CooperationContractId)))
  169 + }
  170 + if cooperationContract, err := cooperationContractRepository.Remove(cooperationContract); err != nil {
  171 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  172 + } else {
  173 + if err := transactionContext.CommitTransaction(); err != nil {
  174 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  175 + }
  176 + return cooperationContract, nil
  177 + }
  178 +}
  179 +
  180 +// 查询共创合约
  181 +func (cooperationContractService *CooperationContractService) SearchCooperationContract(searchCooperationContractQuery *query.SearchCooperationContractQuery) (interface{}, error) {
  182 + if err := searchCooperationContractQuery.ValidateQuery(); err != nil {
  183 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  184 + }
  185 + transactionContext, err := factory.CreateTransactionContext(nil)
  186 + if err != nil {
  187 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  188 + }
  189 + if err := transactionContext.StartTransaction(); err != nil {
  190 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  191 + }
  192 + defer func() {
  193 + transactionContext.RollbackTransaction()
  194 + }()
  195 + if err := transactionContext.CommitTransaction(); err != nil {
  196 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  197 + }
  198 + return nil, nil
  199 +}
  200 +
  201 +// 根据承接人返回共创项目合约
  202 +func (cooperationContractService *CooperationContractService) SearchCooperationContractByUndertaker(searchCooperationContractByUndertakerQuery *query.SearchCooperationContractByUndertakerQuery) (interface{}, error) {
  203 + if err := searchCooperationContractByUndertakerQuery.ValidateQuery(); err != nil {
  204 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  205 + }
  206 + transactionContext, err := factory.CreateTransactionContext(nil)
  207 + if err != nil {
  208 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  209 + }
  210 + if err := transactionContext.StartTransaction(); err != nil {
  211 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  212 + }
  213 + defer func() {
  214 + transactionContext.RollbackTransaction()
  215 + }()
  216 + if err := transactionContext.CommitTransaction(); err != nil {
  217 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  218 + }
  219 + return nil, nil
  220 +}
  221 +
  222 +// 更新共创合约服务
  223 +func (cooperationContractService *CooperationContractService) UpdateCooperationContract(updateCooperationContractCommand *command.UpdateCooperationContractCommand) (interface{}, error) {
  224 + if err := updateCooperationContractCommand.ValidateCommand(); err != nil {
  225 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  226 + }
  227 + transactionContext, err := factory.CreateTransactionContext(nil)
  228 + if err != nil {
  229 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  230 + }
  231 + if err := transactionContext.StartTransaction(); err != nil {
  232 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  233 + }
  234 + defer func() {
  235 + transactionContext.RollbackTransaction()
  236 + }()
  237 + var cooperationContractRepository domain.CooperationContractRepository
  238 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  239 + "transactionContext": transactionContext,
  240 + }); err != nil {
  241 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  242 + } else {
  243 + cooperationContractRepository = value
  244 + }
  245 + cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": updateCooperationContractCommand.CooperationContractId})
  246 + if err != nil {
  247 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  248 + }
  249 + if cooperationContract == nil {
  250 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractCommand.CooperationContractId)))
  251 + }
  252 + if err := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err != nil {
  253 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  254 + }
  255 + if cooperationContract, err := cooperationContractRepository.Save(cooperationContract); err != nil {
  256 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  257 + } else {
  258 + if err := transactionContext.CommitTransaction(); err != nil {
  259 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  260 + }
  261 + return cooperationContract, nil
  262 + }
  263 +}
  264 +
  265 +func NewCooperationContractService(options map[string]interface{}) *CooperationContractService {
  266 + newCooperationContractService := &CooperationContractService{}
  267 + return newCooperationContractService
  268 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type CreateCooperationContractChangeLogCommand struct {
  12 + // 激励规则
  13 + IncentivesRule string `cname:"激励规则" json:"incentivesRule" valid:"Required"`
  14 + // 激励规则明细
  15 + IncentivesRuleDetail string `cname:"激励规则明细" json:"incentivesRuleDetail" valid:"Required"`
  16 + // 合约变更操作类型,1编辑、2暂停、3恢复
  17 + OperationType int32 `cname:"合约变更操作类型,1编辑、2暂停、3恢复" json:"operationType" valid:"Required"`
  18 + // 承接人
  19 + Undertakers string `cname:"承接人" json:"undertakers" valid:"Required"`
  20 + // 共创合约编号
  21 + CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber" valid:"Required"`
  22 + // 公司ID,通过集成REST上下文获取
  23 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  24 + // 组织机构ID
  25 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  26 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  27 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  28 +}
  29 +
  30 +func (createCooperationContractChangeLogCommand *CreateCooperationContractChangeLogCommand) Valid(validation *validation.Validation) {
  31 + validation.SetError("CustomValid", "未实现的自定义认证")
  32 +}
  33 +
  34 +func (createCooperationContractChangeLogCommand *CreateCooperationContractChangeLogCommand) ValidateCommand() error {
  35 + valid := validation.Validation{}
  36 + b, err := valid.Valid(createCooperationContractChangeLogCommand)
  37 + if err != nil {
  38 + return err
  39 + }
  40 + if !b {
  41 + elem := reflect.TypeOf(createCooperationContractChangeLogCommand).Elem()
  42 + for _, validErr := range valid.Errors {
  43 + field, isExist := elem.FieldByName(validErr.Field)
  44 + if isExist {
  45 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  46 + } else {
  47 + return fmt.Errorf(validErr.Message)
  48 + }
  49 + }
  50 + }
  51 + return nil
  52 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type RemoveCooperationContractChangeLogCommand struct {
  12 + // 合约变更记录ID
  13 + CooperationContractChangeLogId int64 `cname:"合约变更记录ID" json:"cooperationContractChangeLogId,string" valid:"Required"`
  14 + // 公司ID,通过集成REST上下文获取
  15 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  16 + // 组织机构ID
  17 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  18 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  19 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  20 +}
  21 +
  22 +func (removeCooperationContractChangeLogCommand *RemoveCooperationContractChangeLogCommand) Valid(validation *validation.Validation) {
  23 + validation.SetError("CustomValid", "未实现的自定义认证")
  24 +}
  25 +
  26 +func (removeCooperationContractChangeLogCommand *RemoveCooperationContractChangeLogCommand) ValidateCommand() error {
  27 + valid := validation.Validation{}
  28 + b, err := valid.Valid(removeCooperationContractChangeLogCommand)
  29 + if err != nil {
  30 + return err
  31 + }
  32 + if !b {
  33 + elem := reflect.TypeOf(removeCooperationContractChangeLogCommand).Elem()
  34 + for _, validErr := range valid.Errors {
  35 + field, isExist := elem.FieldByName(validErr.Field)
  36 + if isExist {
  37 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  38 + } else {
  39 + return fmt.Errorf(validErr.Message)
  40 + }
  41 + }
  42 + }
  43 + return nil
  44 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type UpdateCooperationContractChangeLogCommand struct {
  12 + // 共创合约修改记录id
  13 + CooperationContractChangeLogId string `cname:"共创合约修改记录id" json:"cooperationContractChangeLogId" valid:"Required"`
  14 + // 激励规则
  15 + IncentivesRule string `cname:"激励规则" json:"incentivesRule" valid:"Required"`
  16 + // 激励规则明细
  17 + IncentivesRuleDetail string `cname:"激励规则明细" json:"incentivesRuleDetail" valid:"Required"`
  18 + // 合约变更操作类型,1编辑、2暂停、3恢复
  19 + OperationType int32 `cname:"合约变更操作类型,1编辑、2暂停、3恢复" json:"operationType" valid:"Required"`
  20 + // 承接人
  21 + Undertakers string `cname:"承接人" json:"undertakers" valid:"Required"`
  22 + // 共创合约编号
  23 + CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber" valid:"Required"`
  24 + // 公司ID,通过集成REST上下文获取
  25 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  26 + // 组织机构ID
  27 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  28 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  29 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  30 +}
  31 +
  32 +func (updateCooperationContractChangeLogCommand *UpdateCooperationContractChangeLogCommand) Valid(validation *validation.Validation) {
  33 + validation.SetError("CustomValid", "未实现的自定义认证")
  34 +}
  35 +
  36 +func (updateCooperationContractChangeLogCommand *UpdateCooperationContractChangeLogCommand) ValidateCommand() error {
  37 + valid := validation.Validation{}
  38 + b, err := valid.Valid(updateCooperationContractChangeLogCommand)
  39 + if err != nil {
  40 + return err
  41 + }
  42 + if !b {
  43 + elem := reflect.TypeOf(updateCooperationContractChangeLogCommand).Elem()
  44 + for _, validErr := range valid.Errors {
  45 + field, isExist := elem.FieldByName(validErr.Field)
  46 + if isExist {
  47 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  48 + } else {
  49 + return fmt.Errorf(validErr.Message)
  50 + }
  51 + }
  52 + }
  53 + return nil
  54 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type GetCooperationContractChangeLogQuery struct {
  12 + // 合约变更记录ID
  13 + CooperationContractChangeLogId int64 `cname:"合约变更记录ID" json:"cooperationContractChangeLogId,string" valid:"Required"`
  14 + // 公司ID,通过集成REST上下文获取
  15 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  16 + // 组织机构ID
  17 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  18 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  19 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  20 +}
  21 +
  22 +func (getCooperationContractChangeLogQuery *GetCooperationContractChangeLogQuery) Valid(validation *validation.Validation) {
  23 + validation.SetError("CustomValid", "未实现的自定义认证")
  24 +}
  25 +
  26 +func (getCooperationContractChangeLogQuery *GetCooperationContractChangeLogQuery) ValidateQuery() error {
  27 + valid := validation.Validation{}
  28 + b, err := valid.Valid(getCooperationContractChangeLogQuery)
  29 + if err != nil {
  30 + return err
  31 + }
  32 + if !b {
  33 + elem := reflect.TypeOf(getCooperationContractChangeLogQuery).Elem()
  34 + for _, validErr := range valid.Errors {
  35 + field, isExist := elem.FieldByName(validErr.Field)
  36 + if isExist {
  37 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  38 + } else {
  39 + return fmt.Errorf(validErr.Message)
  40 + }
  41 + }
  42 + }
  43 + return nil
  44 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type ListCooperationContractChangeLogQuery struct {
  12 + // 查询偏离量
  13 + Offset int `cname:"查询偏离量" json:"offset" valid:"Required"`
  14 + // 查询限制
  15 + Limit int `cname:"查询限制" json:"limit" valid:"Required"`
  16 + // 公司ID,通过集成REST上下文获取
  17 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  18 + // 组织机构ID
  19 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  20 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  21 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  22 +}
  23 +
  24 +func (listCooperationContractChangeLogQuery *ListCooperationContractChangeLogQuery) Valid(validation *validation.Validation) {
  25 + validation.SetError("CustomValid", "未实现的自定义认证")
  26 +}
  27 +
  28 +func (listCooperationContractChangeLogQuery *ListCooperationContractChangeLogQuery) ValidateQuery() error {
  29 + valid := validation.Validation{}
  30 + b, err := valid.Valid(listCooperationContractChangeLogQuery)
  31 + if err != nil {
  32 + return err
  33 + }
  34 + if !b {
  35 + elem := reflect.TypeOf(listCooperationContractChangeLogQuery).Elem()
  36 + for _, validErr := range valid.Errors {
  37 + field, isExist := elem.FieldByName(validErr.Field)
  38 + if isExist {
  39 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  40 + } else {
  41 + return fmt.Errorf(validErr.Message)
  42 + }
  43 + }
  44 + }
  45 + return nil
  46 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type SearchCooperationContractChangeLogQuery struct {
  12 + // 合约变更操作类型,1编辑、2暂停、3恢复
  13 + OperationType int32 `cname:"合约变更操作类型,1编辑、2暂停、3恢复" json:"operationType,omitempty"`
  14 + // 共创合约编号
  15 + CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber,omitempty"`
  16 + // 页面大小
  17 + PageSize int32 `cname:"页面大小" json:"pageSize,omitempty"`
  18 + // 页面大小
  19 + PageNumber int32 `cname:"页面大小" json:"pageNumber,omitempty"`
  20 + // 公司ID,通过集成REST上下文获取
  21 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  22 + // 组织机构ID
  23 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  24 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  25 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  26 +}
  27 +
  28 +func (searchCooperationContractChangeLogQuery *SearchCooperationContractChangeLogQuery) Valid(validation *validation.Validation) {
  29 + validation.SetError("CustomValid", "未实现的自定义认证")
  30 +}
  31 +
  32 +func (searchCooperationContractChangeLogQuery *SearchCooperationContractChangeLogQuery) ValidateQuery() error {
  33 + valid := validation.Validation{}
  34 + b, err := valid.Valid(searchCooperationContractChangeLogQuery)
  35 + if err != nil {
  36 + return err
  37 + }
  38 + if !b {
  39 + elem := reflect.TypeOf(searchCooperationContractChangeLogQuery).Elem()
  40 + for _, validErr := range valid.Errors {
  41 + field, isExist := elem.FieldByName(validErr.Field)
  42 + if isExist {
  43 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  44 + } else {
  45 + return fmt.Errorf(validErr.Message)
  46 + }
  47 + }
  48 + }
  49 + return nil
  50 +}
  1 +package service
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/linmadan/egglib-go/core/application"
  6 + "github.com/linmadan/egglib-go/utils/tool_funs"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/command"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/query"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 +)
  12 +
  13 +// 共创合约变更日志
  14 +type CooperationContractChangeLogService struct {
  15 +}
  16 +
  17 +// 创建共创合约变更日志
  18 +func (cooperationContractChangeLogService *CooperationContractChangeLogService) CreateCooperationContractChangeLog(createCooperationContractChangeLogCommand *command.CreateCooperationContractChangeLogCommand) (interface{}, error) {
  19 + if err := createCooperationContractChangeLogCommand.ValidateCommand(); err != nil {
  20 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  21 + }
  22 + transactionContext, err := factory.CreateTransactionContext(nil)
  23 + if err != nil {
  24 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  25 + }
  26 + if err := transactionContext.StartTransaction(); err != nil {
  27 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  28 + }
  29 + defer func() {
  30 + transactionContext.RollbackTransaction()
  31 + }()
  32 + newCooperationContractChangeLog := &domain.CooperationContractChangeLog{
  33 + IncentivesRule: createCooperationContractChangeLogCommand.IncentivesRule,
  34 + IncentivesRuleDetail: createCooperationContractChangeLogCommand.IncentivesRuleDetail,
  35 + OperationType: createCooperationContractChangeLogCommand.OperationType,
  36 + Undertakers: createCooperationContractChangeLogCommand.Undertakers,
  37 + CooperationContractNumber: createCooperationContractChangeLogCommand.CooperationContractNumber,
  38 + //CompanyId: createCooperationContractChangeLogCommand.CompanyId,
  39 + //OrgId: createCooperationContractChangeLogCommand.OrgId,
  40 + //UserId: createCooperationContractChangeLogCommand.UserId,
  41 + }
  42 + var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
  43 + if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
  44 + "transactionContext": transactionContext,
  45 + }); err != nil {
  46 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  47 + } else {
  48 + cooperationContractChangeLogRepository = value
  49 + }
  50 + if cooperationContractChangeLog, err := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err != nil {
  51 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  52 + } else {
  53 + if err := transactionContext.CommitTransaction(); err != nil {
  54 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  55 + }
  56 + return cooperationContractChangeLog, nil
  57 + }
  58 +}
  59 +
  60 +// 返回共创合约变更日志
  61 +func (cooperationContractChangeLogService *CooperationContractChangeLogService) GetCooperationContractChangeLog(getCooperationContractChangeLogQuery *query.GetCooperationContractChangeLogQuery) (interface{}, error) {
  62 + if err := getCooperationContractChangeLogQuery.ValidateQuery(); err != nil {
  63 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  64 + }
  65 + transactionContext, err := factory.CreateTransactionContext(nil)
  66 + if err != nil {
  67 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  68 + }
  69 + if err := transactionContext.StartTransaction(); err != nil {
  70 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  71 + }
  72 + defer func() {
  73 + transactionContext.RollbackTransaction()
  74 + }()
  75 + var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
  76 + if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
  77 + "transactionContext": transactionContext,
  78 + }); err != nil {
  79 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  80 + } else {
  81 + cooperationContractChangeLogRepository = value
  82 + }
  83 + cooperationContractChangeLog, err := cooperationContractChangeLogRepository.FindOne(map[string]interface{}{"cooperationContractChangeLogId": getCooperationContractChangeLogQuery.CooperationContractChangeLogId})
  84 + if err != nil {
  85 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  86 + }
  87 + if cooperationContractChangeLog == nil {
  88 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCooperationContractChangeLogQuery.CooperationContractChangeLogId)))
  89 + } else {
  90 + if err := transactionContext.CommitTransaction(); err != nil {
  91 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  92 + }
  93 + return cooperationContractChangeLog, nil
  94 + }
  95 +}
  96 +
  97 +// 返回共创合约变更日志列表
  98 +func (cooperationContractChangeLogService *CooperationContractChangeLogService) ListCooperationContractChangeLog(listCooperationContractChangeLogQuery *query.ListCooperationContractChangeLogQuery) (interface{}, error) {
  99 + if err := listCooperationContractChangeLogQuery.ValidateQuery(); err != nil {
  100 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  101 + }
  102 + transactionContext, err := factory.CreateTransactionContext(nil)
  103 + if err != nil {
  104 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  105 + }
  106 + if err := transactionContext.StartTransaction(); err != nil {
  107 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  108 + }
  109 + defer func() {
  110 + transactionContext.RollbackTransaction()
  111 + }()
  112 + var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
  113 + if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
  114 + "transactionContext": transactionContext,
  115 + }); err != nil {
  116 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  117 + } else {
  118 + cooperationContractChangeLogRepository = value
  119 + }
  120 + if count, cooperationContractChangeLogs, err := cooperationContractChangeLogRepository.Find(tool_funs.SimpleStructToMap(listCooperationContractChangeLogQuery)); err != nil {
  121 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  122 + } else {
  123 + if err := transactionContext.CommitTransaction(); err != nil {
  124 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  125 + }
  126 + return map[string]interface{}{
  127 + "count": count,
  128 + "cooperationContractChangeLogs": cooperationContractChangeLogs,
  129 + }, nil
  130 + }
  131 +}
  132 +
  133 +// 移除共创合约变更日志
  134 +func (cooperationContractChangeLogService *CooperationContractChangeLogService) RemoveCooperationContractChangeLog(removeCooperationContractChangeLogCommand *command.RemoveCooperationContractChangeLogCommand) (interface{}, error) {
  135 + if err := removeCooperationContractChangeLogCommand.ValidateCommand(); err != nil {
  136 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  137 + }
  138 + transactionContext, err := factory.CreateTransactionContext(nil)
  139 + if err != nil {
  140 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  141 + }
  142 + if err := transactionContext.StartTransaction(); err != nil {
  143 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  144 + }
  145 + defer func() {
  146 + transactionContext.RollbackTransaction()
  147 + }()
  148 + var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
  149 + if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
  150 + "transactionContext": transactionContext,
  151 + }); err != nil {
  152 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  153 + } else {
  154 + cooperationContractChangeLogRepository = value
  155 + }
  156 + cooperationContractChangeLog, err := cooperationContractChangeLogRepository.FindOne(map[string]interface{}{"cooperationContractChangeLogId": removeCooperationContractChangeLogCommand.CooperationContractChangeLogId})
  157 + if err != nil {
  158 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  159 + }
  160 + if cooperationContractChangeLog == nil {
  161 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCooperationContractChangeLogCommand.CooperationContractChangeLogId)))
  162 + }
  163 + if cooperationContractChangeLog, err := cooperationContractChangeLogRepository.Remove(cooperationContractChangeLog); err != nil {
  164 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  165 + } else {
  166 + if err := transactionContext.CommitTransaction(); err != nil {
  167 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  168 + }
  169 + return cooperationContractChangeLog, nil
  170 + }
  171 +}
  172 +
  173 +// 共创合约变更记录搜索
  174 +func (cooperationContractChangeLogService *CooperationContractChangeLogService) SearchCooperationContractChangeLog(searchCooperationContractChangeLogQuery *query.SearchCooperationContractChangeLogQuery) (interface{}, error) {
  175 + if err := searchCooperationContractChangeLogQuery.ValidateQuery(); err != nil {
  176 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  177 + }
  178 + transactionContext, err := factory.CreateTransactionContext(nil)
  179 + if err != nil {
  180 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  181 + }
  182 + if err := transactionContext.StartTransaction(); err != nil {
  183 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  184 + }
  185 + defer func() {
  186 + transactionContext.RollbackTransaction()
  187 + }()
  188 + if err := transactionContext.CommitTransaction(); err != nil {
  189 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  190 + }
  191 + return nil, nil
  192 +}
  193 +
  194 +// 更新共创合约变更日志
  195 +func (cooperationContractChangeLogService *CooperationContractChangeLogService) UpdateCooperationContractChangeLog(updateCooperationContractChangeLogCommand *command.UpdateCooperationContractChangeLogCommand) (interface{}, error) {
  196 + if err := updateCooperationContractChangeLogCommand.ValidateCommand(); err != nil {
  197 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  198 + }
  199 + transactionContext, err := factory.CreateTransactionContext(nil)
  200 + if err != nil {
  201 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  202 + }
  203 + if err := transactionContext.StartTransaction(); err != nil {
  204 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  205 + }
  206 + defer func() {
  207 + transactionContext.RollbackTransaction()
  208 + }()
  209 + var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
  210 + if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
  211 + "transactionContext": transactionContext,
  212 + }); err != nil {
  213 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  214 + } else {
  215 + cooperationContractChangeLogRepository = value
  216 + }
  217 + cooperationContractChangeLog, err := cooperationContractChangeLogRepository.FindOne(map[string]interface{}{"cooperationContractChangeLogId": updateCooperationContractChangeLogCommand.CooperationContractChangeLogId})
  218 + if err != nil {
  219 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  220 + }
  221 + if cooperationContractChangeLog == nil {
  222 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractChangeLogCommand.CooperationContractChangeLogId)))
  223 + }
  224 + if err := cooperationContractChangeLog.Update(tool_funs.SimpleStructToMap(updateCooperationContractChangeLogCommand)); err != nil {
  225 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  226 + }
  227 + if cooperationContractChangeLog, err := cooperationContractChangeLogRepository.Save(cooperationContractChangeLog); err != nil {
  228 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  229 + } else {
  230 + if err := transactionContext.CommitTransaction(); err != nil {
  231 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  232 + }
  233 + return cooperationContractChangeLog, nil
  234 + }
  235 +}
  236 +
  237 +func NewCooperationContractChangeLogService(options map[string]interface{}) *CooperationContractChangeLogService {
  238 + newCooperationContractChangeLogService := &CooperationContractChangeLogService{}
  239 + return newCooperationContractChangeLogService
  240 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type CreateCooperationProjectCommand struct {
  12 + // 共创项目名称
  13 + CooperationProjectName string `cname:"共创项目名称" json:"cooperationProjectName" valid:"Required"`
  14 + // 承接对象,1员工,2共创用户,3公开,可以多选
  15 + CooperationProjectUndertakerType []int32 `cname:"承接对象,1员工,2共创用户,3公开,可以多选" json:"cooperationProjectUndertakerType" valid:"Required"`
  16 + // 共创项目发起人uid
  17 + SponsorUid string `cname:"共创项目发起人uid" json:"sponsorUid" valid:"Required"`
  18 + // 共创项目发布人uid
  19 + PublisherUid string `cname:"共创项目发布人uid" json:"publisherUid" valid:"Required"`
  20 + // 共创项目描述
  21 + CooperationProjectDescription string `cname:"共创项目描述" json:"cooperationProjectDescription,omitempty"`
  22 + // 公司ID,通过集成REST上下文获取
  23 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  24 + // 组织机构ID
  25 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  26 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  27 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  28 +}
  29 +
  30 +func (createCooperationProjectCommand *CreateCooperationProjectCommand) Valid(validation *validation.Validation) {
  31 + validation.SetError("CustomValid", "未实现的自定义认证")
  32 +}
  33 +
  34 +func (createCooperationProjectCommand *CreateCooperationProjectCommand) ValidateCommand() error {
  35 + valid := validation.Validation{}
  36 + b, err := valid.Valid(createCooperationProjectCommand)
  37 + if err != nil {
  38 + return err
  39 + }
  40 + if !b {
  41 + elem := reflect.TypeOf(createCooperationProjectCommand).Elem()
  42 + for _, validErr := range valid.Errors {
  43 + field, isExist := elem.FieldByName(validErr.Field)
  44 + if isExist {
  45 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  46 + } else {
  47 + return fmt.Errorf(validErr.Message)
  48 + }
  49 + }
  50 + }
  51 + return nil
  52 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  6 + "reflect"
  7 + "strings"
  8 +
  9 + "github.com/beego/beego/v2/core/validation"
  10 +)
  11 +
  12 +type ReleaseCooperationProjectCommand struct {
  13 + // 共创项目名称
  14 + CooperationProjectName string `cname:"共创项目名称" json:"cooperationProjectName" valid:"Required"`
  15 + // 共创模式ID
  16 + CooperationModeId int64 `cname:"共创模式ID" json:"cooperationModeId,string" valid:"Required"`
  17 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  18 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  19 + // 用户基本id
  20 + UserBaseId int64 `cname:"用户基本id" json:"userBaseId,string" valid:"Required"`
  21 + // 组织机构ID
  22 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  23 + // 组织名称
  24 + OrgName string `cname:"组织名称" json:"orgName" valid:"Required"`
  25 + // 公司ID,通过集成REST上下文获取
  26 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  27 + // 公司logo
  28 + CompanyLogo string `cname:"公司logo" json:"companyLogo" valid:"Required"`
  29 + // 公司名称
  30 + CompanyName string `cname:"公司名称" json:"companyName" valid:"Required"`
  31 + // 用户关联的组织机构
  32 + Orgs []*domain.Org `cname:"用户关联的组织机构" json:"orgs" valid:"Required"`
  33 + // 部门ID,通过REST集成上下文获取
  34 + DepartmentId int64 `cname:"部门ID,通过REST集成上下文获取" json:"departmentId,string" valid:"Required"`
  35 + // 部门名称
  36 + DepartmentName string `cname:"部门名称" json:"departmentName" valid:"Required"`
  37 + // 部门编码
  38 + DepartmentNumber string `cname:"部门编码" json:"departmentNumber" valid:"Required"`
  39 + // 是否组织机构标识,1为是,2为否,默认为否
  40 + IsOrganization bool `cname:"是否组织机构标识,1为是,2为否,默认为否" json:"isOrganization" valid:"Required"`
  41 + // 角色ID
  42 + RoleId int64 `cname:"角色ID" json:"roleId,string" valid:"Required"`
  43 + // 角色名称
  44 + RoleName string `cname:"角色名称" json:"roleName" valid:"Required"`
  45 + // 用户头像
  46 + UserAvatar string `cname:"用户头像" json:"userAvatar" valid:"Required"`
  47 + // 用户邮箱
  48 + UserEmail string `cname:"用户邮箱" json:"userEmail" valid:"Required"`
  49 + // 共创人员姓名
  50 + UserName string `cname:"共创人员姓名" json:"userName" valid:"Required"`
  51 + // 用户手机号
  52 + UserPhone string `cname:"用户手机号" json:"userPhone" valid:"Required"`
  53 + // 用户账号,区别于手机号,冗余字段
  54 + UserAccount string `cname:"用户账号,区别于手机号,冗余字段" json:"userAccount" valid:"Required"`
  55 + // 用户类型
  56 + UserType int32 `cname:"用户类型" json:"userType" valid:"Required"`
  57 + // 状态
  58 + Status int32 `cname:"状态" json:"status" valid:"Required"`
  59 + // 共创项目承接对象,1员工,2共创用户,3公开,可以多选
  60 + CooperationProjectUndertakerType []int32 `cname:"共创项目承接对象,1员工,2共创用户,3公开,可以多选" json:"cooperationProjectUndertakerType" valid:"Required"`
  61 + // 共创项目描述
  62 + CooperationProjectDescription string `cname:"共创项目描述" json:"cooperationProjectDescription" valid:"Required"`
  63 +}
  64 +
  65 +func (releaseCooperationProjectCommand *ReleaseCooperationProjectCommand) Valid(validation *validation.Validation) {
  66 + validation.SetError("CustomValid", "未实现的自定义认证")
  67 +}
  68 +
  69 +func (releaseCooperationProjectCommand *ReleaseCooperationProjectCommand) ValidateCommand() error {
  70 + valid := validation.Validation{}
  71 + b, err := valid.Valid(releaseCooperationProjectCommand)
  72 + if err != nil {
  73 + return err
  74 + }
  75 + if !b {
  76 + elem := reflect.TypeOf(releaseCooperationProjectCommand).Elem()
  77 + for _, validErr := range valid.Errors {
  78 + field, isExist := elem.FieldByName(validErr.Field)
  79 + if isExist {
  80 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  81 + } else {
  82 + return fmt.Errorf(validErr.Message)
  83 + }
  84 + }
  85 + }
  86 + return nil
  87 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type RemoveCooperationProjectCommand struct {
  12 + // 共创项目ID
  13 + CooperationProjectId int64 `cname:"共创项目ID" json:"cooperationProjectId,string" valid:"Required"`
  14 + // 公司ID,通过集成REST上下文获取
  15 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  16 + // 组织机构ID
  17 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  18 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  19 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  20 +}
  21 +
  22 +func (removeCooperationProjectCommand *RemoveCooperationProjectCommand) Valid(validation *validation.Validation) {
  23 + validation.SetError("CustomValid", "未实现的自定义认证")
  24 +}
  25 +
  26 +func (removeCooperationProjectCommand *RemoveCooperationProjectCommand) ValidateCommand() error {
  27 + valid := validation.Validation{}
  28 + b, err := valid.Valid(removeCooperationProjectCommand)
  29 + if err != nil {
  30 + return err
  31 + }
  32 + if !b {
  33 + elem := reflect.TypeOf(removeCooperationProjectCommand).Elem()
  34 + for _, validErr := range valid.Errors {
  35 + field, isExist := elem.FieldByName(validErr.Field)
  36 + if isExist {
  37 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  38 + } else {
  39 + return fmt.Errorf(validErr.Message)
  40 + }
  41 + }
  42 + }
  43 + return nil
  44 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type UpdateCooperationProjectCommand struct {
  12 + // 共创项目ID
  13 + CooperationProjectId int64 `cname:"共创项目ID" json:"cooperationProjectId,string" valid:"Required"`
  14 + // 共创项目名称
  15 + CooperationProjectName string `cname:"共创项目名称" json:"cooperationProjectName" valid:"Required"`
  16 + // 承接对象,1员工,2共创用户,3公开,可以多选
  17 + CooperationProjectUndertakerType []int32 `cname:"承接对象,1员工,2共创用户,3公开,可以多选" json:"cooperationProjectUndertakerType" valid:"Required"`
  18 + // 共创项目发起人uid
  19 + SponsorUid string `cname:"共创项目发起人uid" json:"sponsorUid" valid:"Required"`
  20 + // 共创项目发布人uid
  21 + PublisherUid string `cname:"共创项目发布人uid" json:"publisherUid" valid:"Required"`
  22 + // 共创项目描述
  23 + CooperationProjectDescription string `cname:"共创项目描述" json:"cooperationProjectDescription,omitempty"`
  24 + // 公司ID,通过集成REST上下文获取
  25 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  26 + // 组织机构ID
  27 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  28 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  29 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  30 +}
  31 +
  32 +func (updateCooperationProjectCommand *UpdateCooperationProjectCommand) Valid(validation *validation.Validation) {
  33 + validation.SetError("CustomValid", "未实现的自定义认证")
  34 +}
  35 +
  36 +func (updateCooperationProjectCommand *UpdateCooperationProjectCommand) ValidateCommand() error {
  37 + valid := validation.Validation{}
  38 + b, err := valid.Valid(updateCooperationProjectCommand)
  39 + if err != nil {
  40 + return err
  41 + }
  42 + if !b {
  43 + elem := reflect.TypeOf(updateCooperationProjectCommand).Elem()
  44 + for _, validErr := range valid.Errors {
  45 + field, isExist := elem.FieldByName(validErr.Field)
  46 + if isExist {
  47 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  48 + } else {
  49 + return fmt.Errorf(validErr.Message)
  50 + }
  51 + }
  52 + }
  53 + return nil
  54 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type CheckUndertakerQuery struct {
  12 + // 共创项目承接对象,1员工,2共创用户,3公开,可以多选
  13 + CooperationProjectUndertakerType []int32 `cname:"共创项目承接对象,1员工,2共创用户,3公开,可以多选" json:"cooperationProjectUndertakerType" valid:"Required"`
  14 + // 共创项目ID
  15 + CooperationProjectId int64 `cname:"共创项目ID" json:"cooperationProjectId,string" valid:"Required"`
  16 +}
  17 +
  18 +func (checkUndertakerQuery *CheckUndertakerQuery) Valid(validation *validation.Validation) {
  19 + validation.SetError("CustomValid", "未实现的自定义认证")
  20 +}
  21 +
  22 +func (checkUndertakerQuery *CheckUndertakerQuery) ValidateQuery() error {
  23 + valid := validation.Validation{}
  24 + b, err := valid.Valid(checkUndertakerQuery)
  25 + if err != nil {
  26 + return err
  27 + }
  28 + if !b {
  29 + elem := reflect.TypeOf(checkUndertakerQuery).Elem()
  30 + for _, validErr := range valid.Errors {
  31 + field, isExist := elem.FieldByName(validErr.Field)
  32 + if isExist {
  33 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  34 + } else {
  35 + return fmt.Errorf(validErr.Message)
  36 + }
  37 + }
  38 + }
  39 + return nil
  40 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type GetCooperationProjectQuery struct {
  12 + // 共创项目ID
  13 + CooperationProjectId int64 `cname:"共创项目ID" json:"cooperationProjectId,string" valid:"Required"`
  14 + // 公司ID,通过集成REST上下文获取
  15 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  16 + // 组织机构ID
  17 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  18 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  19 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  20 +}
  21 +
  22 +func (getCooperationProjectQuery *GetCooperationProjectQuery) Valid(validation *validation.Validation) {
  23 + validation.SetError("CustomValid", "未实现的自定义认证")
  24 +}
  25 +
  26 +func (getCooperationProjectQuery *GetCooperationProjectQuery) ValidateQuery() error {
  27 + valid := validation.Validation{}
  28 + b, err := valid.Valid(getCooperationProjectQuery)
  29 + if err != nil {
  30 + return err
  31 + }
  32 + if !b {
  33 + elem := reflect.TypeOf(getCooperationProjectQuery).Elem()
  34 + for _, validErr := range valid.Errors {
  35 + field, isExist := elem.FieldByName(validErr.Field)
  36 + if isExist {
  37 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  38 + } else {
  39 + return fmt.Errorf(validErr.Message)
  40 + }
  41 + }
  42 + }
  43 + return nil
  44 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type ListCooperationProjectQuery struct {
  12 + // 查询偏离量
  13 + Offset int `cname:"查询偏离量" json:"offset" valid:"Required"`
  14 + // 查询限制
  15 + Limit int `cname:"查询限制" json:"limit" valid:"Required"`
  16 + // 公司ID,通过集成REST上下文获取
  17 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  18 + // 组织机构ID
  19 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  20 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  21 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  22 +}
  23 +
  24 +func (listCooperationProjectQuery *ListCooperationProjectQuery) Valid(validation *validation.Validation) {
  25 + validation.SetError("CustomValid", "未实现的自定义认证")
  26 +}
  27 +
  28 +func (listCooperationProjectQuery *ListCooperationProjectQuery) ValidateQuery() error {
  29 + valid := validation.Validation{}
  30 + b, err := valid.Valid(listCooperationProjectQuery)
  31 + if err != nil {
  32 + return err
  33 + }
  34 + if !b {
  35 + elem := reflect.TypeOf(listCooperationProjectQuery).Elem()
  36 + for _, validErr := range valid.Errors {
  37 + field, isExist := elem.FieldByName(validErr.Field)
  38 + if isExist {
  39 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  40 + } else {
  41 + return fmt.Errorf(validErr.Message)
  42 + }
  43 + }
  44 + }
  45 + return nil
  46 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type SearchCooperationProjectQuery struct {
  12 + // 页面大小
  13 + PageNumber int32 `cname:"页面大小" json:"pageNumber,omitempty"`
  14 + // 页面大小
  15 + PageSize int32 `cname:"页面大小" json:"pageSize,omitempty"`
  16 + // 共创项目名称
  17 + CooperationProjectName string `cname:"共创项目名称" json:"cooperationProjectName,omitempty"`
  18 + // 部门名称
  19 + DepartmentName string `cname:"部门名称" json:"departmentName,omitempty"`
  20 + // 共创项目状态,根据共创项目状态筛选项目数据
  21 + Status int32 `cname:"共创项目状态,根据共创项目状态筛选项目数据" json:"status,omitempty"`
  22 + // 公司ID,通过集成REST上下文获取
  23 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  24 + // 组织机构ID
  25 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  26 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  27 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  28 +}
  29 +
  30 +func (searchCooperationProjectQuery *SearchCooperationProjectQuery) Valid(validation *validation.Validation) {
  31 + validation.SetError("CustomValid", "未实现的自定义认证")
  32 +}
  33 +
  34 +func (searchCooperationProjectQuery *SearchCooperationProjectQuery) ValidateQuery() error {
  35 + valid := validation.Validation{}
  36 + b, err := valid.Valid(searchCooperationProjectQuery)
  37 + if err != nil {
  38 + return err
  39 + }
  40 + if !b {
  41 + elem := reflect.TypeOf(searchCooperationProjectQuery).Elem()
  42 + for _, validErr := range valid.Errors {
  43 + field, isExist := elem.FieldByName(validErr.Field)
  44 + if isExist {
  45 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  46 + } else {
  47 + return fmt.Errorf(validErr.Message)
  48 + }
  49 + }
  50 + }
  51 + return nil
  52 +}
  1 +package service
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/linmadan/egglib-go/core/application"
  6 + "github.com/linmadan/egglib-go/utils/tool_funs"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/command"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 +)
  12 +
  13 +// 共创项目服务
  14 +type CooperationProjectService struct {
  15 +}
  16 +
  17 +// 判断当前勾选的承接对象是否存在用户
  18 +func (cooperationProjectService *CooperationProjectService) CheckUndertaker(checkUndertakerQuery *query.CheckUndertakerQuery) (interface{}, error) {
  19 + if err := checkUndertakerQuery.ValidateQuery(); err != nil {
  20 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  21 + }
  22 + transactionContext, err := factory.CreateTransactionContext(nil)
  23 + if err != nil {
  24 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  25 + }
  26 + if err := transactionContext.StartTransaction(); err != nil {
  27 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  28 + }
  29 + defer func() {
  30 + transactionContext.RollbackTransaction()
  31 + }()
  32 + if err := transactionContext.CommitTransaction(); err != nil {
  33 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  34 + }
  35 + return nil, nil
  36 +}
  37 +
  38 +// 创建共创项目服务
  39 +func (cooperationProjectService *CooperationProjectService) CreateCooperationProject(createCooperationProjectCommand *command.CreateCooperationProjectCommand) (interface{}, error) {
  40 + if err := createCooperationProjectCommand.ValidateCommand(); err != nil {
  41 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  42 + }
  43 + transactionContext, err := factory.CreateTransactionContext(nil)
  44 + if err != nil {
  45 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  46 + }
  47 + if err := transactionContext.StartTransaction(); err != nil {
  48 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  49 + }
  50 + defer func() {
  51 + transactionContext.RollbackTransaction()
  52 + }()
  53 + newCooperationProject := &domain.CooperationProject{
  54 + CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
  55 + CooperationProjectUndertakerType: createCooperationProjectCommand.CooperationProjectUndertakerType,
  56 + SponsorUid: createCooperationProjectCommand.SponsorUid,
  57 + PublisherUid: createCooperationProjectCommand.PublisherUid,
  58 + CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
  59 + CompanyId: createCooperationProjectCommand.CompanyId,
  60 + OrgId: createCooperationProjectCommand.OrgId,
  61 + UserId: createCooperationProjectCommand.UserId,
  62 + }
  63 + var cooperationProjectRepository domain.CooperationProjectRepository
  64 + if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
  65 + "transactionContext": transactionContext,
  66 + }); err != nil {
  67 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  68 + } else {
  69 + cooperationProjectRepository = value
  70 + }
  71 + if cooperationProject, err := cooperationProjectRepository.Save(newCooperationProject); err != nil {
  72 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  73 + } else {
  74 + if err := transactionContext.CommitTransaction(); err != nil {
  75 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  76 + }
  77 + return cooperationProject, nil
  78 + }
  79 +}
  80 +
  81 +// 返回共创项目服务
  82 +func (cooperationProjectService *CooperationProjectService) GetCooperationProject(getCooperationProjectQuery *query.GetCooperationProjectQuery) (interface{}, error) {
  83 + if err := getCooperationProjectQuery.ValidateQuery(); err != nil {
  84 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  85 + }
  86 + transactionContext, err := factory.CreateTransactionContext(nil)
  87 + if err != nil {
  88 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  89 + }
  90 + if err := transactionContext.StartTransaction(); err != nil {
  91 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  92 + }
  93 + defer func() {
  94 + transactionContext.RollbackTransaction()
  95 + }()
  96 + var cooperationProjectRepository domain.CooperationProjectRepository
  97 + if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
  98 + "transactionContext": transactionContext,
  99 + }); err != nil {
  100 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  101 + } else {
  102 + cooperationProjectRepository = value
  103 + }
  104 + cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": getCooperationProjectQuery.CooperationProjectId})
  105 + if err != nil {
  106 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  107 + }
  108 + if cooperationProject == nil {
  109 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCooperationProjectQuery.CooperationProjectId)))
  110 + } else {
  111 + if err := transactionContext.CommitTransaction(); err != nil {
  112 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  113 + }
  114 + return cooperationProject, nil
  115 + }
  116 +}
  117 +
  118 +// 返回共创项目服务列表
  119 +func (cooperationProjectService *CooperationProjectService) ListCooperationProject(listCooperationProjectQuery *query.ListCooperationProjectQuery) (interface{}, error) {
  120 + if err := listCooperationProjectQuery.ValidateQuery(); err != nil {
  121 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  122 + }
  123 + transactionContext, err := factory.CreateTransactionContext(nil)
  124 + if err != nil {
  125 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  126 + }
  127 + if err := transactionContext.StartTransaction(); err != nil {
  128 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  129 + }
  130 + defer func() {
  131 + transactionContext.RollbackTransaction()
  132 + }()
  133 + var cooperationProjectRepository domain.CooperationProjectRepository
  134 + if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
  135 + "transactionContext": transactionContext,
  136 + }); err != nil {
  137 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  138 + } else {
  139 + cooperationProjectRepository = value
  140 + }
  141 + if count, cooperationProjects, err := cooperationProjectRepository.Find(tool_funs.SimpleStructToMap(listCooperationProjectQuery)); err != nil {
  142 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  143 + } else {
  144 + if err := transactionContext.CommitTransaction(); err != nil {
  145 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  146 + }
  147 + return map[string]interface{}{
  148 + "count": count,
  149 + "cooperationProjects": cooperationProjects,
  150 + }, nil
  151 + }
  152 +}
  153 +
  154 +// 发布共创项目
  155 +func (cooperationProjectService *CooperationProjectService) ReleaseCooperationProject(releaseCooperationProjectCommand *command.ReleaseCooperationProjectCommand) (interface{}, error) {
  156 + if err := releaseCooperationProjectCommand.ValidateCommand(); err != nil {
  157 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  158 + }
  159 + transactionContext, err := factory.CreateTransactionContext(nil)
  160 + if err != nil {
  161 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  162 + }
  163 + if err := transactionContext.StartTransaction(); err != nil {
  164 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  165 + }
  166 + defer func() {
  167 + transactionContext.RollbackTransaction()
  168 + }()
  169 + if err := transactionContext.CommitTransaction(); err != nil {
  170 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  171 + }
  172 + return nil, nil
  173 +}
  174 +
  175 +// 移除共创项目服务
  176 +func (cooperationProjectService *CooperationProjectService) RemoveCooperationProject(removeCooperationProjectCommand *command.RemoveCooperationProjectCommand) (interface{}, error) {
  177 + if err := removeCooperationProjectCommand.ValidateCommand(); err != nil {
  178 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  179 + }
  180 + transactionContext, err := factory.CreateTransactionContext(nil)
  181 + if err != nil {
  182 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  183 + }
  184 + if err := transactionContext.StartTransaction(); err != nil {
  185 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  186 + }
  187 + defer func() {
  188 + transactionContext.RollbackTransaction()
  189 + }()
  190 + var cooperationProjectRepository domain.CooperationProjectRepository
  191 + if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
  192 + "transactionContext": transactionContext,
  193 + }); err != nil {
  194 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  195 + } else {
  196 + cooperationProjectRepository = value
  197 + }
  198 + cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": removeCooperationProjectCommand.CooperationProjectId})
  199 + if err != nil {
  200 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  201 + }
  202 + if cooperationProject == nil {
  203 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCooperationProjectCommand.CooperationProjectId)))
  204 + }
  205 + if cooperationProject, err := cooperationProjectRepository.Remove(cooperationProject); err != nil {
  206 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  207 + } else {
  208 + if err := transactionContext.CommitTransaction(); err != nil {
  209 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  210 + }
  211 + return cooperationProject, nil
  212 + }
  213 +}
  214 +
  215 +// 查询共创项目
  216 +func (cooperationProjectService *CooperationProjectService) SearchCooperationProject(searchCooperationProjectQuery *query.SearchCooperationProjectQuery) (interface{}, error) {
  217 + if err := searchCooperationProjectQuery.ValidateQuery(); err != nil {
  218 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  219 + }
  220 + transactionContext, err := factory.CreateTransactionContext(nil)
  221 + if err != nil {
  222 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  223 + }
  224 + if err := transactionContext.StartTransaction(); err != nil {
  225 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  226 + }
  227 + defer func() {
  228 + transactionContext.RollbackTransaction()
  229 + }()
  230 + if err := transactionContext.CommitTransaction(); err != nil {
  231 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  232 + }
  233 + return nil, nil
  234 +}
  235 +
  236 +// 更新共创项目服务
  237 +func (cooperationProjectService *CooperationProjectService) UpdateCooperationProject(updateCooperationProjectCommand *command.UpdateCooperationProjectCommand) (interface{}, error) {
  238 + if err := updateCooperationProjectCommand.ValidateCommand(); err != nil {
  239 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  240 + }
  241 + transactionContext, err := factory.CreateTransactionContext(nil)
  242 + if err != nil {
  243 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  244 + }
  245 + if err := transactionContext.StartTransaction(); err != nil {
  246 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  247 + }
  248 + defer func() {
  249 + transactionContext.RollbackTransaction()
  250 + }()
  251 + var cooperationProjectRepository domain.CooperationProjectRepository
  252 + if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
  253 + "transactionContext": transactionContext,
  254 + }); err != nil {
  255 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  256 + } else {
  257 + cooperationProjectRepository = value
  258 + }
  259 + cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": updateCooperationProjectCommand.CooperationProjectId})
  260 + if err != nil {
  261 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  262 + }
  263 + if cooperationProject == nil {
  264 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationProjectCommand.CooperationProjectId)))
  265 + }
  266 + if err := cooperationProject.Update(tool_funs.SimpleStructToMap(updateCooperationProjectCommand)); err != nil {
  267 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  268 + }
  269 + if cooperationProject, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
  270 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  271 + } else {
  272 + if err := transactionContext.CommitTransaction(); err != nil {
  273 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  274 + }
  275 + return cooperationProject, nil
  276 + }
  277 +}
  278 +
  279 +func NewCooperationProjectService(options map[string]interface{}) *CooperationProjectService {
  280 + newCooperationProjectService := &CooperationProjectService{}
  281 + return newCooperationProjectService
  282 +}
@@ -69,3 +69,11 @@ func CreateMoneyIncentivesRuleRepository(options map[string]interface{}) (domain @@ -69,3 +69,11 @@ func CreateMoneyIncentivesRuleRepository(options map[string]interface{}) (domain
69 } 69 }
70 return repository.NewMoneyIncentivesRuleRepository(transactionContext) 70 return repository.NewMoneyIncentivesRuleRepository(transactionContext)
71 } 71 }
  72 +
  73 +func CreateCooperationContractChangeLogRepository(options map[string]interface{}) (domain.CooperationContractChangeLogRepository, error) {
  74 + var transactionContext *pg.TransactionContext
  75 + if value, ok := options["transactionContext"]; ok {
  76 + transactionContext = value.(*pg.TransactionContext)
  77 + }
  78 + return repository.NewCooperationContractChangeLogRepository(transactionContext)
  79 +}
@@ -52,78 +52,6 @@ func (contractUndertakerFeedback *ContractUndertakerFeedback) Update(data map[st @@ -52,78 +52,6 @@ func (contractUndertakerFeedback *ContractUndertakerFeedback) Update(data map[st
52 if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok { 52 if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
53 contractUndertakerFeedback.CooperationContractNumber = cooperationContractNumber.(string) 53 contractUndertakerFeedback.CooperationContractNumber = cooperationContractNumber.(string)
54 } 54 }
55 - if userId, ok := data["userId"]; ok {  
56 - contractUndertakerFeedback.ContractUndertaker.UserId = userId.(int64)  
57 - }  
58 - if userBaseId, ok := data["userBaseId"]; ok {  
59 - contractUndertakerFeedback.ContractUndertaker.UserBaseId = userBaseId.(int64)  
60 - }  
61 - if orgId, ok := data["orgId"]; ok {  
62 - contractUndertakerFeedback.ContractUndertaker.Org.OrgId = orgId.(int64)  
63 - }  
64 - if orgName, ok := data["orgName"]; ok {  
65 - contractUndertakerFeedback.ContractUndertaker.Org.OrgName = orgName.(string)  
66 - }  
67 - if companyId, ok := data["companyId"]; ok {  
68 - contractUndertakerFeedback.ContractUndertaker.Org.Company.CompanyId = companyId.(int64)  
69 - }  
70 - if companyLogo, ok := data["companyLogo"]; ok {  
71 - contractUndertakerFeedback.ContractUndertaker.Org.Company.CompanyLogo = companyLogo.(string)  
72 - }  
73 - if companyName, ok := data["companyName"]; ok {  
74 - contractUndertakerFeedback.ContractUndertaker.Org.Company.CompanyName = companyName.(string)  
75 - }  
76 - if orgs, ok := data["orgs"]; ok {  
77 - contractUndertakerFeedback.ContractUndertaker.Orgs = orgs.([]*Org)  
78 - }  
79 - if departmentId, ok := data["departmentId"]; ok {  
80 - contractUndertakerFeedback.ContractUndertaker.Department.DepartmentId = departmentId.(int64)  
81 - }  
82 - if departmentName, ok := data["departmentName"]; ok {  
83 - contractUndertakerFeedback.ContractUndertaker.Department.DepartmentName = departmentName.(string)  
84 - }  
85 - if departmentNumber, ok := data["departmentNumber"]; ok {  
86 - contractUndertakerFeedback.ContractUndertaker.Department.DepartmentNumber = departmentNumber.(string)  
87 - }  
88 - if isOrganization, ok := data["isOrganization"]; ok {  
89 - contractUndertakerFeedback.ContractUndertaker.Department.IsOrganization = isOrganization.(bool)  
90 - }  
91 - if roleId, ok := data["roleId"]; ok {  
92 - contractUndertakerFeedback.ContractUndertaker.Role.RoleId = roleId.(int64)  
93 - }  
94 - if roleName, ok := data["roleName"]; ok {  
95 - contractUndertakerFeedback.ContractUndertaker.Role.RoleName = roleName.(string)  
96 - }  
97 - if userAvatar, ok := data["userAvatar"]; ok {  
98 - contractUndertakerFeedback.ContractUndertaker.UserInfo.UserAvatar = userAvatar.(string)  
99 - }  
100 - if userEmail, ok := data["userEmail"]; ok {  
101 - contractUndertakerFeedback.ContractUndertaker.UserInfo.UserEmail = userEmail.(string)  
102 - }  
103 - if userName, ok := data["userName"]; ok {  
104 - contractUndertakerFeedback.ContractUndertaker.UserInfo.UserName = userName.(string)  
105 - }  
106 - if userPhone, ok := data["userPhone"]; ok {  
107 - contractUndertakerFeedback.ContractUndertaker.UserInfo.UserPhone = userPhone.(string)  
108 - }  
109 - if userAccount, ok := data["userAccount"]; ok {  
110 - contractUndertakerFeedback.ContractUndertaker.UserInfo.UserAccount = userAccount.(string)  
111 - }  
112 - if userType, ok := data["userType"]; ok {  
113 - contractUndertakerFeedback.ContractUndertaker.UserType = userType.(int32)  
114 - }  
115 - if status, ok := data["status"]; ok {  
116 - contractUndertakerFeedback.ContractUndertaker.Status = status.(int32)  
117 - }  
118 - if cooperationModeId, ok := data["cooperationModeId"]; ok {  
119 - contractUndertakerFeedback.CooperationMode.CooperationModeId = cooperationModeId.(int64)  
120 - }  
121 - if cooperationModeNumber, ok := data["cooperationModeNumber"]; ok {  
122 - contractUndertakerFeedback.CooperationMode.CooperationModeNumber = cooperationModeNumber.(string)  
123 - }  
124 - if cooperationModeName, ok := data["cooperationModeName"]; ok {  
125 - contractUndertakerFeedback.CooperationMode.CooperationModeName = cooperationModeName.(string)  
126 - }  
127 if status, ok := data["status"]; ok { 55 if status, ok := data["status"]; ok {
128 contractUndertakerFeedback.CooperationMode.Status = status.(int32) 56 contractUndertakerFeedback.CooperationMode.Status = status.(int32)
129 } 57 }
@@ -57,60 +57,9 @@ func (cooperationApplication *CooperationApplication) Update(data map[string]int @@ -57,60 +57,9 @@ func (cooperationApplication *CooperationApplication) Update(data map[string]int
57 if userBaseId, ok := data["userBaseId"]; ok { 57 if userBaseId, ok := data["userBaseId"]; ok {
58 cooperationApplication.CooperationApplicationApplicant.UserBaseId = userBaseId.(int64) 58 cooperationApplication.CooperationApplicationApplicant.UserBaseId = userBaseId.(int64)
59 } 59 }
60 - if orgId, ok := data["orgId"]; ok {  
61 - cooperationApplication.CooperationApplicationApplicant.Org.OrgId = orgId.(int64)  
62 - }  
63 - if orgName, ok := data["orgName"]; ok {  
64 - cooperationApplication.CooperationApplicationApplicant.Org.OrgName = orgName.(string)  
65 - }  
66 - if companyId, ok := data["companyId"]; ok {  
67 - cooperationApplication.CooperationApplicationApplicant.Org.Company.CompanyId = companyId.(int64)  
68 - }  
69 - if companyLogo, ok := data["companyLogo"]; ok {  
70 - cooperationApplication.CooperationApplicationApplicant.Org.Company.CompanyLogo = companyLogo.(string)  
71 - }  
72 - if companyName, ok := data["companyName"]; ok {  
73 - cooperationApplication.CooperationApplicationApplicant.Org.Company.CompanyName = companyName.(string)  
74 - }  
75 if orgs, ok := data["orgs"]; ok { 60 if orgs, ok := data["orgs"]; ok {
76 cooperationApplication.CooperationApplicationApplicant.Orgs = orgs.([]*Org) 61 cooperationApplication.CooperationApplicationApplicant.Orgs = orgs.([]*Org)
77 } 62 }
78 - if departmentId, ok := data["departmentId"]; ok {  
79 - cooperationApplication.CooperationApplicationApplicant.Department.DepartmentId = departmentId.(int64)  
80 - }  
81 - if departmentName, ok := data["departmentName"]; ok {  
82 - cooperationApplication.CooperationApplicationApplicant.Department.DepartmentName = departmentName.(string)  
83 - }  
84 - if departmentNumber, ok := data["departmentNumber"]; ok {  
85 - cooperationApplication.CooperationApplicationApplicant.Department.DepartmentNumber = departmentNumber.(string)  
86 - }  
87 - if isOrganization, ok := data["isOrganization"]; ok {  
88 - cooperationApplication.CooperationApplicationApplicant.Department.IsOrganization = isOrganization.(bool)  
89 - }  
90 - if roleId, ok := data["roleId"]; ok {  
91 - cooperationApplication.CooperationApplicationApplicant.Role.RoleId = roleId.(int64)  
92 - }  
93 - if roleName, ok := data["roleName"]; ok {  
94 - cooperationApplication.CooperationApplicationApplicant.Role.RoleName = roleName.(string)  
95 - }  
96 - if userAvatar, ok := data["userAvatar"]; ok {  
97 - cooperationApplication.CooperationApplicationApplicant.UserInfo.UserAvatar = userAvatar.(string)  
98 - }  
99 - if userEmail, ok := data["userEmail"]; ok {  
100 - cooperationApplication.CooperationApplicationApplicant.UserInfo.UserEmail = userEmail.(string)  
101 - }  
102 - if userName, ok := data["userName"]; ok {  
103 - cooperationApplication.CooperationApplicationApplicant.UserInfo.UserName = userName.(string)  
104 - }  
105 - if userPhone, ok := data["userPhone"]; ok {  
106 - cooperationApplication.CooperationApplicationApplicant.UserInfo.UserPhone = userPhone.(string)  
107 - }  
108 - if userAccount, ok := data["userAccount"]; ok {  
109 - cooperationApplication.CooperationApplicationApplicant.UserInfo.UserAccount = userAccount.(string)  
110 - }  
111 - if userType, ok := data["userType"]; ok {  
112 - cooperationApplication.CooperationApplicationApplicant.UserType = userType.(int32)  
113 - }  
114 if status, ok := data["status"]; ok { 63 if status, ok := data["status"]; ok {
115 cooperationApplication.CooperationApplicationApplicant.Status = status.(int32) 64 cooperationApplication.CooperationApplicationApplicant.Status = status.(int32)
116 } 65 }
@@ -55,9 +55,6 @@ func (cooperationContract *CooperationContract) Identify() interface{} { @@ -55,9 +55,6 @@ func (cooperationContract *CooperationContract) Identify() interface{} {
55 } 55 }
56 56
57 func (cooperationContract *CooperationContract) Update(data map[string]interface{}) error { 57 func (cooperationContract *CooperationContract) Update(data map[string]interface{}) error {
58 - if cooperationContractId, ok := data["cooperationContractId"]; ok {  
59 - cooperationContract.CooperationContractId = cooperationContractId.(int64)  
60 - }  
61 if cooperationContractDescription, ok := data["cooperationContractDescription"]; ok { 58 if cooperationContractDescription, ok := data["cooperationContractDescription"]; ok {
62 cooperationContract.CooperationContractDescription = cooperationContractDescription.(string) 59 cooperationContract.CooperationContractDescription = cooperationContractDescription.(string)
63 } 60 }
@@ -73,107 +70,20 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface @@ -73,107 +70,20 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface
73 if userBaseId, ok := data["userBaseId"]; ok { 70 if userBaseId, ok := data["userBaseId"]; ok {
74 cooperationContract.CooperationContractReferrer.UserBaseId = userBaseId.(int64) 71 cooperationContract.CooperationContractReferrer.UserBaseId = userBaseId.(int64)
75 } 72 }
76 - if orgId, ok := data["orgId"]; ok {  
77 - cooperationContract.CooperationContractReferrer.Org.OrgId = orgId.(int64)  
78 - }  
79 - if orgName, ok := data["orgName"]; ok {  
80 - cooperationContract.CooperationContractReferrer.Org.OrgName = orgName.(string)  
81 - }  
82 - if companyId, ok := data["companyId"]; ok {  
83 - cooperationContract.CooperationContractReferrer.Org.Company.CompanyId = companyId.(int64)  
84 - }  
85 - if companyLogo, ok := data["companyLogo"]; ok {  
86 - cooperationContract.CooperationContractReferrer.Org.Company.CompanyLogo = companyLogo.(string)  
87 - }  
88 - if companyName, ok := data["companyName"]; ok {  
89 - cooperationContract.CooperationContractReferrer.Org.Company.CompanyName = companyName.(string)  
90 - }  
91 if orgs, ok := data["orgs"]; ok { 73 if orgs, ok := data["orgs"]; ok {
92 cooperationContract.CooperationContractReferrer.Orgs = orgs.([]*Org) 74 cooperationContract.CooperationContractReferrer.Orgs = orgs.([]*Org)
93 } 75 }
94 - if departmentId, ok := data["departmentId"]; ok {  
95 - cooperationContract.CooperationContractReferrer.Department.DepartmentId = departmentId.(int64)  
96 - }  
97 - if departmentName, ok := data["departmentName"]; ok {  
98 - cooperationContract.CooperationContractReferrer.Department.DepartmentName = departmentName.(string)  
99 - }  
100 - if departmentNumber, ok := data["departmentNumber"]; ok {  
101 - cooperationContract.CooperationContractReferrer.Department.DepartmentNumber = departmentNumber.(string)  
102 - }  
103 - if isOrganization, ok := data["isOrganization"]; ok {  
104 - cooperationContract.CooperationContractReferrer.Department.IsOrganization = isOrganization.(bool)  
105 - }  
106 - if roleId, ok := data["roleId"]; ok {  
107 - cooperationContract.CooperationContractReferrer.Role.RoleId = roleId.(int64)  
108 - }  
109 - if roleName, ok := data["roleName"]; ok {  
110 - cooperationContract.CooperationContractReferrer.Role.RoleName = roleName.(string)  
111 - }  
112 - if userAvatar, ok := data["userAvatar"]; ok {  
113 - cooperationContract.CooperationContractReferrer.UserInfo.UserAvatar = userAvatar.(string)  
114 - }  
115 - if userEmail, ok := data["userEmail"]; ok {  
116 - cooperationContract.CooperationContractReferrer.UserInfo.UserEmail = userEmail.(string)  
117 - }  
118 - if userName, ok := data["userName"]; ok {  
119 - cooperationContract.CooperationContractReferrer.UserInfo.UserName = userName.(string)  
120 - }  
121 - if userPhone, ok := data["userPhone"]; ok {  
122 - cooperationContract.CooperationContractReferrer.UserInfo.UserPhone = userPhone.(string)  
123 - }  
124 - if userAccount, ok := data["userAccount"]; ok {  
125 - cooperationContract.CooperationContractReferrer.UserInfo.UserAccount = userAccount.(string)  
126 - }  
127 - if userType, ok := data["userType"]; ok {  
128 - cooperationContract.CooperationContractReferrer.UserType = userType.(int32)  
129 - }  
130 if status, ok := data["status"]; ok { 76 if status, ok := data["status"]; ok {
131 cooperationContract.CooperationContractReferrer.Status = status.(int32) 77 cooperationContract.CooperationContractReferrer.Status = status.(int32)
132 } 78 }
133 if cooperationContractUndertakerType, ok := data["cooperationContractUndertakerType"]; ok { 79 if cooperationContractUndertakerType, ok := data["cooperationContractUndertakerType"]; ok {
134 cooperationContract.CooperationContractUndertakerType = cooperationContractUndertakerType.([]int32) 80 cooperationContract.CooperationContractUndertakerType = cooperationContractUndertakerType.([]int32)
135 } 81 }
136 - if cooperationModeId, ok := data["cooperationModeId"]; ok {  
137 - cooperationContract.CooperationMode.CooperationModeId = cooperationModeId.(int64)  
138 - }  
139 - if cooperationModeNumber, ok := data["cooperationModeNumber"]; ok {  
140 - cooperationContract.CooperationMode.CooperationModeNumber = cooperationModeNumber.(string)  
141 - }  
142 - if cooperationModeName, ok := data["cooperationModeName"]; ok {  
143 - cooperationContract.CooperationMode.CooperationModeName = cooperationModeName.(string)  
144 - }  
145 - if status, ok := data["status"]; ok {  
146 - cooperationContract.CooperationMode.Status = status.(int32)  
147 - }  
148 - if remarks, ok := data["remarks"]; ok {  
149 - cooperationContract.CooperationMode.Remarks = remarks.(string)  
150 - }  
151 - if operateTime, ok := data["operateTime"]; ok {  
152 - cooperationContract.CooperationMode.OperateTime = operateTime.(time.Time)  
153 - }  
154 - if updatedAt, ok := data["updatedAt"]; ok {  
155 - cooperationContract.CooperationMode.UpdatedAt = updatedAt.(time.Time)  
156 - }  
157 - if deletedAt, ok := data["deletedAt"]; ok {  
158 - cooperationContract.CooperationMode.DeletedAt = deletedAt.(time.Time)  
159 - }  
160 - if createdAt, ok := data["createdAt"]; ok {  
161 - cooperationContract.CooperationMode.CreatedAt = createdAt.(time.Time)  
162 - }  
163 if status, ok := data["status"]; ok { 82 if status, ok := data["status"]; ok {
164 cooperationContract.Status = status.(int32) 83 cooperationContract.Status = status.(int32)
165 } 84 }
166 if operateTime, ok := data["operateTime"]; ok { 85 if operateTime, ok := data["operateTime"]; ok {
167 cooperationContract.OperateTime = operateTime.(time.Time) 86 cooperationContract.OperateTime = operateTime.(time.Time)
168 } 87 }
169 - if createdAt, ok := data["createdAt"]; ok {  
170 - cooperationContract.CreatedAt = createdAt.(time.Time)  
171 - }  
172 - if deletedAt, ok := data["deletedAt"]; ok {  
173 - cooperationContract.DeletedAt = deletedAt.(time.Time)  
174 - }  
175 - if updatedAt, ok := data["updatedAt"]; ok {  
176 - cooperationContract.UpdatedAt = updatedAt.(time.Time)  
177 - }  
178 return nil 88 return nil
179 } 89 }
  1 +package domain
  2 +
  3 +import "time"
  4 +
  5 +// 共创合约变更日志
  6 +type CooperationContractChangeLog struct {
  7 + // 共创合约变更日志
  8 + CooperationContractChangeLogId int64 `json:"cooperationContractChangeLogId,string"`
  9 + // 激励规则
  10 + IncentivesRule string `json:"incentivesRule"`
  11 + // 激励规则明细
  12 + IncentivesRuleDetail string `json:"incentivesRuleDetail"`
  13 + // 合约变更操作类型,1编辑、2暂停、3恢复
  14 + OperationType int32 `json:"operationType"`
  15 + // 共创合约编号
  16 + CooperationContractNumber string `json:"cooperationContractNumber"`
  17 + // 承接人
  18 + Undertakers string `json:"undertakers"`
  19 + // 公司
  20 + Company *Company `json:"company"`
  21 + // 操作人
  22 + Operator *User `json:"operator"`
  23 + // 更新时间
  24 + UpdatedAt time.Time `json:"updatedAt"`
  25 + // 删除时间
  26 + DeletedAt time.Time `json:"deletedAt"`
  27 + // 创建时间
  28 + CreatedAt time.Time `json:"createdAt"`
  29 +}
  30 +
  31 +type CooperationContractChangeLogRepository interface {
  32 + Save(cooperationContractChangeLog *CooperationContractChangeLog) (*CooperationContractChangeLog, error)
  33 + Remove(cooperationContractChangeLog *CooperationContractChangeLog) (*CooperationContractChangeLog, error)
  34 + FindOne(queryOptions map[string]interface{}) (*CooperationContractChangeLog, error)
  35 + Find(queryOptions map[string]interface{}) (int64, []*CooperationContractChangeLog, error)
  36 +}
  37 +
  38 +func (cooperationContractChangeLog *CooperationContractChangeLog) Identify() interface{} {
  39 + if cooperationContractChangeLog.CooperationContractChangeLogId == 0 {
  40 + return nil
  41 + }
  42 + return cooperationContractChangeLog.CooperationContractChangeLogId
  43 +}
  44 +
  45 +func (cooperationContractChangeLog *CooperationContractChangeLog) Update(data map[string]interface{}) error {
  46 + if incentivesRule, ok := data["incentivesRule"]; ok {
  47 + cooperationContractChangeLog.IncentivesRule = incentivesRule.(string)
  48 + }
  49 + if incentivesRuleDetail, ok := data["incentivesRuleDetail"]; ok {
  50 + cooperationContractChangeLog.IncentivesRuleDetail = incentivesRuleDetail.(string)
  51 + }
  52 + if operationType, ok := data["operationType"]; ok {
  53 + cooperationContractChangeLog.OperationType = operationType.(int32)
  54 + }
  55 + if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
  56 + cooperationContractChangeLog.CooperationContractNumber = cooperationContractNumber.(string)
  57 + }
  58 + if undertakers, ok := data["undertakers"]; ok {
  59 + cooperationContractChangeLog.Undertakers = undertakers.(string)
  60 + }
  61 + if companyId, ok := data["companyId"]; ok {
  62 + cooperationContractChangeLog.Company.CompanyId = companyId.(int64)
  63 + }
  64 + if companyLogo, ok := data["companyLogo"]; ok {
  65 + cooperationContractChangeLog.Company.CompanyLogo = companyLogo.(string)
  66 + }
  67 + if companyName, ok := data["companyName"]; ok {
  68 + cooperationContractChangeLog.Company.CompanyName = companyName.(string)
  69 + }
  70 + if userId, ok := data["userId"]; ok {
  71 + cooperationContractChangeLog.Operator.UserId = userId.(int64)
  72 + }
  73 + if userBaseId, ok := data["userBaseId"]; ok {
  74 + cooperationContractChangeLog.Operator.UserBaseId = userBaseId.(int64)
  75 + }
  76 + if orgId, ok := data["orgId"]; ok {
  77 + cooperationContractChangeLog.Operator.Org.OrgId = orgId.(int64)
  78 + }
  79 + if orgName, ok := data["orgName"]; ok {
  80 + cooperationContractChangeLog.Operator.Org.OrgName = orgName.(string)
  81 + }
  82 + if departmentId, ok := data["departmentId"]; ok {
  83 + cooperationContractChangeLog.Operator.Department.DepartmentId = departmentId.(int64)
  84 + }
  85 + if departmentName, ok := data["departmentName"]; ok {
  86 + cooperationContractChangeLog.Operator.Department.DepartmentName = departmentName.(string)
  87 + }
  88 + if departmentNumber, ok := data["departmentNumber"]; ok {
  89 + cooperationContractChangeLog.Operator.Department.DepartmentNumber = departmentNumber.(string)
  90 + }
  91 + if roleId, ok := data["roleId"]; ok {
  92 + cooperationContractChangeLog.Operator.Role.RoleId = roleId.(int64)
  93 + }
  94 + if roleName, ok := data["roleName"]; ok {
  95 + cooperationContractChangeLog.Operator.Role.RoleName = roleName.(string)
  96 + }
  97 + if userAvatar, ok := data["userAvatar"]; ok {
  98 + cooperationContractChangeLog.Operator.UserInfo.UserAvatar = userAvatar.(string)
  99 + }
  100 + if userEmail, ok := data["userEmail"]; ok {
  101 + cooperationContractChangeLog.Operator.UserInfo.UserEmail = userEmail.(string)
  102 + }
  103 + if userName, ok := data["userName"]; ok {
  104 + cooperationContractChangeLog.Operator.UserInfo.UserName = userName.(string)
  105 + }
  106 + if userPhone, ok := data["userPhone"]; ok {
  107 + cooperationContractChangeLog.Operator.UserInfo.UserPhone = userPhone.(string)
  108 + }
  109 + if userAccount, ok := data["userAccount"]; ok {
  110 + cooperationContractChangeLog.Operator.UserInfo.UserAccount = userAccount.(string)
  111 + }
  112 + if userType, ok := data["userType"]; ok {
  113 + cooperationContractChangeLog.Operator.UserType = userType.(int32)
  114 + }
  115 + if status, ok := data["status"]; ok {
  116 + cooperationContractChangeLog.Operator.Status = status.(int32)
  117 + }
  118 + return nil
  119 +}
@@ -45,9 +45,6 @@ func (cooperationMode *CooperationMode) Identify() interface{} { @@ -45,9 +45,6 @@ func (cooperationMode *CooperationMode) Identify() interface{} {
45 } 45 }
46 46
47 func (cooperationMode *CooperationMode) Update(data map[string]interface{}) error { 47 func (cooperationMode *CooperationMode) Update(data map[string]interface{}) error {
48 - if cooperationModeId, ok := data["cooperationModeId"]; ok {  
49 - cooperationMode.CooperationModeId = cooperationModeId.(int64)  
50 - }  
51 if cooperationModeNumber, ok := data["cooperationModeNumber"]; ok { 48 if cooperationModeNumber, ok := data["cooperationModeNumber"]; ok {
52 cooperationMode.CooperationModeNumber = cooperationModeNumber.(string) 49 cooperationMode.CooperationModeNumber = cooperationModeNumber.(string)
53 } 50 }
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type ContractUndertakerFeedback struct { 8 type ContractUndertakerFeedback struct {
9 tableName string `comment:"承接人反馈信息" pg:"contract_undertaker_feedbacks,alias:contract_undertaker_feedback"` 9 tableName string `comment:"承接人反馈信息" pg:"contract_undertaker_feedbacks,alias:contract_undertaker_feedback"`
10 // 合约承接方反馈记录ID 10 // 合约承接方反馈记录ID
11 - FeedbackId int64 `comment:"合约承接方反馈记录ID" pg:",pk"` 11 + FeedbackId int64 `comment:"合约承接方反馈记录ID" pg:",pk:feedback_id"`
12 // 合约承接方反馈内容附件 12 // 合约承接方反馈内容附件
13 FeedbackAttachment []*domain.Attachment `comment:"合约承接方反馈内容附件"` 13 FeedbackAttachment []*domain.Attachment `comment:"合约承接方反馈内容附件"`
14 // 合约承接方反馈内容 14 // 合约承接方反馈内容
  1 +package models
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  5 + "time"
  6 +)
  7 +
  8 +type CooperationContractChangeLog struct {
  9 + tableName string `comment:"共创合约变更日志" pg:"cooperation_contract_change_logs,alias:cooperation_contract_change_log"`
  10 + // 共创合约变更记录id
  11 + CooperationContractChangeLogId int64 `comment:"共创合约变更记录id" pg:",pk:cooperation_contract_change_log_id"`
  12 + // 激励规则
  13 + IncentivesRule string `comment:"激励规则"`
  14 + // 激励规则明细
  15 + IncentivesRuleDetail string `comment:"激励规则明细"`
  16 + // 合约变更操作类型,1编辑、2暂停、3恢复
  17 + OperationType int32 `comment:"合约变更操作类型,1编辑、2暂停、3恢复"`
  18 + // 共创合约编号
  19 + CooperationContractNumber string `comment:"共创合约编号"`
  20 + // 承接人
  21 + Undertakers string `comment:"承接人"`
  22 + // 公司
  23 + Company *domain.Company `comment:"公司"`
  24 + // 操作人
  25 + Operator *domain.User `comment:"操作人"`
  26 + // 更新时间
  27 + UpdatedAt time.Time `comment:"更新时间"`
  28 + // 删除时间
  29 + DeletedAt time.Time `comment:"删除时间"`
  30 + // 创建时间
  31 + CreatedAt time.Time `comment:"创建时间"`
  32 +}
  1 +package transform
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
  6 +)
  7 +
  8 +func TransformToCooperationContractChangeLogDomainModelFromPgModels(cooperationContractChangeLogModel *models.CooperationContractChangeLog) (*domain.CooperationContractChangeLog, error) {
  9 + return &domain.CooperationContractChangeLog{
  10 + IncentivesRule: cooperationContractChangeLogModel.IncentivesRule,
  11 + IncentivesRuleDetail: cooperationContractChangeLogModel.IncentivesRuleDetail,
  12 + OperationType: cooperationContractChangeLogModel.OperationType,
  13 + CooperationContractNumber: cooperationContractChangeLogModel.CooperationContractNumber,
  14 + Undertakers: cooperationContractChangeLogModel.Undertakers,
  15 + Company: cooperationContractChangeLogModel.Company,
  16 + Operator: cooperationContractChangeLogModel.Operator,
  17 + UpdatedAt: cooperationContractChangeLogModel.UpdatedAt,
  18 + DeletedAt: cooperationContractChangeLogModel.DeletedAt,
  19 + CreatedAt: cooperationContractChangeLogModel.CreatedAt,
  20 + }, nil
  21 +}
  1 +package repository
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/go-pg/pg/v10"
  6 +
  7 + "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
  8 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  9 + "github.com/linmadan/egglib-go/utils/snowflake"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
  12 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/transform"
  13 +)
  14 +
  15 +type CooperationContractChangeLogRepository struct {
  16 + transactionContext *pgTransaction.TransactionContext
  17 +}
  18 +
  19 +func (repository *CooperationContractChangeLogRepository) nextIdentify() (int64, error) {
  20 + IdWorker, err := snowflake.NewIdWorker(1)
  21 + if err != nil {
  22 + return 0, err
  23 + }
  24 + id, err := IdWorker.NextId()
  25 + return id, err
  26 +}
  27 +func (repository *CooperationContractChangeLogRepository) Save(cooperationContractChangeLog *domain.CooperationContractChangeLog) (*domain.CooperationContractChangeLog, error) {
  28 + sqlBuildFields := []string{
  29 + "incentives_rule",
  30 + "incentives_rule_detail",
  31 + "operation_type",
  32 + "cooperation_contract_number",
  33 + "undertakers",
  34 + "company",
  35 + "operator",
  36 + "updated_at",
  37 + "deleted_at",
  38 + "created_at",
  39 + }
  40 + insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
  41 + insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields)
  42 + returningFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
  43 + updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "cooperationContractChangeLog_id")
  44 + updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
  45 + tx := repository.transactionContext.PgTx
  46 + if cooperationContractChangeLog.Identify() == nil {
  47 + cooperationContractChangeLogId, err := repository.nextIdentify()
  48 + if err != nil {
  49 + return cooperationContractChangeLog, err
  50 + } else {
  51 + cooperationContractChangeLog.CooperationContractChangeLogId = cooperationContractChangeLogId
  52 + }
  53 + if _, err := tx.QueryOne(
  54 + pg.Scan(
  55 + &cooperationContractChangeLog.IncentivesRule,
  56 + &cooperationContractChangeLog.IncentivesRuleDetail,
  57 + &cooperationContractChangeLog.OperationType,
  58 + &cooperationContractChangeLog.CooperationContractNumber,
  59 + &cooperationContractChangeLog.Undertakers,
  60 + &cooperationContractChangeLog.Company,
  61 + &cooperationContractChangeLog.Operator,
  62 + &cooperationContractChangeLog.UpdatedAt,
  63 + &cooperationContractChangeLog.DeletedAt,
  64 + &cooperationContractChangeLog.CreatedAt,
  65 + ),
  66 + fmt.Sprintf("INSERT INTO cooperation_contract_change_logs (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
  67 + cooperationContractChangeLog.IncentivesRule,
  68 + cooperationContractChangeLog.IncentivesRuleDetail,
  69 + cooperationContractChangeLog.OperationType,
  70 + cooperationContractChangeLog.CooperationContractNumber,
  71 + cooperationContractChangeLog.Undertakers,
  72 + cooperationContractChangeLog.Company,
  73 + cooperationContractChangeLog.Operator,
  74 + cooperationContractChangeLog.UpdatedAt,
  75 + cooperationContractChangeLog.DeletedAt,
  76 + cooperationContractChangeLog.CreatedAt,
  77 + ); err != nil {
  78 + return cooperationContractChangeLog, err
  79 + }
  80 + } else {
  81 + if _, err := tx.QueryOne(
  82 + pg.Scan(
  83 + &cooperationContractChangeLog.IncentivesRule,
  84 + &cooperationContractChangeLog.IncentivesRuleDetail,
  85 + &cooperationContractChangeLog.OperationType,
  86 + &cooperationContractChangeLog.CooperationContractNumber,
  87 + &cooperationContractChangeLog.Undertakers,
  88 + &cooperationContractChangeLog.Company,
  89 + &cooperationContractChangeLog.Operator,
  90 + &cooperationContractChangeLog.UpdatedAt,
  91 + &cooperationContractChangeLog.DeletedAt,
  92 + &cooperationContractChangeLog.CreatedAt,
  93 + ),
  94 + fmt.Sprintf("UPDATE cooperation_contract_change_logs SET %s WHERE cooperation_contract_change_log_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
  95 + cooperationContractChangeLog.IncentivesRule,
  96 + cooperationContractChangeLog.IncentivesRuleDetail,
  97 + cooperationContractChangeLog.OperationType,
  98 + cooperationContractChangeLog.CooperationContractNumber,
  99 + cooperationContractChangeLog.Undertakers,
  100 + cooperationContractChangeLog.Company,
  101 + cooperationContractChangeLog.Operator,
  102 + cooperationContractChangeLog.UpdatedAt,
  103 + cooperationContractChangeLog.DeletedAt,
  104 + cooperationContractChangeLog.CreatedAt,
  105 + cooperationContractChangeLog.Identify(),
  106 + ); err != nil {
  107 + return cooperationContractChangeLog, err
  108 + }
  109 + }
  110 + return cooperationContractChangeLog, nil
  111 +}
  112 +func (repository *CooperationContractChangeLogRepository) Remove(cooperationContractChangeLog *domain.CooperationContractChangeLog) (*domain.CooperationContractChangeLog, error) {
  113 + tx := repository.transactionContext.PgTx
  114 + cooperationContractChangeLogModel := new(models.CooperationContractChangeLog)
  115 + cooperationContractChangeLogModel.CooperationContractChangeLogId = cooperationContractChangeLog.Identify().(int64)
  116 + if _, err := tx.Model(cooperationContractChangeLogModel).WherePK().Delete(); err != nil {
  117 + return cooperationContractChangeLog, err
  118 + }
  119 + return cooperationContractChangeLog, nil
  120 +}
  121 +func (repository *CooperationContractChangeLogRepository) FindOne(queryOptions map[string]interface{}) (*domain.CooperationContractChangeLog, error) {
  122 + tx := repository.transactionContext.PgTx
  123 + cooperationContractChangeLogModel := new(models.CooperationContractChangeLog)
  124 + query := sqlbuilder.BuildQuery(tx.Model(cooperationContractChangeLogModel), queryOptions)
  125 + query.SetWhereByQueryOption("cooperation_contract_change_log.cooperation_contract_change_log_id = ?", "cooperationContractChangeLogId")
  126 + if err := query.First(); err != nil {
  127 + if err.Error() == "pg: no rows in result set" {
  128 + return nil, fmt.Errorf("没有此资源")
  129 + } else {
  130 + return nil, err
  131 + }
  132 + }
  133 + if cooperationContractChangeLogModel.CooperationContractChangeLogId == 0 {
  134 + return nil, nil
  135 + } else {
  136 + return transform.TransformToCooperationContractChangeLogDomainModelFromPgModels(cooperationContractChangeLogModel)
  137 + }
  138 +}
  139 +func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.CooperationContractChangeLog, error) {
  140 + tx := repository.transactionContext.PgTx
  141 + var cooperationContractChangeLogModels []*models.CooperationContractChangeLog
  142 + cooperationContractChangeLogs := make([]*domain.CooperationContractChangeLog, 0)
  143 + query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractChangeLogModels), queryOptions)
  144 + query.SetOffsetAndLimit(20)
  145 + query.SetOrderDirect("cooperation_contract_change_log_id", "DESC")
  146 + if count, err := query.SelectAndCount(); err != nil {
  147 + return 0, cooperationContractChangeLogs, err
  148 + } else {
  149 + for _, cooperationContractChangeLogModel := range cooperationContractChangeLogModels {
  150 + if cooperationContractChangeLog, err := transform.TransformToCooperationContractChangeLogDomainModelFromPgModels(cooperationContractChangeLogModel); err != nil {
  151 + return 0, cooperationContractChangeLogs, err
  152 + } else {
  153 + cooperationContractChangeLogs = append(cooperationContractChangeLogs, cooperationContractChangeLog)
  154 + }
  155 + }
  156 + return int64(count), cooperationContractChangeLogs, nil
  157 + }
  158 +}
  159 +func NewCooperationContractChangeLogRepository(transactionContext *pgTransaction.TransactionContext) (*CooperationContractChangeLogRepository, error) {
  160 + if transactionContext == nil {
  161 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  162 + } else {
  163 + return &CooperationContractChangeLogRepository{
  164 + transactionContext: transactionContext,
  165 + }, nil
  166 + }
  167 +}
  1 +package controllers
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/web/beego"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/query"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/service"
  8 +)
  9 +
  10 +type CooperationContractController struct {
  11 + beego.BaseController
  12 +}
  13 +
  14 +func (controller *CooperationContractController) CreateCooperationContract() {
  15 + cooperationContractService := service.NewCooperationContractService(nil)
  16 + createCooperationContractCommand := &command.CreateCooperationContractCommand{}
  17 + controller.Unmarshal(createCooperationContractCommand)
  18 + data, err := cooperationContractService.CreateCooperationContract(createCooperationContractCommand)
  19 + controller.Response(data, err)
  20 +}
  21 +
  22 +func (controller *CooperationContractController) UpdateCooperationContract() {
  23 + cooperationContractService := service.NewCooperationContractService(nil)
  24 + updateCooperationContractCommand := &command.UpdateCooperationContractCommand{}
  25 + controller.Unmarshal(updateCooperationContractCommand)
  26 + cooperationContractId := controller.GetString(":cooperationContractId")
  27 + updateCooperationContractCommand.CooperationContractId = cooperationContractId
  28 + data, err := cooperationContractService.UpdateCooperationContract(updateCooperationContractCommand)
  29 + controller.Response(data, err)
  30 +}
  31 +
  32 +func (controller *CooperationContractController) GetCooperationContract() {
  33 + cooperationContractService := service.NewCooperationContractService(nil)
  34 + getCooperationContractQuery := &query.GetCooperationContractQuery{}
  35 + cooperationContractId, _ := controller.GetInt64(":cooperationContractId")
  36 + getCooperationContractQuery.CooperationContractId = cooperationContractId
  37 + data, err := cooperationContractService.GetCooperationContract(getCooperationContractQuery)
  38 + controller.Response(data, err)
  39 +}
  40 +
  41 +func (controller *CooperationContractController) RemoveCooperationContract() {
  42 + cooperationContractService := service.NewCooperationContractService(nil)
  43 + removeCooperationContractCommand := &command.RemoveCooperationContractCommand{}
  44 + controller.Unmarshal(removeCooperationContractCommand)
  45 + cooperationContractId, _ := controller.GetInt64(":cooperationContractId")
  46 + removeCooperationContractCommand.CooperationContractId = cooperationContractId
  47 + data, err := cooperationContractService.RemoveCooperationContract(removeCooperationContractCommand)
  48 + controller.Response(data, err)
  49 +}
  50 +
  51 +func (controller *CooperationContractController) SearchCooperationContract() {
  52 + cooperationContractService := service.NewCooperationContractService(nil)
  53 + searchCooperationContractQuery := &query.SearchCooperationContractQuery{}
  54 + data, err := cooperationContractService.SearchCooperationContract(searchCooperationContractQuery)
  55 + controller.Response(data, err)
  56 +}
  57 +
  58 +func (controller *CooperationContractController) SearchCooperationContractByUndertaker() {
  59 + cooperationContractService := service.NewCooperationContractService(nil)
  60 + searchCooperationContractByUndertakerQuery := &query.SearchCooperationContractByUndertakerQuery{}
  61 + data, err := cooperationContractService.SearchCooperationContractByUndertaker(searchCooperationContractByUndertakerQuery)
  62 + controller.Response(data, err)
  63 +}
  64 +
  65 +func (controller *CooperationContractController) ListCooperationContract() {
  66 + cooperationContractService := service.NewCooperationContractService(nil)
  67 + listCooperationContractQuery := &query.ListCooperationContractQuery{}
  68 + offset, _ := controller.GetInt("offset")
  69 + listCooperationContractQuery.Offset = offset
  70 + limit, _ := controller.GetInt("limit")
  71 + listCooperationContractQuery.Limit = limit
  72 + data, err := cooperationContractService.ListCooperationContract(listCooperationContractQuery)
  73 + controller.Response(data, err)
  74 +}
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/server/web"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego/controllers"
  6 +)
  7 +
  8 +func init() {
  9 + web.Router("/cooperation-contracts/", &controllers.CooperationContractController{}, "Post:CreateCooperationContract")
  10 + web.Router("/cooperation-contracts/:cooperationContractId", &controllers.CooperationContractController{}, "Put:UpdateCooperationContract")
  11 + web.Router("/cooperation-contracts/:cooperationContractId", &controllers.CooperationContractController{}, "Get:GetCooperationContract")
  12 + web.Router("/cooperation-contracts/:cooperationContractId", &controllers.CooperationContractController{}, "Delete:RemoveCooperationContract")
  13 + web.Router("/cooperation-contracts/search", &controllers.CooperationContractController{}, "Post:SearchCooperationContract")
  14 + web.Router("/cooperation-contracts/search-by-undertaker", &controllers.CooperationContractController{}, "Post:SearchCooperationContractByUndertaker")
  15 + web.Router("/cooperation-contracts/", &controllers.CooperationContractController{}, "Get:ListCooperationContract")
  16 +}
1 package cooperation_application 1 package cooperation_application
2 2
3 import ( 3 import (
  4 + "github.com/go-pg/pg/v10"
4 "net/http" 5 "net/http"
5 6
6 "github.com/gavv/httpexpect" 7 "github.com/gavv/httpexpect"
1 package cooperation_application 1 package cooperation_application
2 2
3 import ( 3 import (
  4 + "github.com/go-pg/pg/v10"
4 "net/http" 5 "net/http"
5 6
6 "github.com/gavv/httpexpect" 7 "github.com/gavv/httpexpect"
1 package cooperation_application 1 package cooperation_application
2 2
3 import ( 3 import (
  4 + "github.com/go-pg/pg/v10"
4 "net/http" 5 "net/http"
5 6
6 "github.com/gavv/httpexpect" 7 "github.com/gavv/httpexpect"
1 package cooperation_application 1 package cooperation_application
2 2
3 import ( 3 import (
  4 + "github.com/go-pg/pg/v10"
4 "net/http" 5 "net/http"
5 6
6 "github.com/gavv/httpexpect" 7 "github.com/gavv/httpexpect"
1 package cooperation_application 1 package cooperation_application
2 2
3 import ( 3 import (
  4 + "github.com/go-pg/pg/v10"
4 "net/http" 5 "net/http"
5 6
6 "github.com/gavv/httpexpect" 7 "github.com/gavv/httpexpect"
1 package cooperation_application 1 package cooperation_application
2 2
3 import ( 3 import (
  4 + "github.com/go-pg/pg/v10"
4 "net/http" 5 "net/http"
5 6
6 "github.com/gavv/httpexpect" 7 "github.com/gavv/httpexpect"
1 package cooperation_application 1 package cooperation_application
2 2
3 import ( 3 import (
  4 + "github.com/go-pg/pg/v10"
4 "net/http" 5 "net/http"
5 6
6 "github.com/gavv/httpexpect" 7 "github.com/gavv/httpexpect"
1 package cooperation_application 1 package cooperation_application
2 2
3 import ( 3 import (
  4 + "github.com/go-pg/pg/v10"
4 "net/http" 5 "net/http"
5 6
6 "github.com/gavv/httpexpect" 7 "github.com/gavv/httpexpect"
  1 +package cooperation_contract
  2 +
  3 +import (
  4 + "net/http"
  5 + "net/http/httptest"
  6 + "testing"
  7 +
  8 + "github.com/beego/beego/v2/server/web"
  9 + . "github.com/onsi/ginkgo"
  10 + . "github.com/onsi/gomega"
  11 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application"
  12 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  13 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego"
  14 +)
  15 +
  16 +func TestCooperationContract(t *testing.T) {
  17 + RegisterFailHandler(Fail)
  18 + RunSpecs(t, "Beego Port CooperationContract Correlations Test Case Suite")
  19 +}
  20 +
  21 +var handler http.Handler
  22 +var server *httptest.Server
  23 +
  24 +var _ = BeforeSuite(func() {
  25 + handler = web.BeeApp.Handlers
  26 + server = httptest.NewServer(handler)
  27 +})
  28 +
  29 +var _ = AfterSuite(func() {
  30 + server.Close()
  31 +})
  1 +package cooperation_contract
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/gavv/httpexpect"
  7 + . "github.com/onsi/ginkgo"
  8 + . "github.com/onsi/gomega"
  9 + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  10 +)
  11 +
  12 +var _ = Describe("创建共创合约服务", func() {
  13 + Describe("提交数据创建共创合约服务", func() {
  14 + Context("提交正确的新共创项目合约实体数据", func() {
  15 + It("返回共创项目合约实体数据", func() {
  16 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  17 + body := map[string]interface{}{
  18 + "cooperationContractDescription": "string",
  19 + "cooperationContractNumber": "string",
  20 + "cooperationProjectNumber": "string",
  21 + "departmentNumber": "string",
  22 + "cooperationContractUndertakerType": "array",
  23 + "cooperationContractName": "string",
  24 + "cooperationModeNumber": "string",
  25 + "sponsorUid": "string",
  26 + "dividendsIncentivesRules": "array",
  27 + "moneyIncentivesRules": "array",
  28 + "undertakers": "array",
  29 + "relevants": "array",
  30 + "companyId": "int64",
  31 + "orgId": "int64",
  32 + "userId": "int64",
  33 + }
  34 + httpExpect.POST("/cooperation-contracts/").
  35 + WithJSON(body).
  36 + Expect().
  37 + Status(http.StatusOK).
  38 + JSON().
  39 + Object().
  40 + ContainsKey("code").ValueEqual("code", 0).
  41 + ContainsKey("msg").ValueEqual("msg", "ok").
  42 + ContainsKey("data").Value("data").Object().
  43 + ContainsKey("cooperationContractId").ValueNotEqual("cooperationContractId", BeZero())
  44 + })
  45 + })
  46 + })
  47 + AfterEach(func() {
  48 + _, err := pG.DB.Exec("DELETE FROM cooperation_contracts WHERE true")
  49 + Expect(err).NotTo(HaveOccurred())
  50 + })
  51 +})
  1 +package cooperation_contract
  2 +
  3 +import (
  4 + "github.com/go-pg/pg/v10"
  5 + "net/http"
  6 +
  7 + "github.com/gavv/httpexpect"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("返回共创合约服务", func() {
  14 + var cooperationContractId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&cooperationContractId),
  18 + "INSERT INTO cooperation_contracts (cooperation_contract_id, cooperation_contract_description, cooperation_contract_name, cooperation_contract_number, cooperation_contract_referrer, cooperation_contract_salesman, cooperation_contract_undertaker_type, cooperation_contract_sponsor, cooperation_mode, status, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_id",
  19 + "testCooperationContractId", "testCooperationContractDescription", "testCooperationContractName", "testCooperationContractNumber", "testCooperationContractReferrer", "testCooperationContractSalesman", "testCooperationContractUndertakerType", "testCooperationContractSponsor", "testCooperationMode", "testStatus", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("根据cooperationContractId参数返回共创项目合约实体", func() {
  23 + Context("传入有效的cooperationContractId", func() {
  24 + It("返回共创项目合约实体数据", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + httpExpect.GET("/cooperation-contracts/{cooperationContractId}").
  27 + Expect().
  28 + Status(http.StatusOK).
  29 + JSON().
  30 + Object().
  31 + ContainsKey("code").ValueEqual("code", 0).
  32 + ContainsKey("msg").ValueEqual("msg", "ok").
  33 + ContainsKey("data").Value("data").Object()
  34 + })
  35 + })
  36 + })
  37 + AfterEach(func() {
  38 + _, err := pG.DB.Exec("DELETE FROM cooperation_contracts WHERE true")
  39 + Expect(err).NotTo(HaveOccurred())
  40 + })
  41 +})
  1 +package cooperation_contract
  2 +
  3 +import (
  4 + "github.com/go-pg/pg/v10"
  5 + "net/http"
  6 +
  7 + "github.com/gavv/httpexpect"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("返回共创合约服务列表", func() {
  14 + var cooperationContractId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&cooperationContractId),
  18 + "INSERT INTO cooperation_contracts (cooperation_contract_id, cooperation_contract_description, cooperation_contract_name, cooperation_contract_number, cooperation_contract_referrer, cooperation_contract_salesman, cooperation_contract_undertaker_type, cooperation_contract_sponsor, cooperation_mode, status, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_id",
  19 + "testCooperationContractId", "testCooperationContractDescription", "testCooperationContractName", "testCooperationContractNumber", "testCooperationContractReferrer", "testCooperationContractSalesman", "testCooperationContractUndertakerType", "testCooperationContractSponsor", "testCooperationMode", "testStatus", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("根据参数返回共创项目合约实体列表", func() {
  23 + Context("传入有效的参数", func() {
  24 + It("返回共创项目合约实体数据列表", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + httpExpect.GET("/cooperation-contracts/").
  27 + WithQuery("offset", "int").
  28 + WithQuery("limit", "int").
  29 + Expect().
  30 + Status(http.StatusOK).
  31 + JSON().
  32 + Object().
  33 + ContainsKey("code").ValueEqual("code", 0).
  34 + ContainsKey("msg").ValueEqual("msg", "ok").
  35 + ContainsKey("data").Value("data").Object().
  36 + ContainsKey("count").ValueEqual("count", 1).
  37 + ContainsKey("cooperationContracts").Value("cooperationContracts").Array()
  38 + })
  39 + })
  40 + })
  41 + AfterEach(func() {
  42 + _, err := pG.DB.Exec("DELETE FROM cooperation_contracts WHERE true")
  43 + Expect(err).NotTo(HaveOccurred())
  44 + })
  45 +})
  1 +package cooperation_contract
  2 +
  3 +import (
  4 + "github.com/go-pg/pg/v10"
  5 + "net/http"
  6 +
  7 + "github.com/gavv/httpexpect"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("移除共创合约服务", func() {
  14 + var cooperationContractId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&cooperationContractId),
  18 + "INSERT INTO cooperation_contracts (cooperation_contract_id, cooperation_contract_description, cooperation_contract_name, cooperation_contract_number, cooperation_contract_referrer, cooperation_contract_salesman, cooperation_contract_undertaker_type, cooperation_contract_sponsor, cooperation_mode, status, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_id",
  19 + "testCooperationContractId", "testCooperationContractDescription", "testCooperationContractName", "testCooperationContractNumber", "testCooperationContractReferrer", "testCooperationContractSalesman", "testCooperationContractUndertakerType", "testCooperationContractSponsor", "testCooperationMode", "testStatus", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("根据参数移除共创合约服务", func() {
  23 + Context("传入有效的cooperationContractId", func() {
  24 + It("返回被移除共创项目合约实体的数据", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + httpExpect.DELETE("/cooperation-contracts/{cooperationContractId}").
  27 + Expect().
  28 + Status(http.StatusOK).
  29 + JSON().
  30 + Object().
  31 + ContainsKey("code").ValueEqual("code", 0).
  32 + ContainsKey("msg").ValueEqual("msg", "ok").
  33 + ContainsKey("data").Value("data").Object()
  34 + })
  35 + })
  36 + })
  37 + AfterEach(func() {
  38 + _, err := pG.DB.Exec("DELETE FROM cooperation_contracts WHERE true")
  39 + Expect(err).NotTo(HaveOccurred())
  40 + })
  41 +})
  1 +package cooperation_contract
  2 +
  3 +import (
  4 + "github.com/go-pg/pg/v10"
  5 + "net/http"
  6 +
  7 + "github.com/gavv/httpexpect"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("根据承接人返回共创项目合约", func() {
  14 + var cooperationContractId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&cooperationContractId),
  18 + "INSERT INTO cooperation_contracts (cooperation_contract_id, cooperation_contract_description, cooperation_contract_name, cooperation_contract_number, cooperation_contract_referrer, cooperation_contract_salesman, cooperation_contract_undertaker_type, cooperation_contract_sponsor, cooperation_mode, status, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_id",
  19 + "testCooperationContractId", "testCooperationContractDescription", "testCooperationContractName", "testCooperationContractNumber", "testCooperationContractReferrer", "testCooperationContractSalesman", "testCooperationContractUndertakerType", "testCooperationContractSponsor", "testCooperationMode", "testStatus", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("根据承接人返回共创项目合约", func() {
  23 + Context("", func() {
  24 + It("", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + body := map[string]interface{}{
  27 + "cooperationContractName": "string",
  28 + "sponsorName": "string",
  29 + "companyId": "int64",
  30 + "orgId": "int64",
  31 + "userId": "int64",
  32 + }
  33 + httpExpect.POST("/cooperation-contracts/search-by-undertaker").
  34 + WithJSON(body).
  35 + Expect().
  36 + Status(http.StatusOK).
  37 + JSON().
  38 + Object().
  39 + ContainsKey("code").ValueEqual("code", 0).
  40 + ContainsKey("msg").ValueEqual("msg", "ok").
  41 + ContainsKey("data").Value("data").Object()
  42 + })
  43 + })
  44 + })
  45 + AfterEach(func() {
  46 + _, err := pG.DB.Exec("DELETE FROM cooperation_contracts WHERE true")
  47 + Expect(err).NotTo(HaveOccurred())
  48 + })
  49 +})
  1 +package cooperation_contract
  2 +
  3 +import (
  4 + "github.com/go-pg/pg/v10"
  5 + "net/http"
  6 +
  7 + "github.com/gavv/httpexpect"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("查询共创合约", func() {
  14 + var cooperationContractId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&cooperationContractId),
  18 + "INSERT INTO cooperation_contracts (cooperation_contract_id, cooperation_contract_description, cooperation_contract_name, cooperation_contract_number, cooperation_contract_referrer, cooperation_contract_salesman, cooperation_contract_undertaker_type, cooperation_contract_sponsor, cooperation_mode, status, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_id",
  19 + "testCooperationContractId", "testCooperationContractDescription", "testCooperationContractName", "testCooperationContractNumber", "testCooperationContractReferrer", "testCooperationContractSalesman", "testCooperationContractUndertakerType", "testCooperationContractSponsor", "testCooperationMode", "testStatus", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("查询共创合约", func() {
  23 + Context("", func() {
  24 + It("", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + body := map[string]interface{}{
  27 + "pageSize": "int32",
  28 + "pageNumber": "int32",
  29 + "cooperationContractNumber": "string",
  30 + "sponsorName": "string",
  31 + "companyId": "int64",
  32 + "orgId": "int64",
  33 + "userId": "int64",
  34 + }
  35 + httpExpect.POST("/cooperation-contracts/search").
  36 + WithJSON(body).
  37 + Expect().
  38 + Status(http.StatusOK).
  39 + JSON().
  40 + Object().
  41 + ContainsKey("code").ValueEqual("code", 0).
  42 + ContainsKey("msg").ValueEqual("msg", "ok").
  43 + ContainsKey("data").Value("data").Object()
  44 + })
  45 + })
  46 + })
  47 + AfterEach(func() {
  48 + _, err := pG.DB.Exec("DELETE FROM cooperation_contracts WHERE true")
  49 + Expect(err).NotTo(HaveOccurred())
  50 + })
  51 +})
  1 +package cooperation_contract
  2 +
  3 +import (
  4 + "github.com/go-pg/pg/v10"
  5 + "net/http"
  6 +
  7 + "github.com/gavv/httpexpect"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("更新共创合约服务", func() {
  14 + var cooperationContractId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&cooperationContractId),
  18 + "INSERT INTO cooperation_contracts (cooperation_contract_id, cooperation_contract_description, cooperation_contract_name, cooperation_contract_number, cooperation_contract_referrer, cooperation_contract_salesman, cooperation_contract_undertaker_type, cooperation_contract_sponsor, cooperation_mode, status, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_id",
  19 + "testCooperationContractId", "testCooperationContractDescription", "testCooperationContractName", "testCooperationContractNumber", "testCooperationContractReferrer", "testCooperationContractSalesman", "testCooperationContractUndertakerType", "testCooperationContractSponsor", "testCooperationMode", "testStatus", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("提交数据更新共创合约服务", func() {
  23 + Context("提交正确的共创项目合约实体数据", func() {
  24 + It("返回更新后的共创项目合约实体数据", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + body := map[string]interface{}{
  27 + "cooperationContractDescription": "string",
  28 + "cooperationContractNumber": "string",
  29 + "cooperationProjectNumber": "string",
  30 + "departmentNumber": "string",
  31 + "cooperationContractUndertakerType": "array",
  32 + "cooperationContractName": "string",
  33 + "cooperationModeNumber": "string",
  34 + "sponsorUid": "string",
  35 + "companyId": "int64",
  36 + "orgId": "int64",
  37 + "userId": "int64",
  38 + }
  39 + httpExpect.PUT("/cooperation-contracts/{cooperationContractId}").
  40 + WithJSON(body).
  41 + Expect().
  42 + Status(http.StatusOK).
  43 + JSON().
  44 + Object().
  45 + ContainsKey("code").ValueEqual("code", 0).
  46 + ContainsKey("msg").ValueEqual("msg", "ok").
  47 + ContainsKey("data").Value("data").Object().
  48 + ContainsKey("cooperationContractId").ValueEqual("cooperationContractId", cooperationContractId)
  49 + })
  50 + })
  51 + })
  52 + AfterEach(func() {
  53 + _, err := pG.DB.Exec("DELETE FROM cooperation_contracts WHERE true")
  54 + Expect(err).NotTo(HaveOccurred())
  55 + })
  56 +})