Commit dbd843ee by Li Feifei

go fmt project

parent 347fc415
...@@ -19,7 +19,6 @@ func GetSecretByKey(key string) (error, string) { ...@@ -19,7 +19,6 @@ func GetSecretByKey(key string) (error, string) {
return nil, u_app.Secret return nil, u_app.Secret
} }
func AppIsExit(appid int64) bool { func AppIsExit(appid int64) bool {
return db.MysqlClient.QueryTable(table_name).Filter("id", appid).Exist() return db.MysqlClient.QueryTable(table_name).Filter("id", appid).Exist()
} }
...@@ -46,5 +46,3 @@ func Paginate(count, step, page int64) (int64, int64) { ...@@ -46,5 +46,3 @@ func Paginate(count, step, page int64) (int64, int64) {
total := int64(math.Ceil(float64(count) / float64(step))) total := int64(math.Ceil(float64(count) / float64(step)))
return offset, total return offset, total
} }
...@@ -58,7 +58,7 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...@@ -58,7 +58,7 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
request_map := make(map[string]string) request_map := make(map[string]string)
key_r, _ := regexp.Compile(`[^}|^Common:]\s?(.*?):"(.*?)"`) key_r, _ := regexp.Compile(`[^}|^Common:]\s?(.*?):"(.*?)"`)
result := key_r.FindAllStringSubmatch( fmt.Sprintf("%v", req), -1) result := key_r.FindAllStringSubmatch(fmt.Sprintf("%v", req), -1)
for _, v := range result { for _, v := range result {
request_map[v[1]] = v[2] request_map[v[1]] = v[2]
} }
......
...@@ -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.
......
...@@ -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.
......
...@@ -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.
......
...@@ -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.
......
...@@ -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.
......
...@@ -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.
......
...@@ -15,15 +15,15 @@ var ( ...@@ -15,15 +15,15 @@ var (
field_status = "status" field_status = "status"
field_key = "appkey" field_key = "appkey"
field_updatetime = "updatetime" field_updatetime = "updatetime"
) )
const(
const (
field_status_wait = iota field_status_wait = iota
field_status_agree field_status_agree
field_status_refuse field_status_refuse
) )
func All(accid string) ([]db.ImFriendRequest, error){ func All(accid string) ([]db.ImFriendRequest, error) {
var list []db.ImFriendRequest var list []db.ImFriendRequest
_, err := db.MysqlClient.QueryTable(table_name).Filter(field_accid, accid). _, err := db.MysqlClient.QueryTable(table_name).Filter(field_accid, accid).
Filter(field_status, field_status_wait).All(&list) Filter(field_status, field_status_wait).All(&list)
...@@ -35,7 +35,7 @@ func FindExits(accid, faccid, key string) bool { ...@@ -35,7 +35,7 @@ func FindExits(accid, faccid, key string) bool {
Filter(field_accid, accid). Filter(field_accid, accid).
Filter(field_faccid, faccid). Filter(field_faccid, faccid).
Filter(field_key, key). Filter(field_key, key).
Filter(field_status,field_status_wait).Exist() Filter(field_status, field_status_wait).Exist()
} }
func AddRecord(in *pb.ImFriendAddReq) error { func AddRecord(in *pb.ImFriendAddReq) error {
......
...@@ -15,14 +15,14 @@ type ImFriendService struct { ...@@ -15,14 +15,14 @@ type ImFriendService struct {
pb.UnimplementedImFriendServiceServer pb.UnimplementedImFriendServiceServer
} }
func (fs *ImFriendService) All (ctx context.Context, in *pb.ImFriendListReq) (reply *pb.ImFriendListReply, err error) { func (fs *ImFriendService) All(ctx context.Context, in *pb.ImFriendListReq) (reply *pb.ImFriendListReply, err error) {
// 请求超时 // 请求超时
if ctx.Err() == context.Canceled { if ctx.Err() == context.Canceled {
err = status.New(codes.Canceled, "Client cancelled, abandoning.").Err() err = status.New(codes.Canceled, "Client cancelled, abandoning.").Err()
return return
} }
// 添加用户是否存在 // 添加用户是否存在
if _,err = im_user.GetImUserByAccid(in.Accid); err != nil { if _, err = im_user.GetImUserByAccid(in.Accid); err != nil {
err = status.Error(codes.NotFound, "用户不存在") err = status.Error(codes.NotFound, "用户不存在")
return return
} }
...@@ -44,14 +44,14 @@ func (fs *ImFriendService) All (ctx context.Context, in *pb.ImFriendListReq) (re ...@@ -44,14 +44,14 @@ func (fs *ImFriendService) All (ctx context.Context, in *pb.ImFriendListReq) (re
return return
} }
func (fs *ImFriendService) Add (ctx context.Context,in *pb.ImFriendAddReq) (reply *pb.ImFriendEmptyReply, err error) { func (fs *ImFriendService) Add(ctx context.Context, in *pb.ImFriendAddReq) (reply *pb.ImFriendEmptyReply, err error) {
// 请求超时 // 请求超时
if ctx.Err() == context.Canceled { if ctx.Err() == context.Canceled {
err = status.New(codes.Canceled, "Client cancelled, abandoning.").Err() err = status.New(codes.Canceled, "Client cancelled, abandoning.").Err()
return return
} }
// 添加用户是否存在 // 添加用户是否存在
if _,err = im_user.GetImUserByAccid(in.Accid); err != nil { if _, err = im_user.GetImUserByAccid(in.Accid); err != nil {
err = status.Error(codes.NotFound, "用户不存在") err = status.Error(codes.NotFound, "用户不存在")
return return
} }
...@@ -66,7 +66,7 @@ func (fs *ImFriendService) Add (ctx context.Context,in *pb.ImFriendAddReq) (repl ...@@ -66,7 +66,7 @@ func (fs *ImFriendService) Add (ctx context.Context,in *pb.ImFriendAddReq) (repl
return return
} }
//对方用户黑名单不能添加 //对方用户黑名单不能添加
if ok :=im_user_relationship.IsBlack(in.Accid, in.Faccid, in.Common.Appkey); ok { if ok := im_user_relationship.IsBlack(in.Accid, in.Faccid, in.Common.Appkey); ok {
err = status.Error(codes.AlreadyExists, "已经添加过该好友") err = status.Error(codes.AlreadyExists, "已经添加过该好友")
return return
} }
......
...@@ -27,7 +27,7 @@ var ( ...@@ -27,7 +27,7 @@ var (
) )
// 是否是好友 // 是否是好友
func IsUserRelationship(accid, faccid,key string) bool { func IsUserRelationship(accid, faccid, key string) bool {
return db.MysqlClient.QueryTable(db_tabel).Filter(db_field_accid, accid). return db.MysqlClient.QueryTable(db_tabel).Filter(db_field_accid, accid).
Filter(db_field_faccid, faccid).Filter("appkey", key).Exist() Filter(db_field_faccid, faccid).Filter("appkey", key).Exist()
} }
...@@ -58,7 +58,7 @@ func AddUserRelationship(in *pb.UserRelationshipAddRequest) error { ...@@ -58,7 +58,7 @@ func AddUserRelationship(in *pb.UserRelationshipAddRequest) error {
us.Appkey = in.Common.Appkey us.Appkey = in.Common.Appkey
_, err := db.MysqlClient.Insert(&us) _, err := db.MysqlClient.Insert(&us)
if ok := IsUserRelationship(in.Faccid, in.Accid,in.Common.Appkey); !ok { if ok := IsUserRelationship(in.Faccid, in.Accid, in.Common.Appkey); !ok {
// 被添加者 // 被添加者
ts.Accid = in.Faccid ts.Accid = in.Faccid
ts.Faccid = in.Accid ts.Faccid = in.Accid
......
...@@ -7,9 +7,9 @@ import ( ...@@ -7,9 +7,9 @@ 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/helper" "im-microservice/helper"
"im-microservice/pb" "im-microservice/pb"
"im-microservice/sevice/im_user"
) )
type UserRelationshipService struct { type UserRelationshipService struct {
...@@ -32,7 +32,7 @@ func (us *UserRelationshipService) Add(ctx context.Context, ...@@ -32,7 +32,7 @@ func (us *UserRelationshipService) Add(ctx context.Context,
_, _ = im_user.UpdateImUser(in.Accid, u_map) _, _ = im_user.UpdateImUser(in.Accid, u_map)
// 更改请求用户版本信息 // 更改请求用户版本信息
_,_ = im_user.UpdateImUser(in.Faccid, u_map) _, _ = im_user.UpdateImUser(in.Faccid, u_map)
reply = &pb.UserRelationshipAddReply{} reply = &pb.UserRelationshipAddReply{}
return return
...@@ -55,7 +55,7 @@ func (us *UserRelationshipService) Delete(ctx context.Context, ...@@ -55,7 +55,7 @@ func (us *UserRelationshipService) Delete(ctx context.Context,
_, _ = im_user.UpdateImUser(in.Accid, u_map) _, _ = im_user.UpdateImUser(in.Accid, u_map)
// 更改被添加用户版本信息 // 更改被添加用户版本信息
_,_ = im_user.UpdateImUser(in.Faccid, u_map) _, _ = im_user.UpdateImUser(in.Faccid, u_map)
reply = &pb.UserRelationshipAddReply{} reply = &pb.UserRelationshipAddReply{}
return return
......
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