package com.zcxk.evaluation.controller;

import com.zcxk.evaluation.dto.EvaluationResultDetailsDto;
import com.zcxk.evaluation.service.EvaluationResultDetailsService;
import com.zcxk.exception.ServiceException;
import com.zcxk.model.AjaxMessage;
import com.zcxk.model.ResultStatus;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @ClassName EvaluationResultController
 * @Description: 绩效考评结果详情
 * @Author lihui
 * @Date 2021/5/7
 * @Version V1.0
 **/
@RestController
@RequestMapping("/evaluation/details")
@Api(tags = "考评结果详情")
public class EvaluationResultDetailsController {

    @Autowired
    private EvaluationResultDetailsService evaluationResultDetailService;

    @ApiOperation(value = "修改考评得分")
    @RequestMapping(value = "/update/score", method = RequestMethod.POST)
    @ResponseBody
    public AjaxMessage<String> updateEvaluateScore(@RequestBody @Valid EvaluationResultDetailsDto dto) {
        try {
            evaluationResultDetailService.updateEvaluateScore(dto);
            return new AjaxMessage<>(ResultStatus.OK);
        } catch (ServiceException e) {
            return new AjaxMessage<>(e.getStatus(), e.getMessage(), null);
        }
    }

}

