解决初始化EmpUser表的时候用户角色没有成功插入问题
This commit is contained in:
@@ -70,6 +70,33 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
clearTable(Log.class);
|
clearTable(Log.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AreaService areaService;
|
||||||
|
/**
|
||||||
|
* 区域、行政区划表
|
||||||
|
*/
|
||||||
|
public void initArea() throws Exception{
|
||||||
|
try{
|
||||||
|
clearTable(Area.class);
|
||||||
|
initExcelData(Area.class, new MethodCallback() {
|
||||||
|
@Override
|
||||||
|
public Object execute(Object... params) {
|
||||||
|
String action = (String)params[0];
|
||||||
|
if("save".equals(action)){
|
||||||
|
Area entity = (Area)params[1];
|
||||||
|
entity.setIsNewRecord(true);
|
||||||
|
areaService.save(entity);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new Exception(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ConfigService configService;
|
private ConfigService configService;
|
||||||
/**
|
/**
|
||||||
@@ -263,33 +290,6 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AreaService areaService;
|
|
||||||
/**
|
|
||||||
* 区域、行政区划表
|
|
||||||
*/
|
|
||||||
public void initArea() throws Exception{
|
|
||||||
try{
|
|
||||||
clearTable(Area.class);
|
|
||||||
initExcelData(Area.class, new MethodCallback() {
|
|
||||||
@Override
|
|
||||||
public Object execute(Object... params) {
|
|
||||||
String action = (String)params[0];
|
|
||||||
if("save".equals(action)){
|
|
||||||
Area entity = (Area)params[1];
|
|
||||||
entity.setIsNewRecord(true);
|
|
||||||
areaService.save(entity);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new Exception(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OfficeService officeService;
|
private OfficeService officeService;
|
||||||
/**
|
/**
|
||||||
@@ -389,7 +389,10 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
EmpUser entity = (EmpUser)params[1];
|
EmpUser entity = (EmpUser)params[1];
|
||||||
String header = (String)params[2];
|
String header = (String)params[2];
|
||||||
String val = (String)params[3];
|
String val = (String)params[3];
|
||||||
if ("employee.employeePosts".equals(header)){
|
if ("userRoleString".equals(header)){
|
||||||
|
entity.setUserRoleString(val);
|
||||||
|
return true;
|
||||||
|
}else if ("employee.employeePosts".equals(header)){
|
||||||
entity.getEmployee().setEmployeePosts(new String[]{val});
|
entity.getEmployee().setEmployeePosts(new String[]{val});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -399,6 +402,8 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
entity.setIsNewRecord(true);
|
entity.setIsNewRecord(true);
|
||||||
entity.setPassword(UserService.encryptPassword(entity.getPassword()));
|
entity.setPassword(UserService.encryptPassword(entity.getPassword()));
|
||||||
empUserService.save(entity);
|
empUserService.save(entity);
|
||||||
|
// 设置当前为管理员,否则无法保存用户角色关系
|
||||||
|
entity.setCurrentUser(new User(User.SUPER_ADMIN_CODE));
|
||||||
userService.saveAuth(entity);
|
userService.saveAuth(entity);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ public class InitCoreData extends com.jeesite.modules.sys.db.InitCoreData {
|
|||||||
public void initCoreData() throws Exception{
|
public void initCoreData() throws Exception{
|
||||||
createTable();
|
createTable();
|
||||||
initLog();
|
initLog();
|
||||||
|
initArea();
|
||||||
initConfig();
|
initConfig();
|
||||||
initModule();
|
initModule();
|
||||||
initDict();
|
initDict();
|
||||||
initRole();
|
initRole();
|
||||||
initMenu();
|
initMenu();
|
||||||
initUser();
|
initUser();
|
||||||
initArea();
|
|
||||||
initOffice();
|
initOffice();
|
||||||
initCompany();
|
initCompany();
|
||||||
initPost();
|
initPost();
|
||||||
|
|||||||
Reference in New Issue
Block a user