package com.engine.recruit.controller;

import com.engine.common.util.ServiceUtil;
import com.engine.recruit.util.ResponseResult;
import com.engine.recruit.wrapper.InitRecruitDataWrapper;
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: 2023/11/23
 * @version: 1.0
 */
public class InitRecruitDataController {
    public InitRecruitDataWrapper getInitRecruitDataWrapper(User user) {
        return ServiceUtil.getService(InitRecruitDataWrapper.class, user);
    }

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

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

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