package com.rongwei.bsserver.sys.controller;


import com.rongwei.bscommon.sys.service.EquWarrantyProviderService;
import com.rongwei.bscommon.sys.utils.CommonUtils;
import com.rongwei.bscommon.sys.utils.FileCheckUtil;
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
import com.rongwei.rwcommon.base.R;
import com.rongwei.rwcommon.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
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;

/**
 * <p>
 * 设备子系统——保修商 前端控制器
 * </p>
 *
 * @author zdz
 * @since 2023-12-01
 */
@RestController
@RequestMapping("/equWarrantyProvider")
public class EquWarrantyProviderController {

    @Autowired
    private EquWarrantyProviderService equWarrantyProviderService;

    @Autowired
    FileCheckUtil checkUtil;


    /**
     * 检验规则维护导入
     * @return
     */
    @RequestMapping("/importEquWarrantyProvider")
    @ResponseBody
    public R importEquWarrantyProvider(@RequestParam MultipartFile file, HttpServletRequest request) throws Exception {
        if (file == null){
            return R.error("文件解析失败");
        }
        String errorMsg = checkUtil.fileCheckDetail(file,"2a4972593c094256871805368885e2b2");
        if (StringUtils.isNotBlank(errorMsg)){
            return R.error(errorMsg);
        }
        return equWarrantyProviderService.importEquWarrantyProvider(file);
    }

}

