提交 3556a5c1 authored 作者: mry's avatar mry

合并分支 'dev' 到 'master'

一号添加了Message的查询 查看合并请求 !1
# GitFlow # GitFlow
- 根据gitflow规范,已经拉取了远程的User的基本功能
- 继续进行Message的基本功能
\ No newline at end of file
...@@ -22,7 +22,7 @@ public class SwaggerConfig { ...@@ -22,7 +22,7 @@ public class SwaggerConfig {
.apiInfo(adminApiInfo()) .apiInfo(adminApiInfo())
.select() // 过滤器,用于实现对接口的分组,过滤掉不希望放在adminApi组的接口信息 .select() // 过滤器,用于实现对接口的分组,过滤掉不希望放在adminApi组的接口信息
//只显示admin路径下的页面 //只显示admin路径下的页面
.paths(Predicates.or(PathSelectors.regex("/users.*"))) .paths(Predicates.or(PathSelectors.regex("/users.*"),PathSelectors.regex("/messages.*")))
.build(); .build();
} }
......
package com.git.mygitflow.controller;
import com.git.mygitflow.entity.Message;
import com.git.mygitflow.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@CrossOrigin
@RestController
@RequestMapping("/messages")
@Api(tags = "messages的CRUD")
public class MessageController {
@Autowired
private MessageService messageService;
@GetMapping
@ApiOperation(value = "查询所有")
public ResponseEntity<List<Message>> find(){
List<Message> result = messageService.find();
if (result.size() == 0){
return ResponseEntity.status(404).body(result);
}else {
return ResponseEntity.ok(result);
}
}
}
package com.git.mygitflow.dao;
import com.git.mygitflow.entity.Message;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface MessageDao extends JpaRepository<Message,Integer>, JpaSpecificationExecutor<Message> {
}
package com.git.mygitflow.service.Impl;
import com.git.mygitflow.dao.MessageDao;
import com.git.mygitflow.entity.Message;
import com.git.mygitflow.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class MessageServiceImpl implements MessageService {
@Autowired
private MessageDao messageDao;
@Override
public List<Message> find() {
return messageDao.findAll();
}
}
package com.git.mygitflow.service;
import com.git.mygitflow.entity.Message;
import java.util.List;
public interface MessageService {
List<Message> find();
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论