Example #1
0
func DeleteUser(w http.ResponseWriter, r *http.Request) {
	phoneNumber := r.Header.Get("phone_number")
	SQL := fmt.Sprintf("Delete FROM users WHERE phone_number = '%s'", phoneNumber)

	statusResult, messageResult := service.ExecuteChannelSqlResult(SQL)
	printResult(w, statusResult, messageResult, requests.PhoneNumberJson{phoneNumber})
}
Example #2
0
func blockFriend(phoneNumber string, friendPhoneNumber string, status int) (int, string) {
	var friendUserId int
	sqlRow, err := service.ExecuteChannelSqlRow(getUserIdSQL(friendPhoneNumber))

	switch {
	case err != nil:
		return 508, err.Error()
	default:
		errSqlRow := sqlRow.Scan(&friendUserId)
		statusRow, messageRow := service.CheckScanRowSQL(errSqlRow)
		switch {
		case statusRow == 404:
			return statusRow, "phone number doesn't exists"
		case statusRow != 200:
			return statusRow, messageRow
		default:
			sequel := fmt.Sprintf("INSERT INTO friends_relationship SET user_phone_number =  '%s', friend_phone_number = '%s', status = %v",
				phoneNumber, friendPhoneNumber, status)

			statusInsert, messageInsert := service.ExecuteChannelSqlResult(sequel)
			return statusInsert, messageInsert
		}
	}
}
Example #3
0
func sqlDeleteFriendRelationship(phoneNumber string, friendphoneNumber string, friendshipStatus int) (status int, message string) {
	sequel := fmt.Sprintf("Delete FROM friends_relationship WHERE user_phone_number = '%s' and friend_phone_number = '%s' and status = %v",
		phoneNumber, friendphoneNumber, friendshipStatus)
	status, message = service.ExecuteChannelSqlResult(sequel)
	return
}