This commit is contained in:
123 2025-04-27 14:54:59 +08:00
parent 1a7c7f2225
commit 85a8d27795
2 changed files with 714 additions and 739 deletions

View File

@ -1,20 +1,17 @@
package cc.iteachyou.cms.common;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.springframework.web.bind.annotation.ModelAttribute;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.ModelAttribute;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
/**
*
* controller基类实现将JSON格式结果的输出方法
*/
@SuppressWarnings("unchecked")
@ -33,9 +30,9 @@ public class BaseController implements Serializable {
}
/**
* 从Session中取得用户信息
*
* @return 用户信息
*/
public Object getLoginUser() {
@ -49,6 +46,7 @@ public class BaseController implements Serializable {
/**
* 取得HttpServletRequest对象
*
* @return HttpServletRequest对象
*/
public HttpServletRequest getRequest() {
@ -57,6 +55,7 @@ public class BaseController implements Serializable {
/**
* 取得Response对象
*
* @return
*/
public HttpServletResponse getResponse() {
@ -65,6 +64,7 @@ public class BaseController implements Serializable {
/**
* 转换字符串为json 格式
*
* @param str 普通字符串
*/
public void outJsonString(String str) {
@ -74,6 +74,7 @@ public class BaseController implements Serializable {
/**
* 转换字符串为json 格式并设置ContentType为text/html
*
* @param str 普通字符串
*/
public void outJson(Object obj) {
@ -83,6 +84,7 @@ public class BaseController implements Serializable {
/**
* 输出字符串到页面
*
* @param str 字符
*/
public void outString(String str) {
@ -100,6 +102,7 @@ public class BaseController implements Serializable {
/**
* 输出xml文本串到页面
*
* @param xmlStr xml串
*/
public void outXMLString(String xmlStr) {

View File

@ -1,67 +1,29 @@
package cc.iteachyou.cms.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.util.StrUtil;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wf.captcha.ArithmeticCaptcha;
import com.wf.captcha.utils.CaptchaUtil;
import cc.iteachyou.cms.common.BaseController;
import cc.iteachyou.cms.common.ExceptionEnum;
import cc.iteachyou.cms.common.ResponseResult;
import cc.iteachyou.cms.common.SearchEntity;
import cc.iteachyou.cms.common.StateCodeEnum;
import cc.iteachyou.cms.entity.Archives;
import cc.iteachyou.cms.entity.Attachment;
import cc.iteachyou.cms.entity.Category;
import cc.iteachyou.cms.entity.Field;
import cc.iteachyou.cms.entity.Form;
import cc.iteachyou.cms.entity.SearchRecord;
import cc.iteachyou.cms.common.*;
import cc.iteachyou.cms.entity.System;
import cc.iteachyou.cms.entity.Theme;
import cc.iteachyou.cms.exception.AdminGeneralException;
import cc.iteachyou.cms.exception.CmsException;
import cc.iteachyou.cms.exception.FormParameterException;
import cc.iteachyou.cms.exception.TemplateNotFoundException;
import cc.iteachyou.cms.exception.TemplateReadException;
import cc.iteachyou.cms.exception.TransactionException;
import cc.iteachyou.cms.service.ArchivesService;
import cc.iteachyou.cms.service.AttachmentService;
import cc.iteachyou.cms.service.CategoryService;
import cc.iteachyou.cms.service.FieldService;
import cc.iteachyou.cms.service.FormService;
import cc.iteachyou.cms.service.SearchRecordService;
import cc.iteachyou.cms.service.SystemService;
import cc.iteachyou.cms.service.ThemeService;
import cc.iteachyou.cms.entity.*;
import cc.iteachyou.cms.exception.*;
import cc.iteachyou.cms.service.*;
import cc.iteachyou.cms.taglib.ParseEngine;
import cc.iteachyou.cms.taglib.utils.URLUtils;
import cc.iteachyou.cms.utils.FileConfiguration;
import cc.iteachyou.cms.utils.StringUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.wf.captcha.ArithmeticCaptcha;
import com.wf.captcha.utils.CaptchaUtil;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
@Controller
@Scope("prototype")
@ -90,6 +52,7 @@ public class FrontController extends BaseController {
/**
* 首页方法
*
* @throws CmsException
* @throws IOException
*/
@ -141,6 +104,7 @@ public class FrontController extends BaseController {
/**
* 封面方法
*
* @param typeid 栏目编码
* @param visitUrl 访问URL
* @throws CmsException
@ -210,6 +174,7 @@ public class FrontController extends BaseController {
/**
* 列表方法
*
* @param typeid 栏目编码
* @param visitUrl 访问URL
* @param pageNum 当前页
@ -287,6 +252,7 @@ public class FrontController extends BaseController {
/**
* 文章详情方法
*
* @param id 文章ID
* @throws CmsException
* @throws IOException
@ -381,6 +347,7 @@ public class FrontController extends BaseController {
/**
* 文章详情方法
*
* @param id 文章ID
* @throws CmsException
* @throws IOException
@ -407,6 +374,7 @@ public class FrontController extends BaseController {
/**
* 附件下载
*
* @param id
* @throws AdminGeneralException
*/
@ -444,6 +412,7 @@ public class FrontController extends BaseController {
/**
* 搜索
*
* @param params
* @throws CmsException
*/
@ -521,6 +490,7 @@ public class FrontController extends BaseController {
/**
* 前端投稿
*
* @param params
* @return
* @throws CmsException
@ -654,6 +624,7 @@ public class FrontController extends BaseController {
/**
* 输出字符串到页面
*
* @param html 字符
*/
public void outHtml(String html) {
@ -664,6 +635,7 @@ public class FrontController extends BaseController {
httpServletResponse.setHeader("Cache-Control", "no-cache");
httpServletResponse.setHeader("Cache-Control", "no-store");
httpServletResponse.setHeader("Pragma", "no-cache");
httpServletResponse.setHeader("Cache-Control", "public");
httpServletResponse.setDateHeader("Expires", 0L);
httpServletResponse.getWriter().write(html);
httpServletResponse.flushBuffer();