package com.rongwei.bsserver.sys.controller;

import com.rongwei.bscommon.sys.service.EquFrockTestRecordService;
import com.rongwei.bscommon.sys.utils.FileCheckUtil;
import com.rongwei.rwcommon.base.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/equFrockTestRecord")
public class EquFrockTestRecordController {

    @Autowired
    private EquFrockTestRecordService equFrockTestRecordService;

    @Autowired
    FileCheckUtil checkUtil;

    @RequestMapping("/importEquFrockTestRecord")
    @ResponseBody
    public R importEquFrockTestRecord(@RequestParam MultipartFile file, HttpServletRequest request) throws Exception {
        if (file == null) {
            return R.error("文件解析失败");
        }
//        String errorMsg = checkUtil.fileCheckDetail(file,"d55d1e0878874b179a1a8dbbcd507f18");
//        if (StringUtils.isNotBlank(errorMsg)){
//            return R.error(errorMsg);
//        }
        return equFrockTestRecordService.importEquFrockTestRecord(file);
    }
}
