| | |
| | | package com.yeshi.buwan.controller.admin.api; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.yeshi.buwan.domain.HomeType; |
| | | import com.yeshi.buwan.domain.HomeVideo; |
| | | import com.yeshi.buwan.domain.SuperHomeType; |
| | | import com.yeshi.buwan.domain.recommend.HomeRecommendSpecial; |
| | | import com.yeshi.buwan.domain.system.DetailSystem; |
| | | import com.yeshi.buwan.domain.web.DetailSystemSelect; |
| | | import com.yeshi.buwan.domain.web.HomeTypeAdmin; |
| | | import com.yeshi.buwan.service.imp.HomeTypeService; |
| | | import com.yeshi.buwan.service.inter.recommend.HomeRecommendSpecialService; |
| | | import com.yeshi.buwan.service.inter.recommend.HomeVideoService; |
| | | import com.yeshi.buwan.util.Constant; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.SystemUtil; |
| | | import com.yeshi.buwan.util.video.VideoUtil; |
| | | 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.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpSession; |
| | | import javax.validation.Valid; |
| | | import java.io.PrintWriter; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | |
| | | 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.util.SystemUtil; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.validation.BindingResult; |
| | | 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.system.DetailSystem; |
| | | import com.yeshi.buwan.domain.HomeType; |
| | | import com.yeshi.buwan.domain.HomeVideo; |
| | | import com.yeshi.buwan.domain.SuperHomeType; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import com.yeshi.buwan.domain.web.DetailSystemSelect; |
| | | import com.yeshi.buwan.domain.web.HomeTypeAdmin; |
| | | import com.yeshi.buwan.service.imp.HomeTypeService; |
| | | import com.yeshi.buwan.util.Constant; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.web.tag.PageEntity; |
| | | |
| | | @Controller |
| | | @RequestMapping("admin/new/api/home") |
| | | public class HomeTypeController { |
| | | |
| | | @Resource |
| | | private HomeTypeService homeTypeService; |
| | | |
| | | @Resource |
| | | private HomeVideoService homeVideoService; |
| | | |
| | | @Resource |
| | | private HomeRecommendSpecialService homeRecommendSpecialService; |
| | |
| | | hv.setTag(tag); |
| | | } |
| | | hv.setType(new HomeType(ht)); |
| | | hv.setVideo(new VideoInfo(vid)); |
| | | hv.setVideoId(vid); |
| | | hv.setBigPicture(false); |
| | | hv.setFromType(VideoUtil.getVideoFromType(hv.getVideoId())); |
| | | list.add(hv); |
| | | } |
| | | } |
| | | |
| | | homeTypeService.addHomeTypeVideo(list); |
| | | homeVideoService.addHomeVideo(list); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", 0); |
| | | object.put("msg", "添加成功"); |
| | |
| | | ht.setNumber(homeType.getNumber()); |
| | | ht.setOrderby(homeType.getOrderby()); |
| | | ht.setParams(homeType.getParams()); |
| | | ht.setBigPicture(homeType.isBigPicture()); |
| | | // ht.setVideoType(homeType.getVideoType()); |
| | | ht.setSpecialDataKey(homeType.getSpecialDataKey()); |
| | | homeTypeService.updateHomeType(ht); |
| | |
| | | @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", "更新成功"); |