|
@@ -1,16 +1,18 @@
|
|
|
package com.fjhx.acc.controller;
|
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
import com.fjhx.acc.service.AccAccountService;
|
|
|
+import com.fjhx.applet.utils.OssUtil;
|
|
|
import com.fjhx.params.acc.AccountExcel;
|
|
|
-import org.springblade.core.excel.util.ExcelUtil;
|
|
|
-import org.springblade.core.tool.utils.DateUtil;
|
|
|
+import lombok.SneakyThrows;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -27,10 +29,22 @@ public class AccAccountController {
|
|
|
@Autowired
|
|
|
private AccAccountService accAccountService;
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
@GetMapping("/refreshPassword")
|
|
|
- public void refreshPassword(HttpServletResponse response) {
|
|
|
+ public R refreshPassword() {
|
|
|
List<AccountExcel> list = accAccountService.refreshPassword();
|
|
|
- ExcelUtil.export(response, "员工账号密码" + DateUtil.time(), "员工账号密码", list, AccountExcel.class);
|
|
|
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
+ EasyExcel.write(byteArrayOutputStream, AccountExcel.class).sheet("员工账号密码").doWrite(list);
|
|
|
+ byte[] bytes = byteArrayOutputStream.toByteArray();
|
|
|
+ OssUtil.uploadFile("password.xlsx", new ByteArrayInputStream(bytes));
|
|
|
+ byteArrayOutputStream.close();
|
|
|
+ return R.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/updatePassword")
|
|
|
+ public R updatePassword(@RequestBody Map<String, String> condition) {
|
|
|
+ String password = accAccountService.updatePassword(condition.get("id"));
|
|
|
+ return R.data(password);
|
|
|
}
|
|
|
|
|
|
}
|