diff --git a/pom.xml b/pom.xml
index cfb5452..19c82d6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,7 +64,7 @@
4.1.2
3.3.0
1.9.6
- 4.1.0
+ 4.0.1
1.1.2
2.3.1
@@ -267,6 +267,7 @@
${javax.servlet-api.version}
provided
+
org.apache.tomcat.embed
tomcat-embed-jasper
@@ -425,6 +426,16 @@
+
+ icu.mhb
+ mybatis-plus-join-boot-starter
+ 2.1.0
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
diff --git a/src/main/java/me/mofun/controller/HelpController.java b/src/main/java/me/mofun/controller/HelpController.java
index 88e5691..1cc88d9 100644
--- a/src/main/java/me/mofun/controller/HelpController.java
+++ b/src/main/java/me/mofun/controller/HelpController.java
@@ -1,6 +1,6 @@
package me.mofun.controller;
-
+import me.mofun.entity.News;
import me.mofun.entity.Newstype;
import me.mofun.entity.Suggestion;
import me.mofun.entity.pojo.HelpInfo;
@@ -10,121 +10,139 @@ import me.mofun.service.ISysConfigureService;
import me.mofun.utils.ViewUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
+import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
import java.util.List;
+/**
+ * 帮助中心控制器
+ * 处理帮助相关页面展示和建议提交等功能
+ */
@Controller
@RequestMapping("/help")
public class HelpController {
@Autowired
private ViewUtils viewUtils;
- private final String module = "login";
-
-
-
- private Suggestion suggestion;
- private String rnd;
- private List helpInfoList;
- private List helpTypeList;
-
-
- @Autowired
- private ISysConfigureService sysConfigureService;
- @Autowired
- private INewstypeService newsTypeService;
- @Autowired
- private INewsService newsService;
-
- HttpServletRequest request = null;
- HttpServletResponse response = null;
-
- public Integer newsId; //帮助信息的文章编号,亦即 news表中的 newsId
-
-// public String index(){
-// News news = newsService.getById(newsId.toString());
-// helpTypeList = newsTypeService.indexNewsTypeByParentId(2);
-// helpInfoList = new ArrayList();
-// for(NewsType nt:helpTypeList){
-// HelpInfo item = new HelpInfo();
-// List newsList = newsService.indexNews(nt.getId(),null);
-// item.setCategoryId(nt.getId());
-// item.setCategoryName(nt.getCategoryName());
-// item.setInfoList(newsList);
-// helpInfoList.add(item);
-// }
-// return "index";
-// }
-
-
-
-
-
-// public String doSuggestion(){
-// request = Struts2Utils.getRequest();
-// try {
-// Cookie[] cookies = request.getCookies();
-// if(request.isRequestedSessionIdFromCookie()){
-// for (int i = 0; i < cookies.length; i++) {
-// Cookie cookie = cookies[i];
-// if(cookie.getName().equals("rndCode")){
-// String rndCode = cookie.getValue();
-// if(rnd.trim().equalsIgnoreCase(rndCode)){
-// sysConfigureService.doSuggestion(suggestion);
-// Struts2Utils.render("text/html", "","encoding:UTF-8");
-// }else{
-// Struts2Utils.render("text/html", "","encoding:UTF-8");
-// }
-// }
-// }
-// }
-// } catch (Exception e) {
-// e.printStackTrace();
-// Struts2Utils.render("text/html", "","encoding:UTF-8");
-// }
-//
-// return null;
-// }
-
- @GetMapping("/deliveryFees")
- public ModelAndView deliveryFees() {
- return viewUtils.create(module, "deliveryFees");
- }
-
- @GetMapping("/prodCheck")
- public ModelAndView prodCheck() {
- return viewUtils.create(module, "prodCheck");
- }
- @GetMapping("/shiptwo")
- public ModelAndView shiptwo() {
- return viewUtils.create(module, "shiptwo");
- }
+ // 模块名称,用于视图路径拼接
+ private final String module = "help";
- @GetMapping("/privacy")
- public ModelAndView privacy() {
- return viewUtils.create(module, "privacy");
- }
-
- @GetMapping("/userExperience")
- public ModelAndView userExperience() {
- return viewUtils.create(module, "userExperience");
- }
+ @Autowired
+ private ISysConfigureService sysConfigureService;
- @GetMapping("/qqgroup")
- public ModelAndView qqgroup() {
- return viewUtils.create(module, "qqgroup");
- }
+ @Autowired
+ private INewstypeService newsTypeService;
- @GetMapping("/show")
- public ModelAndView show() {
- return viewUtils.create(module, "show");
- }
+ @Autowired
+ private INewsService newsService;
+
+ /**
+ * 帮助中心首页
+ * 展示帮助信息列表和指定新闻详情
+ *
+ * @param newsId 新闻ID,用于展示具体新闻内容
+ * @return 包含帮助信息的ModelAndView
+ */
+ @GetMapping("/index")
+ public ModelAndView index(@RequestParam(required = false) Integer newsId) {
+ ModelAndView mav = viewUtils.create(module, "index");
+
+ // 获取新闻详情(如果newsId存在)
+ if (newsId != null) {
+ News news = newsService.getById(newsId.toString());
+ mav.addObject("news", news);
+ }
+
+ // 获取帮助类型列表(父ID为2的新闻类型)
+ List helpTypeList = newsTypeService.indexNewsTypeByParentId(2);
+ mav.addObject("helpTypeList", helpTypeList);
+
+ // 构建帮助信息列表,每个类型下包含对应的新闻
+ List helpInfoList = new ArrayList<>();
+ if (helpTypeList != null && !helpTypeList.isEmpty()) {
+ for (Newstype newsType : helpTypeList) {
+ HelpInfo helpInfo = new HelpInfo();
+ helpInfo.setCategoryId(newsType.getId());
+ helpInfo.setCategoryName(newsType.getCategoryName());
+
+ // 获取该类型下的新闻列表
+ List newsList = newsService.indexNews(newsType.getId(), null);
+ helpInfo.setInfoList(newsList);
+
+ helpInfoList.add(helpInfo);
+ }
+ }
+ mav.addObject("helpInfoList", helpInfoList);
+
+ return mav;
+ }
+
+ /**
+ * 处理建议提交
+ * 验证验证码并保存用户建议
+ *
+ * @param request 请求对象
+ * @param response 响应对象
+ * @param suggestion 用户提交的建议
+ * @param rnd 用户输入的验证码
+ * @throws IOException IO异常
+ */
+ @PostMapping("/doSuggestion")
+ public void doSuggestion(HttpServletRequest request,
+ HttpServletResponse response,
+ @ModelAttribute Suggestion suggestion,
+ @RequestParam(required = false) String rnd) throws IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ PrintWriter out = response.getWriter();
+
+ try {
+ // 校验参数
+ if (suggestion == null) {
+ out.print("");
+ return;
+ }
+
+ // 验证验证码
+ Cookie[] cookies = request.getCookies();
+ if (request.isRequestedSessionIdFromCookie() && cookies != null) {
+ for (Cookie cookie : cookies) {
+ if ("rndCode".equals(cookie.getName())) {
+ String rndCode = cookie.getValue();
+ // 验证验证码是否正确
+ if (rnd != null && rnd.trim().equalsIgnoreCase(rndCode)) {
+ // 保存建议
+ sysConfigureService.doSuggestion(suggestion);
+ out.print("");
+ } else {
+ out.print("");
+ }
+ return;
+ }
+ }
+ }
+
+ // 未找到验证码Cookie
+ out.print("");
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ out.print("");
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ // 以下为页面跳转方法,与原Action对应
@GetMapping("/openCookie")
public ModelAndView openCookie() {
@@ -181,4 +199,38 @@ public class HelpController {
return viewUtils.create(module, "suggestion");
}
-}
+ @GetMapping("/deliveryFees")
+ public ModelAndView deliveryFees() {
+ return viewUtils.create(module, "deliveryFees");
+ }
+
+ @GetMapping("/prodCheck")
+ public ModelAndView prodCheck() {
+ return viewUtils.create(module, "prodCheck");
+ }
+
+ @GetMapping("/shiptwo")
+ public ModelAndView shiptwo() {
+ return viewUtils.create(module, "shiptwo");
+ }
+
+ @GetMapping("/privacy")
+ public ModelAndView privacy() {
+ return viewUtils.create(module, "privacy");
+ }
+
+ @GetMapping("/userExperience")
+ public ModelAndView userExperience() {
+ return viewUtils.create(module, "userExperience");
+ }
+
+ @GetMapping("/qqgroup")
+ public ModelAndView qqgroup() {
+ return viewUtils.create(module, "qqgroup");
+ }
+
+ @GetMapping("/show")
+ public ModelAndView show() {
+ return viewUtils.create(module, "show");
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/me/mofun/controller/IndexController.java b/src/main/java/me/mofun/controller/IndexController.java
index 67551b8..d69bd47 100644
--- a/src/main/java/me/mofun/controller/IndexController.java
+++ b/src/main/java/me/mofun/controller/IndexController.java
@@ -1,6 +1,5 @@
package me.mofun.controller;
-import com.baomidou.mybatisplus.core.metadata.IPage;
import me.mofun.entity.*;
import me.mofun.entity.pojo.BuyHistoryJSON;
import me.mofun.entity.pojo.ProductJSON;
@@ -23,11 +22,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.springframework.web.context.request.RequestAttributes;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
diff --git a/src/main/java/me/mofun/controller/UserController.java b/src/main/java/me/mofun/controller/UserController.java
new file mode 100644
index 0000000..2c7de4f
--- /dev/null
+++ b/src/main/java/me/mofun/controller/UserController.java
@@ -0,0 +1,1144 @@
+package me.mofun.controller;
+
+
+import me.mofun.entity.*;
+import me.mofun.entity.pojo.*;
+import me.mofun.entity.vo.Pagination;
+import me.mofun.service.*;
+import me.mofun.util.DateUtil;
+import me.mofun.util.HTMLFilter;
+import me.mofun.util.UserNameUtil;
+import net.sf.json.JSONObject;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Controller
+@RequestMapping("/user")
+public class UserController {
+ private static final long serialVersionUID = 6146740235643445087L;
+
+ @Autowired
+ private IUserService userService;
+ @Autowired
+ private ISpellbuyproductService spellbuyproductService;
+ @Autowired
+ private ISpellbuyrecordService spellbuyrecordService;
+ @Autowired
+ private ILatestlotteryService latestlotteryService;
+ @Autowired
+ private IShareinfoService shareService;
+ @Autowired
+ private IConsumetableService consumetableService;
+ @Autowired
+ private INewsService newsService;
+
+ @Autowired
+ private ICommissionqueryService commissionqueryService;
+ @Autowired
+ private ICommissionpointsService commissionpointsService;
+ @Autowired
+ private IApplymentionService applymentionService;
+ @Autowired
+ private ICardpasswordService cardpasswordService;
+ @Autowired
+ private IOrderdetailService orderdetailService;
+ @Autowired
+ private ISProvinceService provinceService;
+
+ private static final int BUFFER_SIZE = 100 * 1024;
+ private static final HTMLFilter htmlFilter = new HTMLFilter();
+ private static final Logger logger = Logger.getLogger(UserController.class);
+ private static final String UploadImages = "/uploadImages";
+ private static final String FaceImages = "/faceImages";
+
+ // 文件上传复制方法
+ private static void copy(File src, File dst) {
+ try (InputStream in = new BufferedInputStream(new FileInputStream(src), BUFFER_SIZE);
+ OutputStream out = new BufferedOutputStream(new FileOutputStream(dst), BUFFER_SIZE)) {
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int bytesRead;
+ while ((bytesRead = in.read(buffer)) > 0) {
+ out.write(buffer, 0, bytesRead);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @GetMapping("/index")
+ public String index(@RequestParam(required = false) String forward, Model model, HttpServletRequest request) {
+ if (StringUtils.isNotBlank(forward)) {
+ forward = htmlFilter.filter(forward);
+ }
+
+ Cookie[] cookies = request.getCookies();
+ if (request.isRequestedSessionIdFromCookie() && cookies != null) {
+ for (Cookie cookie : cookies) {
+ if ("userId".equals(cookie.getName())) {
+ String userId = cookie.getValue();
+ if (StringUtils.isNotBlank(userId)) {
+ User user = userService.findById(userId);
+ model.addAttribute("user", user);
+
+ // 即将揭晓商品
+ Pagination datePage = spellbuyproductService.upcomingAnnounced(1, 5);
+ List