当前位置:网站首页>53: Chapter 5: develop admin management service: 6: develop [admin administrator exit login, interface]; (one point: when we want to modify a value with a certain coding method, the new value should b

53: Chapter 5: develop admin management service: 6: develop [admin administrator exit login, interface]; (one point: when we want to modify a value with a certain coding method, the new value should b

2022-07-28 02:08:00 Small withered forest

explain :

(1) The content of this blog : Development 【admin The administrator logs out , Interface 】;

(2) One point : When we want to modify a value with some coding method , The new value is best encoded in this way , Go ahead and revise ;

          ●  namely , hypothesis a="df", Then the encoding method is “UTF-8”; then , We want to put a It is amended as follows "fg" When ,"fg" It's better to use "UTF-8" Encoding , Then pour this new value into a;

Catalog

1. stay 【api】 Interface Engineering AdminMngControllerApi Interface , Definition 【admin The administrator logs out , Interface 】;

2. stay 【admin】 Managed services AdminMngController Class , To achieve 【admin The administrator logs out , Interface 】;

3. effect ;


Log out , It's mainly about " User login information " Scavenging ; namely , Clear to Redis Stored in token; Clear previously saved in cookie Users in aid and atoken Etc ;

stay 【39: The third chapter : Developing a pass service :22: Log out & Log off the session ;】 in , What we develop is that ordinary users log out ; It and the administrator user of this blog log out , almost ;

 

1. stay 【api】 Interface Engineering AdminMngControllerApi Interface , Definition 【admin The administrator logs out , Interface 】;

    /**
     * 【admin The administrator logs out , Interface 】;
     * @param adminId
     * @param request
     * @param response
     * @return
     */
    @ApiOperation(value = "admin The administrator logs out ", notes = "admin The administrator logs out ", httpMethod = "POST")
    @PostMapping("/adminLogout") // Set the routing , This needs to be agreed between the front and back ;
    public GraceJSONResult adminLogout(@RequestParam String adminId,
                                       HttpServletRequest request,
                                       HttpServletResponse response);

explain :

(1)  This interface's url、 Request mode 、 Parameters , It's not nonsense , The front and rear ends need to be consistent ;

2. stay 【admin】 Managed services AdminMngController Class , To achieve 【admin The administrator logs out , Interface 】;

    /**
     * 【admin The administrator logs out , Interface 】;
     * @param adminId
     * @param request
     * @param response
     * @return
     */
    @Override
    public GraceJSONResult adminLogout(String adminId,
                                       HttpServletRequest request, HttpServletResponse response) {
        redisOperator.del(REDIS_ADMIN_TOKEN + ":" + adminId);// First , Clear to Redis Stored in token;

        deleteCookie("atoken", request, response);
        deleteCookie("aid", request, response);
        deleteCookie("aname", request, response);
        return null;
    }

explain :

(1)  The logic here and  【39: The third chapter : Developing a pass service :22: Log out & Log off the session ;】 The practice in is exactly the same ; It's just , Delete cookie The logic of , We drew out a method alone ; 

(2) Here we need to pay attention to a development time , Suggested points to follow :

          ●  We are facing cookie When setting the value in , All of them adopt 【URLEncoder.encode( String to be encoded , “UTF-8“);】 It's encoded ; namely , here cookie The values in are in the above encoded format ;

          ●  that , We are revising cookie When it's worth , This value , It's best to use 【URLEncoder.encode( String to be encoded , “UTF-8“);】 Encoding ;

          ●  This helps , Avoid many possible 、 Strange questions ;( Especially in the production environment )

          ●  For this point , I feel a little bit ; but , In fact, it is not very clear , Not thoroughly understood ;

3. effect ;

First, the whole situation install Look at the whole project ; then , Start the front-end project ; Remember to use SwitchHost Open virtual domain name mapping ; start-up 【admin】 The main startup class of the management service ;

……………………………………………………

原网站

版权声明
本文为[Small withered forest]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/209/202207280019557059.html