作者 yangfu

模式修改

@@ -2,6 +2,7 @@ package allied_creation_cooperation @@ -2,6 +2,7 @@ package allied_creation_cooperation
2 2
3 import ( 3 import (
4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/jtime"
5 "time" 6 "time"
6 ) 7 )
7 8
@@ -164,7 +165,7 @@ type ( @@ -164,7 +165,7 @@ type (
164 CooperationProjectNumber string `json:"cooperationProjectNumber"` 165 CooperationProjectNumber string `json:"cooperationProjectNumber"`
165 CooperationProjectDescription string `json:"cooperationProjectDescription"` 166 CooperationProjectDescription string `json:"cooperationProjectDescription"`
166 CooperationProjectName string `json:"cooperationProjectName"` 167 CooperationProjectName string `json:"cooperationProjectName"`
167 - CooperationProjectPublishTime time.Time `json:"cooperationProjectPublishTime"` 168 + CooperationProjectPublishTime jtime.TimeToUnixMsec `json:"cooperationProjectPublishTime"`
168 CooperationProjectPublisher struct { 169 CooperationProjectPublisher struct {
169 UserID string `json:"userId"` 170 UserID string `json:"userId"`
170 UserBaseID string `json:"userBaseId"` 171 UserBaseID string `json:"userBaseId"`
@@ -22,7 +22,7 @@ func (controller *baseController) returnPageListData(count int64, data interface @@ -22,7 +22,7 @@ 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) { 25 +func (controller *baseController) returnListData(count int64, data interface{}, err error) {
26 dataMap := map[string]interface{}{ 26 dataMap := map[string]interface{}{
27 "total": count, 27 "total": count,
28 //"pageNumber": pageNumber, 28 //"pageNumber": pageNumber,
@@ -208,7 +208,7 @@ func (controller *CooperationController) SearchCooperationProject() { @@ -208,7 +208,7 @@ func (controller *CooperationController) SearchCooperationProject() {
208 } 208 }
209 cmd.Operator = controller.GetOperator() 209 cmd.Operator = controller.GetOperator()
210 total, data, err := svr.SearchCooperationProject(cmd) 210 total, data, err := svr.SearchCooperationProject(cmd)
211 - controller.returnMobilePageListData(int64(total), data, err, cmd.PageNumber) 211 + controller.returnPageListData(int64(total), data, err, cmd.PageNumber)
212 } 212 }
213 213
214 func (controller *CooperationController) PersonSearchCooperationProject() { 214 func (controller *CooperationController) PersonSearchCooperationProject() {
@@ -20,6 +20,14 @@ func (controller *baseController) returnPageListData(count int64, data interface @@ -20,6 +20,14 @@ func (controller *baseController) returnPageListData(count int64, data interface
20 controller.Response(dataMap, err) 20 controller.Response(dataMap, err)
21 } 21 }
22 22
  23 +func (controller *baseController) returnListData(count int64, data interface{}, err error) {
  24 + dataMap := map[string]interface{}{
  25 + "total": count,
  26 + "list": data,
  27 + }
  28 + controller.Response(dataMap, err)
  29 +}
  30 +
23 func (controller *baseController) GetOperator() domain.Operator { 31 func (controller *baseController) GetOperator() domain.Operator {
24 token := controller.Ctx.Input.Header("X-Mmm-Accesstoken") 32 token := controller.Ctx.Input.Header("X-Mmm-Accesstoken")
25 loginToken := &domain.LoginToken{} 33 loginToken := &domain.LoginToken{}
@@ -82,8 +82,8 @@ func (controller *CooperationModeController) ListCooperationMode() { @@ -82,8 +82,8 @@ func (controller *CooperationModeController) ListCooperationMode() {
82 listCooperationModeQuery.Operator = controller.GetOperator() 82 listCooperationModeQuery.Operator = controller.GetOperator()
83 listCooperationModeQuery.PageNumber = 1 83 listCooperationModeQuery.PageNumber = 1
84 listCooperationModeQuery.PageSize = 999 84 listCooperationModeQuery.PageSize = 999
85 - _, data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)  
86 - controller.Response(data, err) 85 + cnt, data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)
  86 + controller.returnListData(cnt, data, err)
87 } 87 }
88 88
89 func (controller *CooperationModeController) EnableCooperationMode() { 89 func (controller *CooperationModeController) EnableCooperationMode() {
@@ -24,3 +24,26 @@ func (t UnixTimeSecond) UnmarshalJSON(v []byte) error { @@ -24,3 +24,26 @@ func (t UnixTimeSecond) UnmarshalJSON(v []byte) error {
24 t = UnixTimeSecond(time.Unix(int64(number), 0)) 24 t = UnixTimeSecond(time.Unix(int64(number), 0))
25 return nil 25 return nil
26 } 26 }
  27 +
  28 +type TimeToUnixMsec int64
  29 +
  30 +// MarshalJSON implements json.Marshaler.
  31 +func (t TimeToUnixMsec) MarshalJSON() ([]byte, error) {
  32 + stamp := fmt.Sprintf("%d", t)
  33 + return []byte(stamp), nil
  34 +}
  35 +
  36 +// MarshalJSON implements json.Unmarshaler.
  37 +func (t *TimeToUnixMsec) UnmarshalJSON(v []byte) error {
  38 + if len(v) < 2 {
  39 + *t = 0
  40 + return nil
  41 + }
  42 + str := string(v[1 : len(v)-1])
  43 + number, err := time.Parse(time.RFC3339, str)
  44 + if err != nil {
  45 + return fmt.Errorf("时间类型需要使用时间戳传参:%w", err)
  46 + }
  47 + *t = TimeToUnixMsec(number.Unix() * 1000)
  48 + return nil
  49 +}