package com.engine.secret.web;

import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.secret.service.QualificationApplicationService;
import com.engine.secret.service.impl.QualificationApplicationServiceImpl;
import com.engine.secret.util.ResponseResult;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
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:dxfeng
 * @createTime: 2024/08/29
 * @version: 1.0
 */
public class QualificationApplicationController {
    public QualificationApplicationService getService(User user) {
        return ServiceUtil.getService(QualificationApplicationServiceImpl.class, user);
    }

    @POST
    @Path("/parsingFiles")
    @Produces(MediaType.APPLICATION_JSON)
    public String parsingFiles(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        Map<String, Object> params = ParamUtil.request2Map(request);
        return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getService(user)::parsingFiles, params);

    }

    @POST
    @Path("/deleteParsedData")
    @Produces(MediaType.APPLICATION_JSON)
    public String deleteParsedData(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        Map<String, Object> params = ParamUtil.request2Map(request);
        return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getService(user)::deleteParsedData, params);

    }
}
