无关风月
2025-01-08 a70b9da8a2a1a10984cc09ebaae98861836f836f
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
package com.jilongda.applet.utils;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jilongda.applet.model.TAppUser;
import com.jilongda.applet.service.TAppUserService;
import com.jilongda.common.model.TUser;
import com.jilongda.common.security.JwtTokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
@Component
public class LoginInfoUtil {
 
    @Autowired
    private TAppUserService appUserService;
 
 
    public Integer getUserId(){
        String username = JwtTokenUtils.getUsername();
        TAppUser appUser = appUserService.getOne(new QueryWrapper<TAppUser>().eq("openId", username).eq("isDelete",0));
        return appUser.getId();
    }
 
    public TAppUser getLoginUser(){
        String username = JwtTokenUtils.getUsername();
        TAppUser TAppUser = appUserService.getOne(new QueryWrapper<TAppUser>().eq("openId", username).eq("isDelete",0));
        return TAppUser;
    }
 
    /**
     * @description  注销
     * @author  jqs
     * @date    2024/4/18 10:26
     * @param
     * @return  void
     */
    public void logoff(){
        String username = JwtTokenUtils.getUsername();
        TAppUser userName = appUserService.getOne(new QueryWrapper<TAppUser>().eq("openId", username).eq("isDelete",0));
        userName.setIsDelete(true);
        appUserService.saveOrUpdate(userName);
    }
 
    public Boolean checkPhoneExits(String phone){
        TAppUser userName = appUserService.getOne(new QueryWrapper<TAppUser>().eq("openId", phone).eq("isDelete",0));
        if(userName!=null){
            return true;
        }else{
            return false;
        }
    }
}