|
@@ -1,28 +1,44 @@
|
|
|
package com.yonge.cooleshow.admin.controller;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.TeacherStyleVideo;
|
|
|
-import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
|
|
|
-import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
-import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
-import com.yonge.toolset.base.page.PageInfo;
|
|
|
-import com.yonge.toolset.mybatis.support.PageUtil;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
-import io.swagger.annotations.*;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.Valid;
|
|
|
+
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-import javax.validation.Valid;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.req.TeacherSubmitReq;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.search.TeacherSearch;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TeacherStyleVideo;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.service.TeacherService;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
|
|
|
-
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
+import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
+import com.yonge.toolset.base.exception.BizException;
|
|
|
+import com.yonge.toolset.base.page.PageInfo;
|
|
|
+import com.yonge.toolset.mybatis.support.PageUtil;
|
|
|
+import com.yonge.toolset.utils.date.DateUtil;
|
|
|
+import com.yonge.toolset.utils.excel.POIUtil;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/teacher")
|
|
@@ -71,4 +87,40 @@ public class TeacherController extends BaseController {
|
|
|
public HttpResponseResult<Boolean> submit(@Valid @RequestBody TeacherSubmitReq teacherSubmitReq) {
|
|
|
return teacherService.submit(teacherSubmitReq);
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "老师列表导出")
|
|
|
+ @PostMapping("export")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('teacher/export')")
|
|
|
+ public void export(HttpServletResponse response, @RequestBody TeacherSearch queryInfo) throws IOException {
|
|
|
+ queryInfo.setPage(1);
|
|
|
+ queryInfo.setRows(49999);
|
|
|
+ List<TeacherVo> rows = teacherService.selectPage(PageUtil.getPage(queryInfo), queryInfo).getRecords();
|
|
|
+ if (rows.size() < 1) {
|
|
|
+ throw new BizException("没有可导出数据");
|
|
|
+ }
|
|
|
+ OutputStream outputStream = response.getOutputStream();
|
|
|
+ try {
|
|
|
+ HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"老师编号", "昵称", "姓名", "手机号", "老师类型",
|
|
|
+ "注册时间", "认证时间", "状态", "是否是会员", "徽章"}, new String[]{
|
|
|
+ "userId", "username", "realName", "phone", "teacherType.equals('ENTRY') ? '达人' : '游客'", "createTime", "entryAuthDate",
|
|
|
+ "lockFlag.remark", "isVip ? '是' : '否'", "tag"}, rows);
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
+ response.setHeader("Content-Disposition", "attac:wq" +
|
|
|
+ "hment;filename=老师列表-" + DateUtil.getDate(new Date()) + ".xls");
|
|
|
+
|
|
|
+ outputStream = response.getOutputStream();
|
|
|
+ workbook.write(outputStream);
|
|
|
+ outputStream.flush();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (outputStream != null) {
|
|
|
+ try {
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|