#新增
1. 新增物料分组tree接口
2. 新增通过物料获取物料接口
3. 新增knife4j接口UI显示 访问链接:http://localhost:8080/rsf-server/doc.html#/home
| | |
| | | <artifactId>springfox-boot-starter</artifactId> |
| | | <version>3.0.0</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.github.xiaoymin</groupId> |
| | | <artifactId>knife4j-spring-boot-starter</artifactId> |
| | | <version>3.0.2</version> |
| | | </dependency> |
| | | <!-- jjwt --> |
| | | <dependency> |
| | | <groupId>io.jsonwebtoken</groupId> |
New file |
| | |
| | | package com.vincent.rsf.server.common.config; |
| | | |
| | | import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.beans.BeansException; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.beans.factory.config.BeanPostProcessor; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.util.ReflectionUtils; |
| | | import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping; |
| | | import springfox.documentation.builders.ApiInfoBuilder; |
| | | import springfox.documentation.builders.PathSelectors; |
| | | import springfox.documentation.builders.RequestHandlerSelectors; |
| | | import springfox.documentation.oas.annotations.EnableOpenApi; |
| | | import springfox.documentation.service.ApiInfo; |
| | | import springfox.documentation.spi.DocumentationType; |
| | | import springfox.documentation.spring.web.plugins.Docket; |
| | | import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider; |
| | | import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Configuration |
| | | @EnableKnife4j |
| | | @EnableOpenApi |
| | | public class SwaggerConfig { |
| | | |
| | | @Value("${spring.profiles.active}") |
| | | private String active; |
| | | |
| | | @Bean |
| | | public Docket docket() { |
| | | Docket docket = new Docket(DocumentationType.OAS_30) |
| | | .apiInfo(apiInfo()) |
| | | .groupName("测试分组") |
| | | .enable(true) |
| | | .select() |
| | | //apis: 添加swagger接口提取范围 |
| | | .apis(RequestHandlerSelectors.withClassAnnotation(Api.class)) |
| | | .paths(PathSelectors.any()) |
| | | .build(); |
| | | |
| | | return docket; |
| | | } |
| | | |
| | | private ApiInfo apiInfo() { |
| | | return new ApiInfoBuilder() |
| | | .title("WMS标版1.0版本接口文档") |
| | | .description("WMS标版1.0版本接口文档,技术栈主要包括:SpringBoot、React.js、MySQL5.7") |
| | | .version("v1.0") |
| | | .build(); |
| | | } |
| | | |
| | | @Bean |
| | | public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() { |
| | | return new BeanPostProcessor() { |
| | | |
| | | @Override |
| | | public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { |
| | | if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) { |
| | | customizeSpringfoxHandlerMappings(getHandlerMappings(bean)); |
| | | } |
| | | return bean; |
| | | } |
| | | |
| | | private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings(List<T> mappings) { |
| | | List<T> copy = mappings.stream() |
| | | .filter(mapping -> mapping.getPatternParser() == null) |
| | | .collect(Collectors.toList()); |
| | | mappings.clear(); |
| | | mappings.addAll(copy); |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | private List<RequestMappingInfoHandlerMapping> getHandlerMappings(Object bean) { |
| | | try { |
| | | Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings"); |
| | | field.setAccessible(true); |
| | | return (List<RequestMappingInfoHandlerMapping>) field.get(bean); |
| | | } catch (IllegalArgumentException | IllegalAccessException e) { |
| | | throw new IllegalStateException(e); |
| | | } |
| | | } |
| | | }; |
| | | } |
| | | |
| | | } |
| | |
| | | import org.springframework.web.servlet.AsyncHandlerInterceptor; |
| | | import org.springframework.web.servlet.config.annotation.CorsRegistry; |
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
| | | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | public void addInterceptors(InterceptorRegistry registry) { |
| | | registry.addInterceptor(getAsyncHandlerInterceptor()) |
| | | .addPathPatterns("/**") |
| | | ; |
| | | .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**","/v3/**","/doc.html/**", "/swagger-ui.html/**"); |
| | | } |
| | | |
| | | @Bean |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void addResourceHandlers(ResourceHandlerRegistry registry) { |
| | | registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); |
| | | registry.addResourceHandler("swagger-ui.html") |
| | | .addResourceLocations("classpath:/META-INF/resources/"); |
| | | registry.addResourceHandler("doc.html") |
| | | .addResourceLocations("classpath:/META-INF/resources/"); |
| | | registry.addResourceHandler("/webjars/**") |
| | | .addResourceLocations("classpath:/META-INF/resources/webjars/"); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void addCorsMappings(CorsRegistry registry) { |
| | | registry.addMapping("/**") |
| | | .allowedOriginPatterns("*") |
| | |
| | | package com.vincent.rsf.server.common.domain; |
| | | |
| | | import lombok.Data; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | |
| | | * @since 2017-06-10 10:10:02 |
| | | */ |
| | | @Data |
| | | @Accessors(chain = true) |
| | | public class PageResult<T> implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | "/login", |
| | | "/register", |
| | | "/druid/**", |
| | | "/doc.html", |
| | | "/swagger-ui.html", |
| | | "/swagger-resources/**", |
| | | "/webjars/**", |
| | | "/v2/api-docs", |
| | | "/v3/api-docs", |
| | | "/v2/api-docs/**", |
| | | "/v3/api-docs/**", |
| | | "/swagger-ui/**", |
| | | "/ws/**" |
| | | }; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.common.domain.PageResult; |
| | | import com.vincent.rsf.server.common.utils.ExcelUtil; |
| | | import com.vincent.rsf.server.common.annotation.OperationLog; |
| | | import com.vincent.rsf.server.common.domain.BaseParam; |
| | |
| | | import com.vincent.rsf.server.manager.entity.Matnr; |
| | | import com.vincent.rsf.server.manager.service.MatnrService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | @Api(tags = "物料表接口") |
| | | @RestController |
| | | public class MatnrController extends BaseController { |
| | | |
| | |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:matnr:list')") |
| | | @PostMapping("/matnr/group") |
| | | public R getGroupMatnrs(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<Matnr, BaseParam> pageParam = new PageParam<>(baseParam, Matnr.class); |
| | | LambdaQueryWrapper<Matnr> wrapper = new LambdaQueryWrapper<>(); |
| | | if (!Cools.isEmpty(map.get("condition"))) { |
| | | wrapper.like(Matnr::getName, map.get("condition")); |
| | | } |
| | | if (Cools.isEmpty(map.get("groupId"))) { |
| | | throw new CoolException("分类ID不能为空!!"); |
| | | } |
| | | wrapper.eq(Matnr::getGroupId, map.get("groupId")); |
| | | Page<Matnr> matnrPage = matnrService.page(new Page<>(1, 30), wrapper); |
| | | return R.ok(new PageResult().setRecords(matnrPage.getRecords()).setTotal(matnrPage.getTotal())); |
| | | } |
| | | |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:matnr:list')") |
| | | @PostMapping("/matnr/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.vincent.rsf.common.utils.Utils; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.server.common.domain.PageResult; |
| | | import com.vincent.rsf.server.common.utils.ExcelUtil; |
| | | import com.vincent.rsf.server.common.annotation.OperationLog; |
| | | import com.vincent.rsf.server.common.domain.BaseParam; |
| | |
| | | import com.vincent.rsf.server.manager.entity.MatnrGroup; |
| | | import com.vincent.rsf.server.manager.service.MatnrGroupService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | @Api(tags = "物料分组") |
| | | @RestController |
| | | public class MatnrGroupController extends BaseController { |
| | | |
| | |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:matnrGroup:list')") |
| | | @GetMapping("/matnrGroup/tree") |
| | | public R tree() { |
| | | List<MatnrGroup> matnrs = matnrGroupService.list(new LambdaQueryWrapper<>()); |
| | | List<MatnrGroup> treeData = Utils.toTreeData(matnrs, 0L, MatnrGroup::getParentId, MatnrGroup::getId, MatnrGroup::setChildren); |
| | | return R.ok().add(treeData); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:matnrGroup:list')") |
| | | @PostMapping("/matnrGroup/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(matnrGroupService.list(), MatnrGroup.class), response); |
| | |
| | | import com.vincent.rsf.server.manager.entity.Shipper; |
| | | import com.vincent.rsf.server.manager.service.ShipperService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModel; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | @Api(tags = "货主") |
| | | @RestController |
| | | public class ShipperController extends BaseController { |
| | | |
| | |
| | | import com.vincent.rsf.server.manager.entity.Warehouse; |
| | | import com.vincent.rsf.server.manager.service.WarehouseService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | @Api(tags = "仓库") |
| | | @RestController |
| | | public class WarehouseController extends BaseController { |
| | | |
| | |
| | | package com.vincent.rsf.server.manager.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | import com.vincent.rsf.server.system.entity.User; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @TableName("man_matnr") |
| | | @ApiModel(value = "Matnr", description = "物料所有基础属性") |
| | | public class Matnr implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | /** |
| | | * 条形码 |
| | | */ |
| | | @ApiModelProperty(value = "条形码") |
| | | private String barcode; |
| | | |
| | | /** |
| | |
| | | @ApiModelProperty(value= "备注") |
| | | private String memo; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value= "分类列表") |
| | | @TableField(exist = false) |
| | | private List<Matnr> children; |
| | | |
| | | public Matnr() {} |
| | | |
| | | public Matnr(String name,String code,Long shipperId,Long groupId,Long batchRegularId,String erpCode,String spec,String model,Double weight,String color,String size,String describle,Integer nromNum,String unit,String purchaseUnit,String stockUnit,Short stockLeval,Short flagLabelMange,Double safetyQty,Double minQty,Double maxQty,Integer stagnate,Integer validity,Integer validityWarn,Short flagCheck,Integer status,Integer deleted,Integer tenantId,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | |
| | | package com.vincent.rsf.server.manager.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | import com.vincent.rsf.server.system.entity.User; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @ApiModel(value = "物料类") |
| | | @TableName("man_matnr_group") |
| | | public class MatnrGroup implements Serializable { |
| | | |
| | |
| | | @ApiModelProperty(value= "备注") |
| | | private String memo; |
| | | |
| | | @ApiModelProperty(value = "子类") |
| | | @TableField(exist = false) |
| | | private List<MatnrGroup> children; |
| | | |
| | | public MatnrGroup() {} |
| | | |
| | | public MatnrGroup(String name,String code,Long parentId,Integer status,Integer deleted,Integer tenantId,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @ApiModel(value = "货主基础属性") |
| | | @TableName("man_shipper") |
| | | public class Shipper implements Serializable { |
| | | |
| | |
| | | package com.vincent.rsf.server.manager.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.vincent.rsf.server.common.domain.PageParam; |
| | | import com.vincent.rsf.server.manager.entity.Matnr; |
| | | import com.vincent.rsf.server.manager.entity.MatnrGroup; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | |
| | | @Repository |
| | | public interface MatnrGroupMapper extends BaseMapper<MatnrGroup> { |
| | | |
| | | IPage<Matnr> selectGroupMatnrs(PageParam request); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.vincent.rsf.server.manager.entity.MatnrGroup; |
| | | |
| | | |
| | | public interface MatnrGroupService extends IService<MatnrGroup> { |
| | | |
| | | } |
| | |
| | | package com.vincent.rsf.server.manager.service.impl; |
| | | |
| | | |
| | | import com.vincent.rsf.server.manager.mapper.MatnrGroupMapper; |
| | | import com.vincent.rsf.server.manager.entity.MatnrGroup; |
| | | import com.vincent.rsf.server.manager.service.MatnrGroupService; |
| | |
| | | |
| | | @Service("matnrGroupService") |
| | | public class MatnrGroupServiceImpl extends ServiceImpl<MatnrGroupMapper, MatnrGroup> implements MatnrGroupService { |
| | | |
| | | } |
| | |
| | | name: @pom.artifactId@ |
| | | mvc: |
| | | static-path-pattern: /** |
| | | path match: |
| | | matching-strategy: ANT_PATH_MATCHER |
| | | datasource: |
| | | driver-class-name: com.mysql.jdbc.Driver |
| | | url: jdbc:mysql://192.168.4.24:3306/rsf?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | |
| | | spring:
|
| | | profiles:
|
| | | active: prod
|
| | | active: dev
|
| | |
|
| | | config:
|
| | | system-name: @pom.artifactId@
|
| | |
| | |
|
| | | logging:
|
| | | file:
|
| | | path: logs/@pom.artifactId@ |
| | | path: logs/@pom.artifactId@
|
| | |
|
| | | #knife4j:
|
| | | # enable: true
|
| | | # openapi:
|
| | | # title: Knife4j官方文档
|
| | | # description: "`我是测试`,**你知道吗**
|
| | | # # aaa"
|
| | | # email: xiaoymin@foxmail.com
|
| | | # concat: 八一菜刀
|
| | | # url: https://docs.xiaominfo.com
|
| | | # version: v4.0
|
| | | # license: Apache 2.0
|
| | | # license-url: https://stackoverflow.com/
|
| | | # terms-of-service-url: https://stackoverflow.com/
|
| | | # group:
|
| | | # test1:
|
| | | # group-name: 分组名称
|
| | | # api-rule: package
|
| | | # api-rule-resources:
|
| | | # - com.knife4j.demo.new3 |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.vincent.rsf.server.manager.mapper.MatnrGroupMapper"> |
| | | |
| | | <select id="selectGroupMatnrs" resultType="com.vincent.rsf.server.manager.entity.Matnr"> |
| | | |
| | | </select> |
| | | </mapper> |