feat: support import user. (#1283)

pull/1284/head
Ryan Wang 2021-02-24 18:21:24 +08:00 committed by GitHub
parent a848b734b7
commit 867d1703ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 23 deletions

View File

@ -41,16 +41,4 @@ public class MigrateController {
}
migrateService.migrate(file, MigrateType.HALO);
}
// @PostMapping("wordpress")
// @ApiOperation("Migrate from WordPress")
// public void migrateWordPress(@RequestPart("file") MultipartFile file) {
// migrateService.migrate(file, MigrateType.WORDPRESS);
// }
//
// @PostMapping("cnblogs")
// @ApiOperation("Migrate from cnblogs")
// public void migrateCnBlogs(@RequestPart("file") MultipartFile file) {
// migrateService.migrate(file, MigrateType.CNBLOGS);
// }
}

View File

@ -11,17 +11,7 @@ public enum MigrateType implements ValueEnum<Integer> {
/**
* Halo
*/
HALO(0),
/**
* WordPress
*/
WORDPRESS(1),
/**
* cnblogs.com
*/
CNBLOGS(2);
HALO(0);
private final Integer value;

View File

@ -68,6 +68,7 @@ import run.halo.app.model.entity.SheetComment;
import run.halo.app.model.entity.SheetMeta;
import run.halo.app.model.entity.Tag;
import run.halo.app.model.entity.ThemeSetting;
import run.halo.app.model.entity.User;
import run.halo.app.model.params.PostMarkdownParam;
import run.halo.app.model.support.HaloConst;
import run.halo.app.model.vo.PostMarkdownVO;
@ -515,6 +516,14 @@ public class BackupServiceImpl implements BackupService {
themeSettingService.createInBatch(themeSettings);
eventPublisher.publishEvent(new ThemeUpdatedEvent(this));
List<User> users = Arrays.asList(mapper
.readValue(mapper.writeValueAsString(data.get("user")),
User[].class));
if (users.size() > 0) {
userService.create(users.get(0));
}
}
@Override