- admin 模块重命名 system 模块
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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"})
|
||||
//@EnableAdminServer
|
||||
public class AdminApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext ctx = SpringApplication.run(AdminApplication.class, args);
|
||||
// Object bean = ctx.getBean("test");
|
||||
// System.out.println(AopUtils.getTargetClass(bean));
|
||||
|
||||
// System.out.println(bean);
|
||||
|
||||
// ConfigurableApplicationContext ctx =
|
||||
// System.out.println(); // TODO 后面去掉,这里是临时的
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package cn.iocoder.mall.admin.application.config;
|
||||
|
||||
import cn.iocoder.common.framework.config.GlobalExceptionHandler;
|
||||
import cn.iocoder.common.framework.servlet.CorsFilter;
|
||||
import cn.iocoder.mall.admin.sdk.interceptor.AdminAccessLogInterceptor;
|
||||
import cn.iocoder.mall.admin.sdk.interceptor.AdminSecurityInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
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 java.util.Set;
|
||||
|
||||
@EnableWebMvc
|
||||
@Configuration
|
||||
@Import(value = {GlobalExceptionHandler.class, // 统一全局返回
|
||||
AdminSecurityInterceptor.class})
|
||||
public class MVCConfiguration implements WebMvcConfigurer {
|
||||
|
||||
// @Autowired
|
||||
// private UserSecurityInterceptor securityInterceptor;
|
||||
|
||||
@Autowired
|
||||
private AdminSecurityInterceptor adminSecurityInterceptor;
|
||||
@Autowired
|
||||
private AdminAccessLogInterceptor adminAccessLogInterceptor;
|
||||
|
||||
@Value("${auth.ignore-urls}")
|
||||
private Set<String> ignoreUrls;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// registry.addInterceptor(securityInterceptor).addPathPatterns("/user/**", "/admin/**"); // 只拦截我们定义的接口
|
||||
registry.addInterceptor(adminAccessLogInterceptor).addPathPatterns("/admins/**");
|
||||
registry.addInterceptor(adminSecurityInterceptor.setIgnoreUrls(ignoreUrls)).addPathPatterns("/admins/**")
|
||||
.excludePathPatterns("/admins/passport/login"); // 排除登陆接口
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
// 解决 swagger-ui.html 的访问,参考自 https://stackoverflow.com/questions/43545540/swagger-ui-no-mapping-found-for-http-request 解决
|
||||
registry.addResourceHandler("swagger-ui.html**").addResourceLocations("classpath:/META-INF/resources/swagger-ui.html");
|
||||
registry.addResourceHandler("webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean<CorsFilter> corsFilter() {
|
||||
FilterRegistrationBean<CorsFilter> registrationBean = new FilterRegistrationBean<>();
|
||||
registrationBean.setFilter(new CorsFilter());
|
||||
registrationBean.addUrlPatterns("/*");
|
||||
return registrationBean;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.iocoder.mall.admin.application.config;
|
||||
|
||||
import com.qiniu.util.Auth;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class QiniuConfiguration {
|
||||
|
||||
@Value("${qiniu.access-key}")
|
||||
private String accessKey;
|
||||
@Value("${qiniu.secret-key}")
|
||||
private String secretKey;
|
||||
|
||||
@Bean
|
||||
public Auth auth() {
|
||||
return Auth.create(accessKey, secretKey);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.iocoder.mall.admin.application.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2 // TODO 生产环境时,禁用掉。
|
||||
public class SwaggerConfiguration {
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("cn.iocoder.mall.admin.application.controller"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("管理员子系统")
|
||||
.description("管理员子系统")
|
||||
.termsOfServiceUrl("http://www.iocoder.cn")
|
||||
.version("1.0.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package cn.iocoder.mall.admin.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.admin.api.AdminService;
|
||||
import cn.iocoder.mall.admin.api.ResourceService;
|
||||
import cn.iocoder.mall.admin.api.RoleService;
|
||||
import cn.iocoder.mall.admin.api.bo.AdminPageBO;
|
||||
import cn.iocoder.mall.admin.api.bo.ResourceBO;
|
||||
import cn.iocoder.mall.admin.api.bo.RoleBO;
|
||||
import cn.iocoder.mall.admin.api.constant.ResourceConstants;
|
||||
import cn.iocoder.mall.admin.api.dto.AdminAddDTO;
|
||||
import cn.iocoder.mall.admin.api.dto.AdminPageDTO;
|
||||
import cn.iocoder.mall.admin.api.dto.AdminUpdateDTO;
|
||||
import cn.iocoder.mall.admin.application.convert.AdminConvert;
|
||||
import cn.iocoder.mall.admin.application.convert.ResourceConvert;
|
||||
import cn.iocoder.mall.admin.application.vo.AdminMenuTreeNodeVO;
|
||||
import cn.iocoder.mall.admin.application.vo.AdminPageVO;
|
||||
import cn.iocoder.mall.admin.application.vo.AdminRoleVO;
|
||||
import cn.iocoder.mall.admin.application.vo.AdminVO;
|
||||
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/admin")
|
||||
@Api("管理员模块")
|
||||
public class AdminController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
private ResourceService resourceService;
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
private AdminService adminService;
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
private RoleService roleService;
|
||||
|
||||
// =========== 当前管理员相关的资源 API ===========
|
||||
|
||||
// TODO 功能:当前管理员
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
@GetMapping("/menu_resource_tree")
|
||||
@ApiOperation(value = "获得当前登陆的管理员拥有的菜单权限", notes = "以树结构返回")
|
||||
public CommonResult<List<AdminMenuTreeNodeVO>> menuResourceTree() {
|
||||
List<ResourceBO> resources = resourceService.getResourcesByTypeAndRoleIds(ResourceConstants.TYPE_MENU, AdminSecurityContextHolder.getContext().getRoleIds());
|
||||
// 创建 AdminMenuTreeNodeVO Map
|
||||
// Map<Integer, AdminMenuTreeNodeVO> treeNodeMap = resources.stream().collect(Collectors.toMap(ResourceBO::getId, ResourceConvert.INSTANCE::convert));
|
||||
Map<Integer, AdminMenuTreeNodeVO> treeNodeMap = new LinkedHashMap<>(); // 使用 LinkedHashMap 的原因,是为了排序 。实际也可以用 Stream API ,就是太丑了。
|
||||
resources.stream().sorted(Comparator.comparing(ResourceBO::getSort)).forEach(resourceBO -> treeNodeMap.put(resourceBO.getId(), ResourceConvert.INSTANCE.convert(resourceBO)));
|
||||
// 处理父子关系
|
||||
treeNodeMap.values().stream()
|
||||
.filter(node -> !node.getPid().equals(ResourceConstants.PID_ROOT))
|
||||
.forEach((childNode) -> {
|
||||
// 获得父节点
|
||||
AdminMenuTreeNodeVO parentNode = treeNodeMap.get(childNode.getPid());
|
||||
if (parentNode.getChildren() == null) { // 初始化 children 数组
|
||||
parentNode.setChildren(new ArrayList<>());
|
||||
}
|
||||
// 将自己添加到父节点中
|
||||
parentNode.getChildren().add(childNode);
|
||||
});
|
||||
// 获得到所有的根节点
|
||||
List<AdminMenuTreeNodeVO> rootNodes = treeNodeMap.values().stream()
|
||||
.filter(node -> node.getPid().equals(ResourceConstants.PID_ROOT))
|
||||
// .sorted(Comparator.comparing(AdminMenuTreeNodeVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
return CommonResult.success(rootNodes);
|
||||
}
|
||||
|
||||
@GetMapping("/url_resource_list")
|
||||
@ApiOperation(value = "获得当前登陆的管理员拥有的 URL 权限列表")
|
||||
// @ApiModelProperty(value = "data", example = "['/admin/role/add', '/admin/role/update']") 没效果
|
||||
public CommonResult<Set<String>> urlResourceList() {
|
||||
List<ResourceBO> resources = resourceService.getResourcesByTypeAndRoleIds(ResourceConstants.TYPE_URL, AdminSecurityContextHolder.getContext().getRoleIds());
|
||||
return CommonResult.success(resources.stream().map(ResourceBO::getHandler).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
// =========== 管理员管理 API ===========
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation(value = "管理员分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "nickname", value = "昵称,模糊匹配", example = "小王"),
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"),
|
||||
})
|
||||
public CommonResult<AdminPageVO> page(@RequestParam(value = "nickname", required = false) String nickname,
|
||||
@RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
CommonResult<AdminPageBO> result = adminService.getAdminPage(new AdminPageDTO().setNickname(nickname).setPageNo(pageNo).setPageSize(pageSize));
|
||||
return AdminConvert.INSTANCE.convert(result);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "创建管理员")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "username", value = "账号", required = true, example = "15601691300"),
|
||||
@ApiImplicitParam(name = "nickname", value = "昵称", required = true, example = "小王"),
|
||||
@ApiImplicitParam(name = "password", value = "密码", required = true, example = "buzhidao"),
|
||||
})
|
||||
public CommonResult<AdminVO> add(@RequestParam("username") String username,
|
||||
@RequestParam("nickname") String nickname,
|
||||
@RequestParam("password") String password) {
|
||||
AdminAddDTO adminAddDTO = new AdminAddDTO().setUsername(username).setNickname(nickname).setPassword(password);
|
||||
return AdminConvert.INSTANCE.convert2(adminService.addAdmin(AdminSecurityContextHolder.getContext().getAdminId(), adminAddDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "更新管理员")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "管理员编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "username", value = "账号", required = true, example = "15601691300"),
|
||||
@ApiImplicitParam(name = "nickname", value = "昵称", required = true, example = "小王"),
|
||||
@ApiImplicitParam(name = "password", value = "密码", example = "buzhidao"),
|
||||
})
|
||||
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
|
||||
@RequestParam("username") String username,
|
||||
@RequestParam("nickname") String nickname,
|
||||
@RequestParam(value = "password", required = false) String password) {
|
||||
AdminUpdateDTO adminUpdateDTO = new AdminUpdateDTO().setId(id).setUsername(username).setNickname(nickname).setPassword(password);
|
||||
return adminService.updateAdmin(AdminSecurityContextHolder.getContext().getAdminId(), adminUpdateDTO);
|
||||
}
|
||||
|
||||
@PostMapping("/update_status")
|
||||
@ApiOperation(value = "更新管理员状态")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "管理员编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "status", value = "状态。1 - 开启;2 - 禁用", required = true, example = "1"),
|
||||
})
|
||||
public CommonResult<Boolean> updateStatus(@RequestParam("id") Integer id,
|
||||
@RequestParam("status") Integer status) {
|
||||
return adminService.updateAdminStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除管理员")
|
||||
@ApiImplicitParam(name = "id", value = "管理员编号", required = true, example = "1")
|
||||
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
|
||||
return adminService.deleteAdmin(AdminSecurityContextHolder.getContext().getAdminId(), id);
|
||||
}
|
||||
|
||||
@GetMapping("/role_list")
|
||||
@ApiOperation(value = "指定管理员拥有的角色列表")
|
||||
@ApiImplicitParam(name = "id", value = "管理员编号", required = true, example = "1")
|
||||
public CommonResult<List<AdminRoleVO>> roleList(@RequestParam("id") Integer id) {
|
||||
// 获得管理员拥有的角色集合
|
||||
Set<Integer> adminRoleIdSet = roleService.getRoleList(id).getData();
|
||||
// 获得所有角色数组
|
||||
List<RoleBO> allRoleList = roleService.getRoleList().getData();
|
||||
// 转换出返回结果
|
||||
List<AdminRoleVO> result = AdminConvert.INSTANCE.convert(allRoleList);
|
||||
// 设置每个角色是否赋予给改管理员
|
||||
result.forEach(adminRoleVO -> adminRoleVO.setAssigned(adminRoleIdSet.contains(adminRoleVO.getId())));
|
||||
return CommonResult.success(result);
|
||||
}
|
||||
|
||||
@PostMapping("/assign_role")
|
||||
@ApiOperation(value = "分配给管理员角色")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "管理员编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "roleIds", value = "角色编号集合", required = true, example = "1,2,3"),
|
||||
})
|
||||
public CommonResult<Boolean> assignRole(@RequestParam("id") Integer id,
|
||||
@RequestParam("roleIds")Set<Integer> roleIds) {
|
||||
return adminService.assignRole(AdminSecurityContextHolder.getContext().getAdminId(), id, roleIds);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package cn.iocoder.mall.admin.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.admin.api.DataDictService;
|
||||
import cn.iocoder.mall.admin.api.bo.DataDictBO;
|
||||
import cn.iocoder.mall.admin.api.dto.DataDictAddDTO;
|
||||
import cn.iocoder.mall.admin.api.dto.DataDictUpdateDTO;
|
||||
import cn.iocoder.mall.admin.application.convert.DataDictConvert;
|
||||
import cn.iocoder.mall.admin.application.vo.DataDictEnumVO;
|
||||
import cn.iocoder.mall.admin.application.vo.DataDictVO;
|
||||
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/data_dict")
|
||||
@Api("数据字典模块")
|
||||
public class DataDictController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
private DataDictService dataDictService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "数据字典全列表")
|
||||
public CommonResult<List<DataDictVO>> list() {
|
||||
CommonResult<List<DataDictBO>> result = dataDictService.selectDataDictList();
|
||||
return DataDictConvert.INSTANCE.convert(result);
|
||||
}
|
||||
|
||||
@GetMapping("/tree")
|
||||
@ApiOperation(value = "数据字典树结构", notes = "该接口返回的信息更为精简。一般用于前端缓存数据字典到本地。")
|
||||
public CommonResult<List<DataDictEnumVO>> tree() {
|
||||
// 查询数据字典全列表
|
||||
CommonResult<List<DataDictBO>> result = dataDictService.selectDataDictList();
|
||||
if (result.isError()) {
|
||||
return CommonResult.error(result);
|
||||
}
|
||||
// 构建基于 enumValue 聚合的 Multimap
|
||||
ImmutableListMultimap<String, DataDictBO> dataDictMap = Multimaps.index(result.getData(), DataDictBO::getEnumValue); // KEY 是 enumValue ,VALUE 是 DataDictBO 数组
|
||||
// 构建返回结果
|
||||
List<DataDictEnumVO> dataDictEnumVOs = new ArrayList<>(dataDictMap.size());
|
||||
dataDictMap.keys().forEach(enumValue -> {
|
||||
DataDictEnumVO dataDictEnumVO = new DataDictEnumVO().setEnumValue(enumValue)
|
||||
.setValues(DataDictConvert.INSTANCE.convert2(dataDictMap.get(enumValue)));
|
||||
dataDictEnumVOs.add(dataDictEnumVO);
|
||||
});
|
||||
return CommonResult.success(dataDictEnumVOs);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "创建数据字典")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "enumValue", value = "大类枚举值", required = true, example = "gender"),
|
||||
@ApiImplicitParam(name = "value", value = "小类数值", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "displayName", value = "展示名", required = true, example = "男"),
|
||||
@ApiImplicitParam(name = "sort", required = true, value = "排序值", defaultValue = "10"),
|
||||
@ApiImplicitParam(name = "memo", value = "备注", example = "你猜我猜不猜"),
|
||||
})
|
||||
public CommonResult<DataDictVO> add(@RequestParam("enumValue") String enumValue,
|
||||
@RequestParam("value") String value,
|
||||
@RequestParam("displayName") String displayName,
|
||||
@RequestParam("sort") Integer sort,
|
||||
@RequestParam(value = "memo", required = false) String memo) {
|
||||
// 创建 DataDictAddDTO 对象
|
||||
DataDictAddDTO dataDictAddDTO = new DataDictAddDTO().setEnumValue(enumValue).setValue(value).setDisplayName(displayName)
|
||||
.setSort(sort).setMemo(memo);
|
||||
// 保存数据字典
|
||||
CommonResult<DataDictBO> result = dataDictService.addDataDict(AdminSecurityContextHolder.getContext().getAdminId(), dataDictAddDTO);
|
||||
// 返回结果
|
||||
return DataDictConvert.INSTANCE.convert2(result);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "更新数据字典")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "100"),
|
||||
@ApiImplicitParam(name = "value", value = "小类数值", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "displayName", value = "展示名", required = true, example = "男"),
|
||||
@ApiImplicitParam(name = "sort", required = true, value = "排序值", defaultValue = "10"),
|
||||
@ApiImplicitParam(name = "memo", value = "备注", example = "你猜我猜不猜"),
|
||||
})
|
||||
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
|
||||
@RequestParam("value") String value,
|
||||
@RequestParam("displayName") String displayName,
|
||||
@RequestParam("sort") Integer sort,
|
||||
@RequestParam(value = "memo", required = false) String memo) {
|
||||
// 创建 DataDictAddDTO 对象
|
||||
DataDictUpdateDTO dataDictUpdateDTO = new DataDictUpdateDTO().setId(id).setValue(value).setDisplayName(displayName)
|
||||
.setSort(sort).setMemo(memo);
|
||||
// 更新数据字典
|
||||
return dataDictService.updateDataDict(AdminSecurityContextHolder.getContext().getAdminId(), dataDictUpdateDTO);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除数据字典")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "100")
|
||||
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
|
||||
return dataDictService.deleteDataDict(AdminSecurityContextHolder.getContext().getAdminId(), id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.mall.admin.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import com.qiniu.util.Auth;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/file")
|
||||
@Api("文件模块")
|
||||
public class FileController {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Autowired
|
||||
private Auth auth;
|
||||
@Value("${qiniu.bucket}")
|
||||
private String bucket;
|
||||
|
||||
@GetMapping("/get_qiniu_token")
|
||||
public CommonResult<String> getQiniuToken() {
|
||||
String token = auth.uploadToken(bucket);
|
||||
logger.info("[qiniu_token][token({}) get]", token);
|
||||
return CommonResult.success(token);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.iocoder.mall.admin.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.admin.api.OAuth2Service;
|
||||
import cn.iocoder.mall.admin.api.bo.OAuth2AccessTokenBO;
|
||||
import cn.iocoder.mall.admin.application.convert.PassportConvert;
|
||||
import cn.iocoder.mall.admin.application.vo.PassportLoginVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/passport")
|
||||
@Api("Admin Passport 模块")
|
||||
public class PassportController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
private OAuth2Service oauth2Service;
|
||||
|
||||
@PostMapping("/login")
|
||||
@ApiOperation(value = "手机号 + 密码登陆")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "username", value = "账号", required = true, example = "15601691300"),
|
||||
@ApiImplicitParam(name = "password", value = "密码", required = true, example = "future")
|
||||
})
|
||||
public CommonResult<PassportLoginVO> login(@RequestParam("username") String username,
|
||||
@RequestParam("password") String password) {
|
||||
CommonResult<OAuth2AccessTokenBO> result = oauth2Service.getAccessToken(username, password);
|
||||
return PassportConvert.INSTANCE.convert(result);
|
||||
}
|
||||
|
||||
// TODO 功能 logout
|
||||
|
||||
// TODO 功能 refresh_token
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package cn.iocoder.mall.admin.application.controller.admins;
|
||||
|
||||
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.ResourceConstants;
|
||||
import cn.iocoder.mall.admin.api.dto.ResourceAddDTO;
|
||||
import cn.iocoder.mall.admin.api.dto.ResourceUpdateDTO;
|
||||
import cn.iocoder.mall.admin.application.convert.ResourceConvert;
|
||||
import cn.iocoder.mall.admin.application.vo.ResourceTreeNodeVO;
|
||||
import cn.iocoder.mall.admin.application.vo.ResourceVO;
|
||||
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/resource")
|
||||
@Api("资源模块")
|
||||
public class ResourceController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
private ResourceService resourceService;
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
@GetMapping("/tree")
|
||||
@ApiOperation(value = "获得所有资源,按照树形结构返回")
|
||||
public CommonResult<List<ResourceTreeNodeVO>> tree() {
|
||||
List<ResourceBO> resources = resourceService.getResourcesByType(null);
|
||||
// 创建 AdminMenuTreeNodeVO Map
|
||||
Map<Integer, ResourceTreeNodeVO> treeNodeMap = resources.stream().collect(Collectors.toMap(ResourceBO::getId, ResourceConvert.INSTANCE::convert2));
|
||||
// 处理父子关系
|
||||
treeNodeMap.values().stream()
|
||||
.filter(node -> !node.getPid().equals(ResourceConstants.PID_ROOT))
|
||||
.forEach((childNode) -> {
|
||||
// 获得父节点
|
||||
ResourceTreeNodeVO parentNode = treeNodeMap.get(childNode.getPid());
|
||||
if (parentNode.getChildren() == null) { // 初始化 children 数组
|
||||
parentNode.setChildren(new ArrayList<>());
|
||||
}
|
||||
// 将自己添加到父节点中
|
||||
parentNode.getChildren().add(childNode);
|
||||
});
|
||||
// 获得到所有的根节点
|
||||
List<ResourceTreeNodeVO> rootNodes = treeNodeMap.values().stream()
|
||||
.filter(node -> node.getPid().equals(ResourceConstants.PID_ROOT))
|
||||
.sorted(Comparator.comparing(ResourceTreeNodeVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
return CommonResult.success(rootNodes);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "创建资源", notes = "例如说,菜单资源,Url 资源")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "name", value = "资源名字(标识)", required = true, example = "admin/info"),
|
||||
@ApiImplicitParam(name = "type", value = "资源类型。1 代表【菜单】;2 代表【Url】", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "sort", value = "排序", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "displayName", value = "菜单展示名", required = true, example = "商品管理"),
|
||||
@ApiImplicitParam(name = "pid", value = "父级资源编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "handler", value = "操作", example = "/order/list"),
|
||||
})
|
||||
public CommonResult<ResourceVO> add(@RequestParam("name") String name,
|
||||
@RequestParam("type") Integer type,
|
||||
@RequestParam("sort") Integer sort,
|
||||
@RequestParam("displayName") String displayName,
|
||||
@RequestParam("pid") Integer pid,
|
||||
@RequestParam(value = "handler", required = false) String handler) {
|
||||
ResourceAddDTO resourceAddDTO = new ResourceAddDTO().setName(name).setType(type).setSort(sort)
|
||||
.setDisplayName(displayName).setPid(pid).setHandler(handler);
|
||||
return ResourceConvert.INSTANCE.convert3(resourceService.addResource(AdminSecurityContextHolder.getContext().getAdminId(), resourceAddDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "更新资源")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "资源编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "name", value = "资源名字(标识)", required = true, example = "admin/info"),
|
||||
@ApiImplicitParam(name = "sort", value = "排序", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "displayName", value = "菜单展示名", required = true, example = "商品管理"),
|
||||
@ApiImplicitParam(name = "pid", value = "父级资源编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "handler", value = "操作", example = "/order/list"),
|
||||
})
|
||||
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam("sort") Integer sort,
|
||||
@RequestParam("displayName") String displayName,
|
||||
@RequestParam("pid") Integer pid,
|
||||
@RequestParam(value = "handler", required = false) String handler) {
|
||||
ResourceUpdateDTO resourceUpdateDTO = new ResourceUpdateDTO().setId(id).setName(name).setSort(sort).setDisplayName(displayName).setPid(pid).setHandler(handler);
|
||||
return resourceService.updateResource(AdminSecurityContextHolder.getContext().getAdminId(), resourceUpdateDTO);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除资源")
|
||||
@ApiImplicitParam(name = "id", value = "资源编号", required = true, example = "1")
|
||||
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
|
||||
return resourceService.deleteResource(AdminSecurityContextHolder.getContext().getAdminId(), id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package cn.iocoder.mall.admin.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.util.CollectionUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.admin.api.ResourceService;
|
||||
import cn.iocoder.mall.admin.api.RoleService;
|
||||
import cn.iocoder.mall.admin.api.bo.ResourceBO;
|
||||
import cn.iocoder.mall.admin.api.bo.RolePageBO;
|
||||
import cn.iocoder.mall.admin.api.constant.ResourceConstants;
|
||||
import cn.iocoder.mall.admin.api.dto.RoleAddDTO;
|
||||
import cn.iocoder.mall.admin.api.dto.RolePageDTO;
|
||||
import cn.iocoder.mall.admin.api.dto.RoleUpdateDTO;
|
||||
import cn.iocoder.mall.admin.application.convert.ResourceConvert;
|
||||
import cn.iocoder.mall.admin.application.convert.RoleConvert;
|
||||
import cn.iocoder.mall.admin.application.vo.RolePageVO;
|
||||
import cn.iocoder.mall.admin.application.vo.RoleResourceTreeNodeVO;
|
||||
import cn.iocoder.mall.admin.application.vo.RoleVO;
|
||||
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/role")
|
||||
public class RoleController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
private RoleService roleService;
|
||||
@Reference(validation = "true")
|
||||
@Autowired // TODO Dubbo 2.7.2 移除 bug
|
||||
private ResourceService resourceService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation(value = "角色分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "name", value = "角色名,模糊匹配", required = true, example = "系统管理员"),
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"),
|
||||
})
|
||||
public CommonResult<RolePageVO> page(@RequestParam(value = "name", required = false) String name,
|
||||
@RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
CommonResult<RolePageBO> result = roleService.getRolePage(new RolePageDTO().setName(name).setPageNo(pageNo).setPageSize(pageSize));
|
||||
return RoleConvert.INSTANCE.convert2(result);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "创建角色")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "name", value = "角色", required = true, example = "系统管理员"),
|
||||
})
|
||||
public CommonResult<RoleVO> add(@RequestParam("name") String name) {
|
||||
RoleAddDTO roleAddDTO = new RoleAddDTO().setName(name);
|
||||
return RoleConvert.INSTANCE.convert(roleService.addRole(AdminSecurityContextHolder.getContext().getAdminId(), roleAddDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "更新角色")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "角色编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "name", value = "角色名", required = true, example = "系统管理员"),
|
||||
})
|
||||
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
|
||||
@RequestParam("name") String name) {
|
||||
RoleUpdateDTO roleUpdateDTO = new RoleUpdateDTO().setId(id).setName(name);
|
||||
return roleService.updateRole(AdminSecurityContextHolder.getContext().getAdminId(), roleUpdateDTO);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除角色")
|
||||
@ApiImplicitParam(name = "id", value = "角色编号", required = true, example = "1")
|
||||
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
|
||||
return roleService.deleteRole(AdminSecurityContextHolder.getContext().getAdminId(), id);
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
@GetMapping("/resource_tree")
|
||||
@ApiOperation(value = "获得角色拥有的菜单权限", notes = "以树结构返回")
|
||||
@ApiImplicitParam(name = "id", value = "角色编号", required = true, example = "1")
|
||||
public CommonResult<List<RoleResourceTreeNodeVO>> resourceTree(@RequestParam("id") Integer id) {
|
||||
// 芋艿:此处,严格来说可以在校验下角色是否存在。不过呢,校验了也没啥意义,因为一般不存在这个情况,且不会有业务上的影响。并且,反倒多了一次 rpc 调用。
|
||||
// 第一步,获得角色拥有的资源数组
|
||||
Set<Integer> roleResources = resourceService.getResourcesByTypeAndRoleIds(null, CollectionUtil.asSet(id))
|
||||
.stream().map(ResourceBO::getId).collect(Collectors.toSet());
|
||||
// 第二步,获得资源树
|
||||
List<ResourceBO> allResources = resourceService.getResourcesByType(null);
|
||||
// 创建 AdminMenuTreeNodeVO Map
|
||||
Map<Integer, RoleResourceTreeNodeVO> treeNodeMap = allResources.stream().collect(Collectors.toMap(ResourceBO::getId, ResourceConvert.INSTANCE::convert4));
|
||||
// 处理父子关系
|
||||
treeNodeMap.values().stream()
|
||||
.filter(node -> !node.getPid().equals(ResourceConstants.PID_ROOT))
|
||||
.forEach((childNode) -> {
|
||||
// 获得父节点
|
||||
RoleResourceTreeNodeVO parentNode = treeNodeMap.get(childNode.getPid());
|
||||
if (parentNode.getChildren() == null) { // 初始化 children 数组
|
||||
parentNode.setChildren(new ArrayList<>());
|
||||
}
|
||||
// 将自己添加到父节点中
|
||||
parentNode.getChildren().add(childNode);
|
||||
});
|
||||
// 获得到所有的根节点
|
||||
List<RoleResourceTreeNodeVO> rootNodes = treeNodeMap.values().stream()
|
||||
.filter(node -> node.getPid().equals(ResourceConstants.PID_ROOT))
|
||||
.sorted(Comparator.comparing(RoleResourceTreeNodeVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
// 第三步,设置角色是否有该角色
|
||||
treeNodeMap.values().forEach(nodeVO -> nodeVO.setAssigned(roleResources.contains(nodeVO.getId())));
|
||||
// 返回结果
|
||||
return CommonResult.success(rootNodes);
|
||||
}
|
||||
|
||||
@PostMapping("/assign_resource")
|
||||
@ApiOperation(value = "分配角色资源")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "角色编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "resourceIds", value = "资源数组", required = true, example = "1,2,3"),
|
||||
})
|
||||
public CommonResult<Boolean> assignResource(@RequestParam("id") Integer id,
|
||||
@RequestParam(value = "resourceIds", required = false) Set<Integer> resourceIds) {
|
||||
return roleService.assignResource(AdminSecurityContextHolder.getContext().getAdminId(), id, resourceIds);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.iocoder.mall.admin.application.convert;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.admin.api.bo.AdminBO;
|
||||
import cn.iocoder.mall.admin.api.bo.AdminPageBO;
|
||||
import cn.iocoder.mall.admin.api.bo.RoleBO;
|
||||
import cn.iocoder.mall.admin.application.vo.AdminInfoVO;
|
||||
import cn.iocoder.mall.admin.application.vo.AdminPageVO;
|
||||
import cn.iocoder.mall.admin.application.vo.AdminRoleVO;
|
||||
import cn.iocoder.mall.admin.application.vo.AdminVO;
|
||||
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContext;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AdminConvert {
|
||||
|
||||
AdminConvert INSTANCE = Mappers.getMapper(AdminConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
AdminInfoVO convert(AdminSecurityContext adminSecurityContext);
|
||||
|
||||
@Mappings({})
|
||||
AdminVO convert(AdminBO adminBO);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<AdminVO> convert2(CommonResult<AdminBO> result);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<AdminPageVO> convert(CommonResult<AdminPageBO> result);
|
||||
|
||||
@Mappings({})
|
||||
List<AdminRoleVO> convert(List<RoleBO> roleList);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.mall.admin.application.convert;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.admin.api.bo.DataDictBO;
|
||||
import cn.iocoder.mall.admin.application.vo.DataDictVO;
|
||||
import cn.iocoder.mall.admin.application.vo.DataDictValueVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DataDictConvert {
|
||||
|
||||
DataDictConvert INSTANCE = Mappers.getMapper(DataDictConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
DataDictVO convert(DataDictBO dataDictBO);
|
||||
|
||||
@Mappings({})
|
||||
List<DataDictVO> convert(List<DataDictBO> dataDictBOs);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<List<DataDictVO>> convert(CommonResult<List<DataDictBO>> result);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<DataDictVO> convert2(CommonResult<DataDictBO> result);
|
||||
|
||||
@Mappings({})
|
||||
List<DataDictValueVO> convert2(List<DataDictBO> dataDictBOs);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.iocoder.mall.admin.application.convert;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.admin.api.bo.OAuth2AccessTokenBO;
|
||||
import cn.iocoder.mall.admin.application.vo.PassportLoginVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface PassportConvert {
|
||||
|
||||
PassportConvert INSTANCE = Mappers.getMapper(PassportConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
PassportLoginVO convert(OAuth2AccessTokenBO oauth2AccessTokenBO);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<PassportLoginVO> convert(CommonResult<OAuth2AccessTokenBO> oauth2AccessTokenBO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.mall.admin.application.convert;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.admin.api.bo.ResourceBO;
|
||||
import cn.iocoder.mall.admin.application.vo.AdminMenuTreeNodeVO;
|
||||
import cn.iocoder.mall.admin.application.vo.ResourceTreeNodeVO;
|
||||
import cn.iocoder.mall.admin.application.vo.ResourceVO;
|
||||
import cn.iocoder.mall.admin.application.vo.RoleResourceTreeNodeVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface ResourceConvert {
|
||||
|
||||
ResourceConvert INSTANCE = Mappers.getMapper(ResourceConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
AdminMenuTreeNodeVO convert(ResourceBO resourceBO);
|
||||
|
||||
@Mappings({})
|
||||
ResourceTreeNodeVO convert2(ResourceBO resourceBO);
|
||||
|
||||
@Mappings({})
|
||||
RoleResourceTreeNodeVO convert4(ResourceBO resourceBO);
|
||||
|
||||
@Mappings({})
|
||||
ResourceVO convert3(ResourceBO resourceBO);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<ResourceVO> convert3(CommonResult<ResourceBO> resourceBO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.iocoder.mall.admin.application.convert;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.admin.api.bo.RoleBO;
|
||||
import cn.iocoder.mall.admin.api.bo.RolePageBO;
|
||||
import cn.iocoder.mall.admin.application.vo.RolePageVO;
|
||||
import cn.iocoder.mall.admin.application.vo.RoleVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface RoleConvert {
|
||||
|
||||
RoleConvert INSTANCE = Mappers.getMapper(RoleConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
RoleVO convert(RoleBO roleBO);
|
||||
|
||||
@Mappings({})
|
||||
List<RoleVO> convert(List<RoleBO> roleBO);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<RoleVO> convert(CommonResult<RoleBO> resourceBO);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<RolePageVO> convert2(CommonResult<RolePageBO> resourceBO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ApiModel("管理员信息 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminInfoVO {
|
||||
|
||||
@ApiModelProperty(value = "管理员比那好", required = true, example = "1")
|
||||
private Integer adminId;
|
||||
@ApiModelProperty(value = "角色编号的数组", required = true, example = "[1, 2]")
|
||||
private Set<Integer> roleIds;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("管理员拥有的菜单 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
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 = "排序", required = true, example = "1")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "菜单展示名", required = true, example = "商品管理")
|
||||
private String displayName;
|
||||
@ApiModelProperty(value = "子节点数组")
|
||||
private List<AdminMenuTreeNodeVO> children;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("管理员分页 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminPageVO {
|
||||
|
||||
@ApiModelProperty(value = "管理员数组")
|
||||
private List<AdminVO> list;
|
||||
@ApiModelProperty(value = "管理员总数")
|
||||
private Integer total;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@ApiModel("管理员拥有的角色 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminRoleVO {
|
||||
|
||||
@ApiModelProperty(value = "角色编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "角色名字", required = true, example = "系统管理员")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "是否授权", required = true, example = "true")
|
||||
private Boolean assigned;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("管理员 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminVO {
|
||||
|
||||
@ApiModelProperty(value = "管理员编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "登陆账号", required = true, example = "15601691300")
|
||||
private String username;
|
||||
@ApiModelProperty(value = "昵称", required = true, example = "小王")
|
||||
private String nickname;
|
||||
@ApiModelProperty(value = "账号状态", required = true, example = "1")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("数据字典枚举 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class DataDictEnumVO {
|
||||
|
||||
@ApiModelProperty(value = "大类枚举值", required = true, example = "gender")
|
||||
private String enumValue;
|
||||
@ApiModelProperty(value = "小类数值数组", required = true)
|
||||
private List<DataDictValueVO> values;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@ApiModel("数据字典 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class DataDictVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "大类枚举值", required = true, example = "gender")
|
||||
private String enumValue;
|
||||
@ApiModelProperty(value = "小类数值", required = true, example = "1")
|
||||
private String value;
|
||||
@ApiModelProperty(value = "展示名", required = true, example = "男")
|
||||
private String displayName;
|
||||
@ApiModelProperty(value = "排序值", required = true, example = "10")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "备注", example = "你猜")
|
||||
private String memo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@ApiModel("数据字典枚举值 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class DataDictValueVO {
|
||||
|
||||
@ApiModelProperty(value = "小类数值", required = true, example = "1")
|
||||
private String value;
|
||||
@ApiModelProperty(value = "展示名", required = true, example = "男")
|
||||
private String displayName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@ApiModel("登陆结果 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PassportLoginVO {
|
||||
|
||||
@ApiModelProperty(value = "访问令牌", required = true, example = "2e3d7635c15e47e997611707a237859f")
|
||||
private String accessToken;
|
||||
@ApiModelProperty(value = "刷新令牌", required = true, example = "d091e7c35bbb4313b0f557a6ef23d033")
|
||||
private String refreshToken;
|
||||
@ApiModelProperty(value = "过期时间,单位:秒", required = true, example = "2879")
|
||||
private Integer expiresIn;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("资源树结构 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ResourceTreeNodeVO {
|
||||
|
||||
@ApiModelProperty(value = "资源编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "资源名字(标识)", required = true, example = "商品管理")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "资源类型", required = true, example = "1")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "排序", required = true, example = "1")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "菜单展示名", required = true, example = "商品管理")
|
||||
private String displayName;
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
||||
@ApiModelProperty(value = "父级资源编号", required = true, example = "1", notes = "如果无父资源,则值为 0")
|
||||
private Integer pid;
|
||||
@ApiModelProperty(value = "操作", required = true, example = "/order/list")
|
||||
private String handler;
|
||||
@ApiModelProperty(value = "子节点数组")
|
||||
private List<ResourceTreeNodeVO> children;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("资源 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ResourceVO {
|
||||
|
||||
@ApiModelProperty(value = "资源编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "资源名字(标识)", required = true, example = "商品管理")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "资源类型", required = true, example = "1")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "排序", required = true, example = "1")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "菜单展示名", required = true, example = "商品管理")
|
||||
private String displayName;
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
||||
@ApiModelProperty(value = "父级资源编号", required = true, example = "1", notes = "如果无父资源,则值为 0")
|
||||
private Integer pid;
|
||||
@ApiModelProperty(value = "操作", required = true, example = "/order/list")
|
||||
private String handler;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("角色分页 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class RolePageVO {
|
||||
|
||||
@ApiModelProperty(value = "角色数组")
|
||||
private List<RoleVO> roles;
|
||||
@ApiModelProperty(value = "角色总数")
|
||||
private Integer count;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("角色拥有的资源 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class RoleResourceTreeNodeVO {
|
||||
|
||||
@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 = "排序", required = true, example = "1")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "菜单展示名", required = true, example = "商品管理")
|
||||
private String displayName;
|
||||
@ApiModelProperty(value = "子节点数组")
|
||||
private List<RoleResourceTreeNodeVO> children;
|
||||
@ApiModelProperty(value = "是否授权", required = true, example = "true")
|
||||
private Boolean assigned;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.iocoder.mall.admin.application.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("角色 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class RoleVO {
|
||||
|
||||
@ApiModelProperty(value = "角色编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "角色名字", required = true, example = "系统管理员")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
spring:
|
||||
boot:
|
||||
admin:
|
||||
client:
|
||||
enabled: true
|
||||
url: http://127.0.0.1:18097
|
||||
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: "*"
|
||||
server:
|
||||
port: 19083 # 配置独立端口。而该端口,不使用 nginx 对外暴露,从而不配置安全认证。也就是说,内网环境可访问,外网环境不可访问。当然,这么做的前提是,认为内网安全。
|
||||
@@ -0,0 +1,19 @@
|
||||
spring:
|
||||
application:
|
||||
name: admin-application
|
||||
|
||||
# server
|
||||
server:
|
||||
port: 18083
|
||||
servlet:
|
||||
context-path: /admin-api/
|
||||
|
||||
# auth
|
||||
auth:
|
||||
ignore-urls: /admin-api/admins/admin/passport/login, /admin-api/admins/file/get_qiniu_token
|
||||
|
||||
# qiniu
|
||||
qiniu:
|
||||
access-key: YldfyUC7OewoWM63TPYTairqnq8GMJvNek9EGoID
|
||||
secret-key: zZ7Q8wwZRyaklVvkyLmVydA4WygOBqtc_gTYzalS
|
||||
bucket: onemall
|
||||
Reference in New Issue
Block a user