package com.jeeplus.human.practice.register.controller;

import com.alibaba.fastjson.JSON;
import com.jeeplus.common.utils.ResponseUtil;
import com.jeeplus.human.practice.register.domain.RegistrationBank;
import com.jeeplus.human.practice.register.service.RegistrationBankService;
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;
import java.util.List;

/**
 * @author 王强
 * @version 1.0
 * @date 2023-09-13 10:55
 */
@RestController
@Api("实习人员银行卡表信息")
@RequestMapping(value = "/registerBank")
public class RegisterBankController {

    @Resource
    private RegistrationBankService service;

    /**
     * 保存实习人员登记信息
     * @param registration
     * @return
     */
    @ApiLog(value = "保存实习人员银行卡信息", type = LogTypeEnum.SAVE)
    @PostMapping("save")
    public ResponseEntity save(@Valid @RequestBody RegistrationBank registration) throws Exception {
        RegistrationBank s = service.saveRegistration(registration);
        return ResponseUtil.newInstance().add("businessTable", "human_resources_practice_registration_bank")
                .add("businessId", s.getId())
                .ok ("操作成功");
    }

    /**
     * 查询
     * @param id
     * @return
     */
    @ApiOperation(value = "查询")
    @GetMapping("/findById")
    public ResponseEntity<RegistrationBank> findById(@RequestParam String id) throws Exception{
        RegistrationBank dto = service.findById(id);
        return ResponseEntity.ok(dto);
    }

    /**
     * 根据id修改状态status
     */
    @ApiOperation(value = "根据id修改状态status")
    @PostMapping(value = "updateStatusById")
    public void updateStatusById(@RequestBody RegistrationBank dto) {
        service.updateStatusById(dto);
    }
}
