增加简单的部署打包脚本
增加 Dubbo 参数校验
This commit is contained in:
@@ -113,6 +113,16 @@
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- 打包 -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<fork>true</fork>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -2,12 +2,14 @@ package cn.iocoder.mall.admin.application;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.admin"})
|
||||
public class AdminApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AdminApplication.class, args);
|
||||
ConfigurableApplicationContext ctx = SpringApplication.run(AdminApplication.class, args);
|
||||
System.out.println(); // TODO 后面去掉,这里是临时的
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,10 +5,7 @@ import cn.iocoder.mall.admin.sdk.interceptor.AdminSecurityInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
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 org.springframework.web.servlet.config.annotation.*;
|
||||
|
||||
@EnableWebMvc
|
||||
@Configuration
|
||||
@@ -36,4 +33,13 @@ public class MVCConfiguration implements WebMvcConfigurer {
|
||||
registry.addResourceHandler("webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
}
|
||||
|
||||
// TODO 芋艿,允许跨域
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedHeaders("*")
|
||||
.allowedMethods("*")
|
||||
.allowedOrigins("*");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
@EnableSwagger2 // TODO 生产环境时,禁用掉。
|
||||
public class SwaggerConfiguration {
|
||||
|
||||
@Bean
|
||||
@@ -19,7 +19,7 @@ public class SwaggerConfiguration {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.iocoder.mall.admin.controller"))
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.iocoder.mall.admin.application.controller"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -4,19 +4,19 @@ import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.admin.api.ResourceService;
|
||||
import cn.iocoder.mall.admin.api.bo.ResourceBO;
|
||||
import cn.iocoder.mall.admin.api.constant.ResourceType;
|
||||
import cn.iocoder.mall.admin.api.dto.ResourceAddDTO;
|
||||
import cn.iocoder.mall.admin.application.convert.ResourceConvert;
|
||||
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
|
||||
import cn.iocoder.mall.admin.application.vo.AdminMenuTreeNodeVO;
|
||||
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
|
||||
import com.alibaba.dubbo.config.annotation.Reference;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@@ -24,11 +24,13 @@ import java.util.stream.Collectors;
|
||||
@Api("资源模块")
|
||||
public class ResourceController {
|
||||
|
||||
@Reference
|
||||
@Reference(validation = "true")
|
||||
private ResourceService resourceService;
|
||||
|
||||
// =========== 当前管理员相关的资源 API ===========
|
||||
|
||||
@GetMapping("/admin_menu_tree")
|
||||
@ApiOperation(value = "获得管理员拥有的菜单权限", notes = "以树结构返回")
|
||||
@ApiOperation(value = "获得当前登陆的管理员拥有的菜单权限", notes = "以树结构返回")
|
||||
public CommonResult<List<AdminMenuTreeNodeVO>> adminMenuTree() {
|
||||
List<ResourceBO> resources = resourceService.getResourceByTypeAndRoleIds(ResourceType.MENU, AdminSecurityContextHolder.getContext().getRoleIds());
|
||||
// 创建 AdminMenuTreeNodeVO Map
|
||||
@@ -53,9 +55,36 @@ public class ResourceController {
|
||||
}
|
||||
|
||||
@GetMapping("/admin_url_list")
|
||||
@ApiOperation(value = "获得管理员拥有的 URL 权限列表")
|
||||
public CommonResult adminUrlList() {
|
||||
return null;
|
||||
@ApiOperation(value = "获得当前登陆的管理员拥有的 URL 权限列表")
|
||||
// @ApiModelProperty(value = "data", example = "['/admin/role/add', '/admin/role/update']") 没效果
|
||||
public CommonResult<Set<String>> adminUrlList() {
|
||||
List<ResourceBO> resources = resourceService.getResourceByTypeAndRoleIds(ResourceType.URL, AdminSecurityContextHolder.getContext().getRoleIds());
|
||||
return CommonResult.success(resources.stream().map(ResourceBO::getHandler).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
|
||||
// =========== 资源管理 API ===========
|
||||
|
||||
// TODO 芋艿,注释
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "创建资源", notes = "例如说,菜单资源,Url 资源")
|
||||
public void add(@RequestParam("name") String name,
|
||||
@RequestParam("type") Integer type,
|
||||
@RequestParam("sort") Integer sort,
|
||||
@RequestParam("displayName") String displayName,
|
||||
@RequestParam("pid") Integer pid,
|
||||
@RequestParam("handler") String handler) {
|
||||
ResourceAddDTO resourceAddDTO = new ResourceAddDTO().setName(name).setType(type).setSort(sort)
|
||||
.setDisplayName(displayName).setPid(pid).setHandler(handler);
|
||||
CommonResult<ResourceBO> result = resourceService.addResource(resourceAddDTO);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +1,22 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("管理员拥有的菜单 VO")
|
||||
public class AdminMenuTreeNodeVO {
|
||||
|
||||
/**
|
||||
* 菜单编号
|
||||
*/
|
||||
@ApiModelProperty(value = "菜单编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
/**
|
||||
* 彩蛋名
|
||||
*/
|
||||
@ApiModelProperty(value = "菜单名", required = true, example = "商品管理")
|
||||
private String name;
|
||||
/**
|
||||
* 操作
|
||||
*/
|
||||
@ApiModelProperty(value = "菜单操作", required = true, example = "/order/list")
|
||||
private String handler;
|
||||
/**
|
||||
* 父菜单编号
|
||||
*/
|
||||
@ApiModelProperty(value = "父菜单编号", required = true, example = "1", notes = "如果无父菜单,则值为 0")
|
||||
private Integer pid;
|
||||
/**
|
||||
* 子节点数组
|
||||
*/
|
||||
@ApiModelProperty(value = "子节点数组", example = "[1, 2, 3]")
|
||||
private List<AdminMenuTreeNodeVO> children;
|
||||
|
||||
public Integer getId() {
|
||||
|
||||
@@ -4,4 +4,4 @@ spring:
|
||||
|
||||
# server
|
||||
server:
|
||||
port: 8083
|
||||
port: 18083
|
||||
Reference in New Issue
Block a user