| | |
| | | import java.io.PrintWriter; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpSession; |
| | | import javax.validation.Valid; |
| | | |
| | | import com.yeshi.buwan.domain.recommend.HomeRecommendSpecial; |
| | | import com.yeshi.buwan.service.inter.recommend.HomeRecommendSpecialService; |
| | | import com.yeshi.buwan.service.inter.recommend.HomeVideoService; |
| | | import com.yeshi.buwan.util.SystemUtil; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | |
| | | @Resource |
| | | private HomeTypeService homeTypeService; |
| | | |
| | | @Resource |
| | | private HomeVideoService homeVideoService; |
| | | |
| | | @Resource |
| | | private HomeRecommendSpecialService homeRecommendSpecialService; |
| | | |
| | | @RequestMapping(value = "/gethometypelist", method = RequestMethod.POST) |
| | | public void getHomeTypeList(HttpSession session, PrintWriter out) { |
| | | List<HomeType> list = homeTypeService.getHomeTypeList(SystemUtil.getAdminSelectedSystemId(session)); |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/gethometypelistadmin", method = RequestMethod.POST) |
| | | public void getHomeTypeListAdmin(int page, int detailsystem, String key, HttpSession session, PrintWriter out) { |
| | | public void getHomeTypeListAdmin(int page, int detailsystem, String special, String key, HttpSession session, PrintWriter out) { |
| | | key = StringUtil.isNullOrEmpty(key) ? "" : key; |
| | | String dataKey = null; |
| | | if (special != null && !special.equalsIgnoreCase("0")) { |
| | | HomeRecommendSpecial bean = homeRecommendSpecialService.getSpecial(special); |
| | | if (bean != null) { |
| | | dataKey = bean.getDataKey(); |
| | | } |
| | | } |
| | | |
| | | List<HomeTypeAdmin> list = homeTypeService.getHomeTypeAdmin(key, SystemUtil.getAdminSelectedSystemId(session), detailsystem, page); |
| | | long count = homeTypeService.getHomeTypeAdminCount(key, SystemUtil.getAdminSelectedSystemId(session), detailsystem); |
| | | |
| | | List<HomeTypeAdmin> list = homeTypeService.getHomeTypeAdmin(key, SystemUtil.getAdminSelectedSystemId(session), dataKey, detailsystem, page); |
| | | |
| | | //拉取标签 |
| | | |
| | | |
| | | Map<String, HomeRecommendSpecial> specialMap = new HashMap<>(); |
| | | |
| | | |
| | | long count = homeTypeService.getHomeTypeAdminCount(key, SystemUtil.getAdminSelectedSystemId(session), detailsystem, dataKey); |
| | | PageEntity pe = new PageEntity(); |
| | | pe.setPageIndex(page); |
| | | pe.setPageSize(Constant.pageCount); |
| | |
| | | JSONArray array = new JSONArray(); |
| | | Gson gson = new GsonBuilder().create(); |
| | | for (HomeTypeAdmin ht : list) { |
| | | String specialDataKey = ht.getHomeType().getHomeType().getSpecialDataKey(); |
| | | if (specialMap.get(specialDataKey) == null) { |
| | | specialMap.put(specialDataKey, homeRecommendSpecialService.getSpecialByDataKey(specialDataKey)); |
| | | } |
| | | |
| | | ht.setSpecial(specialMap.get(specialDataKey)); |
| | | |
| | | JSONObject root = new JSONObject(); |
| | | ht.getHomeType().getHomeType().getSystem().setAdmin(null); |
| | | root.put("homeType", gson.toJson(ht.getHomeType().getHomeType())); |
| | |
| | | darray.add(gson.toJson(dss)); |
| | | } |
| | | root.put("detailSystemList", darray); |
| | | root.put("special", specialMap.get(specialDataKey)); |
| | | array.add(root); |
| | | } |
| | | |
| | |
| | | |
| | | @RequestMapping(value = "/addhomevideos", method = RequestMethod.POST) |
| | | public void addHomeVideos(String videoids, String tag, String picture, String types, PrintWriter out) { |
| | | List<HomeVideo> list = new ArrayList<HomeVideo>(); |
| | | List<HomeVideo> list = new ArrayList<>(); |
| | | |
| | | String[] videos = videoids.split(","); |
| | | String[] homeTypes = types.split(","); |
| | |
| | | hv.setTag(tag); |
| | | } |
| | | hv.setType(new HomeType(ht)); |
| | | hv.setVideo(new VideoInfo(vid)); |
| | | hv.setVideoId(vid); |
| | | hv.setBigPicture(false); |
| | | list.add(hv); |
| | | } |
| | | } |
| | | |
| | | homeTypeService.addHomeTypeVideo(list); |
| | | homeVideoService.addHomeVideo(list); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", 0); |
| | | object.put("msg", "添加成功"); |
| | |
| | | ht.setActivity(homeType.getActivity()); |
| | | ht.setColumns(homeType.getColumns()); |
| | | ht.setHasMore(homeType.isHasMore()); |
| | | ht.setMoreTag(homeType.getMoreTag()); |
| | | ht.setRefreshPosition(homeType.getRefreshPosition()); |
| | | ht.setIcon(homeType.getIcon()); |
| | | ht.setIosControl(homeType.getIosControl()); |
| | | ht.setName(homeType.getName()); |
| | | ht.setNumber(homeType.getNumber()); |
| | | ht.setOrderby(homeType.getOrderby()); |
| | | ht.setParams(homeType.getParams()); |
| | | ht.setVideoType(homeType.getVideoType()); |
| | | ht.setBigPicture(homeType.isBigPicture()); |
| | | // ht.setVideoType(homeType.getVideoType()); |
| | | ht.setSpecialDataKey(homeType.getSpecialDataKey()); |
| | | homeTypeService.updateHomeType(ht); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", 0); |
| | |
| | | @RequestMapping(value = "/gethomevideolist", method = RequestMethod.POST) |
| | | public void getHomeVideoList(long id, int page, String key, PrintWriter out) { |
| | | key = StringUtil.isNullOrEmpty(key) ? "" : key; |
| | | List<HomeVideo> list = homeTypeService.getHomeVideoList(id + "", key, page); |
| | | List<HomeVideo> list = homeVideoService.getHomeVideoList(id + "", key, page); |
| | | for (HomeVideo homeVideo : list) { |
| | | homeVideo.setType(null); |
| | | homeVideo.setAdmin(null); |
| | | } |
| | | long count = homeTypeService.getHomeVideoListCount(id + "", key); |
| | | long count = homeVideoService.getHomeVideoListCount(id + "", key); |
| | | PageEntity pe = new PageEntity(); |
| | | pe.setPageIndex(page); |
| | | pe.setPageSize(Constant.pageCount); |
| | |
| | | public void deleteHomeVideo(String ids, PrintWriter out) { |
| | | String[] idStrs = ids.split(","); |
| | | for (String id : idStrs) { |
| | | homeTypeService.deleteHomeVideo(new HomeVideo(id)); |
| | | homeVideoService.deleteHomeVideo(new HomeVideo(id)); |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", 0); |
| | |
| | | object.put("msg", "该视频不存在"); |
| | | out.print(object); |
| | | } else { |
| | | hv.setAdmin(null); |
| | | hv.setType(null); |
| | | hv.getVideo().setAdmin(null); |
| | | Gson gson = new GsonBuilder().create(); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", 0); |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/updatehomevideo", method = RequestMethod.POST) |
| | | public void updateHomeVideo(long id, String tag, String picture, String orderby, PrintWriter out) { |
| | | public void updateHomeVideo(long id, String tag, String picture, String orderby,Boolean bigPicture, PrintWriter out) { |
| | | HomeVideo hv = homeTypeService.getHomeVideoById(id + ""); |
| | | if (hv == null) { |
| | | JSONObject object = new JSONObject(); |
| | |
| | | ob = Integer.parseInt(orderby); |
| | | } |
| | | hv.setOrderby(ob); |
| | | homeTypeService.updateHomeVideo(hv); |
| | | hv.setBigPicture(bigPicture); |
| | | homeVideoService.updateHomeVideo(hv); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", 0); |
| | | object.put("msg", "更新成功"); |