zss
2025-05-26 51ec98113c6d49d0f7eec4e3c030e55e337e97db
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
package com.yuanchu.mom.common;
 
import cn.hutool.json.JSONUtil;
import com.yuanchu.mom.exception.ErrorException;
import com.yuanchu.mom.mapper.AuthMapper;
import com.yuanchu.mom.utils.Jwt;
import com.yuanchu.mom.utils.ServletUtils;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
 
@Component
public class GetLook {
 
    @Resource
    private AuthMapper authMapper;
 
    public Map<String, Integer> selectPowerByMethodAndUserId(String method){
        Integer id;
        try {
            id = Integer.parseInt(JSONUtil.parseObj(new Jwt().readJWT(ServletUtils.getRequest().getHeader("token")).get("data")).get("id")+"");
        }catch (NumberFormatException e){
            throw new ErrorException("授权已过期请重新登陆");
        }
        Map<String, Integer> map = new HashMap<>();
        map.put("userId", id);
        Integer look = authMapper.countPower(id, method);
        map.put("look", look==null?0:look);
        return map;
    }
}