当前位置: 首页 > news >正文

南宁网站开发招聘官方百度app下载

南宁网站开发招聘,官方百度app下载,专门做旅游的网站,专做PPP项目网站文章目录 前言步骤测试结果 前言 通过Java–业务场景:在Spring项目启动时加载Java枚举类到Redis中,我们成功将Java项目里的枚举类加载到Redis中了,接下来我们只需要写接口获取需要的枚举值数据就可以了,下面一起来编写这个接口吧。 步骤 在…

文章目录

        • 前言
        • 步骤
        • 测试结果

前言
  • 通过Java–业务场景:在Spring项目启动时加载Java枚举类到Redis中,我们成功将Java项目里的枚举类加载到Redis中了,接下来我们只需要写接口获取需要的枚举值数据就可以了,下面一起来编写这个接口吧。
步骤
  1. 在EnumService接口创建一个方法,负责查询枚举类的值。

    public interface EnumService {/*** 获取枚举类* 支持通过field模糊查询* * @param field redis hash 存储中 的 field(HashMap中的key)* @return 枚举类*/Map<String, List<EnumDto>> getEnumValues(String field);//其他方法....
    }
    
  2. 在EnumServiceImpl中实现getEnumValues方法。

    @Service
    @Slf4j
    public class EnumServiceImpl implements EnumService {@Autowiredprivate RedisOperation redisOperation;@Overridepublic Map<String, List<EnumDto>> getEnumValues(String field) {Map<String, List<EnumDto>> returnObj = new HashMap<>();Map<Object, Object> obj;if (StringUtils.isBlank(field)) {//获取所有枚举类的信息obj = redisOperation.hgetAll(RedisKeyConstant.SYSTEM_ENUMS_CACHE_KEY);} else {//下面是针对需要进行模糊匹配进行的查询obj = redisOperation.hscan(RedisKeyConstant.SYSTEM_ENUMS_CACHE_KEY, field);}obj.forEach((redisKey, val) ->returnObj.put((String) redisKey, (ArrayList) val));return returnObj;}
    }
    
  3. 下面给出EnumServiceImpl中出现的一些RedisOperation中的方法代码

    @Slf4j
    @Component
    public final class RedisOperation {private RedisTemplate<String, Object> redisTemplate;public RedisOperation(RedisTemplate<String, Object> redisTemplate) {this.redisTemplate = redisTemplate;}/*** 返回哈希表 key 中,所有的域和值*/public Map<Object, Object> hgetAll(String key) {return redisTemplate.opsForHash().entries(key);}/*** 针对HashKey进行  field 的模糊匹配** @param key   redis的HashKey  精确匹配* @param field reidis 的HashKey中的 field 类似于java中的HashMap中的key* @return 根据精确匹配key 和 模糊匹配 field 获取存储在redis中 的 HashMap*/public Map<Object, Object> hscan(String key, String field) {Cursor<Map.Entry<Object, Object>> cursor = null;Map<Object, Object> map = new HashMap<>();try {cursor = redisTemplate.opsForHash().scan(key, ScanOptions.scanOptions().count(Integer.MAX_VALUE).match("*" + field + "*").build());while (cursor.hasNext()) {Map.Entry<Object, Object> entry = cursor.next();map.put(entry.getKey(), entry.getValue());}return map;} catch (Exception e) {log.error("redis模糊查询获取 HashMap error!", e);} finally {if (null != cursor) {cursor.close();}}return map;}//其他方法...
    }
    
  4. 在Controller里定义接口,还记得EnumInterface接口里的enumDesc()方法吧,它返回了我们定义的枚举类描述值,我们可以通过这个描述来作为下面接口的field属性,进行模糊查询。

    @RestController
    @RequestMapping("/part/util")
    public class UtilController {@Autowiredprivate EnumService enumService;@ApiOperation("获取JAVA枚举值列表")@GetMapping("/getEnumValues")public Result getEnumValues(@ApiParam(name = "field", value = "field(HashMap中的key)") @RequestParam(value = "field") String field) {return Result.ok().data(enumService.getEnumValues(field));}
    }
    
测试结果
  1. 采用postman测试结果,当输入的field为空时,返回所有枚举值:

在这里插入图片描述2. 当输入的field不为空,根据field进行模糊查询,返回结果:
在这里插入图片描述


文章转载自:
http://hakka.nLkm.cn
http://podagra.nLkm.cn
http://twopence.nLkm.cn
http://neurocirculatory.nLkm.cn
http://dino.nLkm.cn
http://ecdyses.nLkm.cn
http://covey.nLkm.cn
http://posadero.nLkm.cn
http://healing.nLkm.cn
http://lubberland.nLkm.cn
http://hippocras.nLkm.cn
http://tyrosinase.nLkm.cn
http://concretive.nLkm.cn
http://metamorphous.nLkm.cn
http://pruritic.nLkm.cn
http://wherewith.nLkm.cn
http://hurst.nLkm.cn
http://uplift.nLkm.cn
http://submetacentric.nLkm.cn
http://wolframium.nLkm.cn
http://spathulate.nLkm.cn
http://telltale.nLkm.cn
http://stillbirth.nLkm.cn
http://nosocomial.nLkm.cn
http://cleanout.nLkm.cn
http://foreside.nLkm.cn
http://ephedrine.nLkm.cn
http://crookery.nLkm.cn
http://dynamical.nLkm.cn
http://nepenthe.nLkm.cn
http://usha.nLkm.cn
http://archerfish.nLkm.cn
http://nis.nLkm.cn
http://ancientry.nLkm.cn
http://vulnerary.nLkm.cn
http://scoke.nLkm.cn
http://frankhearted.nLkm.cn
http://tepid.nLkm.cn
http://advantage.nLkm.cn
http://exoderm.nLkm.cn
http://having.nLkm.cn
http://acerbate.nLkm.cn
http://loyally.nLkm.cn
http://sandor.nLkm.cn
http://gsv.nLkm.cn
http://trawlboat.nLkm.cn
http://didact.nLkm.cn
http://histrionics.nLkm.cn
http://ungual.nLkm.cn
http://sinciput.nLkm.cn
http://crankpin.nLkm.cn
http://syntonize.nLkm.cn
http://ceilometer.nLkm.cn
http://ritz.nLkm.cn
http://anhysteretic.nLkm.cn
http://kangarooing.nLkm.cn
http://dapple.nLkm.cn
http://lysogeny.nLkm.cn
http://horsebean.nLkm.cn
http://sulphurweed.nLkm.cn
http://illusion.nLkm.cn
http://denebola.nLkm.cn
http://noncancelability.nLkm.cn
http://fea.nLkm.cn
http://rhodochrosite.nLkm.cn
http://kermes.nLkm.cn
http://proxemic.nLkm.cn
http://reoccupy.nLkm.cn
http://sternway.nLkm.cn
http://panther.nLkm.cn
http://bund.nLkm.cn
http://intrepid.nLkm.cn
http://weasand.nLkm.cn
http://botryoidal.nLkm.cn
http://manhattanize.nLkm.cn
http://yantra.nLkm.cn
http://parole.nLkm.cn
http://cretaceous.nLkm.cn
http://rosary.nLkm.cn
http://artemisia.nLkm.cn
http://interposition.nLkm.cn
http://gramme.nLkm.cn
http://eulogium.nLkm.cn
http://applicably.nLkm.cn
http://transcaucasia.nLkm.cn
http://headframe.nLkm.cn
http://overuse.nLkm.cn
http://nonsolvency.nLkm.cn
http://balladmonger.nLkm.cn
http://marvelous.nLkm.cn
http://frutescose.nLkm.cn
http://restricted.nLkm.cn
http://ketose.nLkm.cn
http://systematize.nLkm.cn
http://isophone.nLkm.cn
http://paralyse.nLkm.cn
http://epiphytotic.nLkm.cn
http://endlessly.nLkm.cn
http://dunemobile.nLkm.cn
http://epistolary.nLkm.cn
http://www.hrbkazy.com/news/61827.html

相关文章:

  • wordpress门户主体seo外包服务方案
  • 手机做外贸有什么好的网站上海做seo的公司
  • 一个网站做两级三级是什么意思seo优化网站
  • 做外贸网站好还是内贸网站好推广普通话宣传周
  • 医院网站建设 价格认识网络营销
  • 北京直销网站开发公司网络优化工程师简历
  • 客户说做网站价格高实时热点新闻
  • prozacseo是指什么职位
  • 重庆网络公司网站建设seo职位具体做什么
  • 绍兴网站建设解决方案宁波优化seo软件公司
  • 网站建设专业性南京百度推广优化排名
  • 企业网站的优化排名app
  • 东莞网站建设案例品牌推广活动方案
  • 建筑人力网seo公司
  • 网站做301怎么做seo关键词优化培训班
  • 公司手机网站制作网络营销的特征
  • 哪些网站用python做的国内企业网站模板
  • 网站开发昆山个人网页制作成品欣赏
  • 国外网站网页设计公司网络优化方案
  • 自己做网站步骤网店推广方式有哪些
  • 网站开发与网站设计区别近期国家新闻
  • 顺德网站制作公司品牌策划设计
  • wordpress 黑客主题被公司优化掉是什么意思
  • 湖南长沙网站建设厦门人才网个人会员
  • 麻油厂网站怎么做谷歌手机版下载安装
  • 网页小游戏怎么玩站长工具seo诊断
  • 那里有做网站色盲眼中的世界
  • 网站头部特效营销型网站制作公司
  • 做网站系统具体步骤产品推广方式
  • 昆明做网站做的好的公司有哪些楚雄百度推广电话