作者 yangfu

共创项目列表修改

package service
import (
"errors"
"time"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
... ... @@ -30,7 +29,7 @@ func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{
Phone: loginCommand.Phone,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "系统错误")
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
switch loginCommand.GrantType {
case "signInPassword":
... ... @@ -38,7 +37,7 @@ func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{
case "signInCaptcha":
result, err = srv.SignInCaptcha(loginCommand.Phone, loginCommand.Captcha)
default:
err = errors.New("登录方式无法解析")
err = application.ThrowError(application.TRANSACTION_ERROR, "登录方式无法解析")
}
return result, err
}
... ...
... ... @@ -17,7 +17,7 @@ type CreateCooperationProjectCommand struct {
// 共创项目名称
CooperationProjectName string `json:"cooperationProjectName" valid:"Required"`
// 共创发起人id
CooperationProjectSponsor int `json:"cooperationProjectSponsor,string,"`
CooperationProjectSponsor int `json:"cooperationProjectSponsor"`
// 项目承接对象
CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"`
// 共创项目描述
... ...
... ... @@ -28,6 +28,7 @@ func (srv CooperationProjectService) CreateCooperationProject(createCooperationP
}
result, err := creationCooperationGateway.CooperationProjectAdd(allied_creation_cooperation.ReqCooperationProjectAdd{
CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
CooperationModeNumber: createCooperationProjectCommand.CooperationModeNumber,
CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
PublisherUid: int(createCooperationProjectCommand.Operator.UserId),
SponsorUid: createCooperationProjectCommand.CooperationProjectSponsor,
... ... @@ -116,12 +117,12 @@ func (srv CooperationProjectService) SearchCooperationProject(projectQuery *comm
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
//var dataList []dto.CooperationProjectItem
//for i := range result.List {
// item := dto.ToCooperationProjectItem(&result.List[i])
// dataList = append(dataList, *item)
//}
return int(result.Total), result.List, nil
}
// PersonSearchCooperationProject 共创用户获取共创项目列表
... ... @@ -137,10 +138,10 @@ func (srv CooperationProjectService) PersonSearchCooperationProject(projectQuery
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
//var dataList []dto.CooperationProjectItem
//for i := range result.List {
// item := dto.ToCooperationProjectItem(&result.List[i])
// dataList = append(dataList, *item)
//}
return int(result.Total), result, nil
}
... ...
... ... @@ -42,7 +42,7 @@ func (srv AuthService) SignInPassword(account string, password string) (interfac
Phone: account,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
ltoken := domain.LoginToken{
UserId: 0,
... ... @@ -52,7 +52,7 @@ func (srv AuthService) SignInPassword(account string, password string) (interfac
}
authcode, err := ltoken.GenerateAuthCode()
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
result := map[string]string{
"authCode": authcode,
... ...
... ... @@ -117,15 +117,15 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var (
dataList = []dto.CooperationProjectInfo{}
)
for i := range result.List {
item := dto.ToCooperationProjectInfo(&result.List[i])
dataList = append(dataList, *item)
}
return result.Total, dataList, nil
//
//var (
// dataList = []dto.CooperationProjectInfo{}
//)
//for i := range result.List {
// item := dto.ToCooperationProjectInfo(&result.List[i])
// dataList = append(dataList, *item)
//}
return int64(result.Total), result.List, nil
}
// 更新共创项目管理
... ...
... ... @@ -157,8 +157,86 @@ type (
}
DataCooperationProjectSearch struct {
Total int64 `json:"total"`
List []CooperationProject `json:"cooperationProjects"`
//Total int64 `json:"total"`
//List []CooperationProject `json:"cooperationProjects"`
List []struct {
CooperationProjectID string `json:"cooperationProjectId"`
CooperationProjectNumber string `json:"cooperationProjectNumber"`
CooperationProjectDescription string `json:"cooperationProjectDescription"`
CooperationProjectName string `json:"cooperationProjectName"`
CooperationProjectPublishTime time.Time `json:"cooperationProjectPublishTime"`
CooperationProjectPublisher struct {
UserID string `json:"userId"`
UserBaseID string `json:"userBaseId"`
Department interface{} `json:"department"`
UserInfo struct {
UserAvatar string `json:"userAvatar"`
UserEmail string `json:"userEmail"`
UserName string `json:"userName"`
UserPhone string `json:"userPhone"`
UserAccount string `json:"userAccount"`
} `json:"userInfo"`
//UserType int `json:"userType"`
//UserName string `json:"userName"`
//UserPhone string `json:"userPhone"`
//Status int `json:"status"`
} `json:"cooperationProjectPublisher"`
CooperationProjectSponsor struct {
UserID string `json:"userId"`
UserBaseID string `json:"userBaseId"`
Department interface{} `json:"department"`
UserInfo struct {
UserAvatar string `json:"userAvatar"`
UserEmail string `json:"userEmail"`
UserName string `json:"userName"`
UserPhone string `json:"userPhone"`
UserAccount string `json:"userAccount"`
} `json:"userInfo"`
//UserType int `json:"userType"`
//UserName string `json:"userName"`
//UserPhone string `json:"userPhone"`
//Status int `json:"status"`
} `json:"cooperationProjectSponsor"`
Department struct {
DepartmentID string `json:"departmentId"`
DepartmentName string `json:"departmentName"`
DepartmentNumber string `json:"departmentNumber"`
//IsOrganization bool `json:"isOrganization"`
} `json:"department"`
CooperationProjectUndertakerTypes []int `json:"cooperationProjectUndertakerTypes"`
Org struct {
OrgID string `json:"orgId"`
OrgName string `json:"orgName"`
} `json:"org"`
Attachment interface{} `json:"attachment"`
Company struct {
CompanyID string `json:"companyId"`
CompanyLogo string `json:"companyLogo"`
CompanyName string `json:"companyName"`
} `json:"company"`
Operator struct {
UserID string `json:"userId"`
UserBaseID string `json:"userBaseId"`
Department interface{} `json:"department"`
UserInfo struct {
UserAvatar string `json:"userAvatar"`
UserEmail string `json:"userEmail"`
UserName string `json:"userName"`
UserPhone string `json:"userPhone"`
UserAccount string `json:"userAccount"`
} `json:"userInfo"`
//UserType int `json:"userType"`
//UserName string `json:"userName"`
//UserPhone string `json:"userPhone"`
//Status int `json:"status"`
} `json:"operator"`
//OperateTime time.Time `json:"operateTime"`
Status int `json:"status"`
//UpdatedAt time.Time `json:"updatedAt"`
//DeletedAt time.Time `json:"deletedAt"`
//CreatedAt time.Time `json:"createdAt"`
} `json:"list"`
Total int `json:"total"`
}
)
... ...
... ... @@ -22,6 +22,15 @@ func (controller *baseController) returnPageListData(count int64, data interface
controller.Response(dataMap, err)
}
func (controller *baseController) returnMobilePageListData(count int64, data interface{}, err error, pageNumber int) {
dataMap := map[string]interface{}{
"total": count,
//"pageNumber": pageNumber,
"list": data,
}
controller.Response(dataMap, err)
}
func (controller *baseController) GetUserId() int64 {
return 1
}
... ...
... ... @@ -207,8 +207,8 @@ func (controller *CooperationController) SearchCooperationProject() {
return
}
cmd.Operator = controller.GetOperator()
_, data, err := svr.SearchCooperationProject(cmd)
controller.Response(data, err)
total, data, err := svr.SearchCooperationProject(cmd)
controller.returnMobilePageListData(int64(total), data, err, cmd.PageNumber)
}
func (controller *CooperationController) PersonSearchCooperationProject() {
... ...