package com.engine.organization.web;

import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.organization.util.response.ReturnResult;
import com.engine.organization.wrapper.OrgVirtualWrapper;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Map;

/**
 * @Author liang.cheng
 * @Date 2023/6/27 3:41 PM
 * @Version 1.0
 */
public class OrgVirtualController {

    public OrgVirtualWrapper getVirtualWrapper(User user) {
        return ServiceUtil.getService(OrgVirtualWrapper.class, user);
    }

    @GET
    @Path("/getTable")
    @Produces(MediaType.APPLICATION_JSON)
    public ReturnResult listOrgVirtual(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        try {
            User user = HrmUserVarify.getUser(request, response);
            Map<String, Object> map = ParamUtil.request2Map(request);
            return ReturnResult.successed(getVirtualWrapper(user).listPage(map));
        } catch (Exception e) {
            return ReturnResult.exceptionHandle(e);
        }
    }

}
