package com.engine.salary.web;

import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.progress.ProgressDTO;
import com.engine.salary.service.ProgressService;
import com.engine.salary.service.impl.ProgressServiceImpl;
import com.engine.salary.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.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

/**
 * 进度条
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
public class SalaryProgressController {

    private ProgressService getSalaryAcctProgressService(User user) {
        return (ProgressService) ServiceUtil.getService(ProgressServiceImpl.class, user);
    }

    //获取进度条
    @GET
    @Path("/getRate")
    @Produces(MediaType.APPLICATION_JSON)
    public String getRate(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "cacheKey") String cacheKey) {
        User user = HrmUserVarify.getUser(request, response);
        return new ResponseResult<String, ProgressDTO>(user).run(getSalaryAcctProgressService(user)::getProgress, cacheKey);
    }

//    @ApiOperation("获取进度条")
//    @GetMapping("/getWelfareAccountRate")
//    @WeaPermission(publicPermission = true)
//    public WeaResult<SalaryAcctProgressDTO> getWelfareAccountRate(@RequestParam String billMonth) {
//        Long employeeId = UserContext.getCurrentEmployeeId();
//        String tenantKey = TenantContext.getCurrentTenantKey();
//        SalaryAcctProgressDTO salaryAcctProgressDTO = salaryAcctProgressService.getProgress(tenantKey + billMonth, employeeId, tenantKey);
//        return WeaResult.success(salaryAcctProgressDTO);
//    }
}
