|
@@ -1,6 +1,8 @@
|
|
|
package cn.efunbox.audio.impl.res;
|
|
|
|
|
|
+import cn.efunbox.audio.entity.BaseOrderEnum;
|
|
|
import cn.efunbox.audio.entity.res.ResAlbum;
|
|
|
+import cn.efunbox.audio.helper.SortHelper;
|
|
|
import cn.efunbox.audio.page.ResOnePage;
|
|
|
import cn.efunbox.audio.repository.res.ResAlbumRepository;
|
|
|
import cn.efunbox.audio.service.res.ResAlbumService;
|
|
@@ -10,6 +12,9 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
@Service
|
|
|
public class ResAlbumServiceImpl implements ResAlbumService {
|
|
|
|
|
@@ -17,12 +22,40 @@ public class ResAlbumServiceImpl implements ResAlbumService {
|
|
|
ResAlbumRepository resAlbumRepository;
|
|
|
|
|
|
@Override
|
|
|
- public ResApiResult getResAlbumList(String typeId, Integer pageNo, Integer pageSize) {
|
|
|
+ public ResApiResult<ResOnePage<ResAlbum>> getResAlbumList(String typeId, Integer pageNum, Integer pageSize) {
|
|
|
if(StringUtils.isBlank(typeId)){
|
|
|
- return ResApiResult.error(ResApiCode.PARAMETER_NULL,"");
|
|
|
+ return ResApiResult.error(ResApiCode.PARAMETER_NULL,ResApiCode.PARAMETER_NULL.getMessage()+"typeId");//错误提示语格式=》请求参数为空:typeId
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询条件
|
|
|
+ ResAlbum resAlbum = new ResAlbum();
|
|
|
+ resAlbum.setTypeId(typeId);
|
|
|
+
|
|
|
+ Long count = resAlbumRepository.count(resAlbum);
|
|
|
+
|
|
|
+
|
|
|
+ ResOnePage onePage = new ResOnePage(count);
|
|
|
+ if(pageNum > 0){
|
|
|
+ onePage.setPageNum(pageNum);
|
|
|
+ }
|
|
|
+ if(pageSize > 0){
|
|
|
+ onePage.setPageSize(pageSize);
|
|
|
}
|
|
|
|
|
|
+ //数据查询
|
|
|
+ List<ResAlbum> resAlbumList = resAlbumRepository.find(
|
|
|
+ resAlbum,
|
|
|
+ onePage.getStart(),
|
|
|
+ onePage.getPageSize(),
|
|
|
+ SortHelper.sortMap2Sort(
|
|
|
+ new LinkedHashMap<String, BaseOrderEnum>() {{
|
|
|
+ put("sort", BaseOrderEnum.ASC);
|
|
|
+ }}
|
|
|
+ )
|
|
|
+ );
|
|
|
+ onePage.setContentList(resAlbumList);
|
|
|
|
|
|
- return null;
|
|
|
+ //响应
|
|
|
+ return ResApiResult.ok(onePage);
|
|
|
}
|
|
|
}
|