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