From 35ceab385c7a942a4c8f22484d674e525676db7b Mon Sep 17 00:00:00 2001 From: youjie <272855983@qq.com> Date: Mon, 27 Feb 2023 14:06:48 +0800 Subject: [PATCH] 优化界面 增加Swagger3Config 配置 --- ant-design-vue-jeecg/src/views/system/monitor/locationStatus.vue | 1 - ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue | 10 +++++----- ant-design-vue-jeecg/src/views/system/task/ShipmentTaskHeaderList.vue | 10 +++++----- ant-design-vue-jeecg/src/views/system/task/TransferTaskHeaderList.vue | 10 +++++----- huaheng-wms-core/pom.xml | 22 ++++++++++++++++++++++ huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java | 2 +- huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/material/service/impl/MaterialServiceImpl.java | 2 +- huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/service/impl/ReceiptDetailServiceImpl.java | 17 ++++++----------- huaheng-wms-core/src/main/java/org/jeecg/utils/Swagger3Config.java | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 135 insertions(+), 29 deletions(-) create mode 100644 huaheng-wms-core/src/main/java/org/jeecg/utils/Swagger3Config.java diff --git a/ant-design-vue-jeecg/src/views/system/monitor/locationStatus.vue b/ant-design-vue-jeecg/src/views/system/monitor/locationStatus.vue index 9bd0667..050441e 100644 --- a/ant-design-vue-jeecg/src/views/system/monitor/locationStatus.vue +++ b/ant-design-vue-jeecg/src/views/system/monitor/locationStatus.vue @@ -7,7 +7,6 @@ <ul id="select_info"> <li> - 货主 <a-select show-search placeholder="请选择库位类型" diff --git a/ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue b/ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue index 1b7a23b..9b26fdd 100644 --- a/ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue +++ b/ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue @@ -109,11 +109,11 @@ <!-- table区域-begin --> <div> - <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;"> - <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a - style="font-weight: 600">{{ selectedRowKeys.length }}</a>项 - <a style="margin-left: 24px" @click="onClearSelected">清空</a> - </div> +<!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">--> +<!-- <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a--> +<!-- style="font-weight: 600">{{ selectedRowKeys.length }}</a>项--> +<!-- <a style="margin-left: 24px" @click="onClearSelected">清空</a>--> +<!-- </div>--> <a-table ref="table" diff --git a/ant-design-vue-jeecg/src/views/system/task/ShipmentTaskHeaderList.vue b/ant-design-vue-jeecg/src/views/system/task/ShipmentTaskHeaderList.vue index ba9b916..9bdaef1 100644 --- a/ant-design-vue-jeecg/src/views/system/task/ShipmentTaskHeaderList.vue +++ b/ant-design-vue-jeecg/src/views/system/task/ShipmentTaskHeaderList.vue @@ -104,11 +104,11 @@ <!-- table区域-begin --> <div> - <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;"> - <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a - style="font-weight: 600">{{ selectedRowKeys.length }}</a>项 - <a style="margin-left: 24px" @click="onClearSelected">清空</a> - </div> +<!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">--> +<!-- <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a--> +<!-- style="font-weight: 600">{{ selectedRowKeys.length }}</a>项--> +<!-- <a style="margin-left: 24px" @click="onClearSelected">清空</a>--> +<!-- </div>--> <a-table ref="table" diff --git a/ant-design-vue-jeecg/src/views/system/task/TransferTaskHeaderList.vue b/ant-design-vue-jeecg/src/views/system/task/TransferTaskHeaderList.vue index 2af7d82..4dbf9e7 100644 --- a/ant-design-vue-jeecg/src/views/system/task/TransferTaskHeaderList.vue +++ b/ant-design-vue-jeecg/src/views/system/task/TransferTaskHeaderList.vue @@ -110,11 +110,11 @@ <!-- table区域-begin --> <div> - <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;"> - <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a - style="font-weight: 600">{{ selectedRowKeys.length }}</a>项 - <a style="margin-left: 24px" @click="onClearSelected">清空</a> - </div> +<!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">--> +<!-- <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a--> +<!-- style="font-weight: 600">{{ selectedRowKeys.length }}</a>项--> +<!-- <a style="margin-left: 24px" @click="onClearSelected">清空</a>--> +<!-- </div>--> <a-table ref="table" diff --git a/huaheng-wms-core/pom.xml b/huaheng-wms-core/pom.xml index aef757b..51ab7ee 100644 --- a/huaheng-wms-core/pom.xml +++ b/huaheng-wms-core/pom.xml @@ -85,6 +85,28 @@ <artifactId>spring-boot-starter-validation</artifactId> </dependency> + <!--swagger--> + <dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-swagger2</artifactId> + <version>3.0.0</version> + </dependency> + <dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-swagger-ui</artifactId> + <version>3.0.0</version> + </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>1.5.22</version> + </dependency> + <dependency> + <groupId>com.github.xiaoymin</groupId> + <artifactId>swagger-bootstrap-ui</artifactId> + <version>1.8.7</version> + </dependency> + </dependencies> <build> diff --git a/huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java b/huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java index 65e23d7..1d1c0bd 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java @@ -28,7 +28,7 @@ import lombok.extern.slf4j.Slf4j; @EnableCaching @SpringBootApplication @EnableAutoConfiguration(exclude = {MongoAutoConfiguration.class}) -@ComponentScan(excludeFilters = {@Filter(type = FilterType.REGEX, pattern = {"org.jeecg.config.mybatis.MybatisInterceptor"})}) +@ComponentScan(excludeFilters = {@Filter(type = FilterType.REGEX, pattern = {"org.jeecg.config.mybatis.MybatisInterceptor", "org.jeecg.config.Swagger2Config"})}) public class JeecgSystemApplication extends SpringBootServletInitializer { @Override diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/material/service/impl/MaterialServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/material/service/impl/MaterialServiceImpl.java index ab6fbeb..3161ad3 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/material/service/impl/MaterialServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/material/service/impl/MaterialServiceImpl.java @@ -28,7 +28,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i return null; } LambdaQueryWrapper<Material> materialLambdaQueryWrapper = Wrappers.lambdaQuery(); - materialLambdaQueryWrapper.eq(Material::getCode, code).eq(Material::getEnable, QuantityConstant.STATUS_DISABLE); + materialLambdaQueryWrapper.eq(Material::getCode, code).eq(Material::getEnable, QuantityConstant.STATUS_ENABLE); Material material = this.getOne(materialLambdaQueryWrapper); return material; } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/service/impl/ReceiptDetailServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/service/impl/ReceiptDetailServiceImpl.java index 5022b50..a7a8ab6 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/service/impl/ReceiptDetailServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/service/impl/ReceiptDetailServiceImpl.java @@ -1,7 +1,7 @@ package org.jeecg.modules.wms.receipt.receiptHeader.service.impl; import java.math.BigDecimal; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; import javax.annotation.Resource; @@ -14,19 +14,12 @@ import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptHeader; import org.jeecg.modules.wms.receipt.receiptHeader.mapper.ReceiptDetailMapper; import org.jeecg.modules.wms.receipt.receiptHeader.service.IReceiptDetailService; import org.jeecg.modules.wms.receipt.receiptHeader.service.IReceiptHeaderService; -import org.jeecg.utils.HuahengJwtUtil; import org.jeecg.utils.StringUtils; import org.jeecg.utils.constant.QuantityConstant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.List; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import com.alibaba.fastjson.JSON; import com.aliyun.oss.ServiceException; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -57,16 +50,18 @@ public class ReceiptDetailServiceImpl extends ServiceImpl<ReceiptDetailMapper, R return receiptDetailMapper.selectByMainId(mainId); } - @Override - public boolean save(ReceiptDetail entity) { + @Override + public boolean save(ReceiptDetail entity) { BigDecimal qty = entity.getQty(); if (qty.compareTo(BigDecimal.ZERO) < 0) { throw new ServiceException("单据数量不能小于0"); } return super.save(entity); } + @Override - @OperationLog(bizId = "''", bizType = "'入库单追踪'", tag = "'入库详情添加'", extra = "#extraJsonString", msg = "''", operatorId = "#username", recordReturnValue = true) public Result saveReceiptDetail(ReceiptDetail receiptDetail) { + @OperationLog(bizId = "''", bizType = "'入库单追踪'", tag = "'入库详情添加'", extra = "#extraJsonString", msg = "''", operatorId = "#username", recordReturnValue = true) + public Result saveReceiptDetail(ReceiptDetail receiptDetail) { ReceiptHeader receiptHeader = receiptHeaderService.getById(receiptDetail.getReceiptId()); if (receiptHeader == null) { return Result.error("添加失败,没有找到入库单头"); diff --git a/huaheng-wms-core/src/main/java/org/jeecg/utils/Swagger3Config.java b/huaheng-wms-core/src/main/java/org/jeecg/utils/Swagger3Config.java new file mode 100644 index 0000000..1f731bf --- /dev/null +++ b/huaheng-wms-core/src/main/java/org/jeecg/utils/Swagger3Config.java @@ -0,0 +1,90 @@ +package org.jeecg.utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.jeecg.common.constant.CommonConstant; +import org.jeecg.config.Swagger2Config; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.web.bind.annotation.RestController; + +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; + +import io.swagger.annotations.ApiOperation; +import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.*; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spi.service.contexts.SecurityContext; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Configuration +@EnableSwagger2 +@EnableKnife4j +@Import(BeanValidatorPluginsConfiguration.class) +public class Swagger3Config extends Swagger2Config { + + /** + * swagger2的配置文件,这里可以配置swagger2的一些基本的内容,比如扫描的包等等 + * @return Docket + */ + @Override + @Bean(value = "defaultApi2") + public Docket defaultApi2() { + return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() + // 此包路径下的类,才生成接口文档 + .apis(RequestHandlerSelectors.basePackage("org.jeecg")) + // 加了ApiOperation注解的类,才生成接口文档 + .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class)).apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + .paths(PathSelectors.any()).build().securitySchemes(Collections.singletonList(securityScheme())).securityContexts(securityContexts()); + // .globalOperationParameters(setHeaderToken()); + } + + /*** + * oauth2配置 + * 需要增加swagger授权回调地址 + * http://localhost:8888/webjars/springfox-swagger-ui/o2c.html + * @return + */ + @Bean + SecurityScheme securityScheme() { + return new ApiKey(CommonConstant.X_ACCESS_TOKEN, CommonConstant.X_ACCESS_TOKEN, "header"); + } + + /** + * 新增 securityContexts 保持登录状态 + */ + private List<SecurityContext> securityContexts() { + return new ArrayList( + Collections.singleton(SecurityContext.builder().securityReferences(defaultAuth()).forPaths(PathSelectors.regex("^(?!auth).*$")).build())); + } + + /** + * api文档的详细信息函数,注意这里的注解引用的是哪个 + * @return + */ + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + // //大标题 + .title("华恒仓储管理系统API接口文档") + // 版本号 + .version("1.0") +// .termsOfServiceUrl("NO terms of service") + // 描述 + .description("后台API接口").license("The Apache License, Version 2.0").licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html").build(); + } + + private List<SecurityReference> defaultAuth() { + AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); + AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; + authorizationScopes[0] = authorizationScope; + return new ArrayList(Collections.singleton(new SecurityReference(CommonConstant.X_ACCESS_TOKEN, authorizationScopes))); + } + +} -- libgit2 0.22.2