feat: 提交项目代码

This commit is contained in:
super_liu
2021-05-31 14:56:05 +08:00
parent d50bb875cb
commit 3ed9ca235a
234 changed files with 27792 additions and 0 deletions
@@ -0,0 +1,6 @@
package com.adc.da.base.entity;
public class BaseEntity {
public BaseEntity() {
}
}
@@ -0,0 +1,72 @@
package com.adc.da.base.entity;
import java.util.List;
public abstract class TreeEntity<T extends TreeEntity> extends BaseEntity {
protected String id;
protected String name;
protected String parentId;
protected String parentIds;
protected T parent;
protected List<T> childList;
protected Integer delFlag;
public TreeEntity() {
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getParentId() {
return this.parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getParentIds() {
return this.parentIds;
}
public void setParentIds(String parentIds) {
this.parentIds = parentIds;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public List<T> getChildList() {
return this.childList;
}
public void setChildList(List<T> childList) {
this.childList = childList;
}
public T getParent() {
return this.parent;
}
public void setParent(T parent) {
this.parent = parent;
}
public Integer getDelFlag() {
return this.delFlag;
}
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
}
@@ -0,0 +1,91 @@
package com.adc.da.base.page;
public class BasePage {
private Integer page = 1;
private Integer pageSize = 20;
private Integer startIndex;
private Integer endIndex;
private String orderBy;
private String order;
private String q;
private Pager pager = new Pager();
public BasePage() {
}
public Pager getPager() {
this.pager.setPageId(this.getPage());
this.pager.setPageSize(this.getPageSize());
String orderField = "";
if (this.orderBy != null && this.orderBy.trim().length() > 0) {
orderField = this.orderBy;
}
if (orderField.trim().length() > 0 && this.order != null && this.order.trim().length() > 0) {
orderField = orderField + " " + this.order;
}
this.pager.setOrderField(orderField);
return this.pager;
}
public void setPager(Pager pager) {
this.pager = pager;
}
public Integer getPage() {
return this.page;
}
public void setPage(Integer page) {
this.page = page;
}
public Integer getPageSize() {
return this.pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public String getOrderBy() {
return this.orderBy;
}
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
public String getOrder() {
return this.order;
}
public void setOrder(String order) {
this.order = order;
}
public String getQ() {
return this.q;
}
public void setQ(String q) {
this.q = q;
}
public Integer getStartIndex() {
return this.startIndex;
}
public void setStartIndex(Integer startIndex) {
this.startIndex = (this.page - 1) * this.pageSize + 1;
}
public Integer getEndIndex() {
return this.endIndex;
}
public void setEndIndex(Integer endIndex) {
this.endIndex = this.page * this.pageSize;
}
}
@@ -0,0 +1,169 @@
package com.adc.da.base.page;
public class Pager {
private int pageId = 1;
private int rowCount = 0;
private int pageSize = 10;
private int pageCount = 0;
private int pageOffset = 0;
private int pageTail = 0;
private String orderField;
private boolean orderDirection = true;
private boolean pageEnabled = true;
private int length = 6;
private int startIndex = 0;
private int endIndex = 0;
private int[] indexs;
public Pager() {
}
public int getLength() {
return this.length;
}
public void setLength(int length) {
this.length = length;
}
public int[] getIndexs() {
int len = this.getEndIndex() - this.getStartIndex() + 1;
this.indexs = new int[len];
for(int i = 0; i < len; ++i) {
this.indexs[i] = this.getStartIndex() + i;
}
return this.indexs;
}
public void setIndexs(int[] indexs) {
this.indexs = indexs;
}
public int getStartIndex() {
this.startIndex = (this.pageId - 1) * this.pageSize + 1;
return this.startIndex;
}
public void setStartIndex(int startIndex) {
System.out.println("startIndx:" + this.pageId + ":" + this.pageSize);
this.startIndex = (this.pageId - 1) * this.pageSize + 1;
}
public int getEndIndex() {
this.endIndex = this.pageId * this.pageSize;
return this.endIndex;
}
public void setEndIndex(int endIndex) {
this.endIndex = this.pageId * this.pageSize;
}
protected void doPage() {
this.pageCount = this.rowCount / this.pageSize + 1;
if (this.rowCount % this.pageSize == 0 && this.pageCount > 1) {
--this.pageCount;
}
this.pageOffset = (this.pageId - 1) * this.pageSize;
this.pageTail = this.pageOffset + this.pageSize;
if (this.pageOffset + this.pageSize > this.rowCount) {
this.pageTail = this.rowCount;
}
}
public String getOrderCondition() {
String condition = "";
if (this.orderField != null && this.orderField.length() != 0) {
condition = " order by " + this.orderField + (this.orderDirection ? " " : " desc ");
}
return condition;
}
public String getMysqlQueryCondition() {
String condition = "";
if (this.pageEnabled) {
}
return condition;
}
public void setOrderDirection(boolean orderDirection) {
this.orderDirection = orderDirection;
}
public boolean isOrderDirection() {
return this.orderDirection;
}
public void setOrderField(String orderField) {
this.orderField = orderField;
}
public String getOrderField() {
return this.orderField;
}
public void setPageCount(int pageCount) {
this.pageCount = pageCount;
}
public int getPageCount() {
return this.pageCount;
}
public void setPageId(int pageId) {
this.pageId = pageId;
}
public int getPageId() {
return this.pageId;
}
public void setPageOffset(int pageOffset) {
this.pageOffset = pageOffset;
}
public int getPageOffset() {
return this.pageOffset;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPageSize() {
return this.pageSize;
}
public void setPageTail(int pageTail) {
this.pageTail = pageTail;
}
public int getPageTail() {
return this.pageTail;
}
public void setRowCount(int rowCount) {
this.rowCount = rowCount;
this.doPage();
}
public int getRowCount() {
return this.rowCount;
}
public boolean isPageEnabled() {
return this.pageEnabled;
}
public void setPageEnabled(boolean pageEnabled) {
this.pageEnabled = pageEnabled;
}
}
@@ -0,0 +1,81 @@
package com.adc.da.base.web;
import com.adc.da.base.page.Pager;
import com.adc.da.http.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class BaseController<T> {
private static final String DATA = "data";
private static final String TOTAL = "total";
protected BaseController() {
}
public PageInfo<T> getPageInfo(Pager pager, List<T> rows) {
PageInfo<T> pageInfo = new PageInfo();
pageInfo.setList(rows);
pageInfo.setCount((long)pager.getRowCount());
pageInfo.setPageSize(pager.getPageSize());
pageInfo.setPageCount((long)pager.getPageCount());
pageInfo.setPageNo(pager.getPageId());
return pageInfo;
}
public static Map<String, Object> getGridData(int total, List<?> rows) {
Map<String, Object> response = new HashMap();
response.put("total", total);
response.put("data", rows);
return response;
}
public static Map<String, Object> getData(Object data) {
Map<String, Object> response = new HashMap();
response.put("data", data);
return response;
}
public static void download(HttpServletResponse response, File file) throws IOException {
download(response, file, file.getName());
}
public static void download(HttpServletResponse response, File file, String fileName) throws IOException {
FileInputStream in = new FileInputStream(file);
Throwable var4 = null;
try {
download(response, (InputStream)in, fileName);
} catch (Throwable var13) {
var4 = var13;
throw var13;
} finally {
if (in != null) {
if (var4 != null) {
try {
in.close();
} catch (Throwable var12) {
var4.addSuppressed(var12);
}
} else {
in.close();
}
}
}
}
public static void download(HttpServletResponse response, InputStream in, String fileName) throws IOException {
response.setContentType("application/x-msdownload;");
response.addHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
response.setCharacterEncoding("UTF-8");
}
}