| | |
| | | import cn.afterturn.easypoi.excel.ExcelImportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import cn.afterturn.easypoi.excel.entity.ImportParams; |
| | | import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
| | | import cn.hutool.core.io.resource.ClassPathResource; |
| | | import cn.hutool.json.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.xiaopeng.api.model.account.SysUser; |
| | |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.common.log.annotation.Log; |
| | | import com.xiaopeng.common.log.enums.BusinessType; |
| | | import com.xiaopeng.operation.dto.InvitationAddDto; |
| | | import com.xiaopeng.operation.exportExcle.XpInvitationCodeExportExcel; |
| | | import com.xiaopeng.operation.exportExcle.XpWhitelistExportExcel; |
| | | import com.xiaopeng.operation.importExcel.InvitationCodeImportExcel; |
| | |
| | | /** |
| | | * 生成邀请码 |
| | | */ |
| | | @PutMapping("/api/v1/invitation/add") |
| | | @PostMapping("/api/v1/invitation/add") |
| | | @ResponseBody |
| | | @ApiOperation(value = "生成邀请码") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "手机号 多个逗号隔开", name = "phones", dataType = "String", required = true) |
| | | }) |
| | | @Transactional |
| | | public R add(@RequestParam("phones") String phones){ |
| | | return xpInvitationCodeService.add(phones); |
| | | public R add(@RequestBody InvitationAddDto dto){ |
| | | return xpInvitationCodeService.add(dto.getPhones()); |
| | | } |
| | | /** |
| | | * 解绑 |
| | |
| | | xpInvitationCodeService.update(xpInvitationCodeUpdateWrapper); |
| | | return R.ok(); |
| | | } |
| | | @ApiOperation(value = "点位导入模板下载") |
| | | @ApiOperation(value = "邀请码导入模板下载") |
| | | @GetMapping("/api/v1/invitation/import-template") |
| | | public void importTemplate() { |
| | | List<InvitationCodeImportExcel> invitationCodeImportExcels = new ArrayList<>(); |
| | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), InvitationCodeImportExcel.class, invitationCodeImportExcels); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | ServletOutputStream outputStream = null; |
| | | //1.获取excel模板 |
| | | ClassPathResource classPathResource = new ClassPathResource("template/邀请码导入模板.xlsx"); |
| | | TemplateExportParams params = new TemplateExportParams(classPathResource.getPath()); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | try { |
| | | String fileName = URLEncoder.encode("邀请码导入模板.xlsx", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setHeader("content-Type", "application/vnd.ms-excel"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | response.setHeader("Content-dispodition", "attachment;filename=" + fileName); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | System.out.println("邀请码导入模板下载失败!"); |
| | |
| | | @ApiOperation(value = "邀请码导入") |
| | | @PostMapping("/base/v1/invitation/importExcel") |
| | | public R<String> importExcel(@RequestPart("file") MultipartFile file) { |
| | | System.out.println("文件名 = " + file.getOriginalFilename()); |
| | | System.out.println("文件大小 = " + file.getSize()); |
| | | System.out.println("ContentType = " + file.getContentType()); |
| | | ImportParams params = new ImportParams(); |
| | | params.setHeadRows(1); //表头行数 |
| | | InputStream inputStream = null; |
| | |
| | | List<XpInvitationCodeExportExcel> xpWhitelistExportExcels = new ArrayList<>(); |
| | | for (XpInvitationCode xpInvitationCode : list) { |
| | | XpInvitationCodeExportExcel xpWhitelistExportExcel = new XpInvitationCodeExportExcel(); |
| | | xpWhitelistExportExcel.setId(xpInvitationCode.getId()); |
| | | // xpWhitelistExportExcel.setId(xpInvitationCode.getId()); |
| | | xpWhitelistExportExcel.setBind_account(xpInvitationCode.getBindAccount()); |
| | | xpWhitelistExportExcel.setInvitationCode(xpInvitationCode.getInvitationCode()); |
| | | LocalDateTime createTime = xpInvitationCode.getCreateTime(); |