package digital.laboratory.platform.entrustment.controller;

import digital.laboratory.platform.common.core.exception.ValidateCodeException;
import digital.laboratory.platform.common.core.util.R;
import digital.laboratory.platform.entrustment.entity.EntrustmentIdentificationMaterial;
import digital.laboratory.platform.entrustment.service.AcceptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 委托受理模块控制器
 */
@RestController
@RequestMapping("/papp/accept")
@Api(value = "AcceptController", tags = "委托受理模块控制器相关接口")
public class AcceptController {

    @Resource
    private AcceptService acceptService;

    @ApiOperation("修改受理后的检材受理编号")
    @PutMapping("/alertMaterialAcceptNo")
    @PreAuthorize("@pms.hasPermission('EntrustmentAccept')")
    public R alertMaterialAcceptNo(@RequestBody EntrustmentIdentificationMaterial material) {
        Boolean success = null;
        try {
            success = acceptService.alertMaterialAcceptNo(material);
        } catch (ValidateCodeException e) {
            e.printStackTrace();
            return R.failed(e.getMessage());
        }
        return R.ok(success);
    }

}
