无关风月
2024-12-09 2053b8fe0e98d4b4449bc756a93ced78f42277c4
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
73
74
75
76
77
78
package com.jilongda.optometry.utils;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jilongda.common.model.TUser;
import com.jilongda.common.security.JwtTokenUtils;
import com.jilongda.optometry.model.SecUser;
import com.jilongda.optometry.service.SecUserService;
import com.jilongda.optometry.service.TUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
@Component
public class LoginInfoUtil {
 
    @Autowired
    private TUserService tUserService;
 
    @Autowired
    private SecUserService secUserService;
 
 
 
 
 
    public Long getUserId1(){
        String username = JwtTokenUtils.getUsername();
        TUser userName = tUserService.getOne(new QueryWrapper<TUser>().eq("userName", username).eq("isDelete",0));
        return userName.getId();
 
    }
    public Long getUserId(){
        String username = JwtTokenUtils.getUsername();
        SecUser userName = secUserService.getOne(new QueryWrapper<SecUser>().eq("phone", username).eq("isDelete",0));
        return userName.getId();
 
    }
    public SecUser getLoginUserByPhone(){
        String username = JwtTokenUtils.getUsername();
        SecUser tUser = secUserService.getOne(new QueryWrapper<SecUser>().eq("phone", username).eq("isDelete",0));
        return tUser;
    }
 
    public SecUser getLoginUser(){
        String username = JwtTokenUtils.getUsername();
        SecUser secUser = secUserService.getOne(new QueryWrapper<SecUser>().eq("phone", username).eq("isDelete",0));
        return secUser;
    }
 
    public Integer getUserType(){
        String username = JwtTokenUtils.getUsername();
        SecUser userName = secUserService.getOne(new QueryWrapper<SecUser>().eq("phone", username).eq("isDelete",0));
        return userName.getUserType();
 
    }
 
    /**
     * @description  注销
     * @author  jqs
     * @date    2024/4/18 10:26
     * @param
     * @return  void
     */
    public void logoff(){
        String username = JwtTokenUtils.getUsername();
        SecUser userName = secUserService.getOne(new QueryWrapper<SecUser>().eq("phone", username).eq("isDelete",0));
        userName.setIsDelete(true);
        secUserService.saveOrUpdate(userName);
    }
 
    public Boolean checkPhoneExits(String phone){
        SecUser userName = secUserService.getOne(new QueryWrapper<SecUser>().eq("phone", phone).eq("isDelete",0));
        if(userName!=null){
            return true;
        }else{
            return false;
        }
    }
}