hugeng 4 роки тому
батько
коміт
84c0c8f84b

+ 24 - 17
src/main/java/com/yc/education/controller/admin/BannersContrller.java

@@ -7,7 +7,6 @@ import com.yc.education.model.Banners;
 import com.yc.education.model.Bannersen;
 import com.yc.education.model.Classify01;
 import com.yc.education.service.*;
-import com.yc.education.util.I18NFilter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -35,31 +34,31 @@ public class BannersContrller {
     private BannersenService bannersenService;
 
     @RequestMapping("admin/banners_list.html")
-    public String bannersList(Model model){
+    public String bannersList(Model model) {
         List<Banners> list = bannersService.findAllBanners();
         model.addAttribute("list", list);
         return "/admin/banners_list";
     }
 
     @RequestMapping("admin/banners_list_en.html")
-    public String bannersListEn(Model model){
+    public String bannersListEn(Model model) {
         List<Bannersen> list = bannersenService.findAllBanners();
         model.addAttribute("list", list);
         return "/adminEn/banners_list";
     }
 
     @RequestMapping("/admin/add_banners.html")
-    public String addBanners(){
+    public String addBanners() {
         return "admin/add_banners";
     }
 
     @RequestMapping("/admin/add_banners_en.html")
-    public String addBannersEn(){
+    public String addBannersEn() {
         return "adminEn/add_banners";
     }
 
     @RequestMapping("admin/submit_addBanners.html")
-    public String submitAddBanners(Banners banners,HttpServletRequest request){
+    public String submitAddBanners(Banners banners, HttpServletRequest request) {
         String rootPath = request.getSession().getServletContext().getRealPath("/");
         String contextPath = request.getSession().getServletContext().getContextPath();
         BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "img").invoke(ActionMap.UPLOAD_FILE);
@@ -71,7 +70,7 @@ public class BannersContrller {
     }
 
     @RequestMapping("admin/submit_addBanners_en.html")
-    public String submitAddBannersEn(Bannersen bannersen, HttpServletRequest request){
+    public String submitAddBannersEn(Bannersen bannersen, HttpServletRequest request) {
         String rootPath = request.getSession().getServletContext().getRealPath("/");
         String contextPath = request.getSession().getServletContext().getContextPath();
         BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "img").invoke(ActionMap.UPLOAD_FILE);
@@ -84,7 +83,7 @@ public class BannersContrller {
 
     //根据id更改一级分类
     @RequestMapping("admin/update_banners.html")
-    public String updateBanners(Model model,Integer pid){
+    public String updateBanners(Model model, Integer pid) {
         Banners banners = bannersService.selectByKey(pid);
         model.addAttribute("banners", banners);
         return "admin/update_banners";
@@ -92,7 +91,7 @@ public class BannersContrller {
 
     //根据id更改一级分类
     @RequestMapping("admin/update_banners_en.html")
-    public String updateBannersEn(Model model,Integer pid){
+    public String updateBannersEn(Model model, Integer pid) {
         Bannersen bannersen = bannersenService.selectByKey(pid);
         model.addAttribute("banners", bannersen);
         return "adminEn/update_banners";
@@ -100,7 +99,7 @@ public class BannersContrller {
 
     //提交更新的一级分类
     @RequestMapping("admin/submit_upBanners.html")
-    public String submit_upBanners(Banners banners,HttpServletRequest request){
+    public String submit_upBanners(Banners banners, HttpServletRequest request) {
         String rootPath = request.getSession().getServletContext().getRealPath("/");
         String contextPath = request.getSession().getServletContext().getContextPath();
         BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "img").invoke(ActionMap.UPLOAD_FILE);
@@ -112,7 +111,7 @@ public class BannersContrller {
 
     //提交更新的一级分类
     @RequestMapping("admin/submit_upBanners_en.html")
-    public String submit_upBannersEn(Bannersen bannersen, HttpServletRequest request){
+    public String submit_upBannersEn(Bannersen bannersen, HttpServletRequest request) {
         String rootPath = request.getSession().getServletContext().getRealPath("/");
         String contextPath = request.getSession().getServletContext().getContextPath();
         BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "img").invoke(ActionMap.UPLOAD_FILE);
@@ -124,19 +123,27 @@ public class BannersContrller {
 
 
     //根据id删除一级分类,先删除商品中对应的所有一级商品,在删除对应的二级分类
-    @RequestMapping(value = "/admin/delete_banners.html",method = RequestMethod.POST)
+    @RequestMapping(value = "/admin/delete_banners.html", method = RequestMethod.POST)
     @ResponseBody
-    public String deleteClass01(Integer pid,HttpServletRequest request ){
+    public String deleteClass01(Integer pid, HttpServletRequest request) {
         int num = bannersService.delete(pid);
-        if(num>0){return "ok";}else{return "error";}
+        if (num > 0) {
+            return "ok";
+        } else {
+            return "error";
+        }
     }
 
     //根据id删除一级分类,先删除商品中对应的所有一级商品,在删除对应的二级分类
-    @RequestMapping(value = "/admin/delete_banners_en.html",method = RequestMethod.POST)
+    @RequestMapping(value = "/admin/delete_banners_en.html", method = RequestMethod.POST)
     @ResponseBody
-    public String deleteClass01(Integer pid){
+    public String deleteClass01(Integer pid) {
         int num = bannersenService.delete(pid);
-        if(num>0){return "ok";}else{return "error";}
+        if (num > 0) {
+            return "ok";
+        } else {
+            return "error";
+        }
     }
 
 

+ 0 - 1
src/main/java/com/yc/education/controller/admin/Classify01Contrller.java

@@ -3,7 +3,6 @@ package com.yc.education.controller.admin;
 import com.yc.education.model.Classify01;
 import com.yc.education.model.Classify01en;
 import com.yc.education.service.*;
-import com.yc.education.util.I18NFilter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;

+ 0 - 1
src/main/java/com/yc/education/controller/admin/Classify02Controller.java

@@ -5,7 +5,6 @@ import com.yc.education.model.Classify01en;
 import com.yc.education.model.Classify02;
 import com.yc.education.model.Classify02en;
 import com.yc.education.service.*;
-import com.yc.education.util.I18NFilter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;

+ 0 - 1
src/main/java/com/yc/education/controller/admin/NewsController.java

@@ -12,7 +12,6 @@ import com.yc.education.model.News;
 import com.yc.education.model.Newsen;
 import com.yc.education.service.NewsService;
 import com.yc.education.service.NewsenService;
-import com.yc.education.util.I18NFilter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;

+ 35 - 32
src/main/java/com/yc/education/controller/admin/ProductController.java

@@ -45,13 +45,14 @@ public class ProductController {
 
     @Autowired
     private Classify01enService classify01enService;
+
     //查找所有的商品
     @RequestMapping("admin/product_list.html")
     public String productList(Model model, String name, String minDate, String maxDate,
-                              @RequestParam(value="cid",defaultValue="0")Integer cid,
-                              @RequestParam(value="wid",defaultValue="0")Integer wid,
-                              @RequestParam(value="page",defaultValue="1")Integer page,
-                              @RequestParam(value="rows",defaultValue = "10") Integer rows){
+                              @RequestParam(value = "cid", defaultValue = "0") Integer cid,
+                              @RequestParam(value = "wid", defaultValue = "0") Integer wid,
+                              @RequestParam(value = "page", defaultValue = "1") Integer page,
+                              @RequestParam(value = "rows", defaultValue = "10") Integer rows) {
         List<Product> list;
         PageHelper.startPage(page, rows);
         list = productService.findProductByPid(cid, wid, name, minDate, maxDate);
@@ -73,10 +74,10 @@ public class ProductController {
     //查找所有的商品
     @RequestMapping("admin/product_list_en.html")
     public String productListEn(Model model, String name, String minDate, String maxDate,
-                              @RequestParam(value="cid",defaultValue="0")Integer cid,
-                              @RequestParam(value="wid",defaultValue="0")Integer wid,
-                              @RequestParam(value="page",defaultValue="1")Integer page,
-                              @RequestParam(value="rows",defaultValue = "10") Integer rows,HttpServletRequest request){
+                                @RequestParam(value = "cid", defaultValue = "0") Integer cid,
+                                @RequestParam(value = "wid", defaultValue = "0") Integer wid,
+                                @RequestParam(value = "page", defaultValue = "1") Integer page,
+                                @RequestParam(value = "rows", defaultValue = "10") Integer rows, HttpServletRequest request) {
         List<Producten> listen;
         PageHelper.startPage(page, rows);
         listen = productenService.findProductByPid(cid, wid, name, minDate, maxDate);
@@ -95,10 +96,23 @@ public class ProductController {
         return "adminEn/product_list";
     }
 
+    //提交更新的商品
+    @RequestMapping("admin/submit_upProduct.html")
+    public String submitUpProduct(HttpServletRequest request, Product product) {
+        String rootPath = request.getSession().getServletContext().getRealPath("/");
+        String contextPath = request.getSession().getServletContext().getContextPath();
+        BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "img").invoke(ActionMap.UPLOAD_FILE);
+        String url = state.getInfo("url");
+        product.setImg(url);
+        productService.updateNotNull(product);
+        return "redirect: product_list.html?wid=" + product.getWid() + "&cid=" + product.getCid();
+    }
+
+
     //根据商品id删除商品
-    @RequestMapping(value = "/admin/delete_product.html",method = RequestMethod.POST)
+    @RequestMapping(value = "/admin/delete_product.html", method = RequestMethod.POST)
     @ResponseBody
-    public String deleteProduct(Integer pid){
+    public String deleteProduct(Integer pid) {
         int num = productService.delete(pid);
         if (num > 0) {
             return "ok";
@@ -108,9 +122,9 @@ public class ProductController {
     }
 
     //根据商品id删除商品
-    @RequestMapping(value = "/admin/delete_product_en.html",method = RequestMethod.POST)
+    @RequestMapping(value = "/admin/delete_product_en.html", method = RequestMethod.POST)
     @ResponseBody
-    public String deleteProductEn(Integer pid){
+    public String deleteProductEn(Integer pid) {
         int num = productenService.delete(pid);
         if (num > 0) {
             return "ok";
@@ -121,7 +135,7 @@ public class ProductController {
 
     //新增某一个二级分类下的商品
     @RequestMapping("admin/add_product.html")
-    public String addProduct(Model model){
+    public String addProduct(Model model) {
         List<Classify01> list01 = classify01Service.findAllClass01();
         model.addAttribute("list01", list01);
         return "admin/add_product";
@@ -129,7 +143,7 @@ public class ProductController {
 
     //新增某一个二级分类下的商品
     @RequestMapping("admin/add_product_en.html")
-    public String addProductEn(Model model){
+    public String addProductEn(Model model) {
         List<Classify01en> list01en = classify01enService.findAllClass01();
         model.addAttribute("list01", list01en);
         return "adminEn/add_product";
@@ -137,7 +151,7 @@ public class ProductController {
 
     //提交新增的商品
     @RequestMapping("admin/submit_addProduct.html")
-    public String submitAddProduct(HttpServletRequest request, Product product){
+    public String submitAddProduct(HttpServletRequest request, Product product) {
         String rootPath = request.getSession().getServletContext().getRealPath("/");
         String contextPath = request.getSession().getServletContext().getContextPath();
         BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "img").invoke(ActionMap.UPLOAD_FILE);
@@ -149,7 +163,7 @@ public class ProductController {
 
     //提交新增的商品
     @RequestMapping("admin/submit_addProduct_en.html")
-    public String submitAddProductEn(HttpServletRequest request,Producten producten){
+    public String submitAddProductEn(HttpServletRequest request, Producten producten) {
         String rootPath = request.getSession().getServletContext().getRealPath("/");
         String contextPath = request.getSession().getServletContext().getContextPath();
         BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "img").invoke(ActionMap.UPLOAD_FILE);
@@ -161,7 +175,7 @@ public class ProductController {
 
     //根据id更新某一个二级分类下的商品
     @RequestMapping("admin/update_product.html")
-    public String updateProduct(Integer pid,Model model){
+    public String updateProduct(Integer pid, Model model) {
         Product product = productService.selectByKey(pid);
         List<Classify01> list01 = classify01Service.findAllClass01();
         List<Classify02> list02 = classify02Service.findClassByCid(product.getCid());//通过一级id查找二级分类集合
@@ -173,7 +187,7 @@ public class ProductController {
 
     //根据id更新某一个二级分类下的商品
     @RequestMapping("admin/update_product_en.html")
-    public String updateProductEn(Integer pid,Model model){
+    public String updateProductEn(Integer pid, Model model) {
         Producten producten = productenService.selectByKey(pid);
         List<Classify01en> list01en = classify01enService.findAllClass01();
         List<Classify02en> list02en = classify02enService.findClassByCid(producten.getCid());//通过一级id查找二级分类集合
@@ -183,21 +197,10 @@ public class ProductController {
         return "adminEn/update_product";
     }
 
-    //提交更新的商品
-    @RequestMapping("admin/submit_upProduct.html")
-    public String submitUpProduct(HttpServletRequest request, Product product){
-        String rootPath = request.getSession().getServletContext().getRealPath("/");
-        String contextPath = request.getSession().getServletContext().getContextPath();
-        BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "img").invoke(ActionMap.UPLOAD_FILE);
-        String url = state.getInfo("url");
-        product.setImg(url);
-        productService.updateNotNull(product);
-        return "redirect: product_list.html";
-    }
 
     //提交更新的商品
     @RequestMapping("admin/submit_upProduct_en.html")
-    public String submitUpProductEn(HttpServletRequest request,Producten producten){
+    public String submitUpProductEn(HttpServletRequest request, Producten producten) {
         String rootPath = request.getSession().getServletContext().getRealPath("/");
         String contextPath = request.getSession().getServletContext().getContextPath();
         BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "img").invoke(ActionMap.UPLOAD_FILE);
@@ -209,7 +212,7 @@ public class ProductController {
 
     /*执行批量删除*/
     @RequestMapping("admin/delete_ProList.html")
-    public String deleteProList(String checkValue){
+    public String deleteProList(String checkValue) {
         String[] skt = checkValue.split(",");
         for (int i = 0; i < skt.length; i++) {
             productService.delete(Integer.parseInt(skt[i]));
@@ -219,7 +222,7 @@ public class ProductController {
 
     /*执行批量删除*/
     @RequestMapping("admin/delete_ProList_en.html")
-    public String deleteProListEn(String checkValue){
+    public String deleteProListEn(String checkValue) {
         String[] skt = checkValue.split(",");
         for (int i = 0; i < skt.length; i++) {
             productenService.delete(Integer.parseInt(skt[i]));