作者 yangfu

关注的共创项目

... ... @@ -219,3 +219,36 @@ func (srv CooperationProjectService) PersonSearchCooperationProjectShareInfo(pro
}
return result, nil
}
// PersonSearchCooperationProject 共创用户获取共创项目列表
func (srv CooperationProjectService) PersonSearchCooperationProjectStarred(projectQuery *command.PersonSearchCooperationProjectQuery) (int, interface{}, error) {
//extQueries := extQuires(projectQuery.Operator)
if projectQuery.Operator.UserBaseId == 0 {
return 0, []struct{}{}, nil
}
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(projectQuery.Operator)
userInfo, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
UserBaseId: projectQuery.Operator.UserBaseId,
})
if err != nil {
return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if len(userInfo.FavoriteOrg()) == 0 {
return 0, []struct{}{}, nil
}
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
projectQuery.Operator)
result, err := creationCooperationGateway.CooperationProjectsSearch(allied_creation_cooperation.ReqCooperationProjectSearch{
PageNumber: projectQuery.PageNumber + 1, //手机序号从0开始的
PageSize: projectQuery.PageSize,
Status: 1, //搜索状态为“招标中”项目
Keyword: projectQuery.Keyword,
OrgIds: userInfo.FavoriteOrg(),
IsSkipFetchProjectModel: true,
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return int(result.Total), result.List, nil
}
... ...
... ... @@ -111,7 +111,8 @@ type (
type (
ReqAuthUserBase struct {
// 手机号码
Account string `cname:"账号" json:"account" valid:"Required"`
Account string `cname:"账号" json:"account" valid:"Required"`
UserBaseId int64 `json:"userBaseId"`
}
DataAuthUserBase struct {
UserID int `json:"userId"`
... ... @@ -129,5 +130,26 @@ type (
ImToken string `json:"imToken"`
CsAccountID string `json:"csAccountId"`
} `json:"im"`
Favorite struct {
OrgItems []int64 `json:"orgItems"`
} `json:"favorite"`
}
)
func (user *DataAuthUserBase) CheckOrgStarred(orgId int64) bool {
var starred bool = false
for i := range user.Favorite.OrgItems {
if user.Favorite.OrgItems[i] == orgId {
starred = true
return starred
}
}
return false
}
func (user *DataAuthUserBase) FavoriteOrg() []int64 {
if user == nil {
return []int64{}
}
return user.Favorite.OrgItems
}
... ...
... ... @@ -249,7 +249,7 @@ func (controller *CooperationController) PersonSearchCooperationProjectStarred()
return
}
cmd.Operator = controller.GetOperator()
total, data, err := svr.PersonSearchCooperationProject(cmd)
total, data, err := svr.PersonSearchCooperationProjectStarred(cmd)
controller.ReturnPageListData(int64(total), data, err, cmd.PageNumber)
}
... ...