Former-commit-id: dc201f24cb70e4fe7043e0907772323cb36823a1
master
wangbing 5 years ago
parent 2d6b60a644
commit a572ac900d

@ -336,11 +336,6 @@ public class SpringBootCallable implements Callable {
ctx.put("author", md.getProjectAuthor());
ctx.put("date", new Date());
if (md.getModuleName().equals("api")) {
freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "ApiManager" + ".java"), option + "/java/module/mgr/ApiManager.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "ApiManagerImpl" + ".java"), option + "/java/module/mgr/ApiManagerImpl.java", ctx);
}
for (Table table : md.getTables()) {
ctx.put("table", table);
freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Manager" + ".java"), option + "/java/module/mgr/manager.ftl", ctx);
@ -947,6 +942,8 @@ public class SpringBootCallable implements Callable {
freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "DictItemTest.java"), option + "/test/system/DictItemTest.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "DictTest.java"), option + "/test/system/DictTest.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "FileTest.java"), option + "/test/system/FileTest.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "ResourceTest.java"), option + "/test/system/ResourceTest.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "TokensTest.java"), option + "/test/system/TokensTest.java", ctx);
}
for (Module md : project.getModules()) {

@ -1,9 +1,7 @@
package ${basePackage}.frame.utils;
import com.fasterxml.jackson.core.TreeNode;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Iterator;
/**
* MD5Util - MD5
@ -15,10 +13,35 @@ import java.util.Iterator;
public class MD5Util {
/**
*
*
*
* @param value
* @return
* @param value
* @param salts
* @return
*/
public static String generatePwd(String value, String... salts) {
String pwd = encode(value);
for (String s : salts) {
pwd = encode(s + value + s);
}
return pwd;
}
/**
*
*
* @param value
* @return
*/
public static String generatePwd(String value) {
return generatePwd(value, "MD5");
}
/**
*
*
* @param value
* @return Hex
*/
public static String encode(String value) {
try {
@ -31,6 +54,12 @@ public class MD5Util {
}
}
/**
*
*
* @param bytes
* @return Hex
*/
public static String encode(byte[] bytes) {
try {
MessageDigest md = MessageDigest.getInstance("md5");
@ -42,6 +71,10 @@ public class MD5Util {
}
}
/**
* @param bytes
* @return Hex
*/
private static String toHexString(byte bytes[]) {
StringBuilder hs = new StringBuilder();
String stmp = "";

@ -1,25 +0,0 @@
package ${basePackage}.module.${moduleName}.mgr;
import ${basePackage}.module.${moduleName}.req.*;
import ${basePackage}.module.${moduleName}.rsp.*;
import ${basePackage}.frame.base.Token;
/**
* Api
*
* @author wangbing
* @version 0.0.1
* @since 2018-10-23
*/
public interface ApiManager {
/**
* Api#example
*
* @param request
* @param token
* @return
*/
ApiExampleResponse example(ApiExampleRequest request, Token token);
}

@ -1,31 +0,0 @@
package ${basePackage}.module.${moduleName}.mgr;
import ${basePackage}.module.${moduleName}.req.*;
import ${basePackage}.module.${moduleName}.rsp.*;
import ${basePackage}.frame.base.Token;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Api
*
* @author wangbing
* @version 0.0.1
* @since 2018-10-23
*/
@Transactional
@Service
public class ApiManagerImpl implements ApiManager {
/**
* Api#example
*
* @param request
* @param token
* @return
*/
@Override
public ApiExampleResponse example(ApiExampleRequest request, Token token) {
return new ApiExampleResponse();
}
}

@ -19,6 +19,12 @@ import org.springframework.transaction.annotation.Transactional;
@Transactional
public class UtilTest {
@Test
public void testGeneratePwd() {
System.out.print("[123456]加密=");
System.out.println(MD5Util.generatePwd("123456"));
}
@Test
public void testIDgenerator() {
for (int i = 0; i < 10; i++) {

@ -0,0 +1,129 @@
package ${basePackage}.system;
import org.junit.Test;
import org.junit.runner.RunWith;
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}.module.system.req.*;
import ${basePackage}.module.system.rsp.*;
import ${basePackage}.frame.base.Token;
/**
* ResourceTest - -
*
* @author author
* @version 0.0.1
* @since 2019-12-19
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class ResourceTest {
@Autowired
private Token token;
@Autowired
private ResourceManager resourceManager;
@Test
public void testCreate() {
ResourceCreateRequest request = new ResourceCreateRequest();
request.setValue("资源内容");
request.setComment("资源描述");
request.setResourceType("code");
request.setValid(true);
ResourceCreateResponse response = resourceManager.create(request,token);
assertTrue(!response.hasError());
}
@Test
public void testDelete() {
//创建数据
ResourceCreateRequest createRequest = new ResourceCreateRequest();
createRequest.setValue("资源内容");
createRequest.setComment("资源描述");
createRequest.setResourceType("code");
createRequest.setValid(true);
ResourceCreateResponse createResponse = resourceManager.create(createRequest,token);
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
//删除数据
ResourceDeleteRequest request = new ResourceDeleteRequest();
request.setId(createResponse.getId());
ResourceDeleteResponse response = resourceManager.delete(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testUpdate() {
//创建数据
ResourceCreateRequest createRequest = new ResourceCreateRequest();
createRequest.setValue("资源内容");
createRequest.setComment("资源描述");
createRequest.setResourceType("code");
createRequest.setValid(true);
ResourceCreateResponse createResponse = resourceManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//更新数据
ResourceUpdateRequest request = new ResourceUpdateRequest();
request.setId(createResponse.getId());
request.setValue("资源内容");
request.setComment("资源描述");
request.setResourceType("code");
request.setValid(true);
ResourceUpdateResponse response = resourceManager.update(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testFind() {
ResourceFindRequest request = new ResourceFindRequest();
request.setValue("资源内容");
request.setComment("资源描述");
request.setResourceType("code");
request.setValid(true);
ResourceFindResponse response = resourceManager.find(request,token);
assertTrue(!response.hasError());
}
@Test
public void testGet() {
//创建数据
ResourceCreateRequest createRequest = new ResourceCreateRequest();
createRequest.setValue("资源内容");
createRequest.setComment("资源描述");
createRequest.setResourceType("code");
createRequest.setValid(true);
ResourceCreateResponse createResponse = resourceManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//获得数据
ResourceGetRequest request = new ResourceGetRequest();
request.setId(createResponse.getId());
ResourceGetResponse response = resourceManager.get(request,token);
assertTrue(!response.hasError() && response.getResource() != null);
}
}

@ -0,0 +1,172 @@
package ${basePackage}.system;
import org.junit.Test;
import org.junit.runner.RunWith;
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.TokensManager;
import ${basePackage}.module.system.req.*;
import ${basePackage}.module.system.rsp.*;
import ${basePackage}.frame.base.Token;
import java.util.Date;
/**
* TokensTest - -
*
* @author author
* @version 0.0.1
* @since 2019-12-19
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class TokensTest {
@Autowired
private Token token;
@Autowired
private TokensManager tokensManager;
@Test
public void testCreate() {
TokensCreateRequest request = new TokensCreateRequest();
request.setUserId(1L);
request.setUserName("用户名称");
request.setLoginTime(new Date());
request.setValidTime(new Date());
request.setValid(true);
request.setDeptId(1L);
request.setDeptCode("部门代码");
request.setDeptName("部门名称");
request.setTerminalType("code");
request.setTerminalIp("终端地址");
request.setTerminalInfo("终端信息");
TokensCreateResponse response = tokensManager.create(request,token);
assertTrue(!response.hasError());
}
@Test
public void testDelete() {
//创建数据
TokensCreateRequest createRequest = new TokensCreateRequest();
createRequest.setUserId(1L);
createRequest.setUserName("用户名称");
createRequest.setLoginTime(new Date());
createRequest.setValidTime(new Date());
createRequest.setValid(true);
createRequest.setDeptId(1L);
createRequest.setDeptCode("部门代码");
createRequest.setDeptName("部门名称");
createRequest.setTerminalType("code");
createRequest.setTerminalIp("终端地址");
createRequest.setTerminalInfo("终端信息");
TokensCreateResponse createResponse = tokensManager.create(createRequest,token);
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
//删除数据
TokensDeleteRequest request = new TokensDeleteRequest();
request.setId(createResponse.getId());
TokensDeleteResponse response = tokensManager.delete(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testUpdate() {
//创建数据
TokensCreateRequest createRequest = new TokensCreateRequest();
createRequest.setUserId(1L);
createRequest.setUserName("用户名称");
createRequest.setLoginTime(new Date());
createRequest.setValidTime(new Date());
createRequest.setValid(true);
createRequest.setDeptId(1L);
createRequest.setDeptCode("部门代码");
createRequest.setDeptName("部门名称");
createRequest.setTerminalType("code");
createRequest.setTerminalIp("终端地址");
createRequest.setTerminalInfo("终端信息");
TokensCreateResponse createResponse = tokensManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//更新数据
TokensUpdateRequest request = new TokensUpdateRequest();
request.setId(createResponse.getId());
request.setUserId(1L);
request.setUserName("用户名称");
request.setLoginTime(new Date());
request.setValidTime(new Date());
request.setValid(true);
request.setDeptId(1L);
request.setDeptCode("部门代码");
request.setDeptName("部门名称");
request.setTerminalType("code");
request.setTerminalIp("终端地址");
request.setTerminalInfo("终端信息");
TokensUpdateResponse response = tokensManager.update(request,token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@Test
public void testFind() {
TokensFindRequest request = new TokensFindRequest();
request.setUserId(1L);
request.setUserName("用户名称");
request.setLoginTime(new Date());
request.setValidTime(new Date());
request.setValid(true);
request.setDeptId(1L);
request.setDeptCode("部门代码");
request.setDeptName("部门名称");
request.setTerminalType("code");
request.setTerminalIp("终端地址");
request.setTerminalInfo("终端信息");
TokensFindResponse response = tokensManager.find(request,token);
assertTrue(!response.hasError());
}
@Test
public void testGet() {
//创建数据
TokensCreateRequest createRequest = new TokensCreateRequest();
createRequest.setUserId(1L);
createRequest.setUserName("用户名称");
createRequest.setLoginTime(new Date());
createRequest.setValidTime(new Date());
createRequest.setValid(true);
createRequest.setDeptId(1L);
createRequest.setDeptCode("部门代码");
createRequest.setDeptName("部门名称");
createRequest.setTerminalType("code");
createRequest.setTerminalIp("终端地址");
createRequest.setTerminalInfo("终端信息");
TokensCreateResponse createResponse = tokensManager.create(createRequest, token);
assertTrue(!createResponse.hasError());
//获得数据
TokensGetRequest request = new TokensGetRequest();
request.setId(createResponse.getId());
TokensGetResponse response = tokensManager.get(request,token);
assertTrue(!response.hasError() && response.getTokens() != null);
}
}
Loading…
Cancel
Save

Powered by TurnKey Linux.