Documentation ¶
Index ¶
- func NewHandler(r *Repository)
- type Repository
- func (m *Repository) AddtoBuyListApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AddtoReadListApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllAuthor(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllAuthorApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllBook(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllBookApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllBookAuthor(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllBookAuthorsApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllBookGenre(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllBookLanguage(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllBuyList(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllBuyListApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllContacts(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllFollowerApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllFollowers(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllGenres(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllLanguage(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllPublisherFilterApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllPublusher(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllReadList(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllReadListApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllRequestBookList(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllRequestedBookssApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllReviewApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllReviews(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllUsers(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminAllUsersApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminDashboard(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminDeleteGenre(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminDeleteRequestedBook(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminGetAuthorDetailByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminGetBookAuthorByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminGetBookDetailByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminGetBookGenreByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminGetBookLanguageByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminGetBuyListByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminGetContactByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminGetFollowerByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminGetGenreByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminGetPublisherDetailByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminGetReadListByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminGetReviewByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminGetUserDetailByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminInsertAuthor(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminInsertBook(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminInsertPublisher(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminInsertReview(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminLogin(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminUpdateUser(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AdminUserAdd(w http.ResponseWriter, r *http.Request)
- func (h *Repository) AllAuthors(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AllBookFilterByGenre(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AllBookFilterByLanguage(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AllBooks(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AllBooksFilterApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AllBooksFilterByGenreApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AllBooksFilterByLanguageApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AllBooksFilterFromBuyList(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AllBooksFilterFromBuyListApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AllBooksFilterFromReadList(w http.ResponseWriter, r *http.Request)
- func (m *Repository) AllBooksFilterFromReadListApi(w http.ResponseWriter, r *http.Request)
- func (h *Repository) AuthorFiltersApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) BookBuyListExistsApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) BookDetailByISBN(w http.ResponseWriter, r *http.Request)
- func (m *Repository) BookReadListExistsApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) ClearSessionMessage(w http.ResponseWriter, r *http.Request)
- func (m *Repository) ContactUs(w http.ResponseWriter, r *http.Request)
- func (m *Repository) CustomNotFoundError(w http.ResponseWriter, r *http.Request)
- func (h *Repository) FollowApi(w http.ResponseWriter, r *http.Request)
- func (h *Repository) FollowExistsApi(w http.ResponseWriter, r *http.Request)
- func (h *Repository) GetFollowingsListByUserIdApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) Home(w http.ResponseWriter, r *http.Request)
- func (m *Repository) Login(w http.ResponseWriter, r *http.Request)
- func (m *Repository) Logout(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PersonalProfile(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PopulateFakeData(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminAddGenre(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminDeleteAuthor(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminDeleteBook(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminDeleteBookAuthor(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminDeleteBookGenre(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminDeleteBookLanguage(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminDeleteBuyList(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminDeleteContact(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminDeleteFollow(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminDeleteLanguage(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminDeletePublisher(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminDeleteReadList(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminDeleteReview(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminGetGenreByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminInsertAuthor(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminInsertBook(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminInsertBookAuthor(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminInsertBookGenre(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminInsertBookLanguage(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminInsertBuyList(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminInsertFollower(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminInsertLanguage(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminInsertPublisher(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminInsertReadList(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminInsertReview(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminKycUpdate(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminLogin(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUpdateAuthor(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUpdateBook(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUpdateBookAuthor(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUpdateBookGenre(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUpdateBookLanguage(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUpdateBuyList(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUpdateFollower(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUpdateLanguage(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUpdatePublisher(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUpdateReadList(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUpdateRequestBookStatus(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUpdateReview(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUserAdd(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUserDeleteByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUserDocumentUpdate(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostAdminUserProfileUpdate(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostContactUs(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostLogin(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostPublicCreateReview(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostPublicDeleteReview(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostPublicUpdateReview(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostRegister(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostRequestBook(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostResetPassword(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostResetPasswordChange(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PostUserProfilePicUpdate(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PublicAboutUs(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PublicCreateReview(w http.ResponseWriter, r *http.Request)
- func (h *Repository) PublicGetAuthorByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PublicUpdateKYC(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PublicUpdateReview(w http.ResponseWriter, r *http.Request)
- func (m *Repository) PublisherWithBooksDetailByID(w http.ResponseWriter, r *http.Request)
- func (m *Repository) Register(w http.ResponseWriter, r *http.Request)
- func (m *Repository) RemoveFromBuyListApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) RemoveFromReadListApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) RequestBook(w http.ResponseWriter, r *http.Request)
- func (m *Repository) ResetPassword(w http.ResponseWriter, r *http.Request)
- func (m *Repository) ResetPasswordChange(w http.ResponseWriter, r *http.Request)
- func (h *Repository) UnFollowApi(w http.ResponseWriter, r *http.Request)
- func (m *Repository) UpdateSession(w http.ResponseWriter, r *http.Request, id, access_level int, username string, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Repository ¶
type Repository struct { App *config.AppConfig DB repository.DatabaseRepo }
Repository used to get global app config and database access
var Repo *Repository
Repo is of type Repository and used by handlers to get access to global app config and datbase
func NewRepo ¶
func NewRepo(a *config.AppConfig, db *driver.DB) *Repository
NewRepo creates a new Repository
func (*Repository) AddtoBuyListApi ¶
func (m *Repository) AddtoBuyListApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AddtoReadListApi ¶
func (m *Repository) AddtoReadListApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AdminAllAuthor ¶
func (m *Repository) AdminAllAuthor(w http.ResponseWriter, r *http.Request)
AdminAllAuthor retrieves all authors from the database and renders the "admin-allauthors.page.tmpl" template. It takes the HTTP response writer and request as parameters. The function calls the AllAuthor interface to retrieve all authors from the database. If an error occurs during retrieval, a server error is returned. The authors are stored in the "authors" key of the data map. The function renders the template with the authors data.
func (*Repository) AdminAllAuthorApi ¶
func (m *Repository) AdminAllAuthorApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AdminAllBook ¶
func (m *Repository) AdminAllBook(w http.ResponseWriter, r *http.Request)
AdminAllBook handles logic for reteriving all Books in admin page. It takes HTTP response writer and request as parameters. The function calls AllBook interface to reterive all the books from the database If any error occurs, a server error is returned. A data map is created that stores the books Finally, "admin-allbooks.page.tmpl" go template is rendered with data.
func (*Repository) AdminAllBookApi ¶
func (m *Repository) AdminAllBookApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AdminAllBookAuthor ¶
func (m *Repository) AdminAllBookAuthor(w http.ResponseWriter, r *http.Request)
AdminAllBookAuthor retrieves all book-author relationships and renders the "admin-allbookauthors.page.tmpl" template. It takes the HTTP response writer and request as parameters. The function calls the database's AllBookAuthor method to retrieve all book-author relationships. If an error occurs during the retrieval, a server error is returned. The function also retrieves all books and authors from the database using the AllBook and AllAuthor methods, respectively. If any errors occur during the retrieval, a server error is returned. The retrieved data, including book-authors, book-author, all authors, and all books, is stored in a data map. The function then renders the template, passing the data map and an empty form to the template for rendering.
func (*Repository) AdminAllBookAuthorsApi ¶
func (m *Repository) AdminAllBookAuthorsApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AdminAllBookGenre ¶
func (m *Repository) AdminAllBookGenre(w http.ResponseWriter, r *http.Request)
AdminAllBookGenre retrieves all book-genre relationships in an admin context. It takes the HTTP response writer and request as parameters. The function retrieves all book-genre relationships, all books, and all genres from the database. If any errors occur during the retrieval process, a server error is returned. The function prepares the necessary data and renders the "admin-allbookgenres.page.tmpl" template, displaying the list of book-genre relationships as well as new book genre relationship add form.
func (*Repository) AdminAllBookLanguage ¶
func (m *Repository) AdminAllBookLanguage(w http.ResponseWriter, r *http.Request)
AdminAllBookLanguage retrieves all book-language relationships in an admin context. It takes the HTTP response writer and request as parameters. The function retrieves all book-language relationships, all books, and all languages from the database. If any errors occur during the retrieval process, a server error is returned. The function prepares the necessary data and renders the "admin-allbooklanguages.page.tmpl" template, displaying the list of book-language relationships as well as new book language relationship add form.
func (*Repository) AdminAllBuyList ¶
func (m *Repository) AdminAllBuyList(w http.ResponseWriter, r *http.Request)
AdminAllBuyList fetches all the relation record between user and books in buyLists
func (*Repository) AdminAllBuyListApi ¶
func (m *Repository) AdminAllBuyListApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AdminAllContacts ¶
func (m *Repository) AdminAllContacts(w http.ResponseWriter, r *http.Request)
AdminAllContacts fetches all the record in Contacts. It takes HTTP response writer and request as parameters.
func (*Repository) AdminAllFollowerApi ¶
func (m *Repository) AdminAllFollowerApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AdminAllFollowers ¶
func (m *Repository) AdminAllFollowers(w http.ResponseWriter, r *http.Request)
AdminAllFollowers fetches all the relation record between user and books in Followers
func (*Repository) AdminAllGenres ¶
func (m *Repository) AdminAllGenres(w http.ResponseWriter, r *http.Request)
AdminAllGenres renders the admin gender page. It takes HTTP response writer and request as parameters. It fetched all genre records from db and renders the page.
func (*Repository) AdminAllLanguage ¶
func (m *Repository) AdminAllLanguage(w http.ResponseWriter, r *http.Request)
AdminAllLanguage retrieves all languages from the database and renders the admin-alllanguages page. It takes the HTTP response writer and request as parameters. The function calls the AllLanguage interface to retrieve all languages from the database. If an error occurs during the retrieval, a server error is returned. The function creates a data map and adds the retrieved languages to the "languages" key in the data map. It creates an empty Language model and adds it to the "language" key in the data map. The function renders the "admin-alllanguages.page.tmpl" template with the data map and an empty form.
func (*Repository) AdminAllPublisherFilterApi ¶
func (m *Repository) AdminAllPublisherFilterApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AdminAllPublusher ¶
func (m *Repository) AdminAllPublusher(w http.ResponseWriter, r *http.Request)
AdminAllPublisher renders admin all publisher page
func (*Repository) AdminAllReadList ¶
func (m *Repository) AdminAllReadList(w http.ResponseWriter, r *http.Request)
AdminAllReadList fetches all the relation record between user and books in readLists
func (*Repository) AdminAllReadListApi ¶
func (m *Repository) AdminAllReadListApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AdminAllRequestBookList ¶
func (m *Repository) AdminAllRequestBookList(w http.ResponseWriter, r *http.Request)
func (*Repository) AdminAllRequestedBookssApi ¶
func (m *Repository) AdminAllRequestedBookssApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AdminAllReviewApi ¶
func (m *Repository) AdminAllReviewApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AdminAllReviews ¶
func (m *Repository) AdminAllReviews(w http.ResponseWriter, r *http.Request)
AdminAllReviews fetches all the record in Reviews. It takes HTTP response writer and request as parameters.
func (*Repository) AdminAllUsers ¶
func (m *Repository) AdminAllUsers(w http.ResponseWriter, r *http.Request)
AdminAllUsers is a handler that handles the HTTP request for retrieving all users in the admin panel. It retrieves the page and limit parameters from the URL query, calculates the offset based on the page and limit, retrieves the users from the database with the specified limit and offset, creates a data map containing the users for rendering the template, and renders the admin all users page.
func (*Repository) AdminAllUsersApi ¶
func (m *Repository) AdminAllUsersApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AdminDashboard ¶
func (m *Repository) AdminDashboard(w http.ResponseWriter, r *http.Request)
AdminDashboard renders admin page for admin user only
func (*Repository) AdminDeleteGenre ¶
func (m *Repository) AdminDeleteGenre(w http.ResponseWriter, r *http.Request)
AdminDeleteGenre deletes the genre from the database in admin context. It takes HTTP response writer and request as parameters.
func (*Repository) AdminDeleteRequestedBook ¶
func (m *Repository) AdminDeleteRequestedBook(w http.ResponseWriter, r *http.Request)
func (*Repository) AdminGetAuthorDetailByID ¶
func (m *Repository) AdminGetAuthorDetailByID(w http.ResponseWriter, r *http.Request)
AdminGetAuthorDetailByID retrieves the author details by ID and renders the admin-authordetail page. It takes the HTTP response writer and request as parameters. The function retrieves the author ID from the URL parameter and converts it to an integer. If the conversion fails, a server error is returned. The function calls the GetAuthorByID interface to retrieve the author from the database. If an error occurs during retrieval, a server error is returned. The function creates a data map and adds the author to the "author" key in the data map. The function renders the "admin-authordetail.page.tmpl" template with the data map.
func (*Repository) AdminGetBookAuthorByID ¶
func (m *Repository) AdminGetBookAuthorByID(w http.ResponseWriter, r *http.Request)
AdminGetBookAuthorByID retrieves the details of a book-author relationship by its book ID and author ID. It takes the HTTP response writer and request as parameters. The function retrieves the book ID and author ID from the URL parameters. If any parsing errors occur, a server error is returned. It retrieves the book-author relationship, book, author, all books, and all authors from the database. The function prepares the necessary data for rendering the template and renders the "admin-bookauthordetial.page.tmpl" template with the form and data.
func (*Repository) AdminGetBookDetailByID ¶
func (m *Repository) AdminGetBookDetailByID(w http.ResponseWriter, r *http.Request)
AdminGetBookDetailByID retrieves and displays the details of a book in the admin. It takes the HTTP response writer and request as parameters. The function extracts the book ID from the URL parameter and converts it to an integer. If there is an error during the conversion, a server error is returned. The function retrieves the book from the database using the GetBookByID method. If an error occurs during the retrieval, a server error is returned. The function retrieves all publishers from the database using the AllPublishers method. If an error occurs during the retrieval, a server error is returned. The function retrieves the publisher of the book using the GetPublisherByID method. If an error occurs during the retrieval, a server error is returned. A data map is created to store the book, publishers, and publisher. The "admin-bookdetail.page.tmpl" template is rendered, passing a new form instance and the data map. The function returns after rendering the template.
func (*Repository) AdminGetBookGenreByID ¶
func (m *Repository) AdminGetBookGenreByID(w http.ResponseWriter, r *http.Request)
AdminGetBookGenreByID handes the detail logic
func (*Repository) AdminGetBookLanguageByID ¶
func (m *Repository) AdminGetBookLanguageByID(w http.ResponseWriter, r *http.Request)
AdminGetBookLanguageByID handes the detail logic for book language. It takes HTTP response writer and request as parameters.
func (*Repository) AdminGetBuyListByID ¶
func (m *Repository) AdminGetBuyListByID(w http.ResponseWriter, r *http.Request)
AdminGetBuyListByID handes the detail logic for BuyList table. It takes HTTP response writer and request as parameters.
func (*Repository) AdminGetContactByID ¶
func (m *Repository) AdminGetContactByID(w http.ResponseWriter, r *http.Request)
AdminGetContactByID handes the detail logic for Contact table. It takes HTTP response writer and request as parameters.
func (*Repository) AdminGetFollowerByID ¶
func (m *Repository) AdminGetFollowerByID(w http.ResponseWriter, r *http.Request)
AdminGetFollowerByID handes the detail logic for Follower table. It takes HTTP response writer and request as parameters.
func (*Repository) AdminGetGenreByID ¶
func (m *Repository) AdminGetGenreByID(w http.ResponseWriter, r *http.Request)
AdminGetGenreByID renders the genre detail and update form page. It mainly handle the get request method. It takes HTTP response writer and request as parameters.
func (*Repository) AdminGetPublisherDetailByID ¶
func (m *Repository) AdminGetPublisherDetailByID(w http.ResponseWriter, r *http.Request)
AdminGetPublisherDetailByID handles the GET request to retrieve the details of a publisher by its ID. It takes the HTTP response writer and request as parameters. The ID of the publisher is extracted from the URL parameter. The publisher is retrieved from the database using the ID. The data map is populated with the publisher object. The template is rendered with the form object and data map.
func (*Repository) AdminGetReadListByID ¶
func (m *Repository) AdminGetReadListByID(w http.ResponseWriter, r *http.Request)
AdminGetReadListByID handes the detail logic for readList table. It takes HTTP response writer and request as parameters.
func (*Repository) AdminGetReviewByID ¶
func (m *Repository) AdminGetReviewByID(w http.ResponseWriter, r *http.Request)
AdminGetReviewByID handes the detail logic for Review table. It takes HTTP response writer and request as parameters.
func (*Repository) AdminGetUserDetailByID ¶
func (m *Repository) AdminGetUserDetailByID(w http.ResponseWriter, r *http.Request)
AdminGetUserDetailByID is a handler that handles the HTTP request for retrieving a user's detail by ID in the admin panel. It retrieves the user ID from the URL parameters, retrieves the user's information from the database, creates a data map containing the user instance for rendering the template, and renders the user detail page.
func (*Repository) AdminInsertAuthor ¶
func (m *Repository) AdminInsertAuthor(w http.ResponseWriter, r *http.Request)
AdminInsertAuthor renders the page inserting new Author. It hanldes the get method for inserting Author It takes HTTP response writer and response as paramters. It creates an empty Author model. It create a data map that stores the empty Author model. Finally, "admin-authorinsert.page.tmpl" is rendered with additional data.
func (*Repository) AdminInsertBook ¶
func (m *Repository) AdminInsertBook(w http.ResponseWriter, r *http.Request)
AdminInsertBook Handles the get method of adding books to the database. It takes the HTTP response writer and request as a parameters. It renders the add book form. It fetches all the publisers from the database by calling AllPublishers interface. If any error occurs during the retrieval, a server error is returned. A data map is created to store the book and publishers. The "admin-bookinsert.page.tmpl" go template is rendered, passing a new form and data.
func (*Repository) AdminInsertPublisher ¶
func (m *Repository) AdminInsertPublisher(w http.ResponseWriter, r *http.Request)
AdminInsertPublisher handles the logic for rendering the publisher insert form. It takes the HTTP response writer and request as parameters. An empty publisher object is created. The data map is populated with the empty publisher object. The template is rendered with the form object and data map.
func (*Repository) AdminInsertReview ¶
func (m *Repository) AdminInsertReview(w http.ResponseWriter, r *http.Request)
AdminInsertReview handles the get method and renders the review add page. It takes HTTP response writer and request as parameters
func (*Repository) AdminLogin ¶
func (m *Repository) AdminLogin(w http.ResponseWriter, r *http.Request)
This function handles the get method of the admin login page. It renders the admin login page.
func (*Repository) AdminUpdateUser ¶
func (m *Repository) AdminUpdateUser(w http.ResponseWriter, r *http.Request)
AdminUpdateUser is a handler that handles the HTTP request for updating a user's information in the admin panel. It retrieves the user ID from the URL parameters, parses the form data from the request, creates a new user instance with the updated information, validates the form, updates the user's information in the database, and redirects the user to the user detail page.
func (*Repository) AdminUserAdd ¶
func (m *Repository) AdminUserAdd(w http.ResponseWriter, r *http.Request)
AdminUserAdd renders page for adding user by admin. It takes HTTP response writer and request as parameters.
func (*Repository) AllAuthors ¶
func (h *Repository) AllAuthors(w http.ResponseWriter, r *http.Request)
func (*Repository) AllBookFilterByGenre ¶
func (m *Repository) AllBookFilterByGenre(w http.ResponseWriter, r *http.Request)
func (*Repository) AllBookFilterByLanguage ¶
func (m *Repository) AllBookFilterByLanguage(w http.ResponseWriter, r *http.Request)
func (*Repository) AllBooks ¶
func (m *Repository) AllBooks(w http.ResponseWriter, r *http.Request)
AllBooks return all books in pages
func (*Repository) AllBooksFilterApi ¶
func (m *Repository) AllBooksFilterApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AllBooksFilterByGenreApi ¶
func (m *Repository) AllBooksFilterByGenreApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AllBooksFilterByLanguageApi ¶
func (m *Repository) AllBooksFilterByLanguageApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AllBooksFilterFromBuyList ¶
func (m *Repository) AllBooksFilterFromBuyList(w http.ResponseWriter, r *http.Request)
func (*Repository) AllBooksFilterFromBuyListApi ¶
func (m *Repository) AllBooksFilterFromBuyListApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AllBooksFilterFromReadList ¶
func (m *Repository) AllBooksFilterFromReadList(w http.ResponseWriter, r *http.Request)
func (*Repository) AllBooksFilterFromReadListApi ¶
func (m *Repository) AllBooksFilterFromReadListApi(w http.ResponseWriter, r *http.Request)
func (*Repository) AuthorFiltersApi ¶
func (h *Repository) AuthorFiltersApi(w http.ResponseWriter, r *http.Request)
func (*Repository) BookBuyListExistsApi ¶
func (m *Repository) BookBuyListExistsApi(w http.ResponseWriter, r *http.Request)
func (*Repository) BookDetailByISBN ¶
func (m *Repository) BookDetailByISBN(w http.ResponseWriter, r *http.Request)
BookDetailByISBN returns the detail of the book using ISBN
func (*Repository) BookReadListExistsApi ¶
func (m *Repository) BookReadListExistsApi(w http.ResponseWriter, r *http.Request)
func (*Repository) ClearSessionMessage ¶
func (m *Repository) ClearSessionMessage(w http.ResponseWriter, r *http.Request)
ClearSessionMessage clears the session message like flash, error and warning after being displayed
func (*Repository) ContactUs ¶
func (m *Repository) ContactUs(w http.ResponseWriter, r *http.Request)
ContactUs renders the contacts us page and contact us form. It takes HTTP request and response writer as paramters
func (*Repository) CustomNotFoundError ¶
func (m *Repository) CustomNotFoundError(w http.ResponseWriter, r *http.Request)
func (*Repository) FollowApi ¶
func (h *Repository) FollowApi(w http.ResponseWriter, r *http.Request)
func (*Repository) FollowExistsApi ¶
func (h *Repository) FollowExistsApi(w http.ResponseWriter, r *http.Request)
func (*Repository) GetFollowingsListByUserIdApi ¶
func (h *Repository) GetFollowingsListByUserIdApi(w http.ResponseWriter, r *http.Request)
func (*Repository) Home ¶
func (m *Repository) Home(w http.ResponseWriter, r *http.Request)
Home handles the home page
func (*Repository) Login ¶
func (m *Repository) Login(w http.ResponseWriter, r *http.Request)
Login Handles the get method of the login
func (*Repository) Logout ¶
func (m *Repository) Logout(w http.ResponseWriter, r *http.Request)
Logout is a handler that handles the HTTP request for logging out the user. If the user is not authenticated, they are redirected to the login page. If the user is authenticated, their session is destroyed and a new session token is generated. Finally, the user is redirected to the login page.
func (*Repository) PersonalProfile ¶
func (m *Repository) PersonalProfile(w http.ResponseWriter, r *http.Request)
PersonalProfile is a handler that handles the HTTP request for displaying the personal profile of a user. It retrieves the user ID from the session, fetches the user's profile information from the database, opens and reads the user's citizenship front and back images, encodes them as base64 strings, creates a data map containing the encoded images and user profile information for rendering the template, and renders the personal profile page.
func (*Repository) PopulateFakeData ¶
func (m *Repository) PopulateFakeData(w http.ResponseWriter, r *http.Request)
func (*Repository) PostAdminAddGenre ¶
func (m *Repository) PostAdminAddGenre(w http.ResponseWriter, r *http.Request)
PostAdminAddGenre is a handler that handles add new genre. It takes HTTP response writer and request as parameters. It parses the data from form, validates it, check for existing genres and only then add new genre. Finally, admin is redirected to all genres page if adding genre is successfull.
func (*Repository) PostAdminDeleteAuthor ¶
func (m *Repository) PostAdminDeleteAuthor(w http.ResponseWriter, r *http.Request)
PostAdminDeleteAuthor handles the deletion of an author. It takes the HTTP response writer and request as parameters. The function retrieves the author ID from the URL parameter and converts it to an integer. If the conversion fails, a server error is returned. The function calls the DeleteAuthor interface to delete the author from the database. If an error occurs during deletion, a server error is returned. The function redirects the user to the "/admin/authors" page.
func (*Repository) PostAdminDeleteBook ¶
func (m *Repository) PostAdminDeleteBook(w http.ResponseWriter, r *http.Request)
PostAdminDeleteBook handles the delete logic of book for admin. It takes HTTP response writer and response as parameters. It fetches the book id from the url and parse it into integer. If it fails to parse, a server error is returned. The function calls the DeleteBook method and pass book id as parameter. If any error occurs, then a server error is returned. If successfull, then admin is redirected to all books page.
func (*Repository) PostAdminDeleteBookAuthor ¶
func (m *Repository) PostAdminDeleteBookAuthor(w http.ResponseWriter, r *http.Request)
PostAdminDeleteBookAuthor deletes a book-author relationship based on the provided book ID and author ID. It takes the HTTP response writer and request as parameters. The function retrieves the book ID and author ID from the URL parameters. If any parsing errors occur, a server error is returned. It calls the database's DeleteBookAuthor method to delete the corresponding book-author relationship. If an error occurs during the deletion, a server error is returned. Otherwise, the function redirects the user to the "/admin/bookAuthors" page with a status code of http.StatusSeeOther.
func (*Repository) PostAdminDeleteBookGenre ¶
func (m *Repository) PostAdminDeleteBookGenre(w http.ResponseWriter, r *http.Request)
PostAdminDeleteBookGenre handles the deletion of a book-genre relationship in an admin context. It takes the HTTP response writer and request as parameters. The function extracts the book ID and genre ID from the URL path parameters, deletes the book-genre relationship from the database, and redirects the user to the "/admin/bookGenres" page. If any errors occur during the process, a server error is returned.
func (*Repository) PostAdminDeleteBookLanguage ¶
func (m *Repository) PostAdminDeleteBookLanguage(w http.ResponseWriter, r *http.Request)
PostAdminDeleteBookLanguage handles the deletion of a book-language relationship in an admin context. It takes the HTTP response writer and request as parameters. The function extracts the book ID and language ID from the URL path parameters, deletes the book-language relationship from the database, and redirects the user to the "/admin/bookLanguages" page. If any errors occur during the process, a server error is returned.
func (*Repository) PostAdminDeleteBuyList ¶
func (m *Repository) PostAdminDeleteBuyList(w http.ResponseWriter, r *http.Request)
PostAdminDeleteBuyList Handles the post method for deleting Buy list record. It takes HTTP response writer and request as paramters
func (*Repository) PostAdminDeleteContact ¶
func (m *Repository) PostAdminDeleteContact(w http.ResponseWriter, r *http.Request)
PostAdminDeleteContact Handles the post method for deleting Contact record. It takes HTTP response writer and request as paramters
func (*Repository) PostAdminDeleteFollow ¶
func (m *Repository) PostAdminDeleteFollow(w http.ResponseWriter, r *http.Request)
PostAdminDeleteFollow Handles the post method for deleting follower list record. It takes HTTP response writer and request as paramters
func (*Repository) PostAdminDeleteLanguage ¶
func (m *Repository) PostAdminDeleteLanguage(w http.ResponseWriter, r *http.Request)
PostAdminDeleteLanguage deletes a language from the database in the admin context. It takes the HTTP response writer and request as parameters. The function retrieves the "id" parameter from the URL and converts it to an integer. If there is an error during the conversion, a server error is returned. The function calls the DeleteLanguage interface to delete the language with the specified ID from the database. If an error occurs during the deletion, a server error is returned. After successful deletion, the function redirects the user to the "/admin/languages" page.
func (*Repository) PostAdminDeletePublisher ¶
func (m *Repository) PostAdminDeletePublisher(w http.ResponseWriter, r *http.Request)
PostAdminDeletePublisher handles the POST request to delete a publisher. It takes the HTTP response writer and request as parameters. The ID of the publisher is extracted from the URL parameter. The publisher is deleted from the database using the ID. If there is an error during the deletion process, a server error is returned. Otherwise, the user is redirected to the publishers admin page.
func (*Repository) PostAdminDeleteReadList ¶
func (m *Repository) PostAdminDeleteReadList(w http.ResponseWriter, r *http.Request)
PostAdminDeleteReadList Handles the post method for deleting read list record. It takes HTTP response writer and request as paramters
func (*Repository) PostAdminDeleteReview ¶
func (m *Repository) PostAdminDeleteReview(w http.ResponseWriter, r *http.Request)
PostAdminDeleteReview Handles the post method for deleting Reviewer list record. It takes HTTP response writer and request as paramters
func (*Repository) PostAdminGetGenreByID ¶
func (m *Repository) PostAdminGetGenreByID(w http.ResponseWriter, r *http.Request)
PostAdminGetGenreByID fetch the specific genre from the database in admin interface as well as handles the update for the genre. It takes HTTP response writer and request as parameters.
func (*Repository) PostAdminInsertAuthor ¶
func (m *Repository) PostAdminInsertAuthor(w http.ResponseWriter, r *http.Request)
PostAdminInsertAuthor handles the insertion of a new author. It takes the HTTP response writer and request as parameters. The function parses the form data from the request. It creates a new form and adds the parsed form data to it. The function retrieves the date of birth from the form and converts it to an integer. If the conversion fails, an error is added to the form errors. The function uploads the author's avatar image using the AdminPublicUploadImage helper function. If the upload fails, an error is added to the form errors. The function creates a new Author model with the form data and the uploaded avatar. The "date_of_birth" field is set to the converted date of birth. The function adds the required validation for the "date_of_birth" field. It creates a data map and adds the author to the "author" key in the data map. If the form is not valid, the function renders the "admin-authorinsert.page.tmpl" template with the form errors and the data map. The function calls the InsertAuthor interface to insert the author into the database. If an error occurs during the insertion, a server error is returned. The function redirects the user to the "/admin/authors" page.
func (*Repository) PostAdminInsertBook ¶
func (m *Repository) PostAdminInsertBook(w http.ResponseWriter, r *http.Request)
PostAdminInsertBook handles the insertion of a new book in the admin context. It takes the HTTP response writer and request as parameters. The function first parses the form data from the request. If an error occurs during the parsing, a server error is returned. A new form instance is created to handle form validation, and a data map is initialized to store the retrieved data. The function parses the published date, paperback, publisher ID, ISBN, and isActive from the form fields, ensuring their appropriate data types. If any errors occur during the parsing, appropriate form errors are added. The function constructs a new book instance of the models.Book struct with the values from the form fields, including the title, description, ISBN, published date, paperback, isActive, addedAt, updatedAt, and publisherID. The function then attempts to upload the book cover image using the AdminPublicUploadImage2 helper function, passing the request, "cover" form field, "book" as the upload type, and the book's ISBN as the filename. If an error occurs during the image upload, a form error is added. The book cover filename is assigned to the book instance. The required and length validations are performed on the form fields using the form instance. If the form is not valid, the function renders the "admin-bookinsert.page.tmpl" template, passing the form and data map. The function then returns. If there are no form validation errors, the function calls the InsertBook method of the database with the book instance. If an error occurs during the insertion, a server error is returned. Finally, the function redirects the user to the list of all books in the admin context.
func (*Repository) PostAdminInsertBookAuthor ¶
func (m *Repository) PostAdminInsertBookAuthor(w http.ResponseWriter, r *http.Request)
PostAdminInsertBookAuthor handles the insertion of a new book-author relationship in an admin context. It takes the HTTP response writer and request as parameters. The function parses the form data from the request and validates it. If any parsing or validation errors occur, a server error is returned. The function retrieves the book ID and author ID from the form data and creates a new BookAuthor object with the provided IDs. It then retrieves all book-author relationships, all books, and all authors from the database to prepare the necessary data for rendering the template. The function checks if the book-author relationship already exists and adds an error to the form if it does. If the form is not valid, the template is rendered with the form and data. If the form is valid, the new book-author relationship is inserted into the database and the user is redirected to the "/admin/bookAuthors" page.
func (*Repository) PostAdminInsertBookGenre ¶
func (m *Repository) PostAdminInsertBookGenre(w http.ResponseWriter, r *http.Request)
PostAdminInsertBookGenre handles the insertion of a new book-genre relationship in an admin context. It takes the HTTP response writer and request as parameters. The function parses the form data from the request and validates it. If any parsing or validation errors occur, a server error is returned. The function retrieves the book ID and genre ID from the form data and creates a new BookGenre object with the provided IDs. It then retrieves all book-genre relationships, all books, and all genres from the database to prepare the necessary data for rendering the template. The function checks if the book-genre relationship already exists and adds an error to the form if it does. If the form is not valid, the template is rendered with the form and data. If the form is valid, the new book-genre relationship is inserted into the database and the user is redirected to the "/admin/bookGenres" page.
func (*Repository) PostAdminInsertBookLanguage ¶
func (m *Repository) PostAdminInsertBookLanguage(w http.ResponseWriter, r *http.Request)
PostAdminInsertBookLanguage handles the insertion of a new book-language relationship in an admin context. It takes the HTTP response writer and request as parameters. The function parses the form data from the request and validates it. If any parsing or validation errors occur, a server error is returned. The function retrieves the book ID and language ID from the form data and creates a new BookLanguage object with the provided IDs. It then retrieves all book-Language relationships, all books, and all Languages from the database to prepare the necessary data for rendering the template. The function checks if the book-language relationship already exists and adds an error to the form if it does. If the form is not valid, the template is rendered with the form and data. If the form is valid, the new book-Language relationship is inserted into the database and the user is redirected to the "/admin/booklanguages" page.
func (*Repository) PostAdminInsertBuyList ¶
func (m *Repository) PostAdminInsertBuyList(w http.ResponseWriter, r *http.Request)
PostAdminInsertBuyList handles post method logic for adding books to buy list by admin. It takes HTTP response writer and request as paramaters
func (*Repository) PostAdminInsertFollower ¶
func (m *Repository) PostAdminInsertFollower(w http.ResponseWriter, r *http.Request)
PostAdminInsertFollower handles post method logic for user following author by admin. It takes HTTP response writer and request as paramaters
func (*Repository) PostAdminInsertLanguage ¶
func (m *Repository) PostAdminInsertLanguage(w http.ResponseWriter, r *http.Request)
PostAdminInsertLanguage inserts a new language into the database in the admin context. It takes the HTTP response writer and request as parameters. The function parses the form data from the request. If there is an error during form parsing, a server error is returned. The function creates a new form instance and initializes a language model with the language value from the form. It sets the "language" field as required in the form. The function creates a data map and adds the "add_language" key with the language model as its value. It calls the AllLanguage interface to retrieve all existing languages from the database. If an error occurs during the retrieval, a server error is returned. The function adds the retrieved languages to the data map with the "languages" key. It checks if the language already exists in the database using the LanguageExists interface. If the language exists, an error is added to the form's errors. If the form is not valid, the function renders the "admin-alllanguages.page.tmpl" template with the form errors and data. If there are no form errors, the function calls the InsertLanguage method to insert the language into the database. If an error occurs during the insertion, a server error is returned. After successful insertion, the function redirects the user to the "/admin/languages" page.
func (*Repository) PostAdminInsertPublisher ¶
func (m *Repository) PostAdminInsertPublisher(w http.ResponseWriter, r *http.Request)
PostAdminInsertPublisher handles the logic for inserting a new publisher using the POST method. It takes the HTTP response writer and request as parameters. The function parses the form data from the request. It creates a new form object and validates the required fields. The established date is converted to an integer. The picture path is obtained by uploading an image using the helper function. A new publisher object is created with the form data and the picture path. The publisher data is stored in the "publisher" key of the data map. If the form is not valid, the template is rendered with the form errors and data. If there is an error during insertion, a server error is returned. Otherwise, the publisher is inserted into the database and a redirect response is sent to the publishers list page.
func (*Repository) PostAdminInsertReadList ¶
func (m *Repository) PostAdminInsertReadList(w http.ResponseWriter, r *http.Request)
PostAdminInsertReadList handles post method logic for adding books to read list by admin. It takes HTTP response writer and request as paramaters
func (*Repository) PostAdminInsertReview ¶
func (m *Repository) PostAdminInsertReview(w http.ResponseWriter, r *http.Request)
PostAdminInsertReview handles the post method of the creating new review. It has HTTP response writer and request as parameters.
func (*Repository) PostAdminKycUpdate ¶
func (m *Repository) PostAdminKycUpdate(w http.ResponseWriter, r *http.Request)
func (*Repository) PostAdminLogin ¶
func (m *Repository) PostAdminLogin(w http.ResponseWriter, r *http.Request)
func (*Repository) PostAdminUpdateAuthor ¶
func (m *Repository) PostAdminUpdateAuthor(w http.ResponseWriter, r *http.Request)
PostAdminUpdateAuthor handles the update author logic. It takes the HTTP response writer and request as parameters. The function retrieves the author ID from the URL parameter and converts it to an integer. If the conversion fails, a server error is returned. The function parses the form data from the request. If an error occurs during parsing, a server error is returned. It creates a new form and adds the parsed form data to it. The function retrieves the date of birth from the form and converts it to an integer. If the conversion fails, a server error is returned. The function creates a new Author model with the form data and the converted date of birth. The author's ID is set to the retrieved ID from the URL parameter. The function creates a data map and adds the author to the "author" key in the data map. If the form is not valid, the function renders the "admin-authordetail.page.tmpl" template with the form errors and the data map. The function calls the UpdateAuthor interface to update the author in the database. If an error occurs during the update, a server error is returned. The function redirects the user to the author's detail page.
func (*Repository) PostAdminUpdateBook ¶
func (m *Repository) PostAdminUpdateBook(w http.ResponseWriter, r *http.Request)
PostAdminUpdateBook handles the update of a book in the admin context. It takes the HTTP response writer and request as parameters. The function retrieves the book ID from the URL parameter and parses it into an integer. If an error occurs during the parsing, a server error is returned. The function then parses the form data from the request. If an error occurs during the parsing, a server error is returned. A new form instance is created to handle form validation, and a data map is initialized to store the retrieved data. The function retrieves the book from the database using the GetBookByID method based on the parsed book ID. If an error occurs during the retrieval, a server error is returned. The function also retrieves the publisher of the book using the GetPublisherByID method based on the publisher ID stored in the retrieved book. If an error occurs during the retrieval, a server error is returned. Additionally, the function retrieves all publishers from the database using the AllPublishers method. If an error occurs during the retrieval, a server error is returned. The retrieved book, publisher, and publishers are stored in the data map. The function parses other form fields such as ISBN, published date, paperback, and isActive, ensuring their appropriate data types. If any errors occur during the parsing, a server error is returned. The function constructs an updated_book instance of the models.Book struct with the updated values from the form fields. The required and length validations are performed on the form fields using the form instance. If the form is not valid, the function renders the "admin-bookdetail.page.tmpl" template, passing the form and data map. The function then returns. If there are no form validation errors, the function calls the UpdateBook method of the database with the updated_book instance. If an error occurs during the update, a server error is returned. Finally, the function redirects the user to the detailed view of the updated book using the book ID.
func (*Repository) PostAdminUpdateBookAuthor ¶
func (m *Repository) PostAdminUpdateBookAuthor(w http.ResponseWriter, r *http.Request)
PostAdminUpdateBookAuthor handles the update logic of a book-author relationship in an admin context. It takes the HTTP response writer and request as parameters. The function retrieves the book ID and author ID from the URL parameters and parses the form data from the request. If any parsing errors occur, a server error is returned. It creates a new form object and retrieves the updated book ID and author ID from the form data. The function checks if the updated book-author relationship already exists and adds an error to the form if it does. It retrieves the book and author details based on their IDs from the database, as well as all books and all authors. The function prepares the necessary data for rendering the template. The form data is then validated, and if the form is not valid, the template is rendered with the form and data. If the form is valid, the book-author relationship is updated in the database, and the user is redirected to the detail page of the updated book-author relationship.
func (*Repository) PostAdminUpdateBookGenre ¶
func (m *Repository) PostAdminUpdateBookGenre(w http.ResponseWriter, r *http.Request)
AdminGetBookGenreByID retrieves information related to a specific book-genre relationship in an admin context. It takes the HTTP response writer and request as parameters. The function extracts the book ID and genre ID from the URL path parameters, retrieves the book-genre relationship, book title, genre information, all books, and all genres from the database. It then prepares the necessary data and renders the "admin-bookgenredetail.page.tmpl" template to display the details. If any errors occur during the process, a server error is returned.
func (*Repository) PostAdminUpdateBookLanguage ¶
func (m *Repository) PostAdminUpdateBookLanguage(w http.ResponseWriter, r *http.Request)
PostAdminUpdateBookLanguage handles the post method for updating the book-language relationship. It takes HTTP response writer and request as parameters.
func (*Repository) PostAdminUpdateBuyList ¶
func (m *Repository) PostAdminUpdateBuyList(w http.ResponseWriter, r *http.Request)
PostAdminUpdateBuyList handles the post method for updating the book-user add buy list relationship. It takes HTTP response writer and request as parameters.
func (*Repository) PostAdminUpdateFollower ¶
func (m *Repository) PostAdminUpdateFollower(w http.ResponseWriter, r *http.Request)
PostAdminUpdateFollower handles the post method for updating the author-user follower relationship. It takes HTTP response writer and request as parameters.
func (*Repository) PostAdminUpdateLanguage ¶
func (m *Repository) PostAdminUpdateLanguage(w http.ResponseWriter, r *http.Request)
PostAdminUpdateLanguage handles the update language logic
func (*Repository) PostAdminUpdatePublisher ¶
func (m *Repository) PostAdminUpdatePublisher(w http.ResponseWriter, r *http.Request)
PostAdminUpdatePublisher handles the post method logic for updating a publisher. It takes the HTTP response writer and request as parameters. The ID of the publisher is extracted from the URL parameter. The form is parsed and a new form object is created. The established date is converted to an integer. The publisher object is populated with the form data. The ID of the publisher is set. The "name" field is marked as required. The data map is populated with the publisher object. If the form is not valid, the template is rendered with the form object and data map. The publisher is updated in the database. The user is redirected to the publisher detail page.
func (*Repository) PostAdminUpdateReadList ¶
func (m *Repository) PostAdminUpdateReadList(w http.ResponseWriter, r *http.Request)
PostAdminUpdateReadList handles the post method for updating the book-user add read list relationship. It takes HTTP response writer and request as parameters.
func (*Repository) PostAdminUpdateRequestBookStatus ¶
func (m *Repository) PostAdminUpdateRequestBookStatus(w http.ResponseWriter, r *http.Request)
func (*Repository) PostAdminUpdateReview ¶
func (m *Repository) PostAdminUpdateReview(w http.ResponseWriter, r *http.Request)
PostAdminUpdateReview handles the post method for updating the Review. It takes HTTP response writer and request as parameters.
func (*Repository) PostAdminUserAdd ¶
func (m *Repository) PostAdminUserAdd(w http.ResponseWriter, r *http.Request)
PostAdminUserAdd handles post method for creating user from admin interface. It takes HTTP response writer and request as parameters. It parses form, store the form data, add validations, check for existing user and then only add user if not exists.
func (*Repository) PostAdminUserDeleteByID ¶
func (m *Repository) PostAdminUserDeleteByID(w http.ResponseWriter, r *http.Request)
PostAdminUserDeleteByID renders a confim page to delete users. It takes HTTP response writer and request as parameters. It parse the id from url, check if auth user id and id from url mathches or not, delete the user if not match.
func (*Repository) PostAdminUserDocumentUpdate ¶
func (m *Repository) PostAdminUserDocumentUpdate(w http.ResponseWriter, r *http.Request)
func (*Repository) PostAdminUserProfileUpdate ¶
func (m *Repository) PostAdminUserProfileUpdate(w http.ResponseWriter, r *http.Request)
PostAdminUserProfileUpdate is a handler that handles the HTTP request for updating a user's profile picture in the admin panel. It retrieves the user ID from the URL parameters, gets the username from the session, uploads the profile picture file, updates the profile picture path in the database, and redirects the user to the user detail page.
func (*Repository) PostContactUs ¶
func (m *Repository) PostContactUs(w http.ResponseWriter, r *http.Request)
ContactUs handles the post method after user submits the contact form. It takes HTTP request and response writer as paramters
func (*Repository) PostLogin ¶
func (m *Repository) PostLogin(w http.ResponseWriter, r *http.Request)
PostLogin is a handler that handles the HTTP POST request for user login. It validates the login form data, authenticates the user, and stores the user ID and access level in the session. If the authentication is successful, it redirects the user to the home page. If the authentication fails, it renders the login page with appropriate error messages.
func (*Repository) PostPublicCreateReview ¶
func (m *Repository) PostPublicCreateReview(w http.ResponseWriter, r *http.Request)
func (*Repository) PostPublicDeleteReview ¶
func (m *Repository) PostPublicDeleteReview(w http.ResponseWriter, r *http.Request)
func (*Repository) PostPublicUpdateReview ¶
func (m *Repository) PostPublicUpdateReview(w http.ResponseWriter, r *http.Request)
func (*Repository) PostRegister ¶
func (m *Repository) PostRegister(w http.ResponseWriter, r *http.Request)
PostRegister is a handler that handles the HTTP POST request for user registration. It creates a new session token, parses a multipart form, validates the form fields, and inserts the user data into the database if the form is valid. If there are any errors during the registration process, the user is redirected to the registration page with error messages. If the registration is successful, the user is redirected to the login page.
func (*Repository) PostRequestBook ¶
func (m *Repository) PostRequestBook(w http.ResponseWriter, r *http.Request)
func (*Repository) PostResetPassword ¶
func (m *Repository) PostResetPassword(w http.ResponseWriter, r *http.Request)
PostResetPassword handles the post method that takes in the email address and send the reset token to user email. It takes HTTP response writer and request as parameters. It parse the form, validates the email, checks if email exists, then send reset token to email if exists.
func (*Repository) PostResetPasswordChange ¶
func (m *Repository) PostResetPasswordChange(w http.ResponseWriter, r *http.Request)
PostResetPasswordChange handles post method and changes the password. It takes HTTP response writer and request as parameters. It parses the form data from the request, validates the form, checks the validity of the reset token, encrypts the new password, updates the user's password in the database, sends a notification email, and redirects the user to the login page.
func (*Repository) PostUserProfilePicUpdate ¶
func (m *Repository) PostUserProfilePicUpdate(w http.ResponseWriter, r *http.Request)
func (*Repository) PublicAboutUs ¶
func (m *Repository) PublicAboutUs(w http.ResponseWriter, r *http.Request)
func (*Repository) PublicCreateReview ¶
func (m *Repository) PublicCreateReview(w http.ResponseWriter, r *http.Request)
func (*Repository) PublicGetAuthorByID ¶
func (h *Repository) PublicGetAuthorByID(w http.ResponseWriter, r *http.Request)
func (*Repository) PublicUpdateKYC ¶
func (m *Repository) PublicUpdateKYC(w http.ResponseWriter, r *http.Request)
func (*Repository) PublicUpdateReview ¶
func (m *Repository) PublicUpdateReview(w http.ResponseWriter, r *http.Request)
func (*Repository) PublisherWithBooksDetailByID ¶
func (m *Repository) PublisherWithBooksDetailByID(w http.ResponseWriter, r *http.Request)
func (*Repository) Register ¶
func (m *Repository) Register(w http.ResponseWriter, r *http.Request)
Register handles the get method of the register.
func (*Repository) RemoveFromBuyListApi ¶
func (m *Repository) RemoveFromBuyListApi(w http.ResponseWriter, r *http.Request)
func (*Repository) RemoveFromReadListApi ¶
func (m *Repository) RemoveFromReadListApi(w http.ResponseWriter, r *http.Request)
func (*Repository) RequestBook ¶
func (m *Repository) RequestBook(w http.ResponseWriter, r *http.Request)
func (*Repository) ResetPassword ¶
func (m *Repository) ResetPassword(w http.ResponseWriter, r *http.Request)
ResetPassword render the password reset page. It takes HTTP response writer and request as parameters. It renders password reset page.
func (*Repository) ResetPasswordChange ¶
func (m *Repository) ResetPasswordChange(w http.ResponseWriter, r *http.Request)
ResetPasswordChange renders password change form with new and confirm password. It takes HTTP response writer and request as parameters.
func (*Repository) UnFollowApi ¶
func (h *Repository) UnFollowApi(w http.ResponseWriter, r *http.Request)
func (*Repository) UpdateSession ¶
func (m *Repository) UpdateSession(w http.ResponseWriter, r *http.Request, id, access_level int, username string, is_validated bool)
Source Files ¶
- admin_author_handler.go
- admin_book_author_handler.go
- admin_book_genre_handler.go
- admin_book_handler.go
- admin_book_language_handler.go
- admin_buylist_handler.go
- admin_contact_handler.go
- admin_follower_handler.go
- admin_genre_handler.go
- admin_language_handler.go
- admin_publisher_handler.go
- admin_readlist_handler.go
- admin_request_book_handler.go
- admin_review_handler.go
- admin_user_handler.go
- auth_handler.go
- auth_reset_password_handler.go
- error_handler.go
- handler.go
- public_about_us_handler.go
- public_author_handler.go
- public_book_handler.go
- public_buyList_handler.go
- public_contact_handler.go
- public_follow_handler.go
- public_genre_handler.go
- public_language_handler.go
- public_publisher_handler.go
- public_readList_handler.go
- public_request_book_handler.go
- public_review_handler.go