Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/rpamis-security-docs/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "radix-nova",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "",
"css": "src/app/global.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"iconLibrary": "lucide",
"rtl": false,
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"menuColor": "default",
"menuAccent": "subtle",
"registries": {
"@react-bits": "https://reactbits.dev/r/{name}.json"
}
}
4 changes: 4 additions & 0 deletions docs/rpamis-security-docs/content/docs/architecture.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Rpamis-security 是基于 MyBatis 插件开发的企业级数据安全组件,

### 🚨 问题分析

[Rapmis-Security技术背景](https://benym.cn/notes/08-open-source-project/01-rpamis/03-security/02-rpamis-security-technical-background)

在传统的企业应用开发中,数据安全处理通常存在以下痛点:

1. **繁琐的脱敏操作**:需要在每一个需要脱敏的接口中手动处理
Expand All @@ -23,6 +25,8 @@ Rpamis-security 是基于 MyBatis 插件开发的企业级数据安全组件,

### 💡 解决方案

[Rpamis-security-原理解析](https://benym.cn/notes/08-open-source-project/01-rpamis/03-security/03-rpamis-security-principle-analysis)

Rpamis-security 提供了以下解决方案:

- **注解式编程**:使用注解标记需要处理的字段和方法,简化开发
Expand Down
153 changes: 2 additions & 151 deletions docs/rpamis-security-docs/content/docs/examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ public class OrderController {

### 1. 嵌套实体脱敏

采用`@NestedMasked`标记嵌套脱敏实体,如`UserDetailVO`中包含`ContactInfoVO`实体,`ContactInfoVO`中包含`@Masked`标记需要脱敏字段

```java
@Data
public class UserDetailVO implements Serializable {
Expand Down Expand Up @@ -520,101 +522,6 @@ public class OrderController {
}
```

### 2. 用户管理系统

```java
@Data
@TableName(value ="users")
public class UserDO implements Serializable {
private static final long serialVersionUID = 1L;

@TableId(value = "id", type = IdType.AUTO)
private Long id;

@TableField(value = "username")
private String username;

@TableField(value = "password")
@SecurityField
private String password;

@TableField(value = "email")
@SecurityField
private String email;

@TableField(value = "phone")
@SecurityField
private String phone;

@TableField(value = "id_card")
@SecurityField
private String idCard;

@TableField(value = "create_time")
private LocalDateTime createTime;
}

@Data
public class UserProfileVO implements Serializable {
private static final long serialVersionUID = 1L;

private Long id;
private String username;

@Masked(type = MaskType.EMAIL_MASK)
private String email;

@Masked(type = MaskType.PHONE_MASK)
private String phone;

@Masked(type = MaskType.IDCARD_MASK)
private String idCard;

private String createTime;
}

@RestController
@RequestMapping("/api/users")
public class UserController {

@Autowired
private UserService userService;

@PostMapping("/register")
public void register(@RequestBody UserDO user) {
user.setCreateTime(LocalDateTime.now());
userService.saveUser(user);
}

@GetMapping("/profile/{id}")
@Desensitizationed
public UserProfileVO getProfile(@PathVariable Long id) {
UserDO userDO = userService.getUser(id);
UserProfileVO vo = new UserProfileVO();
vo.setId(userDO.getId());
vo.setUsername(userDO.getUsername());
vo.setEmail(userDO.getEmail());
vo.setPhone(userDO.getPhone());
vo.setIdCard(userDO.getIdCard());
vo.setCreateTime(userDO.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
return vo;
}
}
```

**返回结果:**

```json
{
"id": 2,
"username": "john_doe",
"email": "joh****@example.com",
"phone": "136****5678",
"idCard": "110***********3329",
"createTime": "2024-01-15"
}
```

## ⚡ 高级用法示例

### 1. 自定义切点表达式
Expand Down Expand Up @@ -683,59 +590,3 @@ public class SecurityConfig {
}
}
```

## 🚀 性能优化示例

### 1. 批量操作优化

```java
@Service
public class BatchService {

@Autowired
private BatchMapper batchMapper;

@Transactional
public void batchInsert(List<DataDO> dataList) {
// 使用 MyBatis 的 foreach 批量插入
batchMapper.batchInsert(dataList);
}
}

@Mapper
public interface BatchMapper {
void batchInsert(@Param("list") List<DataDO> dataList);
}
```

```xml
<mapper namespace="com.example.mapper.BatchMapper">
<insert id="batchInsert">
INSERT INTO data_table (field1, field2, field3)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.field1}, #{item.field2}, #{item.field3})
</foreach>
</insert>
</mapper>
```

### 2. 查询优化

```java
@Service
public class QueryService {

@Autowired
private QueryMapper queryMapper;

public List<DataVO> queryByCondition(String keyword) {
List<DataDO> dataList = queryMapper.selectByKeyword(keyword);
return dataList.stream()
.map(this::convertToVO)
.collect(Collectors.toList());
}
}
```

**说明:** 加解密操作会带来一定的性能开销,建议合理使用。
10 changes: 10 additions & 0 deletions docs/rpamis-security-docs/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ const config = {
// 临时禁用类型检查以避免构建失败
ignoreBuildErrors: true,
},
// 性能优化配置
compress: true,
images: {
formats: ['image/avif', 'image/webp'],
minimumCacheTTL: 60,
unoptimized: true, // 静态导出模式需要
},
compiler: {
removeConsole: process.env.NODE_ENV === 'production',
},
};

export default withMDX(config);
10 changes: 10 additions & 0 deletions docs/rpamis-security-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,34 @@
"@radix-ui/react-popover": "^1.1.15",
"@radix-ui/react-presence": "^1.1.5",
"@radix-ui/react-tabs": "^1.1.13",
"@react-three/fiber": "^9.3.0",
"@react-three/postprocessing": "^3.0.4",
"@takumi-rs/image-response": "^0.70.4",
"ai": "^6.0.116",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"d3-force": "^3.0.0",
"fumadocs-core": "16.6.10",
"fumadocs-mdx": "14.2.9",
"fumadocs-ui": "16.6.10",
"gsap": "^3.14.2",
"hast-util-to-jsx-runtime": "^2.3.6",
"lucide-react": "^0.577.0",
"motion": "^12.23.12",
"next": "16.1.6",
"postprocessing": "^6.36.0",
"radix-ui": "^1.4.3",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"react-force-graph-2d": "^1.29.1",
"react-medium-image-zoom": "^5.4.1",
"remark": "^15.0.1",
"remark-gfm": "^4.0.1",
"remark-rehype": "^11.1.2",
"shadcn": "^4.0.6",
"tailwind-merge": "^3.5.0",
"three": "^0.167.1",
"tw-animate-css": "^1.4.0",
"unist-util-visit": "^5.1.0",
"zod": "^4.3.6"
},
Expand Down
Loading
Loading