diff --git a/项目管理库/诺唯赞CRM项目/CRM模块拆解分析/国际化组件.md b/项目管理库/诺唯赞CRM项目/CRM模块拆解分析/国际化组件.md new file mode 100644 index 0000000..34d11a3 --- /dev/null +++ b/项目管理库/诺唯赞CRM项目/CRM模块拆解分析/国际化组件.md @@ -0,0 +1,106 @@ +## 描述 + +提供前后端在请求中得国别进行对应语言的渲染 将国际化语言持久化到mysql提供实时管理,缓存到redis 提供服务模块的快速加载 前端通过api加载完成页面国际化;后端通过redis 快速加载,通过字典注解、工具类完成列表查询内容国际化 + +## 使用方法 + +1. 以组件方式引入在当前 springboot 工程引入 组件包 + + + + net.rzdata + rz-i18n + 0.0.2-SNAPSHOT + + +2. 组件包扫描包 + + + @ComponentScan(basePackages = {"org.example","com.blueland"}) + @MapperScan(basePackages = {"org.example","com.blueland.common.core.mapper"}) + @EnableAutoConfiguration + public class App { + public static void main(String[] args) { + SpringApplication.run(App.class, args); + } + ​ + } + +3. 增加配置文件 application.yml + + + server: + port: 8080 + servlet: + context-path: /crm-internation + session: + cookie: + name: crm-internation + ​ + spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + driver-class-name: com.mysql.cj.jdbc.Driver + username: crm + password: crm@123 + url: jdbc:mysql://192.168.1.13:3308/crm_usm?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 + redis: + database: 9 + host: 192.168.1.169 + password: '' + tm: + secretId: AKID4IXccMhHdjcJm0wqPjndHhspkbDbGeJz + secretKey: aw3v5B3h8OPQO7j8JPGsFNHwMXTAcprf + ​ + logging: + level: + com.blueland.common.core: debug + mybatis-flex: + type-aliases-package: com.blueland.common.core.domain + ​ + ​ + knife4j: + enable: true + openapi: + title: 国际化接口文档 + group: + test1: + group-name: 国际化 + api-rule: package + api-rule-resources: + - com.blueland.common.core.controller + +5. 创建数据库表: + + + CREATE TABLE `t_international` ( + `id` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '唯一ID', + `code` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '国际化编码', + `name` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '名称', + `lang` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '语言', + `type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '标识(前端:front,后端:back)', + `tenant_id` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '租户号', + `create_by` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + KEY `idx_code` (`code`) USING BTREE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='国际化'; + +## 运行截图: + +![image.png](https://cdn.nlark.com/yuque/0/2024/png/26863921/1708918222284-94896b8a-4c4c-4ab8-b228-8fa689d780e2.png#averageHue=%232f2e2d&clientId=uf576b4f5-f628-4&from=paste&height=718&id=u972a6e59&originHeight=718&originWidth=1723&originalType=binary&ratio=1&rotation=0&showTitle=false&size=221205&status=done&style=none&taskId=u51532904-5ba5-4f01-aa5d-7cf98118a94&title=&width=1723) 访问接口文档: ![image.png](https://cdn.nlark.com/yuque/0/2024/png/26863921/1708918274171-14c13808-c22a-47c6-84db-a98edd8dc1be.png#averageHue=%23be9c72&clientId=uf576b4f5-f628-4&from=paste&height=959&id=u2c7cf92d&originHeight=959&originWidth=1607&originalType=binary&ratio=1&rotation=0&showTitle=false&size=107645&status=done&style=none&taskId=u0138a98a-a3c3-422c-8920-71565fc8ace&title=&width=1607) 请求接口: ![image.png](https://cdn.nlark.com/yuque/0/2024/png/26863921/1708918649480-cff7c46e-6506-490a-b1a1-162867e3c624.png#averageHue=%23fdfbfa&clientId=uf576b4f5-f628-4&from=paste&height=867&id=u6aca93a3&originHeight=867&originWidth=1654&originalType=binary&ratio=1&rotation=0&showTitle=false&size=134494&status=done&style=none&taskId=u641451b3-696d-43be-865c-a904d6db947&title=&width=1654) + +## 前端接入: + +请求前端接口:**GET** /crm-internation/international/findLangPackage header: tenantid:MID 参数: type:front ![image.png](https://cdn.nlark.com/yuque/0/2024/png/26863921/1708931507239-516315b6-bbde-4513-b021-8179c36ebc1c.png#averageHue=%23f9f8f7&clientId=uf576b4f5-f628-4&from=paste&height=595&id=u9ee4153c&originHeight=595&originWidth=1630&originalType=binary&ratio=1&rotation=0&showTitle=false&size=140201&status=done&style=none&taskId=u2820ac66-8d1d-4fed-b960-b17f202080c&title=&width=1630) ![c24e2f6e1f9bb509bf990111fab8597.png](https://cdn.nlark.com/yuque/0/2024/png/26863921/1708931474795-2e7ea2be-9e82-4aff-a980-276d5bc8dbe5.png#averageHue=%23201f1f&clientId=uf576b4f5-f628-4&from=paste&height=850&id=ueb36920d&originHeight=850&originWidth=935&originalType=binary&ratio=1&rotation=0&showTitle=false&size=52457&status=done&style=none&taskId=u306381a7-a1a3-469e-91d8-e0ee8ccb45b&title=&width=935) + +## 后端接入: + +## 前端接入: + +请求前端接口:**GET** /crm-internation/international/findLangPackage header: tenantid:MID 参数: type:back + \ No newline at end of file