Skip to content

acshmily/spring-boot-mask-info-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Use Guide

maven

<dependency>
  <groupId>com.github.acshmily</groupId>
  <artifactId>mask-info-spring-boot-starter</artifactId>
  <version>1.1</version>
</dependency>

Enable Mask AOP

In your SpringBoot ApplicationRunner Class add announce to enable,like

import com.github.acshmily.maskinfo.announce.EnableInfoMask;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableInfoMask // enable mask aop
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
    }
}

Modify your pojo

@Data
public class UserDemo {
    @MaskType(Strategy = MaskType.Strategy.NAME)
    private String name;
    private String age;
    @MaskType(Strategy = MaskType.Strategy.MOBILE)
    private String phone;
    @MaskType(Strategy = MaskType.Strategy.IP)
    private String ip;
    @MaskType(Strategy = MaskType.Strategy.BANKCARD)
    private String bankCard;
    @MaskType(Strategy = MaskType.Strategy.IDCARD)
    private String idCard;
}

Modify your Controller

import com.github.acshmily.maskinfo.announce.Mask;

@RequestMapping
@RestController
public class Controller {
    @Mask
    @RequestMapping("test")
    public R<UserDemo> test(){
        UserDemo user = new UserDemo();
        user.setName("张三");
        user.setAge("13");
        user.setPhone("13800138000");
        user.setBankCard("622522000049631");
        user.setIp("127.0.0.1");
        user.setIdCard("36232920200101000034");
        return R.ok(user);
    }
}

enjoy~~~

About

对于SpringWeb输出被注解的参数进行脱敏

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages