|
|
@@ -1,26 +1,29 @@
|
|
|
package com.sckw.example.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
+import com.sckw.example.dao.KwsDeptDao;
|
|
|
+import com.sckw.example.model.KwsDept;
|
|
|
import com.sckw.example.model.vo.SysUserVo;
|
|
|
import com.sckw.example.service.ExcelExportService;
|
|
|
import com.sckw.excel.config.easyexcel.ExcelImportListener;
|
|
|
import com.sckw.excel.config.easyexcel.RequestHolder;
|
|
|
import com.sckw.excel.utils.DateUtil;
|
|
|
import com.sckw.excel.utils.ExcelUtil;
|
|
|
+import com.sckw.file.api.dubbo.FileApiDubboService;
|
|
|
+import io.seata.spring.annotation.GlobalTransactional;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.hibernate.validator.constraints.Range;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.File;
|
|
|
@@ -34,7 +37,13 @@ import java.util.List;
|
|
|
public class ExcelExportController {
|
|
|
|
|
|
@Autowired
|
|
|
- public ExcelExportService excelExportService;
|
|
|
+ ExcelExportService excelExportService;
|
|
|
+
|
|
|
+ @DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
+ FileApiDubboService fileApiDubboService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ KwsDeptDao kwsDeptDao;
|
|
|
|
|
|
/**
|
|
|
* 模板下载
|
|
|
@@ -112,4 +121,22 @@ public class ExcelExportController {
|
|
|
ExcelImportListener importListener = new ExcelImportListener();
|
|
|
return excelExportService.importExcel(file, importListener);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分布式事务验证
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GlobalTransactional
|
|
|
+ @RequestMapping(value = "globalTransactionalDemo",method = RequestMethod.GET)
|
|
|
+ public HttpResult globalTransactionalDemo() {
|
|
|
+ //auth 服务 调用example实现的dubbo接口
|
|
|
+ KwsDept kwsDept = new KwsDept();
|
|
|
+ kwsDept.setName("张三");
|
|
|
+ kwsDept.setAccount("张三");
|
|
|
+ kwsDept.setParentIds("2");
|
|
|
+ int i= kwsDeptDao.insert(kwsDept);
|
|
|
+ HttpResult result= fileApiDubboService.selectAll();
|
|
|
+ log.info(JSONObject.toJSONString(result));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|