Skip to content

Commit c75b52e

Browse files
committed
代码优化,修改Controller中方法,避免名称重复
命名重复会打印如下日志,不介意的可以不修改: s.d.s.w.s.ApiListingReferenceScanner: Generating unique operation named
1 parent db1a20a commit c75b52e

30 files changed

+163
-152
lines changed

eladmin-common/src/main/java/me/zhengjie/config/RedisConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisC
9898
@Override
9999
public KeyGenerator keyGenerator() {
100100
return (target, method, params) -> {
101-
Map<String,Object> container = new HashMap<>();
101+
Map<String,Object> container = new HashMap<>(4);
102102
Class<?> targetClassClass = target.getClass();
103103
// 类地址
104104
container.put("class",targetClassClass.toGenericString());

eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public class GenConfigController {
3939

4040
@ApiOperation("查询")
4141
@GetMapping(value = "/{tableName}")
42-
public ResponseEntity<Object> query(@PathVariable String tableName){
42+
public ResponseEntity<Object> queryGenConfig(@PathVariable String tableName){
4343
return new ResponseEntity<>(genConfigService.find(tableName), HttpStatus.OK);
4444
}
4545

46-
@ApiOperation("修改")
4746
@PutMapping
48-
public ResponseEntity<Object> update(@Validated @RequestBody GenConfig genConfig){
47+
@ApiOperation("修改")
48+
public ResponseEntity<Object> updateGenConfig(@Validated @RequestBody GenConfig genConfig){
4949
return new ResponseEntity<>(genConfigService.update(genConfig.getTableName(), genConfig),HttpStatus.OK);
5050
}
5151
}

eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class GeneratorController {
4949

5050
@ApiOperation("查询数据库数据")
5151
@GetMapping(value = "/tables/all")
52-
public ResponseEntity<Object> queryTables(){
52+
public ResponseEntity<Object> queryAllTables(){
5353
return new ResponseEntity<>(generatorService.getTables(), HttpStatus.OK);
5454
}
5555

@@ -71,14 +71,14 @@ public ResponseEntity<Object> queryColumns(@RequestParam String tableName){
7171

7272
@ApiOperation("保存字段数据")
7373
@PutMapping
74-
public ResponseEntity<HttpStatus> save(@RequestBody List<ColumnInfo> columnInfos){
74+
public ResponseEntity<HttpStatus> saveColumn(@RequestBody List<ColumnInfo> columnInfos){
7575
generatorService.save(columnInfos);
7676
return new ResponseEntity<>(HttpStatus.OK);
7777
}
7878

7979
@ApiOperation("同步字段数据")
8080
@PostMapping(value = "sync")
81-
public ResponseEntity<HttpStatus> sync(@RequestBody List<String> tables){
81+
public ResponseEntity<HttpStatus> syncColumn(@RequestBody List<String> tables){
8282
for (String table : tables) {
8383
generatorService.sync(generatorService.getColumns(table), generatorService.query(table));
8484
}
@@ -87,7 +87,7 @@ public ResponseEntity<HttpStatus> sync(@RequestBody List<String> tables){
8787

8888
@ApiOperation("生成代码")
8989
@PostMapping(value = "/{tableName}/{type}")
90-
public ResponseEntity<Object> generator(@PathVariable String tableName, @PathVariable Integer type, HttpServletRequest request, HttpServletResponse response){
90+
public ResponseEntity<Object> generatorCode(@PathVariable String tableName, @PathVariable Integer type, HttpServletRequest request, HttpServletResponse response){
9191
if(!generatorEnabled && type == 0){
9292
throw new BadRequestException("此环境不允许生成代码,请选择预览或者下载查看!");
9393
}

eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class LogController {
4646
@ApiOperation("导出数据")
4747
@GetMapping(value = "/download")
4848
@PreAuthorize("@el.check()")
49-
public void download(HttpServletResponse response, LogQueryCriteria criteria) throws IOException {
49+
public void exportLog(HttpServletResponse response, LogQueryCriteria criteria) throws IOException {
5050
criteria.setLogType("INFO");
5151
logService.download(logService.queryAll(criteria), response);
5252
}
@@ -55,14 +55,14 @@ public void download(HttpServletResponse response, LogQueryCriteria criteria) th
5555
@ApiOperation("导出错误数据")
5656
@GetMapping(value = "/error/download")
5757
@PreAuthorize("@el.check()")
58-
public void downloadErrorLog(HttpServletResponse response, LogQueryCriteria criteria) throws IOException {
58+
public void exportErrorLog(HttpServletResponse response, LogQueryCriteria criteria) throws IOException {
5959
criteria.setLogType("ERROR");
6060
logService.download(logService.queryAll(criteria), response);
6161
}
6262
@GetMapping
6363
@ApiOperation("日志查询")
6464
@PreAuthorize("@el.check()")
65-
public ResponseEntity<Object> query(LogQueryCriteria criteria, Pageable pageable){
65+
public ResponseEntity<Object> queryLog(LogQueryCriteria criteria, Pageable pageable){
6666
criteria.setLogType("INFO");
6767
return new ResponseEntity<>(logService.queryAll(criteria,pageable), HttpStatus.OK);
6868
}
@@ -86,7 +86,7 @@ public ResponseEntity<Object> queryErrorLog(LogQueryCriteria criteria, Pageable
8686
@GetMapping(value = "/error/{id}")
8787
@ApiOperation("日志异常详情查询")
8888
@PreAuthorize("@el.check()")
89-
public ResponseEntity<Object> queryErrorLogs(@PathVariable Long id){
89+
public ResponseEntity<Object> queryErrorLogDetail(@PathVariable Long id){
9090
return new ResponseEntity<>(logService.findByErrDetail(id), HttpStatus.OK);
9191
}
9292
@DeleteMapping(value = "/del/error")

eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private String getParameter(Method method, Object[] args) {
113113
//将RequestParam注解修饰的参数作为请求参数
114114
RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
115115
if (requestParam != null) {
116-
Map<String, Object> map = new HashMap<>();
116+
Map<String, Object> map = new HashMap<>(4);
117117
String key = parameters[i].getName();
118118
if (!StringUtils.isEmpty(requestParam.value())) {
119119
key = requestParam.value();

eladmin-system/src/main/java/me/zhengjie/config/thread/AsyncTaskExecutePool.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,17 @@
3232
@Configuration
3333
public class AsyncTaskExecutePool implements AsyncConfigurer {
3434

35-
/** 注入配置类 */
36-
private final AsyncTaskProperties config;
37-
38-
public AsyncTaskExecutePool(AsyncTaskProperties config) {
39-
this.config = config;
40-
}
41-
4235
@Override
4336
public Executor getAsyncExecutor() {
4437
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
4538
//核心线程池大小
46-
executor.setCorePoolSize(config.getCorePoolSize());
39+
executor.setCorePoolSize(AsyncTaskProperties.corePoolSize);
4740
//最大线程数
48-
executor.setMaxPoolSize(config.getMaxPoolSize());
41+
executor.setMaxPoolSize(AsyncTaskProperties.maxPoolSize);
4942
//队列容量
50-
executor.setQueueCapacity(config.getQueueCapacity());
43+
executor.setQueueCapacity(AsyncTaskProperties.queueCapacity);
5144
//活跃时间
52-
executor.setKeepAliveSeconds(config.getKeepAliveSeconds());
45+
executor.setKeepAliveSeconds(AsyncTaskProperties.keepAliveSeconds);
5346
//线程名字前缀
5447
executor.setThreadNamePrefix("el-async-");
5548
// setRejectedExecutionHandler:当pool已经达到max size的时候,如何处理新任务

eladmin-system/src/main/java/me/zhengjie/config/thread/AsyncTaskProperties.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package me.zhengjie.config.thread;
1717

1818
import lombok.Data;
19+
import org.springframework.beans.factory.annotation.Value;
1920
import org.springframework.boot.context.properties.ConfigurationProperties;
2021
import org.springframework.stereotype.Component;
2122

@@ -26,14 +27,33 @@
2627
*/
2728
@Data
2829
@Component
29-
@ConfigurationProperties(prefix = "task.pool")
3030
public class AsyncTaskProperties {
3131

32-
private int corePoolSize;
32+
public static int corePoolSize;
3333

34-
private int maxPoolSize;
34+
public static int maxPoolSize;
3535

36-
private int keepAliveSeconds;
36+
public static int keepAliveSeconds;
3737

38-
private int queueCapacity;
38+
public static int queueCapacity;
39+
40+
@Value("${task.pool.core-pool-size}")
41+
public void setCorePoolSize(int corePoolSize) {
42+
AsyncTaskProperties.corePoolSize = corePoolSize;
43+
}
44+
45+
@Value("${task.pool.max-pool-size}")
46+
public void setMaxPoolSize(int maxPoolSize) {
47+
AsyncTaskProperties.maxPoolSize = maxPoolSize;
48+
}
49+
50+
@Value("${task.pool.keep-alive-seconds}")
51+
public void setKeepAliveSeconds(int keepAliveSeconds) {
52+
AsyncTaskProperties.keepAliveSeconds = keepAliveSeconds;
53+
}
54+
55+
@Value("${task.pool.queue-capacity}")
56+
public void setQueueCapacity(int queueCapacity) {
57+
AsyncTaskProperties.queueCapacity = queueCapacity;
58+
}
3959
}

eladmin-system/src/main/java/me/zhengjie/config/thread/ThreadPoolExecutorUtil.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package me.zhengjie.config.thread;
1717

18-
import me.zhengjie.utils.SpringContextHolder;
19-
2018
import java.util.concurrent.ArrayBlockingQueue;
2119
import java.util.concurrent.ThreadPoolExecutor;
2220
import java.util.concurrent.TimeUnit;
@@ -29,13 +27,12 @@
2927
public class ThreadPoolExecutorUtil {
3028

3129
public static ThreadPoolExecutor getPoll(){
32-
AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);
3330
return new ThreadPoolExecutor(
34-
properties.getCorePoolSize(),
35-
properties.getMaxPoolSize(),
36-
properties.getKeepAliveSeconds(),
31+
AsyncTaskProperties.corePoolSize,
32+
AsyncTaskProperties.maxPoolSize,
33+
AsyncTaskProperties.keepAliveSeconds,
3734
TimeUnit.SECONDS,
38-
new ArrayBlockingQueue<>(properties.getQueueCapacity()),
35+
new ArrayBlockingQueue<>(AsyncTaskProperties.queueCapacity),
3936
new TheadFactoryName()
4037
);
4138
}

eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/AppController.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,22 @@ public class AppController {
4747
@ApiOperation("导出应用数据")
4848
@GetMapping(value = "/download")
4949
@PreAuthorize("@el.check('app:list')")
50-
public void download(HttpServletResponse response, AppQueryCriteria criteria) throws IOException {
50+
public void exportApp(HttpServletResponse response, AppQueryCriteria criteria) throws IOException {
5151
appService.download(appService.queryAll(criteria), response);
5252
}
5353

5454
@ApiOperation(value = "查询应用")
5555
@GetMapping
5656
@PreAuthorize("@el.check('app:list')")
57-
public ResponseEntity<Object> query(AppQueryCriteria criteria, Pageable pageable){
57+
public ResponseEntity<Object> queryApp(AppQueryCriteria criteria, Pageable pageable){
5858
return new ResponseEntity<>(appService.queryAll(criteria,pageable),HttpStatus.OK);
5959
}
6060

6161
@Log("新增应用")
6262
@ApiOperation(value = "新增应用")
6363
@PostMapping
6464
@PreAuthorize("@el.check('app:add')")
65-
public ResponseEntity<Object> create(@Validated @RequestBody App resources){
65+
public ResponseEntity<Object> createApp(@Validated @RequestBody App resources){
6666
appService.create(resources);
6767
return new ResponseEntity<>(HttpStatus.CREATED);
6868
}
@@ -71,7 +71,7 @@ public ResponseEntity<Object> create(@Validated @RequestBody App resources){
7171
@ApiOperation(value = "修改应用")
7272
@PutMapping
7373
@PreAuthorize("@el.check('app:edit')")
74-
public ResponseEntity<Object> update(@Validated @RequestBody App resources){
74+
public ResponseEntity<Object> updateApp(@Validated @RequestBody App resources){
7575
appService.update(resources);
7676
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
7777
}
@@ -80,7 +80,7 @@ public ResponseEntity<Object> update(@Validated @RequestBody App resources){
8080
@ApiOperation(value = "删除应用")
8181
@DeleteMapping
8282
@PreAuthorize("@el.check('app:del')")
83-
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids){
83+
public ResponseEntity<Object> deleteApp(@RequestBody Set<Long> ids){
8484
appService.delete(ids);
8585
return new ResponseEntity<>(HttpStatus.OK);
8686
}

eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DatabaseController.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ public class DatabaseController {
5555
@ApiOperation("导出数据库数据")
5656
@GetMapping(value = "/download")
5757
@PreAuthorize("@el.check('database:list')")
58-
public void download(HttpServletResponse response, DatabaseQueryCriteria criteria) throws IOException {
58+
public void exportDatabase(HttpServletResponse response, DatabaseQueryCriteria criteria) throws IOException {
5959
databaseService.download(databaseService.queryAll(criteria), response);
6060
}
6161

6262
@ApiOperation(value = "查询数据库")
6363
@GetMapping
6464
@PreAuthorize("@el.check('database:list')")
65-
public ResponseEntity<Object> query(DatabaseQueryCriteria criteria, Pageable pageable){
65+
public ResponseEntity<Object> queryDatabase(DatabaseQueryCriteria criteria, Pageable pageable){
6666
return new ResponseEntity<>(databaseService.queryAll(criteria,pageable),HttpStatus.OK);
6767
}
6868

6969
@Log("新增数据库")
7070
@ApiOperation(value = "新增数据库")
7171
@PostMapping
7272
@PreAuthorize("@el.check('database:add')")
73-
public ResponseEntity<Object> create(@Validated @RequestBody Database resources){
73+
public ResponseEntity<Object> createDatabase(@Validated @RequestBody Database resources){
7474
databaseService.create(resources);
7575
return new ResponseEntity<>(HttpStatus.CREATED);
7676
}
@@ -79,7 +79,7 @@ public ResponseEntity<Object> create(@Validated @RequestBody Database resources)
7979
@ApiOperation(value = "修改数据库")
8080
@PutMapping
8181
@PreAuthorize("@el.check('database:edit')")
82-
public ResponseEntity<Object> update(@Validated @RequestBody Database resources){
82+
public ResponseEntity<Object> updateDatabase(@Validated @RequestBody Database resources){
8383
databaseService.update(resources);
8484
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
8585
}
@@ -88,7 +88,7 @@ public ResponseEntity<Object> update(@Validated @RequestBody Database resources)
8888
@ApiOperation(value = "删除数据库")
8989
@DeleteMapping
9090
@PreAuthorize("@el.check('database:del')")
91-
public ResponseEntity<Object> delete(@RequestBody Set<String> ids){
91+
public ResponseEntity<Object> deleteDatabase(@RequestBody Set<String> ids){
9292
databaseService.delete(ids);
9393
return new ResponseEntity<>(HttpStatus.OK);
9494
}
@@ -105,7 +105,7 @@ public ResponseEntity<Object> testConnect(@Validated @RequestBody Database resou
105105
@ApiOperation(value = "执行SQL脚本")
106106
@PostMapping(value = "/upload")
107107
@PreAuthorize("@el.check('database:add')")
108-
public ResponseEntity<Object> upload(@RequestBody MultipartFile file, HttpServletRequest request)throws Exception{
108+
public ResponseEntity<Object> uploadDatabase(@RequestBody MultipartFile file, HttpServletRequest request)throws Exception{
109109
String id = request.getParameter("id");
110110
DatabaseDto database = databaseService.findById(id);
111111
String fileName;

eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployController.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,22 @@ public class DeployController {
5757
@ApiOperation("导出部署数据")
5858
@GetMapping(value = "/download")
5959
@PreAuthorize("@el.check('database:list')")
60-
public void download(HttpServletResponse response, DeployQueryCriteria criteria) throws IOException {
60+
public void exportDeployData(HttpServletResponse response, DeployQueryCriteria criteria) throws IOException {
6161
deployService.download(deployService.queryAll(criteria), response);
6262
}
6363

6464
@ApiOperation(value = "查询部署")
6565
@GetMapping
6666
@PreAuthorize("@el.check('deploy:list')")
67-
public ResponseEntity<Object> query(DeployQueryCriteria criteria, Pageable pageable){
67+
public ResponseEntity<Object> queryDeployData(DeployQueryCriteria criteria, Pageable pageable){
6868
return new ResponseEntity<>(deployService.queryAll(criteria,pageable),HttpStatus.OK);
6969
}
7070

7171
@Log("新增部署")
7272
@ApiOperation(value = "新增部署")
7373
@PostMapping
7474
@PreAuthorize("@el.check('deploy:add')")
75-
public ResponseEntity<Object> create(@Validated @RequestBody Deploy resources){
75+
public ResponseEntity<Object> createDeploy(@Validated @RequestBody Deploy resources){
7676
deployService.create(resources);
7777
return new ResponseEntity<>(HttpStatus.CREATED);
7878
}
@@ -81,7 +81,7 @@ public ResponseEntity<Object> create(@Validated @RequestBody Deploy resources){
8181
@ApiOperation(value = "修改部署")
8282
@PutMapping
8383
@PreAuthorize("@el.check('deploy:edit')")
84-
public ResponseEntity<Object> update(@Validated @RequestBody Deploy resources){
84+
public ResponseEntity<Object> updateDeploy(@Validated @RequestBody Deploy resources){
8585
deployService.update(resources);
8686
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
8787
}
@@ -90,7 +90,7 @@ public ResponseEntity<Object> update(@Validated @RequestBody Deploy resources){
9090
@ApiOperation(value = "删除部署")
9191
@DeleteMapping
9292
@PreAuthorize("@el.check('deploy:del')")
93-
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids){
93+
public ResponseEntity<Object> deleteDeploy(@RequestBody Set<Long> ids){
9494
deployService.delete(ids);
9595
return new ResponseEntity<>(HttpStatus.OK);
9696
}
@@ -99,7 +99,7 @@ public ResponseEntity<Object> delete(@RequestBody Set<Long> ids){
9999
@ApiOperation(value = "上传文件部署")
100100
@PostMapping(value = "/upload")
101101
@PreAuthorize("@el.check('deploy:edit')")
102-
public ResponseEntity<Object> upload(@RequestBody MultipartFile file, HttpServletRequest request)throws Exception{
102+
public ResponseEntity<Object> uploadDeploy(@RequestBody MultipartFile file, HttpServletRequest request)throws Exception{
103103
Long id = Long.valueOf(request.getParameter("id"));
104104
String fileName = "";
105105
if(file != null){

eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployHistoryController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@ public class DeployHistoryController {
4545
@ApiOperation("导出部署历史数据")
4646
@GetMapping(value = "/download")
4747
@PreAuthorize("@el.check('deployHistory:list')")
48-
public void download(HttpServletResponse response, DeployHistoryQueryCriteria criteria) throws IOException {
48+
public void exportDeployHistory(HttpServletResponse response, DeployHistoryQueryCriteria criteria) throws IOException {
4949
deployhistoryService.download(deployhistoryService.queryAll(criteria), response);
5050
}
5151

5252
@ApiOperation(value = "查询部署历史")
5353
@GetMapping
5454
@PreAuthorize("@el.check('deployHistory:list')")
55-
public ResponseEntity<Object> query(DeployHistoryQueryCriteria criteria, Pageable pageable){
55+
public ResponseEntity<Object> queryDeployHistory(DeployHistoryQueryCriteria criteria, Pageable pageable){
5656
return new ResponseEntity<>(deployhistoryService.queryAll(criteria,pageable),HttpStatus.OK);
5757
}
5858

5959
@Log("删除DeployHistory")
6060
@ApiOperation(value = "删除部署历史")
6161
@DeleteMapping
6262
@PreAuthorize("@el.check('deployHistory:del')")
63-
public ResponseEntity<Object> delete(@RequestBody Set<String> ids){
63+
public ResponseEntity<Object> deleteDeployHistory(@RequestBody Set<String> ids){
6464
deployhistoryService.delete(ids);
6565
return new ResponseEntity<>(HttpStatus.OK);
6666
}

0 commit comments

Comments
 (0)