From 7c509f2bf285e689acf05d723cd728b2ece82f2e Mon Sep 17 00:00:00 2001 From: Stan <1576302867@qq.com> Date: Sat, 14 Sep 2024 00:00:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=8A=A8=E6=BC=AB=E7=BD=91?= =?UTF-8?q?=E7=AB=99=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/web/anime/EpisodeController.java | 17 ++------- .../web/anime/RecommendController.java | 16 ++------- .../manager/web/anime/TypeController.java | 14 ++------ .../manager/web/system/RoleController.java | 20 +++-------- .../web/system/UserConnectionController.java | 33 ++++++++--------- .../anime/anime/dto/vo/AnimeDetailVO.java | 6 ++++ .../anime/service/impl/AnimeServiceImpl.java | 25 +++++++++++++ .../anime/episode/dto/vo/EpisodeVO.java | 2 ++ .../episode/repository/EpisodeRepository.java | 3 ++ .../anime/playlist/dto/vo/PlayListVO.java | 4 +++ .../repository/PlayListRepository.java | 3 ++ .../service/impl/RecommendServiceImpl.java | 1 - .../qing/domain/anime/type/Type.java | 2 +- .../anime/type/dto/updater/TypeUpdater.java | 36 +++---------------- .../role/dto/request/RoleUpdateRequest.java | 18 +++------- .../auth/role/dto/updater/RoleUpdater.java | 12 ++----- .../domain/auth/role/mapper/RoleMapper.java | 35 +++++++----------- .../repository/EpisodeRepositoryImpl.java | 6 ++++ .../repository/PlayListRepositoryImpl.java | 6 ++++ .../repository/jpa/EpisodeJpaRepository.java | 4 +++ .../repository/jpa/PlayListJpaRepository.java | 4 +++ 21 files changed, 112 insertions(+), 155 deletions(-) diff --git a/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/anime/EpisodeController.java b/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/anime/EpisodeController.java index e210959f0..c4aa5eb6e 100644 --- a/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/anime/EpisodeController.java +++ b/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/anime/EpisodeController.java @@ -3,7 +3,6 @@ import cn.chenyunlong.common.constants.CodeEnum; import cn.chenyunlong.common.model.JsonResult; import cn.chenyunlong.common.model.PageRequestWrapper; -import cn.chenyunlong.common.model.PageResult; import cn.chenyunlong.qing.domain.anime.episode.dto.creator.EpisodeCreator; import cn.chenyunlong.qing.domain.anime.episode.dto.query.EpisodeQuery; import cn.chenyunlong.qing.domain.anime.episode.dto.request.EpisodeCreateRequest; @@ -16,7 +15,6 @@ import cn.chenyunlong.qing.domain.anime.episode.service.IEpisodeService; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; @@ -96,11 +94,8 @@ public JsonResult findById( return JsonResult.success(response); } - /** - * findByPage request - */ @PostMapping("page") - public JsonResult> page( + public JsonResult> page( @RequestBody PageRequestWrapper request) { PageRequestWrapper wrapper = new PageRequestWrapper<>(); @@ -109,14 +104,6 @@ public JsonResult> page( wrapper.setPageSize(request.getPageSize()); wrapper.setPage(request.getPage()); Page page = episodeService.findByPage(wrapper); - return JsonResult.success( - PageResult.of( - page.getContent().stream() - .map(EpisodeMapper.INSTANCE::vo2CustomResponse) - .collect(Collectors.toList()), - page.getTotalElements(), - page.getSize(), - page.getNumber()) - ); + return JsonResult.success(page.map(EpisodeMapper.INSTANCE::vo2CustomResponse)); } } diff --git a/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/anime/RecommendController.java b/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/anime/RecommendController.java index 3d130ec39..954dcab65 100644 --- a/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/anime/RecommendController.java +++ b/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/anime/RecommendController.java @@ -3,7 +3,6 @@ import cn.chenyunlong.common.constants.CodeEnum; import cn.chenyunlong.common.model.JsonResult; import cn.chenyunlong.common.model.PageRequestWrapper; -import cn.chenyunlong.common.model.PageResult; import cn.chenyunlong.qing.domain.anime.anime.service.IAnimeService; import cn.chenyunlong.qing.domain.anime.recommend.dto.creator.RecommendCreator; import cn.chenyunlong.qing.domain.anime.recommend.dto.query.RecommendQuery; @@ -19,8 +18,6 @@ import cn.chenyunlong.qing.security.util.SpringSecurityUtils; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; -import java.util.List; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; @@ -87,7 +84,7 @@ public JsonResult findById( } @PostMapping("page") - public JsonResult> page( + public JsonResult> page( @RequestBody PageRequestWrapper request) { PageRequestWrapper wrapper = new PageRequestWrapper<>(); @@ -96,15 +93,6 @@ public JsonResult> page( wrapper.setPageSize(request.getPageSize()); wrapper.setPage(request.getPage()); Page page = recommendService.findByPage(wrapper); - List recommendVOList = page.getContent(); - return JsonResult.success( - PageResult.of( - recommendVOList.stream() - .map(RecommendMapper.INSTANCE::vo2CustomResponse) - .collect(Collectors.toList()), - page.getTotalElements(), - page.getSize(), - page.getNumber()) - ); + return JsonResult.success(page.map(RecommendMapper.INSTANCE::vo2CustomResponse)); } } diff --git a/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/anime/TypeController.java b/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/anime/TypeController.java index a35bd3572..e265e5e7a 100644 --- a/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/anime/TypeController.java +++ b/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/anime/TypeController.java @@ -3,7 +3,6 @@ import cn.chenyunlong.common.constants.CodeEnum; import cn.chenyunlong.common.model.JsonResult; import cn.chenyunlong.common.model.PageRequestWrapper; -import cn.chenyunlong.common.model.PageResult; import cn.chenyunlong.qing.domain.anime.type.dto.creator.TypeCreator; import cn.chenyunlong.qing.domain.anime.type.dto.query.TypeQuery; import cn.chenyunlong.qing.domain.anime.type.dto.request.TypeCreateRequest; @@ -15,7 +14,6 @@ import cn.chenyunlong.qing.domain.anime.type.mapper.TypeMapper; import cn.chenyunlong.qing.domain.anime.type.service.ITypeService; import io.swagger.v3.oas.annotations.tags.Tag; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; @@ -96,7 +94,7 @@ public JsonResult findById( * findByPage request */ @PostMapping("page") - public JsonResult> page( + public JsonResult> page( @RequestBody PageRequestWrapper request) { PageRequestWrapper wrapper = new PageRequestWrapper<>(); @@ -105,14 +103,6 @@ public JsonResult> page( wrapper.setPageSize(request.getPageSize()); wrapper.setPage(request.getPage()); Page page = typeService.findByPage(wrapper); - return JsonResult.success( - PageResult.of( - page.getContent().stream() - .map(TypeMapper.INSTANCE::vo2CustomResponse) - .collect(Collectors.toList()), - page.getTotalElements(), - page.getSize(), - page.getNumber()) - ); + return JsonResult.success(page.map(TypeMapper.INSTANCE::vo2CustomResponse)); } } diff --git a/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/system/RoleController.java b/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/system/RoleController.java index 26f572c10..c08e7fc97 100644 --- a/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/system/RoleController.java +++ b/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/system/RoleController.java @@ -3,7 +3,6 @@ import cn.chenyunlong.common.constants.CodeEnum; import cn.chenyunlong.common.model.JsonResult; import cn.chenyunlong.common.model.PageRequestWrapper; -import cn.chenyunlong.common.model.PageResult; import cn.chenyunlong.qing.domain.auth.role.dto.creator.RoleCreator; import cn.chenyunlong.qing.domain.auth.role.dto.query.RoleQuery; import cn.chenyunlong.qing.domain.auth.role.dto.request.RoleCreateRequest; @@ -15,7 +14,6 @@ import cn.chenyunlong.qing.domain.auth.role.mapper.RoleMapper; import cn.chenyunlong.qing.domain.auth.role.service.IRoleService; import io.swagger.v3.oas.annotations.tags.Tag; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; @@ -63,7 +61,7 @@ public JsonResult updateRole( */ @PostMapping("valid/{id}") public JsonResult validRole( - @PathVariable + @PathVariable("id") Long id) { roleService.validRole(id); return JsonResult.success(CodeEnum.Success.getName()); @@ -74,7 +72,7 @@ public JsonResult validRole( */ @PostMapping("invalid/{id}") public JsonResult invalidRole( - @PathVariable + @PathVariable("id") Long id) { roleService.invalidRole(id); return JsonResult.success(CodeEnum.Success.getName()); @@ -85,7 +83,7 @@ public JsonResult invalidRole( */ @GetMapping("findById/{id}") public JsonResult findById( - @PathVariable + @PathVariable("id") Long id) { RoleVO vo = roleService.findById(id); RoleResponse response = RoleMapper.INSTANCE.vo2CustomResponse(vo); @@ -96,7 +94,7 @@ public JsonResult findById( * findByPage request */ @PostMapping("page") - public JsonResult> page( + public JsonResult> page( @RequestBody PageRequestWrapper request) { PageRequestWrapper wrapper = new PageRequestWrapper<>(); @@ -105,14 +103,6 @@ public JsonResult> page( wrapper.setPageSize(request.getPageSize()); wrapper.setPage(request.getPage()); Page page = roleService.findByPage(wrapper); - return JsonResult.success( - PageResult.of( - page.getContent().stream() - .map(RoleMapper.INSTANCE::vo2CustomResponse) - .collect(Collectors.toList()), - page.getTotalElements(), - page.getSize(), - page.getNumber()) - ); + return JsonResult.success(page.map(RoleMapper.INSTANCE::vo2CustomResponse)); } } diff --git a/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/system/UserConnectionController.java b/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/system/UserConnectionController.java index adab05b81..ba4ddc707 100644 --- a/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/system/UserConnectionController.java +++ b/qing-application/qing-application-manager/src/main/java/cn/chenyunlong/qing/application/manager/web/system/UserConnectionController.java @@ -3,7 +3,6 @@ import cn.chenyunlong.common.constants.CodeEnum; import cn.chenyunlong.common.model.JsonResult; import cn.chenyunlong.common.model.PageRequestWrapper; -import cn.chenyunlong.common.model.PageResult; import cn.chenyunlong.qing.domain.auth.connection.dto.creator.UserConnectionCreator; import cn.chenyunlong.qing.domain.auth.connection.dto.query.UserConnectionQuery; import cn.chenyunlong.qing.domain.auth.connection.dto.request.UserConnectionCreateRequest; @@ -15,7 +14,6 @@ import cn.chenyunlong.qing.domain.auth.connection.mapper.UserConnectionMapper; import cn.chenyunlong.qing.domain.auth.connection.service.IUserConnectionService; import io.swagger.v3.oas.annotations.tags.Tag; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; @@ -39,7 +37,9 @@ public class UserConnectionController { * createRequest */ @PostMapping - public JsonResult createUserConnection(@RequestBody UserConnectionCreateRequest request) { + public JsonResult createUserConnection( + @RequestBody + UserConnectionCreateRequest request) { UserConnectionCreator creator = UserConnectionMapper.INSTANCE.request2Dto(request); return JsonResult.success(userConnectionService.createUserConnection(creator)); } @@ -60,7 +60,9 @@ public JsonResult updateUserConnection( * valid */ @PostMapping("valid/{id}") - public JsonResult validUserConnection(@PathVariable Long id) { + public JsonResult validUserConnection( + @PathVariable + Long id) { userConnectionService.validUserConnection(id); return JsonResult.success(CodeEnum.Success.getName()); } @@ -69,7 +71,9 @@ public JsonResult validUserConnection(@PathVariable Long id) { * invalid */ @PostMapping("invalid/{id}") - public JsonResult invalidUserConnection(@PathVariable Long id) { + public JsonResult invalidUserConnection( + @PathVariable + Long id) { userConnectionService.invalidUserConnection(id); return JsonResult.success(CodeEnum.Success.getName()); } @@ -78,17 +82,16 @@ public JsonResult invalidUserConnection(@PathVariable Long id) { * findById */ @GetMapping("findById/{id}") - public JsonResult findById(@PathVariable Long id) { + public JsonResult findById( + @PathVariable + Long id) { UserConnectionVO vo = userConnectionService.findById(id); UserConnectionResponse response = UserConnectionMapper.INSTANCE.vo2CustomResponse(vo); return JsonResult.success(response); } - /** - * findByPage request - */ @PostMapping("page") - public JsonResult> page( + public JsonResult> page( @RequestBody PageRequestWrapper request) { PageRequestWrapper wrapper = new PageRequestWrapper<>(); @@ -97,14 +100,6 @@ public JsonResult> page( wrapper.setPageSize(request.getPageSize()); wrapper.setPage(request.getPage()); Page page = userConnectionService.findByPage(wrapper); - return JsonResult.success( - PageResult.of( - page.getContent().stream() - .map(UserConnectionMapper.INSTANCE::vo2CustomResponse) - .collect(Collectors.toList()), - page.getTotalElements(), - page.getSize(), - page.getNumber()) - ); + return JsonResult.success(page.map(UserConnectionMapper.INSTANCE::vo2CustomResponse)); } } diff --git a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/anime/dto/vo/AnimeDetailVO.java b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/anime/dto/vo/AnimeDetailVO.java index 7362117ad..a1b7dd4fb 100644 --- a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/anime/dto/vo/AnimeDetailVO.java +++ b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/anime/dto/vo/AnimeDetailVO.java @@ -2,6 +2,8 @@ import cn.chenyunlong.common.model.AbstractBaseJpaVo; import cn.chenyunlong.qing.domain.anime.anime.PlayStatus; +import cn.chenyunlong.qing.domain.anime.episode.dto.vo.EpisodeVO; +import cn.chenyunlong.qing.domain.anime.playlist.dto.vo.PlayListVO; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import java.time.LocalDate; @@ -105,4 +107,8 @@ public class AnimeDetailVO extends AbstractBaseJpaVo { private Integer orderNo; private List tagVOList; + + private List episodeList; + + private List playLists; } diff --git a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/anime/service/impl/AnimeServiceImpl.java b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/anime/service/impl/AnimeServiceImpl.java index 47ca15b68..389804285 100644 --- a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/anime/service/impl/AnimeServiceImpl.java +++ b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/anime/service/impl/AnimeServiceImpl.java @@ -24,8 +24,17 @@ import cn.chenyunlong.qing.domain.anime.attachement.repository.AttachmentRepository; import cn.chenyunlong.qing.domain.anime.district.District; import cn.chenyunlong.qing.domain.anime.district.repository.DistrictRepository; +import cn.chenyunlong.qing.domain.anime.episode.Episode; +import cn.chenyunlong.qing.domain.anime.episode.mapper.EpisodeMapper; +import cn.chenyunlong.qing.domain.anime.episode.repository.EpisodeRepository; +import cn.chenyunlong.qing.domain.anime.playlist.PlayList; +import cn.chenyunlong.qing.domain.anime.playlist.dto.vo.PlayListVO; +import cn.chenyunlong.qing.domain.anime.playlist.mapper.PlayListMapper; +import cn.chenyunlong.qing.domain.anime.playlist.repository.PlayListRepository; +import cn.hutool.core.collection.CollUtil; import jakarta.validation.Validator; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; @@ -49,6 +58,8 @@ public class AnimeServiceImpl extends BaseJpaService implements IAnimeService { private final AttachmentRepository attachmentRepository; private final Validator validator; private final AnimeTagRelRepository animeTagRelRepository; + private final PlayListRepository playListRepository; + private final EpisodeRepository episodeRepository; /** * createImpl @@ -143,8 +154,22 @@ public AnimeDetailVO findDetailById(Long id) { return animeRepository.findById(id).map(anime -> { AnimeDetailVO animeDetailVO = AnimeMapper.INSTANCE.entityToDetailVo(anime); List animeTagRelList = animeTagRelRepository.listTagByAnimeId(anime.getId()); + List tagList = tagRepository.findByIds(animeTagRelList.stream().map(AnimeTagRel::getTagId).collect(Collectors.toList())); animeDetailVO.setTagVOList(tagList.stream().map(TagMapper.INSTANCE::entityToVo).collect(Collectors.toList())); + + List playListList = playListRepository.listByAnime(anime.getId()); + + List episodeList = episodeRepository.listByAnimeId(anime.getId()); + Map> longListMap = episodeList.stream().collect(Collectors.groupingBy(Episode::getPlayListId)); + + animeDetailVO.setPlayLists(playListList.stream().map(playList -> { + PlayListVO playListVO = PlayListMapper.INSTANCE.entityToVo(playList); + List episodes = longListMap.getOrDefault(playList.getId(), CollUtil.toList()); + playListVO.setEpisodeList(episodes.stream().map(EpisodeMapper.INSTANCE::entityToVo).collect(Collectors.toList())); + return playListVO; + }).collect(Collectors.toList())); + return animeDetailVO; } ).orElse(null); diff --git a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/episode/dto/vo/EpisodeVO.java b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/episode/dto/vo/EpisodeVO.java index 040972ea1..64fb9f68d 100644 --- a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/episode/dto/vo/EpisodeVO.java +++ b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/episode/dto/vo/EpisodeVO.java @@ -29,6 +29,8 @@ public class EpisodeVO extends AbstractBaseJpaVo { ) private Long animeId; + private String playUrl; + @Schema( title = "collectionId", description = "播放源ID" diff --git a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/episode/repository/EpisodeRepository.java b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/episode/repository/EpisodeRepository.java index f3fa4fbf1..073647e9b 100644 --- a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/episode/repository/EpisodeRepository.java +++ b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/episode/repository/EpisodeRepository.java @@ -2,8 +2,11 @@ import cn.chenyunlong.jpa.support.BaseRepository; import cn.chenyunlong.qing.domain.anime.episode.Episode; +import java.util.List; public interface EpisodeRepository extends BaseRepository { Integer findMaxEpisodeNumberByPlayListId(Long playListId); + + List listByAnimeId(Long animeId); } diff --git a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/playlist/dto/vo/PlayListVO.java b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/playlist/dto/vo/PlayListVO.java index 4a1cc12a4..1096b60e0 100644 --- a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/playlist/dto/vo/PlayListVO.java +++ b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/playlist/dto/vo/PlayListVO.java @@ -1,7 +1,9 @@ package cn.chenyunlong.qing.domain.anime.playlist.dto.vo; import cn.chenyunlong.common.model.AbstractBaseJpaVo; +import cn.chenyunlong.qing.domain.anime.episode.dto.vo.EpisodeVO; import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; import lombok.AccessLevel; import lombok.Data; import lombok.EqualsAndHashCode; @@ -31,4 +33,6 @@ public class PlayListVO extends AbstractBaseJpaVo { title = "icon" ) private String icon; + + private List episodeList; } diff --git a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/playlist/repository/PlayListRepository.java b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/playlist/repository/PlayListRepository.java index 976428b3c..e69a4ba0a 100644 --- a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/playlist/repository/PlayListRepository.java +++ b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/playlist/repository/PlayListRepository.java @@ -2,8 +2,11 @@ import cn.chenyunlong.jpa.support.BaseRepository; import cn.chenyunlong.qing.domain.anime.playlist.PlayList; +import java.util.List; public interface PlayListRepository extends BaseRepository { PlayList findByAnimeIdAndName(Long animeId, String name); + + List listByAnime(Long animeId); } diff --git a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/recommend/service/impl/RecommendServiceImpl.java b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/recommend/service/impl/RecommendServiceImpl.java index df6531d95..2b764944c 100644 --- a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/recommend/service/impl/RecommendServiceImpl.java +++ b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/recommend/service/impl/RecommendServiceImpl.java @@ -93,7 +93,6 @@ public void invalidRecommend(Long id) { @Override public RecommendVO findById(Long id) { Optional recommend = recommendRepository.findById(id); - return new RecommendVO( recommend.orElseThrow(() -> new BusinessException(CodeEnum.NotFoundError))); } diff --git a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/type/Type.java b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/type/Type.java index 3df0e0a70..b4e7aedfb 100644 --- a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/type/Type.java +++ b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/type/Type.java @@ -31,7 +31,7 @@ @Getter @Setter @ToString -@Entity(name = "type") +@Entity(name = "anime_type") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Type extends BaseJpaAggregate { diff --git a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/type/dto/updater/TypeUpdater.java b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/type/dto/updater/TypeUpdater.java index 729d49cce..06d83f597 100644 --- a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/type/dto/updater/TypeUpdater.java +++ b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/anime/type/dto/updater/TypeUpdater.java @@ -9,44 +9,16 @@ @Data public class TypeUpdater { - @Schema( - title = "name" - ) + private Long id; + + @Schema(title = "name") private String name; - @Schema( - title = "instruction" - ) + @Schema(title = "instruction") private String instruction; - private Long id; - public void updateType(Type param) { Optional.ofNullable(getName()).ifPresent(param::setName); Optional.ofNullable(getInstruction()).ifPresent(param::setInstruction); } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getInstruction() { - return instruction; - } - - public void setInstruction(String instruction) { - this.instruction = instruction; - } - - public Long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } } diff --git a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/role/dto/request/RoleUpdateRequest.java b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/role/dto/request/RoleUpdateRequest.java index 85c494a2c..647175e18 100644 --- a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/role/dto/request/RoleUpdateRequest.java +++ b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/role/dto/request/RoleUpdateRequest.java @@ -8,10 +8,10 @@ @Data public class RoleUpdateRequest implements Request { - @Schema( - title = "role", - description = "角色编码" - ) + @Schema(title = "id", description = "角色Id") + private Long id; + + @Schema(title = "role", description = "角色编码") private String role; @Schema( @@ -31,14 +31,4 @@ public class RoleUpdateRequest implements Request { description = "备注" ) private String remark; - - private Long id; - - public Long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } } diff --git a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/role/dto/updater/RoleUpdater.java b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/role/dto/updater/RoleUpdater.java index 9df88f17f..9a0337e22 100644 --- a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/role/dto/updater/RoleUpdater.java +++ b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/role/dto/updater/RoleUpdater.java @@ -9,6 +9,8 @@ @Data public class RoleUpdater { + private Long id; + @Schema( title = "role", description = "角色编码" @@ -33,20 +35,10 @@ public class RoleUpdater { ) private String remark; - private Long id; - public void updateRole(Role param) { Optional.ofNullable(getRole()).ifPresent(param::setRole); Optional.ofNullable(getName()).ifPresent(param::setName); Optional.ofNullable(getPlatformId()).ifPresent(param::setPlatformId); Optional.ofNullable(getRemark()).ifPresent(param::setRemark); } - - public Long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } } diff --git a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/role/mapper/RoleMapper.java b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/role/mapper/RoleMapper.java index 3c225eff3..7ae0dfd14 100644 --- a/qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/role/mapper/RoleMapper.java +++ b/qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/role/mapper/RoleMapper.java @@ -1,5 +1,6 @@ package cn.chenyunlong.qing.domain.auth.role.mapper; +import cn.chenyunlong.common.mapper.DateMapper; import cn.chenyunlong.qing.domain.auth.role.Role; import cn.chenyunlong.qing.domain.auth.role.dto.creator.RoleCreator; import cn.chenyunlong.qing.domain.auth.role.dto.query.RoleQuery; @@ -9,35 +10,25 @@ import cn.chenyunlong.qing.domain.auth.role.dto.response.RoleResponse; import cn.chenyunlong.qing.domain.auth.role.dto.updater.RoleUpdater; import cn.chenyunlong.qing.domain.auth.role.dto.vo.RoleVO; -import cn.hutool.core.bean.BeanUtil; +import cn.chenyunlong.qing.infrustructure.converter.CustomMapper; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; +import org.mapstruct.factory.Mappers; +@Mapper(uses = {CustomMapper.class, DateMapper.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE) public interface RoleMapper { - RoleMapper INSTANCE = new RoleMapper() { + RoleMapper INSTANCE = Mappers.getMapper(RoleMapper.class); - }; + RoleUpdater request2Updater(RoleUpdateRequest request); - default Role dtoToEntity(RoleCreator dto) { - return BeanUtil.copyProperties(dto, Role.class); - } + RoleCreator request2Dto(RoleCreateRequest request); - default RoleUpdater request2Updater(RoleUpdateRequest request) { - return BeanUtil.copyProperties(request, RoleUpdater.class); - } + RoleQuery request2Query(RoleQueryRequest request); - default RoleCreator request2Dto(RoleCreateRequest request) { - return BeanUtil.copyProperties(request, RoleCreator.class); - } + RoleResponse vo2Response(RoleVO vo); - default RoleQuery request2Query(RoleQueryRequest request) { - return BeanUtil.copyProperties(request, RoleQuery.class); - } + RoleResponse vo2CustomResponse(RoleVO vo); - default RoleResponse vo2Response(RoleVO vo) { - return BeanUtil.copyProperties(vo, RoleResponse.class); - } - - default RoleResponse vo2CustomResponse(RoleVO vo) { - return vo2Response(vo); - } + Role dtoToEntity(RoleCreator creator); } diff --git a/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/EpisodeRepositoryImpl.java b/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/EpisodeRepositoryImpl.java index 234f09025..a4e95dfaf 100644 --- a/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/EpisodeRepositoryImpl.java +++ b/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/EpisodeRepositoryImpl.java @@ -4,6 +4,7 @@ import cn.chenyunlong.qing.domain.anime.episode.repository.EpisodeRepository; import cn.chenyunlong.qing.infrastructure.repository.base.JpaServiceImpl; import cn.chenyunlong.qing.infrastructure.repository.jpa.EpisodeJpaRepository; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -17,4 +18,9 @@ public class EpisodeRepositoryImpl extends JpaServiceImpl listByAnimeId(Long animeId) { + return episodeJpaRepository.listByAnimeId(animeId); + } } diff --git a/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/PlayListRepositoryImpl.java b/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/PlayListRepositoryImpl.java index 1b142edb6..07a351712 100644 --- a/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/PlayListRepositoryImpl.java +++ b/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/PlayListRepositoryImpl.java @@ -4,6 +4,7 @@ import cn.chenyunlong.qing.domain.anime.playlist.repository.PlayListRepository; import cn.chenyunlong.qing.infrastructure.repository.base.JpaServiceImpl; import cn.chenyunlong.qing.infrastructure.repository.jpa.PlayListJpaRepository; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -17,4 +18,9 @@ public class PlayListRepositoryImpl extends JpaServiceImpl listByAnime(Long animeId) { + return playListJpaRepository.listByAnime(animeId); + } } diff --git a/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/jpa/EpisodeJpaRepository.java b/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/jpa/EpisodeJpaRepository.java index 0faa6984a..271e19b0c 100644 --- a/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/jpa/EpisodeJpaRepository.java +++ b/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/jpa/EpisodeJpaRepository.java @@ -2,6 +2,7 @@ import cn.chenyunlong.jpa.support.BaseJpaRepository; import cn.chenyunlong.qing.domain.anime.episode.Episode; +import java.util.List; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; @@ -10,4 +11,7 @@ public interface EpisodeJpaRepository extends BaseJpaRepository { @Query("select max(e.episodeNumber) from Episode e where e.playListId = ?1") Integer findMaxEpisodeNumberByPlayListId(Long playListId); + + @Query("select e from Episode e where e.animeId = ?1 ") + List listByAnimeId(Long animeId); } diff --git a/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/jpa/PlayListJpaRepository.java b/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/jpa/PlayListJpaRepository.java index 27a5aeebd..06df0a63d 100644 --- a/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/jpa/PlayListJpaRepository.java +++ b/qing-infrastructure-anime/src/main/java/cn/chenyunlong/qing/infrastructure/repository/jpa/PlayListJpaRepository.java @@ -2,6 +2,7 @@ import cn.chenyunlong.jpa.support.BaseJpaRepository; import cn.chenyunlong.qing.domain.anime.playlist.PlayList; +import java.util.List; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; @@ -10,4 +11,7 @@ public interface PlayListJpaRepository extends BaseJpaRepository @Query("select p from PlayList p where p.animeId = ?1 and p.name = ?2") PlayList findByAnimeIdAndName(Long animeId, String name); + + @Query("select p from PlayList p where p.animeId = ?1") + List listByAnime(Long animeId); }