songshuai před 5 roky
rodič
revize
f6dfaec610

+ 1 - 1
src/main/java/cn/efunbox/audio/config/Config.java

@@ -51,7 +51,7 @@ public class Config extends WebMvcConfigurerAdapter{
         registry.addInterceptor(adminInterceptor())
                 .addPathPatterns("/**", "/device/update", "/device/delete")
                 .excludePathPatterns("/device/**","/audio/info/{audioId}", "/error", "/admin/login", "/audio/search","/file/**","/audio/searchList","/statistics","/album","/album/{albumId}")
-                .excludePathPatterns("/getTypeList","/getTypeContentList");
+                .excludePathPatterns("/getTypeList","/getTypeContentList","/getContentDetail");
 
         registry.addInterceptor(ignoreOptionsInterceptor())
                 .addPathPatterns("/**");

+ 23 - 3
src/main/java/cn/efunbox/audio/controller/res/ResAlbumController.java

@@ -3,7 +3,9 @@ package cn.efunbox.audio.controller.res;
 import cn.efunbox.audio.entity.res.ResAlbum;
 import cn.efunbox.audio.page.ResOnePage;
 import cn.efunbox.audio.service.res.ResAlbumService;
+import cn.efunbox.audio.utils.ResApiCode;
 import cn.efunbox.audio.utils.ResApiResult;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -12,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 @RestController
 @RequestMapping
+@Slf4j
 public class ResAlbumController {
 
     @Autowired
@@ -20,8 +23,25 @@ public class ResAlbumController {
     @RequestMapping(value = "/getTypeContentList")
     public ResApiResult<ResOnePage<ResAlbum>> getResCategoryList(@RequestHeader(value = "USERID",required = false) String USERID,
                                                                  @RequestParam(name="typeId",required = false) String typeId,
-                                                                 @RequestParam(name="pageNum",required = false) int pageNum,
-                                                                 @RequestParam(name="pageSize",required = false) int pageSize){
-        return resAlbumService.getResAlbumList(typeId,pageNum,pageSize);
+                                                                 @RequestParam(name="pageNum",required = false) Integer pageNum,
+                                                                 @RequestParam(name="pageSize",required = false) Integer pageSize){
+
+        try {
+            return resAlbumService.getResAlbumList(typeId,pageNum,pageSize);
+        } catch (Exception e) {
+            log.error("getTypeContentList接口异常:{}",e.getMessage());
+            return ResApiResult.error(ResApiCode.UNKNOWN_ERROR);
+        }
+    }
+
+    @RequestMapping(value = "/getContentDetail")
+    public ResApiResult<ResAlbum> getResCategoryList(@RequestHeader(value = "USERID",required = false) String USERID,
+                                                                 @RequestParam(name="contentId",required = false) String contentId) {
+        try {
+            return resAlbumService.getResAlbumById(contentId);
+        } catch (Exception e) {
+            log.error("getContentDetail接口异常:{}", e.getMessage());
+            return ResApiResult.error(ResApiCode.UNKNOWN_ERROR);
+        }
     }
 }

+ 9 - 2
src/main/java/cn/efunbox/audio/controller/res/ResCategoryController.java

@@ -2,7 +2,9 @@ package cn.efunbox.audio.controller.res;
 
 import cn.efunbox.audio.entity.res.ResCategory;
 import cn.efunbox.audio.service.res.ResCategoryService;
+import cn.efunbox.audio.utils.ResApiCode;
 import cn.efunbox.audio.utils.ResApiResult;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -10,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 @RestController
 @RequestMapping
+@Slf4j
 public class ResCategoryController {
 
     @Autowired
@@ -17,8 +20,12 @@ public class ResCategoryController {
 
     @RequestMapping(value = "/getTypeList")
     public ResApiResult<ResCategory> getResCategoryList(@RequestHeader(value = "USERID",required = false) String USERID){
-       return resCategoryService.getResCategoryList();
+        try {
+            return resCategoryService.getResCategoryList();
+        } catch (Exception e) {
+            log.error("getTypeList接口异常:{}",e.getMessage());
+        }
+        return ResApiResult.error(ResApiCode.UNKNOWN_ERROR);
     }
 
-
 }

+ 41 - 6
src/main/java/cn/efunbox/audio/impl/res/ResAlbumServiceImpl.java

@@ -21,24 +21,34 @@ public class ResAlbumServiceImpl implements ResAlbumService {
     @Autowired
     ResAlbumRepository resAlbumRepository;
 
+    /**
+     * 获取分类下的专辑列表-分页
+     * @param typeId 分类 Id
+     * @param pageNum 页码
+     * @param pageSize 页面大小
+     * @return
+     */
     @Override
-    public ResApiResult<ResOnePage<ResAlbum>> getResAlbumList(String typeId, Integer pageNum, Integer pageSize) {
-        if(StringUtils.isBlank(typeId)){
-            return ResApiResult.error(ResApiCode.PARAMETER_NULL,ResApiCode.PARAMETER_NULL.getMessage()+"typeId");//错误提示语格式=》请求参数为空:typeId
-        }
+    public ResApiResult<ResOnePage<ResAlbum>> getResAlbumList(String typeId, Integer pageNum, Integer pageSize)  {
 
         //查询条件
         ResAlbum resAlbum = new ResAlbum();
+        if(StringUtils.isNotBlank(typeId)){
+            resAlbum.setTypeId(typeId);
+        }
         resAlbum.setTypeId(typeId);
 
         Long count = resAlbumRepository.count(resAlbum);
+        if(count == 0){
+            return ResApiResult.error(ResApiCode.NOT_FOUND);
+        }
 
 
         ResOnePage onePage = new ResOnePage(count);
-        if(pageNum > 0){
+        if(pageNum != null){
             onePage.setPageNum(pageNum);
         }
-        if(pageSize > 0){
+        if(pageSize != null){
             onePage.setPageSize(pageSize);
         }
 
@@ -53,9 +63,34 @@ public class ResAlbumServiceImpl implements ResAlbumService {
                         }}
                 )
         );
+        if(resAlbumList == null || resAlbumList.size() == 0){
+            return ResApiResult.error(ResApiCode.NOT_FOUND);
+        }
+
         onePage.setContentList(resAlbumList);
 
         //响应
         return ResApiResult.ok(onePage);
     }
+
+    /**
+     * 获取专辑详情信息
+     * @param contentId 专辑 id
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public ResApiResult<ResAlbum> getResAlbumById(String contentId) throws Exception {
+        if(StringUtils.isBlank(contentId)){
+            return ResApiResult.error(ResApiCode.PARAMETER_NULL,ResApiCode.PARAMETER_NULL.getMessage()+"contentId");//错误提示语格式=》请求参数为空:contentId
+        }
+
+        //查询
+        ResAlbum resAlbum = resAlbumRepository.find(contentId);
+        if(resAlbum == null){
+            return ResApiResult.error(ResApiCode.NOT_FOUND);
+        }
+
+        return ResApiResult.ok(resAlbum);
+    }
 }

+ 3 - 1
src/main/java/cn/efunbox/audio/service/res/ResAlbumService.java

@@ -6,5 +6,7 @@ import cn.efunbox.audio.utils.ResApiResult;
 
 public interface ResAlbumService {
 
-    ResApiResult<ResOnePage<ResAlbum>> getResAlbumList(String typeId, Integer pageNo, Integer pageSize);
+    ResApiResult<ResOnePage<ResAlbum>> getResAlbumList(String typeId, Integer pageNo, Integer pageSize) throws Exception;
+
+    ResApiResult<ResAlbum> getResAlbumById(String contentId) throws Exception;
 }

+ 1 - 1
src/main/java/cn/efunbox/audio/service/res/ResCategoryService.java

@@ -4,5 +4,5 @@ import cn.efunbox.audio.utils.ResApiResult;
 
 public interface ResCategoryService {
 
-    public ResApiResult getResCategoryList();
+    public ResApiResult getResCategoryList() throws Exception;
 }

+ 0 - 2
src/main/java/cn/efunbox/audio/utils/BaseConstant.java

@@ -4,6 +4,4 @@ package cn.efunbox.audio.utils;
  * 常量类
  */
 public class BaseConstant {
-
-
 }