package com.cyksj.web.controller.manage.corp;

import com.cyksj.dto.Result;
import com.cyksj.enums.GatewayResponse;
import com.cyksj.model.manage.views.CorpUserView;
import com.ejlchina.searcher.BeanSearcher;
import com.ejlchina.searcher.SearchResult;
import com.ejlchina.searcher.util.MapUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 企业微信/用户列表
 * @author chan
 * @date 2024/1/19 10:48
 */
@Slf4j
@RestController
@RequestMapping("/manage/corp/user")
@RequiredArgsConstructor
public class CorpUserController {

    private final BeanSearcher beanSearcher;

    private final HttpServletRequest request;

    /**
     * 企业微信用户列表
     */
    @GetMapping
    public Result<SearchResult<CorpUserView>> get(){
        SearchResult<CorpUserView> search = beanSearcher.search(CorpUserView.class, MapUtils.flatBuilder(request.getParameterMap()).build());
        return GatewayResponse.SUCCESS.newBuilder().toResult(search);
    }

}
