|
@@ -3,11 +3,16 @@ package com.mokamrp.privates.controller.pangu;
|
|
|
import com.aliyun.oss.OSS;
|
|
import com.aliyun.oss.OSS;
|
|
|
import com.aliyun.oss.model.PutObjectRequest;
|
|
import com.aliyun.oss.model.PutObjectRequest;
|
|
|
import com.mokamrp.privates.config.OSSConfiguration;
|
|
import com.mokamrp.privates.config.OSSConfiguration;
|
|
|
|
|
+import com.mokamrp.privates.constant.HttpMsg;
|
|
|
import com.mokamrp.privates.constant.HttpStatus;
|
|
import com.mokamrp.privates.constant.HttpStatus;
|
|
|
import com.mokamrp.privates.entity.PostBasePageHandle;
|
|
import com.mokamrp.privates.entity.PostBasePageHandle;
|
|
|
|
|
+import com.mokamrp.privates.entity.VoltaHandle;
|
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
|
import com.mokamrp.privates.entity.ResHandle;
|
|
import com.mokamrp.privates.entity.ResHandle;
|
|
|
|
|
+import com.mokamrp.privates.help.Analysis;
|
|
|
|
|
+import com.mokamrp.privates.interceptor.AuthUser;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
|
|
|
|
|
+import com.mokamrp.privates.mapper.pojo.User;
|
|
|
import com.mokamrp.privates.utils.OssFile;
|
|
import com.mokamrp.privates.utils.OssFile;
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -25,6 +30,7 @@ import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -97,5 +103,26 @@ public class FosterwxWxfriendController extends BaseController<FosterwxWxfriend>
|
|
|
ossClient.putObject(putObjectRequest);
|
|
ossClient.putObject(putObjectRequest);
|
|
|
return AjaxResult.success(ossConfiguration.getHost() + filePath);
|
|
return AjaxResult.success(ossConfiguration.getHost() + filePath);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/import")
|
|
|
|
|
+ public Object uploadFile(@RequestBody MultipartFile file, @AuthUser User authUser) {
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>(16);
|
|
|
|
|
+ Map<Integer, String> feild = new HashMap<>(5);
|
|
|
|
|
+ feild.put(0, "stationName");
|
|
|
|
|
+ feild.put(1, "wxName");
|
|
|
|
|
+ feild.put(2, "wxUsername");
|
|
|
|
|
+ List<Map<String, String>> row = new ArrayList<>();
|
|
|
|
|
+ VoltaHandle<ArrayList<Map<String, String>>> voltaRes = Analysis.analysis(file, feild);
|
|
|
|
|
+ if (voltaRes.getErr() != null) {
|
|
|
|
|
+ return AjaxResult.error(voltaRes.getErr());
|
|
|
|
|
+ }
|
|
|
|
|
+ row = voltaRes.getData();
|
|
|
|
|
+ try {
|
|
|
|
|
+ VoltaHandle<Boolean> res = fosterwxWxfriendService.importData(row, authUser);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return AjaxResult.error(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return AjaxResult.success(HttpMsg.importSuccess);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|