From 7f0f0ab2e3cf6aa2911e3a77ee16926b0aac94df Mon Sep 17 00:00:00 2001 From: mengqiang <> Date: Sun, 7 Feb 2021 11:16:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sso-auth-center-service/README.md | 101 ++++++++++++++++++ sso-auth-center-service/pom.xml | 2 +- .../java/com/sso/security/SecurityConfig.java | 6 +- sso-auth-center-service/sso-business/pom.xml | 2 +- sso-auth-center-service/sso-common/pom.xml | 2 +- 5 files changed, 107 insertions(+), 6 deletions(-) diff --git a/sso-auth-center-service/README.md b/sso-auth-center-service/README.md index f776ebd..58b5045 100644 --- a/sso-auth-center-service/README.md +++ b/sso-auth-center-service/README.md @@ -1,3 +1,104 @@ # sso-auth-center 统一认证中心服务端 + + +工程模块介绍 + +| **工程模块** | **名称** | **备注** | +| --- | --- | --- | +| sso-auth-center-service | 父工程 | 定义统一依赖版本等 | +| sso-auth-center-admin | 后台web,统一开放网关 | boot项目,后台controller层 | +| sso-business | dao与业务层 | dao层,service层 | +| sso-common | 公共部分 | 工具类、常量类、注解、枚举、业务自定义异常 | +| sso-framework | 核心配置 | 数据源配置、redis配置、验证码、统一异常处理 等 | + + + +类命名规范
+ +| **所属层级** | **名称规则** | **备注** | +| --- | --- | --- | +| DAO层 | entity | entity包下与数据库表一致的实体 | +| | xxxMapper | 与表一致的Mapper | +| | xxxDTO | 中间转换对象,比如关联sql的返回对象 | +| | xxxQuery | dao层查询对象 | +| service层 | xxxBaseService | 公共service,比如用户公共接口,在业务service多次使用的方法 | +| | xxxBaseServiceImpl | | +| | xxxService | 业务 service层 | +| | xxxServiceImpl | 业务service层实现 | +| controller层入参 | xxxAddBO或xxxUpdateBO | 新增业务入参 | +| | xxxEditBO | 修改业务入参 | +| | xxxListPageBO | 分页查询入参需要继承公共分类 BasePageModel | +| controller层出参 | xxxPageVO或xxxListVO | 分页列表返回对象 | +| | xxxDetailVO | 查询详情返回对象 | +| | xxxCountVO | 统计业务返回对象 | +| | xxOptionVO | 下拉选项返回对象 | + + + + +接口命名规范
+ +| | **请求方式** | **备注** | +| --- | --- | --- | +| /listPage | get | 分页列表 | +| /listxxPage | get | 分页列表 | +| /listxxx | get | 不分页的列表 | +| /detail/{id} | get | _获取用户详细信息_ | +| /getxxx | get | 其它详情接口 | +| /add | post | 新增接口 | +| /update 或/edit | put或post | 修改接口 | +| /delete/{id} | / | 删除接口 | +| | | | + +公共返回类
+ +| | **类名** | **常用方法** | +| --- | --- | --- | +| 公共类 | ResultModel | ResultModel._success_(业务object内容)
ResultModel._error_("失败原因") | +| 分页接口公共类 | ResultPageModel | ResultPageModel._success_(resultList,rowCount) | + + +分页接口统一返回结构
+ +| **参数** | **说明** | | +| --- | --- | --- | +| code | 成功 | 200成功,非200失败 | +| total | 总条数 | | +| data [] | 当前页内容列表 | | +| msg | | | + +JSON示例
+ +```json +{ + "code": 200, + "total": 16213, + "data": [ + { + "id": 1, + "name": "张三" + } + ], + "msg": "操作成功" +} +``` + +
详情接口统一返回结构 + +| **参数** | **说明** | | +| --- | --- | --- | +| code | 成功 | 200成功,非200失败 | +| data | object类型对象 | | +| msg | | | + +JSON示例
+ +```json +{ + "code": 200, + "data": {}, + "msg": "操作成功" +} +``` diff --git a/sso-auth-center-service/pom.xml b/sso-auth-center-service/pom.xml index c829466..12b53d8 100755 --- a/sso-auth-center-service/pom.xml +++ b/sso-auth-center-service/pom.xml @@ -165,7 +165,7 @@ ${sso-auth-center.version} - + com.sso sso-common diff --git a/sso-auth-center-service/sso-auth-center-admin/src/main/java/com/sso/security/SecurityConfig.java b/sso-auth-center-service/sso-auth-center-admin/src/main/java/com/sso/security/SecurityConfig.java index 24ce51c..d7ff3a8 100755 --- a/sso-auth-center-service/sso-auth-center-admin/src/main/java/com/sso/security/SecurityConfig.java +++ b/sso-auth-center-service/sso-auth-center-admin/src/main/java/com/sso/security/SecurityConfig.java @@ -90,9 +90,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity httpSecurity) throws Exception { httpSecurity - // CSRF禁用,因为不使用session + // 不使用session 禁用 CSRF .csrf().disable() - // 认证失败处理类 + // 认证失败处理 .exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and() // 基于token,所以不需要session .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() @@ -110,7 +110,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ).permitAll() .antMatchers("/profile/**").anonymous() .antMatchers("/**/webjars/**").anonymous() - .antMatchers("/**/api-docs").anonymous() + .antMatchers("/**/static/**").anonymous() .antMatchers("/**/druid/**").anonymous() //开放接口不拦截-内部有验签 .antMatchers("/open/gateway").anonymous() diff --git a/sso-auth-center-service/sso-business/pom.xml b/sso-auth-center-service/sso-business/pom.xml index b5fc1dd..de49a13 100755 --- a/sso-auth-center-service/sso-business/pom.xml +++ b/sso-auth-center-service/sso-business/pom.xml @@ -17,7 +17,7 @@ - + com.sso sso-common diff --git a/sso-auth-center-service/sso-common/pom.xml b/sso-auth-center-service/sso-common/pom.xml index 2d4a71b..e03052b 100755 --- a/sso-auth-center-service/sso-common/pom.xml +++ b/sso-auth-center-service/sso-common/pom.xml @@ -12,7 +12,7 @@ sso-common - common通用工具 + common 公共模块