| | |
| | | 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 net.sf.json.JSONObject; |
| | | |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | |
| | | 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.HotStar; |
| | | import com.yeshi.buwan.domain.SuperHotStar; |
| | | import com.yeshi.buwan.domain.web.HotStarAdmin; |
| | |
| | | @Controller |
| | | @RequestMapping("admin/new/api/hotstar") |
| | | public class HotStarController { |
| | | @Resource |
| | | private StarService starService; |
| | | @Resource |
| | | private SystemService systemService; |
| | | @Resource |
| | | private StarService starService; |
| | | @Resource |
| | | private SystemService systemService; |
| | | |
| | | @RequestMapping(value = "/hotStarList", method = RequestMethod.POST) |
| | | public void hotStarList(int pageIndex, String key, int detailsystem, |
| | | PrintWriter out) { |
| | | if (pageIndex <= 0) { |
| | | pageIndex = 1; |
| | | } |
| | | List<HotStarAdmin> list = starService.getHotStarAdmin(key, |
| | | detailsystem, pageIndex); |
| | | long count = starService.getHotStarAdminCount(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); |
| | | @RequestMapping(value = "/hotStarList", method = RequestMethod.POST) |
| | | public void hotStarList(int pageIndex, String key, int detailsystem, HttpSession session, |
| | | PrintWriter out) { |
| | | if (pageIndex <= 0) { |
| | | pageIndex = 1; |
| | | } |
| | | List<HotStarAdmin> list = starService.getHotStarAdmin(key, SystemUtil.getAdminSelectedSystemId(session), |
| | | detailsystem, pageIndex); |
| | | long count = starService.getHotStarAdminCount(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); |
| | | |
| | | JSONObject json = new JSONObject(); |
| | | json.put("code", "0"); |
| | | json.put("pageEntity", pe); |
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation() |
| | | .create(); |
| | | json.put("hotStarAdminList", gson.toJson(list)); |
| | | // List<DetailSystem> detailSystemList = .getDetailSystemList(); |
| | | // json.put("detailSystemList", gson.toJson(detailSystemList)); |
| | | out.print(json); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("code", "0"); |
| | | json.put("pageEntity", pe); |
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation() |
| | | .create(); |
| | | json.put("hotStarAdminList", gson.toJson(list)); |
| | | // List<DetailSystem> detailSystemList = .getDetailSystemList(); |
| | | // json.put("detailSystemList", gson.toJson(detailSystemList)); |
| | | out.print(json); |
| | | |
| | | return; |
| | | } |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping("/getHotStar") |
| | | public void getHotStar(String id, PrintWriter out) { |
| | | HotStar hotStar = starService.getStar(id); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("code", "0"); |
| | | Gson gson = new Gson(); |
| | | json.put("hotStar", gson.toJson(hotStar)); |
| | | System.out.println(json.toString()); |
| | | out.print(json); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping("/updateHotStar") |
| | | public void updateHotStar(String id, String beizhu, String country, |
| | | String job, String name, String orderby, String works, |
| | | String portrait, PrintWriter out) { |
| | | HotStar hotStar = starService.getStar(id); |
| | | if(hotStar == null){ |
| | | out.print("no"); |
| | | return; |
| | | } |
| | | hotStar.setBeizhu(beizhu); |
| | | hotStar.setCreatetime(System.currentTimeMillis() + ""); |
| | | hotStar.setCountry(country); |
| | | hotStar.setJob(job); |
| | | hotStar.setName(name); |
| | | orderby = StringUtil.isNullOrEmpty(orderby) ? "0" : orderby; |
| | | hotStar.setOrderby(Integer.parseInt(orderby)); |
| | | hotStar.setPortrait(portrait); |
| | | hotStar.setWorks(works); |
| | | starService.updateStar(hotStar); |
| | | out.print("yes"); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping("/addHotStar") |
| | | public void addHotStar(String detailSystems,String beizhu,String country,String job,String name,String orderby,String portrait,String works,PrintWriter out) { |
| | | 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); |
| | | } |
| | | HotStar hotStar = new HotStar(); |
| | | hotStar.setBeizhu(beizhu); |
| | | hotStar.setCreatetime(System.currentTimeMillis() + ""); |
| | | hotStar.setCountry(country); |
| | | hotStar.setJob(job); |
| | | hotStar.setName(name); |
| | | orderby = StringUtil.isNullOrEmpty(orderby) ? "0" : orderby; |
| | | hotStar.setOrderby(Integer.parseInt(orderby)); |
| | | hotStar.setPortrait(portrait); |
| | | hotStar.setWorks(works); |
| | | hotStar = starService.addStar(hotStar); |
| | | for (String ds : sysList) { |
| | | SuperHotStar ss = new SuperHotStar(); |
| | | ss.setDetailSystem(new DetailSystem(ds)); |
| | | ss.setHotStar(hotStar); |
| | | ss.setCreatetime(System.currentTimeMillis() + ""); |
| | | starService.addSuperHotStar(ss); |
| | | } |
| | | out.print("yes"); |
| | | return ; |
| | | } |
| | | |
| | | @RequestMapping(value="/deleteHotStarList",method=RequestMethod.POST) |
| | | public void deleteHotStarList(String ids,PrintWriter out) { |
| | | String[] idArr = ids.split(","); |
| | | for (String st : idArr) { |
| | | starService.deleteStar(new HotStar(st)); |
| | | System.out.println(st); |
| | | } |
| | | out.print("yes"); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping("setStarDetailSystem") |
| | | public void setStarDetailSystem(String type,String detailSystem,String id, PrintWriter out) { |
| | | System.out.println("type-"+type); |
| | | System.out.println("detailSystem-"+detailSystem); |
| | | System.out.println("id-"+id); |
| | | if ("add".equalsIgnoreCase(type)) { |
| | | if (!StringUtil.isNullOrEmpty(detailSystem) && !StringUtil.isNullOrEmpty(id)) { |
| | | SuperHotStar sz = new SuperHotStar(); |
| | | sz.setCreatetime(System.currentTimeMillis() + ""); |
| | | sz.setDetailSystem(new DetailSystem(detailSystem)); |
| | | sz.setHotStar(new HotStar(id)); |
| | | starService.addSuperHotStar(sz); |
| | | } |
| | | out.print("yes"); |
| | | } else if ("delete".equalsIgnoreCase(type)) {// 获取下级分类 |
| | | if (!StringUtil.isNullOrEmpty(detailSystem) && !StringUtil.isNullOrEmpty(id)) { |
| | | starService.deleteHotStarAdmin(id, detailSystem); |
| | | } |
| | | out.print("yes"); |
| | | } |
| | | } |
| | | @RequestMapping("/getHotStar") |
| | | public void getHotStar(String id, PrintWriter out) { |
| | | HotStar hotStar = starService.getStar(id); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("code", "0"); |
| | | Gson gson = new Gson(); |
| | | json.put("hotStar", gson.toJson(hotStar)); |
| | | System.out.println(json.toString()); |
| | | out.print(json); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping("/updateHotStar") |
| | | public void updateHotStar(String id, String beizhu, String country, |
| | | String job, String name, String orderby, String works, |
| | | String portrait, PrintWriter out) { |
| | | HotStar hotStar = starService.getStar(id); |
| | | if (hotStar == null) { |
| | | out.print("no"); |
| | | return; |
| | | } |
| | | hotStar.setBeizhu(beizhu); |
| | | hotStar.setCreatetime(System.currentTimeMillis() + ""); |
| | | hotStar.setCountry(country); |
| | | hotStar.setJob(job); |
| | | hotStar.setName(name); |
| | | orderby = StringUtil.isNullOrEmpty(orderby) ? "0" : orderby; |
| | | hotStar.setOrderby(Integer.parseInt(orderby)); |
| | | hotStar.setPortrait(portrait); |
| | | hotStar.setWorks(works); |
| | | starService.updateStar(hotStar); |
| | | out.print("yes"); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping("/addHotStar") |
| | | public void addHotStar(String detailSystems, String beizhu, String country, String job, String name, String orderby, String portrait, String works, HttpSession session, PrintWriter out) { |
| | | List<String> sysList = new ArrayList<>(); |
| | | if (!StringUtil.isNullOrEmpty(detailSystems)) { |
| | | if (detailSystems.contains(",")) { |
| | | for (String st : detailSystems.split(",")) |
| | | sysList.add(st); |
| | | } else |
| | | sysList.add(detailSystems); |
| | | } |
| | | HotStar hotStar = new HotStar(); |
| | | hotStar.setBeizhu(beizhu); |
| | | hotStar.setCreatetime(System.currentTimeMillis() + ""); |
| | | hotStar.setCountry(country); |
| | | hotStar.setJob(job); |
| | | hotStar.setName(name); |
| | | orderby = StringUtil.isNullOrEmpty(orderby) ? "0" : orderby; |
| | | hotStar.setOrderby(Integer.parseInt(orderby)); |
| | | hotStar.setPortrait(portrait); |
| | | hotStar.setWorks(works); |
| | | hotStar.setSystem(SystemUtil.getAdminSelectedSystem(session)); |
| | | hotStar = starService.addStar(hotStar); |
| | | for (String ds : sysList) { |
| | | SuperHotStar ss = new SuperHotStar(); |
| | | ss.setDetailSystem(new DetailSystem(ds)); |
| | | ss.setHotStar(hotStar); |
| | | ss.setCreatetime(System.currentTimeMillis() + ""); |
| | | starService.addSuperHotStar(ss); |
| | | } |
| | | out.print("yes"); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping(value = "/deleteHotStarList", method = RequestMethod.POST) |
| | | public void deleteHotStarList(String ids, PrintWriter out) { |
| | | String[] idArr = ids.split(","); |
| | | for (String st : idArr) { |
| | | starService.deleteStar(new HotStar(st)); |
| | | System.out.println(st); |
| | | } |
| | | out.print("yes"); |
| | | return; |
| | | } |
| | | |
| | | @RequestMapping("setStarDetailSystem") |
| | | public void setStarDetailSystem(String type, String detailSystem, String id, PrintWriter out) { |
| | | System.out.println("type-" + type); |
| | | System.out.println("detailSystem-" + detailSystem); |
| | | System.out.println("id-" + id); |
| | | if ("add".equalsIgnoreCase(type)) { |
| | | if (!StringUtil.isNullOrEmpty(detailSystem) && !StringUtil.isNullOrEmpty(id)) { |
| | | SuperHotStar sz = new SuperHotStar(); |
| | | sz.setCreatetime(System.currentTimeMillis() + ""); |
| | | sz.setDetailSystem(new DetailSystem(detailSystem)); |
| | | sz.setHotStar(new HotStar(id)); |
| | | starService.addSuperHotStar(sz); |
| | | } |
| | | out.print("yes"); |
| | | } else if ("delete".equalsIgnoreCase(type)) {// 获取下级分类 |
| | | if (!StringUtil.isNullOrEmpty(detailSystem) && !StringUtil.isNullOrEmpty(id)) { |
| | | starService.deleteHotStarAdmin(id, detailSystem); |
| | | } |
| | | out.print("yes"); |
| | | } |
| | | } |
| | | } |