impl
@Service
public class RedisServiceImpl extends ServiceImpl<PmcSystemDictMapper, PmcSystemDict> implements RedisService{
@Autowired
private PmcSystemDictMapper pmcSystemDictMapper;
@Autowired
private StringRedisTemplate stringRedis;
@Override
public JSONObject gitDict(String str) {
if(!stringRedis.hasKey(str)) {
QueryWrapper<PmcSystemDict> queryWrapper = new QueryWrapper<>();
// queryWrapper.select("value").select("label");
queryWrapper.eq("type", str).eq("del_flag","0");
PmcDictListVo PmcDictListVo=new PmcDictListVo();
List<PmcSystemDict> list = pmcSystemDictMapper.selectList(queryWrapper);
List<PmcDictVo> backlist=new ArrayList<PmcDictVo>();
for(int i=0;i<list.size();i++) {
PmcDictVo pdv=new PmcDictVo();
pdv.setLabel(list.get(i).getLabel());
pdv.setValue(list.get(i).getValue());
backlist.add(pdv);
}
PmcDictListVo.setList(backlist);
String jsonString = JSONObject.toJSONString(PmcDictListVo);
stringRedis.opsForValue().set(str, jsonString);
}
String stringKey = stringRedis.opsForValue().get(str);
JSONObject parseObject = JSONObject.parseObject(stringKey);
return parseObject;
}
}
前台vue
getfiveYearPlanlist () {
this.dicttype ='five_year_plan'
getAction('/system/dict/getType', {dicttype:this.dicttype}).then(res => {
this.fiveYearPlan = res.data.data.list
console.log(res.data.data.list)
})
},