package com.engine.recruit.controller;

import com.engine.common.util.ServiceUtil;
import com.engine.recruit.entity.workplan.WorkPlanCreateParams;
import com.engine.recruit.service.WorkPlanSerivice;
import com.engine.recruit.service.impl.WorkPlanServiceImpl;
import com.engine.recruit.util.ResponseResult;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
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;

/**
 * @Author liang.cheng
 * @Date 2023/10/17 10:48 AM
 * @Description: 面试生成日程
 * @Version 1.0
 */
public class WorkPlanController {

    public WorkPlanSerivice getWorkPlan(User user) {
        return ServiceUtil.getService(WorkPlanServiceImpl.class, user);
    }

    @POST
    @Path("/operate")
    @Produces(MediaType.APPLICATION_JSON)
    public String operateWorkPlan(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody WorkPlanCreateParams workPlanCreateParams) {
        User user = HrmUserVarify.getUser(request, response);
        return new ResponseResult<WorkPlanCreateParams, String>(user).run(getWorkPlan(user)::operate, workPlanCreateParams);
    }


}
