This commit is contained in:
caixiang 2022-06-22 10:23:56 +08:00
parent 3b7b592a16
commit 5d631e77c2
13 changed files with 51 additions and 26 deletions

View File

@ -13,7 +13,8 @@
<module>ym-generator</module> <module>ym-generator</module>
<module>ym-gateway</module> <module>ym-gateway</module>
<module>ym-barcode</module> <module>ym-barcode</module>
<module>yum-basic</module> <module>ym-baisc</module>
</modules> </modules>
<packaging>pom</packaging> <packaging>pom</packaging>

View File

@ -9,7 +9,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>yum-basic</artifactId> <artifactId>ym-baisc</artifactId>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>
@ -18,12 +18,17 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.cnbm</groupId> <groupId>com.cnbm</groupId>
<artifactId>ym-common</artifactId> <artifactId>ym-admin</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.cnbm</groupId>-->
<!-- <artifactId>ym-gateway</artifactId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.cnbm</groupId> <groupId>com.cnbm</groupId>
<artifactId>ym-admin</artifactId> <artifactId>ym-common</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -1,9 +1,6 @@
package com.cnbm.basic.controller; package com.cnbm.basic.controller;
import com.cnbm.admin.annotation.LogOperation; import com.cnbm.admin.annotation.LogOperation;
import com.cnbm.basic.dto.ProductTypeDTO;
import com.cnbm.basic.excel.ProductTypeExcel;
import com.cnbm.basic.service.IProductTypeService;
import com.cnbm.common.constant.Constant; import com.cnbm.common.constant.Constant;
import com.cnbm.common.page.PageData; import com.cnbm.common.page.PageData;
import com.cnbm.common.utils.ExcelUtils; import com.cnbm.common.utils.ExcelUtils;
@ -13,13 +10,14 @@ import com.cnbm.common.validator.ValidatorUtils;
import com.cnbm.common.validator.group.AddGroup; import com.cnbm.common.validator.group.AddGroup;
import com.cnbm.common.validator.group.DefaultGroup; import com.cnbm.common.validator.group.DefaultGroup;
import com.cnbm.common.validator.group.UpdateGroup; import com.cnbm.common.validator.group.UpdateGroup;
import com.cnbm.basic.dto.ProductTypeDTO;
import com.cnbm.basic.excel.ProductTypeExcel;
import com.cnbm.basic.service.IProductTypeService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
@ -36,7 +34,7 @@ import java.util.Map;
* @since 2022-06-21 * @since 2022-06-21
*/ */
@RestController @RestController
@RequestMapping("/generator/productType") @RequestMapping("/basic/productType")
@Api(tags="产品类型 表") @Api(tags="产品类型 表")
public class ProductTypeController { public class ProductTypeController {
@Autowired @Autowired
@ -50,7 +48,7 @@ public class ProductTypeController {
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
}) })
@PreAuthorize("@ex.hasAuthority('generator:productType:page')") // @PreAuthorize("@ex.hasAuthority('basic:productType:page')")
public Result<PageData<ProductTypeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ public Result<PageData<ProductTypeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<ProductTypeDTO> page = productTypeService.page(params); PageData<ProductTypeDTO> page = productTypeService.page(params);
@ -59,7 +57,7 @@ public class ProductTypeController {
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
@PreAuthorize("@ex.hasAuthority('generator:productType:info')") // @PreAuthorize("@ex.hasAuthority('basic:productType:info')")
public Result<ProductTypeDTO> get(@PathVariable("id") Long id){ public Result<ProductTypeDTO> get(@PathVariable("id") Long id){
ProductTypeDTO data = productTypeService.get(id); ProductTypeDTO data = productTypeService.get(id);
@ -69,7 +67,7 @@ public class ProductTypeController {
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
@LogOperation("保存") @LogOperation("保存")
@PreAuthorize("@ex.hasAuthority('generator:productType:save')") // @PreAuthorize("@ex.hasAuthority('basic:productType:save')")
public Result save(@RequestBody ProductTypeDTO dto){ public Result save(@RequestBody ProductTypeDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
@ -82,7 +80,7 @@ public class ProductTypeController {
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
@PreAuthorize("@ex.hasAuthority('generator:productType:update')") // @PreAuthorize("@ex.hasAuthority('basic:productType:update')")
public Result update(@RequestBody ProductTypeDTO dto){ public Result update(@RequestBody ProductTypeDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
@ -95,7 +93,7 @@ public class ProductTypeController {
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
@LogOperation("删除") @LogOperation("删除")
@PreAuthorize("@ex.hasAuthority('generator:productType:delete')") // @PreAuthorize("@ex.hasAuthority('basic:productType:delete')")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
//效验数据 //效验数据
AssertUtils.isArrayEmpty(ids, "id"); AssertUtils.isArrayEmpty(ids, "id");
@ -108,7 +106,7 @@ public class ProductTypeController {
@GetMapping("export") @GetMapping("export")
@ApiOperation("导出") @ApiOperation("导出")
@LogOperation("导出") @LogOperation("导出")
@PreAuthorize("@ex.hasAuthority('generator:productType:export')") // @PreAuthorize("@ex.hasAuthority('basic:productType:export')")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<ProductTypeDTO> list = productTypeService.list(params); List<ProductTypeDTO> list = productTypeService.list(params);

View File

@ -1,8 +1,7 @@
package com.cnbm.basic.mapper; package com.cnbm.basic.mapper;
import com.cnbm.basic.entity.ProductType;
import com.cnbm.common.dao.BaseDao; import com.cnbm.common.dao.BaseDao;
import com.cnbm.basic.entity.ProductType;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**

View File

@ -1,9 +1,8 @@
package com.cnbm.basic.service; package com.cnbm.basic.service;
import com.cnbm.common.service.CrudService;
import com.cnbm.basic.dto.ProductTypeDTO; import com.cnbm.basic.dto.ProductTypeDTO;
import com.cnbm.basic.entity.ProductType; import com.cnbm.basic.entity.ProductType;
import com.cnbm.common.service.CrudService;
/** /**
* 产品类型 * 产品类型

View File

@ -1,12 +1,11 @@
package com.cnbm.basic.service.impl; package com.cnbm.basic.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cnbm.common.service.impl.CrudServiceImpl;
import com.cnbm.basic.dto.ProductTypeDTO; import com.cnbm.basic.dto.ProductTypeDTO;
import com.cnbm.basic.entity.ProductType; import com.cnbm.basic.entity.ProductType;
import com.cnbm.basic.mapper.ProductTypeMapper; import com.cnbm.basic.mapper.ProductTypeMapper;
import com.cnbm.basic.service.IProductTypeService; import com.cnbm.basic.service.IProductTypeService;
import com.cnbm.common.service.impl.CrudServiceImpl;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cnbm.generator.mapper.ProductTypeMapper"> <mapper namespace="com.cnbm.basic.mapper.ProductTypeMapper">
</mapper> </mapper>

View File

@ -34,7 +34,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.cnbm</groupId> <groupId>com.cnbm</groupId>
<artifactId>ym-basic</artifactId> <artifactId>ym-baisc</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -54,6 +54,22 @@ public class SwaggerConfig {
.securitySchemes(Arrays.asList(new ApiKey("token", "token", "header"))); .securitySchemes(Arrays.asList(new ApiKey("token", "token", "header")));
} }
@Bean
public Docket basicApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("ym-basic")
.apiInfo(apiInfos("basic", "基础资料模块"))
.useDefaultResponseMessages(true)
.forCodeGeneration(false)
.select()
.apis(RequestHandlerSelectors.basePackage("com.cnbm.basic"))
.paths(PathSelectors.any())
.build()
.securityContexts(Arrays.asList(securityContext()))
// ApiKey的name需与SecurityReference的reference保持一致
.securitySchemes(Arrays.asList(new ApiKey("token", "token", "header")));
}
/** /**
* 创建该API的基本信息这些基本信息会展现在文档页面中 * 创建该API的基本信息这些基本信息会展现在文档页面中
* 访问地址http://ip:port/swagger-ui.html * 访问地址http://ip:port/swagger-ui.html
@ -68,6 +84,14 @@ public class SwaggerConfig {
.version(version) .version(version)
.build(); .build();
} }
private ApiInfo apiInfos(String title, String desc) {
return new ApiInfoBuilder()
.title(title)
.description(desc)
.termsOfServiceUrl("https://www.baidu.com/")
.version("1.0")
.build();
}
private SecurityContext securityContext() { private SecurityContext securityContext() {
return SecurityContext.builder() return SecurityContext.builder()

View File

@ -7,14 +7,14 @@ server:
min-spare: 30 min-spare: 30
port: 8080 port: 8080
servlet: servlet:
context-path: /ym-pass context-path: /ym-spc
session: session:
cookie: cookie:
http-only: true http-only: true
spring: spring:
application: application:
name: ym-pass name: ym-spc
# 环境 dev|test|prod # 环境 dev|test|prod
profiles: profiles:
active: dev active: dev