作者 陈志颖

feat:添加共创申请管理功能

正在显示 22 个修改的文件 包含 1352 行增加0 行删除
  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 AgreeCooperationApplicationCommand struct {
  12 + // 共创申请ID
  13 + CooperationApplicationId int64 `cname:"共创申请ID" json:"cooperationApplicationId,string" valid:"Required"`
  14 + // 共创申请审核描述
  15 + CooperationApplicationVerifyDescription string `cname:"共创申请审核描述" json:"cooperationApplicationVerifyDescription" 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 + // 菜单编码,APP端必须
  21 + Code string `cname:"菜单编码,APP端必须" json:"code" valid:"Required"`
  22 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  23 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  24 +}
  25 +
  26 +func (agreeCooperationApplicationCommand *AgreeCooperationApplicationCommand) Valid(validation *validation.Validation) {
  27 + validation.SetError("CustomValid", "未实现的自定义认证")
  28 +}
  29 +
  30 +func (agreeCooperationApplicationCommand *AgreeCooperationApplicationCommand) ValidateCommand() error {
  31 + valid := validation.Validation{}
  32 + b, err := valid.Valid(agreeCooperationApplicationCommand)
  33 + if err != nil {
  34 + return err
  35 + }
  36 + if !b {
  37 + elem := reflect.TypeOf(agreeCooperationApplicationCommand).Elem()
  38 + for _, validErr := range valid.Errors {
  39 + field, isExist := elem.FieldByName(validErr.Field)
  40 + if isExist {
  41 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  42 + } else {
  43 + return fmt.Errorf(validErr.Message)
  44 + }
  45 + }
  46 + }
  47 + return nil
  48 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  6 + "reflect"
  7 + "strings"
  8 + "time"
  9 +
  10 + "github.com/beego/beego/v2/core/validation"
  11 +)
  12 +
  13 +type ApplyForCooperationCommand struct {
  14 + // 共创申请描述附件
  15 + CooperationApplicationAttachment []*domain.Attachment `cname:"共创申请描述附件" json:"cooperationApplicationAttachment" valid:"Required"`
  16 + // 共创申请描述
  17 + CooperationApplicationDescription string `cname:"共创申请描述" json:"cooperationApplicationDescription" valid:"Required"`
  18 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  19 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  20 + // 用户基本id
  21 + UserBaseId int64 `cname:"用户基本id" json:"userBaseId,string" valid:"Required"`
  22 + // 组织机构ID
  23 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  24 + // 组织名称
  25 + OrgName string `cname:"组织名称" json:"orgName" valid:"Required"`
  26 + // 公司ID,通过集成REST上下文获取
  27 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  28 + // 公司logo
  29 + CompanyLogo string `cname:"公司logo" json:"companyLogo" valid:"Required"`
  30 + // 公司名称
  31 + CompanyName string `cname:"公司名称" json:"companyName" valid:"Required"`
  32 + // 用户关联的组织机构
  33 + Orgs []*domain.Org `cname:"用户关联的组织机构" json:"orgs" valid:"Required"`
  34 + // 部门ID,通过REST集成上下文获取
  35 + DepartmentId int64 `cname:"部门ID,通过REST集成上下文获取" json:"departmentId,string" valid:"Required"`
  36 + // 部门名称
  37 + DepartmentName string `cname:"部门名称" json:"departmentName" valid:"Required"`
  38 + // 部门编码
  39 + DepartmentNumber string `cname:"部门编码" json:"departmentNumber" valid:"Required"`
  40 + // 是否组织机构标识,1为是,2为否,默认为否
  41 + IsOrganization bool `cname:"是否组织机构标识,1为是,2为否,默认为否" json:"isOrganization" valid:"Required"`
  42 + // 角色ID
  43 + RoleId int64 `cname:"角色ID" json:"roleId,string" valid:"Required"`
  44 + // 角色名称
  45 + RoleName string `cname:"角色名称" json:"roleName" valid:"Required"`
  46 + // 用户头像
  47 + UserAvatar string `cname:"用户头像" json:"userAvatar" valid:"Required"`
  48 + // 用户邮箱
  49 + UserEmail string `cname:"用户邮箱" json:"userEmail" valid:"Required"`
  50 + // 共创人员姓名
  51 + UserName string `cname:"共创人员姓名" json:"userName" valid:"Required"`
  52 + // 用户手机号
  53 + UserPhone string `cname:"用户手机号" json:"userPhone" valid:"Required"`
  54 + // 用户账号,区别于手机号,冗余字段
  55 + UserAccount string `cname:"用户账号,区别于手机号,冗余字段" json:"userAccount" valid:"Required"`
  56 + // 用户类型
  57 + UserType int32 `cname:"用户类型" json:"userType" valid:"Required"`
  58 + // 状态
  59 + Status int32 `cname:"状态" json:"status" valid:"Required"`
  60 + // 共创申请ID
  61 + CooperationApplicationId int64 `cname:"共创申请ID" json:"cooperationApplicationId,string" valid:"Required"`
  62 + // 共创项目编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001
  63 + CooperationProjectNumber string `cname:"共创项目编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001" json:"cooperationProjectNumber" valid:"Required"`
  64 + // 共创申请时间
  65 + CooperationApplyTime time.Time `cname:"共创申请时间" json:"cooperationApplyTime" valid:"Required"`
  66 +}
  67 +
  68 +func (applyForCooperationCommand *ApplyForCooperationCommand) Valid(validation *validation.Validation) {
  69 + validation.SetError("CustomValid", "未实现的自定义认证")
  70 +}
  71 +
  72 +func (applyForCooperationCommand *ApplyForCooperationCommand) ValidateCommand() error {
  73 + valid := validation.Validation{}
  74 + b, err := valid.Valid(applyForCooperationCommand)
  75 + if err != nil {
  76 + return err
  77 + }
  78 + if !b {
  79 + elem := reflect.TypeOf(applyForCooperationCommand).Elem()
  80 + for _, validErr := range valid.Errors {
  81 + field, isExist := elem.FieldByName(validErr.Field)
  82 + if isExist {
  83 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  84 + } else {
  85 + return fmt.Errorf(validErr.Message)
  86 + }
  87 + }
  88 + }
  89 + return nil
  90 +}
  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 CreateCooperationApplicationCommand struct {
  13 + // 共创申请人uid
  14 + ApplicantUid string `cname:"共创申请人uid" json:"applicantUid" valid:"Required"`
  15 + // 共创申请描述
  16 + CooperationApplicationDescription string `cname:"共创申请描述" json:"cooperationApplicationDescription,omitempty"`
  17 + // 共创申请描述附件
  18 + CooperationApplicationAttachment []*domain.Attachment `cname:"共创申请描述附件" json:"cooperationApplicationAttachment,omitempty"`
  19 + // 关联的共创项目编号
  20 + CooperationProjectNumber string `cname:"关联的共创项目编号" json:"cooperationProjectNumber" valid:"Required"`
  21 + // 公司ID,通过集成REST上下文获取
  22 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  23 + // 组织机构ID
  24 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  25 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  26 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  27 +}
  28 +
  29 +func (createCooperationApplicationCommand *CreateCooperationApplicationCommand) Valid(validation *validation.Validation) {
  30 + validation.SetError("CustomValid", "未实现的自定义认证")
  31 +}
  32 +
  33 +func (createCooperationApplicationCommand *CreateCooperationApplicationCommand) ValidateCommand() error {
  34 + valid := validation.Validation{}
  35 + b, err := valid.Valid(createCooperationApplicationCommand)
  36 + if err != nil {
  37 + return err
  38 + }
  39 + if !b {
  40 + elem := reflect.TypeOf(createCooperationApplicationCommand).Elem()
  41 + for _, validErr := range valid.Errors {
  42 + field, isExist := elem.FieldByName(validErr.Field)
  43 + if isExist {
  44 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  45 + } else {
  46 + return fmt.Errorf(validErr.Message)
  47 + }
  48 + }
  49 + }
  50 + return nil
  51 +}
  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 RejectCooperationApplicationCommand struct {
  12 + // 共创申请ID
  13 + CooperationApplicationId int64 `cname:"共创申请ID" json:"cooperationApplicationId,string" valid:"Required"`
  14 + // 共创申请审核描述
  15 + CooperationApplicationVerifyDescription string `cname:"共创申请审核描述" json:"cooperationApplicationVerifyDescription" 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 + // 菜单模块编码,APP端必须
  21 + Code string `cname:"菜单模块编码,APP端必须" json:"code" valid:"Required"`
  22 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  23 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  24 +}
  25 +
  26 +func (rejectCooperationApplicationCommand *RejectCooperationApplicationCommand) Valid(validation *validation.Validation) {
  27 + validation.SetError("CustomValid", "未实现的自定义认证")
  28 +}
  29 +
  30 +func (rejectCooperationApplicationCommand *RejectCooperationApplicationCommand) ValidateCommand() error {
  31 + valid := validation.Validation{}
  32 + b, err := valid.Valid(rejectCooperationApplicationCommand)
  33 + if err != nil {
  34 + return err
  35 + }
  36 + if !b {
  37 + elem := reflect.TypeOf(rejectCooperationApplicationCommand).Elem()
  38 + for _, validErr := range valid.Errors {
  39 + field, isExist := elem.FieldByName(validErr.Field)
  40 + if isExist {
  41 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  42 + } else {
  43 + return fmt.Errorf(validErr.Message)
  44 + }
  45 + }
  46 + }
  47 + return nil
  48 +}
  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 RemoveCooperationApplicationCommand struct {
  12 + // 共创申请ID
  13 + CooperationApplicationId int64 `cname:"共创申请ID" json:"cooperationApplicationId,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 (removeCooperationApplicationCommand *RemoveCooperationApplicationCommand) Valid(validation *validation.Validation) {
  23 + validation.SetError("CustomValid", "未实现的自定义认证")
  24 +}
  25 +
  26 +func (removeCooperationApplicationCommand *RemoveCooperationApplicationCommand) ValidateCommand() error {
  27 + valid := validation.Validation{}
  28 + b, err := valid.Valid(removeCooperationApplicationCommand)
  29 + if err != nil {
  30 + return err
  31 + }
  32 + if !b {
  33 + elem := reflect.TypeOf(removeCooperationApplicationCommand).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 + "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 UpdateCooperationApplicationCommand struct {
  13 + // 共创申请id
  14 + CooperationApplicationId string `cname:"共创申请id" json:"cooperationApplicationId" valid:"Required"`
  15 + // 共创申请人uid
  16 + ApplicantUid string `cname:"共创申请人uid" json:"applicantUid" valid:"Required"`
  17 + // 共创申请描述
  18 + CooperationApplicationDescription string `cname:"共创申请描述" json:"cooperationApplicationDescription,omitempty"`
  19 + // 共创申请描述附件
  20 + CooperationApplicationAttachment []*domain.Attachment `cname:"共创申请描述附件" json:"cooperationApplicationAttachment,omitempty"`
  21 + // 关联的共创项目编号
  22 + CooperationProjectNumber string `cname:"关联的共创项目编号" json:"cooperationProjectNumber" valid:"Required"`
  23 + // 公司ID,通过集成REST上下文获取
  24 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  25 + // 组织机构ID
  26 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  27 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  28 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  29 +}
  30 +
  31 +func (updateCooperationApplicationCommand *UpdateCooperationApplicationCommand) Valid(validation *validation.Validation) {
  32 + validation.SetError("CustomValid", "未实现的自定义认证")
  33 +}
  34 +
  35 +func (updateCooperationApplicationCommand *UpdateCooperationApplicationCommand) ValidateCommand() error {
  36 + valid := validation.Validation{}
  37 + b, err := valid.Valid(updateCooperationApplicationCommand)
  38 + if err != nil {
  39 + return err
  40 + }
  41 + if !b {
  42 + elem := reflect.TypeOf(updateCooperationApplicationCommand).Elem()
  43 + for _, validErr := range valid.Errors {
  44 + field, isExist := elem.FieldByName(validErr.Field)
  45 + if isExist {
  46 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  47 + } else {
  48 + return fmt.Errorf(validErr.Message)
  49 + }
  50 + }
  51 + }
  52 + return nil
  53 +}
  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 GetCooperationApplicationQuery struct {
  12 + // 共创申请ID
  13 + CooperationApplicationId int64 `cname:"共创申请ID" json:"cooperationApplicationId,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 (getCooperationApplicationQuery *GetCooperationApplicationQuery) Valid(validation *validation.Validation) {
  23 + validation.SetError("CustomValid", "未实现的自定义认证")
  24 +}
  25 +
  26 +func (getCooperationApplicationQuery *GetCooperationApplicationQuery) ValidateQuery() error {
  27 + valid := validation.Validation{}
  28 + b, err := valid.Valid(getCooperationApplicationQuery)
  29 + if err != nil {
  30 + return err
  31 + }
  32 + if !b {
  33 + elem := reflect.TypeOf(getCooperationApplicationQuery).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 ListCooperationApplicationQuery 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 (listCooperationApplicationQuery *ListCooperationApplicationQuery) Valid(validation *validation.Validation) {
  25 + validation.SetError("CustomValid", "未实现的自定义认证")
  26 +}
  27 +
  28 +func (listCooperationApplicationQuery *ListCooperationApplicationQuery) ValidateQuery() error {
  29 + valid := validation.Validation{}
  30 + b, err := valid.Valid(listCooperationApplicationQuery)
  31 + if err != nil {
  32 + return err
  33 + }
  34 + if !b {
  35 + elem := reflect.TypeOf(listCooperationApplicationQuery).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 SearchCooperationApplicationQuery struct {
  12 + // 共创项目名称
  13 + CooperationProjectName string `cname:"共创项目名称" json:"cooperationProjectName" valid:"Required"`
  14 + // 申请人姓名
  15 + ApplicantName string `cname:"申请人姓名" json:"applicantName,omitempty"`
  16 + // 共创申请审核状态,1待审核,2已同意,3已拒绝
  17 + CooperationApplicationStatus int32 `cname:"共创申请审核状态,1待审核,2已同意,3已拒绝" json:"cooperationApplicationStatus,omitempty"`
  18 + // 页面大小
  19 + PageSize int32 `cname:"页面大小" json:"pageSize,omitempty"`
  20 + // 页面大小
  21 + PageNumber int32 `cname:"页面大小" json:"pageNumber,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 (searchCooperationApplicationQuery *SearchCooperationApplicationQuery) Valid(validation *validation.Validation) {
  31 + validation.SetError("CustomValid", "未实现的自定义认证")
  32 +}
  33 +
  34 +func (searchCooperationApplicationQuery *SearchCooperationApplicationQuery) ValidateQuery() error {
  35 + valid := validation.Validation{}
  36 + b, err := valid.Valid(searchCooperationApplicationQuery)
  37 + if err != nil {
  38 + return err
  39 + }
  40 + if !b {
  41 + elem := reflect.TypeOf(searchCooperationApplicationQuery).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 + "github.com/linmadan/egglib-go/core/application"
  5 + "github.com/linmadan/egglib-go/utils/tool_funs"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/command"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/query"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
  9 +)
  10 +
  11 +// 共创申请服务
  12 +type CooperationApplicationService struct {
  13 +}
  14 +
  15 +// 审核-同意共创申请
  16 +func (cooperationApplicationService *CooperationApplicationService) AgreeCooperationApplication(agreeCooperationApplicationCommand *command.AgreeCooperationApplicationCommand) (interface{}, error) {
  17 + if err := agreeCooperationApplicationCommand.ValidateCommand(); err != nil {
  18 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  19 + }
  20 + transactionContext, err := factory.CreateTransactionContext(nil)
  21 + if err != nil {
  22 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  23 + }
  24 + if err := transactionContext.StartTransaction(); err != nil {
  25 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  26 + }
  27 + defer func() {
  28 + transactionContext.RollbackTransaction()
  29 + }()
  30 + if err := transactionContext.CommitTransaction(); err != nil {
  31 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  32 + }
  33 + return nil, nil
  34 +}
  35 +
  36 +// 申请共创
  37 +func (cooperationApplicationService *CooperationApplicationService) ApplyForCooperation(applyForCooperationCommand *command.ApplyForCooperationCommand) (interface{}, error) {
  38 + if err := applyForCooperationCommand.ValidateCommand(); err != nil {
  39 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  40 + }
  41 + transactionContext, err := factory.CreateTransactionContext(nil)
  42 + if err != nil {
  43 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  44 + }
  45 + if err := transactionContext.StartTransaction(); err != nil {
  46 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  47 + }
  48 + defer func() {
  49 + transactionContext.RollbackTransaction()
  50 + }()
  51 + if err := transactionContext.CommitTransaction(); err != nil {
  52 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  53 + }
  54 + return nil, nil
  55 +}
  56 +
  57 +// 创建共创申请服务
  58 +func (cooperationApplicationService *CooperationApplicationService) CreateCooperationApplication(createCooperationApplicationCommand *command.CreateCooperationApplicationCommand) (interface{}, error) {
  59 + if err := createCooperationApplicationCommand.ValidateCommand(); err != nil {
  60 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  61 + }
  62 + transactionContext, err := factory.CreateTransactionContext(nil)
  63 + if err != nil {
  64 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  65 + }
  66 + if err := transactionContext.StartTransaction(); err != nil {
  67 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  68 + }
  69 + defer func() {
  70 + transactionContext.RollbackTransaction()
  71 + }()
  72 + newCooperationApplication := &cooperationApplication.CooperationApplication{
  73 + ApplicantUid: createCooperationApplicationCommand.ApplicantUid,
  74 + CooperationApplicationDescription: createCooperationApplicationCommand.CooperationApplicationDescription,
  75 + CooperationApplicationAttachment: createCooperationApplicationCommand.CooperationApplicationAttachment,
  76 + CooperationProjectNumber: createCooperationApplicationCommand.CooperationProjectNumber,
  77 + CompanyId: createCooperationApplicationCommand.CompanyId,
  78 + OrgId: createCooperationApplicationCommand.OrgId,
  79 + UserId: createCooperationApplicationCommand.UserId,
  80 + }
  81 + var cooperationApplicationRepository cooperationApplication.CooperationApplicationRepository
  82 + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
  83 + "transactionContext": transactionContext,
  84 + }); err != nil {
  85 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  86 + } else {
  87 + cooperationApplicationRepository = value
  88 + }
  89 + if cooperationApplication, err := cooperationApplicationRepository.Save(newCooperationApplication); err != nil {
  90 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  91 + } else {
  92 + if err := transactionContext.CommitTransaction(); err != nil {
  93 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  94 + }
  95 + return cooperationApplication, nil
  96 + }
  97 +}
  98 +
  99 +// 返回共创申请服务
  100 +func (cooperationApplicationService *CooperationApplicationService) GetCooperationApplication(getCooperationApplicationQuery *query.GetCooperationApplicationQuery) (interface{}, error) {
  101 + if err := getCooperationApplicationQuery.ValidateQuery(); err != nil {
  102 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  103 + }
  104 + transactionContext, err := factory.CreateTransactionContext(nil)
  105 + if err != nil {
  106 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  107 + }
  108 + if err := transactionContext.StartTransaction(); err != nil {
  109 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  110 + }
  111 + defer func() {
  112 + transactionContext.RollbackTransaction()
  113 + }()
  114 + var cooperationApplicationRepository cooperationApplication.CooperationApplicationRepository
  115 + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
  116 + "transactionContext": transactionContext,
  117 + }); err != nil {
  118 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  119 + } else {
  120 + cooperationApplicationRepository = value
  121 + }
  122 + cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": getCooperationApplicationQuery.CooperationApplicationId})
  123 + if err != nil {
  124 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  125 + }
  126 + if cooperationApplication == nil {
  127 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCooperationApplicationQuery.CooperationApplicationId)))
  128 + } else {
  129 + if err := transactionContext.CommitTransaction(); err != nil {
  130 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  131 + }
  132 + return cooperationApplication, nil
  133 + }
  134 +}
  135 +
  136 +// 返回共创申请服务列表
  137 +func (cooperationApplicationService *CooperationApplicationService) ListCooperationApplication(listCooperationApplicationQuery *query.ListCooperationApplicationQuery) (interface{}, error) {
  138 + if err := listCooperationApplicationQuery.ValidateQuery(); err != nil {
  139 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  140 + }
  141 + transactionContext, err := factory.CreateTransactionContext(nil)
  142 + if err != nil {
  143 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  144 + }
  145 + if err := transactionContext.StartTransaction(); err != nil {
  146 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  147 + }
  148 + defer func() {
  149 + transactionContext.RollbackTransaction()
  150 + }()
  151 + var cooperationApplicationRepository cooperationApplication.CooperationApplicationRepository
  152 + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
  153 + "transactionContext": transactionContext,
  154 + }); err != nil {
  155 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  156 + } else {
  157 + cooperationApplicationRepository = value
  158 + }
  159 + if count, cooperationApplications, err := cooperationApplicationRepository.Find(tool_funs.SimpleStructToMap(listCooperationApplicationQuery)); err != nil {
  160 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  161 + } else {
  162 + if err := transactionContext.CommitTransaction(); err != nil {
  163 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  164 + }
  165 + return map[string]interface{}{
  166 + "count": count,
  167 + "cooperationApplications": cooperationApplications,
  168 + }, nil
  169 + }
  170 +}
  171 +
  172 +// 审核-拒绝共创申请
  173 +func (cooperationApplicationService *CooperationApplicationService) RejectCooperationApplication(rejectCooperationApplicationCommand *command.RejectCooperationApplicationCommand) (interface{}, error) {
  174 + if err := rejectCooperationApplicationCommand.ValidateCommand(); err != nil {
  175 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  176 + }
  177 + transactionContext, err := factory.CreateTransactionContext(nil)
  178 + if err != nil {
  179 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  180 + }
  181 + if err := transactionContext.StartTransaction(); err != nil {
  182 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  183 + }
  184 + defer func() {
  185 + transactionContext.RollbackTransaction()
  186 + }()
  187 + if err := transactionContext.CommitTransaction(); err != nil {
  188 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  189 + }
  190 + return nil, nil
  191 +}
  192 +
  193 +// 移除共创申请服务
  194 +func (cooperationApplicationService *CooperationApplicationService) RemoveCooperationApplication(removeCooperationApplicationCommand *command.RemoveCooperationApplicationCommand) (interface{}, error) {
  195 + if err := removeCooperationApplicationCommand.ValidateCommand(); err != nil {
  196 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  197 + }
  198 + transactionContext, err := factory.CreateTransactionContext(nil)
  199 + if err != nil {
  200 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  201 + }
  202 + if err := transactionContext.StartTransaction(); err != nil {
  203 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  204 + }
  205 + defer func() {
  206 + transactionContext.RollbackTransaction()
  207 + }()
  208 + var cooperationApplicationRepository cooperationApplication.CooperationApplicationRepository
  209 + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
  210 + "transactionContext": transactionContext,
  211 + }); err != nil {
  212 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  213 + } else {
  214 + cooperationApplicationRepository = value
  215 + }
  216 + cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": removeCooperationApplicationCommand.CooperationApplicationId})
  217 + if err != nil {
  218 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  219 + }
  220 + if cooperationApplication == nil {
  221 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCooperationApplicationCommand.CooperationApplicationId)))
  222 + }
  223 + if cooperationApplication, err := cooperationApplicationRepository.Remove(cooperationApplication); err != nil {
  224 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  225 + } else {
  226 + if err := transactionContext.CommitTransaction(); err != nil {
  227 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  228 + }
  229 + return cooperationApplication, nil
  230 + }
  231 +}
  232 +
  233 +// 查询共创申请
  234 +func (cooperationApplicationService *CooperationApplicationService) SearchCooperationApplication(searchCooperationApplicationQuery *query.SearchCooperationApplicationQuery) (interface{}, error) {
  235 + if err := searchCooperationApplicationQuery.ValidateQuery(); err != nil {
  236 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  237 + }
  238 + transactionContext, err := factory.CreateTransactionContext(nil)
  239 + if err != nil {
  240 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  241 + }
  242 + if err := transactionContext.StartTransaction(); err != nil {
  243 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  244 + }
  245 + defer func() {
  246 + transactionContext.RollbackTransaction()
  247 + }()
  248 + if err := transactionContext.CommitTransaction(); err != nil {
  249 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  250 + }
  251 + return nil, nil
  252 +}
  253 +
  254 +// 更新共创申请服务
  255 +func (cooperationApplicationService *CooperationApplicationService) UpdateCooperationApplication(updateCooperationApplicationCommand *command.UpdateCooperationApplicationCommand) (interface{}, error) {
  256 + if err := updateCooperationApplicationCommand.ValidateCommand(); err != nil {
  257 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  258 + }
  259 + transactionContext, err := factory.CreateTransactionContext(nil)
  260 + if err != nil {
  261 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  262 + }
  263 + if err := transactionContext.StartTransaction(); err != nil {
  264 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  265 + }
  266 + defer func() {
  267 + transactionContext.RollbackTransaction()
  268 + }()
  269 + var cooperationApplicationRepository cooperationApplication.CooperationApplicationRepository
  270 + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
  271 + "transactionContext": transactionContext,
  272 + }); err != nil {
  273 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  274 + } else {
  275 + cooperationApplicationRepository = value
  276 + }
  277 + cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": updateCooperationApplicationCommand.CooperationApplicationId})
  278 + if err != nil {
  279 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  280 + }
  281 + if cooperationApplication == nil {
  282 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationApplicationCommand.CooperationApplicationId)))
  283 + }
  284 + if err := cooperationApplication.Update(tool_funs.SimpleStructToMap(updateCooperationApplicationCommand)); err != nil {
  285 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  286 + }
  287 + if cooperationApplication, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil {
  288 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  289 + } else {
  290 + if err := transactionContext.CommitTransaction(); err != nil {
  291 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  292 + }
  293 + return cooperationApplication, nil
  294 + }
  295 +}
  296 +
  297 +func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService {
  298 + newCooperationApplicationService := &CooperationApplicationService{}
  299 + return newCooperationApplicationService
  300 +}
  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/cooperationApplication/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/query"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/service"
  8 +)
  9 +
  10 +type CooperationApplicationController struct {
  11 + beego.BaseController
  12 +}
  13 +
  14 +func (controller *CooperationApplicationController) ApplyForCooperation() {
  15 + cooperationApplicationService := service.NewCooperationApplicationService(nil)
  16 + applyForCooperationCommand := &command.ApplyForCooperationCommand{}
  17 + controller.Unmarshal(applyForCooperationCommand)
  18 + data, err := cooperationApplicationService.ApplyForCooperation(applyForCooperationCommand)
  19 + controller.Response(data, err)
  20 +}
  21 +
  22 +func (controller *CooperationApplicationController) AgreeCooperationApplication() {
  23 + cooperationApplicationService := service.NewCooperationApplicationService(nil)
  24 + agreeCooperationApplicationCommand := &command.AgreeCooperationApplicationCommand{}
  25 + controller.Unmarshal(agreeCooperationApplicationCommand)
  26 + data, err := cooperationApplicationService.AgreeCooperationApplication(agreeCooperationApplicationCommand)
  27 + controller.Response(data, err)
  28 +}
  29 +
  30 +func (controller *CooperationApplicationController) RejectCooperationApplication() {
  31 + cooperationApplicationService := service.NewCooperationApplicationService(nil)
  32 + rejectCooperationApplicationCommand := &command.RejectCooperationApplicationCommand{}
  33 + controller.Unmarshal(rejectCooperationApplicationCommand)
  34 + data, err := cooperationApplicationService.RejectCooperationApplication(rejectCooperationApplicationCommand)
  35 + controller.Response(data, err)
  36 +}
  37 +
  38 +func (controller *CooperationApplicationController) CreateCooperationApplication() {
  39 + cooperationApplicationService := service.NewCooperationApplicationService(nil)
  40 + createCooperationApplicationCommand := &command.CreateCooperationApplicationCommand{}
  41 + controller.Unmarshal(createCooperationApplicationCommand)
  42 + data, err := cooperationApplicationService.CreateCooperationApplication(createCooperationApplicationCommand)
  43 + controller.Response(data, err)
  44 +}
  45 +
  46 +func (controller *CooperationApplicationController) UpdateCooperationApplication() {
  47 + cooperationApplicationService := service.NewCooperationApplicationService(nil)
  48 + updateCooperationApplicationCommand := &command.UpdateCooperationApplicationCommand{}
  49 + controller.Unmarshal(updateCooperationApplicationCommand)
  50 + cooperationApplicationId := controller.GetString(":cooperationApplicationId")
  51 + updateCooperationApplicationCommand.CooperationApplicationId = cooperationApplicationId
  52 + data, err := cooperationApplicationService.UpdateCooperationApplication(updateCooperationApplicationCommand)
  53 + controller.Response(data, err)
  54 +}
  55 +
  56 +func (controller *CooperationApplicationController) GetCooperationApplication() {
  57 + cooperationApplicationService := service.NewCooperationApplicationService(nil)
  58 + getCooperationApplicationQuery := &query.GetCooperationApplicationQuery{}
  59 + cooperationApplicationId, _ := controller.GetInt64(":cooperationApplicationId")
  60 + getCooperationApplicationQuery.CooperationApplicationId = cooperationApplicationId
  61 + data, err := cooperationApplicationService.GetCooperationApplication(getCooperationApplicationQuery)
  62 + controller.Response(data, err)
  63 +}
  64 +
  65 +func (controller *CooperationApplicationController) RemoveCooperationApplication() {
  66 + cooperationApplicationService := service.NewCooperationApplicationService(nil)
  67 + removeCooperationApplicationCommand := &command.RemoveCooperationApplicationCommand{}
  68 + controller.Unmarshal(removeCooperationApplicationCommand)
  69 + cooperationApplicationId, _ := controller.GetInt64(":cooperationApplicationId")
  70 + removeCooperationApplicationCommand.CooperationApplicationId = cooperationApplicationId
  71 + data, err := cooperationApplicationService.RemoveCooperationApplication(removeCooperationApplicationCommand)
  72 + controller.Response(data, err)
  73 +}
  74 +
  75 +func (controller *CooperationApplicationController) SearchCooperationApplication() {
  76 + cooperationApplicationService := service.NewCooperationApplicationService(nil)
  77 + searchCooperationApplicationQuery := &query.SearchCooperationApplicationQuery{}
  78 + data, err := cooperationApplicationService.SearchCooperationApplication(searchCooperationApplicationQuery)
  79 + controller.Response(data, err)
  80 +}
  81 +
  82 +func (controller *CooperationApplicationController) ListCooperationApplication() {
  83 + cooperationApplicationService := service.NewCooperationApplicationService(nil)
  84 + listCooperationApplicationQuery := &query.ListCooperationApplicationQuery{}
  85 + offset, _ := controller.GetInt("offset")
  86 + listCooperationApplicationQuery.Offset = offset
  87 + limit, _ := controller.GetInt("limit")
  88 + listCooperationApplicationQuery.Limit = limit
  89 + data, err := cooperationApplicationService.ListCooperationApplication(listCooperationApplicationQuery)
  90 + controller.Response(data, err)
  91 +}
  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-applications/apply-for-cooperation", &controllers.CooperationApplicationController{}, "Post:ApplyForCooperation")
  10 + web.Router("/cooperation-applications/agree-cooperation-application", &controllers.CooperationApplicationController{}, "Post:AgreeCooperationApplication")
  11 + web.Router("/cooperation-applications/reject-cooperation-application", &controllers.CooperationApplicationController{}, "Post:RejectCooperationApplication")
  12 + web.Router("/cooperation-applications/", &controllers.CooperationApplicationController{}, "Post:CreateCooperationApplication")
  13 + web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Put:UpdateCooperationApplication")
  14 + web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Get:GetCooperationApplication")
  15 + web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Delete:RemoveCooperationApplication")
  16 + web.Router("/cooperation-applications/search", &controllers.CooperationApplicationController{}, "Post:SearchCooperationApplication")
  17 + web.Router("/cooperation-applications/", &controllers.CooperationApplicationController{}, "Get:ListCooperationApplication")
  18 +}
  1 +package cooperation_application
  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 + var cooperationApplicationId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&cooperationApplicationId),
  17 + "INSERT INTO cooperation_applications (cooperation_application_id, cooperation_application_applicant, cooperation_application_attachment, cooperation_application_description, cooperation_application_status, cooperation_application_verifier, cooperation_application_verify_description, cooperation_application_verify_time, cooperation_apply_time, cooperation_project, org, company, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_application_id",
  18 + "testCooperationApplicationId", "testCooperationApplicationApplicant", "testCooperationApplicationAttachment", "testCooperationApplicationDescription", "testCooperationApplicationStatus", "testCooperationApplicationVerifier", "testCooperationApplicationVerifyDescription", "testCooperationApplicationVerifyTime", "testCooperationApplyTime", "testCooperationProject", "testOrg", "testCompany", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("审核-同意共创申请", func() {
  22 + Context("", func() {
  23 + It("", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + body := map[string]interface{}{
  26 + "cooperationApplicationId": "int64",
  27 + "cooperationApplicationVerifyDescription": "string",
  28 + "companyId": "int64",
  29 + "orgId": "int64",
  30 + "code": "string",
  31 + "userId": "int64",
  32 + }
  33 + httpExpect.POST("/cooperation-applications/agree-cooperation-application").
  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_applications WHERE true")
  47 + Expect(err).NotTo(HaveOccurred())
  48 + })
  49 +})
  1 +package cooperation_application
  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 + var cooperationApplicationId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&cooperationApplicationId),
  17 + "INSERT INTO cooperation_applications (cooperation_application_id, cooperation_application_applicant, cooperation_application_attachment, cooperation_application_description, cooperation_application_status, cooperation_application_verifier, cooperation_application_verify_description, cooperation_application_verify_time, cooperation_apply_time, cooperation_project, org, company, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_application_id",
  18 + "testCooperationApplicationId", "testCooperationApplicationApplicant", "testCooperationApplicationAttachment", "testCooperationApplicationDescription", "testCooperationApplicationStatus", "testCooperationApplicationVerifier", "testCooperationApplicationVerifyDescription", "testCooperationApplicationVerifyTime", "testCooperationApplyTime", "testCooperationProject", "testOrg", "testCompany", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("申请共创", func() {
  22 + Context("", func() {
  23 + It("", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + body := map[string]interface{}{
  26 + "cooperationApplicationAttachment": "array",
  27 + "cooperationApplicationDescription": "string",
  28 + "userId": "int64",
  29 + "userBaseId": "int64",
  30 + "orgId": "int64",
  31 + "orgName": "string",
  32 + "companyId": "int64",
  33 + "companyLogo": "string",
  34 + "companyName": "string",
  35 + "orgs": "array",
  36 + "departmentId": "int64",
  37 + "departmentName": "string",
  38 + "departmentNumber": "string",
  39 + "isOrganization": "boolean",
  40 + "roleId": "int64",
  41 + "roleName": "string",
  42 + "userAvatar": "string",
  43 + "userEmail": "string",
  44 + "userName": "string",
  45 + "userPhone": "string",
  46 + "userAccount": "string",
  47 + "userType": "int32",
  48 + "status": "int32",
  49 + "cooperationApplicationId": "int64",
  50 + "cooperationProjectNumber": "string",
  51 + "cooperationApplyTime": "datetime",
  52 + }
  53 + httpExpect.POST("/cooperation-applications/apply-for-cooperation").
  54 + WithJSON(body).
  55 + Expect().
  56 + Status(http.StatusOK).
  57 + JSON().
  58 + Object().
  59 + ContainsKey("code").ValueEqual("code", 0).
  60 + ContainsKey("msg").ValueEqual("msg", "ok").
  61 + ContainsKey("data").Value("data").Object()
  62 + })
  63 + })
  64 + })
  65 + AfterEach(func() {
  66 + _, err := pG.DB.Exec("DELETE FROM cooperation_applications WHERE true")
  67 + Expect(err).NotTo(HaveOccurred())
  68 + })
  69 +})
  1 +package cooperation_application
  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 TestCooperationApplication(t *testing.T) {
  17 + RegisterFailHandler(Fail)
  18 + RunSpecs(t, "Beego Port CooperationApplication 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_application
  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 + "applicantUid": "string",
  19 + "cooperationApplicationDescription": "string",
  20 + "cooperationApplicationAttachment": "array",
  21 + "cooperationProjectNumber": "string",
  22 + "companyId": "int64",
  23 + "orgId": "int64",
  24 + "userId": "int64",
  25 + }
  26 + httpExpect.POST("/cooperation-applications/").
  27 + WithJSON(body).
  28 + Expect().
  29 + Status(http.StatusOK).
  30 + JSON().
  31 + Object().
  32 + ContainsKey("code").ValueEqual("code", 0).
  33 + ContainsKey("msg").ValueEqual("msg", "ok").
  34 + ContainsKey("data").Value("data").Object().
  35 + ContainsKey("cooperationApplicationId").ValueNotEqual("cooperationApplicationId", BeZero())
  36 + })
  37 + })
  38 + })
  39 + AfterEach(func() {
  40 + _, err := pG.DB.Exec("DELETE FROM cooperation_applications WHERE true")
  41 + Expect(err).NotTo(HaveOccurred())
  42 + })
  43 +})
  1 +package cooperation_application
  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 + var cooperationApplicationId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&cooperationApplicationId),
  17 + "INSERT INTO cooperation_applications (cooperation_application_id, cooperation_application_applicant, cooperation_application_attachment, cooperation_application_description, cooperation_application_status, cooperation_application_verifier, cooperation_application_verify_description, cooperation_application_verify_time, cooperation_apply_time, cooperation_project, org, company, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_application_id",
  18 + "testCooperationApplicationId", "testCooperationApplicationApplicant", "testCooperationApplicationAttachment", "testCooperationApplicationDescription", "testCooperationApplicationStatus", "testCooperationApplicationVerifier", "testCooperationApplicationVerifyDescription", "testCooperationApplicationVerifyTime", "testCooperationApplyTime", "testCooperationProject", "testOrg", "testCompany", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("根据cooperationApplicationId参数返回共创申请实体", func() {
  22 + Context("传入有效的cooperationApplicationId", func() {
  23 + It("返回共创申请实体数据", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + httpExpect.GET("/cooperation-applications/{cooperationApplicationId}").
  26 + Expect().
  27 + Status(http.StatusOK).
  28 + JSON().
  29 + Object().
  30 + ContainsKey("code").ValueEqual("code", 0).
  31 + ContainsKey("msg").ValueEqual("msg", "ok").
  32 + ContainsKey("data").Value("data").Object()
  33 + })
  34 + })
  35 + })
  36 + AfterEach(func() {
  37 + _, err := pG.DB.Exec("DELETE FROM cooperation_applications WHERE true")
  38 + Expect(err).NotTo(HaveOccurred())
  39 + })
  40 +})
  1 +package cooperation_application
  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 + var cooperationApplicationId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&cooperationApplicationId),
  17 + "INSERT INTO cooperation_applications (cooperation_application_id, cooperation_application_applicant, cooperation_application_attachment, cooperation_application_description, cooperation_application_status, cooperation_application_verifier, cooperation_application_verify_description, cooperation_application_verify_time, cooperation_apply_time, cooperation_project, org, company, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_application_id",
  18 + "testCooperationApplicationId", "testCooperationApplicationApplicant", "testCooperationApplicationAttachment", "testCooperationApplicationDescription", "testCooperationApplicationStatus", "testCooperationApplicationVerifier", "testCooperationApplicationVerifyDescription", "testCooperationApplicationVerifyTime", "testCooperationApplyTime", "testCooperationProject", "testOrg", "testCompany", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("根据参数返回共创申请实体列表", func() {
  22 + Context("传入有效的参数", func() {
  23 + It("返回共创申请实体数据列表", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + httpExpect.GET("/cooperation-applications/").
  26 + WithQuery("offset", "int").
  27 + WithQuery("limit", "int").
  28 + Expect().
  29 + Status(http.StatusOK).
  30 + JSON().
  31 + Object().
  32 + ContainsKey("code").ValueEqual("code", 0).
  33 + ContainsKey("msg").ValueEqual("msg", "ok").
  34 + ContainsKey("data").Value("data").Object().
  35 + ContainsKey("count").ValueEqual("count", 1).
  36 + ContainsKey("cooperationApplications").Value("cooperationApplications").Array()
  37 + })
  38 + })
  39 + })
  40 + AfterEach(func() {
  41 + _, err := pG.DB.Exec("DELETE FROM cooperation_applications WHERE true")
  42 + Expect(err).NotTo(HaveOccurred())
  43 + })
  44 +})
  1 +package cooperation_application
  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 + var cooperationApplicationId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&cooperationApplicationId),
  17 + "INSERT INTO cooperation_applications (cooperation_application_id, cooperation_application_applicant, cooperation_application_attachment, cooperation_application_description, cooperation_application_status, cooperation_application_verifier, cooperation_application_verify_description, cooperation_application_verify_time, cooperation_apply_time, cooperation_project, org, company, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_application_id",
  18 + "testCooperationApplicationId", "testCooperationApplicationApplicant", "testCooperationApplicationAttachment", "testCooperationApplicationDescription", "testCooperationApplicationStatus", "testCooperationApplicationVerifier", "testCooperationApplicationVerifyDescription", "testCooperationApplicationVerifyTime", "testCooperationApplyTime", "testCooperationProject", "testOrg", "testCompany", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("审核-拒绝共创申请", func() {
  22 + Context("", func() {
  23 + It("", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + body := map[string]interface{}{
  26 + "cooperationApplicationId": "int64",
  27 + "cooperationApplicationVerifyDescription": "string",
  28 + "companyId": "int64",
  29 + "orgId": "int64",
  30 + "code": "string",
  31 + "userId": "int64",
  32 + }
  33 + httpExpect.POST("/cooperation-applications/reject-cooperation-application").
  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_applications WHERE true")
  47 + Expect(err).NotTo(HaveOccurred())
  48 + })
  49 +})
  1 +package cooperation_application
  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 + var cooperationApplicationId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&cooperationApplicationId),
  17 + "INSERT INTO cooperation_applications (cooperation_application_id, cooperation_application_applicant, cooperation_application_attachment, cooperation_application_description, cooperation_application_status, cooperation_application_verifier, cooperation_application_verify_description, cooperation_application_verify_time, cooperation_apply_time, cooperation_project, org, company, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_application_id",
  18 + "testCooperationApplicationId", "testCooperationApplicationApplicant", "testCooperationApplicationAttachment", "testCooperationApplicationDescription", "testCooperationApplicationStatus", "testCooperationApplicationVerifier", "testCooperationApplicationVerifyDescription", "testCooperationApplicationVerifyTime", "testCooperationApplyTime", "testCooperationProject", "testOrg", "testCompany", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("根据参数移除共创申请服务", func() {
  22 + Context("传入有效的cooperationApplicationId", func() {
  23 + It("返回被移除共创申请实体的数据", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + httpExpect.DELETE("/cooperation-applications/{cooperationApplicationId}").
  26 + Expect().
  27 + Status(http.StatusOK).
  28 + JSON().
  29 + Object().
  30 + ContainsKey("code").ValueEqual("code", 0).
  31 + ContainsKey("msg").ValueEqual("msg", "ok").
  32 + ContainsKey("data").Value("data").Object()
  33 + })
  34 + })
  35 + })
  36 + AfterEach(func() {
  37 + _, err := pG.DB.Exec("DELETE FROM cooperation_applications WHERE true")
  38 + Expect(err).NotTo(HaveOccurred())
  39 + })
  40 +})
  1 +package cooperation_application
  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 + var cooperationApplicationId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&cooperationApplicationId),
  17 + "INSERT INTO cooperation_applications (cooperation_application_id, cooperation_application_applicant, cooperation_application_attachment, cooperation_application_description, cooperation_application_status, cooperation_application_verifier, cooperation_application_verify_description, cooperation_application_verify_time, cooperation_apply_time, cooperation_project, org, company, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_application_id",
  18 + "testCooperationApplicationId", "testCooperationApplicationApplicant", "testCooperationApplicationAttachment", "testCooperationApplicationDescription", "testCooperationApplicationStatus", "testCooperationApplicationVerifier", "testCooperationApplicationVerifyDescription", "testCooperationApplicationVerifyTime", "testCooperationApplyTime", "testCooperationProject", "testOrg", "testCompany", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("查询共创申请", func() {
  22 + Context("", func() {
  23 + It("", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + body := map[string]interface{}{
  26 + "cooperationProjectName": "string",
  27 + "applicantName": "string",
  28 + "cooperationApplicationStatus": "int32",
  29 + "pageSize": "int32",
  30 + "pageNumber": "int32",
  31 + "companyId": "int64",
  32 + "orgId": "int64",
  33 + "userId": "int64",
  34 + }
  35 + httpExpect.POST("/cooperation-applications/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_applications WHERE true")
  49 + Expect(err).NotTo(HaveOccurred())
  50 + })
  51 +})
  1 +package cooperation_application
  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 + var cooperationApplicationId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&cooperationApplicationId),
  17 + "INSERT INTO cooperation_applications (cooperation_application_id, cooperation_application_applicant, cooperation_application_attachment, cooperation_application_description, cooperation_application_status, cooperation_application_verifier, cooperation_application_verify_description, cooperation_application_verify_time, cooperation_apply_time, cooperation_project, org, company, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_application_id",
  18 + "testCooperationApplicationId", "testCooperationApplicationApplicant", "testCooperationApplicationAttachment", "testCooperationApplicationDescription", "testCooperationApplicationStatus", "testCooperationApplicationVerifier", "testCooperationApplicationVerifyDescription", "testCooperationApplicationVerifyTime", "testCooperationApplyTime", "testCooperationProject", "testOrg", "testCompany", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("提交数据更新共创申请服务", func() {
  22 + Context("提交正确的共创申请实体数据", func() {
  23 + It("返回更新后的共创申请实体数据", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + body := map[string]interface{}{
  26 + "applicantUid": "string",
  27 + "cooperationApplicationDescription": "string",
  28 + "cooperationApplicationAttachment": "array",
  29 + "cooperationProjectNumber": "string",
  30 + "companyId": "int64",
  31 + "orgId": "int64",
  32 + "userId": "int64",
  33 + }
  34 + httpExpect.PUT("/cooperation-applications/{cooperationApplicationId}").
  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("cooperationApplicationId").ValueEqual("cooperationApplicationId", cooperationApplicationId)
  44 + })
  45 + })
  46 + })
  47 + AfterEach(func() {
  48 + _, err := pG.DB.Exec("DELETE FROM cooperation_applications WHERE true")
  49 + Expect(err).NotTo(HaveOccurred())
  50 + })
  51 +})