|
@@ -12,16 +12,20 @@ import com.yonge.cooleshow.biz.dal.service.TenantActivationCodeService;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantActivationCodeWrapper;
|
|
|
import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
+import com.yonge.toolset.utils.date.DateUtil;
|
|
|
+import com.yonge.toolset.utils.excel.POIUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-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.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
@@ -86,4 +90,36 @@ public class TenantActivationCodeController extends BaseController {
|
|
|
tenantActivationCodeService.activeById(id, sysUser.getId());
|
|
|
return succeed();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/exportOrderCode")
|
|
|
+ @ApiOperation(value = "导出订单激活码模板")
|
|
|
+ public void exportOrderCode(HttpServletResponse response, String orderNo) {
|
|
|
+
|
|
|
+
|
|
|
+ TenantActivationCodeWrapper.TenantActivationCodeQuery query =
|
|
|
+ new TenantActivationCodeWrapper.TenantActivationCodeQuery();
|
|
|
+ query.setActivationStatus(false);
|
|
|
+ query.setOrderNo(orderNo);
|
|
|
+ query.setPage(1);
|
|
|
+ query.setRows(9999);
|
|
|
+ IPage<TenantActivationCodeWrapper.TenantActivationCode> queryInfo =
|
|
|
+ tenantActivationCodeService.selectPage(QueryInfo.getPage(query), query);
|
|
|
+ List<TenantActivationCodeWrapper.TenantActivationCode> rows = queryInfo.getRecords();
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ throw new com.microsvc.toolkit.common.webportal.exception.BizException("没有可导出数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ try (OutputStream outputStream = response.getOutputStream()) {
|
|
|
+ HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"激活码"}, new String[]{
|
|
|
+ "activationCode"}, rows);
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
+ response.setHeader("Content-Disposition", "attac:wq" +
|
|
|
+ "hment;filename=active_code-" + DateUtil.getDate(new Date()) + ".xls");
|
|
|
+ workbook.write(outputStream);
|
|
|
+ outputStream.flush();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("导出激活码异常", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|