diff --git a/luoo_user/src/main/java/com/luoo/user/controller/ArtistController.java b/luoo_user/src/main/java/com/luoo/user/controller/ArtistController.java index 05cedbe..ff6c43e 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/ArtistController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/ArtistController.java @@ -4,6 +4,7 @@ import api.PageResult; import api.Result; import com.luoo.user.dto.UserProcessApproveDto; import com.luoo.user.dto.artist.ArtistRegisterDto; +import com.luoo.user.dto.artist.ArtistSearchDto; import com.luoo.user.dto.artist.ArtistUserBindDto; import com.luoo.user.pojo.ArtistInfo; import com.luoo.user.pojo.UserProcess; @@ -75,11 +76,12 @@ public class ArtistController { } @ApiOperation(value = "分页显示音乐人列表", notes = "分页显示音乐人列表") - @GetMapping("/app/list/{page}/{size}") + @PostMapping("/app/list/{page}/{size}") public Result> getArtistList(@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, - @ApiParam(value = "页码", required = true) @PathVariable Integer page, - @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { - return Result.success(artistService.getListApproveSuccess(page, size)); + @ApiParam(value = "查询条件", required = true) @RequestBody ArtistSearchDto artistSearchDto, + @ApiParam(value = "页码", required = true) @PathVariable Integer page, + @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { + return Result.success(artistService.getList(artistSearchDto, page, size)); } @ApiOperation(value = "上一次申请的记录", notes = "上一次申请的记录-音乐人注册审批失败后可以自动带出上一次审批填写的数据") diff --git a/luoo_user/src/main/java/com/luoo/user/dao/ArtistInfoDao.java b/luoo_user/src/main/java/com/luoo/user/dao/ArtistInfoDao.java index a3b9756..edac8a2 100644 --- a/luoo_user/src/main/java/com/luoo/user/dao/ArtistInfoDao.java +++ b/luoo_user/src/main/java/com/luoo/user/dao/ArtistInfoDao.java @@ -18,13 +18,21 @@ import org.springframework.data.jpa.repository.Query; public interface ArtistInfoDao extends JpaRepository, JpaSpecificationExecutor { - @Query(value = " select t1.* from tb_artist_info t1 left join tb_user_process t2 on t1.user_id = t2.user_id \n" + + @Query(value = " select t1.*, t2.status from tb_artist_info t1 left join tb_user_process t2 on t1.user_id = t2.user_id \n" + " where t2.type = 1 and t2.status = 0", countProjection = "t1.id", nativeQuery = true) public Page findListByCheckState(Pageable pageable); - @Query(value = " select t1.* from tb_artist_info t1 left join tb_user_process t2 on t1.user_id = t2.user_id \n" + + @Query(value = " select t1.*, t2.status from tb_artist_info t1 left join tb_user_process t2 on t1.user_id = t2.user_id \n" + " where t2.type = 1 and t2.status = 1 order by t1.id desc", countProjection = "t1.id", nativeQuery = true) public Page findListApproveSuccess(Pageable pageable); + @Query(value = " select distinct t1.* from tb_artist_info t1 left join tb_user_process t2 on t1.user_id = t2.user_id \n" + + " where t2.type = 1 and t2.status = ?1 order by t1.id desc", countProjection = "t1.id", nativeQuery = true) + public Page findAllByStatus(Integer status, Pageable pageable); + + @Query(value = " select distinct t1.* from tb_artist_info t1 left join tb_user_process t2 on t1.user_id = t2.user_id \n" + + " where t2.type = 1 order by t1.id desc", countProjection = "t1.id", nativeQuery = true) + public Page findAllNoStatus(Pageable pageable); + public ArtistInfo findArtistInfoByUserId(String userId); } diff --git a/luoo_user/src/main/java/com/luoo/user/dto/artist/ArtistSearchDto.java b/luoo_user/src/main/java/com/luoo/user/dto/artist/ArtistSearchDto.java new file mode 100644 index 0000000..29a43fa --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dto/artist/ArtistSearchDto.java @@ -0,0 +1,21 @@ +package com.luoo.user.dto.artist; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: yawei.huang + * @Package: com.luoo.user.dto.artist + * @Project: luoo_parent + * @Date: 2024/5/27 16:07 + * @Filename: ArtistSearchDto + * @Describe: + */ +@Data +public class ArtistSearchDto implements Serializable { + + @ApiModelProperty(value = "申请状态 0-待审批 1-审批通过 2-审批失败") + private Integer status; +} diff --git a/luoo_user/src/main/java/com/luoo/user/service/ArtistService.java b/luoo_user/src/main/java/com/luoo/user/service/ArtistService.java index 9f198cb..87d6cd2 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/ArtistService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/ArtistService.java @@ -1,9 +1,13 @@ package com.luoo.user.service; import api.PageResult; -import com.luoo.user.dao.*; +import com.luoo.user.dao.ArtistInfoDao; +import com.luoo.user.dao.ArtistUserDao; +import com.luoo.user.dao.UserInfoDao; +import com.luoo.user.dao.UserProcessDao; import com.luoo.user.dto.UserProcessApproveDto; import com.luoo.user.dto.artist.ArtistRegisterDto; +import com.luoo.user.dto.artist.ArtistSearchDto; import com.luoo.user.dto.artist.ArtistUserBindDto; import com.luoo.user.pojo.ArtistInfo; import com.luoo.user.pojo.ArtistUser; @@ -286,9 +290,14 @@ public class ArtistService { * 分页显示音乐人列表 * */ - public PageResult getListApproveSuccess(Integer page, Integer size) { + public PageResult getList(ArtistSearchDto artistSearchDto, Integer page, Integer size) { Pageable pageable = PageRequest.of(page - 1, size); - Page artistInfoPage = artistInfoDao.findListApproveSuccess(pageable); + Page artistInfoPage; + if(artistSearchDto.getStatus() == null) { + artistInfoPage = artistInfoDao.findAllNoStatus(pageable); + } else { + artistInfoPage = artistInfoDao.findAllByStatus(artistSearchDto.getStatus(), pageable); + } long totalElements = artistInfoPage.getTotalElements(); return new PageResult<>(totalElements, artistInfoPage.getContent()); }