作者 yangfu

共创项目列表修改

1 package service 1 package service
2 2
3 import ( 3 import (
4 - "errors"  
5 "time" 4 "time"
6 5
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
@@ -30,7 +29,7 @@ func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{ @@ -30,7 +29,7 @@ func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{
30 Phone: loginCommand.Phone, 29 Phone: loginCommand.Phone,
31 }) 30 })
32 if err != nil { 31 if err != nil {
33 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "系统错误") 32 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
34 } 33 }
35 switch loginCommand.GrantType { 34 switch loginCommand.GrantType {
36 case "signInPassword": 35 case "signInPassword":
@@ -38,7 +37,7 @@ func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{ @@ -38,7 +37,7 @@ func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{
38 case "signInCaptcha": 37 case "signInCaptcha":
39 result, err = srv.SignInCaptcha(loginCommand.Phone, loginCommand.Captcha) 38 result, err = srv.SignInCaptcha(loginCommand.Phone, loginCommand.Captcha)
40 default: 39 default:
41 - err = errors.New("登录方式无法解析") 40 + err = application.ThrowError(application.TRANSACTION_ERROR, "登录方式无法解析")
42 } 41 }
43 return result, err 42 return result, err
44 } 43 }
@@ -17,7 +17,7 @@ type CreateCooperationProjectCommand struct { @@ -17,7 +17,7 @@ type CreateCooperationProjectCommand struct {
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"`
21 // 项目承接对象 21 // 项目承接对象
22 CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"` 22 CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"`
23 // 共创项目描述 23 // 共创项目描述
@@ -28,6 +28,7 @@ func (srv CooperationProjectService) CreateCooperationProject(createCooperationP @@ -28,6 +28,7 @@ func (srv CooperationProjectService) CreateCooperationProject(createCooperationP
28 } 28 }
29 result, err := creationCooperationGateway.CooperationProjectAdd(allied_creation_cooperation.ReqCooperationProjectAdd{ 29 result, err := creationCooperationGateway.CooperationProjectAdd(allied_creation_cooperation.ReqCooperationProjectAdd{
30 CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription, 30 CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
  31 + CooperationModeNumber: createCooperationProjectCommand.CooperationModeNumber,
31 CooperationProjectName: createCooperationProjectCommand.CooperationProjectName, 32 CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
32 PublisherUid: int(createCooperationProjectCommand.Operator.UserId), 33 PublisherUid: int(createCooperationProjectCommand.Operator.UserId),
33 SponsorUid: createCooperationProjectCommand.CooperationProjectSponsor, 34 SponsorUid: createCooperationProjectCommand.CooperationProjectSponsor,
@@ -116,12 +117,12 @@ func (srv CooperationProjectService) SearchCooperationProject(projectQuery *comm @@ -116,12 +117,12 @@ func (srv CooperationProjectService) SearchCooperationProject(projectQuery *comm
116 if err != nil { 117 if err != nil {
117 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 118 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
118 } 119 }
119 - var dataList []dto.CooperationProjectItem  
120 - for i := range result.List {  
121 - item := dto.ToCooperationProjectItem(&result.List[i])  
122 - dataList = append(dataList, *item)  
123 - }  
124 - return int(result.Total), dataList, nil 120 + //var dataList []dto.CooperationProjectItem
  121 + //for i := range result.List {
  122 + // item := dto.ToCooperationProjectItem(&result.List[i])
  123 + // dataList = append(dataList, *item)
  124 + //}
  125 + return int(result.Total), result.List, nil
125 } 126 }
126 127
127 // PersonSearchCooperationProject 共创用户获取共创项目列表 128 // PersonSearchCooperationProject 共创用户获取共创项目列表
@@ -137,10 +138,10 @@ func (srv CooperationProjectService) PersonSearchCooperationProject(projectQuery @@ -137,10 +138,10 @@ func (srv CooperationProjectService) PersonSearchCooperationProject(projectQuery
137 if err != nil { 138 if err != nil {
138 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 139 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
139 } 140 }
140 - var dataList []dto.CooperationProjectItem  
141 - for i := range result.List {  
142 - item := dto.ToCooperationProjectItem(&result.List[i])  
143 - dataList = append(dataList, *item)  
144 - }  
145 - return int(result.Total), dataList, nil 141 + //var dataList []dto.CooperationProjectItem
  142 + //for i := range result.List {
  143 + // item := dto.ToCooperationProjectItem(&result.List[i])
  144 + // dataList = append(dataList, *item)
  145 + //}
  146 + return int(result.Total), result, nil
146 } 147 }
@@ -42,7 +42,7 @@ func (srv AuthService) SignInPassword(account string, password string) (interfac @@ -42,7 +42,7 @@ func (srv AuthService) SignInPassword(account string, password string) (interfac
42 Phone: account, 42 Phone: account,
43 }) 43 })
44 if err != nil { 44 if err != nil {
45 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 45 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
46 } 46 }
47 ltoken := domain.LoginToken{ 47 ltoken := domain.LoginToken{
48 UserId: 0, 48 UserId: 0,
@@ -52,7 +52,7 @@ func (srv AuthService) SignInPassword(account string, password string) (interfac @@ -52,7 +52,7 @@ func (srv AuthService) SignInPassword(account string, password string) (interfac
52 } 52 }
53 authcode, err := ltoken.GenerateAuthCode() 53 authcode, err := ltoken.GenerateAuthCode()
54 if err != nil { 54 if err != nil {
55 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 55 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
56 } 56 }
57 result := map[string]string{ 57 result := map[string]string{
58 "authCode": authcode, 58 "authCode": authcode,
@@ -117,15 +117,15 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje @@ -117,15 +117,15 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje
117 if err != nil { 117 if err != nil {
118 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 118 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
119 } 119 }
120 -  
121 - var (  
122 - dataList = []dto.CooperationProjectInfo{}  
123 - )  
124 - for i := range result.List {  
125 - item := dto.ToCooperationProjectInfo(&result.List[i])  
126 - dataList = append(dataList, *item)  
127 - }  
128 - return result.Total, dataList, nil 120 + //
  121 + //var (
  122 + // dataList = []dto.CooperationProjectInfo{}
  123 + //)
  124 + //for i := range result.List {
  125 + // item := dto.ToCooperationProjectInfo(&result.List[i])
  126 + // dataList = append(dataList, *item)
  127 + //}
  128 + return int64(result.Total), result.List, nil
129 } 129 }
130 130
131 // 更新共创项目管理 131 // 更新共创项目管理
@@ -157,8 +157,86 @@ type ( @@ -157,8 +157,86 @@ type (
157 } 157 }
158 158
159 DataCooperationProjectSearch struct { 159 DataCooperationProjectSearch struct {
160 - Total int64 `json:"total"`  
161 - List []CooperationProject `json:"cooperationProjects"` 160 + //Total int64 `json:"total"`
  161 + //List []CooperationProject `json:"cooperationProjects"`
  162 + List []struct {
  163 + CooperationProjectID string `json:"cooperationProjectId"`
  164 + CooperationProjectNumber string `json:"cooperationProjectNumber"`
  165 + CooperationProjectDescription string `json:"cooperationProjectDescription"`
  166 + CooperationProjectName string `json:"cooperationProjectName"`
  167 + CooperationProjectPublishTime time.Time `json:"cooperationProjectPublishTime"`
  168 + CooperationProjectPublisher struct {
  169 + UserID string `json:"userId"`
  170 + UserBaseID string `json:"userBaseId"`
  171 + Department interface{} `json:"department"`
  172 + UserInfo struct {
  173 + UserAvatar string `json:"userAvatar"`
  174 + UserEmail string `json:"userEmail"`
  175 + UserName string `json:"userName"`
  176 + UserPhone string `json:"userPhone"`
  177 + UserAccount string `json:"userAccount"`
  178 + } `json:"userInfo"`
  179 + //UserType int `json:"userType"`
  180 + //UserName string `json:"userName"`
  181 + //UserPhone string `json:"userPhone"`
  182 + //Status int `json:"status"`
  183 + } `json:"cooperationProjectPublisher"`
  184 + CooperationProjectSponsor struct {
  185 + UserID string `json:"userId"`
  186 + UserBaseID string `json:"userBaseId"`
  187 + Department interface{} `json:"department"`
  188 + UserInfo struct {
  189 + UserAvatar string `json:"userAvatar"`
  190 + UserEmail string `json:"userEmail"`
  191 + UserName string `json:"userName"`
  192 + UserPhone string `json:"userPhone"`
  193 + UserAccount string `json:"userAccount"`
  194 + } `json:"userInfo"`
  195 + //UserType int `json:"userType"`
  196 + //UserName string `json:"userName"`
  197 + //UserPhone string `json:"userPhone"`
  198 + //Status int `json:"status"`
  199 + } `json:"cooperationProjectSponsor"`
  200 + Department struct {
  201 + DepartmentID string `json:"departmentId"`
  202 + DepartmentName string `json:"departmentName"`
  203 + DepartmentNumber string `json:"departmentNumber"`
  204 + //IsOrganization bool `json:"isOrganization"`
  205 + } `json:"department"`
  206 + CooperationProjectUndertakerTypes []int `json:"cooperationProjectUndertakerTypes"`
  207 + Org struct {
  208 + OrgID string `json:"orgId"`
  209 + OrgName string `json:"orgName"`
  210 + } `json:"org"`
  211 + Attachment interface{} `json:"attachment"`
  212 + Company struct {
  213 + CompanyID string `json:"companyId"`
  214 + CompanyLogo string `json:"companyLogo"`
  215 + CompanyName string `json:"companyName"`
  216 + } `json:"company"`
  217 + Operator struct {
  218 + UserID string `json:"userId"`
  219 + UserBaseID string `json:"userBaseId"`
  220 + Department interface{} `json:"department"`
  221 + UserInfo struct {
  222 + UserAvatar string `json:"userAvatar"`
  223 + UserEmail string `json:"userEmail"`
  224 + UserName string `json:"userName"`
  225 + UserPhone string `json:"userPhone"`
  226 + UserAccount string `json:"userAccount"`
  227 + } `json:"userInfo"`
  228 + //UserType int `json:"userType"`
  229 + //UserName string `json:"userName"`
  230 + //UserPhone string `json:"userPhone"`
  231 + //Status int `json:"status"`
  232 + } `json:"operator"`
  233 + //OperateTime time.Time `json:"operateTime"`
  234 + Status int `json:"status"`
  235 + //UpdatedAt time.Time `json:"updatedAt"`
  236 + //DeletedAt time.Time `json:"deletedAt"`
  237 + //CreatedAt time.Time `json:"createdAt"`
  238 + } `json:"list"`
  239 + Total int `json:"total"`
162 } 240 }
163 ) 241 )
164 242
@@ -22,6 +22,15 @@ func (controller *baseController) returnPageListData(count int64, data interface @@ -22,6 +22,15 @@ func (controller *baseController) returnPageListData(count int64, data interface
22 controller.Response(dataMap, err) 22 controller.Response(dataMap, err)
23 } 23 }
24 24
  25 +func (controller *baseController) returnMobilePageListData(count int64, data interface{}, err error, pageNumber int) {
  26 + dataMap := map[string]interface{}{
  27 + "total": count,
  28 + //"pageNumber": pageNumber,
  29 + "list": data,
  30 + }
  31 + controller.Response(dataMap, err)
  32 +}
  33 +
25 func (controller *baseController) GetUserId() int64 { 34 func (controller *baseController) GetUserId() int64 {
26 return 1 35 return 1
27 } 36 }
@@ -207,8 +207,8 @@ func (controller *CooperationController) SearchCooperationProject() { @@ -207,8 +207,8 @@ func (controller *CooperationController) SearchCooperationProject() {
207 return 207 return
208 } 208 }
209 cmd.Operator = controller.GetOperator() 209 cmd.Operator = controller.GetOperator()
210 - _, data, err := svr.SearchCooperationProject(cmd)  
211 - controller.Response(data, err) 210 + total, data, err := svr.SearchCooperationProject(cmd)
  211 + controller.returnMobilePageListData(int64(total), data, err, cmd.PageNumber)
212 } 212 }
213 213
214 func (controller *CooperationController) PersonSearchCooperationProject() { 214 func (controller *CooperationController) PersonSearchCooperationProject() {