时间:2021-07-01 10:21:17 帮助过:334人阅读
pid:指导记录主键
user_pid:用户主键
competition_project_pid:用户作品
/**
* 指导记录
* @date 2020/3/24 9:26
*/
@Repository
public interface CompetitionProjectGuideRepository extends JpaRepository<CompetitionProjectGuide, String> {
Optional<CompetitionProjectGuide> findFirstByCompetitionProjectPidOrderByUpdateAtDesc(Long pid);
}
public Optional<CompetitionProjectGuide> findFirstByCompetitionProjectPidOrderByUpdateAtDesc(Long pid) {
return repository.findFirstByCompetitionProjectPidOrderByUpdateAtDesc(pid);
}
@RequestMapping(method = {RequestMethod.GET}, value = "/task/project/guide")
public ResponseEntity getGuide(Long pid) {
Optional<CompetitionProjectGuide> guide = competitionProjectGuideService.findFirstByCompetitionProjectPidOrderByUpdateAtDesc(pid);
guide.orElseThrow(() -> new BusinessException(
HttpStatus.BAD_REQUEST, Translator.toLocale("guide.NotExists.message")));
return ResponseEntity.ok(guide);
}
可以通过findFirst或者findTop来获取
jpa查找数据库最新一条消息
标签:控制 nes new guid size ide stat user blog