作者 tangxuhui

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway into dev

# Conflicts:
#	pkg/infrastructure/service_gateway/allied_creation_cooperation/param_cooperation_application.go
@@ -11,7 +11,7 @@ type AuditCooperationApplicationCommand struct { @@ -11,7 +11,7 @@ type AuditCooperationApplicationCommand struct {
11 //操作人 11 //操作人
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
13 // 共创申请ID 13 // 共创申请ID
14 - CooperationApplicationId []int `json:"cooperationApplicationId" valid:"Required"` 14 + CooperationApplicationId int `json:"cooperationApplicationId" valid:"Required"`
15 // 审核动作,1同意,2拒绝 15 // 审核动作,1同意,2拒绝
16 CooperationApplicationStatus int `json:"cooperationApplicationStatus" valid:"Required"` 16 CooperationApplicationStatus int `json:"cooperationApplicationStatus" valid:"Required"`
17 // 共创申请审核描述 17 // 共创申请审核描述
@@ -25,7 +25,9 @@ type UpdateCooperationProjectCommand struct { @@ -25,7 +25,9 @@ type UpdateCooperationProjectCommand struct {
25 // 共创项目描述 25 // 共创项目描述
26 CooperationProjectDescription string `json:"cooperationProjectDescription" valid:"Required"` 26 CooperationProjectDescription string `json:"cooperationProjectDescription" valid:"Required"`
27 //图片 27 //图片
28 - Images []string `json:"images"` 28 + //Images []string `json:"images"`
  29 + // 附件列表
  30 + Attachment []domain.Attachment `json:"attachment"`
29 } 31 }
30 32
31 func (updateCooperationProjectCommand *UpdateCooperationProjectCommand) Valid(validation *validation.Validation) { 33 func (updateCooperationProjectCommand *UpdateCooperationProjectCommand) Valid(validation *validation.Validation) {
@@ -24,16 +24,23 @@ func (srv CooperationApplicationsService) GetCooperationApplications(application @@ -24,16 +24,23 @@ func (srv CooperationApplicationsService) GetCooperationApplications(application
24 if err != nil { 24 if err != nil {
25 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 25 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
26 } 26 }
27 - //resultProject, err := creationCooperationGateway.CooperationProjectGet(allied_creation_cooperation.ReqCooperationProjectGet{  
28 - // CooperationProjectId: resultApplication.CooperationProject.CooperationProjectID,  
29 - //})  
30 - //if err != nil {  
31 - // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())  
32 - //} 27 +
  28 + if err != nil {
  29 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  30 + }
  31 + resultProject, err := creationCooperationGateway.CooperationProjectGet(allied_creation_cooperation.ReqCooperationProjectGet{
  32 + CooperationProjectId: resultApplication.CooperationProject.CooperationProjectID,
  33 + })
  34 + if err != nil {
  35 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  36 + }
33 //data := map[string]interface{}{ 37 //data := map[string]interface{}{
34 // "cooperationApplication": dto.ToCooperationApplication(&resultApplication.CooperationApplication), 38 // "cooperationApplication": dto.ToCooperationApplication(&resultApplication.CooperationApplication),
35 // "cooperationProject": dto.ToCooperationProjectInfo(&resultProject.CooperationProject), 39 // "cooperationProject": dto.ToCooperationProjectInfo(&resultProject.CooperationProject),
36 //} 40 //}
  41 + resultApplication.CooperationProject.CooperationMode.CooperationModeNumber = resultProject.CooperationMode.CooperationModeNumber
  42 + resultApplication.CooperationProject.CooperationMode.CooperationModeName = resultProject.CooperationMode.CooperationModeName
  43 + resultApplication.CooperationProject.CooperationMode.CooperationModeId = resultProject.CooperationMode.CooperationModeId
37 return resultApplication, nil 44 return resultApplication, nil
38 } 45 }
39 46
@@ -41,15 +48,16 @@ func (srv CooperationApplicationsService) GetCooperationApplications(application @@ -41,15 +48,16 @@ func (srv CooperationApplicationsService) GetCooperationApplications(application
41 func (srv CooperationApplicationsService) AuditCooperationApplications(auditCommand *command.AuditCooperationApplicationCommand) (interface{}, error) { 48 func (srv CooperationApplicationsService) AuditCooperationApplications(auditCommand *command.AuditCooperationApplicationCommand) (interface{}, error) {
42 creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation( 49 creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
43 auditCommand.Operator) 50 auditCommand.Operator)
44 - applicationIds := []string{}  
45 - for _, v := range auditCommand.CooperationApplicationId {  
46 - idStr := strconv.Itoa(v)  
47 - applicationIds = append(applicationIds, idStr)  
48 - }  
49 - _, err := creationCooperationGateway.CooperationApplicationsBatchApproval(allied_creation_cooperation.ReqCooperationApplicationBatchApproval{  
50 - CooperationApplicationIds: applicationIds, 51 + //applicationIds := []string{strconv.Itoa(auditCommand.CooperationApplicationId)}
  52 + //for _, v := range auditCommand.CooperationApplicationId {
  53 + // idStr := strconv.Itoa(v)
  54 + // applicationIds = append(applicationIds, idStr)
  55 + //}
  56 + _, err := creationCooperationGateway.CooperationApplicationsApproval(allied_creation_cooperation.ReqCooperationApplicationApproval{
  57 + CooperationApplicationId: strconv.Itoa(auditCommand.CooperationApplicationId),
51 CooperationApplicationDescription: auditCommand.CooperationApplicationVerifyDescription, 58 CooperationApplicationDescription: auditCommand.CooperationApplicationVerifyDescription,
52 Action: auditCommand.CooperationApplicationStatus, 59 Action: auditCommand.CooperationApplicationStatus,
  60 + Code: "a1-2",
53 }) 61 })
54 if err != nil { 62 if err != nil {
55 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 63 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -6,7 +6,6 @@ import ( @@ -6,7 +6,6 @@ import (
6 "github.com/linmadan/egglib-go/core/application" 6 "github.com/linmadan/egglib-go/core/application"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/dto" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/dto"
9 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"  
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
11 ) 10 )
12 11
@@ -66,12 +65,12 @@ func (srv CooperationProjectService) GetCooperationProject(projectQuery *command @@ -66,12 +65,12 @@ func (srv CooperationProjectService) GetCooperationProject(projectQuery *command
66 // UpdateCooperationProject 更新项目 65 // UpdateCooperationProject 更新项目
67 func (srv CooperationProjectService) UpdateCooperationProject(updateCooperationProjectCommand *command.UpdateCooperationProjectCommand) (interface{}, error) { 66 func (srv CooperationProjectService) UpdateCooperationProject(updateCooperationProjectCommand *command.UpdateCooperationProjectCommand) (interface{}, error) {
68 creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(updateCooperationProjectCommand.Operator) 67 creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(updateCooperationProjectCommand.Operator)
69 - var images []domain.Attachment  
70 - for _, v := range updateCooperationProjectCommand.Images {  
71 - images = append(images, domain.Attachment{  
72 - Url: v,  
73 - })  
74 - } 68 + //var images []domain.Attachment
  69 + //for _, v := range updateCooperationProjectCommand.Images {
  70 + // images = append(images, domain.Attachment{
  71 + // Url: v,
  72 + // })
  73 + //}
75 _, err := creationCooperationGateway.CooperationProjectUpdate(allied_creation_cooperation.ReqCooperationProjectUpdate{ 74 _, err := creationCooperationGateway.CooperationProjectUpdate(allied_creation_cooperation.ReqCooperationProjectUpdate{
76 CooperationProjectId: updateCooperationProjectCommand.CooperationProjectId, 75 CooperationProjectId: updateCooperationProjectCommand.CooperationProjectId,
77 CooperationProjectName: updateCooperationProjectCommand.CooperationProjectName, 76 CooperationProjectName: updateCooperationProjectCommand.CooperationProjectName,
@@ -80,7 +79,7 @@ func (srv CooperationProjectService) UpdateCooperationProject(updateCooperationP @@ -80,7 +79,7 @@ func (srv CooperationProjectService) UpdateCooperationProject(updateCooperationP
80 SponsorUid: strconv.Itoa(int(updateCooperationProjectCommand.CooperationProjectSponsor)), 79 SponsorUid: strconv.Itoa(int(updateCooperationProjectCommand.CooperationProjectSponsor)),
81 PublisherUid: strconv.Itoa(int(updateCooperationProjectCommand.Operator.UserId)), 80 PublisherUid: strconv.Itoa(int(updateCooperationProjectCommand.Operator.UserId)),
82 CooperationProjectDescription: updateCooperationProjectCommand.CooperationProjectDescription, 81 CooperationProjectDescription: updateCooperationProjectCommand.CooperationProjectDescription,
83 - Attachment: images, 82 + Attachment: updateCooperationProjectCommand.Attachment,
84 OrgId: updateCooperationProjectCommand.OrgId, 83 OrgId: updateCooperationProjectCommand.OrgId,
85 }) 84 })
86 if err != nil { 85 if err != nil {
@@ -14,6 +14,7 @@ type Department struct { @@ -14,6 +14,7 @@ type Department struct {
14 } 14 }
15 type User struct { 15 type User struct {
16 UserID int `json:"userId"` 16 UserID int `json:"userId"`
  17 + UserCode string `json:"userCode"`
17 UserInfo map[string]interface{} `json:"userInfo"` 18 UserInfo map[string]interface{} `json:"userInfo"`
18 } 19 }
19 20
@@ -30,6 +31,10 @@ func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creat @@ -30,6 +31,10 @@ func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creat
30 return nil 31 return nil
31 } 32 }
32 var mapDepartment = make(map[int64]*Department) 33 var mapDepartment = make(map[int64]*Department)
  34 + mapDepartment[-1] = &Department{
  35 + DepartmentID: -1,
  36 + DepartmentName: "共创部门",
  37 + }
33 38
34 for i := range subDepartment.Orgs { 39 for i := range subDepartment.Orgs {
35 org := subDepartment.Orgs[i] 40 org := subDepartment.Orgs[i]
@@ -44,16 +49,20 @@ func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creat @@ -44,16 +49,20 @@ func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creat
44 49
45 for i := range userSearch.Users { 50 for i := range userSearch.Users {
46 user := userSearch.Users[i] 51 user := userSearch.Users[i]
  52 + u := User{
  53 + UserID: user.UserId,
  54 + UserCode: user.UserCode,
  55 + UserInfo: map[string]interface{}{
  56 + "userName": user.UserInfo.UserName,
  57 + "phone": user.UserInfo.Phone,
  58 + },
  59 + }
47 if user.Department == nil { 60 if user.Department == nil {
  61 + mapDepartment[-1].Users = append(mapDepartment[-1].Users, u)
48 continue 62 continue
49 } 63 }
50 if v, ok := mapDepartment[int64(user.Department.DepartmentId)]; ok { 64 if v, ok := mapDepartment[int64(user.Department.DepartmentId)]; ok {
51 - v.Users = append(v.Users, User{  
52 - UserID: user.UserId,  
53 - UserInfo: map[string]interface{}{  
54 - "userName": user.UserInfo.UserName,  
55 - },  
56 - }) 65 + v.Users = append(v.Users, u)
57 } 66 }
58 } 67 }
59 return nil 68 return nil
@@ -76,7 +76,7 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat @@ -76,7 +76,7 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat
76 // item := dto.ToCooperationApplicationItem(&result.Grid.List[i]) 76 // item := dto.ToCooperationApplicationItem(&result.Grid.List[i])
77 // dataList = append(dataList, *item) 77 // dataList = append(dataList, *item)
78 //} 78 //}
79 - return int64(result.Grid.Total), result.Grid, nil 79 + return int64(result.Grid.Total), result.Grid.List, nil
80 } 80 }
81 81
82 func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService { 82 func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService {
@@ -13,13 +13,13 @@ type CreateCooperationProjectCommand struct { @@ -13,13 +13,13 @@ type CreateCooperationProjectCommand struct {
13 // 模式编码,唯一确定 13 // 模式编码,唯一确定
14 CooperationModeNumber string `json:"cooperationModeNumber" valid:"Required"` 14 CooperationModeNumber string `json:"cooperationModeNumber" valid:"Required"`
15 // 发起组织ID 15 // 发起组织ID
16 - OrgId int64 `json:"departmentId" valid:"Required"` 16 + OrgId int64 `json:"departmentId"`
17 // 共创项目名称 17 // 共创项目名称
18 CooperationProjectName string `json:"cooperationProjectName" valid:"Required"` 18 CooperationProjectName string `json:"cooperationProjectName" valid:"Required"`
19 // 共创发起人id 19 // 共创发起人id
20 CooperationProjectSponsor int `json:"cooperationProjectSponsor,string,"` 20 CooperationProjectSponsor int `json:"cooperationProjectSponsor,string,"`
21 // 项目承接对象 21 // 项目承接对象
22 - CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"` 22 + CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerTypes"`
23 // 共创项目描述 23 // 共创项目描述
24 CooperationProjectDescription string `json:"cooperationProjectDescription" valid:"Required"` 24 CooperationProjectDescription string `json:"cooperationProjectDescription" valid:"Required"`
25 //图片 25 //图片
@@ -13,6 +13,7 @@ type Department struct { @@ -13,6 +13,7 @@ type Department struct {
13 } 13 }
14 type User struct { 14 type User struct {
15 UserID int `json:"userId,string"` 15 UserID int `json:"userId,string"`
  16 + UserCode string `json:"userCode"`
16 UserInfo map[string]interface{} `json:"userInfo"` 17 UserInfo map[string]interface{} `json:"userInfo"`
17 } 18 }
18 19
@@ -37,9 +38,11 @@ func (dto *DepartmentUsersDto) LoadDto(subDepartment *allied_creation_user.DataO @@ -37,9 +38,11 @@ func (dto *DepartmentUsersDto) LoadDto(subDepartment *allied_creation_user.DataO
37 } 38 }
38 if v, ok := mapDepartment[int64(user.Department.DepartmentId)]; ok { 39 if v, ok := mapDepartment[int64(user.Department.DepartmentId)]; ok {
39 v.Users = append(v.Users, User{ 40 v.Users = append(v.Users, User{
40 - UserID: user.UserId, 41 + UserID: user.UserId,
  42 + UserCode: user.UserCode,
41 UserInfo: map[string]interface{}{ 43 UserInfo: map[string]interface{}{
42 "userName": user.UserInfo.UserName, 44 "userName": user.UserInfo.UserName,
  45 + "phone": user.UserInfo.Phone,
43 }, 46 },
44 }) 47 })
45 } 48 }
@@ -72,6 +72,37 @@ func (gateway HttplibAlliedCreationCooperation) CooperationApplicationsBatchAppr @@ -72,6 +72,37 @@ func (gateway HttplibAlliedCreationCooperation) CooperationApplicationsBatchAppr
72 return &data, err 72 return &data, err
73 } 73 }
74 74
  75 +// CooperationApplicationsBatchApproval 共创申请审核
  76 +func (gateway HttplibAlliedCreationCooperation) CooperationApplicationsApproval(param ReqCooperationApplicationApproval) (*DataCooperationApplicationApproval, error) {
  77 + url := gateway.baseUrL + "/cooperation-applications/agree-cooperation-application"
  78 + method := "POST"
  79 + req := gateway.CreateRequest(url, method)
  80 + log.Logger.Debug("向业务模块请求数据:共创申请批量审核。", map[string]interface{}{
  81 + "api": method + ":" + url,
  82 + "param": param,
  83 + })
  84 + req, err := req.JSONBody(param)
  85 + if err != nil {
  86 + return nil, fmt.Errorf("请求共创申请批量审核失败:%w", err)
  87 + }
  88 +
  89 + byteResult, err := req.Bytes()
  90 + if err != nil {
  91 + return nil, fmt.Errorf("获取共创申请批量审核失败:%w", err)
  92 + }
  93 + log.Logger.Debug("获取业务模块请求数据:共创申请批量审核。", map[string]interface{}{
  94 + "result": string(byteResult),
  95 + })
  96 + var result service_gateway.GatewayResponse
  97 + err = json.Unmarshal(byteResult, &result)
  98 + if err != nil {
  99 + return nil, fmt.Errorf("解析共创申请批量审核:%w", err)
  100 + }
  101 + var data DataCooperationApplicationApproval
  102 + err = gateway.GetResponseData(result, &data)
  103 + return &data, err
  104 +}
  105 +
75 // CooperationApplicationCancel 取消共创申请 106 // CooperationApplicationCancel 取消共创申请
76 func (gateway HttplibAlliedCreationCooperation) CooperationApplicationCancel(param ReqCooperationApplicationCancel) (*DataCooperationApplicationCancel, error) { 107 func (gateway HttplibAlliedCreationCooperation) CooperationApplicationCancel(param ReqCooperationApplicationCancel) (*DataCooperationApplicationCancel, error) {
77 url := gateway.baseUrL + "/cooperation-applications/" + strconv.Itoa(param.ApplicationId) + "/cancel-application" 108 url := gateway.baseUrL + "/cooperation-applications/" + strconv.Itoa(param.ApplicationId) + "/cancel-application"
1 package allied_creation_cooperation 1 package allied_creation_cooperation
2 2
3 -import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/jtime"
  6 +)
4 7
5 //创建共创合约反馈信息 8 //创建共创合约反馈信息
6 type ( 9 type (
@@ -51,7 +54,15 @@ type ( @@ -51,7 +54,15 @@ type (
51 Company interface{} `json:"company"` 54 Company interface{} `json:"company"`
52 //UpdatedAt time.Time `json:"updatedAt"` 55 //UpdatedAt time.Time `json:"updatedAt"`
53 //DeletedAt time.Time `json:"deletedAt"` 56 //DeletedAt time.Time `json:"deletedAt"`
54 - //CreatedAt time.Time `json:"createdAt"` 57 + CreatedAt jtime.TimeToUnixMsec `json:"createdAt"`
  58 + CooperationMode struct {
  59 + // 共创模式ID
  60 + CooperationModeId int `json:"cooperationModeId,string"`
  61 + // 共创模式编码,唯一确定
  62 + CooperationModeNumber string `json:"cooperationModeNumber"`
  63 + // 模式名称,唯一确定
  64 + CooperationModeName string `json:"cooperationModeName"`
  65 + } `json:"cooperationMode"`
55 } `json:"list"` 66 } `json:"list"`
56 Total int `json:"total"` 67 Total int `json:"total"`
57 } `json:"grid"` 68 } `json:"grid"`
@@ -38,7 +38,15 @@ type CooperationApplication struct { @@ -38,7 +38,15 @@ type CooperationApplication struct {
38 CooperationProjectNumber string `json:"cooperationProjectNumber"` 38 CooperationProjectNumber string `json:"cooperationProjectNumber"`
39 CooperationProjectDescription string `json:"cooperationProjectDescription"` 39 CooperationProjectDescription string `json:"cooperationProjectDescription"`
40 CooperationProjectName string `json:"cooperationProjectName"` 40 CooperationProjectName string `json:"cooperationProjectName"`
41 - Attachment []struct { 41 + CooperationMode struct {
  42 + // 共创模式ID
  43 + CooperationModeId int `json:"cooperationModeId,string"`
  44 + // 共创模式编码,唯一确定
  45 + CooperationModeNumber string `json:"cooperationModeNumber"`
  46 + // 模式名称,唯一确定
  47 + CooperationModeName string `json:"cooperationModeName"`
  48 + } `json:"cooperationMode"`
  49 + Attachment []struct {
42 FileType string `json:"fileType"` 50 FileType string `json:"fileType"`
43 Name string `json:"name"` 51 Name string `json:"name"`
44 URL string `json:"url"` 52 URL string `json:"url"`
@@ -79,6 +87,19 @@ type ( @@ -79,6 +87,19 @@ type (
79 } 87 }
80 ) 88 )
81 89
  90 +//共创申请批量审核
  91 +type (
  92 + ReqCooperationApplicationApproval struct {
  93 + CooperationApplicationId string `json:"cooperationApplicationId"`
  94 + CooperationApplicationDescription string `json:"cooperationApplicationDescription"` //描述
  95 + Action int `json:"action"` //审核动作,1同意,2拒绝
  96 + Code string `cname:"菜单编码" json:"code" valid:"Required"`
  97 + }
  98 +
  99 + DataCooperationApplicationApproval struct {
  100 + }
  101 +)
  102 +
82 //取消共创申请 103 //取消共创申请
83 type ( 104 type (
84 ReqCooperationApplicationCancel struct { 105 ReqCooperationApplicationCancel struct {
@@ -108,7 +108,7 @@ type ( @@ -108,7 +108,7 @@ type (
108 CooperationProjectName string `json:"cooperationProjectName"` 108 CooperationProjectName string `json:"cooperationProjectName"`
109 CooperationModeNumber string `json:"cooperationModeNumber"` 109 CooperationModeNumber string `json:"cooperationModeNumber"`
110 // 承接对象,1员工,2共创用户,3公开,可以多选 110 // 承接对象,1员工,2共创用户,3公开,可以多选
111 - CooperationProjectUndertakerType []int32 `json:"cooperationProjectUndertakerType"` 111 + CooperationProjectUndertakerType []int32 `json:"cooperationProjectUndertakerTypes"`
112 // 共创项目发起人uid 112 // 共创项目发起人uid
113 SponsorUid string `json:"sponsorUid"` 113 SponsorUid string `json:"sponsorUid"`
114 // 共创项目发布人uid 114 // 共创项目发布人uid
1 package controllers 1 package controllers
2 2
3 import ( 3 import (
  4 + "github.com/linmadan/egglib-go/core/application"
4 "github.com/linmadan/egglib-go/utils/json" 5 "github.com/linmadan/egglib-go/utils/json"
5 "github.com/linmadan/egglib-go/web/beego" 6 "github.com/linmadan/egglib-go/web/beego"
  7 + "github.com/linmadan/egglib-go/web/beego/utils"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
8 ) 10 )
@@ -31,6 +33,28 @@ func (controller *BaseController) ReturnListData(count int64, data interface{}, @@ -31,6 +33,28 @@ func (controller *BaseController) ReturnListData(count int64, data interface{},
31 controller.Response(dataMap, err) 33 controller.Response(dataMap, err)
32 } 34 }
33 35
  36 +func (controller *BaseController) Response(data interface{}, err error) {
  37 + var response utils.JsonResponse
  38 + if err != nil {
  39 + if _, ok := err.(*application.ServiceError); !ok {
  40 + controller.Data["json"] = map[string]interface{}{
  41 + "code": 1,
  42 + "msg": err.Error(),
  43 + }
  44 + log.Logger.Error(err.Error())
  45 + controller.ServeJSON()
  46 + return
  47 + }
  48 + }
  49 + if err != nil {
  50 + response = utils.ResponseError(controller.Ctx, err)
  51 + } else {
  52 + response = utils.ResponseData(controller.Ctx, data)
  53 + }
  54 + controller.Data["json"] = response
  55 + controller.ServeJSON()
  56 +}
  57 +
34 func (controller *BaseController) GetUserId() int64 { 58 func (controller *BaseController) GetUserId() int64 {
35 return 1 59 return 1
36 } 60 }
@@ -50,6 +50,7 @@ func (controller *CooperationController) GetCooperationApplication() { @@ -50,6 +50,7 @@ func (controller *CooperationController) GetCooperationApplication() {
50 return 50 return
51 } 51 }
52 cmd.Operator = controller.GetOperator() 52 cmd.Operator = controller.GetOperator()
  53 + cmd.CooperationApplicationId, _ = controller.GetInt64(":applicationId")
53 data, err := svr.GetCooperationApplications(cmd) 54 data, err := svr.GetCooperationApplications(cmd)
54 controller.Response(data, err) 55 controller.Response(data, err)
55 } 56 }