@FunctionalInterface
This commit is contained in:
@@ -4,12 +4,6 @@
|
||||
*/
|
||||
package com.jeesite.modules.sys.db;
|
||||
|
||||
import org.quartz.CronTrigger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.jeesite.common.callback.MethodCallback;
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.idgen.IdGen;
|
||||
import com.jeesite.common.tests.BaseInitDataTests;
|
||||
@@ -19,30 +13,12 @@ import com.jeesite.modules.job.entity.JobEntity;
|
||||
import com.jeesite.modules.msg.task.impl.MsgLocalMergePushTask;
|
||||
import com.jeesite.modules.msg.task.impl.MsgLocalPushTask;
|
||||
import com.jeesite.modules.sys.dao.RoleMenuDao;
|
||||
import com.jeesite.modules.sys.entity.Area;
|
||||
import com.jeesite.modules.sys.entity.Company;
|
||||
import com.jeesite.modules.sys.entity.Config;
|
||||
import com.jeesite.modules.sys.entity.DictData;
|
||||
import com.jeesite.modules.sys.entity.DictType;
|
||||
import com.jeesite.modules.sys.entity.EmpUser;
|
||||
import com.jeesite.modules.sys.entity.Menu;
|
||||
import com.jeesite.modules.sys.entity.Module;
|
||||
import com.jeesite.modules.sys.entity.Office;
|
||||
import com.jeesite.modules.sys.entity.Post;
|
||||
import com.jeesite.modules.sys.entity.Role;
|
||||
import com.jeesite.modules.sys.entity.RoleMenu;
|
||||
import com.jeesite.modules.sys.entity.User;
|
||||
import com.jeesite.modules.sys.service.CompanyService;
|
||||
import com.jeesite.modules.sys.service.ConfigService;
|
||||
import com.jeesite.modules.sys.service.DictDataService;
|
||||
import com.jeesite.modules.sys.service.DictTypeService;
|
||||
import com.jeesite.modules.sys.service.EmpUserService;
|
||||
import com.jeesite.modules.sys.service.MenuService;
|
||||
import com.jeesite.modules.sys.service.ModuleService;
|
||||
import com.jeesite.modules.sys.service.OfficeService;
|
||||
import com.jeesite.modules.sys.service.PostService;
|
||||
import com.jeesite.modules.sys.service.RoleService;
|
||||
import com.jeesite.modules.sys.service.UserService;
|
||||
import com.jeesite.modules.sys.entity.*;
|
||||
import com.jeesite.modules.sys.service.*;
|
||||
import org.quartz.CronTrigger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 初始化核心表数据
|
||||
@@ -112,19 +88,16 @@ public class InitCoreData extends BaseInitDataTests {
|
||||
*/
|
||||
public void initConfig() throws Exception{
|
||||
// clearTable(Config.class);
|
||||
initExcelData(Config.class, new MethodCallback() {
|
||||
@Override
|
||||
public Object execute(Object... params) {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Config entity = (Config)params[1];
|
||||
entity.setId(IdGen.nextId());
|
||||
entity.setIsNewRecord(true);
|
||||
configService.save(entity);
|
||||
return null;
|
||||
}
|
||||
initExcelData(Config.class, params -> {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Config entity = (Config)params[1];
|
||||
entity.setId(IdGen.nextId());
|
||||
entity.setIsNewRecord(true);
|
||||
configService.save(entity);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -135,18 +108,15 @@ public class InitCoreData extends BaseInitDataTests {
|
||||
*/
|
||||
public void initModule() throws Exception{
|
||||
// clearTable(Module.class);
|
||||
initExcelData(Module.class, new MethodCallback() {
|
||||
@Override
|
||||
public Object execute(Object... params) {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Module entity = (Module)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
moduleService.save(entity);
|
||||
return null;
|
||||
}
|
||||
initExcelData(Module.class, params -> {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Module entity = (Module)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
moduleService.save(entity);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -159,34 +129,28 @@ public class InitCoreData extends BaseInitDataTests {
|
||||
*/
|
||||
public void initDict() throws Exception{
|
||||
// clearTable(DictType.class);
|
||||
initExcelData(DictType.class, new MethodCallback() {
|
||||
@Override
|
||||
public Object execute(Object... params) {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
DictType entity = (DictType)params[1];
|
||||
entity.setId(IdGen.nextId());
|
||||
entity.setIsNewRecord(true);
|
||||
dictTypeService.save(entity);
|
||||
return null;
|
||||
}
|
||||
initExcelData(DictType.class, params -> {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
DictType entity = (DictType)params[1];
|
||||
entity.setId(IdGen.nextId());
|
||||
entity.setIsNewRecord(true);
|
||||
dictTypeService.save(entity);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
// clearTable(DictData.class);
|
||||
initExcelData(DictData.class, new MethodCallback() {
|
||||
@Override
|
||||
public Object execute(Object... params) {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
DictData entity = (DictData)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
dictDataService.save(entity);
|
||||
return null;
|
||||
}
|
||||
initExcelData(DictData.class, params -> {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
DictData entity = (DictData)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
dictDataService.save(entity);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -199,18 +163,15 @@ public class InitCoreData extends BaseInitDataTests {
|
||||
// clearTable(Role.class);
|
||||
// clearTable(RoleMenu.class);
|
||||
// clearTable(RoleDataScope.class);
|
||||
initExcelData(Role.class, new MethodCallback() {
|
||||
@Override
|
||||
public Object execute(Object... params) {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Role entity = (Role)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
roleService.save(entity);
|
||||
return null;
|
||||
}
|
||||
initExcelData(Role.class, params -> {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Role entity = (Role)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
roleService.save(entity);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -224,22 +185,19 @@ public class InitCoreData extends BaseInitDataTests {
|
||||
public void initMenu() throws Exception{
|
||||
// clearTable(Menu.class);
|
||||
// clearTable(RoleMenu.class);
|
||||
initExcelData(Menu.class, new MethodCallback() {
|
||||
@Override
|
||||
public Object execute(Object... params) {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Menu entity = (Menu)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
menuService.save(entity);
|
||||
RoleMenu rm = new RoleMenu();
|
||||
rm.setMenuCode(entity.getMenuCode());
|
||||
rm.setRoleCode(Role.CORP_ADMIN_ROLE_CODE);
|
||||
roleMenuDao.insert(rm);
|
||||
return null;
|
||||
}
|
||||
initExcelData(Menu.class, params -> {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Menu entity = (Menu)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
menuService.save(entity);
|
||||
RoleMenu rm = new RoleMenu();
|
||||
rm.setMenuCode(entity.getMenuCode());
|
||||
rm.setRoleCode(Role.CORP_ADMIN_ROLE_CODE);
|
||||
roleMenuDao.insert(rm);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -252,18 +210,15 @@ public class InitCoreData extends BaseInitDataTests {
|
||||
// clearTable(User.class);
|
||||
// clearTable(UserRole.class);
|
||||
// clearTable(UserDataScope.class);
|
||||
initExcelData(User.class, new MethodCallback() {
|
||||
@Override
|
||||
public Object execute(Object... params) {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
User entity = (User)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
userService.save(entity);
|
||||
return null;
|
||||
}
|
||||
initExcelData(User.class, params -> {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
User entity = (User)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
userService.save(entity);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -274,18 +229,15 @@ public class InitCoreData extends BaseInitDataTests {
|
||||
*/
|
||||
public void initOffice() throws Exception{
|
||||
// clearTable(Office.class);
|
||||
initExcelData(Office.class, new MethodCallback() {
|
||||
@Override
|
||||
public Object execute(Object... params) {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Office entity = (Office)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
officeService.save(entity);
|
||||
return null;
|
||||
}
|
||||
initExcelData(Office.class, params -> {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Office entity = (Office)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
officeService.save(entity);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -297,18 +249,15 @@ public class InitCoreData extends BaseInitDataTests {
|
||||
public void initCompany() throws Exception{
|
||||
// clearTable(Company.class);
|
||||
// clearTable(CompanyOffice.class);
|
||||
initExcelData(Company.class, new MethodCallback() {
|
||||
@Override
|
||||
public Object execute(Object... params) {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Company entity = (Company)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
companyService.save(entity);
|
||||
return null;
|
||||
}
|
||||
initExcelData(Company.class, params -> {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Company entity = (Company)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
companyService.save(entity);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -319,18 +268,15 @@ public class InitCoreData extends BaseInitDataTests {
|
||||
*/
|
||||
public void initPost() throws Exception{
|
||||
// clearTable(Post.class);
|
||||
initExcelData(Post.class, new MethodCallback() {
|
||||
@Override
|
||||
public Object execute(Object... params) {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Post entity = (Post)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
postService.save(entity);
|
||||
return null;
|
||||
}
|
||||
initExcelData(Post.class, params -> {
|
||||
String action = (String)params[0];
|
||||
if("save".equals(action)){
|
||||
Post entity = (Post)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
postService.save(entity);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -342,36 +288,33 @@ public class InitCoreData extends BaseInitDataTests {
|
||||
public void initEmpUser() throws Exception{
|
||||
// clearTable(Employee.class);
|
||||
// clearTable(EmployeePost.class);
|
||||
initExcelData(EmpUser.class, new MethodCallback() {
|
||||
@Override
|
||||
public Object execute(Object... params) {
|
||||
String action = (String)params[0];
|
||||
if("check".equals(action)){
|
||||
User user = new User();
|
||||
user.setLoginCode("user1");
|
||||
return userService.getByLoginCode(user) == null;
|
||||
}else if("set".equals(action)){
|
||||
EmpUser entity = (EmpUser)params[1];
|
||||
String header = (String)params[2];
|
||||
String val = (String)params[3];
|
||||
if ("userRoleString".equals(header)){
|
||||
entity.setUserRoleString(val);
|
||||
return true;
|
||||
}else if ("employee.employeePosts".equals(header)){
|
||||
entity.getEmployee().setEmployeePosts(val);
|
||||
return true;
|
||||
}
|
||||
}else if("save".equals(action)){
|
||||
EmpUser entity = (EmpUser)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
empUserService.save(entity);
|
||||
// 设置当前为管理员,否则无法保存用户角色关系
|
||||
entity.setCurrentUser(new User(User.SUPER_ADMIN_CODE));
|
||||
userService.saveAuth(entity);
|
||||
return null;
|
||||
initExcelData(EmpUser.class, params -> {
|
||||
String action = (String)params[0];
|
||||
if("check".equals(action)){
|
||||
User user = new User();
|
||||
user.setLoginCode("user1");
|
||||
return userService.getByLoginCode(user) == null;
|
||||
}else if("set".equals(action)){
|
||||
EmpUser entity = (EmpUser)params[1];
|
||||
String header = (String)params[2];
|
||||
String val = (String)params[3];
|
||||
if ("userRoleString".equals(header)){
|
||||
entity.setUserRoleString(val);
|
||||
return true;
|
||||
}else if ("employee.employeePosts".equals(header)){
|
||||
entity.getEmployee().setEmployeePosts(val);
|
||||
return true;
|
||||
}
|
||||
}else if("save".equals(action)){
|
||||
EmpUser entity = (EmpUser)params[1];
|
||||
entity.setIsNewRecord(true);
|
||||
empUserService.save(entity);
|
||||
// 设置当前为管理员,否则无法保存用户角色关系
|
||||
entity.setCurrentUser(new User(User.SUPER_ADMIN_CODE));
|
||||
userService.saveAuth(entity);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user