反脱敏组件使用场景指南

反脱敏Controller层使用场景

单对象或字符串场景

1、 对象接收,POST方式

     
    /**
     * 对象接收,POST方式
     * 示例:
     * http://localhost:8080/submitString
     * {
     *     "name":"wangerxiao",
     *     "phone":"${mm('6b6f745a617049347a4e4a4d416e67543033533077773d3d')}",
     *     "ctfNbr":"${mm('7668307430765957633841547a6f76594d6e64626477497477524a697a69676d30443172746534654e42773d')}"
     * }
     *
     * @param params
     * @return
     */
    @PostMapping("/submitJson")
    @ReverseDesensitization
    public String submitJson(@RequestBody User params) {
        logger.info("反脱敏后:{}", JSON.toJSONString(params));
        return JSON.toJSONString(params);
    }

 

2、 接收纯字符,POST方式

/**
     * 接收纯字符,POST方式
     * 示例:
     * http://localhost:8080/submitString
     * body中:
     * wangerxiao ${mm('7a6b666c364c4a534579346531714e524b4d6950625a412b704a44314347455a474c42724575423955346f3d')} ${mm('7668307430765957633841547a6f76594d6e64626477497477524a697a69676d30443172746534654e42773d')} ${mm('4c3739732b503245306373522b4764375361395653513d3d')} ${mm('6b6f745a617049347a4e4a4d416e67543033533077773d3d')}
     *
     * @param desnsiteStr
     * @return
     */
    @PostMapping("/submitString")
    @ReverseDesensitization
    public String submitString(@RequestBody String desnsiteStr) {
        logger.info("反脱敏后:{}", desnsiteStr);
        return desnsiteStr;
     }

3、接收多个字符串入参,POST或者GET方式

 /**
     * 接收多个字符串入参,POST或者GET方式
     *示例:
     * http://localhost:8080/addUser?username=${mm('7668307430765957633841547a6f76594d6e64626477497477524a697a69676d30443172746534654e42773d')}&password=${mm('4c3739732b503245306373522b4764375361395653513d3d')}
     *
     * @return
     */
    @RequestMapping("/addUser")
    @ReverseDesensitization
    public void addUser(String username,String password) {
        logger.info("username is:"+username);
        logger.info("password is:"+password);
    }

4、接收混合Get方式多个入参,GET方式

  /**
     * 接收混合Get方式多个入参,GET方式
     * 示例:
     * http://localhost:8080/${mm('6b6f745a617049347a4e4a4d416e67543033533077773d3d')}?name= ${mm('7668307430765957633841547a6f76594d6e64626477497477524a697a69676d30443172746534654e42773d')}
     * @param id
     * @param name
     */
    @GetMapping("/{id}")
    @ReverseDesensitization
    public void multiSubmit(@PathVariable(name = "id") String id, @RequestParam(name = "name") String name) {
        logger.info("反脱敏id后:{}", id);
        logger.info("反脱敏name后:{}", name);
    }

集合场景

1、List对象接收,POST方式

 /**
     * List对象接收,POST方式
     * 示例:
     * http://localhost:8080/submitListString
     * [{
     *     "name":"wangerxiao",
     *     "phone":"${mm('6b6f745a617049347a4e4a4d416e67543033533077773d3d')}",
     *     "ctfNbr":"${mm('7668307430765957633841547a6f76594d6e64626477497477524a697a69676d30443172746534654e42773d')}"
     * },
     * {
     *     "name":"leifeng",
     *     "phone":"${mm('6b6f745a617049347a4e4a4d416e67543033533077773d3d')}",
     *     "ctfNbr":"${mm('7668307430765957633841547a6f76594d6e64626477497477524a697a69676d30443172746534654e42773d')}"
     * }]
     *
     * @param params
     * @return
     */

    @PostMapping("/submitListJson")
    @ReverseDesensitization
    public String submitListJson(@RequestBody List params) {
        logger.info("反脱敏List后:{}", JSON.toJSONString(params));
        return JSON.toJSONString(params);
    }

2、Map多个不同对象接收

   /**
     * Map多个不同对象接收
     * 示例:
     * http://localhost:8080/submitMap
     * {
     *     "user": {
     *        "name":"wangerxiao",
     *         "phone":"${mm('6b6f745a617049347a4e4a4d416e67543033533077773d3d')}",
     *         "ctfNbr":"${mm('7668307430765957633841547a6f76594d6e64626477497477524a697a69676d30443172746534654e42773d')}"
     *     },
     *     "user2": {
     *         "name":"leifeng",
     *         "phone":"${mm('6b6f745a617049347a4e4a4d416e67543033533077773d3d')}",
     *         "ctfNbr":"${mm('7668307430765957633841547a6f76594d6e64626477497477524a697a69676d30443172746534654e42773d')}"
     *     }
     * }
     * @return
     */
    @PostMapping("/submitMapJson")
    @ReverseDesensitization
    public String submitMapJson(@RequestBody Map map) {
        logger.info("反脱敏后map:{}", JSON.toJSONString(map));

        return JSON.toJSONString(map);

    }

Postman全场景测试

你可能感兴趣的:(反脱敏组件使用场景指南)