作者 yangfu

模式修改

... ... @@ -2,6 +2,7 @@ package allied_creation_cooperation
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/jtime"
"time"
)
... ... @@ -164,7 +165,7 @@ type (
CooperationProjectNumber string `json:"cooperationProjectNumber"`
CooperationProjectDescription string `json:"cooperationProjectDescription"`
CooperationProjectName string `json:"cooperationProjectName"`
CooperationProjectPublishTime time.Time `json:"cooperationProjectPublishTime"`
CooperationProjectPublishTime jtime.TimeToUnixMsec `json:"cooperationProjectPublishTime"`
CooperationProjectPublisher struct {
UserID string `json:"userId"`
UserBaseID string `json:"userBaseId"`
... ...
... ... @@ -22,7 +22,7 @@ func (controller *baseController) returnPageListData(count int64, data interface
controller.Response(dataMap, err)
}
func (controller *baseController) returnMobilePageListData(count int64, data interface{}, err error, pageNumber int) {
func (controller *baseController) returnListData(count int64, data interface{}, err error) {
dataMap := map[string]interface{}{
"total": count,
//"pageNumber": pageNumber,
... ...
... ... @@ -208,7 +208,7 @@ func (controller *CooperationController) SearchCooperationProject() {
}
cmd.Operator = controller.GetOperator()
total, data, err := svr.SearchCooperationProject(cmd)
controller.returnMobilePageListData(int64(total), data, err, cmd.PageNumber)
controller.returnPageListData(int64(total), data, err, cmd.PageNumber)
}
func (controller *CooperationController) PersonSearchCooperationProject() {
... ...
... ... @@ -20,6 +20,14 @@ func (controller *baseController) returnPageListData(count int64, data interface
controller.Response(dataMap, err)
}
func (controller *baseController) returnListData(count int64, data interface{}, err error) {
dataMap := map[string]interface{}{
"total": count,
"list": data,
}
controller.Response(dataMap, err)
}
func (controller *baseController) GetOperator() domain.Operator {
token := controller.Ctx.Input.Header("X-Mmm-Accesstoken")
loginToken := &domain.LoginToken{}
... ...
... ... @@ -82,8 +82,8 @@ func (controller *CooperationModeController) ListCooperationMode() {
listCooperationModeQuery.Operator = controller.GetOperator()
listCooperationModeQuery.PageNumber = 1
listCooperationModeQuery.PageSize = 999
_, data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)
controller.Response(data, err)
cnt, data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)
controller.returnListData(cnt, data, err)
}
func (controller *CooperationModeController) EnableCooperationMode() {
... ...
... ... @@ -24,3 +24,26 @@ func (t UnixTimeSecond) UnmarshalJSON(v []byte) error {
t = UnixTimeSecond(time.Unix(int64(number), 0))
return nil
}
type TimeToUnixMsec int64
// MarshalJSON implements json.Marshaler.
func (t TimeToUnixMsec) MarshalJSON() ([]byte, error) {
stamp := fmt.Sprintf("%d", t)
return []byte(stamp), nil
}
// MarshalJSON implements json.Unmarshaler.
func (t *TimeToUnixMsec) UnmarshalJSON(v []byte) error {
if len(v) < 2 {
*t = 0
return nil
}
str := string(v[1 : len(v)-1])
number, err := time.Parse(time.RFC3339, str)
if err != nil {
return fmt.Errorf("时间类型需要使用时间戳传参:%w", err)
}
*t = TimeToUnixMsec(number.Unix() * 1000)
return nil
}
... ...