当前位置:网站首页>53:第五章:开发admin管理服务:6:开发【admin管理员退出登录,接口】;(一个点:我们想要修改一个采用了某种编码方式的值时,新的值最好也按照这种编码方式编码后,再去修改;)
53:第五章:开发admin管理服务:6:开发【admin管理员退出登录,接口】;(一个点:我们想要修改一个采用了某种编码方式的值时,新的值最好也按照这种编码方式编码后,再去修改;)
2022-07-28 00:20:00 【小枯林】
说明:
(1)本篇博客内容:开发【admin管理员退出登录,接口】;
(2)一个点:我们想要修改一个采用了某种编码方式的值时,新的值最好也按照这种编码方式编码后,再去修改;
● 即,假设a="df",然后其编码方式是“UTF-8”;然后,我们想要把a修改为"fg"的时候,"fg"最好也用"UTF-8"编码一下,然后再把这个新值灌给a;
目录
1.在【api】接口工程的AdminMngControllerApi接口中,定义【admin管理员退出登录,接口】;
2.在【admin】管理服务的AdminMngController类中,去实现【admin管理员退出登录,接口】;
退出登录,主要是把"用户登录信息"进行清除;即,清除向Redis中存放的token;清除以前保存在cookie中的用户aid和atoken等信息;
在【39:第三章:开发通行证服务:22:退出登录&注销会话;】中,我们开发的是普通用户退出登录;其与本篇博客的管理员用户退出登录,差不多;
1.在【api】接口工程的AdminMngControllerApi接口中,定义【admin管理员退出登录,接口】;
/** * 【admin管理员退出登录,接口】; * @param adminId * @param request * @param response * @return */ @ApiOperation(value = "admin管理员退出登录", notes = "admin管理员退出登录", httpMethod = "POST") @PostMapping("/adminLogout") //设置路由,这个是需要前后端约定好的; public GraceJSONResult adminLogout(@RequestParam String adminId, HttpServletRequest request, HttpServletResponse response);说明:
(1) 这个接口的url、请求方式、参数,不是瞎写的,需要前后端保持一致;
2.在【admin】管理服务的AdminMngController类中,去实现【admin管理员退出登录,接口】;
/** * 【admin管理员退出登录,接口】; * @param adminId * @param request * @param response * @return */ @Override public GraceJSONResult adminLogout(String adminId, HttpServletRequest request, HttpServletResponse response) { redisOperator.del(REDIS_ADMIN_TOKEN + ":" + adminId);//首先,清除向Redis中存放的token; deleteCookie("atoken", request, response); deleteCookie("aid", request, response); deleteCookie("aname", request, response); return null; }说明:
(1) 这儿的逻辑和 【39:第三章:开发通行证服务:22:退出登录&注销会话;】中的做法一模一样;只是,删除cookie的逻辑,我们单独抽出了一个方法;
(2)这儿需要注意一个开发时,建议遵守的点:
● 我们前面在向cookie中设置值的时候,其都采用【URLEncoder.encode(待编码字符串, “UTF-8“);】编码了;即,此时cookie中的值都是上述编码的格式;
● 那么,我们在修改cookie中的值的时候,这个值,最好也利用【URLEncoder.encode(待编码字符串, “UTF-8“);】编码一下;
● 这有助于,规避掉很多可能出现的、奇奇怪怪的问题;(尤其是在生产环境中)
● 对于这一点,自己稍微有点感觉;但,其实不是十分明白的,理解的不透彻;
3.效果;
先全局install一下整个项目;然后,启动前端项目;记得使用SwitchHost开启虚拟域名映射;启动【admin】管理服务的主启动类;
……………………………………………………
边栏推荐
- BGP联邦实验
- Gbase 8C backup control function (IV)
- Custom type: structure, enumeration, union
- Graph theory analysis of white matter brain function network: neural markers for classification and prediction of depression
- Unity 通用红点系统
- 小散量化炒股记|量化系统中数据是源头,教你搭建一款普适的数据源框架
- 物企大变局时代,SRM供应商采购系统助力企业打造物业采购数字化标杆
- EEG多元模式分析预测慈善捐赠行为
- GBase 8c 备份控制函数(一)
- JS数字精度丢失的原因及解决方案
猜你喜欢

Blizzard Diablo 4 ps5 / PS4 beta added to Playstation database

ArcGIS:加载历史遥感影像

N32l43x FLASH read \ write \ erase operation summary

LeetCode高频题128. 最长连续序列,经常被互联网大厂面试考到

嵌入式经典通信协议

How tormenting are weekly and monthly reports? Universal report template recommended collection! (template attached)

ue4 unreal NDisplay插件 简易使用 三折幕 详细...

白质脑功能网络图论分析:抑郁症分类和预测的神经标记

"Do you" want to be a test / development programmer? We strive to sprout

Forget the root password
随机推荐
The petrochemical industry is facing the tide of rising prices, and the digital dealer distribution system platform enables dealers and stores
Leveraging the blue ocean of household appliances consumption with "digital channels", the dealer online system enables enterprises to further their business
数据安全与隐私计算峰会-可证明安全:学习
Solution of digital commerce cloud supply chain centralized purchase management system: centralized purchase system management mode, digital control of enterprise materials
二叉树的遍历和性质
开源飞控(PX4、ardupilot)
Gbase 8C transaction ID and snapshot (VI)
Data security and privacy computing summit - provable security: Learning
Linux系统彻底删除Mysql
EEG多元模式分析预测慈善捐赠行为
ArcGIS:加载历史遥感影像
GBase 8c 事务ID和快照(四)
LeetCode高频题128. 最长连续序列,经常被互联网大厂面试考到
JS数字精度丢失的原因及解决方案
Hcip 13th day notes
GBase 8c 事务ID和快照(三)
基于 Flink CDC 实现海量数据的实时同步和转换
The storage cost is reduced by 80%. How does the cost management of youzan data middle office do?
Gbase 8C database object size function (I)
企业运维实践-使用Aliyun容器镜像服务对海外gcr、quay仓库镜像进行镜像拉取构建






