ApiHTTP

package
v0.0.0-...-bbbc4ea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2019 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JWTGetUserId = "user_id"
)

Variables

View Source
var (
	ErrNoJsonBody         = errors.New("not have any JsonBodyParams")
	ERrPutProfileNoName   = errors.New("`name` not exited in JsonBodyParams")
	ERrPutProfileNoMobile = errors.New("`mobile` not exited in JsonBodyParams")
	ERrPutProfileNoGender = errors.New("`gender` not exited in JsonBodyParams")
)
View Source
var (
	ErrCreatedSameNameGroupChat = errors.New("you created the same group chat already")
	ErrFindManagerFail          = errors.New("find the manager fail")
)
View Source
var (
	ErrAddSelfAsFriend = errors.New("can't build a friendship with yourself")
)
View Source
var GlobalGinStyleLogger *gin.StyleLogger

the source code of the gin.StyleLogger is add by myself. the source code explanation: https://github.com/gin-gonic/gin/pull/2096

Functions

func AddFriend

func AddFriend(c *gin.Context)

Add friend HTTP API function

func CheckAndAcceptFriend

func CheckAndAcceptFriend(selfId int64, params *PutFriendParams) (int, string)

Handle a friend relationship request

func CheckAndAddFriend

func CheckAndAddFriend(selfId, friendId int64, note string) (int, error)

Check if duplicate add the user as friend or self is in black list of target user

func DeleteFriend

func DeleteFriend(c *gin.Context)

Delete friend HTTP API function

func DismissOneGroupChat

func DismissOneGroupChat(c *gin.Context)

todo: update the 'is_delete' to false of the group chat

func EmailValidator

func EmailValidator(
	v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
	field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
) bool

func ForgetPassword

func ForgetPassword(c *gin.Context)

ForgetPassword HTTP API function the auth-token is from the `reset password email`

func GenderValidator

func GenderValidator(
	v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
	field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
) bool

func GetFriendsInfo

func GetFriendsInfo(c *gin.Context)

Get All the user's friends information HTTP API function

func GetGroupChatsUserJoined

func GetGroupChatsUserJoined(c *gin.Context)

The all the group chat information which the user joined

func GetOneGroupChatInfo

func GetOneGroupChatInfo(c *gin.Context)

todo:

func GetProfile

func GetProfile(c *gin.Context)

GetProfile HTTP API function

func GetResetPasswordEmail

func GetResetPasswordEmail(c *gin.Context)

GetResetPasswordEmail HTTP API function Send a email which content with the `Auth-Token` to the user's email box for reset password.

func GetSubscriptionUserFollowed

func GetSubscriptionUserFollowed(c *gin.Context)

todo:

func GetUsersInfoOfGroupChat

func GetUsersInfoOfGroupChat(c *gin.Context)

Get the information of users whom joined the group chat

func HidePasswordAndCompleteAvatarAndQrCodeURL

func HidePasswordAndCompleteAvatarAndQrCodeURL(userBasic *mysqlPb.UserBasic)

Hide password and complete the URL of avatar and qr code

func JWTAuthMiddleware

func JWTAuthMiddleware() gin.HandlerFunc

JWTAuthMiddleware, check the jwt token string from request.

func ManageFriendShipBlacklist

func ManageFriendShipBlacklist(selfId, friendId int64, isBlack bool) (int, string)

Manage the friend blacklist

func MobileValidator

func MobileValidator(
	v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
	field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
) bool

func ModifyFriendNote

func ModifyFriendNote(selfId int64, params *PutFriendParams) (int, string)

// Modify note on my friends

func NameValidator

func NameValidator(
	v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
	field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
) bool

func NewOneGroupChat

func NewOneGroupChat(c *gin.Context)

Create one new group chat with

func ParseQrCode

func ParseQrCode(c *gin.Context)

ParseQrCode HTTP API function

func PasswordValidator

func PasswordValidator(
	v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
	field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
) bool

func PutAvatar

func PutAvatar(c *gin.Context)

PutAvatar HTTP API function

func PutFriend

func PutFriend(c *gin.Context)

Put friend HTTP API function

func PutOneGroupChatAvatar

func PutOneGroupChatAvatar(c *gin.Context)

todo:

func PutOneGroupChatManager

func PutOneGroupChatManager(c *gin.Context)

todo: change the manager of the group chat to other user.

func PutOneGroupChatName

func PutOneGroupChatName(c *gin.Context)

todo:

func PutPassword

func PutPassword(c *gin.Context)

PutPassword HTTP API function

func PutProfile

func PutProfile(c *gin.Context)

PutProfile HTTP API function

func RelateActionValidator

func RelateActionValidator(
	v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
	field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
) bool

func SaveQRCodeLocal

func SaveQRCodeLocal(data []byte, hashName string) error

save QRCode file to local

func SearchGroupChats

func SearchGroupChats(c *gin.Context)

Search group chat information from ElasticSearch

func SearchSubscriptions

func SearchSubscriptions(c *gin.Context)

todo:

func SearchUsers

func SearchUsers(c *gin.Context)

Search user HTTP API function. search data from ElasticSearch

func SignIn

func SignIn(c *gin.Context)

SignIn(Login) HTTP API function

func SignUp

func SignUp(c *gin.Context)

SignUp(Register) HTTP API function. Saving the user's basic information which the user input and set the default value for some value like gender, and create the qr code image for this user.

func StartHttpServer

func StartHttpServer()

func UploadAvatarLocal

func UploadAvatarLocal(data []byte, hashName string) error

Save avatar file to local dir

func UploadDataToCloud

func UploadDataToCloud(data []byte, hashName string) error

todo upload the data to cloud with a hashName

func UserJoinOneGroupChat

func UserJoinOneGroupChat(c *gin.Context)

todo

func UserPutNoteInGroupChat

func UserPutNoteInGroupChat(c *gin.Context)

todo

func UserQuitOneGroupChat

func UserQuitOneGroupChat(c *gin.Context)

todo

Types

type AddFriendParams

type AddFriendParams struct {
	FriendId int64  `json:"dst_id" binding:"required"`
	Note     string `json:"note" binding:"nameValidator"`
}

type DeleteFriendParams

type DeleteFriendParams struct {
	FriendId int64 `json:"dst_id" binding:"required"`
}

type NewGroupChatParam

type NewGroupChatParam struct {
	Name string `json:"name" binding:"nameValidator"`
}

type PutFriendParams

type PutFriendParams struct {
	Action   int    `json:"action" binding:"relateActionValidator"`
	FriendId int64  `json:"dst_id" binding:"required"`
	Note     string `json:"note" binding:"max=10"`
	IsAccept bool   `json:"is_accept"`
	IsBlack  bool   `json:"is_black"`
}

type SearchParam

type SearchParam struct {
	KW   string `json:"kw" binding:"required"`
	Page int    `json:"page"`
	Size int    `json:"size"`
}

type SearchUsersParam

type SearchUsersParam struct {
	KW   string `json:"kw" binding:"required"`
	Page int    `json:"page"`
	Size int    `json:"size"`
}

type TempForgetPassword

type TempForgetPassword struct {
	Password        string `json:"password" binding:"passwordValidator"`
	ConfirmPassword string `json:"confirm_password" binding:"required,eqfield=Password"`
}

type TempPassword

type TempPassword struct {
	OldPassword     string `json:"old_password" binding:"passwordValidator"`
	Password        string `json:"password" binding:"passwordValidator,nefield=OldPassword"`
	ConfirmPassword string `json:"confirm_password" binding:"required,eqfield=Password"`
}

type TempProfile

type TempProfile struct {
	Name   string `json:"name" binding:"nameValidator"`
	Mobile string `json:"mobile" binding:"mobileValidator"`
	Gender int    `json:"gender" binding:"genderValidator"`
}

type UserSignIn

type UserSignIn struct {
	Email    string `json:"email"  binding:"emailValidator"`
	Password string `json:"password"  binding:"passwordValidator"`
}

type UserSignUp

type UserSignUp struct {
	Name            string `json:"name" binding:"nameValidator"`
	Email           string `json:"email"  binding:"emailValidator"`
	Password        string `json:"password"  binding:"passwordValidator"`
	ConfirmPassword string `json:"confirm_password" binding:"required,eqfield=Password"`
}

Sign Up data struct , all field required. Verify data by the validators of gin binding.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL