parent
7cba3f7335
commit
21f395e74b
@ -1,182 +0,0 @@
|
||||
package ${domain}.action;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
<#list modules as m>
|
||||
import ${domain}.module.${m.moduleName}.req.*;
|
||||
import ${domain}.module.${m.moduleName}.mgr.*;
|
||||
</#list>
|
||||
import ${domain}.frame.auth.LocalData;
|
||||
import ${domain}.frame.utils.MapperUtil;
|
||||
import ${domain}.frame.utils.Message;
|
||||
import ${domain}.frame.base.BaseResponse;
|
||||
import ${domain}.frame.base.ErrorType;
|
||||
import ${domain}.frame.auth.Token;
|
||||
import ${domain}.frame.utils.LogUtil;
|
||||
import ${domain}.frame.base.Error;
|
||||
|
||||
@Controller
|
||||
public class AjaxController {
|
||||
<#list modules as m>
|
||||
<#list m.tables as table>
|
||||
@Autowired
|
||||
private ${table.getCName()}Manager ${table.getFName()}Manager;
|
||||
</#list>
|
||||
</#list>
|
||||
|
||||
@RequestMapping("/ajax")
|
||||
@ResponseBody
|
||||
public BaseResponse ajax(@RequestParam("method") String method,HttpServletRequest request,HttpServletResponse response) {
|
||||
|
||||
BaseResponse baseResponse = new BaseResponse();
|
||||
String jsonString = null;
|
||||
try {
|
||||
if (method == null){
|
||||
baseResponse.addError(new Error(ErrorType.BUSINESS_ERROR, "请求方法不能为空!"));
|
||||
return baseResponse;
|
||||
}
|
||||
Token token = LocalData.getToken();
|
||||
if (token == null) {
|
||||
token = LocalData.getTempToken();
|
||||
}
|
||||
if (!token.hasRes(method)) {
|
||||
baseResponse.addError(new Error(ErrorType.BUSINESS_ERROR, "无权调用该接口!"));
|
||||
return baseResponse;
|
||||
}
|
||||
|
||||
InputStreamReader isr = new InputStreamReader(request.getInputStream(),"UTF-8");
|
||||
BufferedReader in = new BufferedReader(isr);
|
||||
jsonString = in.readLine();
|
||||
|
||||
switch (method) {
|
||||
// 示例
|
||||
case "ajax.example.example":
|
||||
break;
|
||||
<#list modules as m>
|
||||
<#list m.tables as table>
|
||||
<#if table.getCreate()>
|
||||
// 创建${table.tableComment}
|
||||
case "ajax.${m.moduleName}.${table.getLName()}.create":
|
||||
baseResponse = create${table.getCName()}(jsonString, token);
|
||||
break;
|
||||
</#if>
|
||||
<#if table.getDelete()>
|
||||
// 删除${table.tableComment}
|
||||
case "ajax.${m.moduleName}.${table.getLName()}.delete":
|
||||
baseResponse = delete${table.getCName()}(jsonString, token);
|
||||
break;
|
||||
</#if>
|
||||
<#if table.getUpdate()>
|
||||
// 修改${table.tableComment}
|
||||
case "ajax.${m.moduleName}.${table.getLName()}.update":
|
||||
baseResponse = update${table.getCName()}(jsonString, token);
|
||||
break;
|
||||
</#if>
|
||||
<#if table.getFind()>
|
||||
// 查询${table.tableComment}
|
||||
case "ajax.${m.moduleName}.${table.getLName()}.find":
|
||||
baseResponse = find${table.getCName()}(jsonString, token);
|
||||
break;
|
||||
</#if>
|
||||
<#if table.getGet()>
|
||||
// 获得${table.tableComment}
|
||||
case "ajax.${m.moduleName}.${table.getLName()}.get":
|
||||
baseResponse = get${table.getCName()}(jsonString, token);
|
||||
break;
|
||||
</#if>
|
||||
<#if table.getSearch()>
|
||||
// 搜索${table.tableComment}
|
||||
case "ajax.${m.moduleName}.${table.getLName()}.search":
|
||||
baseResponse = search${table.getCName()}(jsonString, token);
|
||||
break;
|
||||
</#if>
|
||||
</#list>
|
||||
</#list>
|
||||
default:
|
||||
baseResponse.addError(ErrorType.INVALID_PARAMETER, Message.NOT_EXIST_METHOD);
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
baseResponse.addError(ErrorType.SYSTEM_ERROR, Message.ERROR_500);
|
||||
LogUtil.dumpException(ex);
|
||||
} finally {
|
||||
if(baseResponse.hasError()) {
|
||||
LogUtil.e("请求方法" + method + ", 请求参数:" + jsonString);
|
||||
LogUtil.e("返回结果包含异常" + MapperUtil.toJson(baseResponse));
|
||||
}
|
||||
}
|
||||
return baseResponse;
|
||||
}
|
||||
<#list modules as m>
|
||||
<#list m.tables as table>
|
||||
<#if table.getCreate()>
|
||||
|
||||
/**
|
||||
* 创建${table.tableComment}
|
||||
*/
|
||||
private BaseResponse create${table.getCName()}(String jsonString, Token token) {
|
||||
${table.getCName()}CreateRequest request = MapperUtil.toJava(jsonString, ${table.getCName()}CreateRequest.class);
|
||||
return ${table.getFName()}Manager.create(request, token);
|
||||
}
|
||||
</#if>
|
||||
<#if table.getDelete()>
|
||||
|
||||
/**
|
||||
* 删除${table.tableComment}
|
||||
*/
|
||||
private BaseResponse delete${table.getCName()}(String jsonString, Token token) {
|
||||
${table.getCName()}DeleteRequest request = MapperUtil.toJava(jsonString, ${table.getCName()}DeleteRequest.class);
|
||||
return ${table.getFName()}Manager.delete(request, token);
|
||||
}
|
||||
</#if>
|
||||
<#if table.getUpdate()>
|
||||
|
||||
/**
|
||||
* 修改${table.tableComment}
|
||||
*/
|
||||
private BaseResponse update${table.getCName()}(String jsonString, Token token) {
|
||||
${table.getCName()}UpdateRequest request = MapperUtil.toJava(jsonString, ${table.getCName()}UpdateRequest.class);
|
||||
return ${table.getFName()}Manager.update(request, token);
|
||||
}
|
||||
</#if>
|
||||
<#if table.getFind()>
|
||||
|
||||
/**
|
||||
* 查询${table.tableComment}
|
||||
*/
|
||||
private BaseResponse find${table.getCName()}(String jsonString, Token token) {
|
||||
${table.getCName()}FindRequest request = MapperUtil.toJava(jsonString, ${table.getCName()}FindRequest.class);
|
||||
return ${table.getFName()}Manager.find(request, token);
|
||||
}
|
||||
</#if>
|
||||
<#if table.getGet()>
|
||||
|
||||
/**
|
||||
* 获得${table.tableComment}
|
||||
*/
|
||||
private BaseResponse get${table.getCName()}(String jsonString, Token token) {
|
||||
${table.getCName()}GetRequest request = MapperUtil.toJava(jsonString, ${table.getCName()}GetRequest.class);
|
||||
return ${table.getFName()}Manager.get(request, token);
|
||||
}
|
||||
</#if>
|
||||
<#if table.getSearch()>
|
||||
|
||||
/**
|
||||
* 搜索${table.tableComment}
|
||||
*/
|
||||
private BaseResponse search${table.getCName()}(String jsonString, Token token) {
|
||||
${table.getCName()}SearchRequest request = MapperUtil.toJava(jsonString, ${table.getCName()}SearchRequest.class);
|
||||
return ${table.getFName()}Manager.search(request, token);
|
||||
}
|
||||
</#if>
|
||||
</#list>
|
||||
</#list>
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.example.action;
|
||||
|
||||
import com.example.frame.base.BaseResponse;
|
||||
import com.example.module.wsys.rsp.UserFindResponse;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/feign")
|
||||
public class FeignController {
|
||||
|
||||
@RequestMapping("/{module}/{target}/{method}")
|
||||
public BaseResponse find(
|
||||
@PathVariable String module,
|
||||
@PathVariable String target,
|
||||
@PathVariable String method,
|
||||
@RequestHeader String token,
|
||||
@RequestBody String data) {
|
||||
|
||||
System.out.println("===========");
|
||||
return new UserFindResponse();
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package ${domain}.action.msvr.${module};
|
||||
|
||||
import ${domain}.frame.auth.LocalData;
|
||||
import ${domain}.module.${module}.mgr.${table.getCName()}Manager;
|
||||
<#if table.getCreate()>
|
||||
import ${domain}.module.${module}.req.${table.getCName()}CreateRequest;
|
||||
</#if>
|
||||
<#if table.getDelete()>
|
||||
import ${domain}.module.${module}.req.${table.getCName()}DeleteRequest;
|
||||
</#if>
|
||||
<#if table.getFind()>
|
||||
import ${domain}.module.${module}.req.${table.getCName()}FindRequest;
|
||||
</#if>
|
||||
<#if table.getGet()>
|
||||
import ${domain}.module.${module}.req.${table.getCName()}GetRequest;
|
||||
</#if>
|
||||
<#if table.getSearch()>
|
||||
import ${domain}.module.${module}.req.${table.getCName()}SearchRequest;
|
||||
</#if>
|
||||
<#if table.getUpdate()>
|
||||
import ${domain}.module.${module}.req.${table.getCName()}UpdateRequest;
|
||||
</#if>
|
||||
<#if table.getCreate()>
|
||||
import ${domain}.module.${module}.rsp.${table.getCName()}CreateResponse;
|
||||
</#if>
|
||||
<#if table.getDelete()>
|
||||
import ${domain}.module.${module}.rsp.${table.getCName()}DeleteResponse;
|
||||
</#if>
|
||||
<#if table.getFind()>
|
||||
import ${domain}.module.${module}.rsp.${table.getCName()}FindResponse;
|
||||
</#if>
|
||||
<#if table.getGet()>
|
||||
import ${domain}.module.${module}.rsp.${table.getCName()}GetResponse;
|
||||
</#if>
|
||||
<#if table.getSearch()>
|
||||
import ${domain}.module.${module}.rsp.${table.getCName()}SearchResponse;
|
||||
</#if>
|
||||
<#if table.getUpdate()>
|
||||
import ${domain}.module.${module}.rsp.${table.getCName()}UpdateResponse;
|
||||
</#if>
|
||||
<#list table.methods as item>
|
||||
<#if item.selected>
|
||||
import ${domain}.module.${module}.req.${table.getCName()}${item.getAbbName()?default("")}Request;
|
||||
import ${domain}.module.${module}.rsp.${table.getCName()}${item.getAbbName()?default("")}Response;
|
||||
</#if>
|
||||
</#list>
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class ${table.getCName()}Msvr{
|
||||
|
||||
@Autowired
|
||||
private ${table.getCName()}Manager ${table.getFName()}Manager;
|
||||
|
||||
<#if table.getCreate()>
|
||||
public ${table.getCName()}CreateResponse create(${table.getCName()}CreateRequest request) {
|
||||
return ${table.getFName()}Manager.create(request, LocalData.getToken());
|
||||
}
|
||||
</#if>
|
||||
<#if table.getDelete()>
|
||||
|
||||
public ${table.getCName()}DeleteResponse delete(${table.getCName()}DeleteRequest request) {
|
||||
return ${table.getFName()}Manager.delete(request, LocalData.getToken());
|
||||
}
|
||||
</#if>
|
||||
<#if table.getUpdate()>
|
||||
|
||||
public ${table.getCName()}UpdateResponse update(${table.getCName()}UpdateRequest request) {
|
||||
return ${table.getFName()}Manager.update(request, LocalData.getToken());
|
||||
}
|
||||
</#if>
|
||||
<#if table.getFind()>
|
||||
|
||||
public ${table.getCName()}FindResponse find(${table.getCName()}FindRequest request) {
|
||||
return ${table.getFName()}Manager.find(request, LocalData.getToken());
|
||||
}
|
||||
</#if>
|
||||
<#if table.getGet()>
|
||||
|
||||
public ${table.getCName()}GetResponse get(${table.getCName()}GetRequest request) {
|
||||
return ${table.getFName()}Manager.get(request, LocalData.getToken());
|
||||
}
|
||||
</#if>
|
||||
<#if table.getSearch()>
|
||||
|
||||
public ${table.getCName()}SearchResponse search(${table.getCName()}SearchRequest request) {
|
||||
return ${table.getFName()}Manager.search(request, LocalData.getToken());
|
||||
}
|
||||
</#if>
|
||||
<#list table.methods as item>
|
||||
<#if item.selected>
|
||||
|
||||
public ${table.getCName()}${item.getAbbName()?default("")}Response ${item.name}(${table.getCName()}${item.getAbbName()?default("")}Request request) {
|
||||
return ${table.getFName()}Manager.${item.name}(request, LocalData.getToken());
|
||||
}
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
package ${domain}.module.${moduleName}.svr;
|
||||
|
||||
<#if table.getCreate()>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}CreateRequest;
|
||||
</#if>
|
||||
<#if table.getDelete()>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}DeleteRequest;
|
||||
</#if>
|
||||
<#if table.getFind()>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}FindRequest;
|
||||
</#if>
|
||||
<#if table.getGet()>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}GetRequest;
|
||||
</#if>
|
||||
<#if table.getSearch()>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}SearchRequest;
|
||||
</#if>
|
||||
<#if table.getUpdate()>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}UpdateRequest;
|
||||
</#if>
|
||||
<#if table.getCreate()>
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}CreateResponse;
|
||||
</#if>
|
||||
<#if table.getDelete()>
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}DeleteResponse;
|
||||
</#if>
|
||||
<#if table.getFind()>
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}FindResponse;
|
||||
</#if>
|
||||
<#if table.getGet()>
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}GetResponse;
|
||||
</#if>
|
||||
<#if table.getSearch()>
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}SearchResponse;
|
||||
</#if>
|
||||
<#if table.getUpdate()>
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}UpdateResponse;
|
||||
</#if>
|
||||
<#list table.methods as item>
|
||||
<#if item.selected>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}${item.getAbbName()?default("")}Request;
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}${item.getAbbName()?default("")}Response;
|
||||
</#if>
|
||||
</#list>
|
||||
import ${domain}.frame.auth.Token;
|
||||
|
||||
/**
|
||||
* ${table.tableComment}
|
||||
*
|
||||
* @author ${author?default("")}
|
||||
* @version 0.0.1
|
||||
* @since ${.now?string["yyyy-MM-dd"]}
|
||||
*/
|
||||
public interface ${table.getCName()}Service {
|
||||
<#if table.getCreate()>
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
${table.getCName()}CreateResponse create(${table.getCName()}CreateRequest request, Token token);
|
||||
</#if>
|
||||
<#if table.getDelete()>
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
${table.getCName()}DeleteResponse delete(${table.getCName()}DeleteRequest request, Token token);
|
||||
</#if>
|
||||
<#if table.getUpdate()>
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
${table.getCName()}UpdateResponse update(${table.getCName()}UpdateRequest request, Token token);
|
||||
</#if>
|
||||
<#if table.getFind()>
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
${table.getCName()}FindResponse find(${table.getCName()}FindRequest request, Token token);
|
||||
</#if>
|
||||
<#if table.getSearch()>
|
||||
|
||||
/**
|
||||
* 模糊查询
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
${table.getCName()}SearchResponse search(${table.getCName()}SearchRequest request, Token token);
|
||||
</#if>
|
||||
<#if table.getGet()>
|
||||
|
||||
/**
|
||||
* 获得对象
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
${table.getCName()}GetResponse get(${table.getCName()}GetRequest request, Token token);
|
||||
</#if>
|
||||
<#list table.methods as item>
|
||||
<#if item.selected>
|
||||
|
||||
/**
|
||||
* ${item.note?default("")}
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
${table.getCName()}${item.getAbbName()?default("")}Response ${item.name}(${table.getCName()}${item.getAbbName()?default("")}Request request, Token token);
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
@ -0,0 +1,212 @@
|
||||
package ${domain}.module.${moduleName}.svr;
|
||||
|
||||
import ${domain}.frame.auth.Token;
|
||||
import ${domain}.frame.base.ErrorType;
|
||||
import ${domain}.frame.utils.Message;
|
||||
import ${domain}.frame.utils.ValidationUtil;
|
||||
<#if table.getCreate()>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}CreateRequest;
|
||||
</#if>
|
||||
<#if table.getDelete()>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}DeleteRequest;
|
||||
</#if>
|
||||
<#if table.getFind()>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}FindRequest;
|
||||
</#if>
|
||||
<#if table.getGet()>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}GetRequest;
|
||||
</#if>
|
||||
<#if table.getSearch()>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}SearchRequest;
|
||||
</#if>
|
||||
<#if table.getUpdate()>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}UpdateRequest;
|
||||
</#if>
|
||||
<#if table.getCreate()>
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}CreateResponse;
|
||||
</#if>
|
||||
<#if table.getDelete()>
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}DeleteResponse;
|
||||
</#if>
|
||||
<#if table.getFind()>
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}FindResponse;
|
||||
</#if>
|
||||
<#if table.getGet()>
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}GetResponse;
|
||||
</#if>
|
||||
<#if table.getSearch()>
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}SearchResponse;
|
||||
</#if>
|
||||
<#if table.getUpdate()>
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}UpdateResponse;
|
||||
</#if>
|
||||
<#list table.methods as item>
|
||||
<#if item.selected>
|
||||
import ${domain}.module.${moduleName}.req.${table.getCName()}${item.getAbbName()?default("")}Request;
|
||||
import ${domain}.module.${moduleName}.rsp.${table.getCName()}${item.getAbbName()?default("")}Response;
|
||||
</#if>
|
||||
</#list>
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* ${table.tableComment}
|
||||
*
|
||||
* @author ${author?default("")}
|
||||
* @version 0.0.1
|
||||
* @since ${.now?string["yyyy-MM-dd"]}
|
||||
*/
|
||||
@Service
|
||||
public class ${table.getCName()}ServiceImpl implements ${table.getCName()}Service {
|
||||
|
||||
private final static String SERVICE = "EXAMPLE-WEB";
|
||||
|
||||
private final static String SERVICE_URL = String.format("http://%s/msvr/${moduleName}/${table.getCName()}/", SERVICE);
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
|
||||
<#if table.getCreate()>
|
||||
|
||||
/**
|
||||
* 插入
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
public ${table.getCName()}CreateResponse create(${table.getCName()}CreateRequest request, Token token) {
|
||||
${table.getCName()}CreateResponse response = new ${table.getCName()}CreateResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
try {
|
||||
response = post.postForObject(SERVICE_URL + "create", request, NewTableCreateResponse.class);
|
||||
} catch (RestClientException e) {
|
||||
response.addError(ErrorType.BUSINESS_ERROR, Message.SERVICE_FAILURE);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
</#if>
|
||||
<#if table.getDelete()>
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
public ${table.getCName()}DeleteResponse delete(${table.getCName()}DeleteRequest request, Token token) {
|
||||
${table.getCName()}DeleteResponse response = new ${table.getCName()}DeleteResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
</#if>
|
||||
<#if table.getUpdate()>
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
public ${table.getCName()}UpdateResponse update(${table.getCName()}UpdateRequest request, Token token) {
|
||||
${table.getCName()}UpdateResponse response = new ${table.getCName()}UpdateResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
</#if>
|
||||
<#if table.getFind()>
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
public ${table.getCName()}FindResponse find(${table.getCName()}FindRequest request, Token token) {
|
||||
${table.getCName()}FindResponse response = new ${table.getCName()}FindResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
</#if>
|
||||
<#if table.getGet()>
|
||||
|
||||
/**
|
||||
* 获得对象
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
public ${table.getCName()}GetResponse get(${table.getCName()}GetRequest request, Token token) {
|
||||
${table.getCName()}GetResponse response = new ${table.getCName()}GetResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
</#if>
|
||||
<#if table.getSearch()>
|
||||
|
||||
/**
|
||||
* 模糊查询
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return 响应
|
||||
*/
|
||||
public ${table.getCName()}SearchResponse search(${table.getCName()}SearchRequest request, Token token) {
|
||||
${table.getCName()}SearchResponse response = new ${table.getCName()}SearchResponse();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
</#if>
|
||||
<#list table.methods as item>
|
||||
<#if item.selected>
|
||||
|
||||
/**
|
||||
* ${item.note?default("")}
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param token 令牌
|
||||
* @return
|
||||
*/
|
||||
public ${table.getCName()}${item.getAbbName()?default("")}Response ${item.name}(${table.getCName()}${item.getAbbName()?default("")}Request request, Token token) {
|
||||
${table.getCName()}${item.getAbbName()?default("")}Response response = new ${table.getCName()}${item.getAbbName()?default("")}Response();
|
||||
|
||||
ValidationUtil.validate(request, response);
|
||||
if (response.hasError()) {
|
||||
return response;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package com.example.module.wsys.svr;
|
||||
|
||||
import com.example.frame.auth.Token;
|
||||
import com.example.module.wsys.req.UserFindRequest;
|
||||
import com.example.module.wsys.rsp.UserFindResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
|
||||
@RequestMapping("/user/find")
|
||||
public UserFindResponse find(UserFindRequest request, @RequestParam(name = "token") Token token) {
|
||||
UserFindRequest userFindRequest = new UserFindRequest();
|
||||
userFindRequest.setUserName("AAAAAAAAAAAA");
|
||||
userFindRequest.setPageNumber(2);
|
||||
|
||||
//请求地址
|
||||
String url = "http://EXAMPLE-WEB/feign/wsys/user/find";
|
||||
//入参
|
||||
|
||||
UserFindResponse userFindResponse = restTemplate.postForObject(url, userFindRequest, UserFindResponse.class);
|
||||
return userFindResponse;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue