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/service/imp/IntersectionService.java | 203 +++++++++++++++++++++++--------------------------- 1 files changed, 94 insertions(+), 109 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/service/imp/IntersectionService.java b/src/main/java/com/yeshi/buwan/service/imp/IntersectionService.java index 9a39cb2..d816ce2 100644 --- a/src/main/java/com/yeshi/buwan/service/imp/IntersectionService.java +++ b/src/main/java/com/yeshi/buwan/service/imp/IntersectionService.java @@ -16,133 +16,118 @@ @Service public class IntersectionService { - @Resource - private VideoIntersectionDao videoIntersectionDao; - @Resource - private VideoIntersectionVideoDao videoIntersectionVideoDao; + @Resource + private VideoIntersectionDao videoIntersectionDao; + @Resource + private VideoIntersectionVideoDao videoIntersectionVideoDao; - public VideoIntersectionVideoDao getVideoIntersectionVideoDao() { - return videoIntersectionVideoDao; - } - public void setVideoIntersectionVideoDao(VideoIntersectionVideoDao videoIntersectionVideoDao) { - this.videoIntersectionVideoDao = videoIntersectionVideoDao; - } + // 娣诲姞鍚堥泦 + public void addIntersection(VideoIntersection section) { + videoIntersectionDao.create(section); + } - public VideoIntersectionDao getVideoIntersectionDao() { - return videoIntersectionDao; - } + public void updateIntersection(VideoIntersection section) { + videoIntersectionDao.update(section); + } - public void setVideoIntersectionDao(VideoIntersectionDao videoIntersectionDao) { - this.videoIntersectionDao = videoIntersectionDao; - } + public void deleteIntersection(VideoIntersection section) { + videoIntersectionDao.delete(section); + } - // 娣诲姞鍚堥泦 - public void addIntersection(VideoIntersection section) { - videoIntersectionDao.create(section); - } + public void deleteIntersectionVideo(VideoIntersectionVideo section) { + videoIntersectionVideoDao.delete(section); + } - public void updateIntersection(VideoIntersection section) { - videoIntersectionDao.update(section); - } + // 娣诲姞鍚堥泦瑙嗛 + public void addIntersectionVideo(VideoIntersectionVideo sectionVideo) { + List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list( + "from VideoIntersectionVideo v where v.intersection.id=? and v.video.id=?", + new String[]{sectionVideo.getIntersection().getId(), sectionVideo.getVideo().getId()}); + if (list == null || list.size() == 0) + videoIntersectionVideoDao.create(sectionVideo); + } - public void deleteIntersection(VideoIntersection section) { - videoIntersectionDao.delete(section); - } + public List<VideoIntersection> getIntersectionList() { + return videoIntersectionDao.list("from VideoIntersection"); + } - public void deleteIntersectionVideo(VideoIntersectionVideo section) { - videoIntersectionVideoDao.delete(section); - } + public List<VideoIntersection> getIntersectionList(String key, int pageIndex) { + return videoIntersectionDao.list("from VideoIntersection vi where vi.name like ? ", + (pageIndex - 1) * Constant.pageCount, Constant.pageCount, new String[]{"%" + key + "%"}); + } - // 娣诲姞鍚堥泦瑙嗛 - public void addIntersectionVideo(VideoIntersectionVideo sectionVideo) { - List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list( - "from VideoIntersectionVideo v where v.intersection.id=? and v.video.id=?", - new String[] { sectionVideo.getIntersection().getId(), sectionVideo.getVideo().getId() }); - if (list == null || list.size() == 0) - videoIntersectionVideoDao.create(sectionVideo); - } + public long getIntersectionListCount(String key) { + return videoIntersectionDao.getCount("select count(*) from VideoIntersection vi where vi.name like ? ", + new String[]{"%" + key + "%"}); + } - public List<VideoIntersection> getIntersectionList() { - return videoIntersectionDao.list("from VideoIntersection"); - } + public List<VideoIntersection> getIntersectionListByPage(int page) { + return videoIntersectionDao.list("from VideoIntersection", Constant.pageCount * (page - 1), Constant.pageCount, + new String[]{}); + } - public List<VideoIntersection> getIntersectionList(String key, int pageIndex) { - return videoIntersectionDao.list("from VideoIntersection vi where vi.name like ? ", - (pageIndex - 1) * Constant.pageCount, Constant.pageCount, new String[] { "%" + key + "%" }); - } + public long getIntersectionListPage() { + return videoIntersectionDao.getCount("select count(*) from VideoIntersection"); + } - public long getIntersectionListCount(String key) { - return videoIntersectionDao.getCount("select count(*) from VideoIntersection vi where vi.name like ? ", - new String[] { "%" + key + "%" }); - } + public VideoIntersection getIntersectionById(String id) { + return videoIntersectionDao.find(VideoIntersection.class, id); + } - public List<VideoIntersection> getIntersectionListByPage(int page) { - return videoIntersectionDao.list("from VideoIntersection", Constant.pageCount * (page - 1), Constant.pageCount, - new String[] {}); - } + public List<VideoInfo> getIntersectionVideoList(String intersectionId) { + List<VideoInfo> videoList = new ArrayList<VideoInfo>(); + List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list( + "from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=?", + new String[]{intersectionId}); + for (VideoIntersectionVideo vi : list) + if (vi.getVideo() != null) + videoList.add(vi.getVideo()); + return videoList; + } - public long getIntersectionListPage() { - return videoIntersectionDao.getCount("select count(*) from VideoIntersection"); - } + public VideoIntersectionVideo getIntersectionVideoById(String id) { + return videoIntersectionVideoDao.find(VideoIntersectionVideo.class, id); + } - public VideoIntersection getIntersectionById(String id) { - return videoIntersectionDao.find(VideoIntersection.class, id); - } + public List<VideoInfo> getIntersectionVideoList(String intersectionId, String key, int pageIndex) { + List<VideoInfo> videoList = new ArrayList<VideoInfo>(); + List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list( + "from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=? and v.video.name like ?", + (pageIndex - 1) * Constant.pageCount, Constant.pageCount, + new String[]{intersectionId, "%" + key + "%"}); + for (VideoIntersectionVideo vi : list) + if (vi.getVideo() != null) + videoList.add(vi.getVideo()); + return videoList; + } - public List<VideoInfo> getIntersectionVideoList(String intersectionId) { - List<VideoInfo> videoList = new ArrayList<VideoInfo>(); - List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list( - "from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=?", - new String[] { intersectionId }); - for (VideoIntersectionVideo vi : list) - if (vi.getVideo() != null) - videoList.add(vi.getVideo()); - return videoList; - } + public long getIntersectionVideoListCount(String intersectionId, String key) { + return videoIntersectionVideoDao.getCount( + "select count(*) from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=? and v.video.name like ?", + new String[]{intersectionId, "%" + key + "%"}); + } - public VideoIntersectionVideo getIntersectionVideoById(String id) { - return videoIntersectionVideoDao.find(VideoIntersectionVideo.class, id); - } + public List<VideoIntersectionVideo> getIntersectionVideoListByInersection(String intersectionId) { + List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list( + "from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=?", + new String[]{intersectionId}); + return list; + } - public List<VideoInfo> getIntersectionVideoList(String intersectionId, String key, int pageIndex) { - List<VideoInfo> videoList = new ArrayList<VideoInfo>(); - List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list( - "from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=? and v.video.name like ?", - (pageIndex - 1) * Constant.pageCount, Constant.pageCount, - new String[] { intersectionId, "%" + key + "%" }); - for (VideoIntersectionVideo vi : list) - if (vi.getVideo() != null) - videoList.add(vi.getVideo()); - return videoList; - } + public List<VideoIntersectionVideo> getIntersectionVideoListByInersection(String intersectionId, String key, + int pageIndex) { + List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list( + "from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=? and v.video.name like ?", + (pageIndex - 1) * Constant.pageCount, Constant.pageCount, + new String[]{intersectionId, "%" + key + "%"}); + return list; + } - public long getIntersectionVideoListCount(String intersectionId, String key) { - return videoIntersectionVideoDao.getCount( - "select count(*) from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=? and v.video.name like ?", - new String[] { intersectionId, "%" + key + "%" }); - } - - public List<VideoIntersectionVideo> getIntersectionVideoListByInersection(String intersectionId) { - List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list( - "from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=?", - new String[] { intersectionId }); - return list; - } - - public List<VideoIntersectionVideo> getIntersectionVideoListByInersection(String intersectionId, String key, - int pageIndex) { - List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list( - "from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=? and v.video.name like ?", - (pageIndex - 1) * Constant.pageCount, Constant.pageCount, - new String[] { intersectionId, "%" + key + "%" }); - return list; - } - - public long getIntersectionVideoListByInersectionCount(String intersectionId, String key) { - return videoIntersectionVideoDao.getCount( - "select count(*) from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=? and v.video.name like ?", - new String[] { intersectionId, "%" + key + "%" }); - } + public long getIntersectionVideoListByInersectionCount(String intersectionId, String key) { + return videoIntersectionVideoDao.getCount( + "select count(*) from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=? and v.video.name like ?", + new String[]{intersectionId, "%" + key + "%"}); + } } -- Gitblit v1.8.0