From d73687bc6115007145b4aab050e4e29ff87fd8ae Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 01 三月 2021 18:44:36 +0800
Subject: [PATCH] 布丸代码优化

---
 src/main/java/com/yeshi/buwan/controller/admin/ClassAdminController.java |  443 ++++++++++++++++++++++++-------------------------------
 1 files changed, 195 insertions(+), 248 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/controller/admin/ClassAdminController.java b/src/main/java/com/yeshi/buwan/controller/admin/ClassAdminController.java
index 1071fc5..b3929ae 100644
--- a/src/main/java/com/yeshi/buwan/controller/admin/ClassAdminController.java
+++ b/src/main/java/com/yeshi/buwan/controller/admin/ClassAdminController.java
@@ -1,295 +1,242 @@
 package com.yeshi.buwan.controller.admin;
 
-import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
-import com.yeshi.buwan.domain.DetailSystem;
-import com.yeshi.buwan.domain.HomeVideo;
-import com.yeshi.buwan.domain.HotVideoType;
-import com.yeshi.buwan.domain.SuperHotType;
-import com.yeshi.buwan.domain.SuperVideoType;
-import com.yeshi.buwan.domain.VideoType;
+import com.yeshi.buwan.domain.*;
 import com.yeshi.buwan.domain.web.CategoryRecommendVideoAdmin;
 import com.yeshi.buwan.service.imp.ClassService;
 import com.yeshi.buwan.service.imp.HomeTypeService;
 import com.yeshi.buwan.service.imp.HotVideoTypeService;
 import com.yeshi.buwan.service.imp.SystemService;
 import com.yeshi.buwan.service.imp.recommend.CategoryRecommendVideoService;
-import com.yeshi.buwan.util.Constant;
 import com.yeshi.buwan.util.StringUtil;
+import com.yeshi.buwan.util.SystemUtil;
 import com.yeshi.buwan.web.tag.PageEntity;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 @Controller
 @RequestMapping("")
 public class ClassAdminController {
 
-	@Resource
-	private HotVideoTypeService hotVideoTypeService;
+    @Resource
+    private HotVideoTypeService hotVideoTypeService;
 
-	@Resource
-	private ClassService classService;
+    @Resource
+    private ClassService classService;
 
-	@Resource
-	private HomeTypeService homeTypeService;
-	
-	@Resource
-	private CategoryRecommendVideoService categoryRecommendVideoService;
-	
-	@Resource
-	private SystemService systemService;
-	
-	private String key;
-	private int pageIndex;
-	private int detailsystem;
-	
-	
-	public CategoryRecommendVideoService getCategoryRecommendVideoService() {
-		return categoryRecommendVideoService;
-	}
+    @Resource
+    private HomeTypeService homeTypeService;
 
-	public void setCategoryRecommendVideoService(
-			CategoryRecommendVideoService categoryRecommendVideoService) {
-		this.categoryRecommendVideoService = categoryRecommendVideoService;
-	}
+    @Resource
+    private CategoryRecommendVideoService categoryRecommendVideoService;
 
-	public SystemService getSystemService() {
-		return systemService;
-	}
+    private String key;
+    private int pageIndex;
+    private int detailsystem;
 
-	public void setSystemService(SystemService systemService) {
-		this.systemService = systemService;
-	}
 
-	public String getKey() {
-		return key;
-	}
+    public String getKey() {
+        return key;
+    }
 
-	public void setKey(String key) {
-		this.key = key;
-	}
+    public void setKey(String key) {
+        this.key = key;
+    }
 
-	public int getPageIndex() {
-		return pageIndex;
-	}
+    public int getPageIndex() {
+        return pageIndex;
+    }
 
-	public void setPageIndex(int pageIndex) {
-		this.pageIndex = pageIndex;
-	}
+    public void setPageIndex(int pageIndex) {
+        this.pageIndex = pageIndex;
+    }
 
-	public int getDetailsystem() {
-		return detailsystem;
-	}
+    public int getDetailsystem() {
+        return detailsystem;
+    }
 
-	public void setDetailsystem(int detailsystem) {
-		this.detailsystem = detailsystem;
-	}
+    public void setDetailsystem(int detailsystem) {
+        this.detailsystem = detailsystem;
+    }
 
-	public HotVideoTypeService getHotVideoTypeService() {
-		return hotVideoTypeService;
-	}
 
-	public void setHotVideoTypeService(HotVideoTypeService hotVideoTypeService) {
-		this.hotVideoTypeService = hotVideoTypeService;
-	}
+    @RequestMapping(value = "/ClassAdminServlet", method = RequestMethod.GET)
+    public String get(HttpServletRequest req, PrintWriter out) {
+        try {
+            req.setCharacterEncoding("UTF-8");
+        } catch (UnsupportedEncodingException e1) {
+            e1.printStackTrace();
+        }
+        String type = req.getParameter("type");
+        System.out.println("type--" + type);
+        if (type.equalsIgnoreCase("deleteHotType")) {
+            hotVideoTypeService.deleteHotType(new HotVideoType(req.getParameter("id")));
 
-	public ClassService getClassService() {
-		return classService;
-	}
+            return "hottype_list";
+        } else if (type.equalsIgnoreCase("getVideoType")) {
+            String parentId = req.getParameter("parentId");
+            java.util.List<VideoType> list = classService.getFirstTypeList(parentId);
+            JSONArray array = new JSONArray();
+            for (VideoType t : list) {
+                JSONObject object = new JSONObject();
+                object.put("Id", t.getId());
+                object.put("Name", t.getName());
+                array.add(object);
+            }
+            Gson gson = new Gson();
+            gson.toJson(array);
+            out.print(gson.toJson(array));
+            out.close();
+        } else if (type.equalsIgnoreCase("deleteVideoTypeAll")) {
+            String ids = req.getParameter("ids");
+            if (!StringUtil.isNullOrEmpty(ids)) {
+                if (ids.endsWith(","))
+                    ids = ids.substring(0, ids.length() - 1);
+            }
+            String[] idss = ids.split(",");
+            for (String st : idss) {
+                classService.deleteVideoType(st);
+            }
+            out.print("SUCCESS");
+        } else if (type.equalsIgnoreCase("addSuperVideoType")) {// 鍒嗙被鍒嗘淳
+            String ids = req.getParameter("ids");
+            String system = req.getParameter("system");
+            String icon = req.getParameter("pictures");
+            SuperVideoType svt = new SuperVideoType();
+            svt.setCreatetime(System.currentTimeMillis() + "");
+            svt.setDetailSystem(new DetailSystem(system));
+            svt.setPicture(icon);
+            svt.setType(new VideoType(Long.parseLong(ids)));
+            classService.addSuperVideoType(svt);
+            out.print("SUCCESS");
+        } else if (type.equalsIgnoreCase("deleteSuperVideoType")) {
+            String ids = req.getParameter("ids");
+            String system = req.getParameter("system");
+            classService.deleteVideoTypeAdmin(ids, system);
+            out.print("SUCCESS");
+        } else if (type.equalsIgnoreCase("deleteHotTypeAll")) {
+            String ids = req.getParameter("ids");
+            if (!StringUtil.isNullOrEmpty(ids)) {
+                if (ids.endsWith(","))
+                    ids = ids.substring(0, ids.length() - 1);
+            }
+            String[] idss = ids.split(",");
+            for (String st : idss) {
+                hotVideoTypeService.deleteHotType(new HotVideoType(st));
+            }
+            out.print("SUCCESS");
+        } else if (type.equalsIgnoreCase("addSuperHotType")) {// 鍒嗙被鍒嗘淳
+            String ids = req.getParameter("ids");
+            String system = req.getParameter("system");
+            SuperHotType svt = new SuperHotType();
+            svt.setCreatetime(System.currentTimeMillis() + "");
+            svt.setDetailSystem(new DetailSystem(system));
+            svt.setHotType(new HotVideoType(ids));
+            hotVideoTypeService.addSuperHotType(svt);
+            out.print("SUCCESS");
+        } else if (type.equalsIgnoreCase("deleteSuperHotType")) {
+            String ids = req.getParameter("ids");
+            String system = req.getParameter("system");
+            classService.deleteHotTypeAdmin(ids, system);
+            out.print("SUCCESS");
+        } else if (type.equalsIgnoreCase("changeHomeVideoPicture")) {
+            String homevideid = req.getParameter("id");
+            String picture = req.getParameter("picture");
+            HomeVideo hv = homeTypeService.getHomeVideoById(homevideid);
+            hv.setPicture(picture);
+            homeTypeService.updateHomeVideo(hv);
+            out.print("SUCCESS");
+        }
+        return "";
+    }
 
-	public void setClassService(ClassService classService) {
-		this.classService = classService;
-	}
+    @RequestMapping(value = "/ClassAdminServlet", method = RequestMethod.POST)
+    public String post(HttpServletRequest req, HttpServletResponse resp, PrintWriter out) {
+        try {
+            req.setCharacterEncoding("UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
 
-	public HomeTypeService getHomeTypeService() {
-		return homeTypeService;
-	}
+        String type = req.getParameter("type");
+        if (type.equalsIgnoreCase("addHotType")) {
+            String step1 = req.getParameter("step1");
+            String step2 = req.getParameter("step2");
+            HotVideoType hotType = new HotVideoType();
+            hotType.setAddType(1);
+            hotType.setCreatetime(System.currentTimeMillis() + "");
+            if (!StringUtil.isNullOrEmpty(step2)) {
+                hotType.setType(new VideoType(Long.parseLong(step2)));
+                hotVideoTypeService.addHotType(hotType);
+            } else if (!StringUtil.isNullOrEmpty(step1)) {
+                hotType.setType(new VideoType(Long.parseLong(step1)));
+                hotVideoTypeService.addHotType(hotType);
+            }
 
-	public void setHomeTypeService(HomeTypeService homeTypeService) {
-		this.homeTypeService = homeTypeService;
-	}
+            return "hottype_add";
+        }
+        return "";
+    }
 
-	@RequestMapping(value = "/ClassAdminServlet", method = RequestMethod.GET)
-	public String get(HttpServletRequest req, PrintWriter out) {
-		try {
-			req.setCharacterEncoding("UTF-8");
-		} catch (UnsupportedEncodingException e1) {
-			e1.printStackTrace();
-		}
-		String type = req.getParameter("type");
-		System.out.println("type--"+type);
-		if (type.equalsIgnoreCase("deleteHotType")) {
-			hotVideoTypeService.deleteHotType(new HotVideoType(req.getParameter("id")));
+    /**
+     * 鍏抽敭瀛楁悳绱㈠垪琛�
+     *
+     * @return
+     */
+    @RequestMapping("/search")
+    public void categoryRecommendVideoList(HttpServletRequest request, HttpSession session, PrintWriter out) {
+        if (pageIndex == 0)
+            pageIndex = 1;
+        key = request.getParameter("key");
+        String videotype = request.getParameter("videotype");
+        videotype = StringUtil.isNullOrEmpty(videotype) ? "150" : videotype;
 
-			return "hottype_list";
-		} else if (type.equalsIgnoreCase("getVideoType")) {
-			String parentId = req.getParameter("parentId");
-			java.util.List<VideoType> list = classService.getFirstTypeList(parentId);
-			JSONArray array = new JSONArray();
-			for (VideoType t : list) {
-				JSONObject object = new JSONObject();
-				object.put("Id", t.getId());
-				object.put("Name", t.getName());
-				array.add(object);
-			}
-			Gson gson = new Gson();
-			gson.toJson(array);
-			out.print(gson.toJson(array));
-			out.close();
-		} else if (type.equalsIgnoreCase("deleteVideoTypeAll")) {
-			String ids = req.getParameter("ids");
-			if (!StringUtil.isNullOrEmpty(ids)) {
-				if (ids.endsWith(","))
-					ids = ids.substring(0, ids.length() - 1);
-			}
-			String[] idss = ids.split(",");
-			for (String st : idss) {
-				classService.deleteVideoType(st);
-			}
-			out.print("SUCCESS");
-		} else if (type.equalsIgnoreCase("addSuperVideoType")) {// 鍒嗙被鍒嗘淳
-			String ids = req.getParameter("ids");
-			String system = req.getParameter("system");
-			String icon = req.getParameter("pictures");
-			SuperVideoType svt = new SuperVideoType();
-			svt.setCreatetime(System.currentTimeMillis() + "");
-			svt.setDetailSystem(new DetailSystem(system));
-			svt.setPicture(icon);
-			svt.setType(new VideoType(Long.parseLong(ids)));
-			classService.addSuperVideoType(svt);
-			out.print("SUCCESS");
-		} else if (type.equalsIgnoreCase("deleteSuperVideoType")) {
-			String ids = req.getParameter("ids");
-			String system = req.getParameter("system");
-			classService.deleteVideoTypeAdmin(ids, system);
-			out.print("SUCCESS");
-		} else if (type.equalsIgnoreCase("deleteHotTypeAll")) {
-			String ids = req.getParameter("ids");
-			if (!StringUtil.isNullOrEmpty(ids)) {
-				if (ids.endsWith(","))
-					ids = ids.substring(0, ids.length() - 1);
-			}
-			String[] idss = ids.split(",");
-			for (String st : idss) {
-				hotVideoTypeService.deleteHotType(new HotVideoType(st));
-			}
-			out.print("SUCCESS");
-		} else if (type.equalsIgnoreCase("addSuperHotType")) {// 鍒嗙被鍒嗘淳
-			String ids = req.getParameter("ids");
-			String system = req.getParameter("system");
-			SuperHotType svt = new SuperHotType();
-			svt.setCreatetime(System.currentTimeMillis() + "");
-			svt.setDetailSystem(new DetailSystem(system));
-			svt.setHotType(new HotVideoType(ids));
-			hotVideoTypeService.addSuperHotType(svt);
-			out.print("SUCCESS");
-		} else if (type.equalsIgnoreCase("deleteSuperHotType")) {
-			String ids = req.getParameter("ids");
-			String system = req.getParameter("system");
-			classService.deleteHotTypeAdmin(ids, system);
-			out.print("SUCCESS");
-		} else if (type.equalsIgnoreCase("changeHomeVideoPicture")) {
-			String homevideid = req.getParameter("id");
-			String picture = req.getParameter("picture");
-			HomeVideo hv = homeTypeService.getHomeVideoById(homevideid);
-			hv.setPicture(picture);
-			homeTypeService.updateHomeVideo(hv);
-			out.print("SUCCESS");
-		}
-		return "";
-	}
-
-	@RequestMapping(value = "/ClassAdminServlet", method = RequestMethod.POST)
-	public String post(HttpServletRequest req, HttpServletResponse resp, PrintWriter out) {
-		try {
-			req.setCharacterEncoding("UTF-8");
-		} catch (UnsupportedEncodingException e) {
-			e.printStackTrace();
-		}
-
-		String type = req.getParameter("type");
-		if (type.equalsIgnoreCase("addHotType")) {
-			String step1 = req.getParameter("step1");
-			String step2 = req.getParameter("step2");
-			HotVideoType hotType = new HotVideoType();
-			hotType.setAddType(1);
-			hotType.setCreatetime(System.currentTimeMillis() + "");
-			if (!StringUtil.isNullOrEmpty(step2)) {
-				hotType.setType(new VideoType(Long.parseLong(step2)));
-				hotVideoTypeService.addHotType(hotType);
-			} else if (!StringUtil.isNullOrEmpty(step1)) {
-				hotType.setType(new VideoType(Long.parseLong(step1)));
-				hotVideoTypeService.addHotType(hotType);
-			}
-
-			return "hottype_add";
-		}
-		return "";
-	}
-	
-	/**
-	 * 鍏抽敭瀛楁悳绱㈠垪琛�
-	 * 
-	 * @return
-	 */
-	@RequestMapping("/search")
-	public void categoryRecommendVideoList(HttpServletRequest request,PrintWriter out) {
-		if (pageIndex == 0)
-			pageIndex = 1;
-		key = request.getParameter("key");
-		String videotype = request.getParameter("videotype");
-		videotype = StringUtil.isNullOrEmpty(videotype) ? "150" : videotype;
-
-		List<CategoryRecommendVideoAdmin> list = categoryRecommendVideoService.getCategoryRecommendVideoAdmin(key,
-				Integer.parseInt(videotype), detailsystem, pageIndex);
-		long count = categoryRecommendVideoService.getCategoryRecommendVideoAdminCount(key, Integer.parseInt(videotype),
-				detailsystem);
-		PageEntity pe = new PageEntity();
-		pe.setPageIndex(pageIndex);
-		pe.setPageSize(1);
-		Map<String, String> map = new HashMap<String, String>();
-		map.put("key", key);
-		map.put("detailsystem", detailsystem + "");
-		map.put("videotype", videotype + "");
-		pe.setParams(map);
-		pe.setTotalCount((int) count);
-		Gson gson=new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
-		JSONObject root = new JSONObject();
-		root.put("code", "0");
-		root.put("pageEntity", pe);
-		String json = gson.toJson(list);
-		root.put("crv", json);
+        List<CategoryRecommendVideoAdmin> list = categoryRecommendVideoService.getCategoryRecommendVideoAdmin(key,
+                Integer.parseInt(videotype), SystemUtil.getAdminSelectedSystemId(session), detailsystem, pageIndex);
+        long count = categoryRecommendVideoService.getCategoryRecommendVideoAdminCount(key, Integer.parseInt(videotype),
+                SystemUtil.getAdminSelectedSystemId(session), detailsystem);
+        PageEntity pe = new PageEntity();
+        pe.setPageIndex(pageIndex);
+        pe.setPageSize(1);
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("key", key);
+        map.put("detailsystem", detailsystem + "");
+        map.put("videotype", videotype + "");
+        pe.setParams(map);
+        pe.setTotalCount((int) count);
+        Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
+        JSONObject root = new JSONObject();
+        root.put("code", "0");
+        root.put("pageEntity", pe);
+        String json = gson.toJson(list);
+        root.put("crv", json);
 //		for (CategoryRecommendVideoAdmin categoryRecommendVideoAdmin : list) {
 //			System.out.println(categoryRecommendVideoAdmin.getCategoryRecommendVideo().getCategoryRecommendVideo());
 //			root.put("categoryRecommendVideoAdmin", gson.toJson(categoryRecommendVideoAdmin.getCategoryRecommendVideo().getCategoryRecommendVideo()));
 //		}
-		System.out.println(root.toString());
-		out.print(root);
+        System.out.println(root.toString());
+        out.print(root);
 //		dataMap.put("categoryRecommendVideoAdminList", list);
-		List<DetailSystem> detailSystemList = systemService.getDetailSystemList();
 //		dataMap.put("detailSystemList", detailSystemList);
-		List<VideoType> typeList = classService.getFirstTypeList("");
 //		dataMap.put("videoTypeList", typeList);
 //		json.put("data", data);
 //		System.out.println("jsonStr---------"+jsonStr);
 //		out.print(jsonStr);
-		
-	}
-	
+
+    }
+
 }

--
Gitblit v1.8.0