作者 tangxuhui

更新数据结构 调整适配

... ... @@ -14,12 +14,8 @@ type ListCooperationApplicationQuery struct {
PageNumber int `json:"pageNumber" valid:"Required"`
// 查询限制
PageSize int `json:"pageSize" valid:"Required"`
//共创项目名称
ProjectName string `json:"projectName"`
//申请人名称
ApplicantName string `json:"applicantName"`
//审核状态
VerifyStatus int `json:"verifyStatus"`
Status int `json:"status"`
}
func (listCooperationApplicationQuery *ListCooperationApplicationQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -11,7 +11,7 @@ type EndCooperationProjectCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 共创项目id
CooperationProjectId []int64 `json:"cooperationProjectId,omitempty"`
CooperationProjectId []int `json:"cooperationProjectId,omitempty"`
}
func (endCooperationProjectCommand *EndCooperationProjectCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -39,3 +39,14 @@ func (listCooperationProjectQuery *ListCooperationProjectQuery) ValidateQuery()
}
return nil
}
type PersonSearchCooperationProjectQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 查询偏离量
PageNumber int `json:"pageNumber"`
// 查询限制
PageSize int `json:"pageSize" valid:"Required"`
//
OrgId int `json:"orgId"`
}
... ...
... ... @@ -3,6 +3,7 @@ package service
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/infrastructure/service_gateway/allied_creation_cooperation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
... ... @@ -43,18 +44,19 @@ func (srv CooperationApplicationsService) AuditCooperationApplications(userMenus
}
// GetCooperationApplications TODO:企业获取共创申请列表
func (srv CooperationApplicationsService) SearchCooperationApplications(userMenusCommand *command.ListCooperationApplicationQuery) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
func (srv CooperationApplicationsService) SearchCooperationApplications(applicationQuery *command.ListCooperationApplicationQuery) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
applicationQuery.Operator)
resultMenu, err := creationCooperationGateway.CooperationApplicationsSearch(allied_creation_cooperation.ReqCooperationApplicationSearch{
PageNumber: applicationQuery.PageNumber,
PageSize: applicationQuery.PageSize,
CompanyId: int(applicationQuery.Operator.CompanyId),
CooperationApplicationStatus: applicationQuery.Status,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
return resultMenu, nil
}
/***** 共创用户端 *****/
... ...
package service
import (
"strconv"
"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/infrastructure/service_gateway/allied_creation_cooperation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
// CooperationProjectService 共创项目服务
... ... @@ -18,13 +19,19 @@ func (srv CooperationProjectService) CreateCooperationProject(createCooperationP
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(createCooperationProjectCommand.Operator)
var images []allied_creation_cooperation.ProjectAttachment
for _, v := range createCooperationProjectCommand.Images {
images = append(images, allied_creation_cooperation.ProjectAttachment{
Url: v,
})
}
result, err := creationCooperationGateway.CooperationProjectAdd(allied_creation_cooperation.ReqCooperationProjectAdd{
CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
PublisherUid: int(createCooperationProjectCommand.Operator.UserId),
SponsorUid: createCooperationProjectCommand.CooperationProjectSponsor,
CooperationProjectUndertakerType: createCooperationProjectCommand.CooperationProjectUndertakerType,
// Images: createCooperationProjectCommand.Images,
Attachment: images,
})
if err != nil {
... ... @@ -55,34 +62,45 @@ func (srv CooperationProjectService) GetCooperationProject(projectQuery *command
}
// UpdateCooperationProject
//TODO 企业更新共创项目
func (srv CooperationProjectService) UpdateCooperationProject(userMenusCommand *command.UpdateCooperationProjectCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
func (srv CooperationProjectService) UpdateCooperationProject(updateCooperationProjectCommand *command.UpdateCooperationProjectCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(updateCooperationProjectCommand.Operator)
var images []allied_creation_cooperation.ProjectAttachment
for _, v := range updateCooperationProjectCommand.Images {
images = append(images, allied_creation_cooperation.ProjectAttachment{
Url: v,
})
}
_, err := creationCooperationGateway.CooperationProjectUpdate(allied_creation_cooperation.ReqCooperationProjectUpdate{
CooperationProjectId: updateCooperationProjectCommand.CooperationProjectId,
CooperationProjectName: updateCooperationProjectCommand.CooperationProjectName,
CooperationModeNumber: updateCooperationProjectCommand.CooperationModeNumber,
CooperationProjectUndertakerType: updateCooperationProjectCommand.CooperationProjectUndertakerType,
SponsorUid: updateCooperationProjectCommand.CooperationProjectSponsor,
PublisherUid: strconv.Itoa(int(updateCooperationProjectCommand.Operator.UserId)),
CooperationProjectDescription: updateCooperationProjectCommand.CooperationProjectDescription,
Attachment: images,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
return updateCooperationProjectCommand, nil
}
// EndCooperationProject TODO:企业结束共创项目
func (srv CooperationProjectService) EndCooperationProject(userMenusCommand *command.EndCooperationProjectCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
// EndCooperationProject 企业结束共创项目
func (srv CooperationProjectService) EndCooperationProject(endCooperationProjectCommand *command.EndCooperationProjectCommand) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(endCooperationProjectCommand.Operator)
var projectIds []string
for _, v := range endCooperationProjectCommand.CooperationProjectId {
idStr := strconv.Itoa(v)
projectIds = append(projectIds, idStr)
}
_, err := creationCooperationGateway.CooperationProjectBatchEnd(allied_creation_cooperation.ReqCooperationProjectBatchEnd{
CooperationProjectIds: projectIds,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
return endCooperationProjectCommand, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// SearchCooperationProject 企业获取共创项目列表
... ... @@ -104,3 +122,24 @@ func (srv CooperationProjectService) SearchCooperationProject(projectQuery *comm
}
return int(result.Total), dataList, nil
}
// PersonSearchCooperationProject 共创用户获取共创项目列表
func (srv CooperationProjectService) PersonSearchCooperationProject(projectQuery *command.PersonSearchCooperationProjectQuery) (int, interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
projectQuery.Operator)
orgidStr := strconv.Itoa(projectQuery.OrgId)
result, err := creationCooperationGateway.CooperationProjectsSearch(allied_creation_cooperation.ReqCooperationProjectSearch{
PageNumber: projectQuery.PageNumber,
PageSize: projectQuery.PageSize,
OrgIds: []string{orgidStr},
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var dataList []dto.CooperationProjectItem
for i := range result.List {
item := dto.ToCooperationProjectItem(&result.List[i])
dataList = append(dataList, *item)
}
return int(result.Total), dataList, nil
}
... ...
... ... @@ -11,7 +11,7 @@ type EndCooperationProjectCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 共创项目id
CooperationProjectId []int64 `json:"cooperationProjectId,omitempty"`
CooperationProjectId []string `json:"cooperationProjectId,omitempty"`
}
func (endCooperationProjectCommand *EndCooperationProjectCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -20,14 +20,21 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(createCooperationProjectCommand.Operator)
var images []allied_creation_cooperation.ProjectAttachment
for _, v := range createCooperationProjectCommand.Images {
images = append(images, allied_creation_cooperation.ProjectAttachment{
Url: v,
})
}
result, err := creationCooperationGateway.CooperationProjectAdd(allied_creation_cooperation.ReqCooperationProjectAdd{
CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
CooperationModeNumber: createCooperationProjectCommand.CooperationModeNumber,
PublisherUid: int(createCooperationProjectCommand.Operator.UserId),
SponsorUid: createCooperationProjectCommand.CooperationProjectSponsor,
CooperationProjectUndertakerType: createCooperationProjectCommand.CooperationProjectUndertakerType,
// Images: createCooperationProjectCommand.Images,
//TODO
Attachment: images,
})
if err != nil {
... ... @@ -48,9 +55,14 @@ func (cooperationProjectService *CooperationProjectService) EndCooperationProjec
if err := endCooperationProjectCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
//creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(endCooperationProjectCommand.Operator)
//TODO 等待接口
return nil, nil
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(endCooperationProjectCommand.Operator)
_, err := creationCooperationGateway.CooperationProjectBatchEnd(allied_creation_cooperation.ReqCooperationProjectBatchEnd{
CooperationProjectIds: endCooperationProjectCommand.CooperationProjectId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return endCooperationProjectCommand, nil
}
// 返回共创项目管理
... ... @@ -121,14 +133,21 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(updateCooperationProjectCommand.Operator)
var images []allied_creation_cooperation.ProjectAttachment
for _, v := range updateCooperationProjectCommand.Images {
images = append(images, allied_creation_cooperation.ProjectAttachment{
Url: v,
})
}
_, err := creationCooperationGateway.CooperationProjectUpdate(allied_creation_cooperation.ReqCooperationProjectUpdate{
CooperationProjectId: updateCooperationProjectCommand.CooperationProjectId,
CooperationProjectName: updateCooperationProjectCommand.CooperationProjectName,
CooperationModeNumber: updateCooperationProjectCommand.CooperationModeNumber,
CooperationProjectUndertakerType: updateCooperationProjectCommand.CooperationProjectUndertakerType,
SponsorUid: updateCooperationProjectCommand.CooperationProjectSponsor,
PublisherUid: strconv.Itoa(int(updateCooperationProjectCommand.Operator.UserId)),
CooperationProjectDescription: updateCooperationProjectCommand.CooperationProjectDescription,
Images: updateCooperationProjectCommand.Images,
Attachment: images,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ...
... ... @@ -256,3 +256,34 @@ func (gateway HttplibAlliedCreationCooperation) CooperationProjectsCheck(param R
err = gateway.GetResponseData(result, &data)
return &data, err
}
//CooperationProjectBatchEnd 批量结束共创项目
func (gateway HttplibAlliedCreationCooperation) CooperationProjectBatchEnd(param ReqCooperationProjectBatchEnd) (*DataCooperationProjectBatchEnd, error) {
url := gateway.baseUrL + "/cooperation-projects/batch-end"
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 DataCooperationProjectBatchEnd
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
... ... @@ -228,6 +228,7 @@ type (
CooperationProjectNumber string `json:"cooperationProjectNumber"` //共创项目编号
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
CompanyId int `json:"companyId"`
}
DataCooperationApplicationSearch struct {
... ...
... ... @@ -62,6 +62,7 @@ type (
ReqCooperationProjectAdd struct {
CooperationProjectDescription string `json:"cooperationProjectDescription"`
CooperationProjectName string `json:"cooperationProjectName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
PublisherUid int `json:"publisherUid,string"`
SponsorUid int `json:"sponsorUid,string"`
DepartmentId int `json:"departmentId,string"`
... ... @@ -101,6 +102,7 @@ type (
CooperationProjectId string `json:"cooperationProjectId" `
// 共创项目名称
CooperationProjectName string `json:"cooperationProjectName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
// 承接对象,1员工,2共创用户,3公开,可以多选
CooperationProjectUndertakerType []int32 `json:"cooperationProjectUndertakerType"`
// 共创项目发起人uid
... ... @@ -108,8 +110,8 @@ type (
// 共创项目发布人uid
PublisherUid string `json:"publisherUid"`
// 共创项目描述
CooperationProjectDescription string `json:"cooperationProjectDescription"`
Images []string `json:"images"`
CooperationProjectDescription string `json:"cooperationProjectDescription"`
Attachment []ProjectAttachment `json:"attachment"`
}
DataCooperationProjectUpdate struct {
... ... @@ -147,6 +149,8 @@ type (
CooperationProjectName string `json:"cooperationProjectName"`
// 共创项目状态,1招标中,2结束 0 全部
Status int `json:"status"`
//
OrgIds []string `json:"orgIds"`
}
DataCooperationProjectSearch struct {
... ... @@ -165,3 +169,13 @@ type (
DataCooperationProjectsCheck struct {
}
)
// 批量结束项目
type (
ReqCooperationProjectBatchEnd struct {
CooperationProjectIds []string `json:"cooperationProjectId"`
}
DataCooperationProjectBatchEnd struct {
}
)
... ...
... ... @@ -198,6 +198,19 @@ func (controller *CooperationController) SearchCooperationProject() {
controller.Response(data, err)
}
func (controller *CooperationController) PersonSearchCooperationProject() {
svr := service.CooperationProjectService{}
cmd := &command.PersonSearchCooperationProjectQuery{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
_, data, err := svr.PersonSearchCooperationProject(cmd)
controller.Response(data, err)
}
/***** CompanyCreditAccountService 企业端账期结算 *****/
func (controller *CooperationController) CreditAccountSearch() {
svr := service.CompanyCreditAccountService{}
... ...
... ... @@ -62,8 +62,10 @@ func (controller *CooperationProjectController) ListCooperationProject() {
func (controller *CooperationProjectController) EndCooperationProject() {
cooperationProjectService := service.NewCooperationProjectService(nil)
endCooperationProjectCommand := &command.EndCooperationProjectCommand{}
controller.Unmarshal(endCooperationProjectCommand)
//TODO
err := controller.Unmarshal(endCooperationProjectCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
endCooperationProjectCommand.Operator = controller.GetOperator()
data, err := cooperationProjectService.EndCooperationProject(endCooperationProjectCommand)
controller.Response(data, err)
... ...
... ... @@ -13,11 +13,11 @@ func init() {
web.Router("/v1/web/cooperation-projects/end", &web_client.CooperationProjectController{}, "Put:EndCooperationProject")
/***** 1.共创模式 *****/
web.Router("/v1/web/cooperation-modes/", &web_client.CooperationModeController{}, "Post:CreateCooperationMode")
web.Router("/v1/web/cooperation-modes/:cooperationModeId", &web_client.CooperationModeController{}, "Put:UpdateCooperationMode")
web.Router("/v1/web/cooperation-modes/:cooperationModeId", &web_client.CooperationModeController{}, "Get:GetCooperationMode")
web.Router("/v1/web/cooperation-modes/:cooperationModeId", &web_client.CooperationModeController{}, "Delete:RemoveCooperationMode")
web.Router("/v1/web/cooperation-modes/search", &web_client.CooperationModeController{}, "Post:SearchCooperationMode")
web.Router("/v1/web/cooperation-modes/", &web_client.CooperationModeController{}, "Get:ListCooperationMode")
// web.Router("/v1/web/cooperation-modes/", &web_client.CooperationModeController{}, "Post:CreateCooperationMode")
// web.Router("/v1/web/cooperation-modes/:cooperationModeId", &web_client.CooperationModeController{}, "Put:UpdateCooperationMode")
// web.Router("/v1/web/cooperation-modes/:cooperationModeId", &web_client.CooperationModeController{}, "Get:GetCooperationMode")
// web.Router("/v1/web/cooperation-modes/:cooperationModeId", &web_client.CooperationModeController{}, "Delete:RemoveCooperationMode")
// web.Router("/v1/web/cooperation-modes/search", &web_client.CooperationModeController{}, "Post:SearchCooperationMode")
// web.Router("/v1/web/cooperation-modes/", &web_client.CooperationModeController{}, "Get:ListCooperationMode")
}
... ...