package com.dbnt.kcscbackend.admin.users;


import com.dbnt.kcscbackend.admin.users.service.AdminUsersService;
import com.dbnt.kcscbackend.auth.entity.UserInfo;
import com.dbnt.kcscbackend.config.common.BaseController;
import com.dbnt.kcscbackend.config.common.ResultVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/users")
@Tag(name="AdminConfigController", description = "사이트관리 사용자관리 메뉴 컨트롤러")
public class AdminUsersController extends BaseController {

  private final AdminUsersService adminUsersService;

  @Operation(
      summary = "사용자 목록 조회",
      description = "사용자 목록 조회",
      tags = {"AdminUsersController"}
  )
  @ApiResponses(value = {
      @ApiResponse(responseCode = "200", description = "조회 성공"),
      @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
  })
  @RequestMapping(method = RequestMethod.GET, value = "/list")
  public ResultVO getUserList(UserInfo params) throws Exception{
    ResultVO resultVO = new ResultVO();
    Map<String, Object> resultMap = new HashMap<>();
    params.setQueryInfo();
    resultMap.put("userList", adminUsersService.selectUserList(params));
    params.setContentCnt(adminUsersService.selectUserListCnt(params));
    params.setPaginationInfo();
    resultMap.put("paginationInfo", params);
    resultVO.setResult(resultMap);
    return resultVO;
  }

}
