init data sysout to logger
This commit is contained in:
@@ -76,25 +76,20 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
* 区域、行政区划表
|
* 区域、行政区划表
|
||||||
*/
|
*/
|
||||||
public void initArea() throws Exception{
|
public void initArea() throws Exception{
|
||||||
try{
|
clearTable(Area.class);
|
||||||
clearTable(Area.class);
|
initExcelData(Area.class, new MethodCallback() {
|
||||||
initExcelData(Area.class, new MethodCallback() {
|
@Override
|
||||||
@Override
|
public Object execute(Object... params) {
|
||||||
public Object execute(Object... params) {
|
String action = (String)params[0];
|
||||||
String action = (String)params[0];
|
if("save".equals(action)){
|
||||||
if("save".equals(action)){
|
Area entity = (Area)params[1];
|
||||||
Area entity = (Area)params[1];
|
entity.setIsNewRecord(true);
|
||||||
entity.setIsNewRecord(true);
|
areaService.save(entity);
|
||||||
areaService.save(entity);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}catch(Exception e){
|
}
|
||||||
e.printStackTrace();
|
});
|
||||||
throw new Exception(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -103,26 +98,21 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
* 参数配置表
|
* 参数配置表
|
||||||
*/
|
*/
|
||||||
public void initConfig() throws Exception{
|
public void initConfig() throws Exception{
|
||||||
try{
|
clearTable(Config.class);
|
||||||
clearTable(Config.class);
|
initExcelData(Config.class, new MethodCallback() {
|
||||||
initExcelData(Config.class, new MethodCallback() {
|
@Override
|
||||||
@Override
|
public Object execute(Object... params) {
|
||||||
public Object execute(Object... params) {
|
String action = (String)params[0];
|
||||||
String action = (String)params[0];
|
if("save".equals(action)){
|
||||||
if("save".equals(action)){
|
Config entity = (Config)params[1];
|
||||||
Config entity = (Config)params[1];
|
entity.setId(IdGen.nextId());
|
||||||
entity.setId(IdGen.nextId());
|
entity.setIsNewRecord(true);
|
||||||
entity.setIsNewRecord(true);
|
configService.save(entity);
|
||||||
configService.save(entity);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}catch(Exception e){
|
}
|
||||||
e.printStackTrace();
|
});
|
||||||
throw new Exception(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -131,25 +121,20 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
* 系统模块表
|
* 系统模块表
|
||||||
*/
|
*/
|
||||||
public void initModule() throws Exception{
|
public void initModule() throws Exception{
|
||||||
try{
|
clearTable(Module.class);
|
||||||
clearTable(Module.class);
|
initExcelData(Module.class, new MethodCallback() {
|
||||||
initExcelData(Module.class, new MethodCallback() {
|
@Override
|
||||||
@Override
|
public Object execute(Object... params) {
|
||||||
public Object execute(Object... params) {
|
String action = (String)params[0];
|
||||||
String action = (String)params[0];
|
if("save".equals(action)){
|
||||||
if("save".equals(action)){
|
Module entity = (Module)params[1];
|
||||||
Module entity = (Module)params[1];
|
entity.setIsNewRecord(true);
|
||||||
entity.setIsNewRecord(true);
|
moduleService.save(entity);
|
||||||
moduleService.save(entity);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}catch(Exception e){
|
}
|
||||||
e.printStackTrace();
|
});
|
||||||
throw new Exception(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -160,41 +145,36 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
* 系统字典、用户字典表
|
* 系统字典、用户字典表
|
||||||
*/
|
*/
|
||||||
public void initDict() throws Exception{
|
public void initDict() throws Exception{
|
||||||
try{
|
clearTable(DictType.class);
|
||||||
clearTable(DictType.class);
|
initExcelData(DictType.class, new MethodCallback() {
|
||||||
initExcelData(DictType.class, new MethodCallback() {
|
@Override
|
||||||
@Override
|
public Object execute(Object... params) {
|
||||||
public Object execute(Object... params) {
|
String action = (String)params[0];
|
||||||
String action = (String)params[0];
|
if("save".equals(action)){
|
||||||
if("save".equals(action)){
|
DictType entity = (DictType)params[1];
|
||||||
DictType entity = (DictType)params[1];
|
entity.setId(IdGen.nextId());
|
||||||
entity.setId(IdGen.nextId());
|
entity.setIsNewRecord(true);
|
||||||
entity.setIsNewRecord(true);
|
dictTypeService.save(entity);
|
||||||
dictTypeService.save(entity);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
clearTable(DictData.class);
|
clearTable(DictData.class);
|
||||||
initExcelData(DictData.class, new MethodCallback() {
|
initExcelData(DictData.class, new MethodCallback() {
|
||||||
@Override
|
@Override
|
||||||
public Object execute(Object... params) {
|
public Object execute(Object... params) {
|
||||||
String action = (String)params[0];
|
String action = (String)params[0];
|
||||||
if("save".equals(action)){
|
if("save".equals(action)){
|
||||||
DictData entity = (DictData)params[1];
|
DictData entity = (DictData)params[1];
|
||||||
entity.setIsNewRecord(true);
|
entity.setIsNewRecord(true);
|
||||||
dictDataService.save(entity);
|
dictDataService.save(entity);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}catch(Exception e){
|
}
|
||||||
e.printStackTrace();
|
});
|
||||||
throw new Exception(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -203,27 +183,22 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
* 角色表
|
* 角色表
|
||||||
*/
|
*/
|
||||||
public void initRole() throws Exception{
|
public void initRole() throws Exception{
|
||||||
try{
|
clearTable(Role.class);
|
||||||
clearTable(Role.class);
|
clearTable(RoleMenu.class);
|
||||||
clearTable(RoleMenu.class);
|
clearTable(RoleDataScope.class);
|
||||||
clearTable(RoleDataScope.class);
|
initExcelData(Role.class, new MethodCallback() {
|
||||||
initExcelData(Role.class, new MethodCallback() {
|
@Override
|
||||||
@Override
|
public Object execute(Object... params) {
|
||||||
public Object execute(Object... params) {
|
String action = (String)params[0];
|
||||||
String action = (String)params[0];
|
if("save".equals(action)){
|
||||||
if("save".equals(action)){
|
Role entity = (Role)params[1];
|
||||||
Role entity = (Role)params[1];
|
entity.setIsNewRecord(true);
|
||||||
entity.setIsNewRecord(true);
|
roleService.save(entity);
|
||||||
roleService.save(entity);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}catch(Exception e){
|
}
|
||||||
e.printStackTrace();
|
});
|
||||||
throw new Exception(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -234,30 +209,25 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
* 菜单表
|
* 菜单表
|
||||||
*/
|
*/
|
||||||
public void initMenu() throws Exception{
|
public void initMenu() throws Exception{
|
||||||
try{
|
clearTable(Menu.class);
|
||||||
clearTable(Menu.class);
|
clearTable(RoleMenu.class);
|
||||||
clearTable(RoleMenu.class);
|
initExcelData(Menu.class, new MethodCallback() {
|
||||||
initExcelData(Menu.class, new MethodCallback() {
|
@Override
|
||||||
@Override
|
public Object execute(Object... params) {
|
||||||
public Object execute(Object... params) {
|
String action = (String)params[0];
|
||||||
String action = (String)params[0];
|
if("save".equals(action)){
|
||||||
if("save".equals(action)){
|
Menu entity = (Menu)params[1];
|
||||||
Menu entity = (Menu)params[1];
|
entity.setIsNewRecord(true);
|
||||||
entity.setIsNewRecord(true);
|
menuService.save(entity);
|
||||||
menuService.save(entity);
|
RoleMenu rm = new RoleMenu();
|
||||||
RoleMenu rm = new RoleMenu();
|
rm.setMenuCode(entity.getMenuCode());
|
||||||
rm.setMenuCode(entity.getMenuCode());
|
rm.setRoleCode(Role.CORP_ADMIN_ROLE_CODE);
|
||||||
rm.setRoleCode(Role.CORP_ADMIN_ROLE_CODE);
|
roleMenuDao.insert(rm);
|
||||||
roleMenuDao.insert(rm);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}catch(Exception e){
|
}
|
||||||
e.printStackTrace();
|
});
|
||||||
throw new Exception(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -266,28 +236,23 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
* 用户表
|
* 用户表
|
||||||
*/
|
*/
|
||||||
public void initUser() throws Exception{
|
public void initUser() throws Exception{
|
||||||
try{
|
clearTable(User.class);
|
||||||
clearTable(User.class);
|
clearTable(UserRole.class);
|
||||||
clearTable(UserRole.class);
|
clearTable(UserDataScope.class);
|
||||||
clearTable(UserDataScope.class);
|
initExcelData(User.class, new MethodCallback() {
|
||||||
initExcelData(User.class, new MethodCallback() {
|
@Override
|
||||||
@Override
|
public Object execute(Object... params) {
|
||||||
public Object execute(Object... params) {
|
String action = (String)params[0];
|
||||||
String action = (String)params[0];
|
if("save".equals(action)){
|
||||||
if("save".equals(action)){
|
User entity = (User)params[1];
|
||||||
User entity = (User)params[1];
|
entity.setIsNewRecord(true);
|
||||||
entity.setIsNewRecord(true);
|
entity.setPassword(UserService.encryptPassword(entity.getPassword()));
|
||||||
entity.setPassword(UserService.encryptPassword(entity.getPassword()));
|
userService.save(entity);
|
||||||
userService.save(entity);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}catch(Exception e){
|
}
|
||||||
e.printStackTrace();
|
});
|
||||||
throw new Exception(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -296,25 +261,20 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
* 组织机构、部门表
|
* 组织机构、部门表
|
||||||
*/
|
*/
|
||||||
public void initOffice() throws Exception{
|
public void initOffice() throws Exception{
|
||||||
try{
|
clearTable(Office.class);
|
||||||
clearTable(Office.class);
|
initExcelData(Office.class, new MethodCallback() {
|
||||||
initExcelData(Office.class, new MethodCallback() {
|
@Override
|
||||||
@Override
|
public Object execute(Object... params) {
|
||||||
public Object execute(Object... params) {
|
String action = (String)params[0];
|
||||||
String action = (String)params[0];
|
if("save".equals(action)){
|
||||||
if("save".equals(action)){
|
Office entity = (Office)params[1];
|
||||||
Office entity = (Office)params[1];
|
entity.setIsNewRecord(true);
|
||||||
entity.setIsNewRecord(true);
|
officeService.save(entity);
|
||||||
officeService.save(entity);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}catch(Exception e){
|
}
|
||||||
e.printStackTrace();
|
});
|
||||||
throw new Exception(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -323,26 +283,21 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
* 公司表
|
* 公司表
|
||||||
*/
|
*/
|
||||||
public void initCompany() throws Exception{
|
public void initCompany() throws Exception{
|
||||||
try{
|
clearTable(Company.class);
|
||||||
clearTable(Company.class);
|
clearTable(CompanyOffice.class);
|
||||||
clearTable(CompanyOffice.class);
|
initExcelData(Company.class, new MethodCallback() {
|
||||||
initExcelData(Company.class, new MethodCallback() {
|
@Override
|
||||||
@Override
|
public Object execute(Object... params) {
|
||||||
public Object execute(Object... params) {
|
String action = (String)params[0];
|
||||||
String action = (String)params[0];
|
if("save".equals(action)){
|
||||||
if("save".equals(action)){
|
Company entity = (Company)params[1];
|
||||||
Company entity = (Company)params[1];
|
entity.setIsNewRecord(true);
|
||||||
entity.setIsNewRecord(true);
|
companyService.save(entity);
|
||||||
companyService.save(entity);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}catch(Exception e){
|
}
|
||||||
e.printStackTrace();
|
});
|
||||||
throw new Exception(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -351,25 +306,20 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
* 岗位表
|
* 岗位表
|
||||||
*/
|
*/
|
||||||
public void initPost() throws Exception{
|
public void initPost() throws Exception{
|
||||||
try{
|
clearTable(Post.class);
|
||||||
clearTable(Post.class);
|
initExcelData(Post.class, new MethodCallback() {
|
||||||
initExcelData(Post.class, new MethodCallback() {
|
@Override
|
||||||
@Override
|
public Object execute(Object... params) {
|
||||||
public Object execute(Object... params) {
|
String action = (String)params[0];
|
||||||
String action = (String)params[0];
|
if("save".equals(action)){
|
||||||
if("save".equals(action)){
|
Post entity = (Post)params[1];
|
||||||
Post entity = (Post)params[1];
|
entity.setIsNewRecord(true);
|
||||||
entity.setIsNewRecord(true);
|
postService.save(entity);
|
||||||
postService.save(entity);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}catch(Exception e){
|
}
|
||||||
e.printStackTrace();
|
});
|
||||||
throw new Exception(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -378,41 +328,36 @@ public class InitCoreData extends BaseInitDataTests {
|
|||||||
* 员工、用户表
|
* 员工、用户表
|
||||||
*/
|
*/
|
||||||
public void initEmpUser() throws Exception{
|
public void initEmpUser() throws Exception{
|
||||||
try{
|
clearTable(Employee.class);
|
||||||
clearTable(Employee.class);
|
clearTable(EmployeePost.class);
|
||||||
clearTable(EmployeePost.class);
|
initExcelData(EmpUser.class, new MethodCallback() {
|
||||||
initExcelData(EmpUser.class, new MethodCallback() {
|
@Override
|
||||||
@Override
|
public Object execute(Object... params) {
|
||||||
public Object execute(Object... params) {
|
String action = (String)params[0];
|
||||||
String action = (String)params[0];
|
if("set".equals(action)){
|
||||||
if("set".equals(action)){
|
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 ("userRoleString".equals(header)){
|
||||||
if ("userRoleString".equals(header)){
|
entity.setUserRoleString(val);
|
||||||
entity.setUserRoleString(val);
|
return true;
|
||||||
return true;
|
}else if ("employee.employeePosts".equals(header)){
|
||||||
}else if ("employee.employeePosts".equals(header)){
|
entity.getEmployee().setEmployeePosts(new String[]{val});
|
||||||
entity.getEmployee().setEmployeePosts(new String[]{val});
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if("save".equals(action)){
|
|
||||||
EmpUser entity = (EmpUser)params[1];
|
|
||||||
entity.setIsNewRecord(true);
|
|
||||||
entity.setPassword(UserService.encryptPassword(entity.getPassword()));
|
|
||||||
empUserService.save(entity);
|
|
||||||
// 设置当前为管理员,否则无法保存用户角色关系
|
|
||||||
entity.setCurrentUser(new User(User.SUPER_ADMIN_CODE));
|
|
||||||
userService.saveAuth(entity);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if("save".equals(action)){
|
||||||
|
EmpUser entity = (EmpUser)params[1];
|
||||||
|
entity.setIsNewRecord(true);
|
||||||
|
entity.setPassword(UserService.encryptPassword(entity.getPassword()));
|
||||||
|
empUserService.save(entity);
|
||||||
|
// 设置当前为管理员,否则无法保存用户角色关系
|
||||||
|
entity.setCurrentUser(new User(User.SUPER_ADMIN_CODE));
|
||||||
|
userService.saveAuth(entity);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}catch(Exception e){
|
}
|
||||||
e.printStackTrace();
|
});
|
||||||
throw new Exception(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,6 @@ echo.
|
|||||||
cd %~dp0
|
cd %~dp0
|
||||||
|
|
||||||
cd ../
|
cd ../
|
||||||
call mvn test -Dtest=com.jeesite.test.InitCoreData,com.jeesite.test.InitGenData
|
call mvn test -Dtest=com.jeesite.test.InitCoreData,com.jeesite.test.InitGenData -U
|
||||||
|
|
||||||
pause
|
pause
|
||||||
@@ -16,4 +16,4 @@ echo "\n[信息] 您真的确认继续吗?否则请关闭窗口。(1)\n"
|
|||||||
read -s -n1 -p "请按任意键继续 ... "
|
read -s -n1 -p "请按任意键继续 ... "
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
mvn test -Dtest=com.jeesite.test.InitCoreData,com.jeesite.test.InitGenData
|
mvn test -Dtest=com.jeesite.test.InitCoreData,com.jeesite.test.InitGenData -U
|
||||||
|
|||||||
Reference in New Issue
Block a user