|
|
@ -2,10 +2,21 @@ package ${basePackage}.action.ajax.${module};
|
|
|
|
|
|
|
|
|
|
|
|
import ${basePackage}.frame.auth.LocalData;
|
|
|
|
import ${basePackage}.frame.auth.LocalData;
|
|
|
|
import ${basePackage}.frame.utils.MapperUtil;
|
|
|
|
import ${basePackage}.frame.utils.MapperUtil;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.utils.ResponseUtil;
|
|
|
|
import ${basePackage}.module.${module}.mgr.${table.getCName()}Manager;
|
|
|
|
import ${basePackage}.module.${module}.mgr.${table.getCName()}Manager;
|
|
|
|
|
|
|
|
import ${basePackage}.module.${module}.ent.${table.getCName()};
|
|
|
|
import ${basePackage}.module.${module}.req.*;
|
|
|
|
import ${basePackage}.module.${module}.req.*;
|
|
|
|
import ${basePackage}.module.${module}.rsp.*;
|
|
|
|
import ${basePackage}.module.${module}.rsp.*;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.base.BaseResponse;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.base.ErrorType;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.excel.WSheet;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.excel.exception.ReadErrorException;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.excel.exception.TemplateNotMatchException;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.TreeNode;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
|
|
public class ${table.getCName()}Ajax{
|
|
|
|
public class ${table.getCName()}Ajax{
|
|
|
|
|
|
|
|
|
|
|
@ -13,84 +24,75 @@ public class ${table.getCName()}Ajax{
|
|
|
|
private ${table.getCName()}Manager ${table.getFName()}Manager;
|
|
|
|
private ${table.getCName()}Manager ${table.getFName()}Manager;
|
|
|
|
|
|
|
|
|
|
|
|
<#if table.getCreate()>
|
|
|
|
<#if table.getCreate()>
|
|
|
|
public ${table.getCName()}CreateResponse create(String jsonParam) {
|
|
|
|
public ${table.getCName()}CreateResponse create(TreeNode jsonParam) {
|
|
|
|
${table.getCName()}CreateRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}CreateRequest.class);
|
|
|
|
${table.getCName()}CreateRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}CreateRequest.class);
|
|
|
|
return ${table.getFName()}Manager.create(request, LocalData.getToken());
|
|
|
|
return ${table.getFName()}Manager.create(request, LocalData.getToken());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</#if>
|
|
|
|
</#if>
|
|
|
|
<#if table.getDelete()>
|
|
|
|
<#if table.getDelete()>
|
|
|
|
|
|
|
|
|
|
|
|
public ${table.getCName()}DeleteResponse delete(String jsonParam) {
|
|
|
|
public ${table.getCName()}DeleteResponse delete(TreeNode jsonParam) {
|
|
|
|
${table.getCName()}DeleteRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}DeleteRequest.class);
|
|
|
|
${table.getCName()}DeleteRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}DeleteRequest.class);
|
|
|
|
return ${table.getFName()}Manager.delete(request, LocalData.getToken());
|
|
|
|
return ${table.getFName()}Manager.delete(request, LocalData.getToken());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</#if>
|
|
|
|
</#if>
|
|
|
|
<#if table.getUpdate()>
|
|
|
|
<#if table.getUpdate()>
|
|
|
|
|
|
|
|
|
|
|
|
public ${table.getCName()}UpdateResponse update(String jsonParam) {
|
|
|
|
public ${table.getCName()}UpdateResponse update(TreeNode jsonParam) {
|
|
|
|
${table.getCName()}UpdateRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}UpdateRequest.class);
|
|
|
|
${table.getCName()}UpdateRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}UpdateRequest.class);
|
|
|
|
return ${table.getFName()}Manager.update(request, LocalData.getToken());
|
|
|
|
return ${table.getFName()}Manager.update(request, LocalData.getToken());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</#if>
|
|
|
|
</#if>
|
|
|
|
<#if table.getFind()>
|
|
|
|
<#if table.getFind()>
|
|
|
|
|
|
|
|
|
|
|
|
public ${table.getCName()}FindResponse find(String jsonParam) {
|
|
|
|
public ${table.getCName()}FindResponse find(TreeNode jsonParam) {
|
|
|
|
${table.getCName()}FindRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}FindRequest.class);
|
|
|
|
${table.getCName()}FindRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}FindRequest.class);
|
|
|
|
return ${table.getFName()}Manager.find(request, LocalData.getToken());
|
|
|
|
return ${table.getFName()}Manager.find(request, LocalData.getToken());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</#if>
|
|
|
|
</#if>
|
|
|
|
<#if table.getGet()>
|
|
|
|
<#if table.getGet()>
|
|
|
|
|
|
|
|
|
|
|
|
public ${table.getCName()}GetResponse get(String jsonParam) {
|
|
|
|
public ${table.getCName()}GetResponse get(TreeNode jsonParam) {
|
|
|
|
${table.getCName()}GetRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}GetRequest.class);
|
|
|
|
${table.getCName()}GetRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}GetRequest.class);
|
|
|
|
return ${table.getFName()}Manager.get(request, LocalData.getToken());
|
|
|
|
return ${table.getFName()}Manager.get(request, LocalData.getToken());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</#if>
|
|
|
|
</#if>
|
|
|
|
<#if table.getSearch()>
|
|
|
|
<#if table.getSearch()>
|
|
|
|
|
|
|
|
|
|
|
|
public ${table.getCName()}SearchResponse search(String jsonParam) {
|
|
|
|
public ${table.getCName()}SearchResponse search(TreeNode jsonParam) {
|
|
|
|
${table.getCName()}SearchRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}SearchRequest.class);
|
|
|
|
${table.getCName()}SearchRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}SearchRequest.class);
|
|
|
|
return ${table.getFName()}Manager.search(request, LocalData.getToken());
|
|
|
|
return ${table.getFName()}Manager.search(request, LocalData.getToken());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</#if>
|
|
|
|
</#if>
|
|
|
|
<#if table.getGetAll()>
|
|
|
|
<#if table.getGetAll()>
|
|
|
|
|
|
|
|
|
|
|
|
public ${table.getCName()}GetAllResponse getAll(String jsonParam) {
|
|
|
|
public ${table.getCName()}GetAllResponse getAll(TreeNode jsonParam) {
|
|
|
|
${table.getCName()}GetAllRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}GetAllRequest.class);
|
|
|
|
${table.getCName()}GetAllRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}GetAllRequest.class);
|
|
|
|
return ${table.getFName()}Manager.getAll(request, LocalData.getToken());
|
|
|
|
return ${table.getFName()}Manager.getAll(request, LocalData.getToken());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</#if>
|
|
|
|
</#if>
|
|
|
|
<#if table.getHtml()>
|
|
|
|
<#if table.getHtml()>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Object template(){
|
|
|
|
public Object template(){
|
|
|
|
try {
|
|
|
|
return ResponseUtil.apply(new WSheet<>(${table.getCName()}.class));
|
|
|
|
WSheet<DictItemCreateRequest> sheet = new WSheet<>(DictItemCreateRequest.class);
|
|
|
|
|
|
|
|
byte[] bytes = sheet.getBytes();
|
|
|
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
|
|
|
|
|
|
|
headers.setContentDispositionFormData("attachment", URLEncoder.encode(sheet.getName() + ".xlsx","utf-8"));
|
|
|
|
|
|
|
|
return new ResponseEntity<>(bytes, headers, HttpStatus.OK);
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
|
|
|
|
|
baseResponse.addError(ErrorType.BUSINESS_ERROR, "");
|
|
|
|
|
|
|
|
return baseResponse;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Object exports(TreeNode jsonParam) {
|
|
|
|
|
|
|
|
${table.getCName()}FindRequest request = MapperUtil.toJava(jsonParam, ${table.getCName()}FindRequest.class);
|
|
|
|
|
|
|
|
${table.getCName()}FindResponse response = ${table.getFName()}Manager.find(request, LocalData.getToken());
|
|
|
|
|
|
|
|
if (response.hasError()) {
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ResponseUtil.apply(new WSheet<>(response.getResult()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Object imports(MultipartFile file) {
|
|
|
|
public Object imports(MultipartFile file) {
|
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
byte[] bytes = file.getBytes();
|
|
|
|
WSheet<${table.getCName()}> sheet = new WSheet<>(file.getBytes(), ${table.getCName()}.class);
|
|
|
|
|
|
|
|
|
|
|
|
WSheet<DictCreateRequest> sheet = new WSheet<>(bytes, DictCreateRequest.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sheet.hasError()) {
|
|
|
|
if (sheet.hasError()) {
|
|
|
|
byte[] sheetBytes = sheet.getBytes(true);
|
|
|
|
return ResponseUtil.apply(sheet.getBytes(), sheet.getName() + "-err.xlsx");
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
|
|
|
|
|
|
|
headers.setContentDispositionFormData("attachment", URLEncoder.encode(sheet.getName() + "-err.xlsx","utf-8"));
|
|
|
|
|
|
|
|
return new ResponseEntity<>(sheetBytes, headers, HttpStatus.OK);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return baseResponse;
|
|
|
|
return baseResponse;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -99,7 +101,6 @@ public class ${table.getCName()}Ajax{
|
|
|
|
} catch (TemplateNotMatchException | ReadErrorException e) {
|
|
|
|
} catch (TemplateNotMatchException | ReadErrorException e) {
|
|
|
|
baseResponse.addError(ErrorType.BUSINESS_ERROR, e.getMessage());
|
|
|
|
baseResponse.addError(ErrorType.BUSINESS_ERROR, e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return baseResponse;
|
|
|
|
return baseResponse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</#if>
|
|
|
|
</#if>
|
|
|
|