Former-commit-id: fb431ab883ad04fa61508fb983791f806719a5ef
master
wangbing 5 years ago
parent d9c49bd2e1
commit 13ccd1b3f0

@ -19,13 +19,13 @@ import ${basePackage}.module.system.req.ResourceCreateRequest;
import ${basePackage}.module.system.req.ResourceDeleteRequest;
import ${basePackage}.module.system.req.ResourceFindRequest;
import ${basePackage}.module.system.req.ResourceGetRequest;
import ${basePackage}.module.system.req.ResourceLoadRequest;
import ${basePackage}.module.system.req.ResourceTreeRequest;
import ${basePackage}.module.system.req.ResourceUpdateRequest;
import ${basePackage}.module.system.rsp.ResourceCreateResponse;
import ${basePackage}.module.system.rsp.ResourceDeleteResponse;
import ${basePackage}.module.system.rsp.ResourceFindResponse;
import ${basePackage}.module.system.rsp.ResourceGetResponse;
import ${basePackage}.module.system.rsp.ResourceLoadResponse;
import ${basePackage}.module.system.rsp.ResourceTreeResponse;
import ${basePackage}.module.system.rsp.ResourceUpdateResponse;
import java.io.IOException;
@ -56,8 +56,8 @@ public class ResourceAjax {
return resourceManager.get(request, LocalData.getToken());
}
public ResourceLoadResponse load(ResourceLoadRequest request) {
return resourceManager.load(request, LocalData.getToken());
public ResourceTreeResponse tree(ResourceTreeRequest request) {
return resourceManager.tree(request, LocalData.getToken());
}
public Object template() {

@ -1,33 +0,0 @@
package ${basePackage}.module.system.ent;
public class ResourceCheck {
private long resourceId;
private String resourceValue;
private boolean check;
public long getResourceId() {
return resourceId;
}
public void setResourceId(long resourceId) {
this.resourceId = resourceId;
}
public String getResourceValue() {
return resourceValue;
}
public void setResourceValue(String resourceValue) {
this.resourceValue = resourceValue;
}
public boolean isCheck() {
return check;
}
public void setCheck(boolean check) {
this.check = check;
}
}

@ -1,26 +1,27 @@
package ${basePackage}.module.system.ent;
import java.util.ArrayList;
import java.util.List;
public class ResourceTree {
public class ResourceTree extends Resource {
private String resourceModule;
private Long pId;
private List<ResourceCheck> resourceChecks;
private List<ResourceTree> children = new ArrayList<>();
public String getResourceModule() {
return resourceModule;
public Long getpId() {
return pId;
}
public void setResourceModule(String resourceModule) {
this.resourceModule = resourceModule;
public void setpId(Long pId) {
this.pId = pId;
}
public List<ResourceCheck> getResourceChecks() {
return resourceChecks;
public List<ResourceTree> getChildren() {
return children;
}
public void setResourceChecks(List<ResourceCheck> resourceChecks) {
this.resourceChecks = resourceChecks;
public void setChildren(List<ResourceTree> children) {
this.children = children;
}
}

@ -5,13 +5,13 @@ import ${basePackage}.module.system.req.ResourceCreateRequest;
import ${basePackage}.module.system.req.ResourceDeleteRequest;
import ${basePackage}.module.system.req.ResourceFindRequest;
import ${basePackage}.module.system.req.ResourceGetRequest;
import ${basePackage}.module.system.req.ResourceLoadRequest;
import ${basePackage}.module.system.req.ResourceTreeRequest;
import ${basePackage}.module.system.req.ResourceUpdateRequest;
import ${basePackage}.module.system.rsp.ResourceCreateResponse;
import ${basePackage}.module.system.rsp.ResourceDeleteResponse;
import ${basePackage}.module.system.rsp.ResourceFindResponse;
import ${basePackage}.module.system.rsp.ResourceGetResponse;
import ${basePackage}.module.system.rsp.ResourceLoadResponse;
import ${basePackage}.module.system.rsp.ResourceTreeResponse;
import ${basePackage}.module.system.rsp.ResourceUpdateResponse;
/**
@ -68,5 +68,12 @@ public interface ResourceManager {
*/
ResourceGetResponse get(ResourceGetRequest request, Token token);
ResourceLoadResponse load(ResourceLoadRequest request, Token token);
/**
*
*
* @param request
* @param token
* @return
*/
ResourceTreeResponse tree(ResourceTreeRequest request, Token token);
}

@ -14,24 +14,24 @@ import ${basePackage}.frame.utils.MapperUtil;
import ${basePackage}.frame.utils.Message;
import ${basePackage}.frame.utils.ValidationUtil;
import ${basePackage}.module.system.ent.Resource;
import ${basePackage}.module.system.ent.ResourceCheck;
import ${basePackage}.module.system.ent.ResourceTree;
import ${basePackage}.module.system.mpr.ResourceMapper;
import ${basePackage}.module.system.req.ResourceCreateRequest;
import ${basePackage}.module.system.req.ResourceDeleteRequest;
import ${basePackage}.module.system.req.ResourceFindRequest;
import ${basePackage}.module.system.req.ResourceGetRequest;
import ${basePackage}.module.system.req.ResourceLoadRequest;
import ${basePackage}.module.system.req.ResourceTreeRequest;
import ${basePackage}.module.system.req.ResourceUpdateRequest;
import ${basePackage}.module.system.rsp.ResourceCreateResponse;
import ${basePackage}.module.system.rsp.ResourceDeleteResponse;
import ${basePackage}.module.system.rsp.ResourceFindResponse;
import ${basePackage}.module.system.rsp.ResourceGetResponse;
import ${basePackage}.module.system.rsp.ResourceLoadResponse;
import ${basePackage}.module.system.rsp.ResourceTreeResponse;
import ${basePackage}.module.system.rsp.ResourceUpdateResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* RESOURCE -
@ -184,7 +184,7 @@ public class ResourceManagerImpl implements ResourceManager {
}
@Override
public ResourceTreeResponse load(ResourceTreeRequest request, Token token) {
public ResourceTreeResponse tree(ResourceTreeRequest request, Token token) {
ResourceTreeResponse response = new ResourceTreeResponse();
ValidationUtil.validate(request, response);
@ -204,7 +204,8 @@ public class ResourceManagerImpl implements ResourceManager {
return response;
}
Map<String, ResourceTree> map = new HashMap<>();
Map<String, ResourceTree> treeMap = new HashMap<>();
Map<String, ResourceTree> allMap = new HashMap<>();
List<Resource> result = resourceFindResponse.getResult();
// 获取最顶级资源
@ -213,23 +214,27 @@ public class ResourceManagerImpl implements ResourceManager {
Iterator<Resource> iterator = result.iterator();
while (iterator.hasNext()) {
Resource next = iterator.next();
ResourceTree tree = new ResourceTree();
tree.setId(next.getId());
tree.setCode(next.getCode());
tree.setComment(next.getComment());
if (next.getCode() != null && next.getCode().split("_").length == level) {
ResourceTree tree = MapperUtil.map(next, ResourceTree.class);
map.put(tree.getCode(), tree);
allMap.put(tree.getCode(), tree);
iterator.remove();
{//尝试获取上级资源
//尝试获取上级资源
String code = next.getCode();
ResourceTree Ptree = null;
while (code.contains("_")) {
code = code.substring(0, code.lastIndexOf("_"));
Ptree = map.get(code);
Ptree = allMap.get(code);
if (Ptree != null) break;
}
if (Ptree != null) {
tree.setpId(Ptree.getpId());
Ptree.getChildren().add(tree);
} else {
map.put(tree.getCode(), tree);
}
treeMap.put(tree.getCode(), tree);
}
}
}

@ -1,6 +1,6 @@
package xyz.wbsite.module.system.req;
package ${basePackage}.module.system.req;
import xyz.wbsite.frame.base.BaseRequest;
import ${basePackage}.frame.base.BaseRequest;
/**
* ResourceTreeRequest -

@ -1,7 +1,7 @@
package xyz.wbsite.module.system.rsp;
package ${basePackage}.module.system.rsp;
import xyz.wbsite.frame.base.BaseFindResponse;
import xyz.wbsite.module.system.ent.ResourceTree;
import ${basePackage}.frame.base.BaseFindResponse;
import ${basePackage}.module.system.ent.ResourceTree;
/**
* ResourceTreeResponse -

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<projectName>wadmin</projectName>
<projectBasePackage>xyz.wbsite</projectBasePackage>
<projectBasePackage>${basePackage}</projectBasePackage>
<projectAuthor>wangbing</projectAuthor>
<multiDB>false</multiDB>
<sysMD>false</sysMD>

@ -129,3 +129,6 @@ web.login.page=/login.htm
web.url.auth.included=/,/**/*.htm
# 直接放行
web.url.auth.excluded=/login.htm
# 超级管理员
web.url.auth.admin=admin
web.url.auth.pwd=17fac3376f76d65943d1d26d1f7cb1e5

@ -0,0 +1,142 @@
package ${basePackage}.system;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.mgr.DeptManager;
import ${basePackage}.module.system.req.*;
import ${basePackage}.module.system.rsp.*;
import static org.junit.Assert.assertTrue;
/**
* DeptTest - -
*
* @author wangbing
* @version 0.0.1
* @since 2019-12-27
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class DeptTest {
@Autowired
private Token token;
@Autowired
private DeptManager deptManager;
@Test
public void testCreate() {
DeptCreateRequest request = new DeptCreateRequest();
request.setDeptCode("部门代码");
request.setDeptName("部门名称");
request.setDeptAlias("部门别名");
request.setSupCode("父部门代码");
request.setSupName("父部门名称");
request.setValid(true);
DeptCreateResponse response = deptManager.create(request,token);
assertTrue(!response.hasError());
}
@Test
public void testDelete() {
//创建数据
DeptCreateRequest createRequest = new DeptCreateRequest();
createRequest.setDeptCode("部门代码");
createRequest.setDeptName("部门名称");
createRequest.setDeptAlias("部门别名");
createRequest.setSupCode("父部门代码");
createRequest.setSupName("父部门名称");
createRequest.setValid(true);
DeptCreateResponse createResponse = deptManager.create(createRequest,token);
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
//删除数据
DeptDeleteRequest request = new DeptDeleteRequest();
request.setId(createResponse.getId());
DeptDeleteResponse response = deptManager.delete(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testUpdate() {
//创建数据
DeptCreateRequest createRequest = new DeptCreateRequest();
createRequest.setDeptCode("部门代码");
createRequest.setDeptName("部门名称");
createRequest.setDeptAlias("部门别名");
createRequest.setSupCode("父部门代码");
createRequest.setSupName("父部门名称");
createRequest.setValid(true);
DeptCreateResponse createResponse = deptManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//更新数据
DeptUpdateRequest request = new DeptUpdateRequest();
request.setId(createResponse.getId());
request.setDeptCode("部门代码");
request.setDeptName("部门名称");
request.setDeptAlias("部门别名");
request.setSupCode("父部门代码");
request.setSupName("父部门名称");
request.setValid(true);
DeptUpdateResponse response = deptManager.update(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testFind() {
DeptFindRequest request = new DeptFindRequest();
request.setDeptCode("部门代码");
request.setDeptName("部门名称");
request.setDeptAlias("部门别名");
request.setSupCode("父部门代码");
request.setSupName("父部门名称");
request.setValid(true);
DeptFindResponse response = deptManager.find(request,token);
assertTrue(!response.hasError());
}
@Test
public void testGet() {
//创建数据
DeptCreateRequest createRequest = new DeptCreateRequest();
createRequest.setDeptCode("部门代码");
createRequest.setDeptName("部门名称");
createRequest.setDeptAlias("部门别名");
createRequest.setSupCode("父部门代码");
createRequest.setSupName("父部门名称");
createRequest.setValid(true);
DeptCreateResponse createResponse = deptManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//获得数据
DeptGetRequest request = new DeptGetRequest();
request.setId(createResponse.getId());
DeptGetResponse response = deptManager.get(request,token);
assertTrue(!response.hasError() && response.getDept() != null);
}
}

@ -1,5 +1,11 @@
package ${basePackage}.system;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.mgr.DictItemManager;
import ${basePackage}.module.system.req.DictItemCreateRequest;
@ -12,12 +18,6 @@ import ${basePackage}.module.system.rsp.DictItemDeleteResponse;
import ${basePackage}.module.system.rsp.DictItemFindResponse;
import ${basePackage}.module.system.rsp.DictItemGetResponse;
import ${basePackage}.module.system.rsp.DictItemUpdateResponse;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import static org.junit.Assert.assertTrue;

@ -1,5 +1,11 @@
package ${basePackage}.system;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.mgr.DictItemManager;
import ${basePackage}.module.system.mgr.DictManager;
@ -17,12 +23,6 @@ import ${basePackage}.module.system.rsp.DictGetResponse;
import ${basePackage}.module.system.rsp.DictItemCreateResponse;
import ${basePackage}.module.system.rsp.DictLoadResponse;
import ${basePackage}.module.system.rsp.DictUpdateResponse;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import static org.junit.Assert.assertTrue;

@ -1,5 +1,11 @@
package ${basePackage}.system;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.mgr.FileManager;
import ${basePackage}.module.system.req.FileCreateRequest;
@ -10,12 +16,6 @@ import ${basePackage}.module.system.rsp.FileCreateResponse;
import ${basePackage}.module.system.rsp.FileDeleteResponse;
import ${basePackage}.module.system.rsp.FileFindResponse;
import ${basePackage}.module.system.rsp.FileGetResponse;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import static org.junit.Assert.assertTrue;

@ -2,15 +2,15 @@ package ${basePackage}.system;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertTrue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.module.system.mgr.ResourceManager;
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.req.*;
import ${basePackage}.module.system.rsp.*;
import ${basePackage}.frame.base.Token;
import static org.junit.Assert.assertTrue;
/**
@ -29,7 +29,7 @@ public class ResourceTest {
private Token token;
@Autowired
private ResourceManager resourceManager;
private ${basePackage}.module.system.mgr.ResourceManager resourceManager;
@Test
public void testCreate() {
@ -126,4 +126,14 @@ public class ResourceTest {
assertTrue(!response.hasError() && response.getResource() != null);
}
@Test
public void testTree() {
//创建数据
${basePackage}.module.system.req.ResourceTreeRequest request = new ${basePackage}.module.system.req.ResourceTreeRequest();
${basePackage}.module.system.rsp.ResourceTreeResponse response = resourceManager.tree(request, token);
assertTrue(!response.hasError());
}
}

@ -0,0 +1,118 @@
package ${basePackage}.system;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.mgr.RoleResourceManager;
import ${basePackage}.module.system.req.*;
import ${basePackage}.module.system.rsp.*;
import static org.junit.Assert.assertTrue;
/**
* RoleResourceTest - -
*
* @author wangbing
* @version 0.0.1
* @since 2019-12-27
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class RoleResourceTest {
@Autowired
private Token token;
@Autowired
private RoleResourceManager roleResourceManager;
@Test
public void testCreate() {
RoleResourceCreateRequest request = new RoleResourceCreateRequest();
request.setRoleId(1L);
request.setResourceId(1L);
RoleResourceCreateResponse response = roleResourceManager.create(request,token);
assertTrue(!response.hasError());
}
@Test
public void testDelete() {
//创建数据
RoleResourceCreateRequest createRequest = new RoleResourceCreateRequest();
createRequest.setRoleId(1L);
createRequest.setResourceId(1L);
RoleResourceCreateResponse createResponse = roleResourceManager.create(createRequest,token);
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
//删除数据
RoleResourceDeleteRequest request = new RoleResourceDeleteRequest();
request.setId(createResponse.getId());
RoleResourceDeleteResponse response = roleResourceManager.delete(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testUpdate() {
//创建数据
RoleResourceCreateRequest createRequest = new RoleResourceCreateRequest();
createRequest.setRoleId(1L);
createRequest.setResourceId(1L);
RoleResourceCreateResponse createResponse = roleResourceManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//更新数据
RoleResourceUpdateRequest request = new RoleResourceUpdateRequest();
request.setId(createResponse.getId());
request.setRoleId(1L);
request.setResourceId(1L);
RoleResourceUpdateResponse response = roleResourceManager.update(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testFind() {
RoleResourceFindRequest request = new RoleResourceFindRequest();
request.setRoleId(1L);
request.setResourceId(1L);
RoleResourceFindResponse response = roleResourceManager.find(request,token);
assertTrue(!response.hasError());
}
@Test
public void testGet() {
//创建数据
RoleResourceCreateRequest createRequest = new RoleResourceCreateRequest();
createRequest.setRoleId(1L);
createRequest.setResourceId(1L);
RoleResourceCreateResponse createResponse = roleResourceManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//获得数据
RoleResourceGetRequest request = new RoleResourceGetRequest();
request.setId(createResponse.getId());
RoleResourceGetResponse response = roleResourceManager.get(request,token);
assertTrue(!response.hasError() && response.getRoleResource() != null);
}
}

@ -0,0 +1,124 @@
package ${basePackage}.system;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.mgr.RoleManager;
import ${basePackage}.module.system.req.*;
import ${basePackage}.module.system.rsp.*;
import static org.junit.Assert.assertTrue;
/**
* RoleTest - -
*
* @author wangbing
* @version 0.0.1
* @since 2019-12-27
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class RoleTest {
@Autowired
private Token token;
@Autowired
private RoleManager roleManager;
@Test
public void testCreate() {
RoleCreateRequest request = new RoleCreateRequest();
request.setCode("角色代码");
request.setName("角色名称");
request.setComment("角色描述");
RoleCreateResponse response = roleManager.create(request,token);
assertTrue(!response.hasError());
}
@Test
public void testDelete() {
//创建数据
RoleCreateRequest createRequest = new RoleCreateRequest();
createRequest.setCode("角色代码");
createRequest.setName("角色名称");
createRequest.setComment("角色描述");
RoleCreateResponse createResponse = roleManager.create(createRequest,token);
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
//删除数据
RoleDeleteRequest request = new RoleDeleteRequest();
request.setId(createResponse.getId());
RoleDeleteResponse response = roleManager.delete(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testUpdate() {
//创建数据
RoleCreateRequest createRequest = new RoleCreateRequest();
createRequest.setCode("角色代码");
createRequest.setName("角色名称");
createRequest.setComment("角色描述");
RoleCreateResponse createResponse = roleManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//更新数据
RoleUpdateRequest request = new RoleUpdateRequest();
request.setId(createResponse.getId());
request.setCode("角色代码");
request.setName("角色名称");
request.setComment("角色描述");
RoleUpdateResponse response = roleManager.update(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testFind() {
RoleFindRequest request = new RoleFindRequest();
request.setCode("角色代码");
request.setName("角色名称");
request.setComment("角色描述");
RoleFindResponse response = roleManager.find(request,token);
assertTrue(!response.hasError());
}
@Test
public void testGet() {
//创建数据
RoleCreateRequest createRequest = new RoleCreateRequest();
createRequest.setCode("角色代码");
createRequest.setName("角色名称");
createRequest.setComment("角色描述");
RoleCreateResponse createResponse = roleManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//获得数据
RoleGetRequest request = new RoleGetRequest();
request.setId(createResponse.getId());
RoleGetResponse response = roleManager.get(request,token);
assertTrue(!response.hasError() && response.getRole() != null);
}
}

@ -2,17 +2,19 @@ package ${basePackage}.system;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertTrue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.mgr.TokensManager;
import ${basePackage}.module.system.req.*;
import ${basePackage}.module.system.rsp.*;
import ${basePackage}.frame.base.Token;
import java.util.Date;
import static org.junit.Assert.assertTrue;
/**
* TokensTest - -

@ -0,0 +1,118 @@
package ${basePackage}.system;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.mgr.UserRoleManager;
import ${basePackage}.module.system.req.*;
import ${basePackage}.module.system.rsp.*;
import static org.junit.Assert.assertTrue;
/**
* UserRoleTest - -
*
* @author wangbing
* @version 0.0.1
* @since 2019-12-27
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class UserRoleTest {
@Autowired
private Token token;
@Autowired
private UserRoleManager userRoleManager;
@Test
public void testCreate() {
UserRoleCreateRequest request = new UserRoleCreateRequest();
request.setUserId(1L);
request.setRoleId(1L);
UserRoleCreateResponse response = userRoleManager.create(request,token);
assertTrue(!response.hasError());
}
@Test
public void testDelete() {
//创建数据
UserRoleCreateRequest createRequest = new UserRoleCreateRequest();
createRequest.setUserId(1L);
createRequest.setRoleId(1L);
UserRoleCreateResponse createResponse = userRoleManager.create(createRequest,token);
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
//删除数据
UserRoleDeleteRequest request = new UserRoleDeleteRequest();
request.setId(createResponse.getId());
UserRoleDeleteResponse response = userRoleManager.delete(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testUpdate() {
//创建数据
UserRoleCreateRequest createRequest = new UserRoleCreateRequest();
createRequest.setUserId(1L);
createRequest.setRoleId(1L);
UserRoleCreateResponse createResponse = userRoleManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//更新数据
UserRoleUpdateRequest request = new UserRoleUpdateRequest();
request.setId(createResponse.getId());
request.setUserId(1L);
request.setRoleId(1L);
UserRoleUpdateResponse response = userRoleManager.update(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testFind() {
UserRoleFindRequest request = new UserRoleFindRequest();
request.setUserId(1L);
request.setRoleId(1L);
UserRoleFindResponse response = userRoleManager.find(request,token);
assertTrue(!response.hasError());
}
@Test
public void testGet() {
//创建数据
UserRoleCreateRequest createRequest = new UserRoleCreateRequest();
createRequest.setUserId(1L);
createRequest.setRoleId(1L);
UserRoleCreateResponse createResponse = userRoleManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//获得数据
UserRoleGetRequest request = new UserRoleGetRequest();
request.setId(createResponse.getId());
UserRoleGetResponse response = userRoleManager.get(request,token);
assertTrue(!response.hasError() && response.getUserRole() != null);
}
}

@ -0,0 +1,153 @@
package ${basePackage}.system;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.mgr.UserManager;
import ${basePackage}.module.system.req.*;
import ${basePackage}.module.system.rsp.*;
import static org.junit.Assert.assertTrue;
/**
* UserTest - -
*
* @author wangbing
* @version 0.0.1
* @since 2019-12-27
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class UserTest {
@Autowired
private Token token;
@Autowired
private UserManager userManager;
@Test
public void testCreate() {
UserCreateRequest request = new UserCreateRequest();
request.setUserName("用户账户");
request.setUserCode("用户代码");
request.setUserAlias("用户别名");
request.setUserPwd("用户密码");
request.setUserStatus("code");
request.setDeptId(1L);
request.setDeptCode("部门代码");
request.setDeptName("部门名称");
UserCreateResponse response = userManager.create(request,token);
assertTrue(!response.hasError());
}
@Test
public void testDelete() {
//创建数据
UserCreateRequest createRequest = new UserCreateRequest();
createRequest.setUserName("用户账户");
createRequest.setUserCode("用户代码");
createRequest.setUserAlias("用户别名");
createRequest.setUserPwd("用户密码");
createRequest.setUserStatus("code");
createRequest.setDeptId(1L);
createRequest.setDeptCode("部门代码");
createRequest.setDeptName("部门名称");
UserCreateResponse createResponse = userManager.create(createRequest,token);
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
//删除数据
UserDeleteRequest request = new UserDeleteRequest();
request.setId(createResponse.getId());
UserDeleteResponse response = userManager.delete(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testUpdate() {
//创建数据
UserCreateRequest createRequest = new UserCreateRequest();
createRequest.setUserName("用户账户");
createRequest.setUserCode("用户代码");
createRequest.setUserAlias("用户别名");
createRequest.setUserPwd("用户密码");
createRequest.setUserStatus("code");
createRequest.setDeptId(1L);
createRequest.setDeptCode("部门代码");
createRequest.setDeptName("部门名称");
UserCreateResponse createResponse = userManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//更新数据
UserUpdateRequest request = new UserUpdateRequest();
request.setId(createResponse.getId());
request.setUserName("用户账户");
request.setUserCode("用户代码");
request.setUserAlias("用户别名");
request.setUserPwd("用户密码");
request.setUserStatus("code");
request.setDeptId(1L);
request.setDeptCode("部门代码");
request.setDeptName("部门名称");
UserUpdateResponse response = userManager.update(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testFind() {
UserFindRequest request = new UserFindRequest();
request.setUserName("用户账户");
request.setUserCode("用户代码");
request.setUserAlias("用户别名");
request.setUserStatus("code");
request.setDeptId(1L);
request.setDeptCode("部门代码");
request.setDeptName("部门名称");
UserFindResponse response = userManager.find(request,token);
assertTrue(!response.hasError());
}
@Test
public void testGet() {
//创建数据
UserCreateRequest createRequest = new UserCreateRequest();
createRequest.setUserName("用户账户");
createRequest.setUserCode("用户代码");
createRequest.setUserAlias("用户别名");
createRequest.setUserPwd("用户密码");
createRequest.setUserStatus("code");
createRequest.setDeptId(1L);
createRequest.setDeptCode("部门代码");
createRequest.setDeptName("部门名称");
UserCreateResponse createResponse = userManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//获得数据
UserGetRequest request = new UserGetRequest();
request.setId(createResponse.getId());
UserGetResponse response = userManager.get(request,token);
assertTrue(!response.hasError() && response.getUser() != null);
}
}
Loading…
Cancel
Save

Powered by TurnKey Linux.