zhangzeli
2022-01-05 435b1cfe40ee2822381274d3a0a4f9066157b02b
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
61
62
63
64
65
66
67
68
69
70
71
72
package cn.exrick.xboot.core.dao;
 
import cn.exrick.xboot.core.base.XbootBaseDao;
import cn.exrick.xboot.core.entity.User;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
 
import java.util.List;
 
/**
 * 用户数据处理层
 * @author Exrickx
 */
public interface UserDao extends XbootBaseDao<User, String> {
 
    /**
     * 通过用户名获取用户
     * @param username
     * @return
     */
    User findByUsername(String username);
 
    /**
     * 查询所有用户
     * @return
     */
    List<User> findAll();
 
    /**
     * 通过手机获取用户
     * @param mobile
     * @return
     */
    User findByMobile(String mobile);
 
    /**
     * 通过邮件获取用户
     * @param email
     * @return
     */
    User findByEmail(String email);
 
    /**
     * 通过部门id获取
     * @param departmentId
     * @return
     */
    List<User> findByDepartmentId(String departmentId);
 
    /**
     * 通过用户名模糊搜索
     * @param key
     * @param status
     * @return
     */
    @Query("select u from User u where u.username like %?1% or u.nickname like %?1% and u.status = ?2")
    List<User> findByUsernameLikeAndStatus(String key, Integer status);
 
    /**
     * 更新部门名称
     * @param departmentId
     * @param departmentTitle
     */
    @Modifying
    @Query("update User u set u.departmentTitle=?2 where u.departmentId=?1")
    void updateDepartmentTitle(String departmentId, String departmentTitle);
 
    @Query("select count(id) from User u where u.type2=?1")
    int countByType(int type);
 
    List<User> findByType2(int type);
}