/home/innobuno/dev/g6/templates/trend2025/bbs/menu.html
python
Apply to menu.html
template_data = {
"current_login_count": current_connect_service.fetch_total_records(),
"menus": menu_service.fetch_menus(),
"poll": poll_service.fetch_latest_poll(),
"populars": popular_service.fetch_populars(),
}
request.state.template_data = template_data
python
Apply to menu.html
@cached(LRUCache(maxsize=128), key=lambda _: hashkey("menus"))
def fetch_menus(self) -> List[Menu]:
menus = []
# 부모메뉴 조회
parent_menus = self.db.scalars(
select(Menu)
.where(func.char_length(Menu.me_code) == 2)
.order_by(Menu.me_order)
).all()
for menu in parent_menus:
parent_code = menu.me_code
# 자식 메뉴 조회
child_menus = self.db.scalars(
select(Menu).where(
func.char_length(Menu.me_code) == 4,
func.substr(Menu.me_code, 1, 2) == parent_code
).order_by(Menu.me_order)
).all()
menu.sub = child_menus
menus.append(menu)
return menus
댓글목록
등록된 댓글이 없습니다.