use of run.halo.app.cache.lock.CacheLock in project halo by halo-dev.
the class InstallController method installBlog.
@PostMapping
@ResponseBody
@CacheLock
@ApiOperation("Initializes the blog")
public BaseResponse<String> installBlog(@RequestBody InstallParam installParam) {
// Validate manually
ValidationUtils.validate(installParam, CreateCheck.class);
// Check is installed
boolean isInstalled = optionService.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false);
if (isInstalled) {
throw new BadRequestException("该博客已初始化,不能再次安装!");
}
// Initialize settings
initSettings(installParam);
// Create default user
User user = createUser(installParam);
// Create default category
Category category = createDefaultCategoryIfAbsent();
// Create default post
PostDetailVO post = createDefaultPostIfAbsent(category);
// Create default sheet
createDefaultSheet();
// Create default postComment
createDefaultComment(post);
// Create default menu
createDefaultMenu();
eventPublisher.publishEvent(new LogEvent(this, user.getId().toString(), LogType.BLOG_INITIALIZED, "博客已成功初始化"));
return BaseResponse.ok("安装完成!");
}
use of run.halo.app.cache.lock.CacheLock in project halo-plugin-experimental by guqing.
the class InstallController method installBlog.
@PostMapping
@ResponseBody
@CacheLock
@ApiOperation("Initializes the blog")
public BaseResponse<String> installBlog(@RequestBody InstallParam installParam) {
// Validate manually
ValidationUtils.validate(installParam, CreateCheck.class);
// Check is installed
boolean isInstalled = optionService.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false);
if (isInstalled) {
throw new BadRequestException("该博客已初始化,不能再次安装!");
}
// Initialize settings
initSettings(installParam);
// Create default user
User user = createUser(installParam);
// Create default category
Category category = createDefaultCategoryIfAbsent();
// Create default post
PostDetailVO post = createDefaultPostIfAbsent(category);
// Create default sheet
createDefaultSheet();
// Create default postComment
createDefaultComment(post);
// Create default menu
createDefaultMenu();
eventPublisher.publishEvent(new LogEvent(this, user.getId().toString(), LogType.BLOG_INITIALIZED, "博客已成功初始化"));
return BaseResponse.ok("安装完成!");
}
use of run.halo.app.cache.lock.CacheLock in project halo by halo-dev.
the class UserServiceImpl method create.
@Override
@CacheLock
public User create(User user) {
// Check user
if (count() != 0) {
throw new BadRequestException("当前博客已有用户");
}
User createdUser = super.create(user);
eventPublisher.publishEvent(new UserUpdatedEvent(this, createdUser.getId()));
return createdUser;
}
use of run.halo.app.cache.lock.CacheLock in project halo-plugin-experimental by guqing.
the class UserServiceImpl method create.
@Override
@CacheLock
public User create(User user) {
// Check user
if (count() != 0) {
throw new BadRequestException("当前博客已有用户");
}
User createdUser = super.create(user);
eventPublisher.publishEvent(new UserUpdatedEvent(this, createdUser.getId()));
return createdUser;
}
use of run.halo.app.cache.lock.CacheLock in project halo by ruibaby.
the class InstallController method installBlog.
@PostMapping
@ResponseBody
@CacheLock
@ApiOperation("Initializes the blog")
public BaseResponse<String> installBlog(@RequestBody InstallParam installParam) {
// Validate manually
ValidationUtils.validate(installParam, CreateCheck.class);
// Check is installed
boolean isInstalled = optionService.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false);
if (isInstalled) {
throw new BadRequestException("该博客已初始化,不能再次安装!");
}
// Initialize settings
initSettings(installParam);
// Create default user
User user = createUser(installParam);
// Create default category
Category category = createDefaultCategoryIfAbsent();
// Create default post
PostDetailVO post = createDefaultPostIfAbsent(category);
// Create default sheet
createDefaultSheet();
// Create default postComment
createDefaultComment(post);
// Create default menu
createDefaultMenu();
eventPublisher.publishEvent(new LogEvent(this, user.getId().toString(), LogType.BLOG_INITIALIZED, "博客已成功初始化"));
return BaseResponse.ok("安装完成!");
}
Aggregations