mirror of
https://gitee.com/EMF/solon-manager.git
synced 2025-12-06 08:48:33 +08:00
feat: cms
This commit is contained in:
parent
a151fb4306
commit
a576a7452a
@ -33,14 +33,130 @@
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-logging-logback</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>activerecord-solon-plugin</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>3.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<version>1.9.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-net</groupId>
|
||||
<artifactId>commons-net</artifactId>
|
||||
<version>3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-jexl</groupId>
|
||||
<artifactId>commons-jexl</artifactId>
|
||||
<version>1.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<artifactId>ehcache-core</artifactId>
|
||||
<version>2.6.11</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<artifactId>ehcache-web</artifactId>
|
||||
<version>2.0.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>3.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.8.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>1.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<version>4.4.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
package vip.fuck.sm.plugins.cms;
|
||||
|
||||
import org.noear.solon.Solon;
|
||||
import org.noear.solon.annotation.SolonMain;
|
||||
|
||||
//@SolonMain
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
Solon.start(App.class, args);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,168 @@
|
||||
|
||||
package vip.fuck.sm.plugins.cms;
|
||||
|
||||
import com.jfinal.kit.PathKit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
public class ClassScaner {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ClassScaner.class);
|
||||
|
||||
public static <T extends Annotation> List<Class<T>> scanAnnotationClass(Class<T> annotationClass) {
|
||||
if (annotationClass == null) {
|
||||
log.error("annotationClass: annotationClass is null");
|
||||
return null;
|
||||
}
|
||||
|
||||
List<File> classFileList = new ArrayList<File>();
|
||||
scanClass(classFileList, PathKit.getRootClassPath());
|
||||
|
||||
List<Class<T>> classList = new ArrayList<Class<T>>();
|
||||
for (File file : classFileList) {
|
||||
|
||||
int start = PathKit.getRootClassPath().length();
|
||||
int end = file.toString().length() - 6; // 6 == ".class".length();
|
||||
|
||||
String classFile = file.toString().substring(start + 1, end);
|
||||
Class<T> clazz = classForName(classFile.replace(File.separator, "."));
|
||||
|
||||
if (clazz != null && clazz.getAnnotation(annotationClass)!=null) {
|
||||
classList.add(clazz);
|
||||
}
|
||||
}
|
||||
return classList;
|
||||
}
|
||||
|
||||
public static <T> List<Class<T>> scanSubClass(Class<T> pclazz, boolean mustbeCanNewInstance,boolean scanLib) {
|
||||
if (pclazz == null) {
|
||||
log.error("scanClass: parent clazz is null");
|
||||
return null;
|
||||
}
|
||||
List<File> classFileList = new ArrayList<File>();
|
||||
scanClass(classFileList, PathKit.getRootClassPath());
|
||||
|
||||
List<Class<T>> classList = new ArrayList<Class<T>>();
|
||||
for (File file : classFileList) {
|
||||
|
||||
int start = PathKit.getRootClassPath().length();
|
||||
int end = file.toString().length() - 6; // 6 == ".class".length();
|
||||
|
||||
String classFile = file.toString().substring(start + 1, end);
|
||||
Class<T> clazz = classForName(classFile.replace(File.separator, "."));
|
||||
|
||||
if (clazz != null && pclazz.isAssignableFrom(clazz)) {
|
||||
if (mustbeCanNewInstance) {
|
||||
if (clazz.isInterface())
|
||||
continue;
|
||||
|
||||
if (Modifier.isAbstract(clazz.getModifiers()))
|
||||
continue;
|
||||
}
|
||||
classList.add(clazz);
|
||||
}
|
||||
}
|
||||
//扫描lib目录
|
||||
if(scanLib){
|
||||
File jarsDir = new File(PathKit.getWebRootPath() + "/WEB-INF/lib");
|
||||
if (jarsDir.exists() && jarsDir.isDirectory()) {
|
||||
File[] jarFiles = jarsDir.listFiles(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
String name = pathname.getName().toLowerCase();
|
||||
return name.endsWith(".jar") && name.startsWith("cms");
|
||||
}
|
||||
});
|
||||
|
||||
if (jarFiles != null && jarFiles.length > 0) {
|
||||
for (File f : jarFiles) {
|
||||
try {
|
||||
classList.addAll(scanSubClass(pclazz, new JarFile(f), mustbeCanNewInstance));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return classList;
|
||||
}
|
||||
|
||||
public static <T> List<Class<T>> scanSubClass(Class<T> pclazz, JarFile jarFile, boolean mustbeCanNewInstance) {
|
||||
if (pclazz == null) {
|
||||
log.error("scanClass: parent clazz is null");
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Class<T>> classList = new ArrayList<Class<T>>();
|
||||
Enumeration<JarEntry> entries = jarFile.entries();
|
||||
|
||||
while (entries.hasMoreElements()) {
|
||||
JarEntry jarEntry = entries.nextElement();
|
||||
String entryName = jarEntry.getName();
|
||||
if (!jarEntry.isDirectory() && entryName.endsWith(".class")) {
|
||||
// String className = entryName.replace(File.separator, ".").substring(0, entryName.length() - 6);
|
||||
String className = entryName.replace("/", ".").substring(0, entryName.length() - 6);
|
||||
Class<T> clazz = classForName(className);
|
||||
if (clazz != null && pclazz.isAssignableFrom(clazz)) {
|
||||
if (mustbeCanNewInstance) {
|
||||
if (clazz.isInterface())
|
||||
continue;
|
||||
|
||||
if (Modifier.isAbstract(clazz.getModifiers()))
|
||||
continue;
|
||||
}
|
||||
classList.add(clazz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
jarFile.close();
|
||||
} catch (IOException e) {
|
||||
log.error("jarFile.close is error",e);
|
||||
}
|
||||
|
||||
return classList;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> Class<T> classForName(String className) {
|
||||
Class<T> clazz = null;
|
||||
try {
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
clazz = (Class<T>) Class.forName(className, false, cl);
|
||||
} catch (Throwable e) {
|
||||
log.error("classForName is error,className:"+className);
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
|
||||
private static void scanClass(List<File> fileList, String path) {
|
||||
File files[] = new File(path).listFiles();
|
||||
if (null == files || files.length == 0)
|
||||
return;
|
||||
for (File file : files) {
|
||||
if (file.isDirectory()) {
|
||||
scanClass(fileList, file.getAbsolutePath());
|
||||
} else if (file.getName().endsWith(".class")) {
|
||||
fileList.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms;
|
||||
|
||||
/**
|
||||
* 公共参数
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class CommonAttribute {
|
||||
|
||||
/** UTF-8编码 */
|
||||
public static final String UTF_8 = "UTF-8";
|
||||
|
||||
/** POST */
|
||||
public static final String POST="post";
|
||||
|
||||
/** GET */
|
||||
public static final String GET="get";
|
||||
|
||||
/** 后台页面 */
|
||||
public static final String ADMIN_PATH="/admin/view/";
|
||||
|
||||
/** 后台错误页面 */
|
||||
public static final String ADMIN_ERROR_VIEW = ADMIN_PATH+"error/500.html";
|
||||
|
||||
/** 后台权限错误页面 */
|
||||
public static final String ADMIN_UNAUTHORIZED_VIEW = ADMIN_PATH+"error/403.html";
|
||||
|
||||
/** 前台错误页面 */
|
||||
public static final String FRONT_ERROR_VIEW = "/500.html";
|
||||
|
||||
/** 前台权限错误页面 */
|
||||
public static final String FRONT_RESOURCE_NOT_FOUND_VIEW = "/404.html";
|
||||
|
||||
/** config.xml文件路径 */
|
||||
public static final String CONFIG_XML_PATH = "/config.xml";
|
||||
|
||||
/** config.properties */
|
||||
public static final String CONFIG_PROPERTIES = "config.properties";
|
||||
|
||||
/** job.properties */
|
||||
public static final String JOB_PROPERTIES = "job.properties";
|
||||
|
||||
/** 页面后缀 */
|
||||
public static final String VIEW_EXTENSION = ".html";
|
||||
|
||||
/** 参数分隔符 */
|
||||
public static final String URL_PARA_SEPARATOR = "-";
|
||||
|
||||
/** 上传文件目录 */
|
||||
public static final String UPLOAD_PATH = "static/upload";
|
||||
|
||||
/** 备份文件目录 */
|
||||
public static final String BACK_PATH = "static/back";
|
||||
|
||||
/** JSON时间格式 */
|
||||
public static final String JSON_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
/**
|
||||
* 不可实例化
|
||||
*/
|
||||
private CommonAttribute() {
|
||||
}
|
||||
}
|
||||
101
plugins/cms/src/main/java/vip/fuck/sm/plugins/cms/Config.java
Normal file
101
plugins/cms/src/main/java/vip/fuck/sm/plugins/cms/Config.java
Normal file
@ -0,0 +1,101 @@
|
||||
package vip.fuck.sm.plugins.cms;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Config implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1012463140749529805L;
|
||||
|
||||
/** 缓存名称 */
|
||||
public static final String CACHE_NAME = "config";
|
||||
|
||||
/**
|
||||
* 网站模式
|
||||
*/
|
||||
public enum SiteModel{
|
||||
DYNAMIC("动态"),
|
||||
REWRITE("伪静态"),
|
||||
HTML("静态");
|
||||
public String text;
|
||||
SiteModel(String text){
|
||||
this.text = text;
|
||||
}
|
||||
public String getText(){
|
||||
return this.text;
|
||||
}
|
||||
public static Map<Integer, SiteModel> siteModelValueMap = new HashMap<>();
|
||||
static {
|
||||
SiteModel[] values = SiteModel.values();
|
||||
for (SiteModel siteModel : values) {
|
||||
siteModelValueMap.put(siteModel.ordinal(), siteModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 是否水印开启 */
|
||||
private Boolean isWatermarkEnabled;
|
||||
|
||||
/** 水印图片 */
|
||||
private String watermarkImage;
|
||||
|
||||
/** 水印位置 */
|
||||
private String watermarkPosition;
|
||||
|
||||
/** 是否开启缓存 */
|
||||
private Boolean isCacheEnabled;
|
||||
|
||||
/** 网站模式 */
|
||||
private Integer siteModel;
|
||||
|
||||
String domain;
|
||||
|
||||
public Boolean getIsWatermarkEnabled() {
|
||||
return isWatermarkEnabled;
|
||||
}
|
||||
|
||||
public void setIsWatermarkEnabled(Boolean isWatermarkEnabled) {
|
||||
this.isWatermarkEnabled = isWatermarkEnabled;
|
||||
}
|
||||
|
||||
public String getWatermarkImage() {
|
||||
return watermarkImage;
|
||||
}
|
||||
|
||||
public void setWatermarkImage(String watermarkImage) {
|
||||
this.watermarkImage = watermarkImage;
|
||||
}
|
||||
|
||||
public String getWatermarkPosition() {
|
||||
return watermarkPosition;
|
||||
}
|
||||
|
||||
public void setWatermarkPosition(String watermarkPosition) {
|
||||
this.watermarkPosition = watermarkPosition;
|
||||
}
|
||||
|
||||
public Boolean getIsCacheEnabled() {
|
||||
return isCacheEnabled;
|
||||
}
|
||||
|
||||
public void setIsCacheEnabled(Boolean isCacheEnabled) {
|
||||
this.isCacheEnabled = isCacheEnabled;
|
||||
}
|
||||
|
||||
public Integer getSiteModel() {
|
||||
return siteModel;
|
||||
}
|
||||
|
||||
public void setSiteModel(Integer siteModel) {
|
||||
this.siteModel = siteModel;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
}
|
||||
407
plugins/cms/src/main/java/vip/fuck/sm/plugins/cms/ExcelView.java
Normal file
407
plugins/cms/src/main/java/vip/fuck/sm/plugins/cms/ExcelView.java
Normal file
@ -0,0 +1,407 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms;
|
||||
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.commons.beanutils.ConvertUtils;
|
||||
import org.apache.commons.beanutils.Converter;
|
||||
import org.apache.commons.beanutils.PropertyUtils;
|
||||
import org.apache.commons.beanutils.converters.DateConverter;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import org.apache.poi.hssf.util.HSSFColor;
|
||||
import org.smartboot.http.server.HttpRequest;
|
||||
import org.smartboot.http.server.HttpResponse;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Excel视图
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ExcelView {
|
||||
|
||||
/** 默认日期格式配比 */
|
||||
private static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
/** 文件名称 */
|
||||
private String filename;
|
||||
|
||||
/** 表名称 */
|
||||
private String sheetName;
|
||||
|
||||
/** 属性 */
|
||||
private String[] properties;
|
||||
|
||||
/** 标题 */
|
||||
private String[] titles;
|
||||
|
||||
/** 列宽 */
|
||||
private Integer[] widths;
|
||||
|
||||
/** 类型转换 */
|
||||
private Converter[] converters;
|
||||
|
||||
/** 数据 */
|
||||
private Collection<?> data;
|
||||
|
||||
/** 附加内容 */
|
||||
private String[] contents;
|
||||
|
||||
static {
|
||||
DateConverter dateConverter = new DateConverter();
|
||||
dateConverter.setPattern(DEFAULT_DATE_PATTERN);
|
||||
ConvertUtils.register(dateConverter, Date.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*
|
||||
* @param filename
|
||||
* 文件名称
|
||||
* @param sheetName
|
||||
* 表名称
|
||||
* @param properties
|
||||
* 属性
|
||||
* @param titles
|
||||
* 标题
|
||||
* @param widths
|
||||
* 列宽
|
||||
* @param converters
|
||||
* 类型转换
|
||||
* @param data
|
||||
* 数据
|
||||
* @param contents
|
||||
* 附加内容
|
||||
*/
|
||||
public ExcelView(String filename, String sheetName, String[] properties, String[] titles, Integer[] widths, Converter[] converters, Collection<?> data, String[] contents) {
|
||||
this.filename = filename;
|
||||
this.sheetName = sheetName;
|
||||
this.properties = properties;
|
||||
this.titles = titles;
|
||||
this.widths = widths;
|
||||
this.converters = converters;
|
||||
this.data = data;
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*
|
||||
* @param properties
|
||||
* 属性
|
||||
* @param titles
|
||||
* 标题
|
||||
* @param data
|
||||
* 数据
|
||||
* @param contents
|
||||
* 附加内容
|
||||
*/
|
||||
public ExcelView(String[] properties, String[] titles, Collection<?> data, String[] contents) {
|
||||
this.properties = properties;
|
||||
this.titles = titles;
|
||||
this.data = data;
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*
|
||||
* @param properties
|
||||
* 属性
|
||||
* @param titles
|
||||
* 标题
|
||||
* @param data
|
||||
* 数据
|
||||
*/
|
||||
public ExcelView(String[] properties, String[] titles, Collection<?> data) {
|
||||
this.properties = properties;
|
||||
this.titles = titles;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*
|
||||
* @param properties
|
||||
* 属性
|
||||
* @param data
|
||||
* 数据
|
||||
*/
|
||||
public ExcelView(String[] properties, Collection<?> data) {
|
||||
this.properties = properties;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成Excel文档
|
||||
*
|
||||
* model
|
||||
* 数据
|
||||
* workbook
|
||||
* HSSFWorkbook
|
||||
* @param request
|
||||
* HttpServletRequest
|
||||
* @param response
|
||||
* HttpServletResponse
|
||||
*/
|
||||
public void buildExcelDocument(HttpRequest request, HttpResponse response) throws Exception {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
HSSFSheet sheet;
|
||||
if (StringUtils.isNotEmpty(sheetName)) {
|
||||
sheet = workbook.createSheet(sheetName);
|
||||
} else {
|
||||
sheet = workbook.createSheet();
|
||||
}
|
||||
int rowNumber = 0;
|
||||
if (titles != null && titles.length > 0) {
|
||||
HSSFRow header = sheet.createRow(rowNumber);
|
||||
header.setHeight((short) 400);
|
||||
for (int i = 0; i < properties.length; i++) {
|
||||
HSSFCell cell = header.createCell(i);
|
||||
HSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
cellStyle.setFillForegroundColor(HSSFColor.LIGHT_CORNFLOWER_BLUE.index);
|
||||
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
|
||||
cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
||||
cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
|
||||
HSSFFont font = workbook.createFont();
|
||||
font.setFontHeightInPoints((short) 11);
|
||||
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
|
||||
cellStyle.setFont(font);
|
||||
cell.setCellStyle(cellStyle);
|
||||
if (i == 0) {
|
||||
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
|
||||
HSSFComment comment = patriarch.createComment(new HSSFClientAnchor(0, 0, 0, 0, (short) 1, 1, (short) 4, 4));
|
||||
comment.setString(new HSSFRichTextString("jrecms"));
|
||||
cell.setCellComment(comment);
|
||||
}
|
||||
if (titles.length > i && titles[i] != null) {
|
||||
cell.setCellValue(titles[i]);
|
||||
} else {
|
||||
cell.setCellValue(properties[i]);
|
||||
}
|
||||
if (widths != null && widths.length > i && widths[i] != null) {
|
||||
sheet.setColumnWidth(i, widths[i]);
|
||||
} else {
|
||||
sheet.autoSizeColumn(i);
|
||||
}
|
||||
}
|
||||
rowNumber++;
|
||||
}
|
||||
if (data != null) {
|
||||
for (Object item : data) {
|
||||
HSSFRow row = sheet.createRow(rowNumber);
|
||||
for (int i = 0; i < properties.length; i++) {
|
||||
HSSFCell cell = row.createCell(i);
|
||||
if (converters != null && converters.length > i && converters[i] != null) {
|
||||
Class<?> clazz = PropertyUtils.getPropertyType(item, properties[i]);
|
||||
ConvertUtils.register(converters[i], clazz);
|
||||
cell.setCellValue(BeanUtils.getProperty(item, properties[i]));
|
||||
ConvertUtils.deregister(clazz);
|
||||
if (clazz.equals(Date.class)) {
|
||||
DateConverter dateConverter = new DateConverter();
|
||||
dateConverter.setPattern(DEFAULT_DATE_PATTERN);
|
||||
ConvertUtils.register(dateConverter, Date.class);
|
||||
}
|
||||
} else {
|
||||
cell.setCellValue(BeanUtils.getProperty(item, properties[i]));
|
||||
}
|
||||
if (rowNumber == 0 || rowNumber == 1) {
|
||||
if (widths != null && widths.length > i && widths[i] != null) {
|
||||
sheet.setColumnWidth(i, widths[i]);
|
||||
} else {
|
||||
sheet.autoSizeColumn(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
rowNumber++;
|
||||
}
|
||||
}
|
||||
if (contents != null && contents.length > 0) {
|
||||
rowNumber++;
|
||||
for (String content : contents) {
|
||||
HSSFRow row = sheet.createRow(rowNumber);
|
||||
HSSFCell cell = row.createCell(0);
|
||||
HSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
HSSFFont font = workbook.createFont();
|
||||
font.setColor(HSSFColor.GREY_50_PERCENT.index);
|
||||
cellStyle.setFont(font);
|
||||
cell.setCellStyle(cellStyle);
|
||||
cell.setCellValue(content);
|
||||
rowNumber++;
|
||||
}
|
||||
}
|
||||
response.setContentType("application/force-download");
|
||||
if (StringUtils.isNotEmpty(filename)) {
|
||||
response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(filename, "UTF-8"));
|
||||
} else {
|
||||
response.setHeader("Content-disposition", "attachment");
|
||||
}
|
||||
OutputStream ouputStream = response.getOutputStream();
|
||||
workbook.write(ouputStream);
|
||||
ouputStream.flush();
|
||||
ouputStream.close();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件名称
|
||||
*
|
||||
* @return 文件名称
|
||||
*/
|
||||
public String getFileName() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置文件名称
|
||||
*
|
||||
* @param filename
|
||||
* 文件名称
|
||||
*/
|
||||
public void setFileName(String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表名称
|
||||
*
|
||||
* @return 表名称
|
||||
*/
|
||||
public String getSheetName() {
|
||||
return sheetName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置表名称
|
||||
*
|
||||
* @param sheetName
|
||||
* 表名称
|
||||
*/
|
||||
public void setSheetName(String sheetName) {
|
||||
this.sheetName = sheetName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取属性
|
||||
*
|
||||
* @return 属性
|
||||
*/
|
||||
public String[] getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置属性
|
||||
*
|
||||
* @param properties
|
||||
* 属性
|
||||
*/
|
||||
public void setProperties(String[] properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标题
|
||||
*
|
||||
* @return 标题
|
||||
*/
|
||||
public String[] getTitles() {
|
||||
return titles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置标题
|
||||
*
|
||||
* @param titles
|
||||
* 标题
|
||||
*/
|
||||
public void setTitles(String[] titles) {
|
||||
this.titles = titles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列宽
|
||||
*
|
||||
* @return 列宽
|
||||
*/
|
||||
public Integer[] getWidths() {
|
||||
return widths;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置列宽
|
||||
*
|
||||
* @param widths
|
||||
* 列宽
|
||||
*/
|
||||
public void setWidths(Integer[] widths) {
|
||||
this.widths = widths;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型转换
|
||||
*
|
||||
* @return 类型转换
|
||||
*/
|
||||
public Converter[] getConverters() {
|
||||
return converters;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置类型转换
|
||||
*
|
||||
* @param converters
|
||||
* 类型转换
|
||||
*/
|
||||
public void setConverters(Converter[] converters) {
|
||||
this.converters = converters;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据
|
||||
*
|
||||
* @return 数据
|
||||
*/
|
||||
public Collection<?> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据
|
||||
*
|
||||
* @param data
|
||||
* 数据
|
||||
*/
|
||||
public void setData(Collection<?> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取附加内容
|
||||
*
|
||||
* @return 附加内容
|
||||
*/
|
||||
public String[] getContents() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置附加内容
|
||||
*
|
||||
* @param contents
|
||||
* 附加内容
|
||||
*/
|
||||
public void setContents(String[] contents) {
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms;
|
||||
|
||||
/**
|
||||
* 消息
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class Feedback {
|
||||
|
||||
|
||||
/** 类型 */
|
||||
private String type;
|
||||
|
||||
/** 数据 */
|
||||
private Object data;
|
||||
|
||||
/**消息*/
|
||||
private String msg;
|
||||
|
||||
public Feedback(String type, Object data,String msg) {
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static Feedback success(Object data) {
|
||||
return new Feedback("success", data , null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
public static Feedback error(String msg) {
|
||||
return new Feedback("error", null, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回警告
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
public static Feedback warn(String msg) {
|
||||
return new Feedback("warn", null, msg);
|
||||
}
|
||||
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package vip.fuck.sm.plugins.cms;
|
||||
/**
|
||||
*
|
||||
* 数据库表属性
|
||||
*
|
||||
*/
|
||||
public class TableField {
|
||||
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
/** 名称 */
|
||||
private String type;
|
||||
|
||||
/** 描述 */
|
||||
private String comment;
|
||||
|
||||
/** 是否必填 */
|
||||
private Boolean isRequired;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public Boolean getIsRequired() {
|
||||
return isRequired;
|
||||
}
|
||||
|
||||
public void setIsRequired(Boolean isRequired) {
|
||||
this.isRequired = isRequired;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
package vip.fuck.sm.plugins.cms;
|
||||
|
||||
/**
|
||||
* 模板文件
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TemplateFile {
|
||||
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
/** 大小 */
|
||||
private String size;
|
||||
|
||||
/** 修改日期 */
|
||||
private String modifyDate;
|
||||
|
||||
/** 类型 */
|
||||
private String type;
|
||||
|
||||
/** 是否是目录 */
|
||||
private Boolean isDirectory;
|
||||
|
||||
/**
|
||||
* 获取名称
|
||||
*
|
||||
* @return 名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置名称
|
||||
*
|
||||
* @param name
|
||||
* 名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取大小
|
||||
*
|
||||
* @return 大小
|
||||
*/
|
||||
public String getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置大小
|
||||
*
|
||||
* @param size
|
||||
* 大小
|
||||
*/
|
||||
public void setSize(String size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取修改日期
|
||||
*
|
||||
* @return 修改日期
|
||||
*/
|
||||
public String getModifyDate() {
|
||||
return modifyDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置修改日期
|
||||
*
|
||||
* @param modifyDate
|
||||
* 修改日期
|
||||
*/
|
||||
public void setModifyDate(String modifyDate) {
|
||||
this.modifyDate = modifyDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型
|
||||
*
|
||||
* @return 类型
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置类型
|
||||
*
|
||||
* @param type
|
||||
* 类型
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否是目录
|
||||
*
|
||||
* @return 是否是目录
|
||||
*/
|
||||
public Boolean getIsDirectory() {
|
||||
return isDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否是目录
|
||||
*
|
||||
* @param isDirectory
|
||||
* 是否是目录
|
||||
*/
|
||||
public void setIsDirectory(Boolean isDirectory) {
|
||||
this.isDirectory = isDirectory;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package vip.fuck.sm.plugins.cms;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Inherited
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.TYPE })
|
||||
public @interface TemplateVariable {
|
||||
|
||||
String name();
|
||||
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
package vip.fuck.sm.plugins.cms;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.util.*;
|
||||
|
||||
public class UrlRewriteWrappedRequest extends HttpServletRequestWrapper {
|
||||
|
||||
HashMap overridenParameters;
|
||||
|
||||
public UrlRewriteWrappedRequest(HttpServletRequest httpServletRequest) {
|
||||
super(httpServletRequest);
|
||||
}
|
||||
|
||||
public UrlRewriteWrappedRequest(HttpServletRequest httpServletRequest,
|
||||
HashMap overridenParameters) {
|
||||
super(httpServletRequest);
|
||||
this.overridenParameters = overridenParameters;
|
||||
}
|
||||
|
||||
public Enumeration getParameterNames() {
|
||||
if (overridenParameters != null) {
|
||||
List keys = Collections.list(super.getParameterNames());
|
||||
keys.addAll(overridenParameters.keySet());
|
||||
return Collections.enumeration(keys);
|
||||
}
|
||||
return super.getParameterNames();
|
||||
}
|
||||
|
||||
public Map getParameterMap() {
|
||||
if (overridenParameters != null) {
|
||||
Map superMap = super.getParameterMap();
|
||||
//superMap is an unmodifiable map, hence creating a new one.
|
||||
Map overriddenMap = new HashMap(superMap.size() + overridenParameters.size());
|
||||
overriddenMap.putAll(superMap);
|
||||
overriddenMap.putAll(overridenParameters);
|
||||
return overriddenMap;
|
||||
}
|
||||
return super.getParameterMap();
|
||||
}
|
||||
|
||||
public String[] getParameterValues(String s) {
|
||||
if (overridenParameters != null && overridenParameters.containsKey(s)) {
|
||||
return (String[]) overridenParameters.get(s);
|
||||
}
|
||||
return super.getParameterValues(s);
|
||||
}
|
||||
|
||||
public String getParameter(String s) {
|
||||
if (overridenParameters != null && overridenParameters.containsKey(s)) {
|
||||
String[] values = (String[]) overridenParameters.get(s);
|
||||
if (values == null || values.length == 0) {
|
||||
return null;
|
||||
} else {
|
||||
return values[0];
|
||||
}
|
||||
}
|
||||
return super.getParameter(s);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,155 @@
|
||||
//package vip.fuck.sm.plugins.cms.config;
|
||||
// todo config
|
||||
//import com.cms.ClassScaner;
|
||||
//import com.cms.CommonAttribute;
|
||||
//import com.cms.entity._MappingKit;
|
||||
//import com.cms.handler.ResourcesHandler;
|
||||
//import com.cms.handler.SiteHandler;
|
||||
//import com.cms.handler.UrlHandler;
|
||||
//import com.cms.routes.RouteMapping;
|
||||
//import com.cms.util.TemplateVariableUtils;
|
||||
//import com.jfinal.config.*;
|
||||
//import com.jfinal.core.Controller;
|
||||
//import com.jfinal.core.JFinal;
|
||||
//import com.jfinal.ext.handler.ContextPathHandler;
|
||||
//import com.jfinal.ext.interceptor.SessionInViewInterceptor;
|
||||
//import com.jfinal.json.FastJsonFactory;
|
||||
//import com.jfinal.kit.PropKit;
|
||||
//import com.jfinal.kit.StrKit;
|
||||
//import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||
//import com.jfinal.plugin.activerecord.tx.TxByMethods;
|
||||
//import com.jfinal.plugin.druid.DruidPlugin;
|
||||
//import com.jfinal.plugin.ehcache.EhCachePlugin;
|
||||
//import com.jfinal.render.ViewType;
|
||||
//import com.jfinal.template.Engine;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * 配置
|
||||
// *
|
||||
// *
|
||||
// */
|
||||
//public class CmsConfig extends JFinalConfig{
|
||||
//
|
||||
// /**
|
||||
// * 运行此 main 方法可以启动项目,此main方法可以放置在任意的Class类定义中,不一定要放于此
|
||||
// *
|
||||
// * 使用本方法启动过第一次以后,会在开发工具的 debug、run config 中自动生成
|
||||
// * 一条启动配置,可对该自动生成的配置再添加额外的配置项,例如 VM argument 可配置为:
|
||||
// * -XX:PermSize=64M -XX:MaxPermSize=256M
|
||||
// * @throws IOException
|
||||
// */
|
||||
// public static void main(String[] args) throws IOException {
|
||||
// JFinal.start("src/main/webapp", 8888, "/", 5);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void configConstant(Constants me) {
|
||||
// // TODO Auto-generated method stub
|
||||
// PropKit.use(CommonAttribute.CONFIG_PROPERTIES);
|
||||
// /** 开发者模式 */
|
||||
// me.setDevMode(PropKit.getBoolean("system.devMode", false));
|
||||
// /** 配置页面 */
|
||||
// me.setViewType(ViewType.JFINAL_TEMPLATE);
|
||||
// me.setViewExtension(CommonAttribute.VIEW_EXTENSION);
|
||||
// me.setError404View(CommonAttribute.FRONT_RESOURCE_NOT_FOUND_VIEW);
|
||||
// me.setError500View(CommonAttribute.FRONT_ERROR_VIEW);
|
||||
// /** 编码配置 */
|
||||
// me.setEncoding(CommonAttribute.UTF_8);
|
||||
// /** 上传文件目录 */
|
||||
// me.setBaseUploadPath(CommonAttribute.UPLOAD_PATH);
|
||||
// /** 设置参数分隔符 */
|
||||
// me.setUrlParaSeparator(CommonAttribute.URL_PARA_SEPARATOR);
|
||||
// /** 设置JSON */
|
||||
// me.setJsonFactory(new FastJsonFactory());
|
||||
// me.setJsonDatePattern(CommonAttribute.JSON_DATE_PATTERN);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void configRoute(Routes me) {
|
||||
// // TODO Auto-generated method stub
|
||||
// List<Class<Controller>> controllerClassList = ClassScaner.scanSubClass(Controller.class,true,false);
|
||||
// if (controllerClassList != null) {
|
||||
// for (Class<?> clazz : controllerClassList) {
|
||||
// RouteMapping urlMapping = clazz.getAnnotation(RouteMapping.class);
|
||||
// if (null != urlMapping && StrKit.notBlank(urlMapping.url())) {
|
||||
// me.add(urlMapping.url(), (Class<? extends Controller>) clazz);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void configPlugin(Plugins me) {
|
||||
// // TODO Auto-generated method stub
|
||||
// /** 数据库配置 */
|
||||
// DruidPlugin druidPlugin = new DruidPlugin(PropKit.get("jdbc.url"), PropKit.get("jdbc.username"), PropKit.get("jdbc.password"),PropKit.get("jdbc.driver"));
|
||||
// me.add(druidPlugin);
|
||||
// ActiveRecordPlugin activeRecordPlugin = new ActiveRecordPlugin(druidPlugin);
|
||||
// /** 打印sql */
|
||||
// activeRecordPlugin.setShowSql(true);
|
||||
// me.add(activeRecordPlugin);
|
||||
// /** 表对应的实体配置 */
|
||||
// _MappingKit.mapping(activeRecordPlugin);
|
||||
//// /** 定时任务 */
|
||||
//// me.add(new Cron4jPlugin(CommonAttribute.JOB_PROPERTIES));
|
||||
// /** 缓存 */
|
||||
// me.add(new EhCachePlugin());
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 配置全局拦截器
|
||||
// */
|
||||
// @Override
|
||||
// public void configInterceptor(Interceptors me) {
|
||||
// // TODO Auto-generated method stub
|
||||
// /** session */
|
||||
// me.add(new SessionInViewInterceptor());
|
||||
// /** 事物 */
|
||||
// me.add(new TxByMethods("save","update"));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 配置Handler
|
||||
// */
|
||||
// @Override
|
||||
// public void configHandler(Handlers me) {
|
||||
// // TODO Auto-generated method stub
|
||||
// me.add(new ContextPathHandler("base"));
|
||||
// me.add(new ResourcesHandler());
|
||||
// me.add(new SiteHandler());
|
||||
// me.add(new UrlHandler());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 程序启动后
|
||||
// */
|
||||
// @Override
|
||||
// public void onStart() {
|
||||
// // TODO Auto-generated method stub
|
||||
// TemplateVariableUtils.setBaseVariable();
|
||||
// TemplateVariableUtils.setDirectiveVariable();
|
||||
// TemplateVariableUtils.setMethodVariable();
|
||||
// super.onStart();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 程序停止前
|
||||
// */
|
||||
// @Override
|
||||
// public void onStop() {
|
||||
// // TODO Auto-generated method stub
|
||||
// super.onStop();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 引擎配置
|
||||
// */
|
||||
// @Override
|
||||
// public void configEngine(Engine me) {
|
||||
// // TODO Auto-generated method stub
|
||||
// }
|
||||
//}
|
||||
@ -0,0 +1,156 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.noear.solon.annotation.Mapping;
|
||||
import vip.fuck.sm.plugins.cms.CommonAttribute;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Admin;
|
||||
import vip.fuck.sm.plugins.cms.entity.AdminRole;
|
||||
import vip.fuck.sm.plugins.cms.entity.Role;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 管理员
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Mapping(value = "/admin/admin")
|
||||
|
||||
public class AdminController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index(){
|
||||
setListQuery();
|
||||
String name = getPara("name");
|
||||
String username = getPara("username");
|
||||
Integer pageNumber = getParaToInt("pageNumber");
|
||||
if(pageNumber==null){
|
||||
pageNumber = 1;
|
||||
}
|
||||
setAttr("page", new Admin().dao().findPage(name,username,pageNumber,PAGE_SIZE));
|
||||
setAttr("name", name);
|
||||
setAttr("username", username);
|
||||
render(getView("admin/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户名是否存在
|
||||
*/
|
||||
public void checkUsername() {
|
||||
String username = getPara("username");
|
||||
if (StringUtils.isEmpty(username)) {
|
||||
renderJson(false);
|
||||
return;
|
||||
}
|
||||
renderJson(!new Admin().dao().usernameExists(username));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
setAttr("roles", new Role().dao().findAll());
|
||||
render(getView("admin/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
Admin admin = getModel(Admin.class,"",true);
|
||||
if (new Admin().dao().usernameExists(admin.getUsername())) {
|
||||
render(CommonAttribute.ADMIN_ERROR_VIEW);
|
||||
return;
|
||||
}
|
||||
admin.setPassword(DigestUtils.md5Hex(admin.getPassword()));
|
||||
admin.setCreateDate(new Date());
|
||||
admin.setUpdateDate(new Date());
|
||||
admin.save();
|
||||
Integer[] roleIds = getParaValuesToInt("roleIds");
|
||||
for(Integer roleId : roleIds){
|
||||
AdminRole adminRole = new AdminRole();
|
||||
adminRole.setAdminId(admin.getId());
|
||||
adminRole.setRoleId(roleId);
|
||||
adminRole.save();
|
||||
}
|
||||
redirect(getListQuery("/admin/admin"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Integer id = getParaToInt("id");
|
||||
setAttr("admin", new Admin().dao().findById(id));
|
||||
setAttr("roles", new Role().dao().findAll());
|
||||
render(getView("admin/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update() {
|
||||
Admin admin = getModel(Admin.class,"",true);
|
||||
Admin pAdmin = new Admin().dao().findById(admin.getId());
|
||||
if (pAdmin == null) {
|
||||
render(CommonAttribute.ADMIN_ERROR_VIEW);
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(admin.getPassword())) {
|
||||
admin.setPassword(DigestUtils.md5Hex(admin.getPassword()));
|
||||
} else {
|
||||
admin.setPassword(pAdmin.getPassword());
|
||||
}
|
||||
admin.setUpdateDate(new Date());
|
||||
admin.update();
|
||||
Integer[] roleIds = getParaValuesToInt("roleIds");
|
||||
new AdminRole().dao().deleteByAdminId(admin.getId());
|
||||
for(Integer roleId : roleIds){
|
||||
AdminRole adminRole = new AdminRole();
|
||||
adminRole.setAdminId(admin.getId());
|
||||
adminRole.setRoleId(roleId);
|
||||
adminRole.save();
|
||||
}
|
||||
redirect(getListQuery("/admin/admin"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
public void reset(){
|
||||
Integer id = getParaToInt("id");
|
||||
Admin admin = new Admin().dao().findById(id);
|
||||
admin.setPassword(DigestUtils.md5Hex("123456"));
|
||||
admin.setUpdateDate(new Date());
|
||||
admin.update();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Integer ids[] = getParaValuesToInt("ids");
|
||||
if(ArrayUtils.isNotEmpty(ids)){
|
||||
for(Integer id:ids){
|
||||
new Admin().dao().deleteById(id);
|
||||
}
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,272 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.ObjectUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.noear.solon.core.handle.Context;
|
||||
import org.noear.solon.core.handle.Cookie;
|
||||
import org.noear.solon.core.handle.UploadedFile;
|
||||
import org.noear.solon.core.util.KeyValues;
|
||||
import org.noear.solon.core.util.MultiMap;
|
||||
import org.smartboot.http.server.HttpRequest;
|
||||
import vip.fuck.sm.plugins.cms.CommonAttribute;
|
||||
import vip.fuck.sm.plugins.cms.entity.Admin;
|
||||
import vip.fuck.sm.plugins.cms.entity.Site;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Controller - 基类
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BaseController {
|
||||
|
||||
protected void renderError(int errorStatus){
|
||||
// todo renderError
|
||||
}
|
||||
|
||||
protected void renderCaptcha() {
|
||||
// todo renderCaptcha
|
||||
}
|
||||
|
||||
protected void renderJavascript(String script) {
|
||||
// todo void renderJavascript(String s) {
|
||||
|
||||
}
|
||||
|
||||
protected void keepPara(){
|
||||
// todo keepPara
|
||||
}
|
||||
|
||||
protected HttpRequest getRequest(){
|
||||
return (HttpRequest) Context.current().request();
|
||||
}
|
||||
|
||||
protected Map<String,List<String>> getParaMap(){
|
||||
return Context.current().paramMap().toValuesMap();
|
||||
}
|
||||
|
||||
protected String getAttr(String name){
|
||||
Object session = Context.current().session(name);
|
||||
if(session==null){
|
||||
return null;
|
||||
}
|
||||
return session.toString();
|
||||
}
|
||||
protected <T> T getAttr(String name,Class<T> clazz){
|
||||
return Context.current().session(name,clazz);
|
||||
}
|
||||
|
||||
protected boolean validateCaptcha(String captcha) {
|
||||
// todo valid captcha
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 每页记录数 */
|
||||
protected static final int PAGE_SIZE = 10;
|
||||
|
||||
/** 列表查询Cookie名称 */
|
||||
private static final String LIST_QUERY_COOKIE_NAME = "listQuery";
|
||||
|
||||
protected void setAttr(String key, Object value){
|
||||
Context.current().attrSet(key,value);
|
||||
};
|
||||
|
||||
protected String getPara(String name){
|
||||
return Context.current().param(name);
|
||||
}
|
||||
|
||||
protected String getPara(int name){
|
||||
Collection<String> strings = Context.current().paramNames();
|
||||
return strings.stream().findFirst().get();
|
||||
}
|
||||
|
||||
protected UploadedFile getFile(){
|
||||
MultiMap<UploadedFile> strings = Context.current().fileMap();
|
||||
if(ObjectUtil.isEmpty(strings)){
|
||||
return null;
|
||||
}
|
||||
for (KeyValues<UploadedFile> string : strings) {
|
||||
return string.getFirstValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Integer getParaToInt(String name){
|
||||
return Context.current().paramAsInt(name);
|
||||
}
|
||||
|
||||
protected Integer getParaToInt(String name,Integer dv){
|
||||
return Context.current().paramAsInt(name,dv);
|
||||
}
|
||||
|
||||
protected void redirect(String url){
|
||||
Context.current().redirect(url);
|
||||
}
|
||||
|
||||
protected Long[] getParaValuesToLong(String name){
|
||||
String[] strings = Context.current().paramValues(name);
|
||||
if(ObjectUtil.isEmpty(strings)){
|
||||
return null;
|
||||
}
|
||||
boolean b = Arrays.stream(strings).allMatch(NumberUtil::isInteger);
|
||||
if(!b){
|
||||
throw new UnsupportedOperationException("获取参数失败");
|
||||
}
|
||||
return Arrays.stream(strings).map(NumberUtil::parseLong).toArray(Long[]::new);
|
||||
}
|
||||
|
||||
protected Long getParaToLong(String name) {
|
||||
return Context.current().paramAsLong(name);
|
||||
}
|
||||
|
||||
protected void renderJson(boolean b) {
|
||||
// todo 是否返回json
|
||||
}
|
||||
|
||||
protected void renderJson(Object o) {
|
||||
// todo 是否返回json
|
||||
try {
|
||||
Context.current().render(o);
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected <T> T getModel(Class<T> clazz, String modelName, boolean skipConvertError){
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String[] getParaValues(String name){
|
||||
return Context.current().paramValues(name);
|
||||
}
|
||||
|
||||
protected Boolean getParaToBoolean(String name) {
|
||||
return BooleanUtil.toBoolean(Context.current().param(name));
|
||||
}
|
||||
|
||||
protected Integer[] getParaValuesToInt(String name){
|
||||
String[] strings = Context.current().paramValues(name);
|
||||
if(ObjectUtil.isEmpty(strings)){
|
||||
return null;
|
||||
}
|
||||
boolean b = Arrays.stream(strings).allMatch(NumberUtil::isInteger);
|
||||
if(!b){
|
||||
throw new UnsupportedOperationException("获取参数失败");
|
||||
}
|
||||
return Arrays.stream(strings).map(NumberUtil::parseInt).toArray(Integer[]::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前站点
|
||||
*
|
||||
* @return 当前站点
|
||||
*/
|
||||
// @NotAction
|
||||
protected Site getCurrentSite() {
|
||||
Site currentSite = Context.current().session(Site.ADMIN_SESSION_SITE,Site.class);
|
||||
return currentSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前管理员
|
||||
*
|
||||
* @return 当前管理员
|
||||
*/
|
||||
// @NotAction
|
||||
protected Admin getCurrentAdmin() {
|
||||
Admin currentAdmin = Context.current().session(Admin.SESSION_ADMIN,Admin.class);
|
||||
return currentAdmin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取页面
|
||||
*
|
||||
* @return 页面
|
||||
*/
|
||||
// @NotAction
|
||||
public String getView(String view){
|
||||
return CommonAttribute.ADMIN_PATH+view+CommonAttribute.VIEW_EXTENSION;
|
||||
}
|
||||
public void render(String path){
|
||||
//todo render page path
|
||||
}
|
||||
|
||||
protected void setCookie(String name, String value ,int maxAge,String path){
|
||||
Context.current().cookieSet(name,
|
||||
value,
|
||||
null,"",maxAge);
|
||||
};
|
||||
/**
|
||||
* 设置列表参数
|
||||
*
|
||||
*/
|
||||
// @NotAction
|
||||
protected void setListQuery(){
|
||||
Map<String, List<String>> paraMap = Context.current().paramMap().toValuesMap();
|
||||
String listQuery = "";
|
||||
if(paraMap!=null && !paraMap.isEmpty()){
|
||||
for(String key : paraMap.keySet()){
|
||||
List<String> values = paraMap.get(key);
|
||||
if(CollectionUtils.isNotEmpty(values)){
|
||||
for(String value : values){
|
||||
listQuery+="&"+key+"="+value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(listQuery)){
|
||||
listQuery = listQuery.substring(1);
|
||||
try {
|
||||
setCookie(LIST_QUERY_COOKIE_NAME,
|
||||
URLEncoder.encode(listQuery, "UTF-8")
|
||||
,10*6,"");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表参数
|
||||
*
|
||||
* @return 列表参数
|
||||
*/
|
||||
// @NotAction
|
||||
public String getListQuery(String url){
|
||||
String listQuery = null;
|
||||
try {
|
||||
String cookieListQuery = Context.current().cookie(LIST_QUERY_COOKIE_NAME);
|
||||
if(StringUtils.isNotBlank(cookieListQuery)){
|
||||
listQuery = URLDecoder.decode(cookieListQuery, "UTF-8");
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(StringUtils.isNotBlank(url) && StringUtils.isNotEmpty(listQuery)){
|
||||
if (StringUtils.startsWith(listQuery, "?")) {
|
||||
listQuery = listQuery.substring(1);
|
||||
}
|
||||
if (StringUtils.contains(url, "?")) {
|
||||
url = url + "&" + listQuery;
|
||||
} else {
|
||||
url = url + "?" + listQuery;
|
||||
}
|
||||
Context.current().cookieRemove(LIST_QUERY_COOKIE_NAME);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
import com.cms.Feedback;
|
||||
import com.cms.routes.RouteMapping;
|
||||
import com.cms.util.CacheUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 缓存
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/cache")
|
||||
public class CacheController extends BaseController {
|
||||
|
||||
/**
|
||||
* 清除缓存
|
||||
*/
|
||||
public void delete() {
|
||||
CacheUtils.clearAll();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,216 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Category;
|
||||
import vip.fuck.sm.plugins.cms.entity.Content;
|
||||
import vip.fuck.sm.plugins.cms.entity.Model;
|
||||
import vip.fuck.sm.plugins.cms.entity.ModelField;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
import vip.fuck.sm.plugins.cms.util.PinYinUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 分类
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/category")
|
||||
|
||||
public class CategoryController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index() {
|
||||
setListQuery();
|
||||
setAttr("categoryTree", new Category().dao().findTree(null,getCurrentSite().getId()));
|
||||
render(getView("category/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
setAttr("categoryTree", new Category().dao().findTree(null,getCurrentSite().getId()));
|
||||
setAttr("models",new Model().dao().findNormalList());
|
||||
render(getView("category/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查目录
|
||||
*/
|
||||
public void checkCat(){
|
||||
String cat = getPara("cat");
|
||||
if(StringUtils.isBlank(cat)){
|
||||
renderJson(true);
|
||||
return;
|
||||
}
|
||||
Integer id = getParaToInt("id");
|
||||
if(id!=null){
|
||||
Category category = new Category().dao().findById(id);
|
||||
if(category.getCat().equals(cat)){
|
||||
renderJson(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Category category = new Category().findByCat(cat,getCurrentSite().getId());
|
||||
renderJson(category==null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 内容模型模板
|
||||
*/
|
||||
public void modelTemplate(){
|
||||
Integer modelId = getParaToInt("modelId");
|
||||
Model model = new Model().dao().findById(modelId);
|
||||
Map<String,Object> data = new HashMap<>();
|
||||
data.put("listTemplate", model.getListTemplate());
|
||||
data.put("detailTemplate", model.getDetailTemplate());
|
||||
renderJson(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
Category category = getModel(Category.class,"",true);
|
||||
String[] chunkValues = getParaValues("chunkValues");
|
||||
Integer modelId = category.getModelId();
|
||||
List<ModelField> modelFields = new ModelField().dao().findList(modelId);
|
||||
Map<String,Object> model = new HashMap<String,Object>();
|
||||
for(ModelField modelField : modelFields){
|
||||
model.put(modelField.getName(), getPara(modelField.getName()));
|
||||
}
|
||||
if(ArrayUtils.isNotEmpty(chunkValues)){
|
||||
category.setChunkValue(JSONArray.toJSONString(chunkValues));
|
||||
}else{
|
||||
category.setChunkValue(JSONArray.toJSONString(new String[]{}));
|
||||
}
|
||||
if(StringUtils.isBlank(category.getCat())){
|
||||
category.setCat(PinYinUtils.convertLower(category.getName()));
|
||||
}
|
||||
category.setSiteId(getCurrentSite().getId());
|
||||
category.setValue();
|
||||
category.setCreateDate(new Date());
|
||||
category.setUpdateDate(new Date());
|
||||
category.save();
|
||||
redirect(getListQuery("/admin/category"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Integer id = getParaToInt("id");
|
||||
Category category = new Category().dao().findById(id);
|
||||
setAttr("categoryTree", new Category().dao().findTree(null,getCurrentSite().getId()));
|
||||
setAttr("category", category);
|
||||
setAttr("models",new Model().dao().findNormalList());
|
||||
if(category.getModelId() != null){
|
||||
List<ModelField> modelFields = new ModelField().dao().findList(category.getModelId());
|
||||
setAttr("modelFields", modelFields);
|
||||
}else{
|
||||
setAttr("modelFields", new ArrayList<ModelField>());
|
||||
}
|
||||
render(getView("category/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update() {
|
||||
Category category = getModel(Category.class,"",true);
|
||||
String[] chunkValues = getParaValues("chunkValues");
|
||||
Integer modelId = category.getModelId();
|
||||
List<ModelField> modelFields = new ModelField().dao().findList(modelId);
|
||||
Map<String,Object> model = new HashMap<String,Object>();
|
||||
for(ModelField modelField : modelFields){
|
||||
model.put(modelField.getName(), getPara(modelField.getName()));
|
||||
}
|
||||
if(ArrayUtils.isNotEmpty(chunkValues)){
|
||||
category.setChunkValue(JSONArray.toJSONString(chunkValues));
|
||||
}else{
|
||||
category.setChunkValue(JSONArray.toJSONString(new String[]{}));
|
||||
}
|
||||
if(StringUtils.isBlank(category.getCat())){
|
||||
category.setCat(PinYinUtils.convertLower(category.getName()));
|
||||
}
|
||||
category.setValue();
|
||||
category.setUpdateDate(new Date());
|
||||
category.update();
|
||||
redirect(getListQuery("/admin/category"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*/
|
||||
public void updateStatus(){
|
||||
Integer status = BooleanUtils.toInteger(getParaToBoolean("status"));
|
||||
Integer id = getParaToInt("id");
|
||||
Category category = new Category().dao().findById(id);
|
||||
category.setStatus(status);
|
||||
category.setUpdateDate(new Date());
|
||||
category.update();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public void updateSort(){
|
||||
String sortArray = getPara("sortArray");
|
||||
JSONArray jsonArray = JSONArray.parseArray(sortArray);
|
||||
for(int i=0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
Integer id = jsonObject.getInteger("id");
|
||||
Integer sort = jsonObject.getInteger("sort");
|
||||
Category category = new Category().dao().findById(id);
|
||||
category.setSort(sort);
|
||||
category.update();
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Integer id = getParaToInt("id");
|
||||
Category category = new Category().dao().findById(id);
|
||||
if (category == null) {
|
||||
renderJson(Feedback.error("分类不存在"));
|
||||
return;
|
||||
}
|
||||
List<Category> children = category.getChildren();
|
||||
if (children != null && !children.isEmpty()) {
|
||||
renderJson(Feedback.error("存在下级分类,无法删除"));
|
||||
return;
|
||||
}
|
||||
List<Content> contents = category.getContents();
|
||||
if (contents != null && !contents.isEmpty()) {
|
||||
renderJson(Feedback.error("存在下级内容,无法删除"));
|
||||
return;
|
||||
}
|
||||
new Category().dao().deleteById(id);
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Company;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 公司信息
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/company")
|
||||
public class CompanyController extends BaseController {
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void index(){
|
||||
Company company = new Company().dao().findBySiteId(getCurrentSite().getId());
|
||||
setAttr("company", company);
|
||||
render(getView("company/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void update(){
|
||||
Company company = getModel(Company.class,"",true);
|
||||
company.update();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,281 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Category;
|
||||
import vip.fuck.sm.plugins.cms.entity.Content;
|
||||
import vip.fuck.sm.plugins.cms.entity.ModelField;
|
||||
import vip.fuck.sm.plugins.cms.entity.Tag;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
import vip.fuck.sm.plugins.cms.util.PinYinUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 内容
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/content")
|
||||
public class ContentController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index(){
|
||||
setAttr("categoryTree", new Category().dao().findTree(null,getCurrentSite().getId()));
|
||||
render(getView("content/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
public void tag(){
|
||||
setAttr("tags",new Tag().findAll());
|
||||
render(getView("content/tag"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
Category category = new Category().dao().findById(getParaToInt("categoryId"));
|
||||
List<ModelField> modelFields = new ModelField().dao().findList(category.getModelId());
|
||||
setAttr("categoryTree", new Category().dao().findTree(null,getCurrentSite().getId()));
|
||||
setAttr("modelFields", modelFields);
|
||||
setAttr("category", category);
|
||||
render(getView("content/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
Content content = getModel(Content.class,"",true);
|
||||
String[] chunkValues = getParaValues("chunkValues");
|
||||
Integer modelId = content.getCategory().getModelId();
|
||||
List<ModelField> modelFields = new ModelField().dao().findList(modelId);
|
||||
Map<String,Object> model = new HashMap<String,Object>();
|
||||
for(ModelField modelField : modelFields){
|
||||
if("multipleFile".equals(modelField.getType())){
|
||||
model.put(modelField.getName(), getParaValues(modelField.getName()));
|
||||
}else{
|
||||
model.put(modelField.getName(), getPara(modelField.getName()));
|
||||
}
|
||||
}
|
||||
if(ArrayUtils.isNotEmpty(chunkValues)){
|
||||
content.setChunkValue(JSONArray.toJSONString(chunkValues));
|
||||
}else{
|
||||
content.setChunkValue(JSONArray.toJSONString(new String[]{}));
|
||||
}
|
||||
//轮播多图
|
||||
String[] picValues = getParaValues("picValues");
|
||||
if(ArrayUtils.isNotEmpty(picValues)){
|
||||
content.setPicValue(JSONArray.toJSONString(picValues));
|
||||
}else{
|
||||
content.setPicValue("");
|
||||
}
|
||||
//标签
|
||||
String[] tagNames = getParaValues("tagNames");
|
||||
if(ArrayUtils.isNotEmpty(tagNames)){
|
||||
List<Integer> tagIds = new ArrayList<>();
|
||||
for(String tagName : tagNames){
|
||||
Tag tag = new Tag().dao().findByName(tagName);
|
||||
if(tag==null){
|
||||
tag = new Tag();
|
||||
tag.setName(tagName);
|
||||
tag.setCat(PinYinUtils.convertLower(tagName));
|
||||
tag.setCreateDate(new Date());
|
||||
tag.setUpdateDate(new Date());
|
||||
tag.save();
|
||||
}
|
||||
tagIds.add(tag.getId());
|
||||
}
|
||||
content.setTagIdValue(","+ StringUtils.join(tagIds,",")+",");
|
||||
}else{
|
||||
content.setTagIdValue("");
|
||||
}
|
||||
content.setModelFieldValue(JSONObject.toJSONString(model));
|
||||
content.setSiteId(getCurrentSite().getId());
|
||||
content.setCreateDate(new Date());
|
||||
content.setUpdateDate(new Date());
|
||||
content.save();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Integer id = getParaToInt("id");
|
||||
Content content = new Content().dao().findById(id);
|
||||
Category category = new Category().dao().findById(content.getCategoryId());
|
||||
List<ModelField> modelFields = new ModelField().dao().findList(category.getModelId());
|
||||
setAttr("categoryTree", new Category().dao().findTree(null,getCurrentSite().getId()));
|
||||
setAttr("category", category);
|
||||
setAttr("modelFields", modelFields);
|
||||
setAttr("content", content);
|
||||
render(getView("content/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update() {
|
||||
Content content = getModel(Content.class,"",true);
|
||||
String[] chunkValues = getParaValues("chunkValues");
|
||||
Integer modelId = content.getCategory().getModelId();
|
||||
List<ModelField> modelFields = new ModelField().dao().findList(modelId);
|
||||
Map<String,Object> model = new HashMap<String,Object>();
|
||||
for(ModelField modelField : modelFields){
|
||||
if("multipleFile".equals(modelField.getType())){
|
||||
model.put(modelField.getName(), getParaValues(modelField.getName()));
|
||||
}else{
|
||||
model.put(modelField.getName(), getPara(modelField.getName()));
|
||||
}
|
||||
}
|
||||
if(ArrayUtils.isNotEmpty(chunkValues)){
|
||||
content.setChunkValue(JSONArray.toJSONString(chunkValues));
|
||||
}else{
|
||||
content.setChunkValue(JSONArray.toJSONString(new String[]{}));
|
||||
}
|
||||
//轮播多图
|
||||
String[] picValues = getParaValues("picValues");
|
||||
if(ArrayUtils.isNotEmpty(picValues)){
|
||||
content.setPicValue(JSONArray.toJSONString(picValues));
|
||||
}else{
|
||||
content.setPicValue("");
|
||||
}
|
||||
//标签
|
||||
String[] tagNames = getParaValues("tagNames");
|
||||
if(ArrayUtils.isNotEmpty(tagNames)){
|
||||
List<Integer> tagIds = new ArrayList<>();
|
||||
for(String tagName : tagNames){
|
||||
Tag tag = new Tag().dao().findByName(tagName);
|
||||
if(tag==null){
|
||||
tag = new Tag();
|
||||
tag.setName(tagName);
|
||||
tag.setCat(PinYinUtils.convertLower(tagName));
|
||||
tag.setCreateDate(new Date());
|
||||
tag.setUpdateDate(new Date());
|
||||
tag.save();
|
||||
}
|
||||
tagIds.add(tag.getId());
|
||||
}
|
||||
content.setTagIdValue(","+ StringUtils.join(tagIds,",")+",");
|
||||
}else{
|
||||
content.setTagIdValue("");
|
||||
}
|
||||
content.setModelFieldValue(JSONObject.toJSONString(model));
|
||||
content.setUpdateDate(new Date());
|
||||
content.update();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*/
|
||||
public void updateStatus(){
|
||||
Integer status = BooleanUtils.toInteger(getParaToBoolean("value"));
|
||||
Integer id = getParaToInt("id");
|
||||
Content content = new Content().dao().findById(id);
|
||||
content.setStatus(status);
|
||||
content.setUpdateDate(new Date());
|
||||
content.update();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改是否置顶
|
||||
*/
|
||||
public void updateIsTop(){
|
||||
Boolean isTop = getParaToBoolean("value");
|
||||
Integer id = getParaToInt("id");
|
||||
Content content = new Content().dao().findById(id);
|
||||
content.setIsTop(isTop);
|
||||
content.setUpdateDate(new Date());
|
||||
content.update();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改是否推荐
|
||||
*/
|
||||
public void updateIsRecommend(){
|
||||
Boolean isRecommend = getParaToBoolean("value");
|
||||
Integer id = getParaToInt("id");
|
||||
Content content = new Content().dao().findById(id);
|
||||
content.setIsRecommend(isRecommend);
|
||||
content.setUpdateDate(new Date());
|
||||
content.update();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改是否头条
|
||||
*/
|
||||
public void updateIsHeadline(){
|
||||
Boolean isHeadline = getParaToBoolean("value");
|
||||
Integer id = getParaToInt("id");
|
||||
Content content = new Content().dao().findById(id);
|
||||
content.setIsHeadline(isHeadline);
|
||||
content.setUpdateDate(new Date());
|
||||
content.update();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public void updateSort(){
|
||||
String sortArray = getPara("sortArray");
|
||||
JSONArray jsonArray = JSONArray.parseArray(sortArray);
|
||||
for(int i=0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
Long id = jsonObject.getLong("id");
|
||||
Integer sort = jsonObject.getInteger("sort");
|
||||
Content content = new Content().dao().findById(id);
|
||||
content.setSort(sort);
|
||||
content.update();
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
public void data() {
|
||||
setListQuery();
|
||||
String title = getPara("title");
|
||||
Integer categoryId = getParaToInt("categoryId");
|
||||
Integer pageNumber = getParaToInt("pageNumber");
|
||||
if(pageNumber==null){
|
||||
pageNumber = 1;
|
||||
}
|
||||
setAttr("categoryId",categoryId);
|
||||
setAttr("page", new Content().dao().findPage(categoryId,title,pageNumber,PAGE_SIZE,getCurrentSite().getId()));
|
||||
setAttr("title", title);
|
||||
render(getView("content/data"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Integer ids[] = getParaValuesToInt("ids");
|
||||
if(ArrayUtils.isNotEmpty(ids)){
|
||||
for(Integer id:ids){
|
||||
new Content().dao().deleteById(id);
|
||||
}
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
import vip.fuck.sm.plugins.cms.util.BackupUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
/**
|
||||
* Controller - 数据库
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/database")
|
||||
public class DatabaseController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index() {
|
||||
List<String> backups = BackupUtils.getFiles();
|
||||
Collections.reverse(backups);
|
||||
setAttr("backups", backups);
|
||||
render(getView("database/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 备份
|
||||
*/
|
||||
public void backup(){
|
||||
BackupUtils.backup();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 还原
|
||||
*/
|
||||
public void restore(){
|
||||
String name = getPara("name");
|
||||
BackupUtils.restore(name);
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
String name = getPara("name");
|
||||
BackupUtils.delete(name);
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Div;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
import vip.fuck.sm.plugins.cms.util.TableUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 自定义表
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/div")
|
||||
public class DivController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index(){
|
||||
setListQuery();
|
||||
Integer pageNumber = getParaToInt("pageNumber");
|
||||
if(pageNumber==null){
|
||||
pageNumber = 1;
|
||||
}
|
||||
setAttr("page", new Div().dao().findPage(pageNumber,PAGE_SIZE));
|
||||
render(getView("div/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
render(getView("div/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
Div div = getModel(Div.class,"",true);
|
||||
div.setCreateDate(new Date());
|
||||
div.setUpdateDate(new Date());
|
||||
div.save();
|
||||
//创建数据库表
|
||||
TableUtils.create(div.getTableName());
|
||||
redirect(getListQuery("/admin/div"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Integer id = getParaToInt("id");
|
||||
Div div = new Div().dao().findById(id);
|
||||
setAttr("div", div);
|
||||
render(getView("div/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void update() {
|
||||
Div div = getModel(Div.class,"",true);
|
||||
div.setUpdateDate(new Date());
|
||||
div.update();
|
||||
redirect(getListQuery("/admin/div"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Integer ids[] = getParaValuesToInt("ids");
|
||||
if(ArrayUtils.isNotEmpty(ids)){
|
||||
for(Integer id:ids){
|
||||
Div div = new Div().dao().findById(id);
|
||||
TableUtils.delete(div.getTableName());
|
||||
div.delete();
|
||||
}
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,139 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Div;
|
||||
import vip.fuck.sm.plugins.cms.entity.DivField;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 自定义表数据
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/div_data")
|
||||
public class DivDataController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index(){
|
||||
setListQuery();
|
||||
setAttr("divs", new Div().dao().findAll());
|
||||
render(getView("div_data/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add(){
|
||||
Integer divId = getParaToInt("divId");
|
||||
Div div = new Div().dao().findById(divId);
|
||||
List<DivField> divFields = new DivField().dao().findList(divId);
|
||||
setAttr("divFields",divFields);
|
||||
setAttr("div", div);
|
||||
setAttr("divId", divId);
|
||||
Record divData = new Record();
|
||||
setAttr("divData", divData);
|
||||
render(getView("div_data/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save(){
|
||||
Integer divId = getParaToInt("divId");
|
||||
Div div = new Div().dao().findById(divId);
|
||||
List<DivField> divFields = new DivField().dao().findList(divId);
|
||||
Record divData = new Record();
|
||||
for(DivField divField : divFields){
|
||||
String value = getPara(divField.getName());
|
||||
divData.set(divField.getName(), value);
|
||||
}
|
||||
divData.set("createDate", new Date());
|
||||
divData.set("updateDate", new Date());
|
||||
Db.save(div.getTableName(), divData);
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Integer id = getParaToInt("id");
|
||||
Integer divId = getParaToInt("divId");
|
||||
Div div = new Div().dao().findById(divId);
|
||||
List<DivField> divFields = new DivField().dao().findList(divId);
|
||||
Record divData = Db.findById(div.getTableName(), id);
|
||||
setAttr("divFields",divFields);
|
||||
setAttr("div", div);
|
||||
setAttr("divData", divData);
|
||||
setAttr("divId", divId);
|
||||
render(getView("div_data/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update() {
|
||||
Integer id = getParaToInt("id");
|
||||
Integer divId = getParaToInt("divId");
|
||||
Div div = new Div().dao().findById(divId);
|
||||
List<DivField> divFields = new DivField().dao().findList(divId);
|
||||
Record divData = new Record();
|
||||
for(DivField divField : divFields){
|
||||
String value = getPara(divField.getName());
|
||||
divData.set(divField.getName(), value);
|
||||
}
|
||||
divData.set("id", id);
|
||||
divData.set("updateDate", new Date());
|
||||
Db.update(div.getTableName(), divData);
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
public void data() {
|
||||
setListQuery();
|
||||
Integer divId = getParaToInt("divId");
|
||||
Integer pageNumber = getParaToInt("pageNumber");
|
||||
if(pageNumber==null){
|
||||
pageNumber = 1;
|
||||
}
|
||||
Div div = new Div().dao().findById(divId);
|
||||
List<DivField> divFields = new DivField().dao().findList(divId);
|
||||
setAttr("divFields", divFields);
|
||||
String orderBySql = DbUtils.getOrderBySql("createDate desc");
|
||||
Page<Record> page = Db.paginate(pageNumber, PAGE_SIZE, "select *", "from "+div.getTableName()+" where 1=1 "+orderBySql);
|
||||
setAttr("page", page);
|
||||
setAttr("divId", divId);
|
||||
render(getView("div_data/data"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Integer divId = getParaToInt("divId");
|
||||
Div div = new Div().dao().findById(divId);
|
||||
Integer ids[] = getParaValuesToInt("ids");
|
||||
if(ArrayUtils.isNotEmpty(ids)){
|
||||
Db.update("delete from "+div.getTableName()+" where id in("+StringUtils.join(ids, ",")+")");
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.CommonAttribute;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
/**
|
||||
* Controller - 错误
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/error")
|
||||
public class ErrorController extends BaseController {
|
||||
|
||||
/**
|
||||
* 权限错误
|
||||
*/
|
||||
public void unauthorized() {
|
||||
render(CommonAttribute.ADMIN_UNAUTHORIZED_VIEW);
|
||||
}
|
||||
|
||||
/**
|
||||
* 异常
|
||||
*/
|
||||
public void exception() {
|
||||
render(CommonAttribute.ADMIN_ERROR_VIEW);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
import com.jfinal.kit.PathKit;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.noear.solon.core.handle.UploadedFile;
|
||||
import vip.fuck.sm.plugins.cms.CommonAttribute;
|
||||
import vip.fuck.sm.plugins.cms.Config;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
import vip.fuck.sm.plugins.cms.util.ImageUtils;
|
||||
import vip.fuck.sm.plugins.cms.util.SystemUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Controller - 文件
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/file")
|
||||
public class FileController extends BaseController {
|
||||
|
||||
/**
|
||||
* 上传
|
||||
*/
|
||||
public void upload() {
|
||||
UploadedFile uploadFile = getFile();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
if (uploadFile == null || uploadFile.getContentSize()==0) {
|
||||
data.put("message", "操作错误");
|
||||
data.put("state", "ERROR");
|
||||
renderJson(data);
|
||||
return;
|
||||
}
|
||||
String suffix = FilenameUtils.getExtension(uploadFile.getName());
|
||||
String newFileBaseName = UUID.randomUUID().toString();
|
||||
String newFileName = newFileBaseName+"."+suffix;
|
||||
String url = "/"+ CommonAttribute.UPLOAD_PATH+"/"+newFileName;
|
||||
File newFile = new File(PathKit.getWebRootPath()+url);
|
||||
try {
|
||||
uploadFile.transferTo(newFile);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String [] imageSuffixs = new String[]{"jpg","png"};
|
||||
Config config = SystemUtils.getConfig();
|
||||
if(config.getIsWatermarkEnabled() && ArrayUtils.contains(imageSuffixs, suffix.toLowerCase())){
|
||||
String watermarkImage = config.getWatermarkImage();
|
||||
String watermarkPosition = config.getWatermarkPosition();
|
||||
File watermarkImageFile = new File(PathKit.getWebRootPath()+watermarkImage);
|
||||
String sourceFileName = newFileBaseName+"_source."+suffix;
|
||||
File sourceFile = new File(PathKit.getWebRootPath()+"/"+CommonAttribute.UPLOAD_PATH+"/"+sourceFileName);
|
||||
newFile.renameTo(sourceFile);
|
||||
ImageUtils.addWatermark(sourceFile, newFile, watermarkImageFile, watermarkPosition);
|
||||
FileUtils.deleteQuietly(sourceFile);
|
||||
}
|
||||
data.put("message", "成功");
|
||||
data.put("state", "SUCCESS");
|
||||
data.put("url", url);
|
||||
data.put("name",FilenameUtils.getBaseName(url));
|
||||
// FileUtils.deleteQuietly(uploadFile());
|
||||
renderJson(data);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,119 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.FriendLink;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 友情链接
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/friend_link")
|
||||
public class FriendLinkController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index() {
|
||||
setListQuery();
|
||||
String name = getPara("name");
|
||||
Integer pageNumber = getParaToInt("pageNumber");
|
||||
if(pageNumber==null){
|
||||
pageNumber = 1;
|
||||
}
|
||||
setAttr("page", new FriendLink().dao().findPage(pageNumber,PAGE_SIZE,getCurrentSite().getId()));
|
||||
setAttr("gids", new FriendLink().dao().findGids(getCurrentSite().getId()));
|
||||
setAttr("name", name);
|
||||
render(getView("friend_link/index"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
setAttr("gids", new FriendLink().dao().findGids(getCurrentSite().getId()));
|
||||
render(getView("friend_link/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
FriendLink friendLink = getModel(FriendLink.class,"",true);
|
||||
if(friendLink.getGid()==null){
|
||||
Integer maxGid = new FriendLink().dao().findMaxGid(getCurrentSite().getId());
|
||||
if(maxGid==null){
|
||||
maxGid=0;
|
||||
}
|
||||
maxGid = maxGid+1;
|
||||
friendLink.setGid(maxGid);
|
||||
}
|
||||
friendLink.setSiteId(getCurrentSite().getId());
|
||||
friendLink.setCreateDate(new Date());
|
||||
friendLink.setUpdateDate(new Date());
|
||||
friendLink.save();
|
||||
redirect(getListQuery("/admin/friend_link"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Integer id = getParaToInt("id");
|
||||
setAttr("friendLink", new FriendLink().dao().findById(id));
|
||||
setAttr("gids", new FriendLink().dao().findGids(getCurrentSite().getId()));
|
||||
render(getView("friend_link/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update() {
|
||||
FriendLink friendLink = getModel(FriendLink.class,"",true);
|
||||
friendLink.setUpdateDate(new Date());
|
||||
friendLink.update();
|
||||
redirect(getListQuery("/admin/friend_link"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public void updateSort(){
|
||||
String sortArray = getPara("sortArray");
|
||||
JSONArray jsonArray = JSONArray.parseArray(sortArray);
|
||||
for(int i=0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
Long id = jsonObject.getLong("id");
|
||||
Integer sort = jsonObject.getInteger("sort");
|
||||
FriendLink friendLink = new FriendLink().dao().findById(id);
|
||||
friendLink.setSort(sort);
|
||||
friendLink.update();
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Integer ids[] = getParaValuesToInt("ids");
|
||||
if(ArrayUtils.isNotEmpty(ids)){
|
||||
for(Integer id:ids){
|
||||
new FriendLink().dao().deleteById(id);
|
||||
}
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Guestbook;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 留言
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/guestbook")
|
||||
public class GuestbookController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index() {
|
||||
setListQuery();
|
||||
String name = getPara("name");
|
||||
Integer pageNumber = getParaToInt("pageNumber");
|
||||
if(pageNumber==null){
|
||||
pageNumber = 1;
|
||||
}
|
||||
setAttr("page", new Guestbook().dao().findPage(pageNumber,PAGE_SIZE,getCurrentSite().getId()));
|
||||
setAttr("name", name);
|
||||
render(getView("guestbook/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 回复
|
||||
*/
|
||||
public void reply(){
|
||||
Integer guestbookId = getParaToInt("guestbookId");
|
||||
Guestbook guestbook = new Guestbook().dao().findById(guestbookId);
|
||||
setAttr("guestbook", guestbook);
|
||||
render(getView("guestbook/reply"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改回复
|
||||
*/
|
||||
public void updateReply(){
|
||||
String replyContent = getPara("replyContent");
|
||||
Integer guestbookId = getParaToInt("guestbookId");
|
||||
Guestbook guestbook = new Guestbook().dao().findById(guestbookId);
|
||||
guestbook.setReplyContent(replyContent);
|
||||
guestbook.update();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*/
|
||||
public void updateStatus(){
|
||||
Integer status = BooleanUtils.toInteger(getParaToBoolean("status"));
|
||||
Integer id = getParaToInt("id");
|
||||
Guestbook guestbook = new Guestbook().dao().findById(id);
|
||||
guestbook.setStatus(status);
|
||||
guestbook.setUpdateDate(new Date());
|
||||
guestbook.update();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Integer ids[] = getParaValuesToInt("ids");
|
||||
if(ArrayUtils.isNotEmpty(ids)){
|
||||
for(Integer id:ids){
|
||||
new Guestbook().dao().deleteById(id);
|
||||
}
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import vip.fuck.sm.plugins.cms.Config;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Category;
|
||||
import vip.fuck.sm.plugins.cms.entity.Content;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
import vip.fuck.sm.plugins.cms.util.CacheUtils;
|
||||
import vip.fuck.sm.plugins.cms.util.HtmlUtils;
|
||||
import vip.fuck.sm.plugins.cms.util.SystemUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Controller - 静态化
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/html")
|
||||
public class HtmlController extends BaseController {
|
||||
|
||||
/**
|
||||
* 生成静态
|
||||
*/
|
||||
public void index(){
|
||||
setAttr("defaultStartDate", DateUtils.addDays(new Date(), -7));
|
||||
setAttr("defaultEndDate", new Date());
|
||||
setAttr("categoryTree", new Category().dao().findTree(null,getCurrentSite().getId()));
|
||||
render(getView("html/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成静态
|
||||
*/
|
||||
public void generate() {
|
||||
Config config = SystemUtils.getConfig();
|
||||
if(config.getSiteModel()!= Config.SiteModel.HTML.ordinal()){
|
||||
renderJson(Feedback.error("网站模式不是静态模式"));
|
||||
return;
|
||||
}
|
||||
Integer type = getParaToInt("type");
|
||||
Integer categoryId = getParaToInt("categoryId");
|
||||
Date startDate = getParaToDate("startDate");
|
||||
Date endDate = getParaToDate("endDate");
|
||||
Integer first = getParaToInt("first");
|
||||
Integer count = getParaToInt("count");
|
||||
long startTime = System.currentTimeMillis();
|
||||
if (startDate != null) {
|
||||
Calendar calendar = DateUtils.toCalendar(startDate);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMinimum(Calendar.HOUR_OF_DAY));
|
||||
calendar.set(Calendar.MINUTE, calendar.getActualMinimum(Calendar.MINUTE));
|
||||
calendar.set(Calendar.SECOND, calendar.getActualMinimum(Calendar.SECOND));
|
||||
startDate = calendar.getTime();
|
||||
}
|
||||
if (endDate != null) {
|
||||
Calendar calendar = DateUtils.toCalendar(endDate);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY));
|
||||
calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE));
|
||||
calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND));
|
||||
endDate = calendar.getTime();
|
||||
}
|
||||
if (first == null || first < 0) {
|
||||
first = 0;
|
||||
CacheUtils.clearAll();
|
||||
}
|
||||
if (count == null || count <= 0) {
|
||||
count = 100;
|
||||
}
|
||||
int generateCount = 0;
|
||||
boolean isCompleted = true;
|
||||
if(type== HtmlUtils.Type.INDEX.ordinal()){
|
||||
generateCount = HtmlUtils.generateIndex(getCurrentSite().getId());
|
||||
}else if(type==HtmlUtils.Type.CONTENT.ordinal()){
|
||||
List<Content> contents = new Content().dao().findList(categoryId,null, startDate, endDate,null, first, count,getCurrentSite().getId());
|
||||
for (Content content : contents) {
|
||||
generateCount += HtmlUtils.generate(content);
|
||||
}
|
||||
first += contents.size();
|
||||
if (contents.size() == count) {
|
||||
isCompleted = false;
|
||||
}
|
||||
}else if(type==HtmlUtils.Type.CATEGORY.ordinal()){
|
||||
if(categoryId == null){
|
||||
List<Category> categoryTree = new Category().dao().findTree(null,getCurrentSite().getId());
|
||||
for(Category category : categoryTree){
|
||||
generateCount += HtmlUtils.generate(category);
|
||||
}
|
||||
}else{
|
||||
Category category = new Category().dao().findById(categoryId);
|
||||
generateCount += HtmlUtils.generate(category);
|
||||
}
|
||||
}else{
|
||||
generateCount += HtmlUtils.generateAll(getCurrentSite().getId());
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("first", first);
|
||||
data.put("generateCount", generateCount);
|
||||
data.put("generateTime", endTime - startTime);
|
||||
data.put("isCompleted", isCompleted);
|
||||
renderJson(Feedback.success(data));
|
||||
}
|
||||
|
||||
protected Date getParaToDate(String dn) {
|
||||
String ds = this.getPara(dn);
|
||||
return DateUtil.parse(ds).toJdkDate();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
import com.cms.entity.Admin;
|
||||
import com.cms.entity.Site;
|
||||
import com.cms.routes.RouteMapping;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.time.DateFormatUtils;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Controller - 首页
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/index")
|
||||
|
||||
public class IndexController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*/
|
||||
public void index() {
|
||||
//站点
|
||||
Integer siteId = getParaToInt("siteId");
|
||||
if(siteId == null){
|
||||
Admin currentAdmin = getCurrentAdmin();
|
||||
if(BooleanUtils.isFalse(currentAdmin.getRole().getIsSystem())
|
||||
&& CollectionUtils.isEmpty(currentAdmin.getRole().getSiteIds())){
|
||||
renderHtml("<script>alert('用户没有授权站点');history.back();</script>");
|
||||
return;
|
||||
}
|
||||
Site defaultSite = new Site().dao().findDefault();
|
||||
if(BooleanUtils.isTrue(currentAdmin.getRole().getIsSystem())
|
||||
|| currentAdmin.getRole().getSiteIds().contains(defaultSite.getId())){
|
||||
siteId = defaultSite.getId();
|
||||
}else{
|
||||
siteId = currentAdmin.getRole().getSiteIds().get(0);
|
||||
}
|
||||
}
|
||||
Site currentSite = new Site().dao().findById(siteId);
|
||||
getSession().setAttribute(Site.ADMIN_SESSION_SITE, currentSite);
|
||||
//统计
|
||||
setAttr("contentCount", Db.queryInt("select count(*) from cms_content"));
|
||||
setAttr("formCount", Db.queryInt("select count(*) from cms_div"));
|
||||
setAttr("guestbookCount", Db.queryInt("select count(*) from cms_guestbook"));
|
||||
setAttr("siteCount", Db.queryInt("select count(*) from cms_site"));
|
||||
String guestbookItemSql = "";
|
||||
String contentItemSql = "";
|
||||
for(int i=0;i<=6;i++){
|
||||
Date date = DateUtils.addDays(new Date(), -i);
|
||||
if(i>0){
|
||||
guestbookItemSql+=",";
|
||||
contentItemSql+=",";
|
||||
}
|
||||
guestbookItemSql += "(select count(*) from cms_guestbook where createDate <= '"+DateFormatUtils.format(date, "yyyy-MM-dd")+" 23:59:59') as '"+DateFormatUtils.format(date, "MM-dd")+"'";
|
||||
contentItemSql += "(select count(*) from cms_content where createDate <= '"+DateFormatUtils.format(date, "yyyy-MM-dd")+" 23:59:59') as '"+DateFormatUtils.format(date, "MM-dd")+"'";
|
||||
}
|
||||
String guestbookSql = "select "+guestbookItemSql;
|
||||
Record guestbookRecord = Db.findFirst(guestbookSql);
|
||||
String [] guestbookColumnNames = guestbookRecord.getColumnNames();
|
||||
Object [] guestbookColumnValues = guestbookRecord.getColumnValues();
|
||||
setAttr("guestbookTime", "'"+StringUtils.join(guestbookColumnNames,"','")+"'");
|
||||
setAttr("guestbookValue", StringUtils.join(guestbookColumnValues,","));
|
||||
|
||||
String contentSql = "select "+contentItemSql;
|
||||
Record contentRecord = Db.findFirst(contentSql);
|
||||
String [] contentColumnNames = contentRecord.getColumnNames();
|
||||
Object [] contentColumnValues = contentRecord.getColumnValues();
|
||||
setAttr("contentTime", "'"+StringUtils.join(contentColumnNames,"','")+"'");
|
||||
setAttr("contentValue", StringUtils.join(contentColumnValues,","));
|
||||
|
||||
render(getView("index/index"));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
import com.cms.Feedback;
|
||||
import com.cms.entity.Admin;
|
||||
import com.cms.routes.RouteMapping;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Controller - 管理员登录
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/login")
|
||||
public class LoginController extends BaseController {
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
public void index() {
|
||||
String username = getPara("username");
|
||||
String password = getPara("password");
|
||||
setAttr("username", username);
|
||||
setAttr("password", password);
|
||||
render(getView("login/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
public void login(){
|
||||
String username = getPara("username");
|
||||
String password = getPara("password");
|
||||
Admin admin = new Admin().dao().findByUsername(username);
|
||||
if(admin==null){
|
||||
renderJson(Feedback.error("用户名不存在!"));
|
||||
return;
|
||||
}
|
||||
if(!admin.getPassword().equals(DigestUtils.md5Hex(password))){
|
||||
renderJson(Feedback.error("用户名密码错误!"));
|
||||
return;
|
||||
}
|
||||
getSession().setAttribute(Admin.SESSION_ADMIN, admin);
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
import com.cms.entity.Admin;
|
||||
import com.cms.entity.Site;
|
||||
import com.cms.routes.RouteMapping;
|
||||
|
||||
/**
|
||||
* Controller - 管理员退出
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/logout")
|
||||
public class LogoutController extends BaseController{
|
||||
|
||||
/**
|
||||
* 退出
|
||||
*/
|
||||
public void index(){
|
||||
getSession().removeAttribute(Admin.SESSION_ADMIN);
|
||||
getSession().removeAttribute(Site.ADMIN_SESSION_SITE);
|
||||
redirect("/admin/login");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,131 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Menu;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Controller - 菜单
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/menu")
|
||||
public class MenuController extends BaseController{
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index() {
|
||||
setListQuery();
|
||||
setAttr("menuTree", new Menu().dao().findTree());
|
||||
render(getView("menu/index"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
setAttr("menuTree", new Menu().dao().findTree());
|
||||
render(getView("menu/add"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
Menu menu = getModel(Menu.class,"",true);
|
||||
if(menu.getIsShow()==null){
|
||||
menu.setIsShow(false);
|
||||
}
|
||||
menu.setValue();
|
||||
menu.setCreateDate(new Date());
|
||||
menu.setUpdateDate(new Date());
|
||||
menu.save();
|
||||
redirect(getListQuery("/admin/menu"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Long id = getParaToLong("id");
|
||||
Menu menu = new Menu().dao().findById(id);
|
||||
setAttr("menuTree", new Menu().dao().findTree());
|
||||
setAttr("menu", menu);
|
||||
render(getView("menu/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update() {
|
||||
Menu menu = getModel(Menu.class,"",true);
|
||||
if(menu.getIsShow()==null){
|
||||
menu.setIsShow(false);
|
||||
}
|
||||
menu.setValue();
|
||||
menu.setUpdateDate(new Date());
|
||||
menu.update();
|
||||
redirect(getListQuery("/admin/menu"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改是否显示
|
||||
*/
|
||||
public void updateIsShow(){
|
||||
Boolean isShow = getParaToBoolean("value");
|
||||
Integer id = getParaToInt("id");
|
||||
Menu menu = new Menu().dao().findById(id);
|
||||
menu.setIsShow(isShow);
|
||||
menu.setUpdateDate(new Date());
|
||||
menu.update();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public void updateSort(){
|
||||
String sortArray = getPara("sortArray");
|
||||
JSONArray jsonArray = JSONArray.parseArray(sortArray);
|
||||
for(int i=0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
Long id = jsonObject.getLong("id");
|
||||
Integer sort = jsonObject.getInteger("sort");
|
||||
Menu menu = new Menu().dao().findById(id);
|
||||
menu.setSort(sort);
|
||||
menu.update();
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Long id = getParaToLong("id");
|
||||
Menu menu = new Menu().dao().findById(id);
|
||||
if (menu == null) {
|
||||
renderJson(Feedback.error("菜单不存在"));
|
||||
return;
|
||||
}
|
||||
List<Menu> children = menu.getChildren();
|
||||
if (children != null && !children.isEmpty()) {
|
||||
renderJson(Feedback.error("存在下级菜单,无法删除"));
|
||||
return;
|
||||
}
|
||||
new Menu().dao().deleteById(id);
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Model;
|
||||
import vip.fuck.sm.plugins.cms.entity.ModelField;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 模型
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/model")
|
||||
|
||||
public class ModelController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index() {
|
||||
setListQuery();
|
||||
String name = getPara("name");
|
||||
Integer pageNumber = getParaToInt("pageNumber");
|
||||
if(pageNumber==null){
|
||||
pageNumber = 1;
|
||||
}
|
||||
setAttr("page", new Model().dao().findPage(pageNumber,PAGE_SIZE));
|
||||
setAttr("name", name);
|
||||
render(getView("model/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
render(getView("model/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
Model model = getModel(Model.class,"",true);
|
||||
model.setCreateDate(new Date());
|
||||
model.setUpdateDate(new Date());
|
||||
model.save();
|
||||
redirect(getListQuery("/admin/model"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Long id = getParaToLong("id");
|
||||
setAttr("model", new Model().dao().findById(id));
|
||||
render(getView("model/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update() {
|
||||
Model model = getModel(Model.class,"",true);
|
||||
model.setUpdateDate(new Date());
|
||||
model.update();
|
||||
redirect(getListQuery("/admin/model"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Integer ids[] = getParaValuesToInt("ids");
|
||||
if(ArrayUtils.isNotEmpty(ids)){
|
||||
for(Integer id:ids){
|
||||
new ModelField().dao().deleteByModelId(id);
|
||||
Model model = new Model().dao().findById(id);
|
||||
model.delete();
|
||||
}
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Nav;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 导航
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/nav")
|
||||
|
||||
public class NavController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index() {
|
||||
setListQuery();
|
||||
setAttr("navTree", new Nav().dao().findTree(getCurrentSite().getId()));
|
||||
render(getView("nav/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
setAttr("navTree", new Nav().dao().findTree(getCurrentSite().getId()));
|
||||
render(getView("nav/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
Nav nav = getModel(Nav.class,"",true);
|
||||
nav.setSiteId(getCurrentSite().getId());
|
||||
nav.setValue();
|
||||
nav.setCreateDate(new Date());
|
||||
nav.setUpdateDate(new Date());
|
||||
nav.save();
|
||||
redirect(getListQuery("/admin/nav"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Integer id = getParaToInt("id");
|
||||
Nav nav = new Nav().dao().findById(id);
|
||||
setAttr("navTree", new Nav().dao().findTree(getCurrentSite().getId()));
|
||||
setAttr("nav", nav);
|
||||
render(getView("nav/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update() {
|
||||
Nav nav = getModel(Nav.class,"",true);
|
||||
nav.setValue();
|
||||
nav.setUpdateDate(new Date());
|
||||
nav.update();
|
||||
redirect(getListQuery("/admin/nav"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public void updateSort(){
|
||||
String sortArray = getPara("sortArray");
|
||||
JSONArray jsonArray = JSONArray.parseArray(sortArray);
|
||||
for(int i=0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
Integer id = jsonObject.getInteger("id");
|
||||
Integer sort = jsonObject.getInteger("sort");
|
||||
Nav nav = new Nav().dao().findById(id);
|
||||
nav.setSort(sort);
|
||||
nav.update();
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Integer id = getParaToInt("id");
|
||||
Nav nav = new Nav().dao().findById(id);
|
||||
if (nav == null) {
|
||||
renderJson(Feedback.error("导航不存在"));
|
||||
return;
|
||||
}
|
||||
List<Nav> children = nav.getChildren();
|
||||
if (children != null && !children.isEmpty()) {
|
||||
renderJson(Feedback.error("存在下级导航,无法删除"));
|
||||
return;
|
||||
}
|
||||
new Nav().dao().deleteById(id);
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Admin;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 个人资料
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/profile")
|
||||
public class ProfileController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
setAttr("admin", new Admin().dao().findById(getCurrentAdmin().getId()));
|
||||
render(getView("profile/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update() {
|
||||
String currentPassword = getPara("currentPassword");
|
||||
String password = getPara("password");
|
||||
Admin admin = getCurrentAdmin();
|
||||
Admin pAdmin = new Admin().dao().findById(admin.getId());
|
||||
if (StringUtils.isEmpty(currentPassword) || !StringUtils.equals(DigestUtils.md5Hex(currentPassword), pAdmin.getPassword())) {
|
||||
renderJson(Feedback.error("密码错误"));
|
||||
return;
|
||||
}
|
||||
pAdmin.setPassword(DigestUtils.md5Hex(password));
|
||||
pAdmin.setUpdateDate(new Date());
|
||||
pAdmin.update();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Menu;
|
||||
import vip.fuck.sm.plugins.cms.entity.Role;
|
||||
import vip.fuck.sm.plugins.cms.entity.RoleSite;
|
||||
import vip.fuck.sm.plugins.cms.entity.Site;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 角色
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/role")
|
||||
public class RoleController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index() {
|
||||
setListQuery();
|
||||
Integer pageNumber = getParaToInt("pageNumber");
|
||||
if(pageNumber==null){
|
||||
pageNumber = 1;
|
||||
}
|
||||
setAttr("page", new Role().dao().findPage(pageNumber,PAGE_SIZE));
|
||||
render(getView("role/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
setAttr("sites", new Site().dao().findAll());
|
||||
setAttr("rootMenus", new Menu().dao().findRoots());
|
||||
render(getView("role/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
Role role = getModel(Role.class,"",true);
|
||||
String[] permissions = getParaValues("permissions");
|
||||
if(ArrayUtils.isNotEmpty(permissions)){
|
||||
role.setPermission(JSONArray.toJSONString(permissions));
|
||||
}else{
|
||||
role.setPermission("[]");
|
||||
}
|
||||
role.setCreateDate(new Date());
|
||||
role.setUpdateDate(new Date());
|
||||
role.save();
|
||||
Integer[] siteIds = getParaValuesToInt("siteIds");
|
||||
for(Integer siteId : siteIds){
|
||||
RoleSite roleSite = new RoleSite();
|
||||
roleSite.setRoleId(role.getId());
|
||||
roleSite.setSiteId(siteId);
|
||||
roleSite.save();
|
||||
}
|
||||
redirect(getListQuery("/admin/role"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Long id = getParaToLong("id");
|
||||
setAttr("role", new Role().dao().findById(id));
|
||||
setAttr("rootMenus", new Menu().dao().findRoots());
|
||||
setAttr("sites", new Site().dao().findAll());
|
||||
render(getView("role/edit"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void update() {
|
||||
Role role = getModel(Role.class,"",true);
|
||||
String[] permissions = getParaValues("permissions");
|
||||
if(ArrayUtils.isNotEmpty(permissions)){
|
||||
role.setPermission(JSONArray.toJSONString(permissions));
|
||||
}else{
|
||||
role.setPermission("[]");
|
||||
}
|
||||
role.setUpdateDate(new Date());
|
||||
role.update();
|
||||
Integer[] siteIds = getParaValuesToInt("siteIds");
|
||||
new RoleSite().dao().deleteByRoleId(role.getId());
|
||||
for(Integer siteId : siteIds){
|
||||
RoleSite roleSite = new RoleSite();
|
||||
roleSite.setRoleId(role.getId());
|
||||
roleSite.setSiteId(siteId);
|
||||
roleSite.save();
|
||||
}
|
||||
redirect(getListQuery("/admin/role"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Long ids[] = getParaValuesToLong("ids");
|
||||
if(ArrayUtils.isNotEmpty(ids)){
|
||||
for(Long id:ids){
|
||||
new Role().dao().deleteById(id);
|
||||
}
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import vip.fuck.sm.plugins.cms.Config;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Setup;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
import vip.fuck.sm.plugins.cms.util.CacheUtils;
|
||||
import vip.fuck.sm.plugins.cms.util.SystemUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 配置
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/setup")
|
||||
|
||||
public class SetupController extends BaseController {
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void index(){
|
||||
Config config = SystemUtils.getConfig();
|
||||
setAttr("config", config);
|
||||
render(getView("setup/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update(){
|
||||
Map<String,String> setupMap = new Setup().getSetupMap();
|
||||
Set<String> keys = setupMap.keySet();
|
||||
for(String key : keys){
|
||||
String value = setupMap.get(key);
|
||||
String paraValue = getPara(key);
|
||||
if(!StringUtils.equals(value, paraValue)){
|
||||
Setup setup = new Setup().dao().findByName(key);
|
||||
setup.setValue(paraValue);
|
||||
setup.update();
|
||||
}
|
||||
}
|
||||
CacheUtils.clearConfig();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,130 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Company;
|
||||
import vip.fuck.sm.plugins.cms.entity.Site;
|
||||
import vip.fuck.sm.plugins.cms.entity.Web;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
import vip.fuck.sm.plugins.cms.util.PinYinUtils;
|
||||
import vip.fuck.sm.plugins.cms.util.TemplateUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 站点
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/site")
|
||||
public class SiteController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index() {
|
||||
setListQuery();
|
||||
Integer pageNumber = getParaToInt("pageNumber");
|
||||
if(pageNumber==null){
|
||||
pageNumber = 1;
|
||||
}
|
||||
setAttr("page", new Site().dao().findPage(pageNumber,PAGE_SIZE));
|
||||
render(getView("site/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
setAttr("templates", TemplateUtils.getTemplates());
|
||||
render(getView("site/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
Site site = getModel(Site.class,"",true);
|
||||
if(StringUtils.isBlank(site.getPcTemplate())){
|
||||
site.setPcTemplate(PinYinUtils.convertLower(site.getName()));
|
||||
}
|
||||
if(site.getIsMobile() && StringUtils.isBlank(site.getMobileTemplate())){
|
||||
site.setMobileTemplate(PinYinUtils.convertLower(site.getName())+"_mobile");
|
||||
}
|
||||
site.setCreateDate(new Date());
|
||||
site.setUpdateDate(new Date());
|
||||
site.save();
|
||||
//网站信息
|
||||
Web web = new Web();
|
||||
web.setSiteId(site.getId());
|
||||
web.save();
|
||||
//公司信息
|
||||
Company company = new Company();
|
||||
company.setSiteId(site.getId());
|
||||
company.save();
|
||||
redirect(getListQuery("/admin/site"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Long id = getParaToLong("id");
|
||||
setAttr("site", new Site().dao().findById(id));
|
||||
setAttr("templates", TemplateUtils.getTemplates());
|
||||
render(getView("site/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update() {
|
||||
Site site = getModel(Site.class,"",true);
|
||||
site.setUpdateDate(new Date());
|
||||
site.update();
|
||||
redirect(getListQuery("/admin/site"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Integer ids[] = getParaValuesToInt("ids");
|
||||
if(ArrayUtils.isNotEmpty(ids)){
|
||||
for(Integer id:ids){
|
||||
new Web().dao().findBySiteId(id).delete();
|
||||
new Company().dao().findBySiteId(id).delete();
|
||||
new Site().dao().deleteById(id);
|
||||
}
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置为默认站点
|
||||
*/
|
||||
public void setDefault(){
|
||||
Long id = getParaToLong("id");
|
||||
Site defaultSite = new Site().dao().findDefault();
|
||||
defaultSite.setIsDefault(false);
|
||||
if(StringUtils.isNotBlank(defaultSite.getPcTemplate())){
|
||||
defaultSite.setCat(defaultSite.getPcTemplate());
|
||||
}else if(StringUtils.isNotBlank(defaultSite.getMobileTemplate())){
|
||||
defaultSite.setCat(defaultSite.getMobileTemplate());
|
||||
}
|
||||
defaultSite.setUpdateDate(new Date());
|
||||
defaultSite.update();
|
||||
Site site = new Site().dao().findById(id);
|
||||
site.setIsDefault(true);
|
||||
site.setUpdateDate(new Date());
|
||||
site.setCat("");
|
||||
site.update();
|
||||
redirect(getListQuery("/admin/site"));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,117 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Slide;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 幻灯片
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/slide")
|
||||
public class SlideController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index(){
|
||||
setListQuery();
|
||||
Integer pageNumber = getParaToInt("pageNumber");
|
||||
if(pageNumber==null){
|
||||
pageNumber = 1;
|
||||
}
|
||||
setAttr("page", new Slide().dao().findPage(pageNumber,PAGE_SIZE,getCurrentSite().getId()));
|
||||
setAttr("gids", new Slide().dao().findGids(getCurrentSite().getId()));
|
||||
render(getView("slide/index"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
setAttr("gids", new Slide().dao().findGids(getCurrentSite().getId()));
|
||||
render(getView("slide/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
Slide slide = getModel(Slide.class,"",true);
|
||||
if(slide.getGid()==null){
|
||||
Integer maxGid = new Slide().dao().findMaxGid(getCurrentSite().getId());
|
||||
if(maxGid==null){
|
||||
maxGid=0;
|
||||
}
|
||||
maxGid = maxGid+1;
|
||||
slide.setGid(maxGid);
|
||||
}
|
||||
slide.setSiteId(getCurrentSite().getId());
|
||||
slide.setCreateDate(new Date());
|
||||
slide.setUpdateDate(new Date());
|
||||
slide.save();
|
||||
redirect(getListQuery("/admin/slide"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Integer id = getParaToInt("id");
|
||||
setAttr("slide", new Slide().dao().findById(id));
|
||||
setAttr("gids", new Slide().dao().findGids(getCurrentSite().getId()));
|
||||
render(getView("slide/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void update() {
|
||||
Slide slide = getModel(Slide.class,"",true);
|
||||
slide.setUpdateDate(new Date());
|
||||
slide.update();
|
||||
redirect(getListQuery("/admin/slide"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public void updateSort(){
|
||||
String sortArray = getPara("sortArray");
|
||||
JSONArray jsonArray = JSONArray.parseArray(sortArray);
|
||||
for(int i=0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
Long id = jsonObject.getLong("id");
|
||||
Integer sort = jsonObject.getInteger("sort");
|
||||
Slide slide = new Slide().dao().findById(id);
|
||||
slide.setSort(sort);
|
||||
slide.update();
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Long ids[] = getParaValuesToLong("ids");
|
||||
if(ArrayUtils.isNotEmpty(ids)){
|
||||
for(Long id:ids){
|
||||
new Slide().dao().deleteById(id);
|
||||
}
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Tag;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 标签
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/tag")
|
||||
public class TagController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index() {
|
||||
setListQuery();
|
||||
String name = getPara("name");
|
||||
Integer pageNumber = getParaToInt("pageNumber");
|
||||
if(pageNumber==null){
|
||||
pageNumber = 1;
|
||||
}
|
||||
setAttr("page", new Tag().dao().findPage(pageNumber,PAGE_SIZE,getCurrentSite().getId()));
|
||||
setAttr("name", name);
|
||||
render(getView("tag/index"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
render(getView("tag/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
Tag tag = getModel(Tag.class,"",true);
|
||||
tag.setSiteId(getCurrentSite().getId());
|
||||
tag.setCreateDate(new Date());
|
||||
tag.setUpdateDate(new Date());
|
||||
tag.save();
|
||||
redirect(getListQuery("/admin/tag"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Integer id = getParaToInt("id");
|
||||
setAttr("tag", new Tag().dao().findById(id));
|
||||
render(getView("tag/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update() {
|
||||
Tag tag = getModel(Tag.class,"",true);
|
||||
tag.setUpdateDate(new Date());
|
||||
tag.update();
|
||||
redirect(getListQuery("/admin/tag"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Integer ids[] = getParaValuesToInt("ids");
|
||||
if(ArrayUtils.isNotEmpty(ids)){
|
||||
for(Integer id:ids){
|
||||
new Tag().dao().deleteById(id);
|
||||
}
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,153 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
import com.jfinal.kit.PathKit;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import vip.fuck.sm.plugins.cms.CommonAttribute;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
import vip.fuck.sm.plugins.cms.util.TemplateUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Controller - 模板
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/template")
|
||||
|
||||
public class TemplateController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index() {
|
||||
setListQuery();
|
||||
String directory = getPara("directory");
|
||||
if(StringUtils.isNotBlank(directory)){
|
||||
setAttr("templateFiles", TemplateUtils.getTemplateFiles(directory.replaceAll(",", "/")));
|
||||
setAttr("directory", directory);
|
||||
}else{
|
||||
setAttr("templateFiles", TemplateUtils.getSiteTemplates(getCurrentSite()));
|
||||
}
|
||||
render(getView("template/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
String directory = getPara("directory");
|
||||
setAttr("directory", directory);
|
||||
render(getView("template/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
String fileName = getPara("fileName");
|
||||
String content = getPara("content");
|
||||
String directory = getPara("directory");
|
||||
String filePath = "";
|
||||
if(StringUtils.isNotBlank(directory)){
|
||||
filePath = "/"+directory.replaceAll(",", "/")+"/"+fileName;
|
||||
}else{
|
||||
filePath = "/"+fileName;
|
||||
}
|
||||
try {
|
||||
FileUtils.write(new File(PathKit.getWebRootPath()+"/templates/"+filePath), content);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
redirect(getListQuery("/admin/template"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public void view() {
|
||||
String fileName = getPara("fileName");
|
||||
String directory = getPara("directory");
|
||||
if (StringUtils.isBlank(fileName)) {
|
||||
render(CommonAttribute.ADMIN_ERROR_VIEW);
|
||||
return;
|
||||
}
|
||||
String filePath = "";
|
||||
if(StringUtils.isNotBlank(directory)){
|
||||
filePath = "/"+directory.replaceAll(",", "/")+"/"+fileName;
|
||||
}else{
|
||||
filePath = "/"+fileName;
|
||||
}
|
||||
redirect("/templates/"+filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
String fileName = getPara("fileName");
|
||||
String directory = getPara("directory");
|
||||
if (StringUtils.isBlank(fileName)) {
|
||||
render(CommonAttribute.ADMIN_ERROR_VIEW);
|
||||
return;
|
||||
}
|
||||
setAttr("directory", directory);
|
||||
setAttr("fileName", fileName);
|
||||
String filePath = "";
|
||||
if(StringUtils.isNotBlank(directory)){
|
||||
filePath = "/"+directory.replaceAll(",", "/")+"/"+fileName;
|
||||
}else{
|
||||
filePath = "/"+fileName;
|
||||
}
|
||||
setAttr("content", StringEscapeUtils.escapeHtml(TemplateUtils.read(filePath)));
|
||||
render(getView("template/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update() {
|
||||
String fileName = getPara("fileName");
|
||||
String directory = getPara("directory");
|
||||
String content = getPara("content");
|
||||
if (StringUtils.isBlank(fileName) || content == null) {
|
||||
render(CommonAttribute.ADMIN_ERROR_VIEW);
|
||||
return;
|
||||
}
|
||||
String filePath = "";
|
||||
if(StringUtils.isNotBlank(directory)){
|
||||
filePath = "/"+directory.replaceAll(",", "/")+"/"+fileName;
|
||||
}else{
|
||||
filePath = "/"+fileName;
|
||||
}
|
||||
TemplateUtils.write(filePath, content);
|
||||
redirect(getListQuery("/admin/template"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
String fileName = getPara("fileName");
|
||||
String directory = getPara("directory");
|
||||
String filePath = "";
|
||||
if(StringUtils.isNotBlank(directory)){
|
||||
filePath = "/"+directory.replaceAll(",", "/")+"/"+fileName;
|
||||
}else{
|
||||
filePath = "/"+fileName;
|
||||
}
|
||||
TemplateUtils.delete(filePath);
|
||||
redirect(getListQuery("/admin/template"));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Web;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 网站信息
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/web")
|
||||
public class WebController extends BaseController {
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void index(){
|
||||
Web web = new Web().dao().findBySiteId(getCurrentSite().getId());
|
||||
setAttr("web", web);
|
||||
render(getView("web/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void update(){
|
||||
Web web = getModel(Web.class,"",true);
|
||||
web.update();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,129 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.WechatMenu;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
import vip.fuck.sm.plugins.cms.util.WeixinUtils;
|
||||
|
||||
import java.util.*;
|
||||
/**
|
||||
* Controller - 微信菜单
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/wechat_menu")
|
||||
public class WechatMenuController extends BaseController {
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void index() {
|
||||
List<WechatMenu> wechatMenus = new WechatMenu().dao().findRoots();
|
||||
setAttr("wechatMenus", wechatMenus);
|
||||
render(getView("wechat_menu/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void update() {
|
||||
String data = getPara("data");
|
||||
JSONArray jsonArray = JSONArray.parseArray(data);
|
||||
for(int i=0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
WechatMenu wechatMenu = updateData(jsonObject,null);
|
||||
JSONArray childArray = jsonObject.getJSONArray("child");
|
||||
if(childArray.size()>0){
|
||||
for(int j=0;j<childArray.size();j++){
|
||||
JSONObject childObject = childArray.getJSONObject(j);
|
||||
updateData(childObject,wechatMenu.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<WechatMenu> wechatMenus = new WechatMenu().dao().findRoots();
|
||||
List<Map<String,Object>> button = new ArrayList<>();
|
||||
for(WechatMenu wechatMenu : wechatMenus){
|
||||
List<WechatMenu> subMenus = wechatMenu.getSubMenus();
|
||||
if(CollectionUtils.isNotEmpty(subMenus)){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("name", wechatMenu.getName());
|
||||
List<Map<String,Object>> list = new ArrayList<>();
|
||||
for(WechatMenu subMenu : subMenus){
|
||||
Map<String,Object> subMap = new HashMap<>();
|
||||
subMap.put("type", subMenu.getType());
|
||||
subMap.put("name", subMenu.getName());
|
||||
if("click".equals(subMenu.getType())){
|
||||
subMap.put("key", subMenu.getKeywords());
|
||||
}else if("view".equals(subMenu.getType())){
|
||||
subMap.put("url", subMenu.getUrl());
|
||||
}else if("miniprogram".equals(subMenu.getType())){
|
||||
subMap.put("appid", subMenu.getMiniappid());
|
||||
subMap.put("url", subMenu.getMiniurl());
|
||||
subMap.put("pagepath", subMenu.getMinipath());
|
||||
}
|
||||
list.add(subMap);
|
||||
}
|
||||
map.put("sub_button", list);
|
||||
button.add(map);
|
||||
}else{
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("name", wechatMenu.getName());
|
||||
map.put("type", wechatMenu.getType());
|
||||
if("click".equals(wechatMenu.getType())){
|
||||
map.put("key", wechatMenu.getKeywords());
|
||||
}else if("view".equals(wechatMenu.getType())){
|
||||
map.put("url", wechatMenu.getUrl());
|
||||
}else if("miniprogram".equals(wechatMenu.getType())){
|
||||
map.put("appid", wechatMenu.getMiniappid());
|
||||
map.put("url", wechatMenu.getMiniurl());
|
||||
map.put("pagepath", wechatMenu.getMinipath());
|
||||
}
|
||||
button.add(map);
|
||||
}
|
||||
}
|
||||
Map<String,Object> menu = new HashMap<>();
|
||||
menu.put("button", button);
|
||||
WeixinUtils.menuCreate(JSONObject.toJSONString(menu));
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
// todo @NotAction
|
||||
public WechatMenu updateData(JSONObject jsonObject,Integer parentId){
|
||||
Long id = jsonObject.getLong("id");
|
||||
String name = jsonObject.getString("name");
|
||||
String type = jsonObject.getString("type");
|
||||
String keywords = jsonObject.getString("keywords");
|
||||
String url = jsonObject.getString("url");
|
||||
String miniappid = jsonObject.getString("miniappid");
|
||||
String miniurl = jsonObject.getString("miniurl");
|
||||
String minipath = jsonObject.getString("minipath");
|
||||
WechatMenu wechatMenu = null;
|
||||
if(id != null){
|
||||
wechatMenu = new WechatMenu().dao().findById(id);
|
||||
}
|
||||
if(wechatMenu == null){
|
||||
wechatMenu = new WechatMenu();
|
||||
wechatMenu.setCreateDate(new Date());
|
||||
}
|
||||
wechatMenu.setUpdateDate(new Date());
|
||||
wechatMenu.setParentId(parentId);
|
||||
wechatMenu.setName(name);
|
||||
wechatMenu.setType(type);
|
||||
wechatMenu.setKeywords(keywords);
|
||||
wechatMenu.setUrl(url);
|
||||
wechatMenu.setMiniappid(miniappid);
|
||||
wechatMenu.setMiniurl(miniurl);
|
||||
wechatMenu.setMinipath(minipath);
|
||||
if(wechatMenu.getId() == null){
|
||||
wechatMenu.save();
|
||||
}else{
|
||||
wechatMenu.update();
|
||||
}
|
||||
return wechatMenu;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,134 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin.div;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cms.Feedback;
|
||||
import com.cms.controller.admin.BaseController;
|
||||
import com.cms.entity.Div;
|
||||
import com.cms.entity.DivField;
|
||||
import com.cms.routes.RouteMapping;
|
||||
import com.cms.util.FieldUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 自定义表字段
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/div/div_field")
|
||||
public class DivFieldController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index() {
|
||||
setListQuery();
|
||||
Integer divId = getParaToInt("divId");
|
||||
List<DivField> divFields = new DivField().dao().findList(divId);
|
||||
setAttr("divFields", divFields);
|
||||
setAttr("divId", divId);
|
||||
render(getView("div/div_field/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查名称是否存在
|
||||
*/
|
||||
public void checkName() {
|
||||
Integer divId = getParaToInt("divId");
|
||||
String name = getPara("name");
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
renderJson(false);
|
||||
return;
|
||||
}
|
||||
renderJson(!new DivField().dao().nameExists(divId,name));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
Integer divId = getParaToInt("divId");
|
||||
setAttr("div", new Div().dao().findById(divId));
|
||||
DivField divField = new DivField();
|
||||
divField.setDivId(divId);
|
||||
setAttr("divField",divField);
|
||||
render(getView("div/div_field/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
DivField divField = getModel(DivField.class,"",true);
|
||||
divField.setCreateDate(new Date());
|
||||
divField.setUpdateDate(new Date());
|
||||
divField.save();
|
||||
//数据库表
|
||||
Div div = divField.getDiv();
|
||||
FieldUtils.add(div.getTableName(), divField.getName(),divField.getUiType());
|
||||
redirect(getListQuery("/admin/div/div_field"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Integer id = getParaToInt("id");
|
||||
setAttr("divField", new DivField().dao().findById(id));
|
||||
render(getView("div/div_field/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
public void update() {
|
||||
DivField divField = getModel(DivField.class,"",true);
|
||||
divField.setUpdateDate(new Date());
|
||||
divField.update();
|
||||
redirect(getListQuery("/admin/div/div_field"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public void updateSort(){
|
||||
String sortArray = getPara("sortArray");
|
||||
JSONArray jsonArray = JSONArray.parseArray(sortArray);
|
||||
for(int i=0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
Long id = jsonObject.getLong("id");
|
||||
Integer sort = jsonObject.getInteger("sort");
|
||||
DivField divField = new DivField().dao().findById(id);
|
||||
divField.setSort(sort);
|
||||
divField.update();
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Integer ids[] = getParaValuesToInt("ids");
|
||||
if(ArrayUtils.isNotEmpty(ids)){
|
||||
for(Integer id:ids){
|
||||
DivField divField = new DivField().dao().findById(id);
|
||||
Div div = divField.getDiv();
|
||||
//数据库表
|
||||
FieldUtils.delete(div.getTableName(), divField.getName());
|
||||
divField.delete();
|
||||
}
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,124 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.admin.model;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cms.Feedback;
|
||||
import com.cms.controller.admin.BaseController;
|
||||
import com.cms.entity.Model;
|
||||
import com.cms.entity.ModelField;
|
||||
import com.cms.routes.RouteMapping;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 模型字段
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/admin/model/model_field")
|
||||
public class ModelFieldController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public void index() {
|
||||
setListQuery();
|
||||
Integer modelId = getParaToInt("modelId");
|
||||
List<ModelField> modelFields = new ModelField().dao().findList(modelId);
|
||||
setAttr("modelFields", modelFields);
|
||||
setAttr("modelId", modelId);
|
||||
render(getView("model/model_field/index"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查名称是否存在
|
||||
*/
|
||||
public void checkName() {
|
||||
Integer modelId = getParaToInt("modelId");
|
||||
String name = getPara("name");
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
renderJson(false);
|
||||
return;
|
||||
}
|
||||
renderJson(!new ModelField().dao().nameExists(modelId,name));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add() {
|
||||
Integer modelId = getParaToInt("modelId");
|
||||
setAttr("model", new Model().dao().findById(modelId));
|
||||
render(getView("model/model_field/add"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save() {
|
||||
ModelField modelField = getModel(ModelField.class,"",true);
|
||||
modelField.setCreateDate(new Date());
|
||||
modelField.setUpdateDate(new Date());
|
||||
modelField.save();
|
||||
redirect(getListQuery("/admin/model/model_field"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public void edit() {
|
||||
Integer id = getParaToInt("id");
|
||||
setAttr("modelField", new ModelField().dao().findById(id));
|
||||
render(getView("model/model_field/edit"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public void update() {
|
||||
ModelField modelField = getModel(ModelField.class,"",true);
|
||||
modelField.setUpdateDate(new Date());
|
||||
modelField.update();
|
||||
redirect(getListQuery("/admin/model/model_field"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public void updateSort(){
|
||||
String sortArray = getPara("sortArray");
|
||||
JSONArray jsonArray = JSONArray.parseArray(sortArray);
|
||||
for(int i=0;i<jsonArray.size();i++){
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
Long id = jsonObject.getLong("id");
|
||||
Integer sort = jsonObject.getInteger("sort");
|
||||
ModelField modelField = new ModelField().dao().findById(id);
|
||||
modelField.setSort(sort);
|
||||
modelField.update();
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete() {
|
||||
Integer ids[] = getParaValuesToInt("ids");
|
||||
if(ArrayUtils.isNotEmpty(ids)){
|
||||
for(Integer id:ids){
|
||||
ModelField modelField = new ModelField().dao().findById(id);
|
||||
modelField.delete();
|
||||
}
|
||||
}
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.common;
|
||||
|
||||
import org.noear.solon.annotation.Controller;
|
||||
import vip.fuck.sm.plugins.cms.controller.admin.BaseController;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
@RouteMapping(url = "/common/captcha")
|
||||
public class CaptchaController extends BaseController {
|
||||
|
||||
public void image(){
|
||||
renderCaptcha();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void check(){
|
||||
renderJson(validateCaptcha("captcha"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.common;
|
||||
|
||||
import com.cms.routes.RouteMapping;
|
||||
import com.jfinal.core.Controller;
|
||||
import com.jfinal.kit.PathKit;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@RouteMapping(url = "/common/down")
|
||||
public class DownController extends Controller{
|
||||
|
||||
public void file(){
|
||||
String fileKey = getPara("fileKey");
|
||||
renderFile(new File(PathKit.getWebRootPath()+fileKey));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.front;
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
/**
|
||||
* Controller - Ajax
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/ajax")
|
||||
public class AjaxController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* HTML
|
||||
*/
|
||||
public void html(){
|
||||
keepPara();
|
||||
String html = getPara("html");
|
||||
render("/templates/"+getCurrentTemplate()+"/"+html);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.front;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import vip.fuck.sm.plugins.cms.entity.Site;
|
||||
import vip.fuck.sm.plugins.cms.util.DeviceUtils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 基类
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BaseController extends vip.fuck.sm.plugins.cms.controller.admin.BaseController {
|
||||
protected static final int PAGE_SIZE = 10;
|
||||
private static final String LIST_QUERY_COOKIE_NAME = "frontListQuery";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前站点
|
||||
*
|
||||
* @return 当前站点
|
||||
*/
|
||||
// @NotAction
|
||||
protected Site getCurrentSite() {
|
||||
Site currentSite = getAttr(Site.CURRENT_SITE,Site.class);
|
||||
return currentSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前模板
|
||||
*
|
||||
* @return 当前模板
|
||||
*/
|
||||
// @NotAction
|
||||
protected String getCurrentTemplate() {
|
||||
Site currentSite = getCurrentSite();
|
||||
if(DeviceUtils.isMobile(getRequest())){
|
||||
if(StringUtils.isNotBlank(currentSite.getMobileTemplate())){
|
||||
return currentSite.getMobileTemplate();
|
||||
}
|
||||
}
|
||||
return currentSite.getPcTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取BigDecimal数据
|
||||
*
|
||||
* @param name
|
||||
* 名称
|
||||
* @return BigDecimal数据
|
||||
*/
|
||||
// @NotAction
|
||||
public BigDecimal getParaToBigDecimal(String name){
|
||||
String value = getPara(name);
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
return new BigDecimal(value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// @NotAction
|
||||
public void setListQuery(){
|
||||
Map<String, List<String>> paraMap = getParaMap();
|
||||
String listQuery = "";
|
||||
if(paraMap!=null && !paraMap.isEmpty()){
|
||||
for(String key : paraMap.keySet()){
|
||||
List<String> values = paraMap.get(key);
|
||||
if(ObjectUtil.isNotEmpty(values)){
|
||||
for(String value : values){
|
||||
listQuery+="&"+key+"="+value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(listQuery)){
|
||||
listQuery = listQuery.substring(1);
|
||||
try {
|
||||
setCookie(LIST_QUERY_COOKIE_NAME, URLEncoder.encode(listQuery, "UTF-8"),10 * 60,"");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.front;
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.entity.Category;
|
||||
import vip.fuck.sm.plugins.cms.entity.Model;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
/**
|
||||
* Controller - 栏目
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/category")
|
||||
public class CategoryController extends BaseController {
|
||||
|
||||
/**
|
||||
* 栏目
|
||||
*/
|
||||
public void index() {
|
||||
Integer id = getParaToInt("id");
|
||||
Category category = new Category().dao().findById(id);
|
||||
setAttr("currentCategory", category);
|
||||
Integer pageNumber = getParaToInt("pageNumber");
|
||||
if(pageNumber==null){
|
||||
pageNumber = 1;
|
||||
}
|
||||
setAttr("pageNumber", pageNumber);
|
||||
Model model = category.getModel();
|
||||
if(model.getType() == Model.Type.PAGE.ordinal()){
|
||||
render("/templates/"+getCurrentTemplate()+"/"+category.getDetailTemplate());
|
||||
}else{
|
||||
render("/templates/"+getCurrentTemplate()+"/"+category.getListTemplate());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package vip.fuck.sm.plugins.cms.controller.front;
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.entity.Category;
|
||||
import vip.fuck.sm.plugins.cms.entity.Content;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
/**
|
||||
* Controller - 内容
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/content")
|
||||
public class ContentController extends BaseController {
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
public void index() {
|
||||
Integer id = getParaToInt("id");
|
||||
Content content = new Content().dao().findById(id);
|
||||
setAttr("currentContent", content);
|
||||
Category category = content.getCategory();
|
||||
setAttr("currentCategory", category);
|
||||
render("/templates/"+getCurrentTemplate()+"/"+category.getDetailTemplate());
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击数
|
||||
*/
|
||||
public void visits() {
|
||||
Integer id = getParaToInt("id");
|
||||
if (id == null) {
|
||||
renderJson(0L);
|
||||
return;
|
||||
}
|
||||
Content content = new Content().dao().findById(id);
|
||||
Integer visits = content.getVisits();
|
||||
visits = visits+1;
|
||||
content.setVisits(visits);
|
||||
content.update();
|
||||
renderJavascript("document.write("+visits+")");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,166 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.front;
|
||||
|
||||
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
import vip.fuck.sm.plugins.cms.Config;
|
||||
import vip.fuck.sm.plugins.cms.entity.Div;
|
||||
import vip.fuck.sm.plugins.cms.entity.DivField;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
import vip.fuck.sm.plugins.cms.util.HtmlUtils;
|
||||
import vip.fuck.sm.plugins.cms.util.SystemUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RouteMapping(url = "/api/dev/data")
|
||||
public class DevOpenController extends BaseController{
|
||||
|
||||
public void listByDivId(){
|
||||
setListQuery();
|
||||
Integer divId = getParaToInt("divId");
|
||||
Map<String, List<String>> params = getParaMap();
|
||||
Integer pageNumber = getParaToInt("pageNumber",1);
|
||||
Integer pageSize = getParaToInt("pageSize",PAGE_SIZE);
|
||||
|
||||
Div div = new Div().dao().findById(divId);
|
||||
List<DivField> divFields = new DivField().dao().findList(divId);
|
||||
String orderBySql = DbUtils.getOrderBySql("createDate desc");
|
||||
|
||||
String fromSql = " from "+div.getTableName()+" where 1=1 ";
|
||||
Object[] args = null;
|
||||
List<Object> argsList = new ArrayList<>();
|
||||
if(params!=null && divFields!=null){
|
||||
for(Map.Entry<String,List<String>> en:params.entrySet()){
|
||||
List<String> value = en.getValue();
|
||||
if(value!=null && !value.isEmpty()){
|
||||
List<String> collect
|
||||
= value.stream().filter(it -> it != null && !it.isEmpty()).collect(Collectors.toList());
|
||||
if(collect.isEmpty()){
|
||||
continue;
|
||||
}
|
||||
String key = en.getKey();
|
||||
Optional<DivField> isInField =
|
||||
divFields.stream().filter(it-> Objects.equals(it.getName(),key)).findFirst();
|
||||
boolean sp = collect.size() == 1;
|
||||
if(isInField.isPresent()){
|
||||
DivField divField = isInField.get();
|
||||
String name = divField.getName();
|
||||
String queryType = divField.getQueryType();
|
||||
if("like".equals(queryType)){
|
||||
if(sp){
|
||||
fromSql+=" and "+name+" like concat('%',?,'%') ";
|
||||
argsList.add(collect.get(0));
|
||||
}else{
|
||||
fromSql+=" and (";
|
||||
for (int i = 0; i < collect.size(); i++) {
|
||||
boolean last = i == collect.size()-1;
|
||||
fromSql+= name + " like concat('%',?,'%') ";
|
||||
if(!last){
|
||||
fromSql+=" or ";
|
||||
}
|
||||
argsList.add(collect.get(i));
|
||||
}
|
||||
fromSql+=") ";
|
||||
}
|
||||
}else{
|
||||
if(sp){
|
||||
fromSql+=" and "+name+" = ? ";
|
||||
argsList.add(collect.get(0));
|
||||
}else{
|
||||
fromSql+=" and in( ";
|
||||
for (int i = 0; i < collect.size(); i++) {
|
||||
boolean last = i == collect.size()-1;
|
||||
fromSql+= name + " ? ";
|
||||
if(!last){
|
||||
fromSql+=" , ";
|
||||
}
|
||||
argsList.add(collect.get(i));
|
||||
}
|
||||
fromSql+=") ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(!argsList.isEmpty()){
|
||||
args = new Object[argsList.size()];
|
||||
args = argsList.toArray(args);
|
||||
}
|
||||
fromSql+=orderBySql;;
|
||||
Page<Record> page;
|
||||
if(args != null){
|
||||
page = Db.paginate(pageNumber, pageSize,
|
||||
"select *", fromSql,args);
|
||||
}else{
|
||||
page = Db.paginate(pageNumber, pageSize,
|
||||
"select *", fromSql);
|
||||
}
|
||||
|
||||
for (Record record : page.getList()) {
|
||||
joinImageDomain(record,divFields);
|
||||
}
|
||||
Map<String, Object> rel = new HashMap<>();
|
||||
rel.put("code",200);
|
||||
rel.put("msg","操作成功");
|
||||
rel.put("data",page);
|
||||
rel.put("divFields",divFields);
|
||||
renderJson(rel );
|
||||
}
|
||||
|
||||
// @NotAction todo
|
||||
private void joinImageDomain(Record record ,List<DivField> divFields){
|
||||
if(record==null || divFields==null){
|
||||
return;
|
||||
}
|
||||
Config config = SystemUtils.getConfig();
|
||||
|
||||
for (String columnName : record.getColumnNames()) {
|
||||
Object o = record.get(columnName);
|
||||
boolean isUploadImg = divFields.stream()
|
||||
.anyMatch(it->"single_img_upload".equals(it.getUiType()) && Objects.equals(columnName,it.getName()));
|
||||
boolean isRichText = divFields.stream()
|
||||
.anyMatch(it->"rich_text".equals(it.getUiType()) && Objects.equals(columnName,it.getName()));
|
||||
if(o instanceof String){
|
||||
String v = (String) o;
|
||||
if(isUploadImg){
|
||||
if(v.startsWith("/static/")){
|
||||
record.set(columnName,config.getDomain()+v);
|
||||
}else{
|
||||
record.set(columnName,config.getDomain()+"/static/images/nopic.jpg");
|
||||
}
|
||||
} else if (isRichText) {
|
||||
String s = HtmlUtils.replaceHtmlTag(v,"img","src",
|
||||
"src=\""+config.getDomain(),
|
||||
"\" onerror=\"javascript:this.src='"+config.getDomain()+"/static/images/nopic.jpg';\"");
|
||||
record.set(columnName,s);
|
||||
}
|
||||
}else if(o ==null ||Objects.equals("",o)){
|
||||
if(isUploadImg){
|
||||
record.set(columnName,config.getDomain()+"/static/images/nopic.jpg");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void getByDivIdAndId(){
|
||||
Integer id = getParaToInt("id");
|
||||
Integer divId = getParaToInt("divId");
|
||||
Div div = new Div().dao().findById(divId);
|
||||
List<DivField> divFields = new DivField().dao().findList(divId);
|
||||
Record divData = Db.findById(div.getTableName(), id);
|
||||
joinImageDomain(divData,divFields);
|
||||
Map<String, Object> rel = new HashMap<>();
|
||||
rel.put("code",200);
|
||||
rel.put("msg","操作成功");
|
||||
rel.put("data",divData);
|
||||
rel.put("divFields",divFields);
|
||||
renderJson(rel );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.front;
|
||||
|
||||
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Div;
|
||||
import vip.fuck.sm.plugins.cms.entity.DivField;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Controller - 自定义表
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/div")
|
||||
public class DivController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
public void save(){
|
||||
Integer id = getParaToInt("id");
|
||||
Div div = new Div().dao().findById(id);
|
||||
List<DivField> formFields = new DivField().dao().findList(id);
|
||||
Record divData = new Record();
|
||||
for(DivField divField : formFields){
|
||||
String value = getPara(divField.getName());
|
||||
divData.set(divField.getName(), value);
|
||||
}
|
||||
divData.set("createDate", new Date());
|
||||
divData.set("updateDate", new Date());
|
||||
Db.save(div.getTableName(), divData);
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.front;
|
||||
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.entity.Guestbook;
|
||||
import vip.fuck.sm.plugins.cms.entity.Site;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Controller - 留言
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/guestbook")
|
||||
public class GuestbookController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 留言
|
||||
*/
|
||||
public void save(){
|
||||
if(!validateCaptcha("captcha")){
|
||||
renderJson(Feedback.error("验证码错误!"));
|
||||
return;
|
||||
}
|
||||
Site currentSite = getCurrentSite();
|
||||
Guestbook guestbook = getModel(Guestbook.class,"",true);
|
||||
guestbook.setStatus(0);
|
||||
guestbook.setCreateDate(new Date());
|
||||
guestbook.setUpdateDate(new Date());
|
||||
guestbook.setSiteId(currentSite.getId());
|
||||
guestbook.save();
|
||||
renderJson(Feedback.success(new HashMap<>()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.front;
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
/**
|
||||
* Controller - 首页
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/")
|
||||
public class IndexController extends BaseController {
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*/
|
||||
public void index() {
|
||||
render("/templates/"+getCurrentTemplate()+"/index.html");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.front;
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
/**
|
||||
* Controller - 页面
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/page")
|
||||
public class PageController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 页面
|
||||
*/
|
||||
public void index(){
|
||||
keepPara();
|
||||
String html = getPara(0);
|
||||
render("/templates/"+getCurrentTemplate()+"/"+html+".html");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.front;
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
/**
|
||||
* Controller - 搜索
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/search")
|
||||
public class SearchController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
public void index() {
|
||||
String keyword = getPara("keyword");
|
||||
Integer pageNumber = getParaToInt("pageNumber");
|
||||
if(pageNumber==null){
|
||||
pageNumber = 1;
|
||||
}
|
||||
setAttr("pageNumber", pageNumber);
|
||||
setAttr("keyword", keyword);
|
||||
render("/templates/"+getCurrentTemplate()+"/search.html");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.front;
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.entity.Tag;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
/**
|
||||
* Controller - 标签
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/tag")
|
||||
public class TagController extends BaseController {
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
public void index() {
|
||||
Integer id = getParaToInt("id");
|
||||
Tag tag = new Tag().dao().findById(id);
|
||||
if(tag==null){
|
||||
renderError(404);
|
||||
return;
|
||||
}
|
||||
setAttr("currentTag",tag);
|
||||
render("/templates/"+getCurrentTemplate()+"/tag.html");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.xcx;
|
||||
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.time.DateFormatUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.controller.front.BaseController;
|
||||
import vip.fuck.sm.plugins.cms.entity.Content;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
/**
|
||||
* Controller - 栏目
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/xcx/category")
|
||||
public class CategoryController extends BaseController {
|
||||
|
||||
/**
|
||||
* 列表页
|
||||
*/
|
||||
public void index(){
|
||||
Long categoryId = getParaToLong("categoryId");
|
||||
List<Content> contents = new Content().dao().find("select * from cms_content where categoryId="+categoryId);
|
||||
List<Map<String,Object>> contentsMap = new ArrayList<>();
|
||||
for(Content content : contents){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("id", content.getId());
|
||||
map.put("title", content.getTitle());
|
||||
map.put("createDate", DateFormatUtils.format(content.getCreateDate(), "yyyy-MM-dd HH:mm:ss"));
|
||||
map.put("ico",content.getIco());
|
||||
map.put("text", StringUtils.substring(content.getText(), 0,50));
|
||||
contentsMap.add(map);
|
||||
}
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
result.put("contents", contentsMap);
|
||||
renderJson(Feedback.success(result));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.xcx;
|
||||
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.time.DateFormatUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.controller.front.BaseController;
|
||||
import vip.fuck.sm.plugins.cms.entity.Content;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Controller - 内容
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/xcx/content")
|
||||
public class ContentController extends BaseController {
|
||||
|
||||
/**
|
||||
* 内容页
|
||||
*/
|
||||
public void index(){
|
||||
Long contentId = getParaToLong("contentId");
|
||||
Content content = new Content().dao().findById(contentId);
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("title", content.getTitle());
|
||||
map.put("createDate", DateFormatUtils.format(content.getCreateDate(), "yyyy-MM-dd HH:mm:ss"));
|
||||
map.put("ico",content.getIco());
|
||||
map.put("introduction",content.getIntroduction());
|
||||
map.put("text", StringUtils.substring(content.getText(), 0,50));
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
result.put("content", map);
|
||||
renderJson(Feedback.success(result));
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package vip.fuck.sm.plugins.cms.controller.xcx;
|
||||
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.time.DateFormatUtils;
|
||||
import vip.fuck.sm.plugins.cms.Feedback;
|
||||
import vip.fuck.sm.plugins.cms.controller.front.BaseController;
|
||||
import vip.fuck.sm.plugins.cms.entity.Content;
|
||||
import vip.fuck.sm.plugins.cms.entity.Slide;
|
||||
import vip.fuck.sm.plugins.cms.routes.RouteMapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
/**
|
||||
* Controller - api
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RouteMapping(url = "/xcx")
|
||||
public class IndexController extends BaseController {
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*/
|
||||
public void index() {
|
||||
Long siteId = getParaToLong("siteId");
|
||||
Long categoryId = getParaToLong("categoryId");
|
||||
List<Slide> slides = new Slide().dao().find("select * from cms_slide where siteId="+siteId);
|
||||
List<Map<String,Object>> slidesMap = new ArrayList<>();
|
||||
for(Slide slide : slides){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("image", slide.getImage());
|
||||
map.put("url", slide.getUrl());
|
||||
slidesMap.add(map);
|
||||
}
|
||||
List<Content> contents = new Content().dao().find("select * from cms_content where siteId="+siteId+" and categoryId="+categoryId+" limit 4");
|
||||
List<Map<String,Object>> contentsMap = new ArrayList<>();
|
||||
for(Content content : contents){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("id", content.getId());
|
||||
map.put("title", content.getTitle());
|
||||
map.put("createDate", DateFormatUtils.format(content.getCreateDate(), "yyyy-MM-dd HH:mm:ss"));
|
||||
map.put("ico",content.getIco());
|
||||
map.put("text", StringUtils.substring(content.getText(), 0,50));
|
||||
contentsMap.add(map);
|
||||
}
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
result.put("slides", slidesMap);
|
||||
result.put("contents", contentsMap);
|
||||
renderJson(Feedback.success(result));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,110 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseAdmin;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entity - 管理员
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Admin extends BaseAdmin<Admin> {
|
||||
|
||||
/** 管理员session名称 */
|
||||
public static final String SESSION_ADMIN="session_admin";
|
||||
|
||||
/** 角色 */
|
||||
@JSONField(serialize=false)
|
||||
private Role role;
|
||||
|
||||
/**
|
||||
* 获取权限
|
||||
*
|
||||
* @return 权限
|
||||
*/
|
||||
public List<String> getPermissions() {
|
||||
return JSONArray.parseArray(getRole().getPermission(), String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色
|
||||
*
|
||||
* @return 角色
|
||||
*/
|
||||
public Role getRole(){
|
||||
if(role == null){
|
||||
role = new Role().dao().findFirst("select * from cms_role where id in (select roleId from cms_admin_role where adminId=?)",getId());
|
||||
}
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色ID
|
||||
* @return
|
||||
*/
|
||||
public List<Integer> getRoleIds(){
|
||||
List<Integer> roleIds = Db.query("select roleId from cms_admin_role where adminId=?",getId());
|
||||
return roleIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户名是否存在
|
||||
*
|
||||
* @param username
|
||||
* 用户名(忽略大小写)
|
||||
* @return 用户名是否存在
|
||||
*/
|
||||
public boolean usernameExists(String username) {
|
||||
if (StrKit.isBlank(username)) {
|
||||
return false;
|
||||
}
|
||||
Long count = Db.queryLong("select count(1) from cms_admin where username = ?",username);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户名查找管理员
|
||||
*
|
||||
* @param username
|
||||
* 用户名(忽略大小写)
|
||||
* @return 管理员,若不存在则返回null
|
||||
*/
|
||||
public Admin findByUsername(String username) {
|
||||
if (StrKit.isBlank(username)) {
|
||||
return null;
|
||||
}
|
||||
return findFirst("select * from cms_admin where username = ?",username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找管理员分页
|
||||
*
|
||||
* @param pageNumber
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 每页记录数
|
||||
* @return 管理员分页
|
||||
*/
|
||||
public Page<Admin> findPage(String name,String username,Integer pageNumber,Integer pageSize){
|
||||
String filterSql = "";
|
||||
if(StringUtils.isNotBlank(name)){
|
||||
filterSql+= " and name like '%"+name+"%'";
|
||||
}
|
||||
if(StringUtils.isNotBlank(username)){
|
||||
filterSql+= " and username like '%"+username+"%'";
|
||||
}
|
||||
String orderBySql = DbUtils.getOrderBySql("createDate desc");
|
||||
return paginate(pageNumber, pageSize, "select *", "from cms_admin where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseAdminRole;
|
||||
|
||||
/**
|
||||
* Entity - 管理员角色
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class AdminRole extends BaseAdminRole<AdminRole> {
|
||||
|
||||
/**
|
||||
* 根据管理员ID删除管理员角色
|
||||
*
|
||||
* @param adminId
|
||||
*/
|
||||
public void deleteByAdminId(Integer adminId){
|
||||
Db.update("delete from cms_admin_role where adminId=?",adminId);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,451 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.builder.CompareToBuilder;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import vip.fuck.sm.plugins.cms.Config;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseCategory;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
import vip.fuck.sm.plugins.cms.util.SystemUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Entity - 内容栏目
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Category extends BaseCategory<Category> {
|
||||
|
||||
/** 树路径分隔符 */
|
||||
public static final String TREE_PATH_SEPARATOR = ",";
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
public enum Status{
|
||||
DISABLE("禁用"),
|
||||
NORMAL("启用");
|
||||
public String text;
|
||||
Status(String text){
|
||||
this.text = text;
|
||||
}
|
||||
public String getText(){
|
||||
return this.text;
|
||||
}
|
||||
public static Map<Integer, Status> statusValueMap = new HashMap<>();
|
||||
static {
|
||||
Status[] values = Status.values();
|
||||
for (Status status : values) {
|
||||
statusValueMap.put(status.ordinal(), status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型
|
||||
*/
|
||||
@JSONField(serialize=false)
|
||||
private Model model;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@JSONField(serialize=false)
|
||||
private List<Content> contents;
|
||||
|
||||
/**
|
||||
* 下级分类
|
||||
*/
|
||||
@JSONField(serialize=false)
|
||||
private List<Category> children;
|
||||
|
||||
/**
|
||||
* 上级分类
|
||||
*/
|
||||
@JSONField(serialize=false)
|
||||
private Category parent;
|
||||
|
||||
/**
|
||||
* 获取模型
|
||||
* @return 模型
|
||||
*/
|
||||
public Model getModel(){
|
||||
if(model == null){
|
||||
model = new Model().dao().findById(getModelId());
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据URL目录获取分类
|
||||
* @return 分类
|
||||
*/
|
||||
public Category findByCat(String cat,Integer siteId){
|
||||
return new Category().findFirst("select * from cms_category where cat = ? and siteId=?",cat,siteId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据名称获取分类
|
||||
* @return 分类
|
||||
*/
|
||||
public Category findByName(String name,Integer siteId){
|
||||
return new Category().findFirst("select * from cms_category where name = ? and siteId=?",name,siteId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内容
|
||||
*
|
||||
* @return 内容
|
||||
*/
|
||||
public List<Content> getContents(){
|
||||
if(contents == null){
|
||||
contents = new Content().dao().find("select * from cms_content where categoryId = ?",getId());
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下级分类
|
||||
*
|
||||
* @return 下级分类
|
||||
*/
|
||||
public List<Category> getChildren() {
|
||||
if(children == null){
|
||||
children = find("select * from cms_category where parentId=? order by sort desc",getId());
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上级分类
|
||||
* @return 上级分类
|
||||
*/
|
||||
public Category getParent(){
|
||||
if(parent == null){
|
||||
parent = findById(getParentId());
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据模型ID查询分类
|
||||
*
|
||||
* @param modelId
|
||||
* 模型ID
|
||||
* @param siteId
|
||||
* 站点ID
|
||||
* @return 顶级分类
|
||||
*/
|
||||
public List<Category> findByModelId(Integer modelId,Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
if(modelId != null){
|
||||
filterSql+= " and modelId="+modelId;
|
||||
}
|
||||
String orderBySql = DbUtils.getOrderBySql("grade asc,sort desc");
|
||||
List<Category> categorys = find("select * from cms_category where 1=1 "+filterSql+orderBySql);
|
||||
sort(categorys);
|
||||
return categorys;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找顶级分类
|
||||
*
|
||||
* @param start
|
||||
* 起始位置
|
||||
* @param count
|
||||
* 数量
|
||||
* @return 顶级分类
|
||||
*/
|
||||
public List<Category> findRoots(Integer start,Integer count,Integer siteId){
|
||||
String filterSql = " and siteId="+siteId+" and status="+Status.NORMAL.ordinal();
|
||||
String countSql=DbUtils.getCountSql(start, count);
|
||||
String orderBySql = DbUtils.getOrderBySql("sort desc");
|
||||
return find("select * from cms_category where parentId is null"+filterSql+orderBySql+countSql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找上级分类
|
||||
*
|
||||
* @param categoryId
|
||||
* 分类Id
|
||||
* @param recursive
|
||||
* 是否递归
|
||||
* @param start
|
||||
* 起始位置
|
||||
* @param count
|
||||
* 数量
|
||||
* @return 上级分类
|
||||
*/
|
||||
public List<Category> findParents(Integer categoryId,Boolean recursive,Integer start, Integer count,Integer siteId){
|
||||
Category category = findById(categoryId);
|
||||
if(categoryId == null || category.getParentId() == null){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String filterSql = " and siteId="+siteId+" and status="+Status.NORMAL.ordinal();
|
||||
if(recursive){
|
||||
String countSql=DbUtils.getCountSql(start, count);
|
||||
String orderBySql = DbUtils.getOrderBySql("grade asc");
|
||||
return find("select * from cms_category where id in ("+StringUtils.join(category.getParentIds(), ",")+") "+filterSql+orderBySql+countSql);
|
||||
}else{
|
||||
return find("select * from cms_category where id = ? "+filterSql,findById(categoryId).getParentId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找下级分类
|
||||
*
|
||||
* @param categoryId
|
||||
* 分类Id
|
||||
* @param recursive
|
||||
* 是否递归
|
||||
* @param start
|
||||
* 起始位置
|
||||
* @param count
|
||||
* 数量
|
||||
* @return 下级分类
|
||||
*/
|
||||
public List<Category> findChildren(Integer categoryId,Integer status,Boolean recursive,Integer start,Integer count,Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
if(status!=null){
|
||||
filterSql += " and status="+status;
|
||||
}
|
||||
if(recursive){
|
||||
String countSql=DbUtils.getCountSql(start, count);
|
||||
String orderBySql = DbUtils.getOrderBySql("grade asc,sort desc");
|
||||
List<Category> categorys;
|
||||
if(categoryId!=null){
|
||||
categorys = find("select * from cms_category where 1=1 and treePath like ? "+filterSql+orderBySql+countSql,"%,"+categoryId+",%");
|
||||
}else{
|
||||
categorys = find("select * from cms_category where 1=1 "+filterSql+orderBySql+countSql);
|
||||
}
|
||||
sort(categorys);
|
||||
return categorys;
|
||||
}else{
|
||||
String orderBySql = DbUtils.getOrderBySql("sort desc");
|
||||
return find("select * from cms_category where parentId = ? "+filterSql+orderBySql,categoryId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找分类树
|
||||
*
|
||||
* @return 分类树
|
||||
*/
|
||||
public List<Category> findTree(Integer status,Integer siteId){
|
||||
return findChildren(null,status,true,null,null,siteId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有上级分类ID
|
||||
*
|
||||
* @return 所有上级分类ID
|
||||
*/
|
||||
public Integer[] getParentIds() {
|
||||
String[] treePaths = StringUtils.split(getTreePath(), TREE_PATH_SEPARATOR);
|
||||
Integer[] result = new Integer[treePaths.length];
|
||||
for (int i = 0; i < treePaths.length; i++) {
|
||||
result[i] = Integer.valueOf(treePaths[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序分类
|
||||
*
|
||||
* @param categorys
|
||||
* 分类
|
||||
*/
|
||||
private void sort(List<Category> categorys) {
|
||||
if(categorys == null || categorys.size()==0) {
|
||||
return;
|
||||
}
|
||||
final Map<Integer, Integer> sortMap = new HashMap<Integer, Integer>();
|
||||
for (Category category : categorys) {
|
||||
sortMap.put(category.getId(), category.getSort());
|
||||
}
|
||||
Collections.sort(categorys, new Comparator<Category>() {
|
||||
@Override
|
||||
public int compare(Category category1, Category category2) {
|
||||
Integer[] ids1 = (Integer[]) ArrayUtils.add(category1.getParentIds(), category1.getId());
|
||||
Integer[] ids2 = (Integer[]) ArrayUtils.add(category2.getParentIds(), category2.getId());
|
||||
Iterator<Integer> iterator1 = Arrays.asList(ids1).iterator();
|
||||
Iterator<Integer> iterator2 = Arrays.asList(ids2).iterator();
|
||||
CompareToBuilder compareToBuilder = new CompareToBuilder();
|
||||
while (iterator1.hasNext() && iterator2.hasNext()) {
|
||||
Integer id1 = iterator1.next();
|
||||
Integer id2 = iterator2.next();
|
||||
Integer sort1 = sortMap.get(id1);
|
||||
Integer sort2 = sortMap.get(id2);
|
||||
compareToBuilder.append(sort2,sort1).append(id1, id2);
|
||||
if (!iterator1.hasNext() || !iterator2.hasNext()) {
|
||||
compareToBuilder.append(category1.getGrade(), category2.getGrade());
|
||||
}
|
||||
}
|
||||
return compareToBuilder.toComparison();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置值
|
||||
*
|
||||
*/
|
||||
public void setValue() {
|
||||
if (getParentId() != null) {
|
||||
setTreePath(getParent().getTreePath() + getParent().getId() + TREE_PATH_SEPARATOR);
|
||||
} else {
|
||||
setTreePath(TREE_PATH_SEPARATOR);
|
||||
}
|
||||
setGrade(getParentIds().length);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文本内容
|
||||
*
|
||||
* @return 文本内容
|
||||
*/
|
||||
public String getText() {
|
||||
if (StringUtils.isEmpty(getIntroduction())) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return Jsoup.parse(getIntroduction()).text();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取第一张图片
|
||||
*
|
||||
* @return 第一张图片
|
||||
*/
|
||||
public String getFirstImage(){
|
||||
Elements elements = Jsoup.parse(getIntroduction()).getElementsByTag("img");
|
||||
if(elements!=null && elements.size()>0){
|
||||
Element element = elements.get(0);
|
||||
return element.attr("src");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取路径
|
||||
*
|
||||
* @return 路径
|
||||
*/
|
||||
public String getPath() {
|
||||
if(StringUtils.isNotBlank(getOutlink())){
|
||||
return getOutlink();
|
||||
}
|
||||
Config config = SystemUtils.getConfig();
|
||||
if(config.getSiteModel()== Config.SiteModel.DYNAMIC.ordinal()){
|
||||
return getDynamicPath(null);
|
||||
}
|
||||
return getHtmlPath(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路径
|
||||
*
|
||||
* @return 路径
|
||||
*/
|
||||
public String getPagePath(Integer pageNumber) {
|
||||
Config config = SystemUtils.getConfig();
|
||||
if(config.getSiteModel()==Config.SiteModel.DYNAMIC.ordinal()){
|
||||
return getDynamicPath(pageNumber);
|
||||
}
|
||||
return getHtmlPath(pageNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取动态路径
|
||||
*
|
||||
* @return 动态路径
|
||||
*/
|
||||
public String getDynamicPath(Integer pageNumber){
|
||||
Site site = new Site().dao().findById(getSiteId());
|
||||
String siteUrl = site.getUrl();
|
||||
String categoryCat = getCat();
|
||||
String pageNumberUrl = "";
|
||||
if(pageNumber !=null){
|
||||
pageNumberUrl = "_"+pageNumber;
|
||||
}
|
||||
return siteUrl+"/"+categoryCat+pageNumberUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取静态路径
|
||||
*
|
||||
* @return 静态路径
|
||||
*/
|
||||
public String getHtmlPath(Integer pageNumber) {
|
||||
Site site = new Site().dao().findById(getSiteId());
|
||||
String siteUrl = site.getUrl();
|
||||
String categoryCat = getCat();
|
||||
String pageNumberUrl = "";
|
||||
if(pageNumber !=null){
|
||||
pageNumberUrl = "_"+pageNumber;
|
||||
}
|
||||
return siteUrl+"/"+categoryCat+pageNumberUrl+".html";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取pc模板路径
|
||||
*
|
||||
* @return 模板路径
|
||||
*/
|
||||
public String getPcTemplatePath() {
|
||||
Site site = new Site().dao().findById(getSiteId());
|
||||
if(StringUtils.isBlank(site.getPcTemplate())){
|
||||
return null;
|
||||
}
|
||||
if(getModel().getType()==Model.Type.LIST.ordinal()){
|
||||
if(StringUtils.isBlank(getListTemplate())){
|
||||
return null;
|
||||
}
|
||||
return "templates/"+site.getPcTemplate()+"/"+getListTemplate();
|
||||
}else if(getModel().getType()==Model.Type.PAGE.ordinal()){
|
||||
if(StringUtils.isBlank(getDetailTemplate())){
|
||||
return null;
|
||||
}
|
||||
return "templates/"+site.getPcTemplate()+"/"+getDetailTemplate();
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取mobile模板路径
|
||||
*
|
||||
* @return 模板路径
|
||||
*/
|
||||
public String getMobileTemplatePath() {
|
||||
Site site = new Site().dao().findById(getSiteId());
|
||||
if(StringUtils.isBlank(site.getMobileTemplate())){
|
||||
return null;
|
||||
}
|
||||
if(getModel().getType()==Model.Type.LIST.ordinal()){
|
||||
if(StringUtils.isBlank(getListTemplate())){
|
||||
return null;
|
||||
}
|
||||
return "templates/"+site.getMobileTemplate()+"/"+getListTemplate();
|
||||
}else if(getModel().getType()==Model.Type.PAGE.ordinal()){
|
||||
if(StringUtils.isBlank(getDetailTemplate())){
|
||||
return null;
|
||||
}
|
||||
return "templates/"+site.getMobileTemplate()+"/"+getDetailTemplate();
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseCompany;
|
||||
|
||||
/**
|
||||
* Entity - 公司
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Company extends BaseCompany<Company> {
|
||||
|
||||
/** 前台公司信息 */
|
||||
public static final String CURRENT_COMPANY="currentCompany";
|
||||
|
||||
/**
|
||||
* 根据站点ID查询公司信息
|
||||
*
|
||||
*/
|
||||
public Company findBySiteId(Integer siteId){
|
||||
return findFirst("select * from cms_company where siteId=?",siteId);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,369 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
|
||||
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.time.DateFormatUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import vip.fuck.sm.plugins.cms.Config;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseContent;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
import vip.fuck.sm.plugins.cms.util.SystemUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Entity - 内容
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Content extends BaseContent<Content> {
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
public enum Status{
|
||||
DISABLE("禁用"),
|
||||
NORMAL("启用");
|
||||
public String text;
|
||||
Status(String text){
|
||||
this.text = text;
|
||||
}
|
||||
public String getText(){
|
||||
return this.text;
|
||||
}
|
||||
public static Map<Integer, Status> statusValueMap = new HashMap<>();
|
||||
static {
|
||||
Status[] values = Status.values();
|
||||
for (Status status : values) {
|
||||
statusValueMap.put(status.ordinal(), status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上一篇内容
|
||||
*/
|
||||
@JSONField(serialize=false)
|
||||
private Content lastContent;
|
||||
|
||||
/**
|
||||
* 下一篇内容
|
||||
*/
|
||||
@JSONField(serialize=false)
|
||||
private Content nextContent;
|
||||
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
@JSONField(serialize=false)
|
||||
private Category category;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
@JSONField(serialize=false)
|
||||
private List<Tag> tags;
|
||||
|
||||
|
||||
/**
|
||||
* 查找内容分页
|
||||
*
|
||||
* @param categoryId
|
||||
* 栏目ID
|
||||
* @param pageNumber
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 每页记录数
|
||||
* @return 内容分页
|
||||
*/
|
||||
public Page<Content> findPage(Integer categoryId,String title,Integer pageNumber,Integer pageSize,Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
if(categoryId!=null){
|
||||
filterSql+=" and (categoryId="+categoryId+" or categoryId in ( select id from cms_category where treePath like '%"+Category.TREE_PATH_SEPARATOR+categoryId+Category.TREE_PATH_SEPARATOR+"%'))";
|
||||
}
|
||||
if(StringUtils.isNotBlank(title)){
|
||||
filterSql+= " and title like '%"+title+"%'";
|
||||
}
|
||||
String orderBySql = DbUtils.getOrderBySql("sort desc,createDate desc");
|
||||
return paginate(pageNumber, pageSize, "select *", "from cms_content where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找内容分页
|
||||
*
|
||||
* @param categoryId
|
||||
* 分类ID
|
||||
* @param pageNumber
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 每页记录数
|
||||
* @return 内容分页
|
||||
*/
|
||||
public Page<Content> findPage(Integer categoryId,Integer tagId,String keyword,String condition,String orderBy,Integer pageNumber,Integer pageSize,Integer siteId){
|
||||
String filterSql = " and siteId="+siteId+" and status="+Status.NORMAL.ordinal();
|
||||
if(categoryId!=null){
|
||||
filterSql+=" and (categoryId="+categoryId+" or categoryId in ( select id from cms_category where treePath like '%"+Category.TREE_PATH_SEPARATOR+categoryId+Category.TREE_PATH_SEPARATOR+"%'))";
|
||||
}
|
||||
if(tagId!=null){
|
||||
filterSql+= " and tagIdValue like '%,"+tagId+",%'";
|
||||
}
|
||||
if(StringUtils.isNotBlank(condition)){
|
||||
filterSql+=" and "+condition;
|
||||
}
|
||||
if(StringUtils.isNotBlank(keyword)){
|
||||
filterSql+= " and title like '%"+keyword+"%'";
|
||||
}
|
||||
String orderBySql = "";
|
||||
if(StringUtils.isBlank(orderBy)){
|
||||
orderBySql = DbUtils.getOrderBySql("sort desc,createDate desc");
|
||||
}else{
|
||||
orderBySql = DbUtils.getOrderBySql(orderBy+",sort desc");
|
||||
}
|
||||
return paginate(pageNumber, pageSize, "select *", "from cms_content where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找内容
|
||||
*
|
||||
* @param categoryId
|
||||
* 栏目ID
|
||||
* @param orderBy
|
||||
* 排序
|
||||
* @param start
|
||||
* 起始位置
|
||||
* @param count
|
||||
* 数量
|
||||
* @return 内容
|
||||
*/
|
||||
public List<Content> findList(Integer categoryId, String condition, Date startDate, Date endDate, String orderBy, Integer start, Integer count, Integer siteId){
|
||||
String filterSql = " and siteId="+siteId+" and status="+Status.NORMAL.ordinal();
|
||||
if(categoryId!=null){
|
||||
filterSql+=" and (categoryId="+categoryId+" or categoryId in ( select id from cms_category where treePath like '%"+Category.TREE_PATH_SEPARATOR+categoryId+Category.TREE_PATH_SEPARATOR+"%'))";
|
||||
}
|
||||
if(StringUtils.isNotBlank(condition)){
|
||||
filterSql+=" and "+condition;
|
||||
}
|
||||
if(startDate!=null){
|
||||
filterSql=" and createDate>='"+ DateFormatUtils.format(startDate, "yyyy-MM-dd HH:mm:ss")+"'";
|
||||
}
|
||||
if(endDate!=null){
|
||||
filterSql=" and createDate<='"+DateFormatUtils.format(endDate, "yyyy-MM-dd HH:mm:ss")+"'";
|
||||
}
|
||||
String orderBySql = "";
|
||||
if(StringUtils.isBlank(orderBy)){
|
||||
orderBySql = DbUtils.getOrderBySql("sort desc,createDate desc");
|
||||
}else{
|
||||
orderBySql = DbUtils.getOrderBySql(orderBy+",sort desc");
|
||||
}
|
||||
String countSql=DbUtils.getCountSql(start, count);
|
||||
return find("select * from cms_content where 1=1 "+filterSql+orderBySql+countSql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类
|
||||
* @return 分类
|
||||
*/
|
||||
public Category getCategory(){
|
||||
if(category == null){
|
||||
category = new Category().dao().findById(getCategoryId());
|
||||
}
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文本内容
|
||||
*
|
||||
* @return 文本内容
|
||||
*/
|
||||
public String getText() {
|
||||
if (StringUtils.isEmpty(getIntroduction())) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return Jsoup.parse(getIntroduction()).text();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取第一张图片
|
||||
*
|
||||
* @return 第一张图片
|
||||
*/
|
||||
public String getFirstImage(){
|
||||
Elements elements = Jsoup.parse(getIntroduction()).getElementsByTag("img");
|
||||
if(elements!=null && elements.size()>0){
|
||||
Element element = elements.get(0);
|
||||
return element.attr("src");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取上一篇内容
|
||||
*
|
||||
* @return 上一篇内容
|
||||
*/
|
||||
public Content getLastContent(){
|
||||
if(lastContent == null){
|
||||
lastContent = findFirst("select * from cms_content where id < ? and categoryId=? and status=? order by id desc limit 1",getId(),getCategoryId(),Status.NORMAL.ordinal());
|
||||
}
|
||||
return lastContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一篇内容
|
||||
*
|
||||
* @return 下一篇内容
|
||||
*/
|
||||
public Content getNextContent(){
|
||||
if(nextContent == null){
|
||||
nextContent = findFirst("select * from cms_content where id > ? and categoryId=? and status=? order by id asc limit 1",getId(),getCategoryId(),Status.NORMAL.ordinal());
|
||||
}
|
||||
return nextContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取属性
|
||||
*
|
||||
@param name
|
||||
* 名称
|
||||
* @return 属性
|
||||
*/
|
||||
public String getAttribute(String name){
|
||||
JSONObject jsonObject = JSONObject.parseObject(getModelFieldValue());
|
||||
return jsonObject.getString(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取属性
|
||||
*
|
||||
@param name
|
||||
* 名称
|
||||
* @return 属性
|
||||
*/
|
||||
public List<String> getAttributes(String name){
|
||||
JSONObject jsonObject = JSONObject.parseObject(getModelFieldValue());
|
||||
JSONArray jsonArray = jsonObject.getJSONArray(name);
|
||||
if(jsonArray == null){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return JSONArray.parseArray(jsonArray.toJSONString(),String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取块数据
|
||||
*
|
||||
* @return 块数据
|
||||
*/
|
||||
public List<String> getChunkValues(){
|
||||
if(StringUtils.isNotBlank(getChunkValue())){
|
||||
return JSONArray.parseArray(getChunkValue(), String.class);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取轮播多图
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<String> getPics(){
|
||||
if(StringUtils.isNotBlank(getPicValue())){
|
||||
return JSONArray.parseArray(getPicValue(), String.class);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标签
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Tag> getTags(){
|
||||
String tagIdValue = getTagIdValue();
|
||||
if(StringUtils.isNotBlank(tagIdValue)){
|
||||
if(tags == null){
|
||||
String tagIdsSql = StringUtils.substring(tagIdValue,1,tagIdValue.length()-1);
|
||||
return new Tag().dao().find("select * from cms_tag where id in ("+tagIdsSql+") order by field(id,"+tagIdsSql+")");
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路径
|
||||
*
|
||||
* @return 路径
|
||||
*/
|
||||
public String getPath() {
|
||||
if(StringUtils.isNotBlank(getOutlink())){
|
||||
return getOutlink();
|
||||
}
|
||||
Config config = SystemUtils.getConfig();
|
||||
if(config.getSiteModel()==Config.SiteModel.DYNAMIC.ordinal()){
|
||||
return getDynamicPath();
|
||||
}
|
||||
return getHtmlPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取动态路径
|
||||
*
|
||||
* @return 动态路径
|
||||
*/
|
||||
public String getDynamicPath(){
|
||||
Site site = new Site().dao().findById(getSiteId());
|
||||
String siteUrl = site.getUrl();
|
||||
String categoryCat = getCategory().getCat();
|
||||
return siteUrl+"/"+categoryCat+"/"+getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取静态路径
|
||||
*
|
||||
* @return 静态路径
|
||||
*/
|
||||
public String getHtmlPath() {
|
||||
Site site = new Site().dao().findById(getSiteId());
|
||||
String siteUrl = site.getUrl();
|
||||
String categoryCat = getCategory().getCat();
|
||||
return siteUrl+"/"+categoryCat+"/"+getId()+".html";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取pc模板路径
|
||||
*
|
||||
* @return 模板路径
|
||||
*/
|
||||
public String getPcTemplatePath() {
|
||||
Site site = new Site().dao().findById(getSiteId());
|
||||
if(StringUtils.isBlank(site.getPcTemplate()) || StringUtils.isBlank(getCategory().getDetailTemplate())){
|
||||
return null;
|
||||
}
|
||||
return "templates/"+site.getPcTemplate()+"/"+getCategory().getDetailTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取mobile模板路径
|
||||
*
|
||||
* @return 模板路径
|
||||
*/
|
||||
public String getMobileTemplatePath() {
|
||||
Site site = new Site().dao().findById(getSiteId());
|
||||
if(StringUtils.isBlank(site.getMobileTemplate()) || StringUtils.isBlank(getCategory().getDetailTemplate())){
|
||||
return null;
|
||||
}
|
||||
return "templates/"+site.getMobileTemplate()+"/"+getCategory().getDetailTemplate();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseDiv;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entity - 自定义表
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Div extends BaseDiv<Div> {
|
||||
|
||||
/**
|
||||
* 查找所有自定义表
|
||||
*
|
||||
*/
|
||||
public List<Div> findAll(){
|
||||
return find("select * from cms_div");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找自定义表分页
|
||||
*
|
||||
* @param pageNumber
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 每页记录数
|
||||
* @return 表单分页
|
||||
*/
|
||||
public Page<Div> findPage(Integer pageNumber, Integer pageSize){
|
||||
String filterSql = "";
|
||||
String orderBySql = DbUtils.getOrderBySql("createDate desc");
|
||||
return paginate(pageNumber, pageSize, "select *", "from cms_div where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseDivField;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entity - 自定义表字段
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class DivField extends BaseDivField<DivField> {
|
||||
|
||||
/**
|
||||
* 自定义表
|
||||
*/
|
||||
private Div div;
|
||||
|
||||
|
||||
/**
|
||||
* 获取自定义表
|
||||
*
|
||||
* @return 自定义表
|
||||
*/
|
||||
public Div getDiv(){
|
||||
if(div == null){
|
||||
div = new Div().dao().findById(getDivId());
|
||||
}
|
||||
return div;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断名称是否存在
|
||||
*
|
||||
* @param name
|
||||
* 名称
|
||||
* @return 名称是否存在
|
||||
*/
|
||||
public boolean nameExists(Integer formId,String name) {
|
||||
if (StrKit.isBlank(name)) {
|
||||
return false;
|
||||
}
|
||||
Integer count = Db.queryInt("select count(1) from cms_div_field where divId = ? and name = ?",formId,name);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找自定义表字段
|
||||
*
|
||||
* @param divId
|
||||
* 自定义表ID
|
||||
* @return 自定义表字段
|
||||
*/
|
||||
public List<DivField> findList(Integer divId){
|
||||
String filterSql = "";
|
||||
if(divId != null){
|
||||
filterSql+= " and divId = "+divId;
|
||||
}
|
||||
String orderBySql = DbUtils.getOrderBySql("sort desc,createDate desc");
|
||||
return find("select * from cms_div_field where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据自定义表ID删除自定义表字段
|
||||
*
|
||||
* @param divId
|
||||
*/
|
||||
public void deleteByFormId(Integer divId){
|
||||
Db.update("delete from cms_div_field where divId = ?",divId);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseFriendLink;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entity - 友情链接
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class FriendLink extends BaseFriendLink<FriendLink> {
|
||||
|
||||
|
||||
/**
|
||||
* 查找友情链接分页
|
||||
*
|
||||
* @param pageNumber
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 每页记录数
|
||||
* @param siteId
|
||||
* 站点ID
|
||||
* @return 友情链接分页
|
||||
*/
|
||||
public Page<FriendLink> findPage(Integer pageNumber,Integer pageSize,Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
String orderBySql = DbUtils.getOrderBySql("sort desc,createDate desc");
|
||||
return paginate(pageNumber, pageSize, "select *", "from cms_friend_link where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找分组ID列表
|
||||
*
|
||||
* @param siteId
|
||||
* 站点ID
|
||||
* @return 分组ID列表
|
||||
*/
|
||||
public List<String> findGids(Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
return Db.query("select gid from cms_friend_link where 1=1 "+filterSql+" group by gid order by gid asc");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找最大的分组ID
|
||||
*
|
||||
* @param siteId
|
||||
* 站点ID
|
||||
* @return
|
||||
*/
|
||||
public Integer findMaxGid(Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
return Db.queryInt("select max(gid) from cms_friend_link where 1=1 "+filterSql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找友情链接
|
||||
*
|
||||
* @param orderBy
|
||||
* 排序
|
||||
* @param start
|
||||
* 起始位置
|
||||
* @param count
|
||||
* 数量
|
||||
* @param siteId
|
||||
* 站点ID
|
||||
* @return 友情链接
|
||||
*/
|
||||
public List<FriendLink> findList(Integer gid,String orderBy,Integer start,Integer count,Integer siteId) {
|
||||
String filterSql = " and siteId="+siteId;
|
||||
if(gid != null){
|
||||
filterSql += " and gid="+gid;
|
||||
}
|
||||
String orderBySql = "";
|
||||
if(StringUtils.isBlank(orderBy)){
|
||||
orderBySql = DbUtils.getOrderBySql("sort desc,createDate desc");
|
||||
}else{
|
||||
orderBySql = DbUtils.getOrderBySql(orderBy+",sort desc");
|
||||
}
|
||||
String countSql=DbUtils.getCountSql(start, count);
|
||||
return find("select * from cms_friend_link where 1=1 "+filterSql+orderBySql+countSql);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseGuestbook;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
|
||||
/**
|
||||
* Entity - 留言
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Guestbook extends BaseGuestbook<Guestbook> {
|
||||
|
||||
/**
|
||||
* 查找留言分页
|
||||
*
|
||||
* @param pageNumber
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 每页记录数
|
||||
* @param siteId
|
||||
* 站点ID
|
||||
* @return 留言分页
|
||||
*/
|
||||
public Page<Guestbook> findPage(Integer pageNumber,Integer pageSize,Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
String orderBySql = DbUtils.getOrderBySql("createDate desc");
|
||||
return paginate(pageNumber, pageSize, "select *", "from cms_guestbook where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,224 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.builder.CompareToBuilder;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseMenu;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Entity - 菜单
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Menu extends BaseMenu<Menu> {
|
||||
/** 树路径分隔符 */
|
||||
public static final String TREE_PATH_SEPARATOR = ",";
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
public enum Type{
|
||||
MENU("菜单"),
|
||||
PAGE("页面");
|
||||
public String text;
|
||||
Type(String text){
|
||||
this.text = text;
|
||||
}
|
||||
public String getText(){
|
||||
return this.text;
|
||||
}
|
||||
public static Map<Integer, Type> typeValueMap = new HashMap<>();
|
||||
static {
|
||||
Type[] values = Type.values();
|
||||
for (Type type : values) {
|
||||
typeValueMap.put(type.ordinal(), type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getTypeName(){
|
||||
return Type.typeValueMap.get(getType()).getText();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下级菜单
|
||||
*/
|
||||
@JSONField(serialize=false)
|
||||
private List<Menu> children;
|
||||
|
||||
/**
|
||||
* 上级菜单
|
||||
*/
|
||||
@JSONField(serialize=false)
|
||||
private Menu parent;
|
||||
|
||||
/**
|
||||
* 获取下级菜单地址
|
||||
*
|
||||
* @return 下级菜单地址
|
||||
*/
|
||||
public List<String> getChildrenUrls(){
|
||||
List<String> urls = new ArrayList<>();
|
||||
if(CollectionUtils.isNotEmpty(getChildren())){
|
||||
for(Menu menu : getChildren()){
|
||||
urls.add(menu.getUrl());
|
||||
}
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下级菜单
|
||||
*
|
||||
* @return 下级菜单
|
||||
*/
|
||||
public List<Menu> getChildren() {
|
||||
if(children == null){
|
||||
children = find("select * from cms_menu where parentId=? order by sort desc",getId());
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上级菜单
|
||||
* @return 上级菜单
|
||||
*/
|
||||
public Menu getParent(){
|
||||
if(parent == null){
|
||||
parent = findById(getParentId());
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找顶级菜单
|
||||
*
|
||||
* @return 顶级菜单
|
||||
*/
|
||||
public List<Menu> findRoots(){
|
||||
String orderBySql = DbUtils.getOrderBySql("sort desc");
|
||||
return find("select * from cms_menu where parentId is null and isShow=1 "+orderBySql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找下级菜单
|
||||
*
|
||||
* @param menuId
|
||||
* 菜单Id
|
||||
* @param isShow
|
||||
* 是否显示
|
||||
* @param recursive
|
||||
* 是否递归
|
||||
*
|
||||
* @return 下级菜单
|
||||
*/
|
||||
public List<Menu> findChildren(Integer menuId,Boolean isShow,Boolean recursive){
|
||||
String filterSql = "";
|
||||
if(isShow!=null){
|
||||
filterSql+= " and isShow="+BooleanUtils.toInteger(isShow);
|
||||
}
|
||||
if(recursive){
|
||||
String orderBySql = DbUtils.getOrderBySql("grade asc,sort desc");
|
||||
List<Menu> menus;
|
||||
if(menuId!=null){
|
||||
menus = find("select * from cms_menu where 1=1 and treePath like ? "+filterSql+orderBySql,"%,"+menuId+",%");
|
||||
}else{
|
||||
menus = find("select * from cms_menu where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
sort(menus);
|
||||
return menus;
|
||||
}else{
|
||||
String orderBySql = DbUtils.getOrderBySql("sort desc");
|
||||
return find("select * from cms_menu where parentId = ? "+filterSql+orderBySql,menuId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找菜单树
|
||||
*
|
||||
* @return 菜单树
|
||||
*/
|
||||
public List<Menu> findTree(){
|
||||
return findChildren(null,null,true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有上级分类ID
|
||||
*
|
||||
* @return 所有上级分类ID
|
||||
*/
|
||||
public Integer[] getParentIds() {
|
||||
String[] treePaths = StringUtils.split(getTreePath(), TREE_PATH_SEPARATOR);
|
||||
Integer[] result = new Integer[treePaths.length];
|
||||
for (int i = 0; i < treePaths.length; i++) {
|
||||
result[i] = Integer.valueOf(treePaths[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序菜单
|
||||
*
|
||||
* @param menus
|
||||
* 菜单
|
||||
*/
|
||||
private void sort(List<Menu> menus) {
|
||||
if(menus == null || menus.size()==0) {
|
||||
return;
|
||||
}
|
||||
final Map<Integer, Integer> sortMap = new HashMap<Integer, Integer>();
|
||||
for (Menu menu : menus) {
|
||||
sortMap.put(menu.getId(), menu.getSort());
|
||||
}
|
||||
Collections.sort(menus, new Comparator<Menu>() {
|
||||
@Override
|
||||
public int compare(Menu menu1, Menu menu2) {
|
||||
Integer[] ids1 = (Integer[]) ArrayUtils.add(menu1.getParentIds(), menu1.getId());
|
||||
Integer[] ids2 = (Integer[]) ArrayUtils.add(menu2.getParentIds(), menu2.getId());
|
||||
Iterator<Integer> iterator1 = Arrays.asList(ids1).iterator();
|
||||
Iterator<Integer> iterator2 = Arrays.asList(ids2).iterator();
|
||||
CompareToBuilder compareToBuilder = new CompareToBuilder();
|
||||
while (iterator1.hasNext() && iterator2.hasNext()) {
|
||||
Integer id1 = iterator1.next();
|
||||
Integer id2 = iterator2.next();
|
||||
Integer sort1 = sortMap.get(id1);
|
||||
Integer sort2 = sortMap.get(id2);
|
||||
compareToBuilder.append(sort2,sort1).append(id1, id2);
|
||||
if (!iterator1.hasNext() || !iterator2.hasNext()) {
|
||||
compareToBuilder.append(menu1.getGrade(), menu2.getGrade());
|
||||
}
|
||||
}
|
||||
return compareToBuilder.toComparison();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置值
|
||||
*
|
||||
*/
|
||||
public void setValue() {
|
||||
if (getParentId() != null) {
|
||||
setTreePath(getParent().getTreePath() + getParent().getId() + Category.TREE_PATH_SEPARATOR);
|
||||
} else {
|
||||
setTreePath(Category.TREE_PATH_SEPARATOR);
|
||||
}
|
||||
setGrade(getParentIds().length);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseModel;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Entity - 模型
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Model extends BaseModel<Model> {
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
public enum Status{
|
||||
DISABLE("禁用"),
|
||||
NORMAL("启用");
|
||||
public String text;
|
||||
Status(String text){
|
||||
this.text = text;
|
||||
}
|
||||
public String getText(){
|
||||
return this.text;
|
||||
}
|
||||
public static Map<Integer, Status> statusValueMap = new HashMap<>();
|
||||
static {
|
||||
Status[] values = Status.values();
|
||||
for (Status status : values) {
|
||||
statusValueMap.put(status.ordinal(), status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
public enum Type{
|
||||
PAGE("单页"),
|
||||
LIST("列表");
|
||||
public String text;
|
||||
Type(String text){
|
||||
this.text = text;
|
||||
}
|
||||
public String getText(){
|
||||
return this.text;
|
||||
}
|
||||
public static Map<Integer, Type> typeValueMap = new HashMap<>();
|
||||
static {
|
||||
Type[] values = Type.values();
|
||||
for (Type type : values) {
|
||||
typeValueMap.put(type.ordinal(), type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getTypeName(){
|
||||
return Type.typeValueMap.get(getType()).getText();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找模型分页
|
||||
*
|
||||
* @param pageNumber
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 每页记录数
|
||||
* @return 模型分页
|
||||
*/
|
||||
public Page<Model> findPage(Integer pageNumber,Integer pageSize){
|
||||
String filterSql = "";
|
||||
String orderBySql = DbUtils.getOrderBySql("createDate desc");
|
||||
return paginate(pageNumber, pageSize, "select *", "from cms_model where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找启用模型列表
|
||||
*
|
||||
* @return 启用模型列表
|
||||
*/
|
||||
public List<Model> findNormalList(){
|
||||
String filterSql = " and status="+Status.NORMAL.ordinal();
|
||||
String orderBySql = DbUtils.getOrderBySql("createDate desc");
|
||||
return find("select * from cms_model where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseModelField;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entity - 模型字段
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ModelField extends BaseModelField<ModelField> {
|
||||
|
||||
/**
|
||||
* 模型
|
||||
*/
|
||||
private Model model;
|
||||
|
||||
|
||||
/**
|
||||
* 获取模型
|
||||
*
|
||||
* @return 模型
|
||||
*/
|
||||
public Model getModel(){
|
||||
if(model == null){
|
||||
model = new Model().dao().findById(getModelId());
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断名称是否存在
|
||||
*
|
||||
* @param name
|
||||
* 名称
|
||||
* @return 名称是否存在
|
||||
*/
|
||||
public boolean nameExists(Integer modelId,String name) {
|
||||
if (StrKit.isBlank(name)) {
|
||||
return false;
|
||||
}
|
||||
Integer count = Db.queryInt("select count(1) from cms_model_field where modelId = ? and name = ?",modelId,name);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找模型字段
|
||||
*
|
||||
* @param modelId
|
||||
* 模型ID
|
||||
* @return 模型字段
|
||||
*/
|
||||
public List<ModelField> findList(Integer modelId){
|
||||
String filterSql = "";
|
||||
if(modelId != null){
|
||||
filterSql+= " and modelId = "+modelId;
|
||||
}
|
||||
String orderBySql = DbUtils.getOrderBySql("sort desc,createDate desc");
|
||||
return find("select * from cms_model_field where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据模型ID删除模型属性
|
||||
*
|
||||
* @param modelId
|
||||
*/
|
||||
public void deleteByModelId(Integer modelId){
|
||||
Db.update("delete from cms_model_field where modelId = ?",modelId);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,214 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.builder.CompareToBuilder;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseNav;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Entity - 导航
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Nav extends BaseNav<Nav> {
|
||||
|
||||
/** 树路径分隔符 */
|
||||
public static final String TREE_PATH_SEPARATOR = ",";
|
||||
|
||||
/**
|
||||
* 下级导航
|
||||
*/
|
||||
@JSONField(serialize=false)
|
||||
private List<Nav> children;
|
||||
|
||||
/**
|
||||
* 上级导航
|
||||
*/
|
||||
@JSONField(serialize=false)
|
||||
private Nav parent;
|
||||
|
||||
|
||||
/**
|
||||
* 获取下级导航
|
||||
*
|
||||
* @return 下级导航
|
||||
*/
|
||||
public List<Nav> getChildren() {
|
||||
if(children == null){
|
||||
children = find("select * from cms_nav where parentId=? order by sort desc",getId());
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上级导航
|
||||
* @return 上级导航
|
||||
*/
|
||||
public Nav getParent(){
|
||||
if(parent == null){
|
||||
parent = findById(getParentId());
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查找顶级导航
|
||||
*
|
||||
* @param start
|
||||
* 起始位置
|
||||
* @param count
|
||||
* 数量
|
||||
* @return 顶级导航
|
||||
*/
|
||||
public List<Nav> findRoots(Integer start, Integer count,Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
String countSql= DbUtils.getCountSql(start, count);
|
||||
String orderBySql = DbUtils.getOrderBySql("sort desc");
|
||||
return find("select * from cms_nav where parentId is null"+filterSql+orderBySql+countSql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找上级导航
|
||||
*
|
||||
* @param navId
|
||||
* 导航Id
|
||||
* @param recursive
|
||||
* 是否递归
|
||||
* @param start
|
||||
* 起始位置
|
||||
* @param count
|
||||
* 数量
|
||||
* @return 上级导航
|
||||
*/
|
||||
public List<Nav> findParents(Integer navId,Boolean recursive,Integer start, Integer count,Integer siteId){
|
||||
Nav nav = findById(navId);
|
||||
if(navId == null || nav.getParentId() == null){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String filterSql = " and siteId="+siteId;
|
||||
if(recursive){
|
||||
String countSql=DbUtils.getCountSql(start, count);
|
||||
String orderBySql = DbUtils.getOrderBySql("grade asc");
|
||||
return find("select * from cms_nav where id in ("+ StringUtils.join(nav.getParentIds(), ",")+") "+filterSql+orderBySql+countSql);
|
||||
}else{
|
||||
return find("select * from cms_nav where id = ? "+filterSql,findById(navId).getParentId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找下级导航
|
||||
*
|
||||
* @param navId
|
||||
* 导航Id
|
||||
* @param recursive
|
||||
* 是否递归
|
||||
* @param start
|
||||
* 起始位置
|
||||
* @param count
|
||||
* 数量
|
||||
* @return 下级导航
|
||||
*/
|
||||
public List<Nav> findChildren(Integer navId,Boolean recursive,Integer start,Integer count,Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
if(recursive){
|
||||
String countSql=DbUtils.getCountSql(start, count);
|
||||
String orderBySql = DbUtils.getOrderBySql("grade asc,sort desc");
|
||||
List<Nav> navs;
|
||||
if(navId!=null){
|
||||
navs = find("select * from cms_nav where 1=1 and treePath like ? "+filterSql+orderBySql+countSql,"%,"+navId+",%");
|
||||
}else{
|
||||
navs = find("select * from cms_nav where 1=1 "+filterSql+orderBySql+countSql);
|
||||
}
|
||||
sort(navs);
|
||||
return navs;
|
||||
}else{
|
||||
String orderBySql = DbUtils.getOrderBySql("sort desc");
|
||||
return find("select * from cms_nav where parentId = ? "+filterSql+orderBySql,navId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找导航树
|
||||
*
|
||||
* @return 导航树
|
||||
*/
|
||||
public List<Nav> findTree(Integer siteId){
|
||||
return findChildren(null,true,null,null,siteId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有上级导航ID
|
||||
*
|
||||
* @return 所有上级导航ID
|
||||
*/
|
||||
public Integer[] getParentIds() {
|
||||
String[] treePaths = StringUtils.split(getTreePath(), TREE_PATH_SEPARATOR);
|
||||
Integer[] result = new Integer[treePaths.length];
|
||||
for (int i = 0; i < treePaths.length; i++) {
|
||||
result[i] = Integer.valueOf(treePaths[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序导航
|
||||
*
|
||||
* @param navs
|
||||
* 分类
|
||||
*/
|
||||
private void sort(List<Nav> navs) {
|
||||
if(navs == null || navs.size()==0) {
|
||||
return;
|
||||
}
|
||||
final Map<Integer, Integer> sortMap = new HashMap<Integer, Integer>();
|
||||
for (Nav nav : navs) {
|
||||
sortMap.put(nav.getId(), nav.getSort());
|
||||
}
|
||||
Collections.sort(navs, new Comparator<Nav>() {
|
||||
@Override
|
||||
public int compare(Nav nav1, Nav nav2) {
|
||||
Integer[] ids1 = (Integer[]) ArrayUtils.add(nav1.getParentIds(), nav1.getId());
|
||||
Integer[] ids2 = (Integer[]) ArrayUtils.add(nav2.getParentIds(), nav2.getId());
|
||||
Iterator<Integer> iterator1 = Arrays.asList(ids1).iterator();
|
||||
Iterator<Integer> iterator2 = Arrays.asList(ids2).iterator();
|
||||
CompareToBuilder compareToBuilder = new CompareToBuilder();
|
||||
while (iterator1.hasNext() && iterator2.hasNext()) {
|
||||
Integer id1 = iterator1.next();
|
||||
Integer id2 = iterator2.next();
|
||||
Integer sort1 = sortMap.get(id1);
|
||||
Integer sort2 = sortMap.get(id2);
|
||||
compareToBuilder.append(sort2,sort1).append(id1, id2);
|
||||
if (!iterator1.hasNext() || !iterator2.hasNext()) {
|
||||
compareToBuilder.append(nav1.getGrade(), nav2.getGrade());
|
||||
}
|
||||
}
|
||||
return compareToBuilder.toComparison();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置值
|
||||
*
|
||||
*/
|
||||
public void setValue() {
|
||||
if (getParentId() != null) {
|
||||
setTreePath(getParent().getTreePath() + getParent().getId() + TREE_PATH_SEPARATOR);
|
||||
} else {
|
||||
setTreePath(TREE_PATH_SEPARATOR);
|
||||
}
|
||||
setGrade(getParentIds().length);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseRole;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entity - 角色
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Role extends BaseRole<Role> {
|
||||
|
||||
|
||||
/**
|
||||
* 获取权限
|
||||
*
|
||||
* @return 权限
|
||||
*/
|
||||
public List<String> getPermissions() {
|
||||
return JSONArray.parseArray(getPermission(), String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取站点ID
|
||||
* @return
|
||||
*/
|
||||
public List<Integer> getSiteIds(){
|
||||
String orderBySql = DbUtils.getOrderBySql("id desc");
|
||||
List<Integer> siteIds = Db.query("select siteId from cms_role_site where roleId=?"+orderBySql,getId());
|
||||
return siteIds;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查找角色分页
|
||||
*
|
||||
* @param pageNumber
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 每页记录数
|
||||
* @return 角色分页
|
||||
*/
|
||||
public Page<Role> findPage(Integer pageNumber,Integer pageSize){
|
||||
String filterSql = "";
|
||||
String orderBySql = DbUtils.getOrderBySql("createDate desc");
|
||||
return paginate(pageNumber, pageSize, "select *", "from cms_role where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseRoleSite;
|
||||
|
||||
/**
|
||||
* Entity - 角色站点
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class RoleSite extends BaseRoleSite<RoleSite> {
|
||||
|
||||
/**
|
||||
* 根据角色ID删除角色站点
|
||||
*
|
||||
* @param roleId
|
||||
*/
|
||||
public void deleteByRoleId(Integer roleId){
|
||||
Db.update("delete from cms_role_site where roleId=?",roleId);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseSetup;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Entity - 配置
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Setup extends BaseSetup<Setup> {
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
*/
|
||||
public Map<String,String> getSetupMap(){
|
||||
List<Setup> setups = findAll();
|
||||
Map<String,String> setupMap = new HashMap<String, String>();
|
||||
for(Setup setup : setups){
|
||||
setupMap.put(setup.getName(), setup.getValue());
|
||||
}
|
||||
return setupMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找全部配置
|
||||
*/
|
||||
public List<Setup> findAll(){
|
||||
return new Setup().dao().find("select * from cms_setup order by sort desc");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据名称查找配置
|
||||
*
|
||||
* @return 配置
|
||||
*/
|
||||
public Setup findByName(String name){
|
||||
return new Setup().dao().findFirst("select * from cms_setup where name = ?",name);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseSite;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
import vip.fuck.sm.plugins.cms.util.JFinal;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Entity -站点
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Site extends BaseSite<Site> {
|
||||
|
||||
/** 前台站点 */
|
||||
public static final String CURRENT_SITE="currentSite";
|
||||
|
||||
/** 后台站点 */
|
||||
public static final String ADMIN_SESSION_SITE="admin_session_site";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
public enum Type{
|
||||
CAT("目录"),
|
||||
DOMAIN("域名");
|
||||
public String text;
|
||||
Type(String text){
|
||||
this.text = text;
|
||||
}
|
||||
public String getText(){
|
||||
return this.text;
|
||||
}
|
||||
public static Map<Integer, Type> typeValueMap = new HashMap<>();
|
||||
static {
|
||||
Type[] values = Type.values();
|
||||
for (Type type : values) {
|
||||
typeValueMap.put(type.ordinal(), type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找站点分页
|
||||
*
|
||||
* @param pageNumber
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 每页记录数
|
||||
* @return 站点分页
|
||||
*/
|
||||
public Page<Site> findPage(Integer pageNumber,Integer pageSize){
|
||||
String filterSql = "";
|
||||
String orderBySql = DbUtils.getOrderBySql("createDate desc");
|
||||
return paginate(pageNumber, pageSize, "select *", "from cms_site where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找默认站点
|
||||
*
|
||||
*/
|
||||
public Site findDefault(){
|
||||
return findFirst("select * from cms_site where isDefault=? ", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找所有站点
|
||||
*
|
||||
*/
|
||||
public List<Site> findAll(){
|
||||
String orderBySql = DbUtils.getOrderBySql("createDate desc");
|
||||
return find("select * from cms_site"+orderBySql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取地址
|
||||
*/
|
||||
public String getUrl(){
|
||||
String contextPath = JFinal.me().getContextPath();
|
||||
if(Type.CAT.ordinal()==getType()){
|
||||
String cat = getCat(); //目录
|
||||
if(StringUtils.isBlank(cat)){
|
||||
return contextPath;
|
||||
}
|
||||
return contextPath+"/"+cat;
|
||||
}else if(Type.DOMAIN.ordinal()==getType()){
|
||||
String protocol = getProtocol(); //协议
|
||||
if(StringUtils.isBlank(protocol)){
|
||||
protocol = "";
|
||||
}
|
||||
String domain = getDomain(); //域名
|
||||
if(StringUtils.isBlank(domain)){
|
||||
domain = "";
|
||||
}
|
||||
return protocol+domain+contextPath;
|
||||
}
|
||||
return contextPath;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseSlide;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entity - 幻灯片
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Slide extends BaseSlide<Slide> {
|
||||
|
||||
/**
|
||||
* 查找幻灯片分页
|
||||
*
|
||||
* @param pageNumber
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 每页记录数
|
||||
* @param siteId
|
||||
* 站点ID
|
||||
* @return 幻灯片分页
|
||||
*/
|
||||
public Page<Slide> findPage(Integer pageNumber,Integer pageSize,Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
String orderBySql = DbUtils.getOrderBySql("sort desc,createDate desc");
|
||||
return paginate(pageNumber, pageSize, "select *", "from cms_slide where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找分组ID列表
|
||||
*
|
||||
* @param siteId
|
||||
* 站点ID
|
||||
* @return 分组ID列表
|
||||
*/
|
||||
public List<String> findGids(Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
return Db.query("select gid from cms_slide where 1=1 "+filterSql+" group by gid order by gid asc");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找最大的分组ID
|
||||
*
|
||||
* @param siteId
|
||||
* 站点ID
|
||||
* @return
|
||||
*/
|
||||
public Integer findMaxGid(Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
return Db.queryInt("select max(gid) from cms_slide where 1=1 "+filterSql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找幻灯片
|
||||
*
|
||||
* @param orderBy
|
||||
* 排序
|
||||
* @param start
|
||||
* 起始位置
|
||||
* @param count
|
||||
* 数量
|
||||
* @param siteId
|
||||
* 站点ID
|
||||
* @return 幻灯片
|
||||
*/
|
||||
public List<Slide> findList(Integer gid,String orderBy,Integer start,Integer count,Integer siteId) {
|
||||
String filterSql = " and siteId="+siteId;
|
||||
if(gid != null){
|
||||
filterSql += " and gid="+gid;
|
||||
}
|
||||
String orderBySql = "";
|
||||
if(StringUtils.isBlank(orderBy)){
|
||||
orderBySql = DbUtils.getOrderBySql("sort desc,createDate desc");
|
||||
}else{
|
||||
orderBySql = DbUtils.getOrderBySql(orderBy+",sort desc");
|
||||
}
|
||||
String countSql=DbUtils.getCountSql(start, count);
|
||||
return find("select * from cms_slide where 1=1 "+filterSql+orderBySql+countSql);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseTag;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
import vip.fuck.sm.plugins.cms.util.JFinal;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entity - 标签
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Tag extends BaseTag<Tag> {
|
||||
|
||||
/**
|
||||
* 根据URL目录查找标签
|
||||
*
|
||||
* @param cat
|
||||
* URL目录
|
||||
* @return 标签,若不存在则返回null
|
||||
*/
|
||||
public Tag findByCat(String cat) {
|
||||
if (StrKit.isBlank(cat)) {
|
||||
return null;
|
||||
}
|
||||
return findFirst("select * from cms_tag where cat = ?",cat);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据名称查找标签
|
||||
*
|
||||
* @param name
|
||||
* 标签名称
|
||||
* @return 标签,若不存在则返回null
|
||||
*/
|
||||
public Tag findByName(String name) {
|
||||
if (StrKit.isBlank(name)) {
|
||||
return null;
|
||||
}
|
||||
return findFirst("select * from cms_tag where name = ?",name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找标签分页
|
||||
*
|
||||
* @param pageNumber
|
||||
* 页码
|
||||
* @param pageSize
|
||||
* 每页记录数
|
||||
* @param siteId
|
||||
* 站点ID
|
||||
* @return 友情链接分页
|
||||
*/
|
||||
public Page<Tag> findPage(Integer pageNumber, Integer pageSize, Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
String orderBySql = DbUtils.getOrderBySql("createDate desc");
|
||||
return paginate(pageNumber, pageSize, "select *", "from cms_tag where 1=1 "+filterSql+orderBySql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找标签
|
||||
*
|
||||
* @param orderBy
|
||||
* 排序
|
||||
* @param start
|
||||
* 起始位置
|
||||
* @param count
|
||||
* 数量
|
||||
* @return 标签
|
||||
*/
|
||||
public List<Tag> findList(String condition, String orderBy, Integer start, Integer count,Integer siteId){
|
||||
String filterSql = " and siteId="+siteId;
|
||||
if(StringUtils.isNotBlank(condition)){
|
||||
filterSql+=" and "+condition;
|
||||
}
|
||||
String orderBySql = "";
|
||||
if(StringUtils.isNotBlank(orderBy)){
|
||||
orderBySql = DbUtils.getOrderBySql(orderBy);
|
||||
}else{
|
||||
orderBySql = DbUtils.getOrderBySql("createDate desc");
|
||||
}
|
||||
String countSql= DbUtils.getCountSql(start, count);
|
||||
return find("select * from cms_tag where 1=1 "+filterSql+orderBySql+countSql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路径
|
||||
*
|
||||
* @return 路径
|
||||
*/
|
||||
public String getPath() {
|
||||
String url = JFinal.me().getContextPath();
|
||||
String param = "";
|
||||
Site site = new Site().dao().findById(getSiteId());
|
||||
String siteCat = site.getCat();
|
||||
if(StringUtils.isNotBlank(siteCat)){
|
||||
url+="/"+siteCat;
|
||||
}
|
||||
String cat = getCat();
|
||||
if(StringUtils.isNotBlank(cat)){
|
||||
url+="/tag/"+cat;
|
||||
}else{
|
||||
url+="/tag";
|
||||
param+="&id="+getId();
|
||||
}
|
||||
if(StringUtils.isNotBlank(param)){
|
||||
param = "?" +param.substring(1);
|
||||
}
|
||||
return url+param;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseWeb;
|
||||
|
||||
/**
|
||||
* Entity - 网站信息
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Web extends BaseWeb<Web> {
|
||||
|
||||
/** 前台网站信息 */
|
||||
public static final String CURRENT_WEB="currentWeb";
|
||||
|
||||
/**
|
||||
* 根据站点ID查询网站信息
|
||||
*
|
||||
*/
|
||||
public Web findBySiteId(Integer siteId){
|
||||
return findFirst("select * from cms_web where siteId=?",siteId);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import vip.fuck.sm.plugins.cms.entity.base.BaseWechatMenu;
|
||||
import vip.fuck.sm.plugins.cms.util.DbUtils;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entity - 微信菜单
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class WechatMenu extends BaseWechatMenu<WechatMenu> {
|
||||
|
||||
/**
|
||||
* 下级微信菜单
|
||||
*/
|
||||
@JSONField(serialize=false)
|
||||
private List<WechatMenu> subMenus;
|
||||
|
||||
|
||||
/**
|
||||
* 获取下级微信菜单
|
||||
*
|
||||
* @return 下级微信菜单
|
||||
*/
|
||||
public List<WechatMenu> getSubMenus() {
|
||||
if(subMenus == null){
|
||||
subMenus = find("select * from cms_wechat_menu where parentId=? order by sort asc",getId());
|
||||
}
|
||||
return subMenus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找顶级微信菜单
|
||||
*
|
||||
* @return 顶级微信菜单
|
||||
*/
|
||||
public List<WechatMenu> findRoots(){
|
||||
String filterSql = "";
|
||||
String orderBySql = DbUtils.getOrderBySql("sort asc");
|
||||
return find("select * from cms_wechat_menu where parentId is null"+filterSql+orderBySql);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
//package vip.fuck.sm.plugins.cms.entity;
|
||||
//
|
||||
//import com.jfinal.kit.PropKit;
|
||||
//import com.jfinal.plugin.activerecord.generator.Generator;
|
||||
//import com.jfinal.plugin.druid.DruidPlugin;
|
||||
//
|
||||
//import javax.sql.DataSource;
|
||||
//
|
||||
///**
|
||||
// * 本 demo 仅表达最为粗浅的 jfinal 用法,更为有价值的实用的企业级用法
|
||||
// * 详见 JFinal 俱乐部: http://jfinal.com/club
|
||||
// *
|
||||
// * 在数据库表有任何变动时,运行一下 main 方法,极速响应变化进行代码重构
|
||||
// */
|
||||
//public class _JFinalDemoGenerator {
|
||||
//
|
||||
// public static DataSource getDataSource() {
|
||||
// PropKit.use("config.properties");
|
||||
// DruidPlugin druidPlugin = new DruidPlugin(PropKit.get("jdbc.url"), PropKit.get("jdbc.username"), PropKit.get("jdbc.password"),PropKit.get("jdbc.driver"));
|
||||
// druidPlugin.start();
|
||||
// return druidPlugin.getDataSource();
|
||||
// }
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
// // base model 所使用的包名
|
||||
// String baseModelPackageName = "com.cms.entity.base";
|
||||
// // base model 文件保存路径
|
||||
// String baseModelOutputDir = "c:/src/com/cms/entity/base";
|
||||
//
|
||||
// // model 所使用的包名 (MappingKit 默认使用的包名)
|
||||
// String modelPackageName = "com.cms.entity";
|
||||
// // model 文件保存路径 (MappingKit 与 DataDictionary 文件默认保存路径)
|
||||
// String modelOutputDir = baseModelOutputDir + "/..";
|
||||
//
|
||||
// // 创建生成器
|
||||
// Generator generator = new Generator(getDataSource(), baseModelPackageName, baseModelOutputDir, modelPackageName, modelOutputDir);
|
||||
// // 设置是否生成链式 setter 方法
|
||||
// generator.setGenerateChainSetter(false);
|
||||
// // 添加不需要生成的表名
|
||||
//// generator.addExcludedTable("adv");
|
||||
// // 设置是否在 Model 中生成 dao 对象
|
||||
// generator.setGenerateDaoInModel(true);
|
||||
// // 设置是否生成链式 setter 方法
|
||||
// generator.setGenerateChainSetter(true);
|
||||
// // 设置是否生成字典文件
|
||||
// generator.setGenerateDataDictionary(false);
|
||||
// // 设置需要被移除的表名前缀用于生成modelName。例如表名 "osc_user",移除前缀 "osc_"后生成的model名为 "User"而非 OscUser
|
||||
// generator.setRemovedTableNamePrefixes("cms_");
|
||||
// // 生成
|
||||
// generator.generate();
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
@ -0,0 +1,42 @@
|
||||
package vip.fuck.sm.plugins.cms.entity;
|
||||
|
||||
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
* <pre>
|
||||
* Example:
|
||||
* public void configPlugin(Plugins me) {
|
||||
* ActiveRecordPlugin arp = new ActiveRecordPlugin(...);
|
||||
* _MappingKit.mapping(arp);
|
||||
* me.add(arp);
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public class _MappingKit {
|
||||
|
||||
public static void mapping(ActiveRecordPlugin arp) {
|
||||
arp.addMapping("cms_admin", "id", Admin.class);
|
||||
arp.addMapping("cms_admin_role", "id", AdminRole.class);
|
||||
arp.addMapping("cms_category", "id", Category.class);
|
||||
arp.addMapping("cms_company", "id", Company.class);
|
||||
arp.addMapping("cms_content", "id", Content.class);
|
||||
arp.addMapping("cms_div", "id", Div.class);
|
||||
arp.addMapping("cms_div_field", "id", DivField.class);
|
||||
arp.addMapping("cms_friend_link", "id", FriendLink.class);
|
||||
arp.addMapping("cms_guestbook", "id", Guestbook.class);
|
||||
arp.addMapping("cms_menu", "id", Menu.class);
|
||||
arp.addMapping("cms_model", "id", Model.class);
|
||||
arp.addMapping("cms_model_field", "id", ModelField.class);
|
||||
arp.addMapping("cms_nav", "id", Nav.class);
|
||||
arp.addMapping("cms_role", "id", Role.class);
|
||||
arp.addMapping("cms_role_site", "id", RoleSite.class);
|
||||
arp.addMapping("cms_setup", "id", Setup.class);
|
||||
arp.addMapping("cms_site", "id", Site.class);
|
||||
arp.addMapping("cms_slide", "id", Slide.class);
|
||||
arp.addMapping("cms_tag", "id", Tag.class);
|
||||
arp.addMapping("cms_web", "id", Web.class);
|
||||
arp.addMapping("cms_wechat_menu", "id", WechatMenu.class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseAdmin<M extends BaseAdmin<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setName(String name) {
|
||||
set("name", name);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStr("name");
|
||||
}
|
||||
|
||||
public M setPassword(String password) {
|
||||
set("password", password);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return getStr("password");
|
||||
}
|
||||
|
||||
public M setUsername(String username) {
|
||||
set("username", username);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return getStr("username");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseAdminRole<M extends BaseAdminRole<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setAdminId(Integer adminId) {
|
||||
set("adminId", adminId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getAdminId() {
|
||||
return getInt("adminId");
|
||||
}
|
||||
|
||||
public M setRoleId(Integer roleId) {
|
||||
set("roleId", roleId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getRoleId() {
|
||||
return getInt("roleId");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,229 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseCategory<M extends BaseCategory<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setStatus(Integer status) {
|
||||
set("status", status);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return getInt("status");
|
||||
}
|
||||
|
||||
public M setSort(Integer sort) {
|
||||
set("sort", sort);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return getInt("sort");
|
||||
}
|
||||
|
||||
public M setGrade(Integer grade) {
|
||||
set("grade", grade);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getGrade() {
|
||||
return getInt("grade");
|
||||
}
|
||||
|
||||
public M setCat(String cat) {
|
||||
set("cat", cat);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getCat() {
|
||||
return getStr("cat");
|
||||
}
|
||||
|
||||
public M setName(String name) {
|
||||
set("name", name);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStr("name");
|
||||
}
|
||||
|
||||
public M setSubname(String subname) {
|
||||
set("subname", subname);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getSubname() {
|
||||
return getStr("subname");
|
||||
}
|
||||
|
||||
public M setIco(String ico) {
|
||||
set("ico", ico);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getIco() {
|
||||
return getStr("ico");
|
||||
}
|
||||
|
||||
public M setImage(String image) {
|
||||
set("image", image);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return getStr("image");
|
||||
}
|
||||
|
||||
public M setIntroduction(String introduction) {
|
||||
set("introduction", introduction);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getIntroduction() {
|
||||
return getStr("introduction");
|
||||
}
|
||||
|
||||
public M setDescription(String description) {
|
||||
set("description", description);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return getStr("description");
|
||||
}
|
||||
|
||||
public M setKeywords(String keywords) {
|
||||
set("keywords", keywords);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getKeywords() {
|
||||
return getStr("keywords");
|
||||
}
|
||||
|
||||
public M setTitle(String title) {
|
||||
set("title", title);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return getStr("title");
|
||||
}
|
||||
|
||||
public M setTreePath(String treePath) {
|
||||
set("treePath", treePath);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getTreePath() {
|
||||
return getStr("treePath");
|
||||
}
|
||||
|
||||
public M setParentId(Integer parentId) {
|
||||
set("parentId", parentId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getParentId() {
|
||||
return getInt("parentId");
|
||||
}
|
||||
|
||||
public M setModelId(Integer modelId) {
|
||||
set("modelId", modelId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getModelId() {
|
||||
return getInt("modelId");
|
||||
}
|
||||
|
||||
public M setListTemplate(String listTemplate) {
|
||||
set("listTemplate", listTemplate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getListTemplate() {
|
||||
return getStr("listTemplate");
|
||||
}
|
||||
|
||||
public M setDetailTemplate(String detailTemplate) {
|
||||
set("detailTemplate", detailTemplate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getDetailTemplate() {
|
||||
return getStr("detailTemplate");
|
||||
}
|
||||
|
||||
public M setOutlink(String outlink) {
|
||||
set("outlink", outlink);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getOutlink() {
|
||||
return getStr("outlink");
|
||||
}
|
||||
|
||||
public M setChunkValue(String chunkValue) {
|
||||
set("chunkValue", chunkValue);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getChunkValue() {
|
||||
return getStr("chunkValue");
|
||||
}
|
||||
|
||||
public M setRemark(String remark) {
|
||||
set("remark", remark);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return getStr("remark");
|
||||
}
|
||||
|
||||
public M setSiteId(Integer siteId) {
|
||||
set("siteId", siteId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSiteId() {
|
||||
return getInt("siteId");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,157 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseCompany<M extends BaseCompany<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setName(String name) {
|
||||
set("name", name);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStr("name");
|
||||
}
|
||||
|
||||
public M setAddress(String address) {
|
||||
set("address", address);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return getStr("address");
|
||||
}
|
||||
|
||||
public M setPostcode(String postcode) {
|
||||
set("postcode", postcode);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getPostcode() {
|
||||
return getStr("postcode");
|
||||
}
|
||||
|
||||
public M setContact(String contact) {
|
||||
set("contact", contact);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getContact() {
|
||||
return getStr("contact");
|
||||
}
|
||||
|
||||
public M setMobile(String mobile) {
|
||||
set("mobile", mobile);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return getStr("mobile");
|
||||
}
|
||||
|
||||
public M setPhone(String phone) {
|
||||
set("phone", phone);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return getStr("phone");
|
||||
}
|
||||
|
||||
public M setFax(String fax) {
|
||||
set("fax", fax);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getFax() {
|
||||
return getStr("fax");
|
||||
}
|
||||
|
||||
public M setEmail(String email) {
|
||||
set("email", email);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return getStr("email");
|
||||
}
|
||||
|
||||
public M setQq(String qq) {
|
||||
set("qq", qq);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getQq() {
|
||||
return getStr("qq");
|
||||
}
|
||||
|
||||
public M setWeixin(String weixin) {
|
||||
set("weixin", weixin);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getWeixin() {
|
||||
return getStr("weixin");
|
||||
}
|
||||
|
||||
public M setH5(String h5) {
|
||||
set("h5", h5);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getH5() {
|
||||
return getStr("h5");
|
||||
}
|
||||
|
||||
public M setApp(String app) {
|
||||
set("app", app);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getApp() {
|
||||
return getStr("app");
|
||||
}
|
||||
|
||||
public M setBlicense(String blicense) {
|
||||
set("blicense", blicense);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getBlicense() {
|
||||
return getStr("blicense");
|
||||
}
|
||||
|
||||
public M setOther(String other) {
|
||||
set("other", other);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getOther() {
|
||||
return getStr("other");
|
||||
}
|
||||
|
||||
public M setSiteId(Integer siteId) {
|
||||
set("siteId", siteId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSiteId() {
|
||||
return getInt("siteId");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,292 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseContent<M extends BaseContent<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setPublishDate(java.util.Date publishDate) {
|
||||
set("publishDate", publishDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getPublishDate() {
|
||||
return getDate("publishDate");
|
||||
}
|
||||
|
||||
public M setStatus(Integer status) {
|
||||
set("status", status);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return getInt("status");
|
||||
}
|
||||
|
||||
public M setAuthor(String author) {
|
||||
set("author", author);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return getStr("author");
|
||||
}
|
||||
|
||||
public M setSource(String source) {
|
||||
set("source", source);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return getStr("source");
|
||||
}
|
||||
|
||||
public M setOutlink(String outlink) {
|
||||
set("outlink", outlink);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getOutlink() {
|
||||
return getStr("outlink");
|
||||
}
|
||||
|
||||
public M setIco(String ico) {
|
||||
set("ico", ico);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getIco() {
|
||||
return getStr("ico");
|
||||
}
|
||||
|
||||
public M setImage(String image) {
|
||||
set("image", image);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return getStr("image");
|
||||
}
|
||||
|
||||
public M setPicValue(String picValue) {
|
||||
set("picValue", picValue);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getPicValue() {
|
||||
return getStr("picValue");
|
||||
}
|
||||
|
||||
public M setTagIdValue(String tagIdValue) {
|
||||
set("tagIdValue", tagIdValue);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getTagIdValue() {
|
||||
return getStr("tagIdValue");
|
||||
}
|
||||
|
||||
public M setAttach(String attach) {
|
||||
set("attach", attach);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getAttach() {
|
||||
return getStr("attach");
|
||||
}
|
||||
|
||||
public M setIsTop(Boolean isTop) {
|
||||
set("isTop", isTop);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Boolean getIsTop() {
|
||||
return get("isTop");
|
||||
}
|
||||
|
||||
public M setIsRecommend(Boolean isRecommend) {
|
||||
set("isRecommend", isRecommend);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Boolean getIsRecommend() {
|
||||
return get("isRecommend");
|
||||
}
|
||||
|
||||
public M setIsHeadline(Boolean isHeadline) {
|
||||
set("isHeadline", isHeadline);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Boolean getIsHeadline() {
|
||||
return get("isHeadline");
|
||||
}
|
||||
|
||||
public M setVisits(Integer visits) {
|
||||
set("visits", visits);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getVisits() {
|
||||
return getInt("visits");
|
||||
}
|
||||
|
||||
public M setLikes(Integer likes) {
|
||||
set("likes", likes);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getLikes() {
|
||||
return getInt("likes");
|
||||
}
|
||||
|
||||
public M setOppose(Integer oppose) {
|
||||
set("oppose", oppose);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getOppose() {
|
||||
return getInt("oppose");
|
||||
}
|
||||
|
||||
public M setSort(Integer sort) {
|
||||
set("sort", sort);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return getInt("sort");
|
||||
}
|
||||
|
||||
public M setDescription(String description) {
|
||||
set("description", description);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return getStr("description");
|
||||
}
|
||||
|
||||
public M setKeywords(String keywords) {
|
||||
set("keywords", keywords);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getKeywords() {
|
||||
return getStr("keywords");
|
||||
}
|
||||
|
||||
public M setTitle(String title) {
|
||||
set("title", title);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return getStr("title");
|
||||
}
|
||||
|
||||
public M setSubtitle(String subtitle) {
|
||||
set("subtitle", subtitle);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getSubtitle() {
|
||||
return getStr("subtitle");
|
||||
}
|
||||
|
||||
public M setTitlecolor(String titlecolor) {
|
||||
set("titlecolor", titlecolor);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getTitlecolor() {
|
||||
return getStr("titlecolor");
|
||||
}
|
||||
|
||||
public M setIntroduction(String introduction) {
|
||||
set("introduction", introduction);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getIntroduction() {
|
||||
return getStr("introduction");
|
||||
}
|
||||
|
||||
public M setCategoryId(Integer categoryId) {
|
||||
set("categoryId", categoryId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getCategoryId() {
|
||||
return getInt("categoryId");
|
||||
}
|
||||
|
||||
public M setChunkValue(String chunkValue) {
|
||||
set("chunkValue", chunkValue);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getChunkValue() {
|
||||
return getStr("chunkValue");
|
||||
}
|
||||
|
||||
public M setModelFieldValue(String modelFieldValue) {
|
||||
set("modelFieldValue", modelFieldValue);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getModelFieldValue() {
|
||||
return getStr("modelFieldValue");
|
||||
}
|
||||
|
||||
public M setRemark(String remark) {
|
||||
set("remark", remark);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return getStr("remark");
|
||||
}
|
||||
|
||||
public M setSiteId(Integer siteId) {
|
||||
set("siteId", siteId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSiteId() {
|
||||
return getInt("siteId");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,58 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseDiv<M extends BaseDiv<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setName(String name) {
|
||||
set("name", name);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStr("name");
|
||||
}
|
||||
|
||||
public M setTableName(String tableName) {
|
||||
set("tableName", tableName);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return getStr("tableName");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,97 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseDivField<M extends BaseDivField<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setName(String name) {
|
||||
set("name", name);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStr("name");
|
||||
}
|
||||
|
||||
public M setSort(Integer sort) {
|
||||
set("sort", sort);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return getInt("sort");
|
||||
}
|
||||
|
||||
public M setAlias(String alias) {
|
||||
set("alias", alias);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return getStr("alias");
|
||||
}
|
||||
|
||||
public M setDivId(Integer divId) {
|
||||
set("divId", divId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Integer getDivId() {
|
||||
return getInt("divId");
|
||||
}
|
||||
|
||||
public String getUiType() {
|
||||
return getStr("uiType");
|
||||
}
|
||||
|
||||
public M setUiType(String uiType) {
|
||||
set("uiType", uiType);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
|
||||
public String getQueryType() {
|
||||
return getStr("queryType");
|
||||
}
|
||||
|
||||
public M setQueryType(String queryType) {
|
||||
set("queryType", queryType);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,94 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseFriendLink<M extends BaseFriendLink<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setSort(Integer sort) {
|
||||
set("sort", sort);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return getInt("sort");
|
||||
}
|
||||
|
||||
public M setLogo(String logo) {
|
||||
set("logo", logo);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getLogo() {
|
||||
return getStr("logo");
|
||||
}
|
||||
|
||||
public M setName(String name) {
|
||||
set("name", name);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStr("name");
|
||||
}
|
||||
|
||||
public M setUrl(String url) {
|
||||
set("url", url);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return getStr("url");
|
||||
}
|
||||
|
||||
public M setGid(Integer gid) {
|
||||
set("gid", gid);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getGid() {
|
||||
return getInt("gid");
|
||||
}
|
||||
|
||||
public M setSiteId(Integer siteId) {
|
||||
set("siteId", siteId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSiteId() {
|
||||
return getInt("siteId");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,112 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseGuestbook<M extends BaseGuestbook<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setContact(String contact) {
|
||||
set("contact", contact);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getContact() {
|
||||
return getStr("contact");
|
||||
}
|
||||
|
||||
public M setMobile(String mobile) {
|
||||
set("mobile", mobile);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return getStr("mobile");
|
||||
}
|
||||
|
||||
public M setContent(String content) {
|
||||
set("content", content);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return getStr("content");
|
||||
}
|
||||
|
||||
public M setIp(String ip) {
|
||||
set("ip", ip);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return getStr("ip");
|
||||
}
|
||||
|
||||
public M setReplyContent(String replyContent) {
|
||||
set("replyContent", replyContent);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getReplyContent() {
|
||||
return getStr("replyContent");
|
||||
}
|
||||
|
||||
public M setReplyDate(java.util.Date replyDate) {
|
||||
set("replyDate", replyDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getReplyDate() {
|
||||
return getDate("replyDate");
|
||||
}
|
||||
|
||||
public M setStatus(Integer status) {
|
||||
set("status", status);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return getInt("status");
|
||||
}
|
||||
|
||||
public M setSiteId(Integer siteId) {
|
||||
set("siteId", siteId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSiteId() {
|
||||
return getInt("siteId");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,130 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseMenu<M extends BaseMenu<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setSort(Integer sort) {
|
||||
set("sort", sort);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return getInt("sort");
|
||||
}
|
||||
|
||||
public M setGrade(Integer grade) {
|
||||
set("grade", grade);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getGrade() {
|
||||
return getInt("grade");
|
||||
}
|
||||
|
||||
public M setTreePath(String treePath) {
|
||||
set("treePath", treePath);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getTreePath() {
|
||||
return getStr("treePath");
|
||||
}
|
||||
|
||||
public M setCode(String code) {
|
||||
set("code", code);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return getStr("code");
|
||||
}
|
||||
|
||||
public M setName(String name) {
|
||||
set("name", name);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStr("name");
|
||||
}
|
||||
|
||||
public M setType(Integer type) {
|
||||
set("type", type);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return getInt("type");
|
||||
}
|
||||
|
||||
public M setParentId(Long parentId) {
|
||||
set("parentId", parentId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return getLong("parentId");
|
||||
}
|
||||
|
||||
public M setUrl(String url) {
|
||||
set("url", url);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return getStr("url");
|
||||
}
|
||||
|
||||
public M setIcon(String icon) {
|
||||
set("icon", icon);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return getStr("icon");
|
||||
}
|
||||
|
||||
public M setIsShow(Boolean isShow) {
|
||||
set("isShow", isShow);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Boolean getIsShow() {
|
||||
return get("isShow");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,85 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseModel<M extends BaseModel<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setName(String name) {
|
||||
set("name", name);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStr("name");
|
||||
}
|
||||
|
||||
public M setType(Integer type) {
|
||||
set("type", type);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return getInt("type");
|
||||
}
|
||||
|
||||
public M setListTemplate(String listTemplate) {
|
||||
set("listTemplate", listTemplate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getListTemplate() {
|
||||
return getStr("listTemplate");
|
||||
}
|
||||
|
||||
public M setDetailTemplate(String detailTemplate) {
|
||||
set("detailTemplate", detailTemplate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getDetailTemplate() {
|
||||
return getStr("detailTemplate");
|
||||
}
|
||||
|
||||
public M setStatus(Integer status) {
|
||||
set("status", status);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return getInt("status");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,94 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseModelField<M extends BaseModelField<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setName(String name) {
|
||||
set("name", name);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStr("name");
|
||||
}
|
||||
|
||||
public M setSort(Integer sort) {
|
||||
set("sort", sort);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return getInt("sort");
|
||||
}
|
||||
|
||||
public M setType(String type) {
|
||||
set("type", type);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return getStr("type");
|
||||
}
|
||||
|
||||
public M setAlias(String alias) {
|
||||
set("alias", alias);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return getStr("alias");
|
||||
}
|
||||
|
||||
public M setValue(String value) {
|
||||
set("value", value);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return getStr("value");
|
||||
}
|
||||
|
||||
public M setModelId(Long modelId) {
|
||||
set("modelId", modelId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Long getModelId() {
|
||||
return getLong("modelId");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,121 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseNav<M extends BaseNav<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setGrade(Integer grade) {
|
||||
set("grade", grade);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getGrade() {
|
||||
return getInt("grade");
|
||||
}
|
||||
|
||||
public M setTreePath(String treePath) {
|
||||
set("treePath", treePath);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getTreePath() {
|
||||
return getStr("treePath");
|
||||
}
|
||||
|
||||
public M setParentId(Integer parentId) {
|
||||
set("parentId", parentId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getParentId() {
|
||||
return getInt("parentId");
|
||||
}
|
||||
|
||||
public M setSort(Integer sort) {
|
||||
set("sort", sort);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return getInt("sort");
|
||||
}
|
||||
|
||||
public M setImage(String image) {
|
||||
set("image", image);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return getStr("image");
|
||||
}
|
||||
|
||||
public M setName(String name) {
|
||||
set("name", name);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStr("name");
|
||||
}
|
||||
|
||||
public M setUrl(String url) {
|
||||
set("url", url);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return getStr("url");
|
||||
}
|
||||
|
||||
public M setIsOutlink(Boolean isOutlink) {
|
||||
set("isOutlink", isOutlink);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Boolean getIsOutlink() {
|
||||
return get("isOutlink");
|
||||
}
|
||||
|
||||
public M setSiteId(Integer siteId) {
|
||||
set("siteId", siteId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSiteId() {
|
||||
return getInt("siteId");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,76 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseRole<M extends BaseRole<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setName(String name) {
|
||||
set("name", name);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStr("name");
|
||||
}
|
||||
|
||||
public M setIsSystem(Boolean isSystem) {
|
||||
set("isSystem", isSystem);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Boolean getIsSystem() {
|
||||
return get("isSystem");
|
||||
}
|
||||
|
||||
public M setRemark(String remark) {
|
||||
set("remark", remark);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return getStr("remark");
|
||||
}
|
||||
|
||||
public M setPermission(String permission) {
|
||||
set("permission", permission);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return getStr("permission");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseRoleSite<M extends BaseRoleSite<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setSiteId(Integer siteId) {
|
||||
set("siteId", siteId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSiteId() {
|
||||
return getInt("siteId");
|
||||
}
|
||||
|
||||
public M setRoleId(Integer roleId) {
|
||||
set("roleId", roleId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getRoleId() {
|
||||
return getInt("roleId");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,58 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseSetup<M extends BaseSetup<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setName(String name) {
|
||||
set("name", name);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStr("name");
|
||||
}
|
||||
|
||||
public M setValue(String value) {
|
||||
set("value", value);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return getStr("value");
|
||||
}
|
||||
|
||||
public M setRemark(String remark) {
|
||||
set("remark", remark);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return getStr("remark");
|
||||
}
|
||||
|
||||
public M setSort(Integer sort) {
|
||||
set("sort", sort);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return getInt("sort");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,121 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseSite<M extends BaseSite<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setType(Integer type) {
|
||||
set("type", type);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return getInt("type");
|
||||
}
|
||||
|
||||
public M setProtocol(String protocol) {
|
||||
set("protocol", protocol);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return getStr("protocol");
|
||||
}
|
||||
|
||||
public M setPcTemplate(String pcTemplate) {
|
||||
set("pcTemplate", pcTemplate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getPcTemplate() {
|
||||
return getStr("pcTemplate");
|
||||
}
|
||||
|
||||
public M setIsMobile(Boolean isMobile) {
|
||||
set("isMobile", isMobile);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Boolean getIsMobile() {
|
||||
return get("isMobile");
|
||||
}
|
||||
|
||||
public M setMobileTemplate(String mobileTemplate) {
|
||||
set("mobileTemplate", mobileTemplate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getMobileTemplate() {
|
||||
return getStr("mobileTemplate");
|
||||
}
|
||||
|
||||
public M setIsDefault(Boolean isDefault) {
|
||||
set("isDefault", isDefault);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Boolean getIsDefault() {
|
||||
return get("isDefault");
|
||||
}
|
||||
|
||||
public M setName(String name) {
|
||||
set("name", name);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getStr("name");
|
||||
}
|
||||
|
||||
public M setCat(String cat) {
|
||||
set("cat", cat);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getCat() {
|
||||
return getStr("cat");
|
||||
}
|
||||
|
||||
public M setDomain(String domain) {
|
||||
set("domain", domain);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return getStr("domain");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,103 @@
|
||||
package vip.fuck.sm.plugins.cms.entity.base;
|
||||
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.jfinal.plugin.activerecord.Model;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public abstract class BaseSlide<M extends BaseSlide<M>> extends Model<M> implements IBean {
|
||||
|
||||
public M setId(Integer id) {
|
||||
set("id", id);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return getInt("id");
|
||||
}
|
||||
|
||||
public M setCreateDate(java.util.Date createDate) {
|
||||
set("createDate", createDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getCreateDate() {
|
||||
return getDate("createDate");
|
||||
}
|
||||
|
||||
public M setUpdateDate(java.util.Date updateDate) {
|
||||
set("updateDate", updateDate);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public java.util.Date getUpdateDate() {
|
||||
return getDate("updateDate");
|
||||
}
|
||||
|
||||
public M setSort(Integer sort) {
|
||||
set("sort", sort);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return getInt("sort");
|
||||
}
|
||||
|
||||
public M setSubtitle(String subtitle) {
|
||||
set("subtitle", subtitle);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getSubtitle() {
|
||||
return getStr("subtitle");
|
||||
}
|
||||
|
||||
public M setImage(String image) {
|
||||
set("image", image);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return getStr("image");
|
||||
}
|
||||
|
||||
public M setTitle(String title) {
|
||||
set("title", title);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return getStr("title");
|
||||
}
|
||||
|
||||
public M setUrl(String url) {
|
||||
set("url", url);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return getStr("url");
|
||||
}
|
||||
|
||||
public M setGid(Integer gid) {
|
||||
set("gid", gid);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getGid() {
|
||||
return getInt("gid");
|
||||
}
|
||||
|
||||
public M setSiteId(Integer siteId) {
|
||||
set("siteId", siteId);
|
||||
return (M)this;
|
||||
}
|
||||
|
||||
public Integer getSiteId() {
|
||||
return getInt("siteId");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user