zxl
2026-03-25 963a8c24874c2e10a329a6ea39774bc5eda0f762
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
package com.tievd.jyz.cache;
 
import com.tievd.jyz.entity.SysCarModel;
import com.tievd.jyz.service.ISysCarModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * Author: wqy
 * Date: 2023/8/29 14:58
 */
@Component
public class CarModelCache {
    
    private static final Map<String, String> modelCacheMap = new HashMap<>();
    
    
    @Autowired
    ISysCarModelService carModelService;
    
    @PostConstruct
    private void init(){
        List<SysCarModel> carModels = carModelService.list();
        for (SysCarModel carModel : carModels) {
            modelCacheMap.put(carModel.getModelCode(), carModel.getModelName());
        }
    }
    
    public static String getModeName(String modelCode) {
        return modelCacheMap.get(modelCode);
    }
    
    public static boolean contains(String modelCode) {
        return modelCacheMap.containsKey(modelCode);
    }
    
}