Browse Source

feat: format code

pull/7/head
konenet 3 years ago
parent
commit
eef9f95837
  1. 3
      api/v1/group_router.go
  2. 3
      api/v1/user_router.go
  3. 2
      cmd/main.go
  4. 16
      common/constant/constant.go
  5. 19
      common/util/file-suffix.go
  6. 4
      server/client.go
  7. 2
      server/server.go
  8. 4
      test/proto_test.go

3
api/v1/group_router.go

@ -8,6 +8,7 @@ import ( @@ -8,6 +8,7 @@ import (
"github.com/gin-gonic/gin"
)
// 获取分组列表
func GetGroup(c *gin.Context) {
uuid := c.Param("uuid")
@ -47,4 +48,4 @@ func GetGroupUsers(c *gin.Context) { @@ -47,4 +48,4 @@ func GetGroupUsers(c *gin.Context) {
groupUuid := c.Param("uuid")
users := service.GroupService.GetUserIdByGroupUuid(groupUuid)
c.JSON(http.StatusOK, response.SuccessMsg(users))
}
}

3
api/v1/user_router.go

@ -50,7 +50,6 @@ func ModifyUserInfo(c *gin.Context) { @@ -50,7 +50,6 @@ func ModifyUserInfo(c *gin.Context) {
c.JSON(http.StatusOK, response.SuccessMsg(nil))
}
func GetUserDetails(c *gin.Context) {
uuid := c.Param("uuid")
@ -73,4 +72,4 @@ func AddFriend(c *gin.Context) { @@ -73,4 +72,4 @@ func AddFriend(c *gin.Context) {
}
c.JSON(http.StatusOK, response.SuccessMsg(nil))
}
}

2
cmd/main.go

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
package main
import (
"chat-room/global/log"
"chat-room/config"
"chat-room/global/log"
"chat-room/router"
"chat-room/server"
"go.uber.org/zap"

16
common/constant/constant.go

@ -2,16 +2,16 @@ package constant @@ -2,16 +2,16 @@ package constant
const (
HEAT_BEAT = "heatbeat"
PONG = "pong"
PONG = "pong"
MESSAGE_TYPE_USER = 1
MESSAGE_TYPE_USER = 1
MESSAGE_TYPE_GROUP = 2
TEXT = 1
FILE = 2
IMAGE = 3
AUDIO = 4
VIDEO = 5
TEXT = 1
FILE = 2
IMAGE = 3
AUDIO = 4
VIDEO = 5
AUDIO_ONLINE = 6
VIDEO_ONLINE = 7
)
)

19
common/util/file-suffix.go

@ -34,12 +34,12 @@ func init() { @@ -34,12 +34,12 @@ func init() {
fileTypeMap.Store("5374616E64617264204A", "mdb") //MS Access (mdb)
fileTypeMap.Store("252150532D41646F6265", "ps")
fileTypeMap.Store("255044462d312e350d0a", "pdf") //Adobe Acrobat (pdf)
fileTypeMap.Store("D0CF11E0", "xls") //xls
fileTypeMap.Store("504B030414000600080000002100", "xlsx") //xls
fileTypeMap.Store("d0cf11e0a1b11ae10000", "doc") //MS Excel 注意:word、msi 和 excel的文件头一样
fileTypeMap.Store("504b0304140006000800", "docx") //docx文件
fileTypeMap.Store("d0cf11e0a1b11ae10000", "wps") //WPS文字wps、表格et、演示dps都是一样的
fileTypeMap.Store("255044462d312e350d0a", "pdf") //Adobe Acrobat (pdf)
fileTypeMap.Store("D0CF11E0", "xls") //xls
fileTypeMap.Store("504B030414000600080000002100", "xlsx") //xls
fileTypeMap.Store("d0cf11e0a1b11ae10000", "doc") //MS Excel 注意:word、msi 和 excel的文件头一样
fileTypeMap.Store("504b0304140006000800", "docx") //docx文件
fileTypeMap.Store("d0cf11e0a1b11ae10000", "wps") //WPS文字wps、表格et、演示dps都是一样的
fileTypeMap.Store("2e524d46000000120001", "rmvb") //rmvb/rm相同
fileTypeMap.Store("464c5601050000000900", "flv") //flv与f4v相同
@ -49,12 +49,11 @@ func init() { @@ -49,12 +49,11 @@ func init() {
fileTypeMap.Store("3026b2758e66cf11a6d9", "wmv") //wmv与asf相同
fileTypeMap.Store("52494646e27807005741", "wav") //Wave (wav)
fileTypeMap.Store("52494646246009005741", "wav") //Wave (wav)
fileTypeMap.Store("52494646", "wav") //Wave (wav)
fileTypeMap.Store("52494646", "wav") //Wave (wav)
fileTypeMap.Store("52494646d07d60074156", "avi")
fileTypeMap.Store("1a45dfa3a34286810142", "webm")
fileTypeMap.Store("4d546864000000060001", "mid") //MIDI (mid)
fileTypeMap.Store("504b0304140000000800", "zip")
fileTypeMap.Store("526172211a0700cf9073", "rar")

4
server/client.go

@ -33,14 +33,14 @@ func (c *Client) Read() { @@ -33,14 +33,14 @@ func (c *Client) Read() {
msg := &protocol.Message{}
proto.Unmarshal(message, msg)
// pong
if msg.Type == constant.HEAT_BEAT {
pong := &protocol.Message{
Content: constant.PONG,
Type: constant.HEAT_BEAT,
}
pongByte, err2 :=proto.Marshal(pong)
pongByte, err2 := proto.Marshal(pong)
if nil != err2 {
log.Error("client marshal message error", log.Any("client marshal message error", err2.Error()))
}

2
server/server.go

@ -84,7 +84,7 @@ func (s *Server) Start() { @@ -84,7 +84,7 @@ func (s *Server) Start() {
client.Send <- message
}
}
} else {
// 无对应接受人员进行广播
for id, conn := range s.Clients {

4
test/proto_test.go

@ -1,5 +1 @@ @@ -1,5 +1 @@
package test
import (
)

Loading…
Cancel
Save