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

汽车4s网站设计做外贸是不是要有网站

汽车4s网站设计,做外贸是不是要有网站,做网站ps的图片,星辰博客wordpress一、需求背景 需要给一份问卷进行授权#xff0c;授权的角色固定为4类#xff0c;分别是#xff1a; 农户、企业、金融机构、政府用户#xff0c;这4类角色定义在字典里面#xff0c;并且很少改动。这4类角色下面#xff0c;可能有多个角色#xff0c;这些角色通过字典的…一、需求背景 需要给一份问卷进行授权授权的角色固定为4类分别是 农户、企业、金融机构、政府用户这4类角色定义在字典里面并且很少改动。这4类角色下面可能有多个角色这些角色通过字典的key关联到上述4个类型中的一个;       在新增、编辑问卷的时候需要把这4类所有的角色都展示出来供管理员选择。 二、需求分析 由于涉及到的数据很少改动且主要以查询为主于是第一想法就是通过 枚举链对实现,具体实现如下: 三、实现过程 1. 枚举类 import lombok.Getter; import lombok.Setter;import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; import java.util.stream.Stream;import static com.xxx.xxx.utils.StreamUtil.forEachIfPresent;/*** Author: wxz* Date: 2023.11.29 10:35* Description: 问卷调查授权枚举*/ public enum PaperAuthorRoleEnum {ANONYMITY(un-limit, 不限, Collections.singletonList()),AGRICULTURAL(member, 农户,Collections.singletonList(member)),ENTERPRISE(enterprises, 企业, Collections.singletonList(agricultural-enterprises)),FINANCIAL_INSTITUTION(finance, 金融机构,FinanceRoleKeys()),GOVERNMENT_USERS(government, 政府用户, GovernmentRoleKeys()),;/*** 角色类型*/Getterprivate final String type;/*** 角色类型名称*/Getterprivate final String typeName;/*** 角色id集合*/Getterprivate final ListString roleKeys;/*** 角色列表*/Getterprivate final ListPaperRole paperRoleList;/*** 角色缓存数据*/private static MapString, SysRole roleCache new ConcurrentHashMap();PaperAuthorRoleEnum(String type, String typeName, ListString roleKeys) {this.type type;this.typeName typeName;this.roleKeys roleKeys;this.paperRoleList getRolesFromCache(roleKeys);}/*** 根据角色类型查找枚举* param type 角色类型* return 类型枚举*/public static PaperAuthorRoleEnum of(String type) {if (type null) {return null;}PaperAuthorRoleEnum[] values PaperAuthorRoleEnum.values();for (PaperAuthorRoleEnum a : values) {if (a.type.equals(type)) {return a;}}return null;}/*** 金融机构角色keys*/private static ListString FinanceRoleKeys() {ListString list new ArrayList();//银行机构有5个等级for (int i 1; i 5; i) {list.add(bank_level_ i);}return list;}/*** 政府角色keys*/private static ListString GovernmentRoleKeys() {return new ArrayList(Arrays.asList(collector,government,government-role));}/*** 获取所有枚举的keys* return*/private ListString getAllRolKeys() {ListString roleKeys new ArrayList();roleKeys.addAll(Collections.singletonList(member));roleKeys.addAll(Collections.singletonList(agricultural-enterprises));roleKeys.addAll(FinanceRoleKeys());roleKeys.addAll(GovernmentRoleKeys());return roleKeys;}/*** 从缓存中获取角色列表* param roleKeys* return*/private ListPaperRole getRolesFromCache(ListString roleKeys) {ListPaperRole paperRoles new ArrayList();SetString notExitKeys new HashSet();boolean sign (roleCache null);//如果已经存在缓存里面,则优先从缓存里面获取if (sign) {notExitKeys.addAll(getAllRolKeys());roleCache new ConcurrentHashMap();} else {roleKeys.forEach(key - {if (!roleCache.containsKey(key)) {notExitKeys.add(key);} else {PaperRole paperRole new PaperRole().setRoleId(roleCache.get(key).getRoleId()).setRoleName(roleCache.get(key).getRoleName());paperRoles.add(paperRole);}});}//不存在于缓存的数据,重新从数据库里面查询出来,放在缓存里面if (notExitKeys.size() 0) {OptionalListSysRole sysRoles Optional.ofNullable(SpringUtils.getBean(SysRoleMapper.class).selectListByRoleKeys(new ArrayList(notExitKeys)));// forEachIfPresent()方法参考: https://blog.csdn.net/qq_37844454/article/details/134964619forEachIfPresent(sysRoles,item-{roleCache.put(item.getRoleKey(), item);PaperRole paperRole new PaperRole().setRoleId(item.getRoleId()).setRoleName(item.getRoleName());paperRoles.add(paperRole);});}return paperRoles;}/*** 获取所有的枚举*/public static PaperAuthorRoleEnum[] getValues() {return new PaperAuthorRoleEnum[]{AGRICULTURAL, ENTERPRISE, FINANCIAL_INSTITUTION, GOVERNMENT_USERS};} }2. 控制器调用 //使用线程安装的链对做缓存,避免读多写少的数据频繁请求数据库private static ConcurrentLinkedQueuePaperAuthorTypeDTO dtoQueue new ConcurrentLinkedQueue();GetMapping(value /getRoleList)public AjaxResult getRoleList() {if (CollectionUtils.isEmpty(dtoQueue)) {dtoQueue new ConcurrentLinkedQueue();Arrays.stream(PaperAuthorRoleEnum.getValues()).forEach(anEnum-{dtoQueue.offer(new PaperAuthorTypeDTO().setRoleId(anEnum.getType()).setRoleName(anEnum.getTypeName()));});}return AjaxResult.success(dtoQueue);}
http://www.huolong8.cn/news/266583/

相关文章:

  • 视频网站搭建源码网站logo设计教程
  • 张家口市住房和城乡建设局网站郑州seo关键词推广
  • 上海网站建设觉策动力软件工程师证书有哪些
  • 怀化做网站的公司网站开发完没人运营
  • 莱芜网站优化有哪些谷歌云做网站服务器
  • 网页设计与制作课程定位沈阳网站建设seo优化
  • 上海建科建设监理网站网站文案技巧
  • 中国城市建设网站遵义网站建设哪家好?
  • 医院网站建设的规划wordpress手机全部显示图片
  • 济南卓远网站建设关于网站开发的文章
  • 深圳网站建设服务公司阿里云9元做网站
  • 昆明企业网站制作东莞招标网官网
  • 淘宝营销网站建设成都网站seo费用
  • 电信的网做的网站移动网打不开该找电信还是移动企业网站系统有哪些
  • pc网站做成移动网站东营网站seo外包
  • wordpress新增站点滕州盛扬网站建设推广
  • cn体育门户网站源码网站平台建设需要多少钱
  • python 做办公网站添加网站绑定主机名
  • 帮做简历哪个网站好cms系统源码
  • 律师网站设计织梦网站建设选项卡教程
  • 秦皇岛公司做网站免费国外服务器地址
  • 冲浪网站优化网seo短视频发布页
  • 史志网站建设方案无锡市新吴区住房和建设交通局网站
  • 做爰全过程免费的视频网站wordpress使用memcached
  • 新浪微博 ssc网站建设设计网红打卡
  • 九网互联怎么建设网站招人在哪里找最快
  • 网站从建设到赚钱的流程廊坊网站建设墨子
  • 免x网站网页制作页面布局
  • 网站怎么做内链接地址营销推广模式有哪些
  • 免费申请二级网站源码长沙企业网站建设企业