Skip to content

Commit

Permalink
fix code check
Browse files Browse the repository at this point in the history
  • Loading branch information
Hourunze1997 committed Dec 26, 2024
1 parent 388ca9d commit 2e27087
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 503 deletions.
21 changes: 0 additions & 21 deletions message/app/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import (
)

type MessageListAppService interface {
GetInnerMessageQuick(userName string, cmd *CmdToGetInnerMessageQuick) ([]MessageListDTO,
int64, error)
GetInnerMessage(userName string, cmd *CmdToGetInnerMessage) ([]MessageListDTO, int64, error)
CountAllUnReadMessage(userName string) ([]CountDTO, error)
SetMessageIsRead(cmd *CmdToSetIsRead) error
RemoveMessage(cmd *CmdToSetIsRead) error
Expand Down Expand Up @@ -61,24 +58,6 @@ type messageListAppService struct {
messageListAdapter domain.MessageListAdapter
}

func (s *messageListAppService) GetInnerMessageQuick(userName string,
cmd *CmdToGetInnerMessageQuick) ([]MessageListDTO, int64, error) {
response, count, err := s.messageListAdapter.GetInnerMessageQuick(*cmd, userName)
if err != nil {
return []MessageListDTO{}, 0, err
}
return response, count, nil
}

func (s *messageListAppService) GetInnerMessage(userName string,
cmd *CmdToGetInnerMessage) ([]MessageListDTO, int64, error) {
response, count, err := s.messageListAdapter.GetInnerMessage(*cmd, userName)
if err != nil {
return []MessageListDTO{}, 0, err
}
return response, count, nil
}

func (s *messageListAppService) CountAllUnReadMessage(userName string) ([]CountDTO, error) {
count, err := s.messageListAdapter.CountAllUnReadMessage(userName)
if err != nil {
Expand Down
72 changes: 0 additions & 72 deletions message/controller/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ func AddRouterForMessageListController(
}

v1 := r.Group("/message_center")
v1.POST("/inner", ctl.GetInnerMessage)
v1.GET("/inner_quick", ctl.GetInnerMessageQuick)
v1.GET("/inner/count", ctl.CountAllUnReadMessage)
v1.PUT("/inner", ctl.SetMessageIsRead)
v1.DELETE("/inner", ctl.RemoveMessage)
Expand All @@ -52,76 +50,6 @@ type messageListController struct {
appService app.MessageListAppService
}

// GetInnerMessageQuick
// @Summary GetInnerMessageQuick
// @Description get inner message by filter
// @Tags message_center
// @Accept json
// @Success 202 {object} app.MessageListDTO
// @Failure 500 string system_error 查询失败
// @Failure 400 string bad_request 请求参数错误
// @Router /message_center/inner_quick [get]
// @Id getInnerMessageQuick
func (ctl *messageListController) GetInnerMessageQuick(ctx *gin.Context) {
var params queryInnerParamsQuick
if err := ctx.ShouldBindQuery(&params); err != nil {
commonctl.SendBadRequestParam(ctx, xerrors.Errorf("failed to bind params, %v", err))
return
}

cmd, err := params.toCmd()
if err != nil {
commonctl.SendBadRequestParam(ctx, xerrors.Errorf("failed to convert req to cmd, %v", err))

return
}
userName, err := user.GetEulerUserName(ctx)
if err != nil {
commonctl.SendUnauthorized(ctx, xerrors.Errorf("get username failed, err:%v", err))
return
}
if data, count, err := ctl.appService.GetInnerMessageQuick(userName, &cmd); err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{"error": xerrors.Errorf("查询失败,err:%v", err)})
} else {
ctx.JSON(http.StatusAccepted, gin.H{"query_info": data, "count": count})
}
}

// GetInnerMessage
// @Summary GetInnerMessage
// @Description get inner message
// @Tags message_center
// @Param Params query queryInnerParams true "Query InnerParams"
// @Accept json
// @Success 202 {object} app.MessageListDTO
// @Failure 500 string system_error 查询失败
// @Failure 400 string bad_request 无法解析请求正文
// @Router /message_center/inner [post]
// @Id getInnerMessage
func (ctl *messageListController) GetInnerMessage(ctx *gin.Context) {
var params queryInnerParams
if err := ctx.ShouldBindJSON(&params); err != nil {
commonctl.SendBadRequestParam(ctx, xerrors.Errorf("failed to bind params, %v", err))
return
}

cmd, err := params.toCmd()
if err != nil {
commonctl.SendBadRequestParam(ctx, xerrors.Errorf("failed to convert req to cmd, %v", err))
return
}
userName, err := user.GetEulerUserName(ctx)
if err != nil {
commonctl.SendUnauthorized(ctx, xerrors.Errorf("get username failed, err:%v", err))
return
}
if data, count, err := ctl.appService.GetInnerMessage(userName, &cmd); err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{"error": xerrors.Errorf("查询失败,err:%v", err)})
} else {
ctx.JSON(http.StatusAccepted, gin.H{"query_info": data, "count": count})
}
}

// CountAllUnReadMessage
// @Summary CountAllUnReadMessage
// @Description get unread inner message count
Expand Down
3 changes: 0 additions & 3 deletions message/domain/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved
package domain

type MessageListAdapter interface {
GetInnerMessageQuick(cmd CmdToGetInnerMessageQuick, serName string) (
[]MessageListDO, int64, error)
GetInnerMessage(cmd CmdToGetInnerMessage, userName string) ([]MessageListDO, int64, error)
CountAllUnReadMessage(userName string) ([]CountDO, error)
SetMessageIsRead(source, eventId string) error
RemoveMessage(source, eventId string) error
Expand Down
Loading

0 comments on commit 2e27087

Please sign in to comment.