コード例 #1
0
def GetBooksByPage(req):
    book_pagination = models.Books.query.filter(models.Books.delete_at == None).paginate(page=req.page, per_page=req.per_page)
    has_next = book_pagination.has_next
    has_prev = book_pagination.has_prev
    books = ConvertModelListToDictList(book_pagination.items)
    print(type(books))
    return has_next, has_prev, books
コード例 #2
0
def SearchSchedules(req: SearchSchedulesReq):
    search_schedules = models.Schedules.query.filter(or_(models.Schedules.schedule_id == req.schedule_id,
                                                         models.Schedules.employee_id == req.employee_id
                                                     )).all()

    schedules = ConvertModelListToDictList(search_schedules)
    return schedules
コード例 #3
0
def SearchAuthor(req: SearchAuthorReq):
    author = models.Authors.query.filter(
        or_(models.Authors.author_id == req.author_id,
            models.Authors.author_name == req.author_name)).all()
    authors = ConvertModelListToDictList(author)

    return authors
コード例 #4
0
def SearchCustomers(req: SearchCustomersReq):
    search_customer = models.Customers.query.filter(or_(models.Customers.customer_id == req.customer_id,
                                                        models.Customers.account_id == req.account_id,
                                                        models.Customers.identity_id == req.identity_id,
                                                        models.Customers.phone == req.phone)).all()
    customers = ConvertModelListToDictList(search_customer)
    return customers
コード例 #5
0
ファイル: models.py プロジェクト: phong3710/LibraryManagement
 def serialize(self):
     return {
         "borrow_ticket_id":
         self.borrow_ticket_id,
         "customer":
         self.customer.serialize(),
         "note":
         self.note,
         "employee":
         self.employee.serialize(),
         "quantity":
         self.quantity,
         "borrow_date":
         self.borrow_date,
         "appointment_date":
         self.appointment_date,
         "return_date":
         self.return_date,
         "status":
         self.status,
         "delete_at":
         self.delete_at,
         "borrow_ticket_details":
         ConvertModelListToDictList(self.borrow_ticket_detail)
     }
コード例 #6
0
def GetBorrowTicketsByPage(req: GetItemsByPageReq):
    borrowticket_pagination = models.Borrowtickets.query.filter(models.Borrowtickets.delete_at == None).paginate \
        (per_page=req.per_page, page=req.page)
    has_next = borrowticket_pagination.has_next
    has_prev = borrowticket_pagination.has_prev
    borrow_tickets = ConvertModelListToDictList(borrowticket_pagination.items)
    return has_next, has_prev, borrow_tickets
コード例 #7
0
def GetCategoriesByPage(req):
    category_pagination = models.Categories.query.filter(
        models.Categories.delete_at == None).paginate(page=req.page,
                                                      per_page=req.per_page)
    has_next = category_pagination.has_next
    has_prev = category_pagination.has_prev
    categories = ConvertModelListToDictList(category_pagination.items)
    return has_next, has_prev, categories
コード例 #8
0
def SearchAccounts(acc_info):
    model_accounts = models.Accounts.query.filter(
        or_(
            models.Accounts.account_id == acc_info.account_id,
            models.Accounts.account_name == acc_info.account_name,
        )).all()
    accounts = ConvertModelListToDictList(model_accounts)
    return accounts
コード例 #9
0
def GetAccountsByPage(req):
    account_pagination = models.Accounts.query.filter(
        models.Accounts.delete_at == None).paginate(page=req.page,
                                                    per_page=req.per_page)
    has_next = account_pagination.has_next
    has_prev = account_pagination.has_prev
    accounts = ConvertModelListToDictList(account_pagination.items)
    return has_next, has_prev, accounts
コード例 #10
0
def GetOrderDetailsByPage(req: GetItemsByPageReq):
    order_detail_pagination = models.Orderdetails.query.filter(
        models.Orderdetails.delete_at == None).paginate(per_page=req.per_page,
                                                        page=req.page)
    has_next = order_detail_pagination.has_next
    has_prev = order_detail_pagination.has_prev
    order_details = ConvertModelListToDictList(order_detail_pagination.items)
    return has_next, has_prev, order_details
コード例 #11
0
def GetSuppliersByPage(req: GetItemsByPageReq):
    supplier_pagination = Suppliers.query.filter(
        Suppliers.delete_at == None).paginate(per_page=req.per_page,
                                              page=req.page)
    has_next = supplier_pagination.has_next
    has_prev = supplier_pagination.has_prev
    suppliers = ConvertModelListToDictList(supplier_pagination.items)
    return has_next, has_prev, suppliers
コード例 #12
0
def GetEmployeesbyPage(req: GetItemsByPageReq):
    employees_pagination = models.Employees.query.filter(
        models.Employees.delete_at == None).paginate(per_page=req.per_page,
                                                     page=req.page)
    has_next = employees_pagination.has_next
    has_prev = employees_pagination.has_prev
    employees = ConvertModelListToDictList(employees_pagination.items)
    return has_next, has_prev, employees
コード例 #13
0
def SearchOrders(req: SearchOrdersReq):
    search_order = models.Orders.query.filter(
        or_(models.Orders.customer_id == req.customer_id,
            models.Orders.order_id == req.order_id,
            models.Orders.employee_id == req.employee_id,
            models.Orders.order_date == req.order_date)).all()
    orders = ConvertModelListToDictList(search_order)
    res = SearchOrdersRsp(orders).serialize()
    return res
コード例 #14
0
def SearchBook(req: SearchBookReq):
    model_books = models.Books.query.filter(or_(
            models.Books.book_id == req.book_id,
            models.Books.book_name == req.book_name,
            models.Books.author_id == req.author_id,
            models.Books.category_id == req.category_id,
            models.Books.supplier_id == req.supplier_id,
    )).all()
    books = ConvertModelListToDictList(model_books)
    return books
コード例 #15
0
def SearchEmployees(req: SearchEmployeesReq):
    search_employee = models.Employees.query.filter(
        or_(models.Employees.first_name == req.first_name,
            models.Employees.last_name == req.last_name,
            models.Employees.identity_id == req.identity_id,
            models.Employees.account_id == req.account_id,
            models.Employees.phone == req.phone,
            models.Employees.employee_id == req.employee_id)).all()
    employees = ConvertModelListToDictList(search_employee)
    return employees
コード例 #16
0
def SearchBorrowTicket(req: SearchBorrowTicketReq):
    search_borrow_ticket = models.Borrowtickets.query.filter(
        or_(
            models.Borrowtickets.customer_id == req.customer_id,
            models.Borrowtickets.employee_id == req.employee_id,
            models.Borrowtickets.borrow_date == req.borrow_date,
            models.Borrowtickets.return_date == req.return_date,
            models.Borrowtickets.status == req.status,
            models.Borrowtickets.borrow_ticket_id == req.borrow_ticket_id,
        )).all()
    # first = search_borrow_ticket[0]
    # print(first.books)
    borrow_tickets = ConvertModelListToDictList(search_borrow_ticket)

    return borrow_tickets
コード例 #17
0
def GetScheduleByPage(req: GetItemsByPageReq):
    schedule_pagination = models.Schedules.query.filter(models.Schedules.delete_at == None).paginate(per_page=req.per_page, page=req.page)
    has_next = schedule_pagination.has_next
    has_prev = schedule_pagination.has_prev
    schedules = ConvertModelListToDictList(schedule_pagination.items)
    return has_next, has_prev, schedules
コード例 #18
0
def SearchSuppliers(req: SearchSuppliersReq):
    search_suppliers = Suppliers.query.filter(
        or_(Suppliers.supplier_id == req.supplier_id,
            Suppliers.contact_name == req.contact_name)).all()
    suppliers = ConvertModelListToDictList(search_suppliers)
    return suppliers
コード例 #19
0
def SearchCategory(req: SearchCategoryReq):
    search_category = models.Categories.query.filter(
        or_(models.Categories.category_id == req.category_id,
            models.Categories.category_name == req.category_name)).all()
    categories = ConvertModelListToDictList(search_category)
    return categories
コード例 #20
0
def GetCustomersByPage(req: GetItemsByPageReq):
    customers_pagination = models.Customers.query.filter(models.Customers.delete_at == None).paginate(per_page=req.per_page, page=req.page)
    has_next = customers_pagination.has_next
    has_prev = customers_pagination.has_prev
    customers = ConvertModelListToDictList(customers_pagination.items)
    return has_next, has_prev, customers