Commit dbd843ee by Li Feifei

go fmt project

parent 347fc415
......@@ -19,7 +19,6 @@ func GetSecretByKey(key string) (error, string) {
return nil, u_app.Secret
}
func AppIsExit(appid int64) bool {
return db.MysqlClient.QueryTable(table_name).Filter("id", appid).Exist()
}
\ No newline at end of file
}
......@@ -46,5 +46,3 @@ func Paginate(count, step, page int64) (int64, int64) {
total := int64(math.Ceil(float64(count) / float64(step)))
return offset, total
}
......@@ -58,7 +58,7 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
request_map := make(map[string]string)
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 {
request_map[v[1]] = v[2]
}
......
......@@ -5,10 +5,10 @@ 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"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
......
......@@ -5,10 +5,10 @@ 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"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
......
......@@ -5,10 +5,10 @@ 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"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
......
......@@ -5,10 +5,10 @@ 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"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
......
......@@ -5,10 +5,10 @@ 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"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
......
......@@ -5,10 +5,10 @@ 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"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
......
......@@ -8,22 +8,22 @@ import (
)
var (
table_name = "im_friend_request"
field_id = "id"
field_accid = "accid"
field_faccid = "faccid"
field_status = "status"
field_key = "appkey"
table_name = "im_friend_request"
field_id = "id"
field_accid = "accid"
field_faccid = "faccid"
field_status = "status"
field_key = "appkey"
field_updatetime = "updatetime"
)
const(
const (
field_status_wait = iota
field_status_agree
field_status_refuse
)
func All(accid string) ([]db.ImFriendRequest, error){
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)
......@@ -35,7 +35,7 @@ func FindExits(accid, faccid, key string) bool {
Filter(field_accid, accid).
Filter(field_faccid, faccid).
Filter(field_key, key).
Filter(field_status,field_status_wait).Exist()
Filter(field_status, field_status_wait).Exist()
}
func AddRecord(in *pb.ImFriendAddReq) error {
......
......@@ -15,14 +15,14 @@ type ImFriendService struct {
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 {
err = status.New(codes.Canceled, "Client cancelled, abandoning.").Err()
return
}
// 添加用户是否存在
if _,err = im_user.GetImUserByAccid(in.Accid); err != nil {
if _, err = im_user.GetImUserByAccid(in.Accid); err != nil {
err = status.Error(codes.NotFound, "用户不存在")
return
}
......@@ -44,14 +44,14 @@ func (fs *ImFriendService) All (ctx context.Context, in *pb.ImFriendListReq) (re
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 {
err = status.New(codes.Canceled, "Client cancelled, abandoning.").Err()
return
}
// 添加用户是否存在
if _,err = im_user.GetImUserByAccid(in.Accid); err != nil {
if _, err = im_user.GetImUserByAccid(in.Accid); err != nil {
err = status.Error(codes.NotFound, "用户不存在")
return
}
......@@ -66,7 +66,7 @@ func (fs *ImFriendService) Add (ctx context.Context,in *pb.ImFriendAddReq) (repl
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, "已经添加过该好友")
return
}
......@@ -88,7 +88,7 @@ func (fs *ImFriendService) Update(ctx context.Context, in *pb.ImFriendUpdateReq)
err = status.New(codes.Canceled, "Client cancelled, abandoning.").Err()
return
}
if err = Update(in); err != nil {
if err = Update(in); err != nil {
err = status.Error(codes.Internal, err.Error())
return
}
......
......@@ -22,12 +22,12 @@ var (
db_field_serverex = "serverex"
db_field_updatetime = "updatetime"
db_field_createtime = "createtime"
open = 2
open = 2
db_close = 1
)
// 是否是好友
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).
Filter(db_field_faccid, faccid).Filter("appkey", key).Exist()
}
......@@ -58,7 +58,7 @@ func AddUserRelationship(in *pb.UserRelationshipAddRequest) error {
us.Appkey = in.Common.Appkey
_, 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.Faccid = in.Accid
......
......@@ -7,9 +7,9 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"im-microservice/sevice/im_user"
"im-microservice/helper"
"im-microservice/pb"
"im-microservice/sevice/im_user"
)
type UserRelationshipService struct {
......@@ -32,7 +32,7 @@ func (us *UserRelationshipService) Add(ctx context.Context,
_, _ = im_user.UpdateImUser(in.Accid, u_map)
// 更改请求用户版本信息
_,_ = im_user.UpdateImUser(in.Faccid, u_map)
_, _ = im_user.UpdateImUser(in.Faccid, u_map)
reply = &pb.UserRelationshipAddReply{}
return
......@@ -55,7 +55,7 @@ func (us *UserRelationshipService) Delete(ctx context.Context,
_, _ = im_user.UpdateImUser(in.Accid, u_map)
// 更改被添加用户版本信息
_,_ = im_user.UpdateImUser(in.Faccid, u_map)
_, _ = im_user.UpdateImUser(in.Faccid, u_map)
reply = &pb.UserRelationshipAddReply{}
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