Просмотр исходного кода

fix 账号密码、过期时间

zoujiajian 3 лет назад
Родитель
Сommit
bd560bfa39

+ 39 - 34
netflix-web/src/main/java/com/cyksj/web/controller/manage/account/CmsAccountController.java

@@ -120,40 +120,45 @@ public class CmsAccountController {
         EasyExcelUtils.createTemplateExcel(response, ExcelAccountTemplateData.class, "账号导入模板", "账号导入模板", ExcelTypeEnum.XLSX, null);
     }
 
-    /**
-     * 导入账号,修改密码
-     */
-    @PostMapping("/import/account")
-    public Result<String> importAccount(Long goodsId, MultipartFile file) throws Exception {
-        EasyExcel.read(file.getInputStream(), ExcelAccountTemplateData.class, new AnalysisEventListener<ExcelAccountTemplateData>() {
-            @SneakyThrows
-            @Override
-            public void invoke(ExcelAccountTemplateData data, AnalysisContext analysisContext) {
-                if (StrUtil.isNotBlank(data.getAccount())) {
-                    Account account = accountService.getOne(Wrappers.lambdaQuery(Account.class)
-                            .eq(Account::getGoodsId, goodsId)
-                            .eq(Account::getAccount, data.getAccount()));
-                    if (account != null) {
-                        if (StrUtil.isNotBlank(data.getPassword()) && !data.getPassword().equals(account.getPassword())) {
-                            account.setPassword(data.getPassword());
-                            if (data.getExpiryTime() != null) {
-                                account.setExpiryTime(data.getExpiryTime());
-                            }
-                            accountService.updateById(account);
-                            //发放模板消息
-                            accountService.sendAccountTemplateMsg(account);
-                        }
-                    }
-                }
-            }
-
-            @Override
-            public void doAfterAllAnalysed(AnalysisContext analysisContext) {
-
-            }
-        }).sheet().doRead();
-        return GatewayResponse.SUCCESS.newBuilder().toResult("导入成功");
-    }
+	/**
+	 * 导入账号,修改密码
+	 */
+	@PostMapping("/import/account")
+	public Result<String> importAccount(Long goodsId, MultipartFile file) throws Exception {
+		EasyExcel.read(file.getInputStream(), ExcelAccountTemplateData.class, new AnalysisEventListener<ExcelAccountTemplateData>() {
+			@SneakyThrows
+			@Override
+			public void invoke(ExcelAccountTemplateData data, AnalysisContext analysisContext) {
+				if (StrUtil.isNotBlank(data.getAccount())) {
+					Account account = accountService.getOne(Wrappers.lambdaQuery(Account.class)
+							.eq(Account::getGoodsId, goodsId)
+							.eq(Account::getAccount, data.getAccount()));
+					Boolean flag = false;
+					if (account != null) {
+						if (data.getExpiryTime() != null) {
+							account.setExpiryTime(data.getExpiryTime());
+							flag = true;
+						}
+						if (StrUtil.isNotBlank(data.getPassword()) && !data.getPassword().equals(account.getPassword())) {
+							account.setPassword(data.getPassword());
+							flag = true;
+							//发放模板消息
+							accountService.sendAccountTemplateMsg(account);
+						}
+						if (flag) {
+							accountService.updateById(account);
+						}
+					}
+				}
+			}
+
+			@Override
+			public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+
+			}
+		}).sheet().doRead();
+		return GatewayResponse.SUCCESS.newBuilder().toResult("导入成功");
+	}
 
     @PostMapping("/post")
     public Result<String> add(@RequestBody Account account){