package com.engine.recruit.controller;

import com.engine.common.util.ServiceUtil;
import com.engine.recruit.entity.workbench.OptionVO;
import com.engine.recruit.entity.workbench.RecruitPortalCommonVO;
import com.engine.recruit.service.WorkBenchPortalService;
import com.engine.recruit.service.impl.WorkBenchPortalServiceImpl;
import com.engine.recruit.util.ResponseResult;
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.List;

/**
 * @Author liang.cheng
 * @Date 2023/10/18 4:34 PM
 * @Version 1.0
 */
public class WorkBenchPortalController {

    public WorkBenchPortalService getWorkBenchPortal(User user) {
        return ServiceUtil.getService(WorkBenchPortalServiceImpl.class, user);
    }


    @GET
    @Path("/top")
    @Produces(MediaType.APPLICATION_JSON)
    public String getRecruitPortalTop(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        return new ResponseResult<String, List<RecruitPortalCommonVO>>(user).run(getWorkBenchPortal(user) :: getRecruitPortalTop);
    }


    @GET
    @Path("/jobTenure")
    @Produces(MediaType.APPLICATION_JSON)
    public String getJobTenure(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        return new ResponseResult<String, OptionVO>(user).run(getWorkBenchPortal(user) :: getJobTenure);
    }

    @GET
    @Path("/waitStepPerson")
    @Produces(MediaType.APPLICATION_JSON)
    public String getWaitStepPerson(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        return new ResponseResult<String, OptionVO>(user).run(getWorkBenchPortal(user) :: getWaitStepPerson);
    }

    @GET
    @Path("/recruitTransform")
    @Produces(MediaType.APPLICATION_JSON)
    public String getRecruitTransform(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        return new ResponseResult<String, OptionVO>(user).run(getWorkBenchPortal(user) :: getRecruitTransform);
    }


    @GET
    @Path("/peopleFrom")
    @Produces(MediaType.APPLICATION_JSON)
    public String getPeopleFrom(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        return new ResponseResult<String, OptionVO>(user).run(getWorkBenchPortal(user) :: getPeopleFrom);
    }



    @GET
    @Path("/recruitProgress")
    @Produces(MediaType.APPLICATION_JSON)
    public String getRecruitProgress(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        return new ResponseResult<String, List<RecruitPortalCommonVO>>(user).run(getWorkBenchPortal(user) :: getRecruitProgress);
    }
}
