Java的新项目学成在线笔记-day14(六)

2 我的媒资 2.1 需求分析
通过我的媒资可以查询本教育机构拥有的媒资文件,进行文件处理、删除文件、修改文件信息等操作,具体需求如 下:
1、分页查询我的媒资文件
2、删除媒资文件 3、处理媒资文件
4、修改媒资文件信息
Java的新项目学成在线笔记-day14(六)
2.2 API
本节讲解我的媒资文件分页查询、处理媒资文件,其它功能请学员自行实现。

[mw_shl_code=applescript,true]@Api(value = "媒体文件管理",description = "媒体文件管理接口",tags = {"媒体文件管理接口"}) public interface MediaFileControllerApi {
@ApiOperation("查询文件列表")
public QueryResponseResult findList(int page, int size, QueryMediaFileRequest queryMediaFileRequest) ;
}[/mw_shl_code]
2.3 服务端开发
2.3.1 Dao


[mw_shl_code=applescript,true]@Repository public interface MediaFileDao 
extends MongoRepository<MediaFile,String> { 
  }[/mw_shl_code]
2.3.2  Service 
定义findList方法实现媒资文件查询列表。

[mw_shl_code=applescript,true]@Service public class MediaFileService {     
  private static Logger logger = LoggerFactory.getLogger(MediaFileService.class);   
    @Autowired   
  MediaFileRepository mediaFileRepository;   
    //文件列表分页查询  
   public QueryResponseResult findList(int page,int size,QueryMediaFileRequest
  queryMediaFileRequest){    
     //查询条件     
    MediaFile mediaFile = new MediaFile();     
    if(queryMediaFileRequest == null){    
         queryMediaFileRequest = new QueryMediaFileRequest();    
     }       
  //查询条件匹配器     
    ExampleMatcher matcher = ExampleMatcher.matching()    
             .withMatcher("tag", ExampleMatcher.GenericPropertyMatchers.conta×××())//tag字段 模糊匹配       
          .withMatcher("fileOriginalName",  ExampleMatcher.GenericPropertyMatchers.conta×××())//文件原始名称模糊匹配                 .withMatcher("processStatus", ExampleMatcher.GenericPropertyMatchers.exact());// 处理状态精确匹配(默认) 
        //查询条件对象       
  if(StringUtils.isNotEmpty(queryMediaFileRequest.getTag())){[/mw_shl_code]
[mw_shl_code=applescript,true]mediaFile.setTag(queryMediaFileRequest.getTag());    
     }    
     if(StringUtils.isNotEmpty(queryMediaFileRequest.getFileOriginalName())){             mediaFile.setFileOriginalName(queryMediaFileRequest.getFileOriginalName());   
      }      
   if(StringUtils.isNotEmpty(queryMediaFileRequest.getProcessStatus())){     
        mediaFile.setProcessStatus(queryMediaFileRequest.getProcessStatus());    
     }     
    //定义example实例  
       Example<MediaFile> ex = Example.of(mediaFile, matcher);   
        page = page‐1;    
     //分页参数   
      Pageable pageable = new PageRequest(page, size);  
       //分页查询       
  Page<MediaFile> all = mediaFileRepository.findAll(ex,pageable);   
      QueryResult<MediaFile> mediaFileQueryResult = new QueryResult<MediaFile>();     
    mediaFileQueryResult.setList(all.getContent());       
  mediaFileQueryResult.setTotal(all.getTotalElements()); 
        return new QueryResponseResult(CommonCode.SUCCESS,mediaFileQueryResult); 
    }   }
[/mw_shl_code]
2.3.3 Controller 
[mw_shl_code=applescript,true]@RestController @RequestMapping("/media/file") public class MediaFileController implements MediaFileControllerApi {       @Autowired 
    MediaFileService mediaFileService;   
  @Autowired    
MediaUploadService mediaUploadService;   
    @Override  
   @GetMapping("/list/{page}/{size}")  
   public QueryResponseResult findList(@PathVariable("page") int page, @PathVariable("size") 
int size, QueryMediaFileRequest queryMediaFileRequest) {      //媒资文件查询          
    return mediaFileService.findList(page,size,queryMediaFileRequest); 
    }  
   }[/mw_shl_code]

转载于:https://blog.51cto.com/13517854/2409100

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值