|
| 1 | +package com.inks.hb.authinfo.controller; |
| 2 | + |
| 3 | +import com.inks.hb.authinfo.pojo.AuthInfo; |
| 4 | +import com.inks.hb.authinfo.service.AuthService; |
| 5 | +import com.inks.hb.authinfo.service.AuthServiceImpl; |
| 6 | +import com.inks.hb.common.ExportExcel; |
| 7 | + |
| 8 | +import javax.servlet.annotation.WebServlet; |
| 9 | +import javax.servlet.http.HttpServlet; |
| 10 | +import javax.servlet.http.HttpServletRequest; |
| 11 | +import javax.servlet.http.HttpServletResponse; |
| 12 | +import java.sql.SQLException; |
| 13 | +import java.util.ArrayList; |
| 14 | + |
| 15 | +@WebServlet(name = "AuthInfoExcelServlet", value = "/AuthInfoExcelServlet") |
| 16 | +public class AuthInfoExcelServlet extends HttpServlet { |
| 17 | + protected void doPost(HttpServletRequest request, HttpServletResponse response) { |
| 18 | + this.doGet(request, response); |
| 19 | + } |
| 20 | + |
| 21 | + protected void doGet(HttpServletRequest request, HttpServletResponse response) { |
| 22 | + |
| 23 | + AuthService service = new AuthServiceImpl(); |
| 24 | + |
| 25 | + ArrayList<AuthInfo> infoArrayList = null; |
| 26 | + try { |
| 27 | + infoArrayList = service.query(1, service.queryAuthInfoNum()); |
| 28 | + } catch (SQLException e) { |
| 29 | + e.printStackTrace(); |
| 30 | + } |
| 31 | + |
| 32 | + String[] headers = {"权限ID", "权限名称", "可读", "可写", "可改", "可删"}; |
| 33 | + String fileName = "权限信息"; |
| 34 | + |
| 35 | + ExportExcel<AuthInfo> ee = new ExportExcel<>(); |
| 36 | + ee.exportExcel(headers, infoArrayList, fileName, response); |
| 37 | + } |
| 38 | +} |
0 commit comments