“djh”
2024-12-04 d1549b8445c65a6775cf1ba093f5040ace0f87e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.gkhy.huataiFourierSpecialGasMonitor.domain.account.repository.jpa;
 
import com.gkhy.huataiFourierSpecialGasMonitor.domain.account.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
 
import java.time.LocalDateTime;
import java.util.List;
 
@Repository
public interface UserRepository extends JpaRepository<User,Long> , JpaSpecificationExecutor<User> {
 
    @Query(value = "select u from User u where u.name = :name  and u.status in (1,2)")
    User findUserByName(String name);
 
    List<User> findAllByIdIn(List<Long> userIdList);
 
    @Modifying
    @Query(value = "update User u set u.hash = :hash ,u.salt = :salt ,u.gmtModified = :time where u.id = :uid")
    Integer updatePassword(Long uid, String hash, String salt, LocalDateTime time);
 
    @Modifying
    @Query(value = "update User u set u.status = :status ,u.gmtModified = :time where u.id = :uid")
    Integer updateUserStatus(Long uid,Byte status,LocalDateTime time);
 
    /*@Modifying
    @Query(value = "update User u set u.roleId = :roleId ,u.gmtModified = :time where u.id = :uid")
    Integer updateUserRole(Long uid,Long roleId,LocalDateTime time);*/
 
    @Query(value = "select u from User u where u.phone = :phone and u.status in (1,2)")
    User findUserByPhone(String phone);
 
    @Query(value = "select u from User u where u.idType = :idType and u.idSerial = :idSerial and u.status in (1,2)")
    User findByIdTypeAndIdSerial(Byte idType,String idSerial);
 
    @Query("update User u set u.phone = :phone where u.id = :uid")
    @Modifying
    Integer updateUserPhone(Long uid,String phone);
    /**
     * 用户列表
     */
    @Query(value = "select * from sys_user  where status in (1,2)", nativeQuery = true)
    List<User> getUserList();
 
    @Query(value = "select u from User u where u.realName like %:name% and u.status in (1,2)")
    List<User> getUsersByRealName(String name);
 
    /**
     * 用户列表
     */
    @Query(value = "select * from sys_user  where id = :evaluateUserId and status in (1,2)", nativeQuery = true)
    User getUserInfoByIdAndSellInfo(Long evaluateUserId);
    @Query(value = "select u from User u where u.id = :uid and u.status in (1,2)")
    User getById(Long uid);
 
    User findUserByIdAndStatus(Long userId, Byte status);
}