Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

관리자 리스트의 경우 board_list(), member_list() 함수 참고하세요. #11

Closed
kagla opened this issue Oct 18, 2023 · 0 comments

Comments

@kagla
Copy link
Contributor

kagla commented Oct 18, 2023

공통 검색 파라미터를 사용시

async def member_list(request: Request, db: Session = Depends(get_db), search_params: dict = Depends(common_search_query_params)):

select query 시

result = select_query(
            request, 
            models.Member, 
            search_params, 
            same_search_fields = ["mb_level"], 
            prefix_search_fields = ["mb_name", "mb_nick", "mb_tel", "mb_hp", "mb_datetime", "mb_recommend"]
        )

    same_search_fields: # 값이 완전히 같아야지만 필터링 '검색어'
    prefix_search_fields: # 뒤에 %를 붙여서 필터링 '검색어%'

수정된 회원 관리 리스트 코드

@router.get("/member_list")
async def member_list(request: Request, db: Session = Depends(get_db), search_params: dict = Depends(common_search_query_params)):
    '''
    회원관리 목록
    '''
    request.session["menu_key"] = MEMBER_MENU_KEY
    
    result = select_query(
                request, 
                models.Member, 
                search_params, 
                same_search_fields = ["mb_level"], 
                prefix_search_fields = ["mb_name", "mb_nick", "mb_tel", "mb_hp", "mb_datetime", "mb_recommend"]
            )
    
    query_string = generate_query_string(request)
    
    context = {
        "request": request,
        "members": result['rows'],
        "admin": request.state.context['member'], # 로그인해 있는 회원을 관리자로 간주함
        "total_count": result['total_count'],
        "paging": get_paging(request, search_params['current_page'], result['total_count'], f"/admin/member_list?{query_string}&page="),
    }
    return templates.TemplateResponse("member_list.html", context)
@kagla kagla closed this as completed Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant