27
27
import io .swagger .annotations .ApiParam ;
28
28
import lombok .AllArgsConstructor ;
29
29
import lombok .SneakyThrows ;
30
- import org .apache .commons .codec .Charsets ;
31
30
import org .springblade .core .mp .support .Condition ;
32
31
import org .springblade .core .mp .support .Query ;
33
32
import org .springblade .core .secure .BladeUser ;
33
+ import org .springblade .core .secure .annotation .PreAuth ;
34
34
import org .springblade .core .secure .utils .SecureUtil ;
35
35
import org .springblade .core .tool .api .R ;
36
36
import org .springblade .core .tool .constant .BladeConstant ;
37
+ import org .springblade .core .tool .constant .RoleConstant ;
37
38
import org .springblade .core .tool .utils .Func ;
38
39
import org .springblade .system .user .entity .User ;
39
40
import org .springblade .system .user .excel .UserExcel ;
52
53
import java .io .IOException ;
53
54
import java .io .InputStream ;
54
55
import java .net .URLEncoder ;
56
+ import java .nio .charset .StandardCharsets ;
55
57
import java .util .ArrayList ;
56
58
import java .util .List ;
57
59
import java .util .Map ;
@@ -227,6 +229,7 @@ public R importUser(MultipartFile file, Integer isCovered) {
227
229
@ GetMapping ("export-user" )
228
230
@ ApiOperationSupport (order = 13 )
229
231
@ ApiOperation (value = "导出用户" , notes = "传入user" )
232
+ @ PreAuth (RoleConstant .HAS_ROLE_ADMIN )
230
233
public void exportUser (@ ApiIgnore @ RequestParam Map <String , Object > user , BladeUser bladeUser , HttpServletResponse response ) {
231
234
QueryWrapper <User > queryWrapper = Condition .getQueryWrapper (user , User .class );
232
235
if (!SecureUtil .isAdministrator ()){
@@ -235,8 +238,8 @@ public void exportUser(@ApiIgnore @RequestParam Map<String, Object> user, BladeU
235
238
queryWrapper .lambda ().eq (User ::getIsDeleted , BladeConstant .DB_NOT_DELETED );
236
239
List <UserExcel > list = userService .exportUser (queryWrapper );
237
240
response .setContentType ("application/vnd.ms-excel" );
238
- response .setCharacterEncoding (Charsets .UTF_8 .name ());
239
- String fileName = URLEncoder .encode ("用户数据导出" , Charsets .UTF_8 .name ());
241
+ response .setCharacterEncoding (StandardCharsets .UTF_8 .name ());
242
+ String fileName = URLEncoder .encode ("用户数据导出" , StandardCharsets .UTF_8 .name ());
240
243
response .setHeader ("Content-disposition" , "attachment;filename=" + fileName + ".xlsx" );
241
244
EasyExcel .write (response .getOutputStream (), UserExcel .class ).sheet ("用户数据表" ).doWrite (list );
242
245
}
@@ -251,8 +254,8 @@ public void exportUser(@ApiIgnore @RequestParam Map<String, Object> user, BladeU
251
254
public void exportUser (HttpServletResponse response ) {
252
255
List <UserExcel > list = new ArrayList <>();
253
256
response .setContentType ("application/vnd.ms-excel" );
254
- response .setCharacterEncoding (Charsets .UTF_8 .name ());
255
- String fileName = URLEncoder .encode ("用户数据模板" , Charsets .UTF_8 .name ());
257
+ response .setCharacterEncoding (StandardCharsets .UTF_8 .name ());
258
+ String fileName = URLEncoder .encode ("用户数据模板" , StandardCharsets .UTF_8 .name ());
256
259
response .setHeader ("Content-disposition" , "attachment;filename=" + fileName + ".xlsx" );
257
260
EasyExcel .write (response .getOutputStream (), UserExcel .class ).sheet ("用户数据表" ).doWrite (list );
258
261
}
0 commit comments