Pārlūkot izejas kodu

fix midJourney安全码

zoujiajian 3 gadi atpakaļ
vecāks
revīzija
51e2d62f20

+ 8 - 4
netflix-service/src/main/java/com/cyksj/service/mange/group/CmsGroupServiceImpl.java

@@ -25,9 +25,11 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 import java.util.Optional;
+import java.util.stream.Collectors;
 
 /**
  * @author chan
@@ -67,9 +69,11 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
         if (sku == null) {
             throw new BusinessRuntimeException("该商品规格不存在!");
         }
-        String[] verifyCodeArray = null;
+        List<String> verifyCodeList = null;
         if (StrUtil.isNotBlank(verifyCodes)) {
-            verifyCodeArray = verifyCodes.split(",");
+            verifyCodes = verifyCodes.replaceAll("\n", "");
+            String[] verifyCodeArray = verifyCodes.split("\\*");
+            verifyCodeList = Arrays.stream(verifyCodeArray).filter(str -> StrUtil.isNotBlank(str)).map(str -> str.trim()).collect(Collectors.toList());
         }
         groups.setNum(sku.getNum());
         groups.setAvailableNum(sku.getNum());
@@ -84,8 +88,8 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
             relation.setGroupsId(groups.getId());
             relation.setStatus(GroupsRelation.Status.none);
             relation.setNum(i);
-            if (verifyCodeArray != null && verifyCodeArray.length > 0 && verifyCodeArray.length >= i) {
-                relation.setVerifyCode(verifyCodeArray[i - 1]);
+            if (verifyCodeList != null && verifyCodeList.size() > 0 && verifyCodeList.size() >= i) {
+                relation.setVerifyCode(verifyCodeList.get(i - 1));
             }
             relationMapper.insert(relation);
         }

+ 13 - 4
netflix-service/src/main/java/com/cyksj/task/Scheduler.java

@@ -92,6 +92,8 @@ public class Scheduler {
 
 	    private final AccountDoubleVerifyRecordMapper doubleVerifyRecordMapper;
 
+	    private final AccountDoubleVerifyRecordMapper accountDoubleVerifyRecordMapper;
+
 
     /**
      * 每5分钟清理过期账号
@@ -436,10 +438,17 @@ public class Scheduler {
     	//chatGPT PLUS
 		Long goodsId = 18l;
 		List<AccountDoubleVerifyRecord> doubleVerifyRecords = groupsMapper.selectGPTDoubleVerifyTrips(goodsId);
-		List<List<AccountDoubleVerifyRecord>> partition = Lists.partition(doubleVerifyRecords, 100);
-		partition.forEach(list -> {
-			log.info("批量插入待开启双重验证号数据大小:{}", list.size());
-			doubleVerifyRecordMapper.batchInsert(list);
+		doubleVerifyRecords.forEach(data -> {
+			AccountDoubleVerifyRecord exist = accountDoubleVerifyRecordMapper.selectOne(Wrappers.lambdaQuery(AccountDoubleVerifyRecord.class)
+					.eq(AccountDoubleVerifyRecord::getAccountId, data.getAccountId())
+					.eq(AccountDoubleVerifyRecord::getDeleted, true).last("limit 1"));
+			if (exist == null) {
+				if (redisService.setNx(String.format("%s-%s", data.getAccountId(), data.getId()), data.getId(), 60l)) {
+					log.info("插入待开启双重验证号账号:{}", data.getAccount());
+					data.setRemark("车队满员后三天后自动移入");
+					doubleVerifyRecordMapper.insert(data);
+				}
+			}
 		});
 	}
 }

+ 1 - 1
netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java

@@ -146,7 +146,7 @@ public class GroupRelationController {
                             .eq(AccountDoubleVerifyRecord::getAccountId, groupsRelationView.getAccountId())
                             .eq(AccountDoubleVerifyRecord::getDeleted, true).last("limit 1"));
                     if (exist == null) {
-                        if (redisService.setNx(String.format("%s-%s"), groupsRelationView.getAccountId(), groupsRelationView.getId())) {
+                        if (redisService.setNx(String.format("%s-%s", groupsRelationView.getAccountId(), groupsRelationView.getId()), groupsRelationView.getId(), 60l)) {
                             //记录
                             AccountDoubleVerifyRecord accountDoubleVerifyRecord = new AccountDoubleVerifyRecord();
                             accountDoubleVerifyRecord.setAccountId(groupsRelationView.getAccountId());

+ 5 - 3
netflix-web/src/main/java/com/cyksj/web/controller/manage/account/CmsAccountController.java

@@ -53,6 +53,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Optional;
 import java.util.Set;
@@ -366,17 +367,18 @@ public class CmsAccountController {
 	    }
 	    String verifyCodes = account.getVerifyCodes();
 	    if (StrUtil.isNotBlank(verifyCodes) && !StrUtil.equals(verifyCodes, db.getVerifyCodes())) {
-		    String[] verifyCodesArray = verifyCodes.split(",");
+		    String[] verifyCodesArray = verifyCodes.split("\\*");
+		    List<String> verifyCodeList = Arrays.stream(verifyCodesArray).filter(str -> StrUtil.isNotBlank(str)).map(str -> str.trim()).collect(Collectors.toList());
 		    List<GroupsRelationView> relationViews = beanSearcher.searchAll(GroupsRelationView.class, MapUtils.builder()
 				    .field(GroupsRelationView::getAccountId, account.getId())
 				    .onlySelect(GroupsRelationView::getId)
 				    .build());
 		    if (CollUtil.isNotEmpty(relationViews)) {
-			    for (int i = 0; i < verifyCodesArray.length; i++) {
+			    for (int i = 0; i < verifyCodeList.size(); i++) {
 				    if (i < relationViews.size()) {
 					    GroupsRelationView groupsRelationView = relationViews.get(i);
 					    groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
-							    .set(GroupsRelation::getVerifyCode, verifyCodesArray[i])
+							    .set(GroupsRelation::getVerifyCode, verifyCodeList.get(i))
 							    .eq(GroupsRelation::getId, groupsRelationView.getId()));
 				    }
 			    }