package com.engine.mingfeng.controller;

import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.mingfeng.service.PerformanService;
import com.engine.mingfeng.service.impl.PerformanServiceImpl;
import com.google.gson.Gson;
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 chenwnj
 * @date 2023/11/6
 * @description
 **/
public class PerformanController {
    public PerformanService getPerformanService(User user) {
        return ServiceUtil.getService(PerformanServiceImpl.class,user);
    }

    @Path("/getperformaninfo")
    @POST
    @Produces(MediaType.APPLICATION_JSON)
    public String getPerformanInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        Map<String, Object> params = ParamUtil.request2Map(request);
        Map<String, Object> resultDatas = getPerformanService(user).getPerformanInfo(params);
        return  new Gson().toJson(resultDatas);
    }
}
