package com.engine.attendance.workflow.web;

import com.alibaba.fastjson.JSONObject;
import com.engine.attendance.workflow.service.EnterpriseCalendarService;
import com.engine.attendance.workflow.service.impl.EnterpriseCalendarServiceImpl;
import com.engine.common.util.ApiReturnTools;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
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.HashMap;
import java.util.Map;

/**
 * @Author: sy
 * @Description: 企业日历
 * @Date: 2024/4/24
 **/
public class EnterpriseCalendarApi {

    private EnterpriseCalendarService getEnterpriseCalendarService(User user) {
        return ServiceUtil.getService(EnterpriseCalendarServiceImpl.class,user);
    }

    /**
     * 生成企业日历初始化数据
     * @param request
     * @param response
     * @return
     */
    @POST
    @Path("/initCalendar")
    @Produces(MediaType.TEXT_PLAIN)
    public String initCalendar(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        Map<String, Object> apidatas = new HashMap<String, Object>();
        User user = HrmUserVarify.getUser(request, response);
        apidatas = getEnterpriseCalendarService(user).initCalendar(ParamUtil.request2Map(request));
        return ApiReturnTools.success(apidatas);
    }
}
