| | |
| | | package com.yeshi.buwan.controller.admin.api; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpSession; |
| | | |
| | | import com.yeshi.buwan.util.SystemUtil; |
| | | 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.system.DetailSystem; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import com.yeshi.buwan.domain.special.Special; |
| | | import com.yeshi.buwan.domain.special.SpecialVideo; |
| | |
| | | @RequestMapping("admin/new/api/special") |
| | | public class SpecialController { |
| | | |
| | | @Resource |
| | | private SpecialService specialService; |
| | | @Resource |
| | | private SpecialService specialService; |
| | | |
| | | @Resource |
| | | private SystemService systemService; |
| | | |
| | | @RequestMapping(value = "/getspeciallist", method = RequestMethod.POST) |
| | | public void getSpecialList(PrintWriter out) { |
| | | List<Special> list = specialService.getSpecialList(); |
| | | JSONArray array = new JSONArray(); |
| | | if (list != null) |
| | | for (Special special : list) { |
| | | JSONObject obj = new JSONObject(); |
| | | obj.put("id", special.getId()); |
| | | obj.put("name", special.getName()); |
| | | array.add(obj); |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", 0); |
| | | object.put("data", array); |
| | | out.print(object); |
| | | } |
| | | @Resource |
| | | private SystemService systemService; |
| | | |
| | | @RequestMapping(value = "/addspecialvideo", method = RequestMethod.POST) |
| | | public void addSpecialVideo(String specialid, String videos, PrintWriter out) { |
| | | String[] videoStr = videos.split(","); |
| | | String[] sps = specialid.split(","); |
| | | for (String videoid : videoStr) { |
| | | for (String sp : sps) { |
| | | SpecialVideo sv = new SpecialVideo(); |
| | | sv.setCreatetime(System.currentTimeMillis() + ""); |
| | | sv.setOrderby(0); |
| | | sv.setSpecial(new Special(sp)); |
| | | sv.setVideo(new VideoInfo(videoid)); |
| | | specialService.addSpecialVideo(sv); |
| | | } |
| | | } |
| | | @RequestMapping(value = "/getspeciallist", method = RequestMethod.POST) |
| | | public void getSpecialList(PrintWriter out) { |
| | | List<Special> list = specialService.getSpecialList(); |
| | | JSONArray array = new JSONArray(); |
| | | if (list != null) |
| | | for (Special special : list) { |
| | | JSONObject obj = new JSONObject(); |
| | | obj.put("id", special.getId()); |
| | | obj.put("name", special.getName()); |
| | | array.add(obj); |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", 0); |
| | | object.put("data", array); |
| | | out.print(object); |
| | | } |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", 0); |
| | | object.put("msg", "添加成功"); |
| | | out.print(object); |
| | | } |
| | | |
| | | /** |
| | | * 关键字搜索列表 |
| | | * |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/specialList", method = RequestMethod.POST) |
| | | public void specialList(int pageIndex,String key,int detailsystem,PrintWriter out) { |
| | | @RequestMapping(value = "/addspecialvideo", method = RequestMethod.POST) |
| | | public void addSpecialVideo(String specialid, String videos, PrintWriter out) { |
| | | String[] videoStr = videos.split(","); |
| | | String[] sps = specialid.split(","); |
| | | for (String videoid : videoStr) { |
| | | for (String sp : sps) { |
| | | SpecialVideo sv = new SpecialVideo(); |
| | | sv.setCreatetime(System.currentTimeMillis() + ""); |
| | | sv.setOrderby(0); |
| | | sv.setSpecial(new Special(sp)); |
| | | sv.setVideo(new VideoInfo(videoid)); |
| | | specialService.addSpecialVideo(sv); |
| | | } |
| | | } |
| | | |
| | | if (pageIndex == 0) |
| | | pageIndex = 1; |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", 0); |
| | | object.put("msg", "添加成功"); |
| | | out.print(object); |
| | | } |
| | | |
| | | List<SpecialAdmin> list = specialService.getSpecialAdmin(key, detailsystem, pageIndex); |
| | | long count = specialService.getSpecialAdminCount(key, detailsystem); |
| | | PageEntity pe = new PageEntity(); |
| | | pe.setPageIndex(pageIndex); |
| | | pe.setPageSize(Constant.pageCount); |
| | | Map<String, String> map = new HashMap<String, String>(); |
| | | map.put("key", key); |
| | | map.put("detailsystem", detailsystem + ""); |
| | | 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); |
| | | root.put("SpecialAdminList", gson.toJson(list)); |
| | | System.out.println(root.toString()); |
| | | out.print(root); |
| | | return ; |
| | | } |
| | | |
| | | @RequestMapping(value = "/delSpecial", method = RequestMethod.POST) |
| | | public void delSpecial(String ids,PrintWriter out) { |
| | | if(ids!=null && !"".equals(ids.trim())){ |
| | | String[] idArr = ids.split(","); |
| | | for (String id : idArr) { |
| | | specialService.deleteSpecial(new Special(id)); |
| | | System.out.println(id); |
| | | } |
| | | out.print("yes"); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/setSpecialApp", method = RequestMethod.POST) |
| | | public void set(String type,String detailSystem, String id,PrintWriter out) { |
| | | |
| | | System.out.println("type="+type); |
| | | System.out.println("detailSystem="+detailSystem); |
| | | |
| | | if ("add".equalsIgnoreCase(type)) {// 获取来源列表 |
| | | if (!StringUtil.isNullOrEmpty(detailSystem) && !StringUtil.isNullOrEmpty(id)) { |
| | | SuperSpecial sz = new SuperSpecial(); |
| | | sz.setDetailSystem(new DetailSystem(detailSystem)); |
| | | sz.setSpecial(new Special(id)); |
| | | specialService.addSuperSpecial(sz); |
| | | out.print("yes"); |
| | | } |
| | | } else if ("delete".equalsIgnoreCase(type)) {// 获取下级分类 |
| | | if (!StringUtil.isNullOrEmpty(detailSystem) && !StringUtil.isNullOrEmpty(id)) { |
| | | specialService.deleteSpecialAdmin(id, detailSystem); |
| | | out.print("yes"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/getSpecial", method = RequestMethod.POST) |
| | | public void getSpecial(String id,PrintWriter out) { |
| | | Special special = specialService.getSpecial(id); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("code", "0"); |
| | | json.put("data", new Gson().toJson(special)); |
| | | out.print(json); |
| | | return ; |
| | | } |
| | | @RequestMapping(value = "/updateSpecial", method = RequestMethod.POST) |
| | | public void updateSpecial(String id,String introduction,String name,int orderby,String picture,String show,String showonmain,PrintWriter out) { |
| | | |
| | | System.out.println("id:"+id); |
| | | System.out.println("name:"+name); |
| | | System.out.println("show:"+show); |
| | | System.out.println("showonmain:"+showonmain); |
| | | System.out.println("picture:"+picture); |
| | | System.out.println("orderby:"+orderby); |
| | | System.out.println("introduction:"+introduction); |
| | | |
| | | Special special = specialService.getSpecial(id); |
| | | special.setIntroduction(introduction); |
| | | special.setName(name); |
| | | special.setOrderby(orderby); |
| | | special.setPicture(picture); |
| | | if ("on".equalsIgnoreCase(show)) |
| | | special.setShow(true); |
| | | else |
| | | special.setShow(false); |
| | | /** |
| | | * 关键字搜索列表 |
| | | * |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/specialList", method = RequestMethod.POST) |
| | | public void specialList(int pageIndex, String key, int detailsystem, HttpSession session, PrintWriter out) { |
| | | |
| | | if ("on".equalsIgnoreCase(showonmain)) |
| | | special.setShowonmain(true); |
| | | else |
| | | special.setShowonmain(false); |
| | | |
| | | specialService.updateSpecial(special); |
| | | |
| | | out.print("yes"); |
| | | return ; |
| | | } |
| | | @RequestMapping(value = "/addSpecial", method = RequestMethod.POST) |
| | | public void addSpecial(String detailSystems,String introduction,String name,int orderby,String picture,String show,String showonmain,PrintWriter out) { |
| | | |
| | | System.out.println("name:"+name); |
| | | System.out.println("detailSystems:"+detailSystems); |
| | | System.out.println("show:"+show); |
| | | System.out.println("showonmain:"+showonmain); |
| | | System.out.println("picture:"+picture); |
| | | System.out.println("orderby:"+orderby); |
| | | System.out.println("introduction:"+introduction); |
| | | |
| | | |
| | | List<String> sysList = new ArrayList<String>(); |
| | | if (!StringUtil.isNullOrEmpty(detailSystems)) { |
| | | if (detailSystems.contains(",")) { |
| | | for (String st : detailSystems.split(",")) |
| | | sysList.add(st); |
| | | } else |
| | | sysList.add(detailSystems); |
| | | } |
| | | if (pageIndex == 0) |
| | | pageIndex = 1; |
| | | |
| | | Special special = new Special(); |
| | | special.setIntroduction(introduction); |
| | | special.setName(name); |
| | | special.setOrderby(orderby); |
| | | special.setPicture(picture); |
| | | special.setCreatetime(System.currentTimeMillis() + ""); |
| | | if ("on".equalsIgnoreCase(show)) |
| | | special.setShow(true); |
| | | else |
| | | special.setShow(false); |
| | | List<SpecialAdmin> list = specialService.getSpecialAdmin(key, SystemUtil.getAdminSelectedSystemId(session), detailsystem, pageIndex); |
| | | long count = specialService.getSpecialAdminCount(key, SystemUtil.getAdminSelectedSystemId(session), detailsystem); |
| | | PageEntity pe = new PageEntity(); |
| | | pe.setPageIndex(pageIndex); |
| | | pe.setPageSize(Constant.pageCount); |
| | | Map<String, String> map = new HashMap<String, String>(); |
| | | map.put("key", key); |
| | | map.put("detailsystem", detailsystem + ""); |
| | | 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); |
| | | root.put("SpecialAdminList", gson.toJson(list)); |
| | | System.out.println(root.toString()); |
| | | out.print(root); |
| | | return; |
| | | } |
| | | |
| | | if ("on".equalsIgnoreCase(showonmain)) |
| | | special.setShowonmain(true); |
| | | else |
| | | special.setShowonmain(false); |
| | | @RequestMapping(value = "/delSpecial", method = RequestMethod.POST) |
| | | public void delSpecial(String ids, PrintWriter out) { |
| | | if (ids != null && !"".equals(ids.trim())) { |
| | | String[] idArr = ids.split(","); |
| | | for (String id : idArr) { |
| | | specialService.deleteSpecial(new Special(id)); |
| | | System.out.println(id); |
| | | } |
| | | out.print("yes"); |
| | | } |
| | | } |
| | | |
| | | specialService.addSpecial(special); |
| | | @RequestMapping(value = "/setSpecialApp", method = RequestMethod.POST) |
| | | public void set(String type, String detailSystem, String id, PrintWriter out) { |
| | | |
| | | for (String ds : sysList) { |
| | | SuperSpecial ss = new SuperSpecial(); |
| | | ss.setDetailSystem(new DetailSystem(ds)); |
| | | ss.setSpecial(special); |
| | | specialService.addSuperSpecial(ss); |
| | | } |
| | | out.print("yes"); |
| | | |
| | | return ; |
| | | } |
| | | |
| | | @RequestMapping(value = "/specialVideoList", method = RequestMethod.POST) |
| | | public void specialVideoList(String key,String specialId,int pageIndex,PrintWriter out) { |
| | | |
| | | System.out.println("key=="+key); |
| | | System.out.println("specialId=="+specialId); |
| | | System.out.println("type=" + type); |
| | | System.out.println("detailSystem=" + detailSystem); |
| | | |
| | | long count = specialService.getSpecialVideoListCount(specialId, key); |
| | | PageEntity pe = new PageEntity(); |
| | | pe.setPageIndex(pageIndex); |
| | | pe.setPageSize(Constant.pageCount); |
| | | Map<String, String> map = new HashMap<String, String>(); |
| | | map.put("key", key); |
| | | map.put("specialId", specialId); |
| | | pe.setParams(map); |
| | | pe.setTotalCount((int) count); |
| | | JSONObject json=new JSONObject(); |
| | | json.put("code", "0"); |
| | | json.put("pageEntity", pe); |
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); |
| | | List<SpecialVideo> list = specialService.getSpecialVideoList(specialId,pe, key); |
| | | json.put("specialVideoList", gson.toJson(list)); |
| | | out.print(json); |
| | | return ; |
| | | } |
| | | |
| | | @RequestMapping(value = "/deleteSpecialVideoList", method = RequestMethod.POST) |
| | | public void deleteSpecialVideoList(String ids,PrintWriter out) { |
| | | if(!StringUtil.isNullOrEmpty(ids)){ |
| | | String[] idArr = ids.split(","); |
| | | for (String id : idArr) { |
| | | specialService.deleteSpecialVideo(id); |
| | | System.out.println("iiid--"+id); |
| | | } |
| | | out.print("yes"); |
| | | } |
| | | return; |
| | | } |
| | | if ("add".equalsIgnoreCase(type)) {// 获取来源列表 |
| | | if (!StringUtil.isNullOrEmpty(detailSystem) && !StringUtil.isNullOrEmpty(id)) { |
| | | SuperSpecial sz = new SuperSpecial(); |
| | | sz.setDetailSystem(new DetailSystem(detailSystem)); |
| | | sz.setSpecial(new Special(id)); |
| | | specialService.addSuperSpecial(sz); |
| | | out.print("yes"); |
| | | } |
| | | } else if ("delete".equalsIgnoreCase(type)) {// 获取下级分类 |
| | | if (!StringUtil.isNullOrEmpty(detailSystem) && !StringUtil.isNullOrEmpty(id)) { |
| | | specialService.deleteSpecialAdmin(id, detailSystem); |
| | | out.print("yes"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/getSpecial", method = RequestMethod.POST) |
| | | public void getSpecial(String id, PrintWriter out) { |
| | | Special special = specialService.getSpecial(id); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("code", "0"); |
| | | json.put("data", new Gson().toJson(special)); |
| | | out.print(json); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping(value = "/updateSpecial", method = RequestMethod.POST) |
| | | public void updateSpecial(String id, String introduction, String name, int orderby, String picture, String show, String showonmain, PrintWriter out) { |
| | | |
| | | System.out.println("id:" + id); |
| | | System.out.println("name:" + name); |
| | | System.out.println("show:" + show); |
| | | System.out.println("showonmain:" + showonmain); |
| | | System.out.println("picture:" + picture); |
| | | System.out.println("orderby:" + orderby); |
| | | System.out.println("introduction:" + introduction); |
| | | |
| | | Special special = specialService.getSpecial(id); |
| | | special.setIntroduction(introduction); |
| | | special.setName(name); |
| | | special.setOrderby(orderby); |
| | | special.setPicture(picture); |
| | | if ("on".equalsIgnoreCase(show)) |
| | | special.setShow(true); |
| | | else |
| | | special.setShow(false); |
| | | |
| | | if ("on".equalsIgnoreCase(showonmain)) |
| | | special.setShowonmain(true); |
| | | else |
| | | special.setShowonmain(false); |
| | | |
| | | specialService.updateSpecial(special); |
| | | |
| | | out.print("yes"); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping(value = "/addSpecial", method = RequestMethod.POST) |
| | | public void addSpecial(String detailSystems, String introduction, String name, int orderby, String picture, String show, String showonmain, HttpSession session, PrintWriter out) { |
| | | |
| | | System.out.println("name:" + name); |
| | | System.out.println("detailSystems:" + detailSystems); |
| | | System.out.println("show:" + show); |
| | | System.out.println("showonmain:" + showonmain); |
| | | System.out.println("picture:" + picture); |
| | | System.out.println("orderby:" + orderby); |
| | | System.out.println("introduction:" + introduction); |
| | | |
| | | |
| | | List<String> sysList = new ArrayList<String>(); |
| | | if (!StringUtil.isNullOrEmpty(detailSystems)) { |
| | | if (detailSystems.contains(",")) { |
| | | for (String st : detailSystems.split(",")) |
| | | sysList.add(st); |
| | | } else |
| | | sysList.add(detailSystems); |
| | | } |
| | | |
| | | Special special = new Special(); |
| | | special.setIntroduction(introduction); |
| | | special.setName(name); |
| | | special.setOrderby(orderby); |
| | | special.setPicture(picture); |
| | | special.setCreatetime(System.currentTimeMillis() + ""); |
| | | if ("on".equalsIgnoreCase(show)) |
| | | special.setShow(true); |
| | | else |
| | | special.setShow(false); |
| | | |
| | | if ("on".equalsIgnoreCase(showonmain)) |
| | | special.setShowonmain(true); |
| | | else |
| | | special.setShowonmain(false); |
| | | |
| | | |
| | | special.setSystem(SystemUtil.getAdminSelectedSystem(session)); |
| | | |
| | | specialService.addSpecial(special); |
| | | |
| | | for (String ds : sysList) { |
| | | SuperSpecial ss = new SuperSpecial(); |
| | | ss.setDetailSystem(new DetailSystem(ds)); |
| | | ss.setSpecial(special); |
| | | specialService.addSuperSpecial(ss); |
| | | } |
| | | out.print("yes"); |
| | | |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping(value = "/specialVideoList", method = RequestMethod.POST) |
| | | public void specialVideoList(String key, String specialId, int pageIndex, PrintWriter out) { |
| | | |
| | | System.out.println("key==" + key); |
| | | System.out.println("specialId==" + specialId); |
| | | |
| | | long count = specialService.getSpecialVideoListCount(specialId, key); |
| | | PageEntity pe = new PageEntity(); |
| | | pe.setPageIndex(pageIndex); |
| | | pe.setPageSize(Constant.pageCount); |
| | | Map<String, String> map = new HashMap<String, String>(); |
| | | map.put("key", key); |
| | | map.put("specialId", specialId); |
| | | pe.setParams(map); |
| | | pe.setTotalCount((int) count); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("code", "0"); |
| | | json.put("pageEntity", pe); |
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); |
| | | List<SpecialVideo> list = specialService.getSpecialVideoList(specialId, pe, key); |
| | | json.put("specialVideoList", gson.toJson(list)); |
| | | out.print(json); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping(value = "/deleteSpecialVideoList", method = RequestMethod.POST) |
| | | public void deleteSpecialVideoList(String ids, PrintWriter out) { |
| | | if (!StringUtil.isNullOrEmpty(ids)) { |
| | | String[] idArr = ids.split(","); |
| | | for (String id : idArr) { |
| | | specialService.deleteSpecialVideo(id); |
| | | System.out.println("iiid--" + id); |
| | | } |
| | | out.print("yes"); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | } |