| | |
| | | import com.zy.asrs.wcs.common.domain.PageParam; |
| | | import com.zy.asrs.wcs.sys.entity.Role; |
| | | import com.zy.asrs.wcs.sys.service.RoleService; |
| | | import com.zy.asrs.wcs.utils.ExcelUtil; |
| | | import com.zy.asrs.wcs.utils.Utils; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | |
| | | @PreAuthorize("hasAuthority('sys:role:list')") |
| | | @PostMapping("/role/export") |
| | | public R export(@RequestBody Role role) { |
| | | return R.ok("导出成功"); |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | Workbook workbook = ExcelUtil.create(); |
| | | try { |
| | | // 设置响应头 |
| | | response.reset(); |
| | | Utils.cors(response); |
| | | response.setContentType("application/octet-stream; charset=utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("Role.xls", "UTF-8")); |
| | | workbook.write(response.getOutputStream()); |
| | | } finally { |
| | | workbook.close(); |
| | | } |
| | | } |
| | | |
| | | } |