Commit f212f5bc by Li Feifei

add friend_request service

parent 1dae6eea
No preview for this file type
...@@ -56,7 +56,8 @@ func newMysqlClient() { ...@@ -56,7 +56,8 @@ func newMysqlClient() {
beeLogger.Log.Fatalf("db connect error => %v", err) beeLogger.Log.Fatalf("db connect error => %v", err)
return return
} }
orm.RegisterModel(new(CompanyApp), new(ImBase), new(ImChatRoom), new(ImUserRelationship), new(ImUser)) orm.RegisterModel(new(CompanyApp), new(ImBase), new(ImChatRoom),
new(ImUserRelationship), new(ImUser), new(ImFriendRequest))
orm.Debug = true orm.Debug = true
MysqlClient = orm.NewOrm() MysqlClient = orm.NewOrm()
beeLogger.Log.Success("MySQL connect success") beeLogger.Log.Success("MySQL connect success")
......
...@@ -55,3 +55,12 @@ type ImUser struct { ...@@ -55,3 +55,12 @@ type ImUser struct {
Platform string Platform string
Edition string Edition string
} }
type ImFriendRequest struct {
Id int
Accid string
Faccid string
Status int64
Createtime string
Updatetime string
}
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"im-microservice/pb" "im-microservice/pb"
"im-microservice/sevice/health" "im-microservice/sevice/health"
"im-microservice/sevice/im_chat_room" "im-microservice/sevice/im_chat_room"
"im-microservice/sevice/im_friend_request"
ic "im-microservice/sevice/im_configure" ic "im-microservice/sevice/im_configure"
"im-microservice/sevice/im_user" "im-microservice/sevice/im_user"
iur "im-microservice/sevice/im_user_relationship" iur "im-microservice/sevice/im_user_relationship"
...@@ -42,7 +43,7 @@ func init() { ...@@ -42,7 +43,7 @@ func init() {
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer( grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
grpc_validator.UnaryServerInterceptor(), grpc_validator.UnaryServerInterceptor(),
middleware.Interceptor, middleware.Interceptor,
middleware.Auth, //middleware.Auth,
grpc_recovery.UnaryServerInterceptor(middleware.RecoveryInterceptor()), grpc_recovery.UnaryServerInterceptor(middleware.RecoveryInterceptor()),
grpc_zap.UnaryServerInterceptor(middleware.ZapInterceptor()), grpc_zap.UnaryServerInterceptor(middleware.ZapInterceptor()),
))) )))
...@@ -52,6 +53,7 @@ func init() { ...@@ -52,6 +53,7 @@ func init() {
pb.RegisterChatRoomServiceServer(rpc_server, &im_chat_room.ImChatRoomService{}) pb.RegisterChatRoomServiceServer(rpc_server, &im_chat_room.ImChatRoomService{})
pb.RegisterImUserServer(rpc_server, &im_user.ImUserServer{}) pb.RegisterImUserServer(rpc_server, &im_user.ImUserServer{})
pb.RegisterUserRelationshipServiceServer(rpc_server, &iur.UserRelationshipService{}) pb.RegisterUserRelationshipServiceServer(rpc_server, &iur.UserRelationshipService{})
pb.RegisterImFriendServiceServer(rpc_server, &im_friend_request.ImFriendService{})
reflection.Register(rpc_server) reflection.Register(rpc_server)
RpcServer = rpc_server RpcServer = rpc_server
} }
...@@ -22,3 +22,18 @@ ...@@ -22,3 +22,18 @@
{"level":"error","ts":"2020-07-06T11:28:57.628+0800","caller":"grpclog/grpclog.go:51","msg":"grpc: server failed to encode response: rpc error: code = Internal desc = grpc: error while marshaling: proto: Marshal called with nil","system":"grpc","grpc_log":true} {"level":"error","ts":"2020-07-06T11:28:57.628+0800","caller":"grpclog/grpclog.go:51","msg":"grpc: server failed to encode response: rpc error: code = Internal desc = grpc: error while marshaling: proto: Marshal called with nil","system":"grpc","grpc_log":true}
{"level":"info","ts":"2020-07-06T13:42:58.519+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T13:42:58+08:00","grpc.request.deadline":"2020-07-06T13:43:01+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.UserRelationshipService","grpc.method":"ListBlackAndMuteList","grpc.code":"OK","grpc.time_ms":33.638999938964844} {"level":"info","ts":"2020-07-06T13:42:58.519+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T13:42:58+08:00","grpc.request.deadline":"2020-07-06T13:43:01+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.UserRelationshipService","grpc.method":"ListBlackAndMuteList","grpc.code":"OK","grpc.time_ms":33.638999938964844}
{"level":"info","ts":"2020-07-06T13:43:16.098+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T13:43:16+08:00","grpc.request.deadline":"2020-07-06T13:43:19+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.UserRelationshipService","grpc.method":"ListBlackAndMuteList","grpc.code":"OK","grpc.time_ms":17.27400016784668} {"level":"info","ts":"2020-07-06T13:43:16.098+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T13:43:16+08:00","grpc.request.deadline":"2020-07-06T13:43:19+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.UserRelationshipService","grpc.method":"ListBlackAndMuteList","grpc.code":"OK","grpc.time_ms":17.27400016784668}
{"level":"info","ts":"2020-07-06T15:31:36.222+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code AlreadyExists","grpc.start_time":"2020-07-06T15:31:35+08:00","grpc.request.deadline":"2020-07-06T15:31:38+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"Add","error":"rpc error: code = AlreadyExists desc = 已经添加过该好友","grpc.code":"AlreadyExists","grpc.time_ms":522.9140014648438}
{"level":"info","ts":"2020-07-06T15:35:26.910+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code NotFound","grpc.start_time":"2020-07-06T15:35:26+08:00","grpc.request.deadline":"2020-07-06T15:35:29+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"Add","error":"rpc error: code = NotFound desc = 用户不存在","grpc.code":"NotFound","grpc.time_ms":125.20099639892578}
{"level":"info","ts":"2020-07-06T15:36:07.905+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T15:36:07+08:00","grpc.request.deadline":"2020-07-06T15:36:10+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"Add","grpc.code":"OK","grpc.time_ms":458.4519958496094}
{"level":"info","ts":"2020-07-06T15:37:06.868+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T15:37:06+08:00","grpc.request.deadline":"2020-07-06T15:37:09+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"Add","grpc.code":"OK","grpc.time_ms":649.9130249023438}
{"level":"info","ts":"2020-07-06T15:37:40.312+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T15:37:39+08:00","grpc.request.deadline":"2020-07-06T15:37:42+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"Add","grpc.code":"OK","grpc.time_ms":657.301025390625}
{"level":"info","ts":"2020-07-06T15:38:05.741+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T15:38:04+08:00","grpc.request.deadline":"2020-07-06T15:38:07+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"Add","grpc.code":"OK","grpc.time_ms":779.1309814453125}
{"level":"info","ts":"2020-07-06T15:38:10.250+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T15:38:09+08:00","grpc.request.deadline":"2020-07-06T15:38:12+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"Add","grpc.code":"OK","grpc.time_ms":726.1229858398438}
{"level":"info","ts":"2020-07-06T15:38:46.219+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T15:38:43+08:00","grpc.request.deadline":"2020-07-06T15:38:46+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"Add","grpc.code":"OK","grpc.time_ms":2541.693115234375}
{"level":"info","ts":"2020-07-06T15:38:51.246+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code AlreadyExists","grpc.start_time":"2020-07-06T15:38:50+08:00","grpc.request.deadline":"2020-07-06T15:38:53+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"Add","error":"rpc error: code = AlreadyExists desc = 已经提交过申请","grpc.code":"AlreadyExists","grpc.time_ms":297.6159973144531}
{"level":"info","ts":"2020-07-06T15:40:50.063+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T15:40:49+08:00","grpc.request.deadline":"2020-07-06T15:40:52+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"Update","grpc.code":"OK","grpc.time_ms":110.69400024414062}
{"level":"info","ts":"2020-07-06T15:41:04.915+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T15:41:04+08:00","grpc.request.deadline":"2020-07-06T15:41:07+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"Update","grpc.code":"OK","grpc.time_ms":77.06600189208984}
{"level":"info","ts":"2020-07-06T16:00:29.941+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T16:00:29+08:00","grpc.request.deadline":"2020-07-06T16:00:32+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"All","grpc.code":"OK","grpc.time_ms":229.0019989013672}
{"level":"info","ts":"2020-07-06T16:00:42.666+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T16:00:42+08:00","grpc.request.deadline":"2020-07-06T16:00:45+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"All","grpc.code":"OK","grpc.time_ms":254.00100708007812}
{"level":"info","ts":"2020-07-06T16:01:07.713+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T16:01:07+08:00","grpc.request.deadline":"2020-07-06T16:01:10+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"All","grpc.code":"OK","grpc.time_ms":147.58200073242188}
{"level":"info","ts":"2020-07-06T16:01:21.752+0800","caller":"go-grpc-middleware@v1.2.0/chain.go:25","msg":"finished unary call with code OK","grpc.start_time":"2020-07-06T16:01:21+08:00","grpc.request.deadline":"2020-07-06T16:01:24+08:00","system":"grpc","span.kind":"server","grpc.service":"pb.ImFriendService","grpc.method":"All","grpc.code":"OK","grpc.time_ms":215.05599975585938}
...@@ -68,18 +68,7 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...@@ -68,18 +68,7 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
curtime := c_r.FindAllStringSubmatch(s, -1) curtime := c_r.FindAllStringSubmatch(s, -1)
check_sum := cs_r.FindAllStringSubmatch(s, -1) check_sum := cs_r.FindAllStringSubmatch(s, -1)
//if len(appkey) < 1 {
// return nil, permissionError("缺少appkey")
//}
//if len(nonce) < 1 {
// return nil, permissionError("缺少nonce")
//}
//if len(curtime) < 1 {
// return nil, permissionError("缺少curtime")
//}
//if len(check_sum) < 1 {
// return nil, permissionError("缺少checksum")
//}
request_map["Appkey"] = appkey[0][1] request_map["Appkey"] = appkey[0][1]
request_map["Nonce"] = nonce[0][1] request_map["Nonce"] = nonce[0][1]
request_map["Curtime"] = curtime[0][1] request_map["Curtime"] = curtime[0][1]
......
No preview for this file type
...@@ -464,7 +464,7 @@ var file_u_proto_im_base_proto_rawDesc = []byte{ ...@@ -464,7 +464,7 @@ var file_u_proto_im_base_proto_rawDesc = []byte{
0x79, 0x22, 0x67, 0x0a, 0x13, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x44, 0x65, 0x79, 0x22, 0x67, 0x0a, 0x13, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x44, 0x65,
0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x70,
0x61, 0x6e, 0x79, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x61, 0x6e, 0x79, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42,
0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x10, 0x00, 0x52, 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79,
0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x52, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x22, 0x33, 0x0a, 0x0d, 0x47, 0x65, 0x6f, 0x6e, 0x52, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x22, 0x33, 0x0a, 0x0d, 0x47, 0x65,
......
...@@ -5,10 +5,10 @@ package pb ...@@ -5,10 +5,10 @@ package pb
import ( import (
fmt "fmt" fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto" proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators" _ "github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators" github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
math "math"
) )
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
...@@ -36,6 +36,9 @@ func (this *ConfigureReply) Validate() error { ...@@ -36,6 +36,9 @@ func (this *ConfigureReply) Validate() error {
return nil return nil
} }
func (this *ConfigureDelRequest) Validate() error { func (this *ConfigureDelRequest) Validate() error {
if !(this.CompanyUserId > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("CompanyUserId", fmt.Errorf(`value '%v' must be greater than '0'`, this.CompanyUserId))
}
if this.Common != nil { if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil { if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err) return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
......
...@@ -705,7 +705,7 @@ var file_u_proto_im_chat_room_proto_rawDesc = []byte{ ...@@ -705,7 +705,7 @@ var file_u_proto_im_chat_room_proto_rawDesc = []byte{
0x74, 0x12, 0x22, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x06, 0x43, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x06, 0x43,
0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x06, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x18, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x06, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x18,
0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x06, 0x52, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x10, 0x00, 0x52, 0x06, 0x52,
0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x74, 0x61,
0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75,
...@@ -717,14 +717,14 @@ var file_u_proto_im_chat_room_proto_rawDesc = []byte{ ...@@ -717,14 +717,14 @@ var file_u_proto_im_chat_room_proto_rawDesc = []byte{
0x73, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x06, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x06,
0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x06, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x06, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x64,
0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x06, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x10, 0x00, 0x52, 0x06,
0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x22, 0x12, 0x0a, 0x10, 0x43, 0x68, 0x61, 0x74, 0x52, 0x6f, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x22, 0x12, 0x0a, 0x10, 0x43, 0x68, 0x61, 0x74, 0x52, 0x6f,
0x6f, 0x6d, 0x44, 0x65, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x59, 0x0a, 0x13, 0x43, 0x68, 0x6f, 0x6d, 0x44, 0x65, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x59, 0x0a, 0x13, 0x43, 0x68,
0x61, 0x74, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x61, 0x74, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x22, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x06, 0x43, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x06, 0x43,
0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x06, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x18, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x06, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x18,
0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x06, 0x52, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x10, 0x00, 0x52, 0x06, 0x52,
0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x22, 0xe8, 0x01, 0x0a, 0x11, 0x43, 0x68, 0x61, 0x74, 0x52, 0x6f, 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x22, 0xe8, 0x01, 0x0a, 0x11, 0x43, 0x68, 0x61, 0x74, 0x52, 0x6f,
0x6f, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x17, 0x0a, 0x07, 0x52, 0x6f, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x17, 0x0a, 0x07, 0x52,
0x6f, 0x6f, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x52, 0x6f, 0x6f, 0x6f, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x52, 0x6f,
......
...@@ -5,10 +5,10 @@ package pb ...@@ -5,10 +5,10 @@ package pb
import ( import (
fmt "fmt" fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto" proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators" _ "github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators" github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
math "math"
) )
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
...@@ -42,6 +42,9 @@ func (this *ChatRoomUpdateRequest) Validate() error { ...@@ -42,6 +42,9 @@ func (this *ChatRoomUpdateRequest) Validate() error {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err) return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
} }
} }
if !(this.RoomId > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("RoomId", fmt.Errorf(`value '%v' must be greater than '0'`, this.RoomId))
}
return nil return nil
} }
func (this *ChatRoomUpdateReply) Validate() error { func (this *ChatRoomUpdateReply) Validate() error {
...@@ -53,6 +56,9 @@ func (this *ChatRoomDelRequest) Validate() error { ...@@ -53,6 +56,9 @@ func (this *ChatRoomDelRequest) Validate() error {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err) return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
} }
} }
if !(this.RoomId > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("RoomId", fmt.Errorf(`value '%v' must be greater than '0'`, this.RoomId))
}
return nil return nil
} }
func (this *ChatRoomDelReply) Validate() error { func (this *ChatRoomDelReply) Validate() error {
...@@ -64,6 +70,9 @@ func (this *ChatRoomInfoRequest) Validate() error { ...@@ -64,6 +70,9 @@ func (this *ChatRoomInfoRequest) Validate() error {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err) return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
} }
} }
if !(this.RoomId > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("RoomId", fmt.Errorf(`value '%v' must be greater than '0'`, this.RoomId))
}
return nil return nil
} }
func (this *ChatRoomInfoReply) Validate() error { func (this *ChatRoomInfoReply) Validate() error {
......
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: u-proto/im_friend_req.proto
package pb
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
func (this *ImFriendAddReq) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if this.Accid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Accid", fmt.Errorf(`value '%v' must not be an empty string`, this.Accid))
}
if this.Faccid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Faccid", fmt.Errorf(`value '%v' must not be an empty string`, this.Faccid))
}
return nil
}
func (this *ImFriendEmptyReply) Validate() error {
return nil
}
func (this *ImFriendUpdateReq) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if !(this.Status > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("Status", fmt.Errorf(`value '%v' must be greater than '0'`, this.Status))
}
if !(this.Status < 3) {
return github_com_mwitkow_go_proto_validators.FieldError("Status", fmt.Errorf(`value '%v' must be less than '3'`, this.Status))
}
return nil
}
func (this *ImFriendListReq) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if this.Accid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Accid", fmt.Errorf(`value '%v' must not be an empty string`, this.Accid))
}
return nil
}
func (this *ImFriendListOne) Validate() error {
return nil
}
func (this *ImFriendListReply) Validate() error {
for _, item := range this.List {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("List", err)
}
}
}
return nil
}
...@@ -587,7 +587,7 @@ var file_u_proto_im_user_relationship_proto_rawDesc = []byte{ ...@@ -587,7 +587,7 @@ var file_u_proto_im_user_relationship_proto_rawDesc = []byte{
0x52, 0x05, 0x41, 0x63, 0x63, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x06, 0x46, 0x61, 0x63, 0x63, 0x69, 0x52, 0x05, 0x41, 0x63, 0x63, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x06, 0x46, 0x61, 0x63, 0x63, 0x69,
0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52,
0x06, 0x46, 0x61, 0x63, 0x63, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x18, 0x06, 0x46, 0x61, 0x63, 0x63, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x18,
0x04, 0x20, 0x01, 0x28, 0x03, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x04, 0x54, 0x04, 0x20, 0x01, 0x28, 0x03, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x10, 0x00, 0x52, 0x04, 0x54,
0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0x1a, 0x0a, 0x18, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x6c, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0x1a, 0x0a, 0x18, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x6c,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x41, 0x64, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x41, 0x64, 0x64, 0x52, 0x65, 0x70, 0x6c,
...@@ -627,9 +627,9 @@ var file_u_proto_im_user_relationship_proto_rawDesc = []byte{ ...@@ -627,9 +627,9 @@ var file_u_proto_im_user_relationship_proto_rawDesc = []byte{
0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x09, 0x54, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x09, 0x54,
0x61, 0x72, 0x67, 0x65, 0x74, 0x41, 0x63, 0x63, 0x12, 0x2a, 0x0a, 0x0c, 0x52, 0x65, 0x6c, 0x61, 0x61, 0x72, 0x67, 0x65, 0x74, 0x41, 0x63, 0x63, 0x12, 0x2a, 0x0a, 0x0c, 0x52, 0x65, 0x6c, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x42, 0x06, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x42, 0x06,
0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x0c, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xe2, 0xdf, 0x1f, 0x02, 0x10, 0x00, 0x52, 0x0c, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x54, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20,
0x01, 0x28, 0x03, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x05, 0x56, 0x61, 0x6c, 0x01, 0x28, 0x03, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x10, 0x00, 0x52, 0x05, 0x56, 0x61, 0x6c,
0x75, 0x65, 0x22, 0x5b, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x41, 0x75, 0x65, 0x22, 0x5b, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x41,
0x6e, 0x64, 0x4d, 0x75, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x22, 0x0a, 0x6e, 0x64, 0x4d, 0x75, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x22, 0x0a,
0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e,
......
...@@ -5,10 +5,10 @@ package pb ...@@ -5,10 +5,10 @@ package pb
import ( import (
fmt "fmt" fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto" proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators" _ "github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators" github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
math "math"
) )
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
...@@ -28,6 +28,9 @@ func (this *UserRelationshipAddRequest) Validate() error { ...@@ -28,6 +28,9 @@ func (this *UserRelationshipAddRequest) Validate() error {
if this.Faccid == "" { if this.Faccid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Faccid", fmt.Errorf(`value '%v' must not be an empty string`, this.Faccid)) return github_com_mwitkow_go_proto_validators.FieldError("Faccid", fmt.Errorf(`value '%v' must not be an empty string`, this.Faccid))
} }
if !(this.Type > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("Type", fmt.Errorf(`value '%v' must be greater than '0'`, this.Type))
}
return nil return nil
} }
func (this *UserRelationshipAddReply) Validate() error { func (this *UserRelationshipAddReply) Validate() error {
...@@ -86,6 +89,12 @@ func (this *SetSpecialRelationReq) Validate() error { ...@@ -86,6 +89,12 @@ func (this *SetSpecialRelationReq) Validate() error {
if this.TargetAcc == "" { if this.TargetAcc == "" {
return github_com_mwitkow_go_proto_validators.FieldError("TargetAcc", fmt.Errorf(`value '%v' must not be an empty string`, this.TargetAcc)) return github_com_mwitkow_go_proto_validators.FieldError("TargetAcc", fmt.Errorf(`value '%v' must not be an empty string`, this.TargetAcc))
} }
if !(this.RelationType > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("RelationType", fmt.Errorf(`value '%v' must be greater than '0'`, this.RelationType))
}
if !(this.Value > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("Value", fmt.Errorf(`value '%v' must be greater than '0'`, this.Value))
}
return nil return nil
} }
func (this *ListBlackAndMuteListReq) Validate() error { func (this *ListBlackAndMuteListReq) Validate() error {
......
package im_friend_request
import (
"github.com/astaxie/beego/orm"
"im-microservice/db"
"im-microservice/helper"
"im-microservice/pb"
)
var (
table_name = "im_friend_request"
field_id = "id"
field_accid = "accid"
field_faccid = "faccid"
field_status = "status"
field_updatetime = "updatetime"
)
const(
field_status_wait = iota
field_status_agree
field_status_refuse
)
func All(accid string) ([]db.ImFriendRequest, error){
var list []db.ImFriendRequest
_, err := db.MysqlClient.QueryTable(table_name).Filter(field_accid, accid).
Filter(field_status, field_status_wait).All(&list)
return list, err
}
func FindExits(accid, faccid string) bool {
return db.MysqlClient.QueryTable(table_name).
Filter(field_accid, accid).
Filter(field_faccid, faccid).
Filter(field_status,field_status_wait).Exist()
}
func AddRecord(in *pb.ImFriendAddReq) error {
var (
db_friend db.ImFriendRequest
)
now := helper.GetNowTime()
db_friend.Faccid = in.Faccid
db_friend.Accid = in.Accid
db_friend.Status = field_status_wait
db_friend.Createtime = now
db_friend.Updatetime = now
_, err := db.MysqlClient.Insert(&db_friend)
return err
}
func Update(in *pb.ImFriendUpdateReq) error {
orm_params := make(orm.Params)
orm_params[field_status] = in.Status
orm_params[field_updatetime] = helper.GetNowTime()
_, err := db.MysqlClient.QueryTable(table_name).Filter(field_id, in.Id).Filter(field_status, field_status_wait).Update(orm_params)
return err
}
package im_friend_request
import (
"context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"im-microservice/pb"
"im-microservice/sevice/im_user"
"im-microservice/sevice/im_user_relationship"
)
type ImFriendService struct {
pb.UnimplementedImFriendServiceServer
}
func (fs *ImFriendService) All (ctx context.Context, in *pb.ImFriendListReq) (reply *pb.ImFriendListReply, err error) {
// 添加用户是否存在
if _,err = im_user.GetImUserByAccid(in.Accid); err != nil {
err = status.Error(codes.NotFound, "用户不存在")
return
}
results, err := All(in.Accid)
if err != nil {
return
}
reply = &pb.ImFriendListReply{}
if len(results) > 0 {
for _, v := range results {
reply.List = append(reply.List, &pb.ImFriendListOne{
Id: int64(v.Id),
Accid: v.Accid,
Faccid: v.Faccid,
Createtime: v.Createtime,
})
}
}
return
}
func (fs *ImFriendService) Add (ctx context.Context,in *pb.ImFriendAddReq) (reply *pb.ImFriendEmptyReply, err error) {
// 添加用户是否存在
if _,err = im_user.GetImUserByAccid(in.Accid); err != nil {
err = status.Error(codes.NotFound, "用户不存在")
return
}
// 被添加用户存在
if _, err = im_user.GetImUserByAccid(in.Faccid); err != nil {
err = status.Error(codes.NotFound, "被添加用户不存在")
return
}
//是否已经添加过好友
if ok := im_user_relationship.IsUserRelationship(in.Accid, in.Faccid); ok {
err = status.Error(codes.AlreadyExists, "已经添加过该好友")
return
}
//对方用户黑名单不能添加
if ok :=im_user_relationship.IsBlack(in.Accid, in.Faccid); ok {
err = status.Error(codes.AlreadyExists, "已经添加过该好友")
return
}
// 已经提过添加好友申请
if ok := FindExits(in.Accid, in.Faccid); ok {
err = status.Error(codes.AlreadyExists, "已经提交过申请")
return
}
if err = AddRecord(in); err != nil {
return
}
reply = &pb.ImFriendEmptyReply{}
return
}
func (fs *ImFriendService) Update(ctx context.Context, in *pb.ImFriendUpdateReq) (reply *pb.ImFriendEmptyReply, err error) {
if err = Update(in); err != nil {
err = status.Error(codes.Internal, err.Error())
return
}
reply = &pb.ImFriendEmptyReply{}
return
}
...@@ -32,8 +32,20 @@ func IsUserRelationship(accid, faccid string) bool { ...@@ -32,8 +32,20 @@ func IsUserRelationship(accid, faccid string) bool {
Filter(db_field_faccid, faccid).Exist() Filter(db_field_faccid, faccid).Exist()
} }
//是否是对方黑名单
func IsBlack(accid, faccid string) bool {
return db.MysqlClient.QueryTable(db_tabel).Filter(db_field_accid, faccid).
Filter(db_field_faccid, accid).Filter(db_field_blacklist, close).Exist()
}
func AddUserRelationship(in *pb.UserRelationshipAddRequest) error { func AddUserRelationship(in *pb.UserRelationshipAddRequest) error {
var us db.ImUserRelationship var (
us db.ImUserRelationship
ts db.ImUserRelationship
)
// 发起者
now := helper.GetNowTime() now := helper.GetNowTime()
us.Accid = in.Accid us.Accid = in.Accid
us.Faccid = in.Faccid us.Faccid = in.Faccid
...@@ -44,6 +56,24 @@ func AddUserRelationship(in *pb.UserRelationshipAddRequest) error { ...@@ -44,6 +56,24 @@ func AddUserRelationship(in *pb.UserRelationshipAddRequest) error {
us.Mute = open us.Mute = open
us.Createtime = now us.Createtime = now
_, err := db.MysqlClient.Insert(&us) _, err := db.MysqlClient.Insert(&us)
if ok := IsUserRelationship(in.Faccid, in.Accid); !ok {
// 被添加者
ts.Accid = in.Faccid
ts.Faccid = in.Accid
ts.Msg = in.Msg
ts.Type = int(in.Type)
ts.Updatetime = now
ts.Blacklist = open
ts.Mute = open
ts.Createtime = now
_, err1 := db.MysqlClient.Insert(&ts)
if err1 != nil {
return status.Error(codes.Internal, err.Error())
}
}
if err != nil { if err != nil {
err = status.Error(codes.Internal, err.Error()) err = status.Error(codes.Internal, err.Error())
} }
......
...@@ -5,8 +5,8 @@ import ( ...@@ -5,8 +5,8 @@ import (
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
"im-microservice/sevice/im_user"
"im-microservice/sevice/im_user"
"im-microservice/helper" "im-microservice/helper"
"im-microservice/pb" "im-microservice/pb"
) )
...@@ -18,10 +18,6 @@ type UserRelationshipService struct { ...@@ -18,10 +18,6 @@ type UserRelationshipService struct {
func (us *UserRelationshipService) Add(ctx context.Context, func (us *UserRelationshipService) Add(ctx context.Context,
in *pb.UserRelationshipAddRequest) (reply *pb.UserRelationshipAddReply, err error) { in *pb.UserRelationshipAddRequest) (reply *pb.UserRelationshipAddReply, err error) {
if ok := IsUserRelationship(in.Accid, in.Faccid); ok {
err = status.Error(codes.AlreadyExists, "已经添加过该好友")
return
}
//添加好友 //添加好友
if err = AddUserRelationship(in); err != nil { if err = AddUserRelationship(in); err != nil {
return return
...@@ -31,6 +27,9 @@ func (us *UserRelationshipService) Add(ctx context.Context, ...@@ -31,6 +27,9 @@ func (us *UserRelationshipService) Add(ctx context.Context,
u_map["edition"] = helper.GetNowTime() u_map["edition"] = helper.GetNowTime()
_, _ = im_user.UpdateImUser(in.Accid, u_map) _, _ = im_user.UpdateImUser(in.Accid, u_map)
// 更改请求用户版本信息
_,_ = im_user.UpdateImUser(in.Faccid, u_map)
reply = &pb.UserRelationshipAddReply{} reply = &pb.UserRelationshipAddReply{}
return return
} }
...@@ -47,6 +46,9 @@ func (us *UserRelationshipService) Delete(ctx context.Context, ...@@ -47,6 +46,9 @@ func (us *UserRelationshipService) Delete(ctx context.Context,
u_map["edition"] = helper.GetNowTime() u_map["edition"] = helper.GetNowTime()
_, _ = im_user.UpdateImUser(in.Accid, u_map) _, _ = im_user.UpdateImUser(in.Accid, u_map)
// 更改被添加用户版本信息
_,_ = im_user.UpdateImUser(in.Faccid, u_map)
reply = &pb.UserRelationshipAddReply{} reply = &pb.UserRelationshipAddReply{}
return return
} }
......
...@@ -19,7 +19,7 @@ message ConfigureRequest { ...@@ -19,7 +19,7 @@ message ConfigureRequest {
message ConfigureReply {} message ConfigureReply {}
message ConfigureDelRequest { message ConfigureDelRequest {
int64 CompanyUserId = 1 [(validator.field) = {string_not_empty: true}]; int64 CompanyUserId = 1 [(validator.field) = {int_gt: 0}];
Common Common = 2; Common Common = 2;
} }
......
...@@ -20,7 +20,7 @@ message ChatRoomAddReply{ ...@@ -20,7 +20,7 @@ message ChatRoomAddReply{
// 更新聊天室 // 更新聊天室
message ChatRoomUpdateRequest { message ChatRoomUpdateRequest {
Common Common = 1; Common Common = 1;
int64 RoomId = 2 [(validator.field) = {string_not_empty: true}]; int64 RoomId = 2 [(validator.field) = {int_gt: 0}];
string Name = 3; string Name = 3;
int64 Status = 4; int64 Status = 4;
string Announcement = 5; string Announcement = 5;
...@@ -31,7 +31,7 @@ message ChatRoomUpdateReply {} ...@@ -31,7 +31,7 @@ message ChatRoomUpdateReply {}
// 删除聊天室 // 删除聊天室
message ChatRoomDelRequest { message ChatRoomDelRequest {
Common Common = 1; Common Common = 1;
int64 RoomId = 2 [(validator.field) = {string_not_empty: true}]; int64 RoomId = 2 [(validator.field) = {int_gt: 0}];
} }
message ChatRoomDelReply {} message ChatRoomDelReply {}
...@@ -39,7 +39,7 @@ message ChatRoomDelReply {} ...@@ -39,7 +39,7 @@ message ChatRoomDelReply {}
// 获取单个聊天室信息 // 获取单个聊天室信息
message ChatRoomInfoRequest { message ChatRoomInfoRequest {
Common Common = 1; Common Common = 1;
int64 RoomId = 2 [(validator.field) = {string_not_empty: true}]; int64 RoomId = 2 [(validator.field) = {int_gt: 0}];
} }
message ChatRoomInfoReply { message ChatRoomInfoReply {
......
syntax = "proto3";
package pb;
import "u-proto/common.proto";
import "github.com/mwitkow/go-proto-validators/validator.proto";
// 发起添加好友申请
message ImFriendAddReq {
Common Common = 1;
string Accid = 2 [(validator.field) = {string_not_empty: true}];
string Faccid = 3 [(validator.field) = {string_not_empty: true}];
}
message ImFriendEmptyReply {}
// 更改添加好友状态
message ImFriendUpdateReq {
Common Common = 1;
int64 Id = 2 [(validator.field) = {string_not_empty: true}];
int64 Status = 3 [(validator.field) = {int_gt: 0, int_lt:3}];
}
// 获取申请好友列表
message ImFriendListReq {
Common Common = 1;
string Accid = 2 [(validator.field) = {string_not_empty: true}];
}
message ImFriendListOne {
int64 Id = 1;
string Accid = 2;
string Faccid = 3;
string Createtime = 4;
}
message ImFriendListReply {
repeated ImFriendListOne List = 1;
}
service ImFriendService {
rpc All(ImFriendListReq) returns(ImFriendListReply) {}
rpc Add(ImFriendAddReq) returns(ImFriendEmptyReply) {}
rpc Update(ImFriendUpdateReq) returns(ImFriendEmptyReply) {}
}
\ No newline at end of file
...@@ -10,7 +10,7 @@ message UserRelationshipAddRequest { ...@@ -10,7 +10,7 @@ message UserRelationshipAddRequest {
Common Common = 1; Common Common = 1;
string Accid = 2 [(validator.field) = {string_not_empty: true}]; string Accid = 2 [(validator.field) = {string_not_empty: true}];
string Faccid = 3 [(validator.field) = {string_not_empty: true}]; string Faccid = 3 [(validator.field) = {string_not_empty: true}];
int64 Type = 4 [(validator.field) = {string_not_empty: true}]; int64 Type = 4 [(validator.field) = {int_gt: 0}];
string Msg = 5; string Msg = 5;
} }
...@@ -45,8 +45,8 @@ message SetSpecialRelationReq { ...@@ -45,8 +45,8 @@ message SetSpecialRelationReq {
Common Common = 1; Common Common = 1;
string Accid = 2 [(validator.field) = {string_not_empty: true}]; string Accid = 2 [(validator.field) = {string_not_empty: true}];
string TargetAcc = 3 [(validator.field) = {string_not_empty: true}]; string TargetAcc = 3 [(validator.field) = {string_not_empty: true}];
int64 RelationType = 4 [(validator.field) = {string_not_empty: true}]; int64 RelationType = 4 [(validator.field) = {int_gt: 0}];
int64 Value = 5 [(validator.field) = {string_not_empty: true}]; int64 Value = 5 [(validator.field) = {int_gt: 0}];
} }
//查看指定用户的黑名单和静音列表 //查看指定用户的黑名单和静音列表
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment