parent
02a15977ab
commit
411cd3f1b4
10 changed files with 112 additions and 13 deletions
@ -0,0 +1,10 @@ |
||||
package com.lq; |
||||
|
||||
import org.junit.runner.RunWith; |
||||
import org.springframework.test.context.ContextConfiguration; |
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class) |
||||
@ContextConfiguration(value = {"/spring-mybatis-config.xml","/spring-import.xml"}) |
||||
public class BaseTest { |
||||
} |
@ -0,0 +1,57 @@ |
||||
package com.lq; |
||||
|
||||
|
||||
import com.lq.cms.emun.BasicsPermissionKeyEnum; |
||||
import com.lq.cms.emun.StatusTypeEnum; |
||||
import com.lq.dao.SysPermissionDao; |
||||
import com.lq.dao.SysResourceDao; |
||||
import com.lq.dao.SysUserDao; |
||||
import com.lq.entity.SysPermission; |
||||
import com.lq.entity.SysResource; |
||||
import org.junit.Test; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
|
||||
public class SysPermissionServiceTest extends BaseTest { |
||||
|
||||
@Autowired |
||||
private SysUserDao sysUserDao; |
||||
@Autowired |
||||
private SysPermissionDao sysPermissionDao; |
||||
@Autowired |
||||
private SysResourceDao sysResourceDao; |
||||
|
||||
@Test |
||||
public void test(){ |
||||
|
||||
//1.查询所有菜单
|
||||
List<SysResource> sysResourceList = sysResourceDao.findAll(); |
||||
|
||||
//2.构建基本的权限
|
||||
// List<SysPermission> sysPermissionList = new ArrayList<>();
|
||||
BasicsPermissionKeyEnum[] basicsPermissionKeyEnums = BasicsPermissionKeyEnum.values(); |
||||
sysResourceList.forEach((sysResource)->{ |
||||
for (BasicsPermissionKeyEnum basicsPermissionKeyEnum:basicsPermissionKeyEnums){ |
||||
SysPermission sysPermission = new SysPermission(); |
||||
sysPermission.setStatus(StatusTypeEnum.STATUS_ACTIVITY_YES.getValue()); |
||||
sysPermission.setSysResourceId(sysResource.getId()); |
||||
sysPermission.setName(basicsPermissionKeyEnum.getDesc()); |
||||
sysPermission.setPermissionKey(basicsPermissionKeyEnum.getValue()); |
||||
sysPermission.setPermissionType(basicsPermissionKeyEnum.getType()); |
||||
sysPermission.setCreateTime(new Date()); |
||||
sysPermission.setCreateUserId(1L); |
||||
sysPermission.setUpdateTime(new Date()); |
||||
sysPermission.setUpdateUserId(1L); |
||||
// sysPermissionList.add(sysPermission);
|
||||
sysPermissionDao.save(sysPermission); |
||||
} |
||||
}); |
||||
//3.权限入库
|
||||
// sysPermissionDao.batchSave(sysPermissionList);
|
||||
} |
||||
} |
Loading…
Reference in new issue