Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 使用 spring-javaformat 改进代码的结构/格式 #4625

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .springjavaformatconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://github.com/spring-io/spring-javaformat/#java-8-support
# 高版本支持 JDK 8
java-baseline=8
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ JeecgBoot 提供了一系列`低代码模块`,实现在线开发`真正的零
| `jeecg-boot-starter` | [Stater依赖项目单独维护,点击下载](https://gitee.com/jeecg/jeecg-boot-starter) |
| `更多开源插件` | [更多源码下载](https://github.com/jeecgboot) |

##### 代码规范 [spring-javaformat](https://github.com/spring-io/spring-javaformat)

<details>
<summary>代码规范说明</summary>

1. 由于 <a href="https://github.com/spring-io/spring-javaformat" target="_blank">spring-javaformat</a>
强制所有代码按照指定格式排版,未按此要求提交的代码将不能通过合并(打包)
2. 如果使用 IntelliJ IDEA
开发,请安装自动格式化软件 <a href="https://repo1.maven.org/maven2/io/spring/javaformat/spring-javaformat-intellij-idea-plugin/" target="_blank">
spring-javaformat-intellij-idea-plugin</a>
3. 其他开发工具,请参考 <a href="https://github.com/spring-io/spring-javaformat" target="_blank">spring-javaformat</a>
说明,或`提交代码前`在项目根目录运行下列命令(需要开发者电脑支持`mvn`命令)进行代码格式化
```
mvn spring-javaformat:apply
```
</details>



Expand Down
3 changes: 3 additions & 0 deletions jeecg-boot-base-core/.springjavaformatconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://github.com/spring-io/spring-javaformat/#java-8-support
# 高版本支持 JDK 8
java-baseline=8
224 changes: 110 additions & 114 deletions jeecg-boot-base-core/src/main/java/org/jeecg/common/api/CommonAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,123 +8,119 @@

/**
* 通用api
*
* @author: jeecg-boot
*/
public interface CommonAPI {

/**
* 1查询用户角色信息
* @param username
* @return
*/
Set<String> queryUserRoles(String username);


/**
* 2查询用户权限信息
* @param username
* @return
*/
Set<String> queryUserAuths(String username);

/**
* 3根据 id 查询数据库中存储的 DynamicDataSourceModel
*
* @param dbSourceId
* @return
*/
DynamicDataSourceModel getDynamicDbSourceById(String dbSourceId);

/**
* 4根据 code 查询数据库中存储的 DynamicDataSourceModel
*
* @param dbSourceCode
* @return
*/
DynamicDataSourceModel getDynamicDbSourceByCode(String dbSourceCode);

/**
* 5根据用户账号查询用户信息
* @param username
* @return
*/
public LoginUser getUserByName(String username);


/**
* 6字典表的 翻译
* @param table
* @param text
* @param code
* @param key
* @return
*/
String translateDictFromTable(String table, String text, String code, String key);

/**
* 7普通字典的翻译
* @param code
* @param key
* @return
*/
String translateDict(String code, String key);

/**
* 8查询数据权限
* @param component 组件
* @param username 用户名
* @param requestPath 前段请求地址
* @return
*/
List<SysPermissionDataRuleModel> queryPermissionDataRule(String component, String requestPath, String username);


/**
* 9查询用户信息
* @param username
* @return
*/
SysUserCacheInfo getCacheUser(String username);

/**
* 10获取数据字典
* @param code
* @return
*/
public List<DictModel> queryDictItemsByCode(String code);

/**
* 获取有效的数据字典项
* @param code
* @return
*/
public List<DictModel> queryEnableDictItemsByCode(String code);

/**
* 13获取表数据字典
* @param table
* @param text
* @param code
* @return
*/
List<DictModel> queryTableDictItemsByCode(String table, String text, String code);

/**
* 14 普通字典的翻译,根据多个dictCode和多条数据,多个以逗号分割
* @param dictCodes 例如:user_status,sex
* @param keys 例如:1,2,0
* @return
*/
Map<String, List<DictModel>> translateManyDict(String dictCodes, String keys);

/**
* 15 字典表的 翻译,可批量
* @param table
* @param text
* @param code
* @param keys 多个用逗号分割
* @return
*/
List<DictModel> translateDictFromTableByKeys(String table, String text, String code, String keys);
/**
* 1查询用户角色信息
* @param username
* @return
*/
Set<String> queryUserRoles(String username);

/**
* 2查询用户权限信息
* @param username
* @return
*/
Set<String> queryUserAuths(String username);

/**
* 3根据 id 查询数据库中存储的 DynamicDataSourceModel
* @param dbSourceId
* @return
*/
DynamicDataSourceModel getDynamicDbSourceById(String dbSourceId);

/**
* 4根据 code 查询数据库中存储的 DynamicDataSourceModel
* @param dbSourceCode
* @return
*/
DynamicDataSourceModel getDynamicDbSourceByCode(String dbSourceCode);

/**
* 5根据用户账号查询用户信息
* @param username
* @return
*/
public LoginUser getUserByName(String username);

/**
* 6字典表的 翻译
* @param table
* @param text
* @param code
* @param key
* @return
*/
String translateDictFromTable(String table, String text, String code, String key);

/**
* 7普通字典的翻译
* @param code
* @param key
* @return
*/
String translateDict(String code, String key);

/**
* 8查询数据权限
* @param component 组件
* @param username 用户名
* @param requestPath 前段请求地址
* @return
*/
List<SysPermissionDataRuleModel> queryPermissionDataRule(String component, String requestPath, String username);

/**
* 9查询用户信息
* @param username
* @return
*/
SysUserCacheInfo getCacheUser(String username);

/**
* 10获取数据字典
* @param code
* @return
*/
public List<DictModel> queryDictItemsByCode(String code);

/**
* 获取有效的数据字典项
* @param code
* @return
*/
public List<DictModel> queryEnableDictItemsByCode(String code);

/**
* 13获取表数据字典
* @param table
* @param text
* @param code
* @return
*/
List<DictModel> queryTableDictItemsByCode(String table, String text, String code);

/**
* 14 普通字典的翻译,根据多个dictCode和多条数据,多个以逗号分割
* @param dictCodes 例如:user_status,sex
* @param keys 例如:1,2,0
* @return
*/
Map<String, List<DictModel>> translateManyDict(String dictCodes, String keys);

/**
* 15 字典表的 翻译,可批量
* @param table
* @param text
* @param code
* @param keys 多个用逗号分割
* @return
*/
List<DictModel> translateDictFromTableByKeys(String table, String text, String code, String keys);

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,29 @@
@Data
public class DataLogDTO {

private String tableName;
private String tableName;

private String dataId;
private String dataId;

private String content;
private String content;

private String type;
private String type;

public DataLogDTO(){
public DataLogDTO() {

}
}

public DataLogDTO(String tableName, String dataId, String content, String type) {
this.tableName = tableName;
this.dataId = dataId;
this.content = content;
this.type = type;
}
public DataLogDTO(String tableName, String dataId, String content, String type) {
this.tableName = tableName;
this.dataId = dataId;
this.content = content;
this.type = type;
}

public DataLogDTO(String tableName, String dataId, String type) {
this.tableName = tableName;
this.dataId = dataId;
this.type = type;
}

public DataLogDTO(String tableName, String dataId, String type) {
this.tableName = tableName;
this.dataId = dataId;
this.type = type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,31 @@
import java.io.Serializable;

/**
* 文件下载
* cloud api 用到的接口传输对象
* 文件下载 cloud api 用到的接口传输对象
*
* @author: jeecg-boot
*/
@Data
public class FileDownDTO implements Serializable {

private static final long serialVersionUID = 6749126258686446019L;
private static final long serialVersionUID = 6749126258686446019L;

private String filePath;
private String uploadpath;
private String uploadType;
private HttpServletResponse response;
private String filePath;

public FileDownDTO(){}
private String uploadpath;

private String uploadType;

private HttpServletResponse response;

public FileDownDTO() {
}

public FileDownDTO(String filePath, String uploadpath, String uploadType, HttpServletResponse response) {
this.filePath = filePath;
this.uploadpath = uploadpath;
this.uploadType = uploadType;
this.response = response;
}

public FileDownDTO(String filePath, String uploadpath, String uploadType,HttpServletResponse response){
this.filePath = filePath;
this.uploadpath = uploadpath;
this.uploadType = uploadType;
this.response = response;
}
}