Skip to content

Commit

Permalink
✨ Feat: enhance web coding
Browse files Browse the repository at this point in the history
  • Loading branch information
SaminZou committed Dec 27, 2024
1 parent 182d8ed commit ee98ea6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public interface UserRepository extends JpaRepository<UserDO, Integer> {
*/
List<UserDO> findUserBySex(int sex);

Optional<UserDO> findUserDOById(Integer id);

long countBySex(Integer sex);

@Query(
Expand All @@ -38,6 +36,9 @@ public interface UserRepository extends JpaRepository<UserDO, Integer> {
List<Integer> findDistinctBySex(
@Param("startTime") String startTime, @Param("endTime") String endTime);

@Query(value = "SELECT u FROM UserDO u WHERE u.id = :id")
Optional<UserDO> findByIdCustom(@Param("id") Integer id);

List<UserDO> findByCreateTimeBetween(String startDate, String endDate);

// 直接这样声明只会调用 select 语句,Jpa 的安全设定
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public List<UserVO> findBySex(int sex) {
}

public UserVO detail(Integer id) {
Optional<UserDO> opt = userRepository.findUserDOById(id);
Optional<UserDO> opt = userRepository.findByIdCustom(id);
UserDO userDO = opt.orElse(new UserDO());

UserVO userVO = new UserVO();
Expand Down
2 changes: 1 addition & 1 deletion web/demo-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<redisson.version>3.17.0</redisson.version>
<knife4j.version>3.0.3</knife4j.version>
<jjwt.version>0.9.1</jjwt.version>
<hutool.version>5.8.14</hutool.version>
<hutool.version>5.8.21</hutool.version>
</properties>

<dependencyManagement>
Expand Down

0 comments on commit ee98ea6

Please sign in to comment.