mirror of
https://gitee.com/many2many/java-web.git
synced 2025-01-11 14:40:55 +08:00
changed
This commit is contained in:
parent
2a078a47cc
commit
5c6259fb8a
@ -12,6 +12,9 @@ public class UserController {
|
||||
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
/**
|
||||
* 获取指定ID的用户信息
|
||||
* Method: GET
|
||||
|
@ -2,16 +2,19 @@ package com.lk.demo;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
List<User> findByNameLikeOrderByAgeDesc(String name);
|
||||
|
||||
|
||||
@Query("Select u from User u where u.name like %?1% order by u.age desc")
|
||||
List<User> abcd(String name);
|
||||
|
||||
@Query("Select u from User u where u.name like %:name% order by u.age desc")
|
||||
List<User> dcba(@Param("name") String name);
|
||||
|
||||
@Query(value = "Select * from Users u where u.name like %?1% order by u.age desc", nativeQuery = true)
|
||||
List<User> queryUsersByName(String name);
|
||||
|
||||
|
@ -28,6 +28,7 @@ public class UserService {
|
||||
|
||||
userRepository.findByNameLikeOrderByAgeDesc(name);
|
||||
userRepository.abcd(name);
|
||||
userRepository.dcba(name);
|
||||
return userRepository.queryUsersByName(name);
|
||||
}
|
||||
|
||||
|
@ -17,10 +17,8 @@
|
||||
|
||||
|
||||
spring:
|
||||
|
||||
jackson:
|
||||
property-naming-strategy: SNAKE_CASE # 驼峰转下划线
|
||||
|
||||
datasource:
|
||||
url: jdbc:h2:file:./db.h2 # 使用文件存储
|
||||
driverClassName: org.h2.Driver
|
||||
|
Loading…
Reference in New Issue
Block a user