Selaa lähdekoodia

fix 导出双重认证账号

zoujiajian 3 vuotta sitten
vanhempi
sitoutus
d1bb84b258

+ 65 - 0
netflix-dao/src/main/java/com/cyksj/model/excel/ExcelDoubleVerifyAccountData.java

@@ -0,0 +1,65 @@
+package com.cyksj.model.excel;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.SearchBean;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/*
+ *项目名: netflix
+ *文件名: ExcelDoubleVerifyAccountData
+ *创建者: JavaZou
+ *创建时间:2023/5/24 10:59
+ */
+@Getter
+@Setter
+@SearchBean(tables = "account a inner join account_double_verify_record ar on a.id = ar.account_id and ar.deleted is true" +
+		" left join goods_don g on g.id = a.goods_id" +
+		" left join groups_trips gt on gt.id = ar.groups_id" +
+		" left join goods_don_sku sku on sku.id = gt.sku_id")
+public class ExcelDoubleVerifyAccountData {
+
+	@DbField("g.id")
+	@ExcelIgnore
+	private Long goodsId;
+
+	@DbField("g.title")
+	@ExcelProperty("平台")
+	private String title;
+
+	@DbField("sku.id")
+	@ExcelIgnore
+	private Long skuId;
+
+	@DbField("sku.spec_val")
+	@ExcelProperty("规格")
+	private String specVal;
+
+	@DbField("a.account")
+	@ExcelProperty("账号")
+	private String account;
+
+	@DbField("a.password")
+	@ExcelProperty("密码")
+	private String password;
+
+	@DbField("a.expiry_time")
+	@ExcelProperty("账号有效期")
+	private Date expiryTime;
+
+	@DbField("gt.available_num")
+	@ExcelProperty("剩余座位数")
+	private Integer availableNum;
+
+	@DbField("a.api_secret")
+	@ExcelProperty("双重验证密钥")
+	private String apiSecret;
+
+	@DbField("ar.remark")
+	@ExcelProperty("待开启原因")
+	private String reason;
+}

+ 21 - 0
netflix-dao/src/main/java/com/cyksj/model/excel/ExcelImportDoubleVerifyAccountData.java

@@ -0,0 +1,21 @@
+package com.cyksj.model.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/*
+ *项目名: netflix
+ *文件名: ExcelImportDoubleVerifyAccountData
+ *创建者: JavaZou
+ *创建时间:2023/5/24 17:42
+ */
+@Getter
+@Setter
+public class ExcelImportDoubleVerifyAccountData {
+	@ExcelProperty("账号")
+	private String account;
+
+	@ExcelProperty("双重验证密钥")
+	private String apiSecret;
+}

+ 56 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/account/CmsAccountController.java

@@ -21,7 +21,9 @@ import com.cyksj.enums.GatewayResponse;
 import com.cyksj.mapper.*;
 import com.cyksj.mapper.manage.cms.CmsUserMapper;
 import com.cyksj.model.entity.*;
+import com.cyksj.model.excel.ExcelDoubleVerifyAccountData;
 import com.cyksj.model.excel.ExcelImportAccountData;
+import com.cyksj.model.excel.ExcelImportDoubleVerifyAccountData;
 import com.cyksj.model.excel.ExcelManageAccountData;
 import com.cyksj.model.manage.request.ReqAccountIncrExpiryTime;
 import com.cyksj.model.manage.views.AccountView;
@@ -664,4 +666,58 @@ public class CmsAccountController {
 		}
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
+
+	/**
+	 * 导出双重验证账号列表
+	 */
+	@GetMapping("/doubleVerify/export")
+	public void exportDoubleVerifyAccount(HttpServletResponse response) {
+		List<ExcelDoubleVerifyAccountData> dataList = beanSearcher.searchAll(ExcelDoubleVerifyAccountData.class, MapUtils.flatBuilder(request.getParameterMap()).build());
+		EasyExcelUtils.createExcelStreamMutilByEasyExcel(response, ExcelDoubleVerifyAccountData.class, dataList, "账号待开启双重验证列表", "账号待开启双重验证列表", ExcelTypeEnum.XLS, null);
+	}
+
+
+	/**
+	 * 批量导入账号双重账号验证码
+	 */
+	@PostMapping("/doubleVerify/import")
+	public Result<String> importDoubleVerifyCode(MultipartFile file) throws Exception {
+		EasyExcel.read(file.getInputStream(), ExcelDoubleVerifyAccountData.class, new AnalysisEventListener<ExcelDoubleVerifyAccountData>() {
+			@Override
+			public void invoke(ExcelDoubleVerifyAccountData data, AnalysisContext analysisContext) {
+				String account = data.getAccount();
+				String apiSecret = data.getApiSecret();
+				if (StrUtil.isBlank(account) || StrUtil.isBlank(apiSecret)) {
+					return;
+				}
+				Account ac = accountService.getOne(Wrappers.lambdaQuery(Account.class)
+						.in(Account::getGoodsId, List.of(18, 26))
+						.eq(Account::getAccount, account.trim())
+						.eq(Account::getApiSecret, "")
+						.last("limit 1"));
+				if (ac == null) return;
+				ac.setApiSecret(apiSecret.trim());
+				accountService.updateById(ac);
+
+				doubleVerifyRecordMapper.update(null, Wrappers.lambdaUpdate(AccountDoubleVerifyRecord.class)
+						.set(AccountDoubleVerifyRecord::getGroupsId, false)
+						.eq(AccountDoubleVerifyRecord::getAccountId, ac.getId())
+						.eq(AccountDoubleVerifyRecord::getDeleted, true));
+			}
+
+			@Override
+			public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+
+			}
+		}).sheet().doRead();
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 双重认证导入模板
+	 */
+	@GetMapping("/export/doubleVerify/template")
+	public void exportDoubleVerifyAccountTemplate(HttpServletResponse response) {
+		EasyExcelUtils.createTemplateExcel(response, ExcelImportDoubleVerifyAccountData.class, "账号双重认证码导入模板", "账号双重认证码导入模板", ExcelTypeEnum.XLS, null);
+	}
 }