8000 fix:Optimizing meaningless code by JIeJaitt · Pull Request #6 · danmuking/DiTing-Go · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix:Optimizing meaningless code #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions service/contact_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import (
"DiTing-Go/global"
pkgEnum "DiTing-Go/pkg/domain/enum"
pkgReq "DiTing-Go/pkg/domain/vo/req"
"DiTing-Go/pkg/domain/vo/resp"
pkgResp "DiTing-Go/pkg/domain/vo/resp"
"DiTing-Go/pkg/utils"
"DiTing-Go/service/adapter"
"context"
"github.com/gin-gonic/gin"
cmap "github.com/orcaman/concurrent-map/v2"
"github.com/pkg/errors"
"strconv"
"sync"
"time"

"github.com/gin-gonic/gin"
cmap "github.com/orcaman/concurrent-map/v2"
"github.com/pkg/errors"
)

func GetContactListService(uid int64, pageReq pkgReq.PageReq) (pkgResp.ResponseData, error) {
Expand Down Expand Up @@ -280,15 +280,15 @@ func GetContactDetailService(c *gin.Context) {
uid := c.GetInt64("uid")
getMessageListReq := req.GetMessageListReq{}
if err := c.ShouldBindQuery(&getMessageListReq); err != nil { //ShouldBind()会自动推导
resp.ErrorResponse(c, "参数错误")
pkgResp.ErrorResponse(c, "参数错误")
c.Abort()
return
}
roomId := getMessageListReq.RoomId
cursor, err := timestampToTime(getMessageListReq.Cursor)
if err != nil {
global.Logger.Errorf("时间戳转换失败 %s", err)
resp.ErrorResponse(c, "系统正忙,请稍后再试")
pkgResp.ErrorResponse(c, "系统正忙,请稍后再试")
c.Abort()
return
}
Expand All @@ -302,7 +302,7 @@ func GetContactDetailService(c *gin.Context) {
_, err = contactQ.Where(contact.UID.Eq(uid), contact.RoomID.Eq(roomId)).Update(contact.ReadTime, time.Now())
if err != nil {
global.Logger.Errorf("更新会话失败 %s", err)
resp.ErrorResponse(c, "系统正忙,请稍后再试")
pkgResp.ErrorResponse(c, "系统正忙,请稍后再试")
c.Abort()
return
}
Expand All @@ -311,12 +311,12 @@ func GetContactDetailService(c *gin.Context) {
pageResp, err := GetContactDetail(roomId, pageRequest)
if err != nil {
global.Logger.Errorf("查询会话详情失败 %s", err)
resp.ErrorResponse(c, "系统正忙,请稍后再试")
pkgResp.ErrorResponse(c, "系统正忙,请稍后再试")
c.Abort()
return
}
resp.SuccessResponse(c, pageResp)
return

pkgResp.SuccessResponse(c, pageResp)
}

func GetContactDetail(roomID int64, pageRequest pkgReq.PageReq) (*pkgResp.PageResp, error) {
Expand Down
14 changes: 11 additions & 3 deletions service/friend_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import (
"DiTing-Go/utils/redisCache"
"context"
"fmt"
"github.com/pkg/errors"
"gorm.io/gen"
"gorm.io/gorm"
"sort"
"strconv"
"time"

"github.com/pkg/errors"
"gorm.io/gen"
"gorm.io/gorm"
)

// ApplyFriendService 添加好友
Expand Down Expand Up @@ -246,6 +247,13 @@ func AgreeFriend(uid, friendUid int64) error {
// 查到了,更新状态
if err == nil {
_, err := userFriendTx.Where(userFriend.UID.Eq(uid), userFriend.FriendUID.Eq(friendUid)).Update(userFriend.DeleteStatus, enum.NORMAL)
if err != nil {
if err := tx.Rollback(); err != nil {
global.Logger.Errorf("事务回滚失败 %s", err.Error())
}
global.Logger.Errorf("更新好友关系失败 %s", err.Error())
return err
}
_, err = userFriendTx.Where(userFriend.UID.Eq(friendUid), userFriend.FriendUID.Eq(uid)).Update(userFriend.DeleteStatus, enum.NORMAL)
if err != nil {
if err := tx.Rollback(); err != nil {
Expand Down
Loading
0