package com.jeeplus.human.enrollment.enrollmentRegistration.controller;

import com.jeeplus.common.utils.ResponseUtil;
import com.jeeplus.human.enrollment.enrollmentRegistration.domain.EnrollmentWageCard;
import com.jeeplus.human.enrollment.enrollmentRegistration.service.EnrollmentWageCardService;
import com.jeeplus.logging.annotation.ApiLog;
import com.jeeplus.logging.constant.enums.LogTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author 王强
 * @version 1.0
 * @date 2023-12-03 11:20
 */
@RestController
@Api("入职人员工资登记表信息")
@RequestMapping(value = "/enrollmentWageCard")
public class EnrollmentWageCardController {

    @Resource
    private EnrollmentWageCardService wageCardService;

    /**
     * 保存工资卡信息
     * @param wageCard
     * @return
     */
    @ApiLog(value = "保存工资卡信息", type = LogTypeEnum.SAVE)
    @PostMapping("saveWageCard")
    public ResponseEntity saveWageCard(@Valid @RequestBody EnrollmentWageCard wageCard) throws Exception {
        EnrollmentWageCard s = wageCardService.saveWageCard(wageCard);
        return ResponseUtil.newInstance().add("businessTable", "human_resources_enrollment_wage_card")
                .add("businessId", s.getId())
                .ok ("操作成功");
    }

    /**
     * 根据人员登记id查询工资卡信息
     * @param id
     * @return
     */
    @ApiOperation(value = "根据人员登记id查询工资卡信息")
    @GetMapping("/findWageCardById")
    public ResponseEntity<EnrollmentWageCard> findWageCardById(@RequestParam String id) throws Exception{
        EnrollmentWageCard dto = wageCardService.findById(id);
        return ResponseEntity.ok(dto);
    }

    /**
     * 根据人员登记id修改状态工资卡信息流程的status
     */
    @ApiOperation(value = "根据人员登记id修改状态工资卡信息流程的status")
    @PostMapping(value = "updateWageCardStatusById")
    public void updateWageCardStatusById(@RequestBody EnrollmentWageCard dto) {
        wageCardService.updateStatusById(dto);
    }
}
