初始化方法添加关联表清理

This commit is contained in:
thinkgem
2018-01-06 10:25:44 +08:00
parent b6a299d316
commit a3c4457cef
2 changed files with 442 additions and 395 deletions

View File

@@ -13,19 +13,24 @@ import com.jeesite.common.tests.BaseInitDataTests;
import com.jeesite.modules.sys.dao.RoleMenuDao; import com.jeesite.modules.sys.dao.RoleMenuDao;
import com.jeesite.modules.sys.entity.Area; import com.jeesite.modules.sys.entity.Area;
import com.jeesite.modules.sys.entity.Company; import com.jeesite.modules.sys.entity.Company;
import com.jeesite.modules.sys.entity.CompanyOffice;
import com.jeesite.modules.sys.entity.Config; import com.jeesite.modules.sys.entity.Config;
import com.jeesite.modules.sys.entity.DictData; import com.jeesite.modules.sys.entity.DictData;
import com.jeesite.modules.sys.entity.DictType; import com.jeesite.modules.sys.entity.DictType;
import com.jeesite.modules.sys.entity.EmpUser; import com.jeesite.modules.sys.entity.EmpUser;
import com.jeesite.modules.sys.entity.Employee; import com.jeesite.modules.sys.entity.Employee;
import com.jeesite.modules.sys.entity.EmployeePost;
import com.jeesite.modules.sys.entity.Log; import com.jeesite.modules.sys.entity.Log;
import com.jeesite.modules.sys.entity.Menu; import com.jeesite.modules.sys.entity.Menu;
import com.jeesite.modules.sys.entity.Module; import com.jeesite.modules.sys.entity.Module;
import com.jeesite.modules.sys.entity.Office; import com.jeesite.modules.sys.entity.Office;
import com.jeesite.modules.sys.entity.Post; import com.jeesite.modules.sys.entity.Post;
import com.jeesite.modules.sys.entity.Role; import com.jeesite.modules.sys.entity.Role;
import com.jeesite.modules.sys.entity.RoleDataScope;
import com.jeesite.modules.sys.entity.RoleMenu; import com.jeesite.modules.sys.entity.RoleMenu;
import com.jeesite.modules.sys.entity.User; import com.jeesite.modules.sys.entity.User;
import com.jeesite.modules.sys.entity.UserDataScope;
import com.jeesite.modules.sys.entity.UserRole;
import com.jeesite.modules.sys.service.AreaService; import com.jeesite.modules.sys.service.AreaService;
import com.jeesite.modules.sys.service.CompanyService; import com.jeesite.modules.sys.service.CompanyService;
import com.jeesite.modules.sys.service.ConfigService; import com.jeesite.modules.sys.service.ConfigService;
@@ -54,12 +59,18 @@ public class InitCoreData extends BaseInitDataTests {
InitCoreData.class.getSimpleName() + ".xlsx").getFile()); InitCoreData.class.getSimpleName() + ".xlsx").getFile());
} }
/**
* 清理日志表
*/
public void initLog() throws Exception{ public void initLog() throws Exception{
clearTable(new Log()); clearTable(new Log());
} }
@Autowired @Autowired
private ConfigService configService; private ConfigService configService;
/**
* 参数配置表
*/
public void initConfig() throws Exception{ public void initConfig() throws Exception{
try{ try{
clearTable(new Config()); clearTable(new Config());
@@ -85,6 +96,9 @@ public class InitCoreData extends BaseInitDataTests {
@Autowired @Autowired
private ModuleService moduleService; private ModuleService moduleService;
/**
* 系统模块表
*/
public void initModule() throws Exception{ public void initModule() throws Exception{
try{ try{
clearTable(new Module()); clearTable(new Module());
@@ -111,6 +125,9 @@ public class InitCoreData extends BaseInitDataTests {
private DictTypeService dictTypeService; private DictTypeService dictTypeService;
@Autowired @Autowired
private DictDataService dictDataService; private DictDataService dictDataService;
/**
* 系统字典、用户字典表
*/
public void initDict() throws Exception{ public void initDict() throws Exception{
try{ try{
clearTable(new DictType()); clearTable(new DictType());
@@ -151,9 +168,14 @@ public class InitCoreData extends BaseInitDataTests {
@Autowired @Autowired
private RoleService roleService; private RoleService roleService;
/**
* 角色表
*/
public void initRole() throws Exception{ public void initRole() throws Exception{
try{ try{
clearTable(new Role()); clearTable(new Role());
clearTable(new RoleMenu());
clearTable(new RoleDataScope());
initExcelData(Role.class, new MethodCallback() { initExcelData(Role.class, new MethodCallback() {
@Override @Override
public Object execute(Object... params) { public Object execute(Object... params) {
@@ -177,6 +199,9 @@ public class InitCoreData extends BaseInitDataTests {
private MenuService menuService; private MenuService menuService;
@Autowired @Autowired
private RoleMenuDao roleMenuDao; private RoleMenuDao roleMenuDao;
/**
* 菜单表
*/
public void initMenu() throws Exception{ public void initMenu() throws Exception{
try{ try{
clearTable(new Menu()); clearTable(new Menu());
@@ -206,9 +231,14 @@ public class InitCoreData extends BaseInitDataTests {
@Autowired @Autowired
private UserService userService; private UserService userService;
/**
* 用户表
*/
public void initUser() throws Exception{ public void initUser() throws Exception{
try{ try{
clearTable(new User()); clearTable(new User());
clearTable(new UserRole());
clearTable(new UserDataScope());
initExcelData(User.class, new MethodCallback() { initExcelData(User.class, new MethodCallback() {
@Override @Override
public Object execute(Object... params) { public Object execute(Object... params) {
@@ -231,6 +261,9 @@ public class InitCoreData extends BaseInitDataTests {
@Autowired @Autowired
private AreaService areaService; private AreaService areaService;
/**
* 区域、行政区划表
*/
public void initArea() throws Exception{ public void initArea() throws Exception{
try{ try{
clearTable(new Area()); clearTable(new Area());
@@ -255,6 +288,9 @@ public class InitCoreData extends BaseInitDataTests {
@Autowired @Autowired
private OfficeService officeService; private OfficeService officeService;
/**
* 组织机构、部门表
*/
public void initOffice() throws Exception{ public void initOffice() throws Exception{
try{ try{
clearTable(new Office()); clearTable(new Office());
@@ -279,9 +315,13 @@ public class InitCoreData extends BaseInitDataTests {
@Autowired @Autowired
private CompanyService companyService; private CompanyService companyService;
/**
* 公司表
*/
public void initCompany() throws Exception{ public void initCompany() throws Exception{
try{ try{
clearTable(new Company()); clearTable(new Company());
clearTable(new CompanyOffice());
initExcelData(Company.class, new MethodCallback() { initExcelData(Company.class, new MethodCallback() {
@Override @Override
public Object execute(Object... params) { public Object execute(Object... params) {
@@ -303,6 +343,9 @@ public class InitCoreData extends BaseInitDataTests {
@Autowired @Autowired
private PostService postService; private PostService postService;
/**
* 岗位表
*/
public void initPost() throws Exception{ public void initPost() throws Exception{
try{ try{
clearTable(new Post()); clearTable(new Post());
@@ -327,9 +370,13 @@ public class InitCoreData extends BaseInitDataTests {
@Autowired @Autowired
private EmpUserService empUserService; private EmpUserService empUserService;
/**
* 员工、用户表
*/
public void initEmpUser() throws Exception{ public void initEmpUser() throws Exception{
try{ try{
clearTable(new Employee()); clearTable(new Employee());
clearTable(new EmployeePost());
initExcelData(EmpUser.class, new MethodCallback() { initExcelData(EmpUser.class, new MethodCallback() {
@Override @Override
public Object execute(Object... params) { public Object execute(Object... params) {

View File

@@ -16,18 +16,18 @@ public class InitCoreData extends com.jeesite.modules.db.InitCoreData {
@Test @Test
public void initCoreData() throws Exception{ public void initCoreData() throws Exception{
// initLog(); initLog();
// initConfig(); initConfig();
// initModule(); initModule();
initDict(); initDict();
// initRole(); initRole();
initMenu(); initMenu();
// initUser(); initUser();
// initArea(); // initArea();
// initOffice(); initOffice();
// initCompany(); initCompany();
// initPost(); initPost();
// initEmpUser(); initEmpUser();
} }
} }