|
|
@@ -6,16 +6,13 @@ import cn.reghao.tnb.account.app.model.po.UserAccount;
|
|
|
import cn.reghao.tnb.account.app.service.AccountRegistryService;
|
|
|
import cn.reghao.tnb.account.app.service.OAuthAppService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.io.FileUtils;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
|
-import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -57,43 +54,42 @@ public class UserAccountTest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 本地发布视频稿件时使用已创建但未使用的帐号
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @date 2025-07-05 23:07:787
|
|
|
+ */
|
|
|
@Test
|
|
|
public void create() {
|
|
|
- List<UserAccount> list = userAccountMapper.findAll();
|
|
|
-
|
|
|
- String basePath = "";
|
|
|
+ String basePath = "/home/reghao/disk/1/vod/1/12.个人/";
|
|
|
File baseDir = new File(basePath);
|
|
|
- File[] files = baseDir.listFiles();
|
|
|
- for (int i = 0; i < files.length; i++) {
|
|
|
- File srcDir = files[i];
|
|
|
- String dirName = srcDir.getName();
|
|
|
+ int len = baseDir.listFiles().length;
|
|
|
|
|
|
- UserAccount userAccount = list.get(i);
|
|
|
- long userId = userAccount.getUserId();
|
|
|
- //String screenName = dirName;
|
|
|
- String namePrefix = "";
|
|
|
- String screenName = String.format("%s%s", namePrefix, userId);
|
|
|
+ List<UserAccount> list = userAccountMapper.findNotUsedAccount(len);
|
|
|
+ if (list.size() != len) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- String dirName1 = String.format("%s.%s", userId, screenName);
|
|
|
- String destPath = String.format("%s/%s", srcDir.getParent(), dirName1);
|
|
|
- File destDir = new File(destPath);
|
|
|
+ File[] subDirs = baseDir.listFiles();
|
|
|
+ for (int i = 0; i < len; i++) {
|
|
|
+ long userId = list.get(i).getUserId();
|
|
|
+ File subDir = subDirs[i];
|
|
|
|
|
|
- try {
|
|
|
- renameDir(srcDir, destDir);
|
|
|
- userAccountMapper.updateUserScreenName(userId, screenName);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ /*String filename = subDir.getName();
|
|
|
+ UserAccount userAccount = userAccountMapper.findByUserId(userId);
|
|
|
+ String username = userAccount.getUsername();
|
|
|
+ String username1 = username.replace("_", "");
|
|
|
+ String screenName = filename;
|
|
|
+ userAccountMapper.updateUserProfile(userId, username1, screenName);
|
|
|
|
|
|
- private boolean renameDir(File srcDir, File destDir) throws IOException {
|
|
|
- if (srcDir.exists() && !destDir.exists()) {
|
|
|
- FileUtils.moveDirectory(srcDir, destDir);
|
|
|
- return true;
|
|
|
+ String password = "ecUgpUeIX2ub84EYPsiQ";
|
|
|
+ String salt = RandomString.getSalt(64);
|
|
|
+ String encodedPassword = passwordEncoder.encode(password + salt);
|
|
|
+ userAccountMapper.updateSetPassword(userId, encodedPassword, salt);*/
|
|
|
+ userId++;
|
|
|
}
|
|
|
-
|
|
|
- return false;
|
|
|
}
|
|
|
|
|
|
@Autowired
|