1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

用户管理添加导出到文件;一些改动;删除多余页面

This commit is contained in:
2023-04-03 12:36:41 +08:00
parent 14907e3e26
commit ac885fb06b
25 changed files with 257 additions and 3128 deletions

View File

@@ -23,6 +23,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -92,6 +95,9 @@ public class UserController {
// 新增、修改弹窗时,使用该列作为主键列进行操作
String idFieldName = "id";
// 当前管理页面
String pageName = "用户管理";
// 指定前端表格显示列
JSONArray columns = FieldBuilder.create()
.add("username", "username", "账号", "",
@@ -185,6 +191,7 @@ public class UserController {
map.put("columns", columns);
map.put("fieldMapper", fieldMapper);
map.put("idFieldName", idFieldName);
map.put("pageName", pageName);
// 返回结果
return Res.success(map);
@@ -213,6 +220,7 @@ public class UserController {
}
String passwordHash = DigestUtils.sha512Hex(password);
user.setPassword(passwordHash);
user.setId(null);
userService.addUser(user);
} else {
// 修改用户
@@ -250,4 +258,28 @@ public class UserController {
boolean b = userService.deleteUser(existUser.getId());
return Res.success(b);
}
/**
* 导出用户列表
*
* @return
*/
@GetMapping("/manage/exportUserList")
@ResponseBody
public Res exportUserList(UserVO userVO) {
List<User> userList = userService.getUserList(userVO);
List<UserVO> userVOList = UserVO.convertFrom(userList);
// 当前时间
Date now = Calendar.getInstance().getTime();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss");
String dateTime = format.format(now);
HashMap<String, Object> map = new HashMap<>();
map.put("list", userVOList);
map.put("sheetName", "用户表-" + System.currentTimeMillis());
map.put("fileName", "用户表_导出时间_" + dateTime);
return Res.success(map);
}
}