mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-23 11:09:29 +08:00
超级管理员角色
This commit is contained in:
39
src/main/java/xyz/playedu/api/checks/AdminRoleCheck.java
Normal file
39
src/main/java/xyz/playedu/api/checks/AdminRoleCheck.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package xyz.playedu.api.checks;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
import xyz.playedu.api.constant.BackendConstant;
|
||||
import xyz.playedu.api.domain.AdminRole;
|
||||
import xyz.playedu.api.service.AdminRoleService;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author 杭州白书科技有限公司
|
||||
* @create 2023/2/23 22:09
|
||||
*/
|
||||
@Component
|
||||
public class AdminRoleCheck implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private AdminRoleService adminRoleService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
AdminRole adminRole = adminRoleService.getBySlug(BackendConstant.SUPER_ADMIN_ROLE);
|
||||
if (adminRole != null) {//已存在超级管理权限
|
||||
return;
|
||||
}
|
||||
adminRole = new AdminRole();
|
||||
|
||||
adminRole.setName("超级管理角色");
|
||||
adminRole.setSlug(BackendConstant.SUPER_ADMIN_ROLE);
|
||||
adminRole.setCreatedAt(new Date());
|
||||
adminRole.setUpdatedAt(new Date());
|
||||
|
||||
adminRoleService.save(adminRole);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user