init
This commit is contained in:
15
blade-service/blade-desk/Dockerfile
Normal file
15
blade-service/blade-desk/Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM bladex/alpine-java:openjdk17_cn_slim
|
||||
|
||||
LABEL maintainer="bladejava@qq.com"
|
||||
|
||||
RUN mkdir -p /blade/desk
|
||||
|
||||
WORKDIR /blade/desk
|
||||
|
||||
EXPOSE 8105
|
||||
|
||||
COPY ./target/blade-desk.jar ./app.jar
|
||||
|
||||
ENTRYPOINT ["java", "--add-opens", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
|
||||
|
||||
CMD ["--spring.profiles.active=test"]
|
||||
80
blade-service/blade-desk/pom.xml
Normal file
80
blade-service/blade-desk/pom.xml
Normal file
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-service</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>blade-desk</artifactId>
|
||||
<name>${project.artifactId}</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-boot</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-desk-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-user-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-flow-api</artifactId>
|
||||
</dependency>
|
||||
<!--Oss-->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-oss</artifactId>
|
||||
</dependency>
|
||||
<!--Http-->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-http</artifactId>
|
||||
</dependency>
|
||||
<!--MinIO-->
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
</dependency>
|
||||
<!--QiNiu-->
|
||||
<dependency>
|
||||
<groupId>com.qiniu</groupId>
|
||||
<artifactId>qiniu-java-sdk</artifactId>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-transaction</artifactId>
|
||||
</dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>${docker.fabric.skip}</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.desk;
|
||||
|
||||
import org.springblade.core.cloud.client.BladeCloudApplication;
|
||||
import org.springblade.core.launch.BladeApplication;
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
|
||||
/**
|
||||
* Desk启动器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@BladeCloudApplication
|
||||
public class DeskApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
BladeApplication.run(AppConstant.APPLICATION_DESK_NAME, DeskApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.desk.controller;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.common.cache.CacheNames;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.desk.entity.ProcessLeave;
|
||||
import org.springblade.desk.service.ILeaveService;
|
||||
import org.springblade.system.cache.UserCache;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@RequestMapping("/process/leave")
|
||||
@AllArgsConstructor
|
||||
public class LeaveController extends BladeController implements CacheNames {
|
||||
|
||||
private final ILeaveService leaveService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param businessId 主键
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
public R<ProcessLeave> detail(Long businessId) {
|
||||
ProcessLeave detail = leaveService.getById(businessId);
|
||||
detail.getFlow().setAssigneeName(UserCache.getUser(detail.getCreateUser()).getName());
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*
|
||||
* @param leave 请假信息
|
||||
*/
|
||||
@PostMapping("start-process")
|
||||
public R startProcess(@RequestBody ProcessLeave leave) {
|
||||
return R.status(leaveService.startProcess(leave));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.desk.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.BladePage;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.tenant.annotation.TenantDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.jackson.BladeView;
|
||||
import org.springblade.core.tool.jackson.Views;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.xss.annotation.XssIgnore;
|
||||
import org.springblade.desk.pojo.entity.Notice;
|
||||
import org.springblade.desk.feign.INoticeClient;
|
||||
import org.springblade.desk.service.INoticeService;
|
||||
import org.springblade.desk.pojo.vo.NoticeVO;
|
||||
import org.springblade.desk.wrapper.NoticeWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@TenantDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@PreAuth(menu = "notice")
|
||||
@RequestMapping("notice")
|
||||
@Tag(name = "用户博客", description = "博客接口")
|
||||
public class NoticeController extends BladeController {
|
||||
|
||||
private final INoticeService noticeService;
|
||||
|
||||
private final INoticeClient noticeClient;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@BladeView(Views.Detail.class)
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入notice")
|
||||
public R<NoticeVO> detail(Notice notice) {
|
||||
Notice detail = noticeService.getOne(Condition.getQueryWrapper(notice));
|
||||
return R.data(NoticeWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@BladeView(Views.Summary.class)
|
||||
@Parameters({
|
||||
@Parameter(name = "category", description = "公告类型", in = ParameterIn.QUERY, schema = @Schema(type = "integer")),
|
||||
@Parameter(name = "title", description = "公告标题", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入notice")
|
||||
public R<IPage<NoticeVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> notice, Query query) {
|
||||
NoticeWrapper.build().noticeQuery(notice);
|
||||
IPage<Notice> pages = noticeService.page(Condition.getPage(query), Condition.getQueryWrapper(notice, Notice.class));
|
||||
return R.data(NoticeWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 多表联合查询自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@BladeView(Views.Summary.class)
|
||||
@Parameters({
|
||||
@Parameter(name = "category", description = "公告类型", in = ParameterIn.QUERY, schema = @Schema(type = "integer")),
|
||||
@Parameter(name = "title", description = "公告标题", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入notice")
|
||||
public R<IPage<NoticeVO>> page(@Parameter(hidden = true) NoticeVO notice, Query query) {
|
||||
IPage<NoticeVO> pages = noticeService.selectNoticePage(Condition.getPage(query), notice);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入notice")
|
||||
public R save(@RequestBody Notice notice) {
|
||||
return R.status(noticeService.save(notice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入notice")
|
||||
public R update(@RequestBody Notice notice) {
|
||||
return R.status(noticeService.updateById(notice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@XssIgnore
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入notice")
|
||||
public R submit(@RequestBody Notice notice) {
|
||||
return R.status(noticeService.saveOrUpdate(notice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入notice")
|
||||
public R remove(@Parameter(description = "主键集合") @RequestParam String ids) {
|
||||
boolean temp = noticeService.deleteLogic(Func.toLongList(ids));
|
||||
return R.status(temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程调用分页接口
|
||||
*/
|
||||
@GetMapping("/top")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "分页远程调用", description = "传入current,size")
|
||||
public R<BladePage<Notice>> top(@Parameter(description = "当前页") @RequestParam Integer current, @Parameter(description = "每页显示条数") @RequestParam Integer size) {
|
||||
BladePage<Notice> page = noticeClient.top(current, size);
|
||||
return R.data(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.desk.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.flow.core.pojo.entity.FlowEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 请假流程实体类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@TableName("blade_process_leave")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ProcessLeave extends FlowEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 流程定义id
|
||||
*/
|
||||
private String processDefinitionId;
|
||||
/**
|
||||
* 流程实例id
|
||||
*/
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 请假开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
/**
|
||||
* 请假结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 请假理由
|
||||
*/
|
||||
private String reason;
|
||||
/**
|
||||
* 审批人
|
||||
*/
|
||||
private String taskUser;
|
||||
/**
|
||||
* 流程申请时间
|
||||
*/
|
||||
private Date applyTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.desk.feign;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.mp.support.BladePage;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.desk.pojo.entity.Notice;
|
||||
import org.springblade.desk.service.INoticeService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
|
||||
/**
|
||||
* Notice Feign
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden()
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class NoticeClient implements INoticeClient {
|
||||
|
||||
private final INoticeService service;
|
||||
|
||||
@Override
|
||||
@GetMapping(TOP)
|
||||
public BladePage<Notice> top(Integer current, Integer size) {
|
||||
Query query = new Query();
|
||||
query.setCurrent(current);
|
||||
query.setSize(size);
|
||||
IPage<Notice> page = service.page(Condition.getPage(query));
|
||||
return BladePage.of(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.desk.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.desk.entity.ProcessLeave;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface LeaveMapper extends BaseMapper<ProcessLeave> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.desk.mapper.LeaveMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.desk.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.desk.pojo.entity.Notice;
|
||||
import org.springblade.desk.pojo.vo.NoticeVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface NoticeMapper extends BaseMapper<Notice> {
|
||||
|
||||
/**
|
||||
* 前N条数据
|
||||
*
|
||||
* @param number 数量
|
||||
* @return List<Notice>
|
||||
*/
|
||||
List<Notice> topList(Integer number);
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页
|
||||
* @param notice 实体
|
||||
* @return List<NoticeVO>
|
||||
*/
|
||||
List<NoticeVO> selectNoticePage(IPage page, NoticeVO notice);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.desk.mapper.NoticeMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="noticeResultMap" type="org.springblade.desk.pojo.entity.Notice">
|
||||
<result column="id" property="id"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="release_time" property="releaseTime"/>
|
||||
<result column="title" property="title"/>
|
||||
<result column="content" property="content"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="noticeVOResultMap" type="org.springblade.desk.pojo.vo.NoticeVO">
|
||||
<result column="id" property="id"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="release_time" property="releaseTime"/>
|
||||
<result column="title" property="title"/>
|
||||
<result column="content" property="content"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="topList" resultMap="noticeResultMap">
|
||||
select * from blade_notice limit #{number}
|
||||
</select>
|
||||
|
||||
<select id="selectNoticePage" resultMap="noticeVOResultMap">
|
||||
SELECT
|
||||
n.*,
|
||||
d.dict_value AS categoryName
|
||||
FROM
|
||||
blade_notice n
|
||||
LEFT JOIN ( SELECT * FROM blade_dict WHERE CODE = 'notice' ) d ON n.category = d.dict_key
|
||||
WHERE
|
||||
n.is_deleted = 0 and n.tenant_id = #{notice.tenantId}
|
||||
<if test="notice.title!=null">
|
||||
and n.title like concat(concat('%', #{notice.title}), '%')
|
||||
</if>
|
||||
<if test="notice.category!=null">
|
||||
and n.category = #{notice.category}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.desk.service;
|
||||
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
import org.springblade.desk.entity.ProcessLeave;
|
||||
|
||||
/**
|
||||
* 服务类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface ILeaveService extends BaseService<ProcessLeave> {
|
||||
|
||||
/**
|
||||
* 开启流程
|
||||
*
|
||||
* @param leave 请假实体
|
||||
* @return boolean
|
||||
*/
|
||||
boolean startProcess(ProcessLeave leave);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.desk.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
import org.springblade.desk.pojo.entity.Notice;
|
||||
import org.springblade.desk.pojo.vo.NoticeVO;
|
||||
|
||||
/**
|
||||
* 服务类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface INoticeService extends BaseService<Notice> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
* @param page
|
||||
* @param notice
|
||||
* @return
|
||||
*/
|
||||
IPage<NoticeVO> selectNoticePage(IPage<NoticeVO> page, NoticeVO notice);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.desk.service.impl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.support.Kv;
|
||||
import org.springblade.core.tool.utils.DateUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.desk.entity.ProcessLeave;
|
||||
import org.springblade.desk.mapper.LeaveMapper;
|
||||
import org.springblade.desk.service.ILeaveService;
|
||||
import org.springblade.flow.core.constant.ProcessConstant;
|
||||
import org.springblade.flow.core.pojo.entity.BladeFlow;
|
||||
import org.springblade.flow.core.feign.IFlowClient;
|
||||
import org.springblade.flow.core.utils.FlowUtil;
|
||||
import org.springblade.flow.core.utils.TaskUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 服务实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class LeaveServiceImpl extends BaseServiceImpl<LeaveMapper, ProcessLeave> implements ILeaveService {
|
||||
|
||||
private final IFlowClient flowClient;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
// @GlobalTransactional
|
||||
public boolean startProcess(ProcessLeave leave) {
|
||||
String businessTable = FlowUtil.getBusinessTable(ProcessConstant.LEAVE_KEY);
|
||||
if (Func.isEmpty(businessTable)) {
|
||||
throw new ServiceException("流程启动失败,未找到相关业务表");
|
||||
}
|
||||
if (Func.isEmpty(leave.getId())) {
|
||||
// 保存leave
|
||||
leave.setApplyTime(DateUtil.now());
|
||||
save(leave);
|
||||
// 启动流程
|
||||
Kv variables = Kv.create()
|
||||
.set(ProcessConstant.TASK_VARIABLE_CREATE_USER, AuthUtil.getUserName())
|
||||
.set("taskUser", TaskUtil.getTaskUser(leave.getTaskUser()))
|
||||
.set("days", DateUtil.between(leave.getStartTime(), leave.getEndTime()).toDays());
|
||||
R<BladeFlow> result = flowClient.startProcessInstanceById(leave.getProcessDefinitionId(), FlowUtil.getBusinessKey(businessTable, String.valueOf(leave.getId())), variables);
|
||||
if (result.isSuccess()) {
|
||||
log.debug("流程已启动,流程ID:" + result.getData().getProcessInstanceId());
|
||||
// 返回流程id写入leave
|
||||
leave.setProcessInstanceId(result.getData().getProcessInstanceId());
|
||||
updateById(leave);
|
||||
} else {
|
||||
throw new ServiceException("开启流程失败");
|
||||
}
|
||||
} else {
|
||||
|
||||
updateById(leave);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.desk.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.desk.pojo.entity.Notice;
|
||||
import org.springblade.desk.mapper.NoticeMapper;
|
||||
import org.springblade.desk.service.INoticeService;
|
||||
import org.springblade.desk.pojo.vo.NoticeVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 服务实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Service
|
||||
public class NoticeServiceImpl extends BaseServiceImpl<NoticeMapper, Notice> implements INoticeService {
|
||||
|
||||
@Override
|
||||
public IPage<NoticeVO> selectNoticePage(IPage<NoticeVO> page, NoticeVO notice) {
|
||||
// 若不使用mybatis-plus自带的分页方法,则不会自动带入tenantId,所以我们需要自行注入
|
||||
notice.setTenantId(AuthUtil.getTenantId());
|
||||
return page.setRecords(baseMapper.selectNoticePage(page, notice));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.desk.wrapper;
|
||||
|
||||
import org.springblade.core.mp.support.BaseEntityWrapper;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.desk.pojo.entity.Notice;
|
||||
import org.springblade.desk.pojo.vo.NoticeVO;
|
||||
import org.springblade.system.cache.DictCache;
|
||||
import org.springblade.system.pojo.enums.DictEnum;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Notice包装类,返回视图层所需的字段
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class NoticeWrapper extends BaseEntityWrapper<Notice, NoticeVO> {
|
||||
|
||||
public static NoticeWrapper build() {
|
||||
return new NoticeWrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoticeVO entityVO(Notice notice) {
|
||||
NoticeVO noticeVO = Objects.requireNonNull(BeanUtil.copyProperties(notice, NoticeVO.class));
|
||||
String dictValue = DictCache.getValue(DictEnum.NOTICE, noticeVO.getCategory());
|
||||
noticeVO.setCategoryName(dictValue);
|
||||
return noticeVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询条件处理
|
||||
*/
|
||||
public void noticeQuery(Map<String, Object> notice) {
|
||||
// 此场景仅在 pg数据库 map类型传参的情况下需要处理,entity传参已经包含数据类型,则无需关心
|
||||
// 针对 pg数据库 int类型字段查询需要强转的处理示例
|
||||
String searchKey = "category";
|
||||
if (Func.isNotEmpty(notice.get(searchKey))) {
|
||||
// 数据库字段为int类型,设置"="查询,具体查询参数请见 @org.springblade.core.mp.support.SqlKeyword
|
||||
notice.put(searchKey.concat("_equal"), Func.toInt(notice.get(searchKey)));
|
||||
// 默认"like"查询,pg数据库 场景会报错,所以将其删除
|
||||
notice.remove(searchKey);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#服务器端口
|
||||
server:
|
||||
port: 8105
|
||||
|
||||
#数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
url: ${blade.datasource.dev.url}
|
||||
username: ${blade.datasource.dev.username}
|
||||
password: ${blade.datasource.dev.password}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#服务器端口
|
||||
server:
|
||||
port: 8105
|
||||
|
||||
#数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
url: ${blade.datasource.prod.url}
|
||||
username: ${blade.datasource.prod.username}
|
||||
password: ${blade.datasource.prod.password}
|
||||
@@ -0,0 +1,10 @@
|
||||
#服务器端口
|
||||
server:
|
||||
port: 8105
|
||||
|
||||
#数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
url: ${blade.datasource.test.url}
|
||||
username: ${blade.datasource.test.username}
|
||||
password: ${blade.datasource.test.password}
|
||||
@@ -0,0 +1,97 @@
|
||||
package org.springblade.test.secure;
|
||||
|
||||
import org.springblade.core.http.HttpRequest;
|
||||
import org.springblade.core.http.ResponseSpec;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
import static org.springblade.test.secure.SecureTestBuilder.*;
|
||||
|
||||
/**
|
||||
* Secure安全框架 - 基础认证测试类
|
||||
* 测试HTTP Basic Authentication
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public class SecureBasicTest {
|
||||
|
||||
/**
|
||||
* Basic认证用户名
|
||||
*/
|
||||
private static final String BASIC_USERNAME = "admin";
|
||||
|
||||
/**
|
||||
* Basic认证密码
|
||||
*/
|
||||
private static final String BASIC_PASSWORD = "admin123";
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 设置日志级别,方便调试
|
||||
initHttpLog();
|
||||
|
||||
printHeader("Secure 基础认证测试");
|
||||
|
||||
// 测试1: 获取Token
|
||||
String accessToken = getToken();
|
||||
|
||||
// 测试2: 使用Token调用受保护API
|
||||
if (StringUtil.isNotBlank(accessToken)) {
|
||||
testCallApiWithToken(accessToken);
|
||||
}
|
||||
|
||||
// 测试3: Basic认证调用受保护API
|
||||
testBasicAuth();
|
||||
|
||||
printFooter();
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用Token调用受保护API
|
||||
*
|
||||
* @param accessToken 访问令牌
|
||||
*/
|
||||
private static void testCallApiWithToken(String accessToken) {
|
||||
printSection(2, "使用 Token 调用受保护 API");
|
||||
callApiWithToken("/blade-desk/notice/list", accessToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试Basic认证调用受保护API
|
||||
* 认证原理: Authorization: Basic {Base64(username:password)}
|
||||
*/
|
||||
private static void testBasicAuth() {
|
||||
printSection(1, "Basic 认证调用受保护 API");
|
||||
|
||||
try {
|
||||
// 1. 生成Basic Auth凭证
|
||||
String credentials = BASIC_USERNAME + ":" + BASIC_PASSWORD;
|
||||
String encoded = Base64.getEncoder().encodeToString(credentials.getBytes());
|
||||
String basicAuth = "Basic " + encoded;
|
||||
|
||||
System.out.println();
|
||||
System.out.println(" Basic Auth Parameters:");
|
||||
printKeyValue(" username", BASIC_USERNAME);
|
||||
printKeyValue(" password", BASIC_PASSWORD);
|
||||
printKeyValue(" credentials", credentials);
|
||||
printKeyValue(" encoded", encoded);
|
||||
printKeyValue(" Authorization", basicAuth);
|
||||
|
||||
// 2. 发送带Basic认证的请求
|
||||
String response = HttpRequest.get(BASE_URL + "/blade-test/info/basic")
|
||||
.addHeader("Authorization", basicAuth)
|
||||
.addHeader("Blade-Requested-With", "BladeHttpRequest")
|
||||
.execute()
|
||||
.onSuccess(ResponseSpec::asString);
|
||||
|
||||
System.out.println();
|
||||
printKeyValue("Response", response);
|
||||
printSuccess("Basic 认证请求发送成功");
|
||||
} catch (Exception e) {
|
||||
printError("Basic 认证异常 - " + e.getMessage());
|
||||
printWarning("如果Basic认证接口未配置或不存在会报错,属于正常情况");
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package org.springblade.test.secure;
|
||||
|
||||
import org.springblade.core.http.HttpRequest;
|
||||
import org.springblade.core.http.ResponseSpec;
|
||||
import org.springblade.core.tool.utils.DigestUtil;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.springblade.test.secure.SecureTestBuilder.*;
|
||||
|
||||
/**
|
||||
* Secure安全框架 - 签名认证测试类
|
||||
* 测试获取Token以及签名认证(nonce+timestamp)
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public class SecureSignTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 设置日志级别,方便调试
|
||||
initHttpLog();
|
||||
|
||||
printHeader("Secure 签名认证测试");
|
||||
|
||||
// 测试1: 获取Token
|
||||
String accessToken = getToken();
|
||||
|
||||
// 测试2: 使用Token调用受保护API
|
||||
if (StringUtil.isNotBlank(accessToken)) {
|
||||
testCallApiWithToken(accessToken);
|
||||
}
|
||||
|
||||
// 测试3: 签名认证(nonce+timestamp)
|
||||
testSignAuth();
|
||||
|
||||
printFooter();
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用Token调用受保护API
|
||||
*
|
||||
* @param accessToken 访问令牌
|
||||
*/
|
||||
private static void testCallApiWithToken(String accessToken) {
|
||||
printSection(2, "使用 Token 调用受保护 API");
|
||||
callApiWithToken("/blade-desk/notice/list", accessToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试签名认证(nonce+timestamp)
|
||||
* 签名规则: signature = SHA1(timestamp + nonce)
|
||||
*/
|
||||
private static void testSignAuth() {
|
||||
printSection(3, "签名认证 (nonce + timestamp)");
|
||||
|
||||
try {
|
||||
// 1. 生成签名参数
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
String nonce = UUID.randomUUID().toString().replace("-", "");
|
||||
String signature = DigestUtil.sha1Hex(timestamp + nonce);
|
||||
|
||||
System.out.println();
|
||||
System.out.println(" Signature Parameters:");
|
||||
printKeyValue(" timestamp", timestamp);
|
||||
printKeyValue(" nonce", nonce);
|
||||
printKeyValue(" signature", signature);
|
||||
printKeyValue(" algorithm", "SHA1(timestamp + nonce)");
|
||||
|
||||
// 2. 发送带签名的请求
|
||||
String response = HttpRequest.get(BASE_URL + "/blade-test/info/sign")
|
||||
.addHeader("Authorization", CLIENT_AUTH)
|
||||
.addHeader("Blade-Requested-With", "BladeHttpRequest")
|
||||
.addHeader("timestamp", timestamp)
|
||||
.addHeader("nonce", nonce)
|
||||
.addHeader("signature", signature)
|
||||
.execute()
|
||||
.onSuccess(ResponseSpec::asString);
|
||||
|
||||
System.out.println();
|
||||
printKeyValue("Response", response);
|
||||
printSuccess("签名认证请求发送成功");
|
||||
} catch (Exception e) {
|
||||
printError("签名认证异常 - " + e.getMessage());
|
||||
printWarning("如果签名认证接口未配置或不存在会报错,属于正常情况");
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package org.springblade.test.secure;
|
||||
|
||||
import org.springblade.core.http.HttpRequest;
|
||||
import org.springblade.core.http.LogLevel;
|
||||
import org.springblade.core.http.ResponseSpec;
|
||||
import org.springblade.core.tool.jackson.JsonUtil;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Secure安全框架测试工具类
|
||||
* 提供通用的Token获取、API调用及打印辅助方法
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public class SecureTestBuilder {
|
||||
|
||||
/**
|
||||
* 分隔线
|
||||
*/
|
||||
public static final String LINE = "─".repeat(60);
|
||||
public static final String DOUBLE_LINE = "═".repeat(60);
|
||||
|
||||
/**
|
||||
* 服务地址
|
||||
*/
|
||||
public static final String BASE_URL = "http://localhost";
|
||||
|
||||
/**
|
||||
* 客户端认证信息 (saber3:saber3_secret 的 Base64 编码)
|
||||
*/
|
||||
public static final String CLIENT_AUTH = "Basic c2FiZXIzOnNhYmVyM19zZWNyZXQ=";
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
public static final String TENANT_ID = "000000";
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
public static final String USERNAME = "admin";
|
||||
|
||||
/**
|
||||
* 密码(国密加密后的字符串,具体见 @org.springblade.test.sm.Sm2Test)
|
||||
*/
|
||||
public static final String PASSWORD = "";
|
||||
|
||||
/**
|
||||
* 初始化HTTP日志级别
|
||||
*/
|
||||
public static void initHttpLog() {
|
||||
HttpRequest.setGlobalLog(LogLevel.BODY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印测试头部
|
||||
*
|
||||
* @param title 测试标题
|
||||
*/
|
||||
public static void printHeader(String title) {
|
||||
System.out.println();
|
||||
System.out.println(DOUBLE_LINE);
|
||||
System.out.println(" " + title);
|
||||
System.out.println(DOUBLE_LINE);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印测试尾部
|
||||
*/
|
||||
public static void printFooter() {
|
||||
System.out.println(DOUBLE_LINE);
|
||||
System.out.println(" 测试执行完毕");
|
||||
System.out.println(DOUBLE_LINE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印测试章节
|
||||
*
|
||||
* @param testNo 测试编号
|
||||
* @param title 章节标题
|
||||
*/
|
||||
public static void printSection(int testNo, String title) {
|
||||
System.out.println(LINE);
|
||||
System.out.printf(" [TEST-%d] %s%n", testNo, title);
|
||||
System.out.println(LINE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印键值对
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
*/
|
||||
public static void printKeyValue(String key, Object value) {
|
||||
System.out.printf(" %-16s: %s%n", key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印成功消息
|
||||
*
|
||||
* @param message 消息内容
|
||||
*/
|
||||
public static void printSuccess(String message) {
|
||||
System.out.printf("%n [SUCCESS] %s%n%n", message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印错误消息
|
||||
*
|
||||
* @param message 消息内容
|
||||
*/
|
||||
public static void printError(String message) {
|
||||
System.out.printf("%n [FAILED] %s%n%n", message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印警告消息
|
||||
*
|
||||
* @param message 消息内容
|
||||
*/
|
||||
public static void printWarning(String message) {
|
||||
System.out.printf(" [WARN] %s%n", message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Token
|
||||
* 通用方法,供签名认证等场景复用
|
||||
*
|
||||
* @return accessToken,获取失败返回null
|
||||
*/
|
||||
public static String getToken() {
|
||||
printSection(1, "获取 Token");
|
||||
|
||||
try {
|
||||
String response = HttpRequest.post(BASE_URL + "/blade-auth/oauth/token")
|
||||
.addHeader("Authorization", CLIENT_AUTH)
|
||||
.addHeader("Content-Type", "application/x-www-form-urlencoded")
|
||||
.formBuilder()
|
||||
.add("grant_type", "password")
|
||||
.add("tenant_id", TENANT_ID)
|
||||
.add("username", USERNAME)
|
||||
.add("password", PASSWORD)
|
||||
.execute()
|
||||
.onSuccess(ResponseSpec::asString);
|
||||
|
||||
System.out.println();
|
||||
printKeyValue("Response", response);
|
||||
|
||||
if (StringUtil.isNotBlank(response)) {
|
||||
Map<String, Object> result = JsonUtil.readMap(response, String.class, Object.class);
|
||||
if (result != null && result.containsKey("access_token")) {
|
||||
String accessToken = (String) result.get("access_token");
|
||||
String tokenType = (String) result.get("token_type");
|
||||
Object expiresIn = result.get("expires_in");
|
||||
|
||||
System.out.println();
|
||||
System.out.println(" Token Details:");
|
||||
printKeyValue(" token_type", tokenType);
|
||||
printKeyValue(" access_token", accessToken.substring(0, Math.min(50, accessToken.length())) + "...");
|
||||
printKeyValue(" expires_in", expiresIn + " seconds");
|
||||
|
||||
printSuccess("Token 获取成功");
|
||||
return accessToken;
|
||||
} else {
|
||||
printError("Token 获取失败 - " + result);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
printError("Token 获取异常 - " + e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用Token调用受保护API
|
||||
*
|
||||
* @param url API地址(相对路径,如 /blade-desk/notice/list)
|
||||
* @param accessToken 访问令牌
|
||||
*/
|
||||
public static void callApiWithToken(String url, String accessToken) {
|
||||
try {
|
||||
String response = HttpRequest.get(BASE_URL + url)
|
||||
.addHeader("Authorization", CLIENT_AUTH)
|
||||
.addHeader("Blade-Auth", "bearer " + accessToken)
|
||||
.addHeader("Blade-Requested-With", "BladeHttpRequest")
|
||||
.execute()
|
||||
.onSuccess(ResponseSpec::asString);
|
||||
|
||||
System.out.println();
|
||||
printKeyValue("Response", response);
|
||||
printSuccess("API 调用成功");
|
||||
} catch (Exception e) {
|
||||
printError("API 调用异常 - " + e.getMessage());
|
||||
printWarning("如果接口不存在会返回 404,属于正常情况");
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package org.springblade.test.sm;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
|
||||
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
|
||||
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
|
||||
import org.bouncycastle.util.encoders.Hex;
|
||||
import org.springblade.core.tool.utils.SM2Util;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* SM2Test
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class Sm2Test {
|
||||
|
||||
@SneakyThrows
|
||||
public static void main(String[] args) {
|
||||
System.out.println("================== SM2 加解密与签名测试 ==================");
|
||||
|
||||
// 1. 生成SM2密钥对
|
||||
AsymmetricCipherKeyPair keyPair = SM2Util.generateKeyPair();
|
||||
String publicKeyString = SM2Util.getPublicKeyString(keyPair);
|
||||
String privateKeyString = SM2Util.getPrivateKeyString(keyPair);
|
||||
System.out.println("1. 生成SM2密钥对:");
|
||||
System.out.println(" 公钥 (16进制): " + publicKeyString);
|
||||
System.out.println(" 公钥长度: " + publicKeyString.length());
|
||||
System.out.println(" 私钥 (16进制): " + privateKeyString);
|
||||
System.out.println(" 私钥长度: " + privateKeyString.length());
|
||||
|
||||
System.out.println("--------------------------------------------------");
|
||||
|
||||
// 2. 从字符串恢复密钥
|
||||
System.out.println("2. 从字符串恢复密钥...");
|
||||
ECPublicKeyParameters publicKey = SM2Util.stringToPublicKey(publicKeyString);
|
||||
ECPrivateKeyParameters privateKey = SM2Util.stringToPrivateKey(privateKeyString);
|
||||
System.out.println(" 密钥恢复成功!");
|
||||
|
||||
System.out.println("--------------------------------------------------");
|
||||
|
||||
// 3. 准备待加密的原文
|
||||
String originalText = "Hello BladeX! 这是一段需要被国密SM2算法加密和签名的敏感信息。1234567890";
|
||||
System.out.println("3. 待加密的原文: " + originalText);
|
||||
|
||||
System.out.println("--------------------------------------------------");
|
||||
|
||||
// 4. 执行加密
|
||||
System.out.println("4. 正在执行加密操作...");
|
||||
byte[] encryptedData = SM2Util.encrypt(originalText, publicKey);
|
||||
if (encryptedData != null && encryptedData.length > 0) {
|
||||
System.out.println(" 加密成功!");
|
||||
System.out.println(" 加密后的密文 (16进制): " + Hex.toHexString(encryptedData));
|
||||
System.out.println(" 密文长度: " + encryptedData.length + " 字节");
|
||||
} else {
|
||||
System.out.println(" 加密失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("--------------------------------------------------");
|
||||
|
||||
// 5. 执行解密
|
||||
System.out.println("5. 正在执行解密操作...");
|
||||
String decryptedText = SM2Util.decrypt(encryptedData, privateKey);
|
||||
if (StringUtil.isNotBlank(decryptedText)) {
|
||||
System.out.println(" 解密成功!");
|
||||
System.out.println(" 解密后的明文: " + decryptedText);
|
||||
} else {
|
||||
System.out.println(" 解密失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("--------------------------------------------------");
|
||||
|
||||
// 6. 执行数字签名
|
||||
System.out.println("6. 正在执行数字签名...");
|
||||
byte[] signature = SM2Util.sign(originalText, privateKey);
|
||||
if (signature != null && signature.length > 0) {
|
||||
System.out.println(" 签名成功!");
|
||||
System.out.println(" 数字签名 (16进制): " + Hex.toHexString(signature));
|
||||
System.out.println(" 签名长度: " + signature.length + " 字节");
|
||||
} else {
|
||||
System.out.println(" 签名失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("--------------------------------------------------");
|
||||
|
||||
// 7. 验证签名
|
||||
System.out.println("7. 正在验证数字签名...");
|
||||
boolean isVerified = SM2Util.verify(originalText, signature, publicKey);
|
||||
System.out.println(" 签名验证结果: " + (isVerified ? "有效" : "无效"));
|
||||
|
||||
System.out.println("--------------------------------------------------");
|
||||
|
||||
// 8. 校验加解密结果
|
||||
System.out.println("8. 正在校验原文与解密后的明文是否一致...");
|
||||
boolean isDecryptMatch = originalText.equals(decryptedText);
|
||||
System.out.println(" 加解密校验结果: " + (isDecryptMatch ? "一致" : "不一致"));
|
||||
|
||||
System.out.println("==================================================");
|
||||
|
||||
// 9. 最终结果汇总
|
||||
if (isDecryptMatch && isVerified) {
|
||||
System.out.println("\n[成功] SM2加解密与签名流程验证通过!");
|
||||
System.out.println(" ✓ 密钥对生成成功");
|
||||
System.out.println(" ✓ 加解密功能正常");
|
||||
System.out.println(" ✓ 数字签名验证通过");
|
||||
} else {
|
||||
System.out.println("\n[失败] SM2加解密与签名流程验证失败!");
|
||||
if (!isDecryptMatch) {
|
||||
System.out.println(" ✗ 加解密校验失败");
|
||||
}
|
||||
if (!isVerified) {
|
||||
System.out.println(" ✗ 数字签名验证失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package org.springblade.test.sm;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import org.springblade.core.tool.utils.SM4Util;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* Sm4Test
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public class Sm4Test {
|
||||
|
||||
@SneakyThrows
|
||||
public static void main(String[] args) {
|
||||
System.out.println("================== SM4 加解密测试 ==================");
|
||||
|
||||
// 1. 生成SM4密钥
|
||||
String sm4Key = SM4Util.generateKey();
|
||||
System.out.println("1. 生成SM4密钥 (16进制): " + sm4Key);
|
||||
System.out.println(" 密钥长度 (Hex): " + sm4Key.length());
|
||||
|
||||
System.out.println("--------------------------------------------------");
|
||||
|
||||
// 2. 准备待加密的原文
|
||||
String originalText = "Hello BladeX! 这是一段需要被国密SM4算法加密的敏感信息。1234567890";
|
||||
System.out.println("2. 待加密的原文: " + originalText);
|
||||
|
||||
System.out.println("--------------------------------------------------");
|
||||
|
||||
// 3. 执行加密
|
||||
System.out.println("3. 正在执行加密操作...");
|
||||
String encryptedText = SM4Util.encrypt(originalText, sm4Key);
|
||||
if (StringUtil.isNotBlank(encryptedText)) {
|
||||
System.out.println(" 加密成功!");
|
||||
System.out.println(" 加密后的密文 (16进制): " + encryptedText);
|
||||
} else {
|
||||
System.out.println(" 加密失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("--------------------------------------------------");
|
||||
|
||||
// 4. 执行解密
|
||||
System.out.println("4. 正在执行解密操作...");
|
||||
String decryptedText = SM4Util.decrypt(encryptedText, sm4Key);
|
||||
if (StringUtil.isNotBlank(decryptedText)) {
|
||||
System.out.println(" 解密成功!");
|
||||
System.out.println(" 解密后的明文: " + decryptedText);
|
||||
} else {
|
||||
System.out.println(" 解密失败!");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("--------------------------------------------------");
|
||||
|
||||
// 5. 校验结果
|
||||
System.out.println("5. 正在校验原文与解密后的明文是否一致...");
|
||||
boolean isMatch = originalText.equals(decryptedText);
|
||||
System.out.println(" 校验结果: " + (isMatch ? "一致" : "不一致"));
|
||||
|
||||
System.out.println("==================================================");
|
||||
|
||||
if (isMatch) {
|
||||
System.out.println("\n[成功] SM4加解密流程验证通过!");
|
||||
} else {
|
||||
System.out.println("\n[失败] SM4加解密流程验证失败!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
15
blade-service/blade-system/Dockerfile
Normal file
15
blade-service/blade-system/Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM bladex/alpine-java:openjdk17_cn_slim
|
||||
|
||||
LABEL maintainer="bladejava@qq.com"
|
||||
|
||||
RUN mkdir -p /blade/system
|
||||
|
||||
WORKDIR /blade/system
|
||||
|
||||
EXPOSE 8106
|
||||
|
||||
COPY ./target/blade-system.jar ./app.jar
|
||||
|
||||
ENTRYPOINT ["java", "--add-opens", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
|
||||
|
||||
CMD ["--spring.profiles.active=test"]
|
||||
59
blade-service/blade-system/pom.xml
Normal file
59
blade-service/blade-system/pom.xml
Normal file
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>blade-service</artifactId>
|
||||
<groupId>org.springblade</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>blade-system</artifactId>
|
||||
<name>${project.artifactId}</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-boot</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-excel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-literule</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-system-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-user-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>${docker.fabric.skip}</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system;
|
||||
|
||||
import org.springblade.core.cloud.client.BladeCloudApplication;
|
||||
import org.springblade.core.launch.BladeApplication;
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
|
||||
/**
|
||||
* 系统模块启动器
|
||||
* @author Chill
|
||||
*/
|
||||
@BladeCloudApplication
|
||||
public class SystemApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
BladeApplication.run(AppConstant.APPLICATION_SYSTEM_NAME, SystemApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.ApiKey;
|
||||
import org.springblade.system.pojo.vo.ApiKeyVO;
|
||||
import org.springblade.system.service.IApiKeyService;
|
||||
import org.springblade.system.wrapper.ApiKeyWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 令牌权限 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@IsAdmin
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/api-key")
|
||||
@Tag(name = "令牌权限", description = "令牌权限接口")
|
||||
public class ApiKeyController extends BladeController {
|
||||
|
||||
private final IApiKeyService apiKeyService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入apiKey")
|
||||
public R<ApiKeyVO> detail(ApiKey apiKey) {
|
||||
ApiKey detail = apiKeyService.getOne(Condition.getQueryWrapper(apiKey));
|
||||
return R.data(ApiKeyWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入apiKey")
|
||||
public R<IPage<ApiKeyVO>> list(@Parameter(hidden = true) ApiKey apiKey, Query query) {
|
||||
IPage<ApiKey> pages = apiKeyService.page(Condition.getPage(query), Condition.getQueryWrapper(apiKey));
|
||||
return R.data(ApiKeyWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "自定义分页", description = "传入apiKey")
|
||||
public R<IPage<ApiKeyVO>> page(@Parameter(hidden = true) ApiKeyVO apiKey, Query query) {
|
||||
IPage<ApiKeyVO> pages = apiKeyService.selectApiKeyPage(Condition.getPage(query), apiKey);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入apiKey")
|
||||
public R<String> save(@Valid @RequestBody ApiKey apiKey) {
|
||||
return R.data(apiKeyService.submitApiKey(apiKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入apiKey")
|
||||
public R<String> update(@Valid @RequestBody ApiKey apiKey) {
|
||||
return R.data(apiKeyService.submitApiKey(apiKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入apiKey")
|
||||
public R<String> submit(@Valid @RequestBody ApiKey apiKey) {
|
||||
return R.data(apiKeyService.submitApiKey(apiKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R<Boolean> remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(apiKeyService.removeApiKey(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用
|
||||
*/
|
||||
@PostMapping("/enable")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "启用", description = "传入ids")
|
||||
public R<Boolean> enable(@RequestParam String ids) {
|
||||
return R.status(apiKeyService.enableApiKey(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用
|
||||
*/
|
||||
@PostMapping("/disable")
|
||||
@ApiOperationSupport(order = 9)
|
||||
@Operation(summary = "禁用", description = "传入ids")
|
||||
public R<Boolean> disable(@RequestParam String ids) {
|
||||
return R.status(apiKeyService.disableApiKey(ids));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.ApiKeyLog;
|
||||
import org.springblade.system.pojo.vo.ApiKeyLogVO;
|
||||
import org.springblade.system.service.IApiKeyLogService;
|
||||
import org.springblade.system.wrapper.ApiKeyLogWrapper;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 令牌调用日志 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@IsAdmin
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/api-key-log")
|
||||
@Tag(name = "令牌调用日志", description = "令牌调用日志接口")
|
||||
public class ApiKeyLogController {
|
||||
|
||||
private final IApiKeyLogService apiKeyLogService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入apiKeyLog")
|
||||
public R<ApiKeyLog> detail(ApiKeyLog apiKeyLog) {
|
||||
QueryWrapper<ApiKeyLog> queryWrapper = Condition.getQueryWrapper(apiKeyLog);
|
||||
return R.data(queryWrapper.isEmptyOfWhere() ? null : apiKeyLogService.getOne(queryWrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入apiKeyLog")
|
||||
public R<IPage<ApiKeyLogVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> apiKeyLog, Query query) {
|
||||
IPage<ApiKeyLog> pages = apiKeyLogService.page(Condition.getPage(query.setDescs("create_time")), Condition.getQueryWrapper(apiKeyLog, ApiKeyLog.class));
|
||||
return R.data(ApiKeyLogWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.ApiScope;
|
||||
import org.springblade.system.pojo.vo.ApiScopeVO;
|
||||
import org.springblade.system.service.IApiScopeService;
|
||||
import org.springblade.system.wrapper.ApiScopeWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
||||
|
||||
/**
|
||||
* 接口权限控制器
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdmin
|
||||
@RequestMapping("api-scope")
|
||||
@Tag(name = "接口权限", description = "接口权限")
|
||||
public class ApiScopeController extends BladeController {
|
||||
|
||||
private final IApiScopeService apiScopeService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入dataScope")
|
||||
public R<ApiScope> detail(ApiScope dataScope) {
|
||||
ApiScope detail = apiScopeService.getOne(Condition.getQueryWrapper(dataScope));
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Parameters({
|
||||
@Parameter(name = "menuId", description = "菜单主键", in = ParameterIn.QUERY, schema = @Schema(type = "integer", format = "int64")),
|
||||
@Parameter(name = "scopeName", description = "接口权限名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "resourceCode", description = "资源编号", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入dataScope")
|
||||
public R<IPage<ApiScopeVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> dataScope, Query query) {
|
||||
ApiScopeWrapper.build().apiScopeQuery(dataScope);
|
||||
IPage<ApiScope> pages = apiScopeService.page(Condition.getPage(query), Condition.getQueryWrapper(dataScope, ApiScope.class));
|
||||
return R.data(ApiScopeWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "新增", description = "传入dataScope")
|
||||
public R save(@Valid @RequestBody ApiScope dataScope) {
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
return R.status(apiScopeService.save(dataScope));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "修改", description = "传入dataScope")
|
||||
public R update(@Valid @RequestBody ApiScope dataScope) {
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
return R.status(apiScopeService.updateById(dataScope));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "新增或修改", description = "传入dataScope")
|
||||
public R submit(@Valid @RequestBody ApiScope dataScope) {
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
return R.status(apiScopeService.saveOrUpdate(dataScope));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
return R.status(apiScopeService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdministrator;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.AuthClient;
|
||||
import org.springblade.system.service.IAuthClientService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 应用管理控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Hidden
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdministrator
|
||||
@RequestMapping("/client")
|
||||
@Tag(name = "应用管理", description = "接口")
|
||||
public class AuthClientController extends BladeController {
|
||||
|
||||
private final IAuthClientService clientService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入client")
|
||||
public R<AuthClient> detail(AuthClient authClient) {
|
||||
AuthClient detail = clientService.getOne(Condition.getQueryWrapper(authClient));
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入client")
|
||||
public R<IPage<AuthClient>> list(AuthClient authClient, Query query) {
|
||||
IPage<AuthClient> pages = clientService.page(Condition.getPage(query), Condition.getQueryWrapper(authClient));
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "新增", description = "传入client")
|
||||
public R save(@Valid @RequestBody AuthClient authClient) {
|
||||
return R.status(clientService.save(authClient));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "修改", description = "传入client")
|
||||
public R update(@Valid @RequestBody AuthClient authClient) {
|
||||
return R.status(clientService.updateById(authClient));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "新增或修改", description = "传入client")
|
||||
public R submit(@Valid @RequestBody AuthClient authClient) {
|
||||
return R.status(clientService.saveOrUpdate(authClient));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(clientService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.AuthLock;
|
||||
import org.springblade.system.pojo.vo.AuthLockVO;
|
||||
import org.springblade.system.service.IAuthLockService;
|
||||
import org.springblade.system.wrapper.AuthLockWrapper;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
/**
|
||||
* 认证锁定记录 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/auth-lock")
|
||||
@Tag(name = "认证锁定记录", description = "认证锁定记录")
|
||||
public class AuthLockController {
|
||||
|
||||
private final IAuthLockService authLockService;
|
||||
|
||||
@IsAdmin
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "分页查询", description = "传入查询条件")
|
||||
public R<IPage<AuthLockVO>> page(@Parameter(hidden = true) AuthLock authLock, Query query) {
|
||||
IPage<AuthLock> pages = authLockService.page(Condition.getPage(query), Condition.getQueryWrapper(authLock).orderByDesc("lock_begin_time"));
|
||||
return R.data(AuthLockWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
@IsAdmin
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "查看详情", description = "传入id")
|
||||
public R<AuthLockVO> detail(AuthLock authLock) {
|
||||
AuthLock detail = authLockService.getOne(Condition.getQueryWrapper(authLock));
|
||||
return R.data(AuthLockWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
@IsAdmin
|
||||
@PostMapping("/unlock")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "手动解锁", description = "传入锁定记录ID和解锁原因")
|
||||
public R unlock(@Parameter(description = "锁定记录ID", required = true) @RequestParam Long id,
|
||||
@Parameter(description = "解锁原因") @RequestParam(required = false) String unlockReason) {
|
||||
return R.status(authLockService.manualUnlock(id, unlockReason));
|
||||
}
|
||||
|
||||
@IsAdmin
|
||||
@PostMapping("/lock")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "手动锁定用户", description = "传入用户ID、锁定原因、锁定时间")
|
||||
public R lock(@Parameter(description = "用户ID", required = true) @RequestParam Long userId,
|
||||
@Parameter(description = "锁定原因", required = true) @RequestParam String lockReason,
|
||||
@Parameter(description = "锁定开始时间") @RequestParam(required = false) Date lockBeginTime,
|
||||
@Parameter(description = "锁定结束时间") @RequestParam(required = false) Date lockEndTime) {
|
||||
return R.status(authLockService.manualLock(userId, lockReason, lockBeginTime, lockEndTime));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.AuthLog;
|
||||
import org.springblade.system.pojo.vo.AuthLogVO;
|
||||
import org.springblade.system.service.IAuthLogService;
|
||||
import org.springblade.system.wrapper.AuthLogWrapper;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
/**
|
||||
* 认证日志 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/auth-log")
|
||||
@Tag(name = "认证日志", description = "认证日志")
|
||||
public class AuthLogController {
|
||||
|
||||
private final IAuthLogService authLogService;
|
||||
|
||||
/**
|
||||
* 分页查询认证日志
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "分页查询", description = "传入查询条件")
|
||||
public R<IPage<AuthLogVO>> page(@Parameter(hidden = true) AuthLog authLog, Query query) {
|
||||
IPage<AuthLog> pages = authLogService.page(Condition.getPage(query), Condition.getQueryWrapper(authLog).orderByDesc("login_time"));
|
||||
return R.data(AuthLogWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看认证日志详情
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "查看详情", description = "传入id")
|
||||
public R<AuthLogVO> detail(AuthLog authLog) {
|
||||
AuthLog detail = authLogService.getOne(Condition.getQueryWrapper(authLog));
|
||||
return R.data(AuthLogWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.DataScope;
|
||||
import org.springblade.system.pojo.vo.DataScopeVO;
|
||||
import org.springblade.system.service.IDataScopeService;
|
||||
import org.springblade.system.wrapper.DataScopeWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
||||
|
||||
/**
|
||||
* 数据权限控制器
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdmin
|
||||
@RequestMapping("data-scope")
|
||||
@Tag(name = "数据权限", description = "数据权限")
|
||||
public class DataScopeController extends BladeController {
|
||||
|
||||
private final IDataScopeService dataScopeService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入dataScope")
|
||||
public R<DataScope> detail(DataScope dataScope) {
|
||||
DataScope detail = dataScopeService.getOne(Condition.getQueryWrapper(dataScope));
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Parameters({
|
||||
@Parameter(name = "menuId", description = "菜单主键", in = ParameterIn.QUERY, schema = @Schema(type = "integer", format = "int64")),
|
||||
@Parameter(name = "scopeName", description = "数据权限名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "resourceCode", description = "资源编号", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入dataScope")
|
||||
public R<IPage<DataScopeVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> dataScope, Query query) {
|
||||
DataScopeWrapper.build().dataScopeQuery(dataScope);
|
||||
IPage<DataScope> pages = dataScopeService.page(Condition.getPage(query), Condition.getQueryWrapper(dataScope, DataScope.class));
|
||||
return R.data(DataScopeWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "新增", description = "传入dataScope")
|
||||
public R save(@Valid @RequestBody DataScope dataScope) {
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
return R.status(dataScopeService.save(dataScope));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "修改", description = "传入dataScope")
|
||||
public R update(@Valid @RequestBody DataScope dataScope) {
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
return R.status(dataScopeService.updateById(dataScope));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "新增或修改", description = "传入dataScope")
|
||||
public R submit(@Valid @RequestBody DataScope dataScope) {
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
return R.status(dataScopeService.saveOrUpdate(dataScope));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
return R.status(dataScopeService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.secure.BladeUser;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.secure.constant.AuthConstant;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.support.Kv;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.cache.DictCache;
|
||||
import org.springblade.system.cache.UserCache;
|
||||
import org.springblade.system.pojo.entity.Dept;
|
||||
import org.springblade.system.pojo.entity.User;
|
||||
import org.springblade.system.pojo.enums.DictEnum;
|
||||
import org.springblade.system.pojo.vo.DeptVO;
|
||||
import org.springblade.system.pojo.vo.UserVO;
|
||||
import org.springblade.system.service.IDeptService;
|
||||
import org.springblade.system.wrapper.DeptWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/dept")
|
||||
@Tag(name = "部门", description = "部门")
|
||||
public class DeptController extends BladeController {
|
||||
|
||||
private final IDeptService deptService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@PreAuth(menu = "dept")
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入dept")
|
||||
public R<DeptVO> detail(Dept dept) {
|
||||
return R.data(DeptWrapper.build().entityVO(deptService.getDetail(dept)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@PreAuth(menu = "dept")
|
||||
@GetMapping("/list")
|
||||
@Parameters({
|
||||
@Parameter(name = "deptName", description = "部门名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "fullName", description = "部门全称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "列表", description = "传入dept")
|
||||
public R<List<DeptVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> dept) {
|
||||
return R.data(deptService.selectList(dept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 懒加载列表
|
||||
*/
|
||||
@PreAuth(menu = "dept")
|
||||
@GetMapping("/lazy-list")
|
||||
@Parameters({
|
||||
@Parameter(name = "deptName", description = "部门名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "fullName", description = "部门全称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "懒加载列表", description = "传入dept")
|
||||
public R<List<DeptVO>> lazyList(@Parameter(hidden = true) @RequestParam Map<String, Object> dept, Long parentId, BladeUser bladeUser) {
|
||||
List<DeptVO> list = deptService.lazyList(bladeUser.getTenantId(), parentId, dept);
|
||||
return R.data(DeptWrapper.build().listNodeLazyVO(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门树形结构
|
||||
*/
|
||||
@PreAuth(menu = "dept")
|
||||
@GetMapping("/tree")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "树形结构", description = "树形结构")
|
||||
public R<List<DeptVO>> tree(String tenantId) {
|
||||
return R.data(deptService.tree(tenantId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 懒加载获取部门树形结构
|
||||
* <p>
|
||||
* tenantId 由 Service 层完整决策:超管入参为空表示查全部,非超管强制覆盖为会话租户。
|
||||
*/
|
||||
@PreAuth(menu = "dept")
|
||||
@GetMapping("/lazy-tree")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "懒加载树形结构", description = "树形结构")
|
||||
public R<List<DeptVO>> lazyTree(String tenantId, Long parentId) {
|
||||
return R.data(deptService.lazyTree(tenantId, parentId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@IsAdmin
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入dept")
|
||||
public R submit(@Valid @RequestBody Dept dept) {
|
||||
if (deptService.submit(dept)) {
|
||||
CacheUtil.clear(SYS_CACHE);
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
// 返回懒加载树更新节点所需字段
|
||||
Kv kv = Kv.create().set("id", String.valueOf(dept.getId())).set("tenantId", dept.getTenantId())
|
||||
.set("deptCategoryName", DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory()));
|
||||
return R.data(kv);
|
||||
}
|
||||
return R.fail("操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@IsAdmin
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
CacheUtil.clear(SYS_CACHE);
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
return R.status(deptService.removeDept(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉数据源
|
||||
*/
|
||||
@PreAuth(AuthConstant.PERMIT_ALL)
|
||||
@GetMapping("/select")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "下拉数据源", description = "传入id集合")
|
||||
public R<List<Dept>> select(Long userId, String deptId) {
|
||||
if (Func.isNotEmpty(userId)) {
|
||||
User user = UserCache.getUser(userId);
|
||||
deptId = user.getDeptId();
|
||||
}
|
||||
List<Dept> list = deptService.list(Wrappers.<Dept>lambdaQuery().in(Dept::getId, Func.toLongList(deptId)));
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门的主管信息
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("/dept-leader-info")
|
||||
@ApiOperationSupport(order = 9)
|
||||
@Operation(summary = "获取部门的主管信息", description = "传入deptId")
|
||||
public R<List<UserVO>> deptLeaderInfo(@Parameter(description = "部门id", required = true) @RequestParam Long deptId) {
|
||||
List<UserVO> list = deptService.deptLeaderInfo(deptId);
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.common.constant.CommonConstant;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.system.pojo.entity.DictBiz;
|
||||
import org.springblade.system.service.IDictBizService;
|
||||
import org.springblade.system.pojo.vo.DictBizVO;
|
||||
import org.springblade.system.wrapper.DictBizWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/dict-biz")
|
||||
@Tag(name = "业务字典", description = "业务字典")
|
||||
public class DictBizController extends BladeController {
|
||||
|
||||
private final IDictBizService dictService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入dict")
|
||||
public R<DictBizVO> detail(DictBiz dict) {
|
||||
DictBiz detail = dictService.getOne(Condition.getQueryWrapper(dict));
|
||||
return R.data(DictBizWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Parameters({
|
||||
@Parameter(name = "code", description = "字典编号", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "dictValue", description = "字典名称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "列表", description = "传入dict")
|
||||
public R<List<DictBizVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> dict) {
|
||||
List<DictBiz> list = dictService.list(Condition.getQueryWrapper(dict, DictBiz.class).lambda().orderByAsc(DictBiz::getSort));
|
||||
return R.data(DictBizWrapper.build().listNodeVO(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 顶级列表
|
||||
*/
|
||||
@GetMapping("/parent-list")
|
||||
@Parameters({
|
||||
@Parameter(name = "code", description = "字典编号", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "dictValue", description = "字典名称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "列表", description = "传入dict")
|
||||
public R<IPage<DictBizVO>> parentList(@Parameter(hidden = true) @RequestParam Map<String, Object> dict, Query query) {
|
||||
return R.data(dictService.parentList(dict, query));
|
||||
}
|
||||
|
||||
/**
|
||||
* 子列表
|
||||
*/
|
||||
@GetMapping("/child-list")
|
||||
@Parameters({
|
||||
@Parameter(name = "code", description = "字典编号", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "dictValue", description = "字典名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "parentId", description = "字典名称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "列表", description = "传入dict")
|
||||
public R<List<DictBizVO>> childList(@Parameter(hidden = true) @RequestParam Map<String, Object> dict, @RequestParam(required = false, defaultValue = "-1") Long parentId) {
|
||||
return R.data(dictService.childList(dict, parentId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典树形结构
|
||||
*/
|
||||
@GetMapping("/tree")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "树形结构", description = "树形结构")
|
||||
public R<List<DictBizVO>> tree() {
|
||||
List<DictBizVO> tree = dictService.tree();
|
||||
return R.data(tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典树形结构
|
||||
*/
|
||||
@GetMapping("/parent-tree")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "树形结构", description = "树形结构")
|
||||
public R<List<DictBizVO>> parentTree() {
|
||||
List<DictBizVO> tree = dictService.parentTree();
|
||||
return R.data(tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PreAuth(menu = "dictbiz")
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入dict")
|
||||
public R submit(@Valid @RequestBody DictBiz dict) {
|
||||
CacheUtil.clear(DICT_CACHE);
|
||||
return R.status(dictService.submit(dict));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PreAuth(menu = "dictbiz")
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
CacheUtil.clear(DICT_CACHE);
|
||||
return R.status(dictService.removeDict(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典
|
||||
*/
|
||||
@GetMapping("/dictionary")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "获取字典", description = "获取字典")
|
||||
public R<List<DictBiz>> dictionary(String code) {
|
||||
List<DictBiz> tree = dictService.getList(code);
|
||||
return R.data(tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典树
|
||||
*/
|
||||
@GetMapping("/dictionary-tree")
|
||||
@ApiOperationSupport(order = 9)
|
||||
@Operation(summary = "获取字典树", description = "获取字典树")
|
||||
public R<List<DictBizVO>> dictionaryTree(String code) {
|
||||
List<DictBiz> tree = dictService.getList(code);
|
||||
return R.data(DictBizWrapper.build().listNodeVO(tree));
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典键值列表
|
||||
*/
|
||||
@GetMapping("/select")
|
||||
@ApiOperationSupport(order = 10)
|
||||
@Operation(summary = "字典键值列表", description = "字典键值列表")
|
||||
public R<List<DictBiz>> select() {
|
||||
List<DictBiz> list = dictService.list(Wrappers.<DictBiz>query().lambda().eq(DictBiz::getParentId, CommonConstant.TOP_PARENT_ID));
|
||||
list.forEach(dict -> dict.setDictValue(dict.getCode() + StringPool.COLON + StringPool.SPACE + dict.getDictValue()));
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典全列表
|
||||
*/
|
||||
@GetMapping("/select-all")
|
||||
@ApiOperationSupport(order = 11)
|
||||
@Operation(summary = "字典全列表", description = "字典全列表")
|
||||
public R<List<DictBiz>> selectAll() {
|
||||
List<DictBiz> list = dictService.list(Wrappers.<DictBiz>query().lambda().eq(DictBiz::getIsDeleted, BladeConstant.DB_NOT_DELETED));
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.common.constant.CommonConstant;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.system.pojo.entity.Dict;
|
||||
import org.springblade.system.service.IDictService;
|
||||
import org.springblade.system.pojo.vo.DictVO;
|
||||
import org.springblade.system.wrapper.DictWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE;
|
||||
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/dict")
|
||||
@Tag(name = "系统字典", description = "系统字典")
|
||||
public class DictController extends BladeController {
|
||||
|
||||
private final IDictService dictService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入dict")
|
||||
public R<DictVO> detail(Dict dict) {
|
||||
Dict detail = dictService.getOne(Condition.getQueryWrapper(dict));
|
||||
return R.data(DictWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Parameters({
|
||||
@Parameter(name = "code", description = "字典编号", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "dictValue", description = "字典名称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "列表", description = "传入dict")
|
||||
public R<List<DictVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> dict) {
|
||||
List<Dict> list = dictService.list(Condition.getQueryWrapper(dict, Dict.class).lambda().orderByAsc(Dict::getSort));
|
||||
DictWrapper dictWrapper = new DictWrapper();
|
||||
return R.data(dictWrapper.listNodeVO(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 顶级列表
|
||||
*/
|
||||
@GetMapping("/parent-list")
|
||||
@Parameters({
|
||||
@Parameter(name = "code", description = "字典编号", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "dictValue", description = "字典名称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "列表", description = "传入dict")
|
||||
public R<IPage<DictVO>> parentList(@Parameter(hidden = true) @RequestParam Map<String, Object> dict, Query query) {
|
||||
return R.data(dictService.parentList(dict, query));
|
||||
}
|
||||
|
||||
/**
|
||||
* 子列表
|
||||
*/
|
||||
@GetMapping("/child-list")
|
||||
@Parameters({
|
||||
@Parameter(name = "code", description = "字典编号", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "dictValue", description = "字典名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "parentId", description = "字典名称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "列表", description = "传入dict")
|
||||
public R<List<DictVO>> childList(@Parameter(hidden = true) @RequestParam Map<String, Object> dict, @RequestParam(required = false, defaultValue = "-1") Long parentId) {
|
||||
return R.data(dictService.childList(dict, parentId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典树形结构
|
||||
*/
|
||||
@GetMapping("/tree")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "树形结构", description = "树形结构")
|
||||
public R<List<DictVO>> tree() {
|
||||
List<DictVO> tree = dictService.tree();
|
||||
return R.data(tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典树形结构
|
||||
*/
|
||||
@GetMapping("/parent-tree")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "树形结构", description = "树形结构")
|
||||
public R<List<DictVO>> parentTree() {
|
||||
List<DictVO> tree = dictService.parentTree();
|
||||
return R.data(tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PreAuth(menu = "dict")
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入dict")
|
||||
public R submit(@Valid @RequestBody Dict dict) {
|
||||
CacheUtil.clear(DICT_CACHE, Boolean.FALSE);
|
||||
return R.status(dictService.submit(dict));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PreAuth(menu = "dict")
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
CacheUtil.clear(DICT_CACHE, Boolean.FALSE);
|
||||
return R.status(dictService.removeDict(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典
|
||||
*/
|
||||
@GetMapping("/dictionary")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "获取字典", description = "获取字典")
|
||||
public R<List<Dict>> dictionary(String code) {
|
||||
List<Dict> tree = dictService.getList(code);
|
||||
return R.data(tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典
|
||||
*/
|
||||
@GetMapping("/dictionary-full")
|
||||
@ApiOperationSupport(order = 9)
|
||||
@Operation(summary = "获取字典", description = "获取字典")
|
||||
public R<List<Dict>> dictionaryFull(String code) {
|
||||
List<Dict> tree = dictService.getList(code);
|
||||
tree.forEach(dict -> dict.setDictValue(dict.getDictKey() + StringPool.SPACE + StringPool.COLON + StringPool.SPACE + dict.getDictValue()));
|
||||
return R.data(tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典树
|
||||
*/
|
||||
@GetMapping("/dictionary-tree")
|
||||
@ApiOperationSupport(order = 10)
|
||||
@Operation(summary = "获取字典树", description = "获取字典树")
|
||||
public R<List<DictVO>> dictionaryTree(String code) {
|
||||
List<Dict> tree = dictService.getList(code);
|
||||
return R.data(DictWrapper.build().listNodeVO(tree));
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典键值列表
|
||||
*/
|
||||
@GetMapping("/select")
|
||||
@ApiOperationSupport(order = 11)
|
||||
@Operation(summary = "字典键值列表", description = "字典键值列表")
|
||||
public R<List<Dict>> select() {
|
||||
List<Dict> list = dictService.list(Wrappers.<Dict>query().lambda().eq(Dict::getParentId, CommonConstant.TOP_PARENT_ID));
|
||||
list.forEach(dict -> dict.setDictValue(dict.getCode() + StringPool.COLON + StringPool.SPACE + dict.getDictValue()));
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典全列表
|
||||
*/
|
||||
@GetMapping("/select-all")
|
||||
@ApiOperationSupport(order = 12)
|
||||
@Operation(summary = "字典全列表", description = "字典全列表")
|
||||
public R<List<Dict>> selectAll() {
|
||||
List<Dict> list = dictService.list(Wrappers.<Dict>query().lambda().eq(Dict::getIsDeleted, BladeConstant.DB_NOT_DELETED));
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.secure.BladeUser;
|
||||
import org.springblade.core.secure.annotation.IsAdministrator;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.node.TreeNode;
|
||||
import org.springblade.core.tool.support.Kv;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.Menu;
|
||||
import org.springblade.system.pojo.entity.TopMenu;
|
||||
import org.springblade.system.pojo.vo.CheckedTreeVO;
|
||||
import org.springblade.system.pojo.vo.GrantTreeVO;
|
||||
import org.springblade.system.pojo.vo.MenuVO;
|
||||
import org.springblade.system.service.IMenuService;
|
||||
import org.springblade.system.service.ITopMenuService;
|
||||
import org.springblade.system.wrapper.MenuWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.MENU_CACHE;
|
||||
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/menu")
|
||||
@Tag(name = "菜单", description = "菜单")
|
||||
public class MenuController extends BladeController {
|
||||
|
||||
private final IMenuService menuService;
|
||||
private final ITopMenuService topMenuService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@IsAdministrator
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入menu")
|
||||
public R<MenuVO> detail(Menu menu) {
|
||||
Menu detail = menuService.getOne(Condition.getQueryWrapper(menu));
|
||||
return R.data(MenuWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@IsAdministrator
|
||||
@GetMapping("/list")
|
||||
@Parameters({
|
||||
@Parameter(name = "code", description = "菜单编号", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "name", description = "菜单名称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "列表", description = "传入menu")
|
||||
public R<List<MenuVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> menu) {
|
||||
List<Menu> list = menuService.list(Condition.getQueryWrapper(menu, Menu.class).lambda().orderByAsc(Menu::getSort));
|
||||
return R.data(MenuWrapper.build().listNodeVO(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 懒加载列表
|
||||
*/
|
||||
@IsAdministrator
|
||||
@GetMapping("/lazy-list")
|
||||
@Parameters({
|
||||
@Parameter(name = "code", description = "菜单编号", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "name", description = "菜单名称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "懒加载列表", description = "传入menu")
|
||||
public R<List<MenuVO>> lazyList(Long parentId, @Parameter(hidden = true) @RequestParam Map<String, Object> menu) {
|
||||
List<MenuVO> list = menuService.lazyList(parentId, menu);
|
||||
return R.data(MenuWrapper.build().listNodeLazyVO(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单列表
|
||||
*/
|
||||
@IsAdministrator
|
||||
@GetMapping("/menu-list")
|
||||
@Parameters({
|
||||
@Parameter(name = "code", description = "菜单编号", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "name", description = "菜单名称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "菜单列表", description = "传入menu")
|
||||
public R<List<MenuVO>> menuList(@Parameter(hidden = true) @RequestParam Map<String, Object> menu) {
|
||||
List<Menu> list = menuService.list(Condition.getQueryWrapper(menu, Menu.class).lambda().eq(Menu::getCategory, 1).orderByAsc(Menu::getSort));
|
||||
return R.data(MenuWrapper.build().listNodeVO(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 懒加载菜单列表
|
||||
*/
|
||||
@IsAdministrator
|
||||
@GetMapping("/lazy-menu-list")
|
||||
@Parameters({
|
||||
@Parameter(name = "code", description = "菜单编号", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "name", description = "菜单名称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "懒加载菜单列表", description = "传入menu")
|
||||
public R<List<MenuVO>> lazyMenuList(Long parentId, @Parameter(hidden = true) @RequestParam Map<String, Object> menu) {
|
||||
List<MenuVO> list = menuService.lazyMenuList(parentId, menu);
|
||||
return R.data(MenuWrapper.build().listNodeLazyVO(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@IsAdministrator
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入menu")
|
||||
public R submit(@Valid @RequestBody Menu menu) {
|
||||
if (menuService.submit(menu)) {
|
||||
CacheUtil.clear(MENU_CACHE);
|
||||
CacheUtil.clear(MENU_CACHE, Boolean.FALSE);
|
||||
// 返回懒加载树更新节点所需字段
|
||||
Kv kv = Kv.create().set("id", String.valueOf(menu.getId()));
|
||||
return R.data(kv);
|
||||
}
|
||||
return R.fail("操作失败");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@IsAdministrator
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
CacheUtil.clear(MENU_CACHE);
|
||||
CacheUtil.clear(MENU_CACHE, Boolean.FALSE);
|
||||
return R.status(menuService.removeMenu(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端菜单数据
|
||||
*/
|
||||
@GetMapping("/routes")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "前端菜单数据", description = "前端菜单数据")
|
||||
public R<List<MenuVO>> routes(BladeUser user, Long topMenuId) {
|
||||
List<MenuVO> list = menuService.routes((user == null) ? null : user.getRoleId(), topMenuId);
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端按钮数据
|
||||
*/
|
||||
@GetMapping("/buttons")
|
||||
@ApiOperationSupport(order = 10)
|
||||
@Operation(summary = "前端按钮数据", description = "前端按钮数据")
|
||||
public R<List<MenuVO>> buttons(BladeUser user) {
|
||||
List<MenuVO> list = menuService.buttons(user.getRoleId());
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单树形结构
|
||||
*/
|
||||
@GetMapping("/tree")
|
||||
@ApiOperationSupport(order = 11)
|
||||
@Operation(summary = "树形结构", description = "树形结构")
|
||||
public R<List<TreeNode>> tree() {
|
||||
List<TreeNode> tree = menuService.tree();
|
||||
return R.data(tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限分配树形结构
|
||||
*/
|
||||
@GetMapping("/grant-tree")
|
||||
@ApiOperationSupport(order = 12)
|
||||
@Operation(summary = "权限分配树形结构", description = "权限分配树形结构")
|
||||
public R<GrantTreeVO> grantTree(BladeUser user) {
|
||||
GrantTreeVO vo = new GrantTreeVO();
|
||||
vo.setMenu(menuService.grantTree(user));
|
||||
vo.setDataScope(menuService.grantDataScopeTree(user));
|
||||
vo.setApiScope(menuService.grantApiScopeTree(user));
|
||||
return R.data(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限分配树形结构
|
||||
*/
|
||||
@GetMapping("/role-tree-keys")
|
||||
@ApiOperationSupport(order = 13)
|
||||
@Operation(summary = "角色所分配的树", description = "角色所分配的树")
|
||||
public R<CheckedTreeVO> roleTreeKeys(String roleIds) {
|
||||
CheckedTreeVO vo = new CheckedTreeVO();
|
||||
vo.setMenu(menuService.roleTreeKeys(roleIds));
|
||||
vo.setDataScope(menuService.dataScopeTreeKeys(roleIds));
|
||||
vo.setApiScope(menuService.apiScopeTreeKeys(roleIds));
|
||||
return R.data(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取顶部菜单树形结构
|
||||
*/
|
||||
@GetMapping("/grant-top-tree")
|
||||
@ApiOperationSupport(order = 14)
|
||||
@Operation(summary = "顶部菜单树形结构", description = "顶部菜单树形结构")
|
||||
public R<GrantTreeVO> grantTopTree(BladeUser user) {
|
||||
GrantTreeVO vo = new GrantTreeVO();
|
||||
vo.setMenu(menuService.grantTopTree(user));
|
||||
return R.data(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取顶部菜单树形结构
|
||||
*/
|
||||
@GetMapping("/top-tree-keys")
|
||||
@ApiOperationSupport(order = 15)
|
||||
@Operation(summary = "顶部菜单所分配的树", description = "顶部菜单所分配的树")
|
||||
public R<CheckedTreeVO> topTreeKeys(String topMenuIds) {
|
||||
CheckedTreeVO vo = new CheckedTreeVO();
|
||||
vo.setMenu(menuService.topTreeKeys(topMenuIds));
|
||||
return R.data(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 顶部菜单数据
|
||||
*/
|
||||
@GetMapping("/top-menu")
|
||||
@ApiOperationSupport(order = 16)
|
||||
@Operation(summary = "顶部菜单数据", description = "顶部菜单数据")
|
||||
public R<List<TopMenu>> topMenu(BladeUser user) {
|
||||
if (Func.isEmpty(user)) {
|
||||
return null;
|
||||
}
|
||||
List<TopMenu> list = topMenuService.list(Wrappers.<TopMenu>query().lambda().orderByAsc(TopMenu::getSort));
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 主页顶部菜单数据
|
||||
*/
|
||||
@GetMapping("/main-menu")
|
||||
@ApiOperationSupport(order = 18)
|
||||
@Operation(summary = "主页顶部菜单数据", description = "主页顶部菜单数据")
|
||||
public R<TopMenu> mainMenu(BladeUser user) {
|
||||
if (Func.isEmpty(user)) {
|
||||
return null;
|
||||
}
|
||||
TopMenu topMenu = topMenuService.getOne(
|
||||
Wrappers.<TopMenu>query().lambda().eq(TopMenu::getIsMain, 1)
|
||||
);
|
||||
return R.data(topMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置的角色权限
|
||||
*/
|
||||
@GetMapping("auth-routes")
|
||||
@ApiOperationSupport(order = 17)
|
||||
@Operation(summary = "菜单的角色权限")
|
||||
public R<List<Kv>> authRoutes(BladeUser user) {
|
||||
if (Func.isEmpty(user)) {
|
||||
return null;
|
||||
}
|
||||
return R.data(menuService.authRoutes(user));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.Param;
|
||||
import org.springblade.system.pojo.vo.ParamVO;
|
||||
import org.springblade.system.service.IParamService;
|
||||
import org.springblade.system.wrapper.ParamWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.PARAM_CACHE;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdmin
|
||||
@RequestMapping("/param")
|
||||
@Tag(name = "参数配置", description = "参数配置")
|
||||
public class ParamController extends BladeController {
|
||||
|
||||
private final IParamService paramService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入param")
|
||||
public R<ParamVO> detail(Param param) {
|
||||
Param detail = paramService.getOne(Condition.getQueryWrapper(param));
|
||||
return R.data(ParamWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Parameters({
|
||||
@Parameter(name = "paramName", description = "参数名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "paramKey", description = "参数键名", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "paramValue", description = "参数键值", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入param")
|
||||
public R<IPage<ParamVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> param, Query query) {
|
||||
IPage<Param> pages = paramService.page(Condition.getPage(query), Condition.getQueryWrapper(param, Param.class));
|
||||
return R.data(ParamWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "新增或修改", description = "传入param")
|
||||
public R submit(@Valid @RequestBody Param param) {
|
||||
CacheUtil.clear(PARAM_CACHE);
|
||||
CacheUtil.clear(PARAM_CACHE, Boolean.FALSE);
|
||||
return R.status(paramService.saveOrUpdate(param));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
CacheUtil.clear(PARAM_CACHE);
|
||||
CacheUtil.clear(PARAM_CACHE, Boolean.FALSE);
|
||||
return R.status(paramService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.Post;
|
||||
import org.springblade.system.service.IPostService;
|
||||
import org.springblade.system.pojo.vo.PostVO;
|
||||
import org.springblade.system.wrapper.PostWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 岗位表 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@PreAuth(menu = "post")
|
||||
@RequestMapping("/post")
|
||||
@Tag(name = "岗位", description = "岗位")
|
||||
public class PostController extends BladeController {
|
||||
|
||||
private final IPostService postService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入post")
|
||||
public R<PostVO> detail(Post post) {
|
||||
Post detail = postService.getOne(Condition.getQueryWrapper(post));
|
||||
return R.data(PostWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页 岗位表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入post")
|
||||
public R<IPage<PostVO>> list(Post post, Query query) {
|
||||
IPage<Post> pages = postService.page(Condition.getPage(query), Condition.getQueryWrapper(post));
|
||||
return R.data(PostWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自定义分页 岗位表
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入post")
|
||||
public R<IPage<PostVO>> page(PostVO post, Query query) {
|
||||
IPage<PostVO> pages = postService.selectPostPage(Condition.getPage(query), post);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 岗位表
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入post")
|
||||
public R save(@Valid @RequestBody Post post) {
|
||||
return R.status(postService.submit(post));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 岗位表
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入post")
|
||||
public R update(@Valid @RequestBody Post post) {
|
||||
return R.status(postService.submit(post));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改 岗位表
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入post")
|
||||
public R submit(@Valid @RequestBody Post post) {
|
||||
return R.status(postService.submit(post));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除 岗位表
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(postService.remove(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉数据源
|
||||
*/
|
||||
@GetMapping("/select")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "下拉数据源", description = "传入post")
|
||||
public R<List<Post>> select(String tenantId) {
|
||||
return R.data(postService.selectByTenant(tenantId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdministrator;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.RateLimit;
|
||||
import org.springblade.system.pojo.vo.RateLimitVO;
|
||||
import org.springblade.system.service.IRateLimitService;
|
||||
import org.springblade.system.wrapper.RateLimitWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 限流规则 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@IsAdministrator
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/rate-limit")
|
||||
@Tag(name = "限流规则", description = "限流规则接口")
|
||||
public class RateLimitController extends BladeController {
|
||||
|
||||
private final IRateLimitService rateLimitService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入rateLimit")
|
||||
public R<RateLimitVO> detail(RateLimit rateLimit) {
|
||||
RateLimit detail = rateLimitService.getOne(Condition.getQueryWrapper(rateLimit));
|
||||
return R.data(RateLimitWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入rateLimit")
|
||||
public R<IPage<RateLimitVO>> list(@Parameter(hidden = true) RateLimit rateLimit, Query query) {
|
||||
IPage<RateLimit> pages = rateLimitService.page(Condition.getPage(query), Condition.getQueryWrapper(rateLimit));
|
||||
return R.data(RateLimitWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "新增", description = "传入rateLimit")
|
||||
public R<Boolean> save(@Valid @RequestBody RateLimit rateLimit) {
|
||||
return R.status(rateLimitService.submitRateLimit(rateLimit));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "修改", description = "传入rateLimit")
|
||||
public R<Boolean> update(@Valid @RequestBody RateLimit rateLimit) {
|
||||
return R.status(rateLimitService.submitRateLimit(rateLimit));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "新增或修改", description = "传入rateLimit")
|
||||
public R<Boolean> submit(@Valid @RequestBody RateLimit rateLimit) {
|
||||
return R.status(rateLimitService.submitRateLimit(rateLimit));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R<Boolean> remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(rateLimitService.removeRateLimit(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用
|
||||
*/
|
||||
@PostMapping("/enable")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "启用", description = "传入ids")
|
||||
public R<Boolean> enable(@RequestParam String ids) {
|
||||
return R.status(rateLimitService.enableRateLimit(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用
|
||||
*/
|
||||
@PostMapping("/disable")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "禁用", description = "传入ids")
|
||||
public R<Boolean> disable(@RequestParam String ids) {
|
||||
return R.status(rateLimitService.disableRateLimit(ids));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdministrator;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.RateLimitLog;
|
||||
import org.springblade.system.pojo.vo.RateLimitLogVO;
|
||||
import org.springblade.system.service.IRateLimitLogService;
|
||||
import org.springblade.system.wrapper.RateLimitLogWrapper;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 限流触发日志 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@IsAdministrator
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/rate-limit-log")
|
||||
public class RateLimitLogController {
|
||||
|
||||
private final IRateLimitLogService logService;
|
||||
|
||||
/**
|
||||
* 查询单条
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public R<RateLimitLog> detail(RateLimitLog log) {
|
||||
QueryWrapper<RateLimitLog> queryWrapper = Condition.getQueryWrapper(log);
|
||||
return R.data(queryWrapper.isEmptyOfWhere() ? null : logService.getOne(queryWrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询多条(分页)
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R<IPage<RateLimitLogVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> log, Query query) {
|
||||
IPage<RateLimitLog> pages = logService.page(Condition.getPage(query.setDescs("create_time")), Condition.getQueryWrapper(log, RateLimitLog.class));
|
||||
return R.data(RateLimitLogWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.secure.annotation.IsAdministrator;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.RecordData;
|
||||
import org.springblade.system.pojo.vo.RecordDataVO;
|
||||
import org.springblade.system.service.IRecordDataService;
|
||||
import org.springblade.system.wrapper.RecordDataWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据审计表 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/record-data")
|
||||
@Tag(name = "数据审计表", description = "数据审计表接口")
|
||||
public class RecordDataController extends BladeController {
|
||||
|
||||
private final IRecordDataService recordDataService;
|
||||
|
||||
/**
|
||||
* 数据审计表 详情
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入recordData")
|
||||
public R<RecordDataVO> detail(RecordData recordData) {
|
||||
RecordData detail = recordDataService.getOne(Condition.getQueryWrapper(recordData));
|
||||
return R.data(RecordDataWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据审计表 分页
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入recordData")
|
||||
public R<IPage<RecordDataVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> recordData, Query query) {
|
||||
IPage<RecordData> pages = recordDataService.page(Condition.getPage(query.setDescs(BladeConstant.DB_PRIMARY_KEY)), Condition.getQueryWrapper(recordData, RecordData.class));
|
||||
return R.data(RecordDataWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据审计表 新增
|
||||
*/
|
||||
@IsAdministrator
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "新增", description = "传入recordData")
|
||||
public R save(@Valid @RequestBody RecordData recordData) {
|
||||
return R.status(recordDataService.save(recordData));
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据审计表 修改
|
||||
*/
|
||||
@IsAdministrator
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "修改", description = "传入recordData")
|
||||
public R update(@Valid @RequestBody RecordData recordData) {
|
||||
return R.status(recordDataService.updateById(recordData));
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据审计表 新增或修改
|
||||
*/
|
||||
@IsAdministrator
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "新增或修改", description = "传入recordData")
|
||||
public R submit(@Valid @RequestBody RecordData recordData) {
|
||||
return R.status(recordDataService.saveOrUpdate(recordData));
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据审计表 删除
|
||||
*/
|
||||
@IsAdministrator
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(recordDataService.removeByIds(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.excel.util.ExcelUtil;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.DateUtil;
|
||||
import org.springblade.system.pojo.entity.Region;
|
||||
import org.springblade.system.excel.RegionExcel;
|
||||
import org.springblade.system.excel.RegionImporter;
|
||||
import org.springblade.system.service.IRegionService;
|
||||
import org.springblade.system.pojo.vo.RegionVO;
|
||||
import org.springblade.system.wrapper.RegionWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 行政区划表 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@PreAuth(menu = "region")
|
||||
@RequestMapping("/region")
|
||||
@Tag(name = "行政区划", description = "行政区划")
|
||||
public class RegionController extends BladeController {
|
||||
|
||||
private final IRegionService regionService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入region")
|
||||
public R<RegionVO> detail(Region region) {
|
||||
Region detail = regionService.getOne(Condition.getQueryWrapper(region));
|
||||
return R.data(RegionWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页 行政区划表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入region")
|
||||
public R<IPage<Region>> list(Region region, Query query) {
|
||||
IPage<Region> pages = regionService.page(Condition.getPage(query), Condition.getQueryWrapper(region));
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 懒加载列表
|
||||
*/
|
||||
@GetMapping("/lazy-list")
|
||||
@Parameters({
|
||||
@Parameter(name = "code", description = "区划编号", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "name", description = "区划名称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "懒加载列表", description = "传入menu")
|
||||
public R<List<RegionVO>> lazyList(String parentCode, @Parameter(hidden = true) @RequestParam Map<String, Object> menu) {
|
||||
List<RegionVO> list = regionService.lazyList(parentCode, menu);
|
||||
return R.data(RegionWrapper.build().listNodeLazyVO(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 懒加载列表
|
||||
*/
|
||||
@GetMapping("/lazy-tree")
|
||||
@Parameters({
|
||||
@Parameter(name = "code", description = "区划编号", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "name", description = "区划名称", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "懒加载列表", description = "传入menu")
|
||||
public R<List<RegionVO>> lazyTree(String parentCode, @Parameter(hidden = true) @RequestParam Map<String, Object> menu) {
|
||||
List<RegionVO> list = regionService.lazyTree(parentCode, menu);
|
||||
return R.data(RegionWrapper.build().listNodeLazyVO(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 行政区划表
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "新增", description = "传入region")
|
||||
public R save(@Valid @RequestBody Region region) {
|
||||
return R.status(regionService.save(region));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 行政区划表
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "修改", description = "传入region")
|
||||
public R update(@Valid @RequestBody Region region) {
|
||||
return R.status(regionService.updateById(region));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改 行政区划表
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "新增或修改", description = "传入region")
|
||||
public R submit(@Valid @RequestBody Region region) {
|
||||
return R.status(regionService.submit(region));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除 行政区划表
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "删除", description = "传入主键")
|
||||
public R remove(@Parameter(description = "主键", required = true) @RequestParam String id) {
|
||||
return R.status(regionService.removeRegion(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 行政区划下拉数据源
|
||||
*/
|
||||
@GetMapping("/select")
|
||||
@ApiOperationSupport(order = 9)
|
||||
@Operation(summary = "下拉数据源", description = "传入tenant")
|
||||
public R<List<Region>> select(@RequestParam(required = false, defaultValue = "00") String code) {
|
||||
List<Region> list = regionService.list(Wrappers.<Region>query().lambda().eq(Region::getParentCode, code));
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入行政区划数据
|
||||
*/
|
||||
@PostMapping("import-region")
|
||||
@ApiOperationSupport(order = 10)
|
||||
@Operation(summary = "导入行政区划", description = "传入excel")
|
||||
public R importRegion(MultipartFile file, Integer isCovered) {
|
||||
RegionImporter regionImporter = new RegionImporter(regionService, isCovered == 1);
|
||||
ExcelUtil.save(file, regionImporter, RegionExcel.class);
|
||||
return R.success("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出行政区划数据
|
||||
*/
|
||||
@GetMapping("export-region")
|
||||
@ApiOperationSupport(order = 11)
|
||||
@Operation(summary = "导出行政区划", description = "传入user")
|
||||
public void exportRegion(@Parameter(hidden = true) @RequestParam Map<String, Object> region, HttpServletResponse response) {
|
||||
QueryWrapper<Region> queryWrapper = Condition.getQueryWrapper(region, Region.class);
|
||||
List<RegionExcel> list = regionService.exportRegion(queryWrapper);
|
||||
ExcelUtil.export(response, "行政区划数据" + DateUtil.time(), "行政区划数据表", list, RegionExcel.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出模板
|
||||
*/
|
||||
@GetMapping("export-template")
|
||||
@ApiOperationSupport(order = 12)
|
||||
@Operation(summary = "导出模板")
|
||||
public void exportUser(HttpServletResponse response) {
|
||||
List<RegionExcel> list = new ArrayList<>();
|
||||
ExcelUtil.export(response, "行政区划模板", "行政区划表", list, RegionExcel.class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.secure.BladeUser;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.secure.constant.AuthConstant;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.cache.UserCache;
|
||||
import org.springblade.system.pojo.entity.Role;
|
||||
import org.springblade.system.pojo.entity.User;
|
||||
import org.springblade.system.pojo.vo.GrantVO;
|
||||
import org.springblade.system.pojo.vo.RoleVO;
|
||||
import org.springblade.system.service.IRoleService;
|
||||
import org.springblade.system.wrapper.RoleWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdmin
|
||||
@RequestMapping("/role")
|
||||
@Tag(name = "角色", description = "角色")
|
||||
public class RoleController extends BladeController {
|
||||
|
||||
private final IRoleService roleService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入role")
|
||||
public R<RoleVO> detail(Role role) {
|
||||
return R.data(RoleWrapper.build().entityVO(roleService.getDetail(role)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Parameters({
|
||||
@Parameter(name = "roleName", description = "参数名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "roleAlias", description = "角色别名", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "列表", description = "传入role")
|
||||
public R<List<RoleVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> role) {
|
||||
return R.data(roleService.selectList(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色树形结构
|
||||
* <p>
|
||||
* 仅超级管理员可指定任意 tenantId 查询;其他用户强制使用自身 tenantId,
|
||||
* 防止通过 tenantId 参数越权读取其他租户的角色树。
|
||||
*/
|
||||
@GetMapping("/tree")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "树形结构", description = "树形结构")
|
||||
public R<List<RoleVO>> tree(String tenantId) {
|
||||
return R.data(roleService.tree(tenantId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定角色树形结构
|
||||
* <p>
|
||||
* 仅超级管理员可通过任意 roleId 跳转到对应租户的角色树(用于跨租户管理);
|
||||
* 其他用户忽略 roleId 参数,强制返回自身租户的角色树,
|
||||
* 防止通过 roleId 越权读取其他租户的角色结构。
|
||||
*/
|
||||
@GetMapping("/tree-by-id")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "树形结构", description = "树形结构")
|
||||
public R<List<RoleVO>> treeById(Long roleId) {
|
||||
return R.data(roleService.treeById(roleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "新增或修改", description = "传入role")
|
||||
public R submit(@Valid @RequestBody Role role) {
|
||||
CacheUtil.clear(SYS_CACHE);
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
return R.status(roleService.submit(role));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
CacheUtil.clear(SYS_CACHE);
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
return R.status(roleService.removeRole(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置角色权限
|
||||
*/
|
||||
@PostMapping("/grant")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "权限设置", description = "传入roleId集合以及menuId集合")
|
||||
public R grant(@RequestBody GrantVO grantVO) {
|
||||
CacheUtil.clear(SYS_CACHE);
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
boolean temp = roleService.grant(grantVO.getRoleIds(), grantVO.getMenuIds(), grantVO.getDataScopeIds(), grantVO.getApiScopeIds());
|
||||
return R.status(temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉数据源
|
||||
*/
|
||||
@PreAuth(AuthConstant.PERMIT_ALL)
|
||||
@GetMapping("/select")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "下拉数据源", description = "传入id集合")
|
||||
public R<List<Role>> select(Long userId, String roleId) {
|
||||
if (Func.isNotEmpty(userId)) {
|
||||
User user = UserCache.getUser(userId);
|
||||
roleId = user.getRoleId();
|
||||
}
|
||||
List<Role> list = roleService.list(Wrappers.<Role>lambdaQuery().in(Role::getId, Func.toLongList(roleId)));
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取现有角色别名列表
|
||||
*/
|
||||
@GetMapping("/alias")
|
||||
@ApiOperationSupport(order = 9)
|
||||
@Operation(summary = "获取角色别名", description = "获取角色别名")
|
||||
public R<List<Role>> alias() {
|
||||
return R.data(roleService.alias(AuthUtil.getTenantId()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.Post;
|
||||
import org.springblade.system.service.IDeptService;
|
||||
import org.springblade.system.service.IPostService;
|
||||
import org.springblade.system.service.IRoleService;
|
||||
import org.springblade.system.service.IUserService;
|
||||
import org.springblade.system.pojo.vo.DeptVO;
|
||||
import org.springblade.system.pojo.vo.PostVO;
|
||||
import org.springblade.system.pojo.vo.RoleVO;
|
||||
import org.springblade.system.pojo.vo.UserVO;
|
||||
import org.springblade.system.wrapper.PostWrapper;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 查询控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/search")
|
||||
@Tag(name = "信息查询", description = "信息查询")
|
||||
public class SearchController {
|
||||
|
||||
private final IRoleService roleService;
|
||||
|
||||
private final IDeptService deptService;
|
||||
|
||||
private final IPostService postService;
|
||||
|
||||
private final IUserService userService;
|
||||
|
||||
/**
|
||||
* 角色信息查询
|
||||
*/
|
||||
@GetMapping("/role")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "角色信息查询", description = "传入roleName或者parentId")
|
||||
public R<List<RoleVO>> roleSearch(String roleName, Long parentId) {
|
||||
return R.data(roleService.search(roleName, parentId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门信息查询
|
||||
*/
|
||||
@GetMapping("/dept")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "部门信息查询", description = "传入deptName或者parentId")
|
||||
public R<List<DeptVO>> deptSearch(String deptName, Long parentId) {
|
||||
return R.data(deptService.search(deptName, parentId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位信息查询
|
||||
*/
|
||||
@GetMapping("/post")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "岗位信息查询", description = "传入postName")
|
||||
public R<IPage<PostVO>> postSearch(String postName, Query query) {
|
||||
LambdaQueryWrapper<Post> queryWrapper = Wrappers.<Post>query().lambda();
|
||||
if (Func.isNotBlank(postName)) {
|
||||
queryWrapper.like(Post::getPostName, postName);
|
||||
}
|
||||
IPage<Post> pages = postService.page(Condition.getPage(query), queryWrapper);
|
||||
return R.data(PostWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户列表查询
|
||||
*/
|
||||
@Parameters({
|
||||
@Parameter(name = "name", description = "人员姓名", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "deptName", description = "部门名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "postName", description = "职位名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "current", description = "当前页数", in = ParameterIn.QUERY, schema = @Schema(type = "integer")),
|
||||
@Parameter(name = "size", description = "每页数量", in = ParameterIn.QUERY, schema = @Schema(type = "integer"))
|
||||
})
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "用户列表查询", description = "用户列表查询")
|
||||
@GetMapping("/user")
|
||||
public R<IPage<UserVO>> userSearch(@Parameter(hidden = true) UserVO user, @Parameter(hidden = true) Query query) {
|
||||
return R.data(userService.selectUserSearch(user, query));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户的主管信息
|
||||
*/
|
||||
@GetMapping("/leader-info")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "获取用户的主管信息", description = "传入userId")
|
||||
public R<List<UserVO>> leaderInfo(@Parameter(description = "userId", required = true) Long userId) {
|
||||
List<UserVO> list = userService.leaderInfo(userId);
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门的主管信息
|
||||
*/
|
||||
@GetMapping("/dept-leader-info")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "获取部门的主管信息", description = "传入deptId")
|
||||
public R<List<UserVO>> deptLeaderInfo(@Parameter(description = "部门id", required = true) Long deptId) {
|
||||
List<UserVO> list = deptService.deptLeaderInfo(deptId);
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主管列表
|
||||
*/
|
||||
@GetMapping("/leader-list")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "获取主管列表", description = "获取所有主管用户列表")
|
||||
public R<List<UserVO>> leaderList(@Parameter(description = "租户编号") String tenantId, @Parameter(description = "用户姓名") String realName) {
|
||||
List<UserVO> list = userService.leaderList(tenantId, realName);
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,266 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.secure.annotation.IsAdministrator;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
import org.springblade.core.tool.support.Kv;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.Tenant;
|
||||
import org.springblade.system.pojo.entity.TenantPackage;
|
||||
import org.springblade.system.pojo.vo.TenantVO;
|
||||
import org.springblade.system.service.ITenantPackageService;
|
||||
import org.springblade.system.service.ITenantService;
|
||||
import org.springblade.system.wrapper.TenantWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
||||
import static org.springblade.core.tenant.constant.TenantBaseConstant.TENANT_DATASOURCE_CACHE;
|
||||
import static org.springblade.core.tenant.constant.TenantBaseConstant.TENANT_DATASOURCE_EXIST_KEY;
|
||||
import static org.springblade.system.cache.SysCache.TENANT_PACKAGE_ID;
|
||||
import static org.springblade.system.cache.SysCache.TENANT_TENANT_ID;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/tenant")
|
||||
@Tag(name = "租户管理", description = "接口")
|
||||
public class TenantController extends BladeController {
|
||||
|
||||
private final ITenantService tenantService;
|
||||
|
||||
private final ITenantPackageService tenantPackageService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入tenant")
|
||||
public R<Tenant> detail(Tenant tenant) {
|
||||
return R.data(tenantService.getDetail(tenant));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("/list")
|
||||
@Parameters({
|
||||
@Parameter(name = "tenantId", description = "参数名称", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "tenantName", description = "角色别名", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "contactNumber", description = "联系电话", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入tenant")
|
||||
public R<IPage<Tenant>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> tenant, Query query) {
|
||||
return R.data(tenantService.selectPage(tenant, query));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉数据源
|
||||
*/
|
||||
@GetMapping("/select")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "下拉数据源", description = "传入tenant")
|
||||
public R<List<TenantVO>> select(Tenant tenant) {
|
||||
// 仅查询启用状态的租户,Service 层统一收敛租户范围
|
||||
tenant.setStatus(BladeConstant.DB_STATUS_NORMAL);
|
||||
return R.data(TenantWrapper.build().listVO(tenantService.selectList(tenant)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "分页", description = "传入tenant")
|
||||
public R<IPage<Tenant>> page(Tenant tenant, Query query) {
|
||||
IPage<Tenant> pages = tenantService.selectTenantPage(Condition.getPage(query), tenant);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@IsAdministrator
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "新增或修改", description = "传入tenant")
|
||||
public R submit(@Valid @RequestBody Tenant tenant) {
|
||||
return R.status(tenantService.submitTenant(tenant));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除至回收站
|
||||
*/
|
||||
@IsAdministrator
|
||||
@PostMapping("/recycle")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "删除至回收站", description = "传入ids")
|
||||
public R recycle(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(tenantService.recycleTenant(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 从回收站恢复
|
||||
*/
|
||||
@IsAdministrator
|
||||
@PostMapping("/pass")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "从回收站恢复", description = "传入ids")
|
||||
public R pass(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(tenantService.passTenant(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 从回收站删除
|
||||
*/
|
||||
@IsAdministrator
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "从回收站删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(tenantService.removeTenant(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权配置
|
||||
*/
|
||||
@IsAdministrator
|
||||
@PostMapping("/setting")
|
||||
@ApiOperationSupport(order = 9)
|
||||
@Operation(summary = "授权配置", description = "传入ids,accountNumber,expireTime")
|
||||
public R setting(@Parameter(description = "主键集合", required = true) @RequestParam String ids, @Parameter(description = "账号额度") Integer accountNumber, @Parameter(description = "过期时间") Date expireTime) {
|
||||
return R.status(tenantService.setting(accountNumber, expireTime, ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据源配置
|
||||
*/
|
||||
@IsAdministrator
|
||||
@PostMapping("datasource")
|
||||
@ApiOperationSupport(order = 10)
|
||||
@Operation(summary = "数据源配置", description = "传入datasource_id")
|
||||
public R datasource(@Parameter(description = "租户ID", required = true) @RequestParam String tenantId, @Parameter(description = "数据源ID", required = true) @RequestParam Long datasourceId){
|
||||
CacheUtil.evict(TENANT_DATASOURCE_CACHE, TENANT_DATASOURCE_EXIST_KEY, tenantId, Boolean.FALSE);
|
||||
return R.status(tenantService.update(Wrappers.<Tenant>update().lambda().set(Tenant::getDatasourceId, datasourceId).eq(Tenant::getTenantId, tenantId)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据名称查询列表
|
||||
*
|
||||
* @param name 租户名称
|
||||
*/
|
||||
@IsAdministrator
|
||||
@GetMapping("/find-by-name")
|
||||
@ApiOperationSupport(order = 11)
|
||||
@Operation(summary = "详情", description = "传入tenant")
|
||||
public R<List<Tenant>> findByName(String name) {
|
||||
List<Tenant> list = tenantService.list(Wrappers.<Tenant>query().lambda().like(Tenant::getTenantName, name));
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据域名查询信息
|
||||
*
|
||||
* @param domain 域名
|
||||
*/
|
||||
@GetMapping("/info")
|
||||
@ApiOperationSupport(order = 12)
|
||||
@Operation(summary = "配置信息", description = "传入domain")
|
||||
public R<Kv> info(String domain) {
|
||||
Tenant tenant = tenantService.getOne(Wrappers.<Tenant>query().lambda().eq(Tenant::getDomainUrl, domain));
|
||||
Kv kv = Kv.create();
|
||||
if (tenant != null) {
|
||||
kv.set("tenantId", tenant.getTenantId())
|
||||
.set("domain", tenant.getDomainUrl())
|
||||
.set("backgroundUrl", tenant.getBackgroundUrl());
|
||||
}
|
||||
return R.data(kv);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据租户ID查询产品包详情
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
*/
|
||||
@IsAdministrator
|
||||
@GetMapping("/package-detail")
|
||||
@ApiOperationSupport(order = 13)
|
||||
@Operation(summary = "产品包详情", description = "传入tenantId")
|
||||
public R<TenantPackage> packageDetail(Long tenantId) {
|
||||
Tenant tenant = tenantService.getById(tenantId);
|
||||
return R.data(tenantPackageService.getById(tenant.getPackageId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品包配置
|
||||
*/
|
||||
@IsAdministrator
|
||||
@PostMapping("/package-setting")
|
||||
@ApiOperationSupport(order = 14)
|
||||
@Operation(summary = "产品包配置", description = "传入packageId")
|
||||
public R packageSetting(@Parameter(description = "租户ID", required = true) @RequestParam String tenantId, @Parameter(description = "产品包ID") Long packageId) {
|
||||
CacheUtil.evict(SYS_CACHE, TENANT_TENANT_ID, tenantId, Boolean.FALSE);
|
||||
CacheUtil.evict(SYS_CACHE, TENANT_PACKAGE_ID, tenantId, Boolean.FALSE);
|
||||
return R.status(tenantService.update(Wrappers.<Tenant>update().lambda().set(Tenant::getPackageId, packageId).eq(Tenant::getTenantId, tenantId)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdministrator;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.system.pojo.entity.TenantDatasource;
|
||||
import org.springblade.system.service.ITenantDatasourceService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 多租户数据源表 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdministrator
|
||||
@RequestMapping("/tenant-datasource")
|
||||
@Tag(name = "多租户数据源表", description = "多租户数据源表接口")
|
||||
public class TenantDatasourceController extends BladeController {
|
||||
|
||||
private final ITenantDatasourceService datasourceService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入datasource")
|
||||
public R<TenantDatasource> detail(TenantDatasource datasource) {
|
||||
TenantDatasource detail = datasourceService.getOne(Condition.getQueryWrapper(datasource));
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页 数据源配置表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入datasource")
|
||||
public R<IPage<TenantDatasource>> list(TenantDatasource datasource, Query query) {
|
||||
IPage<TenantDatasource> pages = datasourceService.page(Condition.getPage(query), Condition.getQueryWrapper(datasource));
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 数据源配置表
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入datasource")
|
||||
public R save(@Valid @RequestBody TenantDatasource datasource) {
|
||||
return R.status(datasourceService.save(datasource));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 数据源配置表
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入datasource")
|
||||
public R update(@Valid @RequestBody TenantDatasource datasource) {
|
||||
return R.status(datasourceService.updateById(datasource));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改 数据源配置表
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入datasource")
|
||||
public R submit(@Valid @RequestBody TenantDatasource datasource) {
|
||||
if (StringUtil.isNotBlank(datasource.getUrl())) {
|
||||
datasource.setUrl(datasource.getUrl().replace("&", "&"));
|
||||
}
|
||||
return R.status(datasourceService.saveOrUpdate(datasource));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除 数据源配置表
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(datasourceService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据源列表
|
||||
*/
|
||||
@GetMapping("/select")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "下拉数据源", description = "查询列表")
|
||||
public R<List<TenantDatasource>> select() {
|
||||
List<TenantDatasource> list = datasourceService.list();
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdministrator;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.TenantPackage;
|
||||
import org.springblade.system.service.ITenantPackageService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
||||
|
||||
/**
|
||||
* 租户产品表 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdministrator
|
||||
@RequestMapping("/tenant-package")
|
||||
@Tag(name = "租户产品包", description = "租户产品包")
|
||||
public class TenantPackageController extends BladeController {
|
||||
|
||||
private final ITenantPackageService tenantPackageService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入tenantPackage")
|
||||
public R<TenantPackage> detail(TenantPackage tenantPackage) {
|
||||
TenantPackage detail = tenantPackageService.getOne(Condition.getQueryWrapper(tenantPackage));
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页 租户产品表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Parameters({
|
||||
@Parameter(name = "packageName", description = "产品包名", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入tenantPackage")
|
||||
public R<IPage<TenantPackage>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> tenantPackage, Query query) {
|
||||
IPage<TenantPackage> pages = tenantPackageService.page(Condition.getPage(query), Condition.getQueryWrapper(tenantPackage, TenantPackage.class));
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 租户产品表
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "新增", description = "传入tenantPackage")
|
||||
public R save(@Valid @RequestBody TenantPackage tenantPackage) {
|
||||
return R.status(tenantPackageService.save(tenantPackage));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 租户产品表
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "修改", description = "传入tenantPackage")
|
||||
public R update(@Valid @RequestBody TenantPackage tenantPackage) {
|
||||
return R.status(tenantPackageService.updateById(tenantPackage));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改 租户产品表
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "新增或修改", description = "传入tenantPackage")
|
||||
public R submit(@Valid @RequestBody TenantPackage tenantPackage) {
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
return R.status(tenantPackageService.saveOrUpdate(tenantPackage));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除 租户产品表
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
return R.status(tenantPackageService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下拉数据源
|
||||
*/
|
||||
@GetMapping("/select")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "下拉数据源", description = "传入tenant")
|
||||
public R<List<TenantPackage>> select(TenantPackage tenantPackage) {
|
||||
return R.data(tenantPackageService.list(Condition.getQueryWrapper(tenantPackage)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.TopMenu;
|
||||
import org.springblade.system.pojo.vo.GrantVO;
|
||||
import org.springblade.system.service.ITopMenuService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.MENU_CACHE;
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
||||
|
||||
/**
|
||||
* 顶部菜单表 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdmin
|
||||
@RequestMapping("/topmenu")
|
||||
@Tag(name = "顶部菜单表", description = "顶部菜单")
|
||||
public class TopMenuController extends BladeController {
|
||||
|
||||
private final ITopMenuService topMenuService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入topMenu")
|
||||
public R<TopMenu> detail(TopMenu topMenu) {
|
||||
TopMenu detail = topMenuService.getOne(Condition.getQueryWrapper(topMenu));
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页 顶部菜单表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入topMenu")
|
||||
public R<IPage<TopMenu>> list(TopMenu topMenu, Query query) {
|
||||
IPage<TopMenu> pages = topMenuService.page(Condition.getPage(query), Condition.getQueryWrapper(topMenu).lambda().orderByAsc(TopMenu::getSort));
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 顶部菜单表
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入topMenu")
|
||||
public R save(@Valid @RequestBody TopMenu topMenu) {
|
||||
return R.status(topMenuService.save(topMenu));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 顶部菜单表
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入topMenu")
|
||||
public R update(@Valid @RequestBody TopMenu topMenu) {
|
||||
return R.status(topMenuService.updateById(topMenu));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改 顶部菜单表
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入topMenu")
|
||||
public R submit(@Valid @RequestBody TopMenu topMenu) {
|
||||
return R.status(topMenuService.saveOrUpdate(topMenu));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除 顶部菜单表
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(topMenuService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置顶部菜单
|
||||
*/
|
||||
@PostMapping("/grant")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "顶部菜单配置", description = "传入topMenuId集合以及menuId集合")
|
||||
public R grant(@RequestBody GrantVO grantVO) {
|
||||
CacheUtil.clear(SYS_CACHE);
|
||||
CacheUtil.clear(MENU_CACHE);
|
||||
CacheUtil.clear(MENU_CACHE, Boolean.FALSE);
|
||||
boolean temp = topMenuService.grant(grantVO.getTopMenuIds(), grantVO.getMenuIds());
|
||||
return R.status(temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设为主页
|
||||
*/
|
||||
@PostMapping("/enable")
|
||||
@ApiOperationSupport(order = 9)
|
||||
@Operation(summary = "设为主页", description = "传入id")
|
||||
public R enable(@Parameter(description = "主键", required = true) @RequestParam Long id) {
|
||||
CacheUtil.clear(SYS_CACHE);
|
||||
CacheUtil.clear(MENU_CACHE);
|
||||
CacheUtil.clear(MENU_CACHE, Boolean.FALSE);
|
||||
return R.status(topMenuService.enable(id));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,372 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.excel.util.ExcelUtil;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.BladeUser;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.jackson.BladeView;
|
||||
import org.springblade.core.tool.jackson.Views;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
import org.springblade.core.tool.utils.DateUtil;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.system.excel.UserExcel;
|
||||
import org.springblade.system.excel.UserImporter;
|
||||
import org.springblade.system.pojo.entity.User;
|
||||
import org.springblade.system.pojo.vo.UserVO;
|
||||
import org.springblade.system.service.IUserService;
|
||||
import org.springblade.system.wrapper.UserWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
@Tag(name = "用户", description = "用户")
|
||||
@AllArgsConstructor
|
||||
public class UserController {
|
||||
|
||||
private final IUserService userService;
|
||||
|
||||
/**
|
||||
* 查询单条
|
||||
*/
|
||||
@IsAdmin
|
||||
@BladeView(Views.Admin.class)
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "查看详情", description = "传入id")
|
||||
@GetMapping("/detail")
|
||||
public R<UserVO> detail(User user) {
|
||||
return R.data(UserWrapper.build().entityVO(userService.getDetail(user)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单条
|
||||
*/
|
||||
@BladeView
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "查看详情", description = "传入id")
|
||||
@GetMapping("/info")
|
||||
public R<UserVO> info(BladeUser user) {
|
||||
User detail = userService.getById(user.getUserId());
|
||||
return R.data(UserWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("/list")
|
||||
@BladeView(Views.Admin.class)
|
||||
@Parameters({
|
||||
@Parameter(name = "account", description = "账号名", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "realName", description = "姓名", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "列表", description = "传入account和realName")
|
||||
public R<IPage<UserVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> user, Query query) {
|
||||
return R.data(userService.selectPage(user, query));
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义用户列表
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("/page")
|
||||
@BladeView(Views.Admin.class)
|
||||
@Parameters({
|
||||
@Parameter(name = "account", description = "账号名", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "realName", description = "姓名", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
})
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "列表", description = "传入account和realName")
|
||||
public R<IPage<UserVO>> page(@Parameter(hidden = true) User user, Query query, Long deptId, BladeUser bladeUser) {
|
||||
IPage<User> pages = userService.selectUserPage(Condition.getPage(query), user, deptId, (AuthUtil.isAdministrator() ? StringPool.EMPTY : bladeUser.getTenantId()));
|
||||
return R.data(UserWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@IsAdmin
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "新增或修改", description = "传入User")
|
||||
public R submit(@Valid @RequestBody User user) {
|
||||
return R.status(userService.submit(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@IsAdmin
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "修改", description = "传入User")
|
||||
public R update(@Valid @RequestBody User user) {
|
||||
return R.status(userService.updateUser(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@IsAdmin
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "删除", description = "传入id集合")
|
||||
public R remove(@RequestParam String ids) {
|
||||
return R.status(userService.removeUser(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置菜单权限
|
||||
*/
|
||||
@IsAdmin
|
||||
@PostMapping("/grant")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "权限设置", description = "传入roleId集合以及menuId集合")
|
||||
public R grant(@Parameter(description = "userId集合", required = true) @RequestParam String userIds,
|
||||
@Parameter(description = "roleId集合", required = true) @RequestParam String roleIds) {
|
||||
boolean temp = userService.grant(userIds, roleIds);
|
||||
return R.status(temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 密码重制
|
||||
*/
|
||||
@IsAdmin
|
||||
@PostMapping("/reset-password")
|
||||
@ApiOperationSupport(order = 9)
|
||||
@Operation(summary = "初始化密码", description = "传入userId集合")
|
||||
public R resetPassword(@Parameter(description = "userId集合", required = true) @RequestParam String userIds) {
|
||||
boolean temp = userService.resetPassword(userIds);
|
||||
return R.status(temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
@PostMapping("/update-password")
|
||||
@ApiOperationSupport(order = 10)
|
||||
@Operation(summary = "修改密码", description = "传入密码")
|
||||
public R updatePassword(BladeUser user, @Parameter(description = "旧密码", required = true) @RequestParam String oldPassword,
|
||||
@Parameter(description = "新密码", required = true) @RequestParam String newPassword,
|
||||
@Parameter(description = "新密码", required = true) @RequestParam String newPassword1) {
|
||||
boolean temp = userService.updatePassword(user.getUserId(), oldPassword, newPassword, newPassword1);
|
||||
return R.status(temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改基本信息
|
||||
*/
|
||||
@PostMapping("/update-info")
|
||||
@ApiOperationSupport(order = 11)
|
||||
@Operation(summary = "修改基本信息", description = "传入User")
|
||||
public R updateInfo(@Valid @RequestBody User user) {
|
||||
return R.status(userService.updateUserInfo(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*/
|
||||
@GetMapping("/user-list")
|
||||
@BladeView(Views.Admin.class)
|
||||
@ApiOperationSupport(order = 12)
|
||||
@Operation(summary = "用户列表", description = "传入user")
|
||||
public R<List<UserVO>> userList(User user, BladeUser bladeUser) {
|
||||
QueryWrapper<User> queryWrapper = Condition.getQueryWrapper(user);
|
||||
List<User> list = userService.list((!AuthUtil.isAdministrator()) ? queryWrapper.lambda().eq(User::getTenantId, bladeUser.getTenantId()) : queryWrapper);
|
||||
return R.data(UserWrapper.build().listVO(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户分页
|
||||
*/
|
||||
@GetMapping("/user-page")
|
||||
@BladeView(Views.Admin.class)
|
||||
@ApiOperationSupport(order = 13)
|
||||
@Operation(summary = "用户分页(排除管理员)", description = "分页查询非管理员角色用户")
|
||||
public R<IPage<UserVO>> userPage(Query query, @RequestParam(required = false) String account, @RequestParam(required = false) String name) {
|
||||
return R.data(userService.userPage(Condition.getPage(query), account, name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入用户
|
||||
*/
|
||||
@IsAdmin
|
||||
@PostMapping("import-user")
|
||||
@ApiOperationSupport(order = 14)
|
||||
@Operation(summary = "导入用户", description = "传入excel")
|
||||
public R importUser(MultipartFile file, Integer isCovered) {
|
||||
UserImporter userImporter = new UserImporter(userService, isCovered == 1);
|
||||
ExcelUtil.save(file, userImporter, UserExcel.class);
|
||||
return R.success("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出用户
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("export-user")
|
||||
@ApiOperationSupport(order = 15)
|
||||
@Operation(summary = "导出用户", description = "传入user")
|
||||
public void exportUser(@Parameter(hidden = true) @RequestParam Map<String, Object> user, HttpServletResponse response) {
|
||||
List<UserExcel> list = userService.exportUser(user);
|
||||
ExcelUtil.export(response, "用户数据" + DateUtil.time(), "用户数据表", list, UserExcel.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出模板
|
||||
*/
|
||||
@GetMapping("export-template")
|
||||
@ApiOperationSupport(order = 16)
|
||||
@Operation(summary = "导出模板")
|
||||
public void exportUser(HttpServletResponse response) {
|
||||
List<UserExcel> list = new ArrayList<>();
|
||||
ExcelUtil.export(response, "用户数据模板", "用户数据表", list, UserExcel.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 第三方注册用户
|
||||
*/
|
||||
@PostMapping("/register-guest")
|
||||
@ApiOperationSupport(order = 17)
|
||||
@Operation(summary = "第三方注册用户", description = "传入user")
|
||||
public R registerGuest(User user, Long oauthId) {
|
||||
return R.status(userService.registerGuest(user, oauthId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 配置用户平台信息
|
||||
*/
|
||||
@PostMapping("/update-platform")
|
||||
@ApiOperationSupport(order = 18)
|
||||
@Operation(summary = "配置用户平台信息", description = "传入user")
|
||||
public R updatePlatform(Long userId, Integer userType, String userExt) {
|
||||
return R.status(userService.updatePlatform(userId, userType, userExt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看平台详情
|
||||
*/
|
||||
@IsAdmin
|
||||
@BladeView(Views.Admin.class)
|
||||
@ApiOperationSupport(order = 19)
|
||||
@Operation(summary = "查看平台详情", description = "传入id")
|
||||
@GetMapping("/platform-detail")
|
||||
public R<UserVO> platformDetail(User user) {
|
||||
return R.data(userService.platformDetail(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核通过
|
||||
*/
|
||||
@IsAdmin
|
||||
@PostMapping("/audit-pass")
|
||||
@ApiOperationSupport(order = 20)
|
||||
@Operation(summary = "审核通过", description = "传入id集合")
|
||||
public R auditPass(String userIds) {
|
||||
return R.status(userService.auditPass(userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核拒绝
|
||||
*/
|
||||
@IsAdmin
|
||||
@PostMapping("/audit-refuse")
|
||||
@ApiOperationSupport(order = 21)
|
||||
@Operation(summary = "审核拒绝", description = "传入id集合")
|
||||
public R auditRefuse(String userIds) {
|
||||
return R.status(userService.auditRefuse(userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户为主管
|
||||
*/
|
||||
@IsAdmin
|
||||
@PostMapping("/set-leader")
|
||||
@ApiOperationSupport(order = 22)
|
||||
@Operation(summary = "设置用户为主管", description = "传入userId")
|
||||
public R setLeader(@Parameter(description = "userId", required = true) @RequestParam Long userId) {
|
||||
return R.status(userService.setLeader(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户的主管信息
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("/leader-info")
|
||||
@BladeView(Views.Admin.class)
|
||||
@ApiOperationSupport(order = 23)
|
||||
@Operation(summary = "获取用户的主管信息", description = "传入userId")
|
||||
public R<List<UserVO>> leaderInfo(@Parameter(description = "userId", required = true) @RequestParam Long userId) {
|
||||
List<UserVO> list = userService.leaderInfo(userId);
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主管列表
|
||||
*/
|
||||
@IsAdmin
|
||||
@GetMapping("/leader-list")
|
||||
@BladeView(Views.Admin.class)
|
||||
@ApiOperationSupport(order = 24)
|
||||
@Operation(summary = "获取主管列表", description = "获取所有主管用户列表")
|
||||
public R<List<UserVO>> leaderList(@Parameter(description = "租户编号") String tenantId, @Parameter(description = "用户姓名") String realName) {
|
||||
List<UserVO> list = userService.leaderList(tenantId, realName);
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.excel;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
||||
import cn.idev.excel.annotation.write.style.ContentRowHeight;
|
||||
import cn.idev.excel.annotation.write.style.HeadRowHeight;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* RegionExcel
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@ColumnWidth(16)
|
||||
@HeadRowHeight(20)
|
||||
@ContentRowHeight(18)
|
||||
public class RegionExcel implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ExcelProperty("区划编号")
|
||||
private String code;
|
||||
|
||||
@ExcelProperty("父区划编号")
|
||||
private String parentCode;
|
||||
|
||||
@ExcelProperty("祖区划编号")
|
||||
private String ancestors;
|
||||
|
||||
@ExcelProperty("区划名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("省级区划编号")
|
||||
private String provinceCode;
|
||||
|
||||
@ExcelProperty("省级名称")
|
||||
private String provinceName;
|
||||
|
||||
@ExcelProperty("市级区划编号")
|
||||
private String cityCode;
|
||||
|
||||
@ExcelProperty("市级名称")
|
||||
private String cityName;
|
||||
|
||||
@ExcelProperty("区级区划编号")
|
||||
private String districtCode;
|
||||
|
||||
@ExcelProperty("区级名称")
|
||||
private String districtName;
|
||||
|
||||
@ExcelProperty("镇级区划编号")
|
||||
private String townCode;
|
||||
|
||||
@ExcelProperty("镇级名称")
|
||||
private String townName;
|
||||
|
||||
@ExcelProperty("村级区划编号")
|
||||
private String villageCode;
|
||||
|
||||
@ExcelProperty("村级名称")
|
||||
private String villageName;
|
||||
|
||||
@ExcelProperty("层级")
|
||||
private Integer regionLevel;
|
||||
|
||||
@ExcelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.excel;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springblade.core.excel.support.ExcelImporter;
|
||||
import org.springblade.system.service.IRegionService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 行政区划数据导入类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class RegionImporter implements ExcelImporter<RegionExcel> {
|
||||
|
||||
private final IRegionService service;
|
||||
private final Boolean isCovered;
|
||||
|
||||
@Override
|
||||
public void save(List<RegionExcel> data) {
|
||||
service.importRegion(data, isCovered);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.excel;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelIgnore;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
||||
import cn.idev.excel.annotation.write.style.ContentRowHeight;
|
||||
import cn.idev.excel.annotation.write.style.HeadRowHeight;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* UserExcel
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@ColumnWidth(25)
|
||||
@HeadRowHeight(20)
|
||||
@ContentRowHeight(18)
|
||||
public class UserExcel implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ColumnWidth(15)
|
||||
@ExcelProperty("租户编号")
|
||||
private String tenantId;
|
||||
|
||||
@ExcelIgnore
|
||||
@ExcelProperty("用户平台")
|
||||
private String userType;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty("用户平台名称")
|
||||
private String userTypeName;
|
||||
|
||||
@ColumnWidth(15)
|
||||
@ExcelProperty("账户")
|
||||
private String account;
|
||||
|
||||
@ColumnWidth(10)
|
||||
@ExcelProperty("昵称")
|
||||
private String name;
|
||||
|
||||
@ColumnWidth(10)
|
||||
@ExcelProperty("姓名")
|
||||
private String realName;
|
||||
|
||||
@ExcelProperty("邮箱")
|
||||
private String email;
|
||||
|
||||
@ColumnWidth(15)
|
||||
@ExcelProperty("手机")
|
||||
private String phone;
|
||||
|
||||
@ExcelIgnore
|
||||
@ExcelProperty("角色ID")
|
||||
private String roleId;
|
||||
|
||||
@ExcelIgnore
|
||||
@ExcelProperty("部门ID")
|
||||
private String deptId;
|
||||
|
||||
@ExcelIgnore
|
||||
@ExcelProperty("岗位ID")
|
||||
private String postId;
|
||||
|
||||
@ExcelProperty("角色名称")
|
||||
private String roleName;
|
||||
|
||||
@ExcelProperty("部门名称")
|
||||
private String deptName;
|
||||
|
||||
@ExcelProperty("岗位名称")
|
||||
private String postName;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty("生日")
|
||||
private Date birthday;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.excel;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springblade.core.excel.support.ExcelImporter;
|
||||
import org.springblade.system.service.IUserService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户数据导入类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class UserImporter implements ExcelImporter<UserExcel> {
|
||||
|
||||
private final IUserService service;
|
||||
private final Boolean isCovered;
|
||||
|
||||
@Override
|
||||
public void save(List<UserExcel> data) {
|
||||
service.importUser(data, isCovered);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springblade.core.secure.BladeUser;
|
||||
import org.springblade.core.secure.provider.ApiKeyInfo;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.constant.RoleConstant;
|
||||
import org.springblade.core.tool.jackson.JsonUtil;
|
||||
import org.springblade.core.tool.support.Kv;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.system.pojo.dto.ApiKeyLogDTO;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.springblade.core.secure.constant.ApiKeyConstant.*;
|
||||
|
||||
/**
|
||||
* API Key Feign实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class ApiKeyClient implements IApiKeyClient {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Override
|
||||
@GetMapping(GET_USER)
|
||||
public BladeUser getUser(String apiKey) {
|
||||
// 第一步:查询 API Key 基本信息
|
||||
ApiKeyInfo apiKeyInfo = queryApiKeyInfo(apiKey);
|
||||
if (apiKeyInfo == null) {
|
||||
return null;
|
||||
}
|
||||
// 检查状态
|
||||
if (apiKeyInfo.getStatus() == null || apiKeyInfo.getStatus() != STATUS_ACTIVE) {
|
||||
return null;
|
||||
}
|
||||
// 检查过期时间
|
||||
Date expireTime = apiKeyInfo.getExpireTime();
|
||||
if (expireTime != null && expireTime.before(new Date())) {
|
||||
return null;
|
||||
}
|
||||
// 检查用户ID
|
||||
if (apiKeyInfo.getUserId() == null) {
|
||||
return null;
|
||||
}
|
||||
// 第二步:查询关联用户信息
|
||||
populateUserInfo(apiKeyInfo);
|
||||
if (Func.isBlank(apiKeyInfo.getAccount())) {
|
||||
return null;
|
||||
}
|
||||
// 第三步:解析角色名称(含超管安全判定)
|
||||
String roleName = resolveRoleName(apiKeyInfo.getRoleId());
|
||||
// 构建 BladeUser
|
||||
BladeUser bladeUser = new BladeUser();
|
||||
bladeUser.setUserId(apiKeyInfo.getUserId());
|
||||
bladeUser.setTenantId(apiKeyInfo.getTenantId());
|
||||
bladeUser.setAccount(apiKeyInfo.getAccount());
|
||||
bladeUser.setUserName(apiKeyInfo.getName());
|
||||
bladeUser.setNickName(apiKeyInfo.getRealName());
|
||||
bladeUser.setClientId(apiKey);
|
||||
bladeUser.setDeptId(Func.toStrWithEmpty(apiKeyInfo.getDeptId(), StringPool.MINUS_ONE));
|
||||
bladeUser.setPostId(Func.toStrWithEmpty(apiKeyInfo.getPostId(), StringPool.MINUS_ONE));
|
||||
bladeUser.setRoleId(Func.toStrWithEmpty(apiKeyInfo.getRoleId(), StringPool.MINUS_ONE));
|
||||
bladeUser.setRoleName(roleName);
|
||||
// 解析扩展参数
|
||||
String extParams = apiKeyInfo.getExtParams();
|
||||
Kv detail = Func.isNotBlank(extParams) ? JsonUtil.parse(extParams, Kv.class) : null;
|
||||
if (detail == null) {
|
||||
detail = Kv.create();
|
||||
}
|
||||
detail.set(DETAIL_API_KEY_ID, apiKeyInfo.getId());
|
||||
bladeUser.setDetail(detail);
|
||||
return bladeUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(GET_API_PATH)
|
||||
public String getApiPath(String apiKey) {
|
||||
ApiKeyInfo apiKeyInfo = queryApiKeyInfo(apiKey);
|
||||
return (apiKeyInfo != null) ? apiKeyInfo.getApiPath() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(SAVE_LOG)
|
||||
public int saveLog(@RequestBody ApiKeyLogDTO apiKeyLog) {
|
||||
return jdbcTemplate.update(API_KEY_LOG_INSERT,
|
||||
apiKeyLog.getId(), apiKeyLog.getTenantId(),
|
||||
apiKeyLog.getServiceId(), apiKeyLog.getServerIp(), apiKeyLog.getServerHost(), apiKeyLog.getEnv(),
|
||||
apiKeyLog.getApiKeyId(), apiKeyLog.getRequestUri(), apiKeyLog.getMethod(), apiKeyLog.getRemoteIp(),
|
||||
apiKeyLog.getUserAgent(), apiKeyLog.getParams(), Func.toStr(apiKeyLog.getTime()),
|
||||
apiKeyLog.getCreateBy(), apiKeyLog.getCreateTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 第一步:查询 API Key 基本信息
|
||||
*
|
||||
* @param apiKey API Key
|
||||
* @return ApiKeyInfo(仅含 Key 表字段)
|
||||
*/
|
||||
private ApiKeyInfo queryApiKeyInfo(String apiKey) {
|
||||
List<ApiKeyInfo> results = jdbcTemplate.query(API_KEY_SELECT_STATEMENT, new BeanPropertyRowMapper<>(ApiKeyInfo.class), apiKey);
|
||||
if (results.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return results.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 第二步:查询关联用户信息并填充至 ApiKeyInfo
|
||||
*
|
||||
* @param apiKeyInfo API Key 信息(需含 userId)
|
||||
*/
|
||||
private void populateUserInfo(ApiKeyInfo apiKeyInfo) {
|
||||
List<ApiKeyInfo> results = jdbcTemplate.query(
|
||||
API_KEY_USER_SELECT_STATEMENT, new BeanPropertyRowMapper<>(ApiKeyInfo.class), apiKeyInfo.getUserId()
|
||||
);
|
||||
if (results.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ApiKeyInfo userInfo = results.get(0);
|
||||
apiKeyInfo.setAccount(userInfo.getAccount());
|
||||
apiKeyInfo.setName(userInfo.getName());
|
||||
apiKeyInfo.setRealName(userInfo.getRealName());
|
||||
apiKeyInfo.setDeptId(userInfo.getDeptId());
|
||||
apiKeyInfo.setPostId(userInfo.getPostId());
|
||||
apiKeyInfo.setRoleId(userInfo.getRoleId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三步:解析角色别名,若用户为管理员则返回空字符串
|
||||
*
|
||||
* @param roleId 角色ID(逗号分隔)
|
||||
* @return 角色别名(逗号分隔),管理员返回空字符串
|
||||
*/
|
||||
private String resolveRoleName(String roleId) {
|
||||
if (Func.isBlank(roleId) || StringPool.MINUS_ONE.equals(roleId)) {
|
||||
return StringPool.EMPTY;
|
||||
}
|
||||
Long[] roleIds = Func.toLongArray(roleId);
|
||||
if (roleIds.length == 0) {
|
||||
return StringPool.EMPTY;
|
||||
}
|
||||
// 构建参数化 IN 子句
|
||||
String placeholders = String.join(StringPool.COMMA, Collections.nCopies(roleIds.length, "?"));
|
||||
String sql = String.format(API_KEY_ROLE_SELECT_STATEMENT, placeholders);
|
||||
List<Map<String, Object>> roles = jdbcTemplate.queryForList(sql, (Object[]) roleIds);
|
||||
if (roles.isEmpty()) {
|
||||
return StringPool.EMPTY;
|
||||
}
|
||||
// 为了系统安全性考虑,管理员角色不返回角色信息,保持低权限角色调用系统给第三方的接口
|
||||
boolean isAdmin = roles.stream()
|
||||
.anyMatch(role -> {
|
||||
String roleAlias = Func.toStr(role.get(ROLE_ALIAS_COLUMN));
|
||||
return RoleConstant.ADMINISTRATOR.equals(roleAlias) || RoleConstant.ADMIN.equals(roleAlias);
|
||||
});
|
||||
if (isAdmin) {
|
||||
return StringPool.EMPTY;
|
||||
}
|
||||
// 拼接角色名称
|
||||
return roles.stream()
|
||||
.map(role -> Func.toStr(role.get(ROLE_ALIAS_COLUMN)))
|
||||
.filter(Func::isNotBlank)
|
||||
.collect(Collectors.joining(StringPool.COMMA));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.secure.provider.PermissionMenu;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
||||
import static org.springblade.core.secure.constant.PermissionConstant.*;
|
||||
|
||||
/**
|
||||
* 接口权限Feign实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class ApiScopeClient implements IApiScopeClient {
|
||||
|
||||
private static final String SCOPE_CACHE_ALL_MENU = "apiScope:allMenu:permission";
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Override
|
||||
@GetMapping(PERMISSION_PATH)
|
||||
public List<String> permissionPath(String roleId) {
|
||||
List<Long> roleIds = Func.toLongList(roleId);
|
||||
return jdbcTemplate.queryForList(permissionAllStatement(roleIds.size()), String.class, roleIds.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(PERMISSION_CODE)
|
||||
public List<String> permissionCode(String permission, String roleId) {
|
||||
List<Object> args = new ArrayList<>(Collections.singletonList(permission));
|
||||
List<Long> roleIds = Func.toLongList(roleId);
|
||||
args.addAll(roleIds);
|
||||
return jdbcTemplate.queryForList(permissionCodeStatement(roleIds.size()), String.class, args.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(PERMISSION_MENU)
|
||||
public List<String> permissionMenu(String permission, String roleId) {
|
||||
// 获取所有菜单
|
||||
List<PermissionMenu> allMenus = permissionAllMenu();
|
||||
// 获取角色菜单
|
||||
List<Long> roleIds = Func.toLongList(roleId);
|
||||
List<PermissionMenu> roleIdMenus = jdbcTemplate.query(permissionMenuStatement(roleIds.size()), new BeanPropertyRowMapper<>(PermissionMenu.class), roleIds.toArray());
|
||||
// 反向递归角色菜单所有父级
|
||||
List<PermissionMenu> routes = new LinkedList<>(roleIdMenus);
|
||||
roleIdMenus.forEach(roleMenu -> recursion(allMenus, routes, roleMenu));
|
||||
// 支持逗号分隔的多个权限匹配
|
||||
Set<String> permissionSet = Arrays.stream(permission.split(StringPool.COMMA))
|
||||
.map(String::trim)
|
||||
.collect(Collectors.toSet());
|
||||
// 获取匹配的菜单权限值
|
||||
return routes.stream()
|
||||
.map(PermissionMenu::getCode)
|
||||
.filter(permissionSet::contains)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有菜单权限信息
|
||||
*/
|
||||
private List<PermissionMenu> permissionAllMenu() {
|
||||
List<PermissionMenu> permissions = CacheUtil.get(SYS_CACHE, SCOPE_CACHE_ALL_MENU, StringPool.EMPTY, List.class, Boolean.FALSE);
|
||||
if (permissions == null) {
|
||||
permissions = jdbcTemplate.query(permissionAllMenuStatement(), new BeanPropertyRowMapper<>(PermissionMenu.class));
|
||||
CacheUtil.put(SYS_CACHE, SCOPE_CACHE_ALL_MENU, StringPool.EMPTY, permissions, Boolean.FALSE);
|
||||
}
|
||||
return permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归获取菜单父级
|
||||
*
|
||||
* @param allMenus 所有菜单合集
|
||||
* @param routes 角色分配的菜单合集
|
||||
* @param roleMenu 当前菜单
|
||||
*/
|
||||
private void recursion(List<PermissionMenu> allMenus, List<PermissionMenu> routes, PermissionMenu roleMenu) {
|
||||
Optional<PermissionMenu> menu = allMenus.stream().filter(x -> Func.equals(x.getId(), roleMenu.getParentId())).findFirst();
|
||||
if (menu.isPresent() && !routes.contains(menu.get())) {
|
||||
routes.add(menu.get());
|
||||
recursion(allMenus, routes, menu.get());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.service.IAuthLockService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
|
||||
/**
|
||||
* 认证锁定 Feign实现类
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class AuthLockClient implements IAuthLockClient {
|
||||
|
||||
private final IAuthLockService authLockService;
|
||||
|
||||
@Override
|
||||
@GetMapping(IS_ACCOUNT_LOCKED)
|
||||
public R<Boolean> isAccountLocked(String tenantId, String account) {
|
||||
return R.data(authLockService.isAccountLocked(tenantId, account));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(IS_IP_LOCKED)
|
||||
public R<Boolean> isIpLocked(String tenantId, String ip) {
|
||||
return R.data(authLockService.isIpLocked(tenantId, ip));
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(ADD_ACCOUNT_FAIL_COUNT)
|
||||
public R<Void> addAccountFailCount(String tenantId, String account, Long userId, String ip, String userAgent) {
|
||||
authLockService.addAccountFailCount(tenantId, account, userId, ip, userAgent);
|
||||
return R.success("success");
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(ADD_IP_FAIL_COUNT)
|
||||
public R<Void> addIpFailCount(String tenantId, String ip, String userAgent) {
|
||||
authLockService.addIpFailCount(tenantId, ip, userAgent);
|
||||
return R.success("success");
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(RELEASE_SYSTEM_LOCK)
|
||||
public R<Void> releaseSystemLock(String tenantId, String account) {
|
||||
authLockService.releaseSystemLock(tenantId, account);
|
||||
return R.success("success");
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(RELEASE_SYSTEM_IP_LOCK)
|
||||
public R<Void> releaseSystemIpLock(String tenantId, String ip) {
|
||||
authLockService.releaseSystemIpLock(tenantId, ip);
|
||||
return R.success("success");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.AuthLog;
|
||||
import org.springblade.system.service.IAuthLogService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
|
||||
/**
|
||||
* 认证日志 Feign实现类
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class AuthLogClient implements IAuthLogClient {
|
||||
|
||||
private final IAuthLogService authLogService;
|
||||
|
||||
@Override
|
||||
@PostMapping(SAVE_AUTH_LOG)
|
||||
public R<Void> saveAuthLog(@RequestBody AuthLog authLog) {
|
||||
authLogService.save(authLog);
|
||||
return R.success("success");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springblade.core.datarecord.model.DataRecordInfo;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
import org.springblade.core.tool.jackson.JsonUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static org.springblade.core.datarecord.constant.DataRecordConstant.RECORD_INSERT_SQL;
|
||||
|
||||
/**
|
||||
* 数据审计Feign实现类
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class DataRecordClient implements IDataRecordClient {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Override
|
||||
@PostMapping(SAVE_RECORD_DATA)
|
||||
public int saveRecordData(@RequestBody DataRecordInfo recordInfo, String recordLevel, String recordMessage) {
|
||||
return jdbcTemplate.update(RECORD_INSERT_SQL,
|
||||
// 主键
|
||||
recordInfo.getRecordId(),
|
||||
// 基础服务信息
|
||||
recordInfo.getServiceId(),
|
||||
recordInfo.getServerHost(),
|
||||
recordInfo.getServerIp(),
|
||||
recordInfo.getEnv(),
|
||||
// 审计级别
|
||||
recordLevel,
|
||||
// 请求信息
|
||||
recordInfo.getMethod(),
|
||||
recordInfo.getRequestUri(),
|
||||
recordInfo.getUserAgent(),
|
||||
recordInfo.getRemoteIp(),
|
||||
// 操作信息
|
||||
recordInfo.getOperation(),
|
||||
recordInfo.getTableName(),
|
||||
// 数据转换:将 Map 转换为 JSON 字符串
|
||||
JsonUtil.toJson(recordInfo.getOldData()),
|
||||
JsonUtil.toJson(recordInfo.getNewData()),
|
||||
// 审计消息
|
||||
recordMessage,
|
||||
// 审计结果
|
||||
recordInfo.getRecordResult(),
|
||||
// 记录耗时
|
||||
Func.toStr(recordInfo.getCost()),
|
||||
// 记录时间
|
||||
recordInfo.getRecordTime(),
|
||||
// 记录人
|
||||
Func.toLong(recordInfo.getUserId()),
|
||||
// 业务状态:默认为正常状态
|
||||
BladeConstant.DB_STATUS_NORMAL,
|
||||
// 逻辑删除状态:默认为未删除状态
|
||||
BladeConstant.DB_NOT_DELETED
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springblade.core.datascope.constant.DataScopeConstant;
|
||||
import org.springblade.core.datascope.model.DataScopeModel;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.utils.CollectionUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据权限Feign实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class DataScopeClient implements IDataScopeClient {
|
||||
|
||||
private static final DataScopeModel SEARCHED_DATA_SCOPE_MODEL = new DataScopeModel(Boolean.TRUE);
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
/**
|
||||
* 获取数据权限
|
||||
*
|
||||
* @param mapperId 数据权限mapperId
|
||||
* @param roleId 用户角色集合
|
||||
* @return DataScopeModel
|
||||
*/
|
||||
@Override
|
||||
@GetMapping(GET_DATA_SCOPE_BY_MAPPER)
|
||||
public DataScopeModel getDataScopeByMapper(String mapperId, String roleId) {
|
||||
List<Object> args = new ArrayList<>(Collections.singletonList(mapperId));
|
||||
List<Long> roleIds = Func.toLongList(roleId);
|
||||
args.addAll(roleIds);
|
||||
// 增加searched字段防止未配置的参数重复读库导致缓存击穿
|
||||
// 后续若有新增配置则会清空缓存重新加载
|
||||
DataScopeModel dataScope;
|
||||
List<DataScopeModel> list = jdbcTemplate.query(DataScopeConstant.dataByMapper(roleIds.size()), args.toArray(), new BeanPropertyRowMapper<>(DataScopeModel.class));
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
dataScope = list.iterator().next();
|
||||
dataScope.setSearched(Boolean.TRUE);
|
||||
} else {
|
||||
dataScope = SEARCHED_DATA_SCOPE_MODEL;
|
||||
}
|
||||
return dataScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据权限
|
||||
*
|
||||
* @param code 数据权限资源编号
|
||||
* @return DataScopeModel
|
||||
*/
|
||||
@Override
|
||||
@GetMapping(GET_DATA_SCOPE_BY_CODE)
|
||||
public DataScopeModel getDataScopeByCode(String code) {
|
||||
// 增加searched字段防止未配置的参数重复读库导致缓存击穿
|
||||
// 后续若有新增配置则会清空缓存重新加载
|
||||
DataScopeModel dataScope;
|
||||
List<DataScopeModel> list = jdbcTemplate.query(DataScopeConstant.DATA_BY_CODE, new Object[]{code}, new BeanPropertyRowMapper<>(DataScopeModel.class));
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
dataScope = list.iterator().next();
|
||||
dataScope.setSearched(Boolean.TRUE);
|
||||
} else {
|
||||
dataScope = SEARCHED_DATA_SCOPE_MODEL;
|
||||
}
|
||||
return dataScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门子级
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return deptIds
|
||||
*/
|
||||
@Override
|
||||
@GetMapping(GET_DEPT_ANCESTORS)
|
||||
public List<Long> getDeptAncestors(Long deptId) {
|
||||
return jdbcTemplate.queryForList(DataScopeConstant.DATA_BY_DEPT, new Object[]{deptId}, Long.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.DictBiz;
|
||||
import org.springblade.system.service.IDictBizService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 字典服务Feign实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class DictBizClient implements IDictBizClient {
|
||||
|
||||
private final IDictBizService service;
|
||||
|
||||
@Override
|
||||
@GetMapping(GET_BY_ID)
|
||||
public R<DictBiz> getById(Long id) {
|
||||
return R.data(service.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(GET_VALUE)
|
||||
public R<String> getValue(String code, String dictKey) {
|
||||
return R.data(service.getValue(code, dictKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(GET_LIST)
|
||||
public R<List<DictBiz>> getList(String code) {
|
||||
return R.data(service.getList(code));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.Dict;
|
||||
import org.springblade.system.service.IDictService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 字典服务Feign实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class DictClient implements IDictClient {
|
||||
|
||||
private final IDictService service;
|
||||
|
||||
@Override
|
||||
@GetMapping(GET_BY_ID)
|
||||
public R<Dict> getById(Long id) {
|
||||
return R.data(service.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(GET_VALUE)
|
||||
public R<String> getValue(String code, String dictKey) {
|
||||
return R.data(service.getValue(code, dictKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(GET_LIST)
|
||||
public R<List<Dict>> getList(String code) {
|
||||
return R.data(service.getList(code));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springblade.core.ratelimit.RateLimitRule;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.system.pojo.dto.RateLimitLogDTO;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.springblade.core.ratelimit.RateLimitConstant.RATE_LIMIT_LOG_INSERT;
|
||||
import static org.springblade.core.ratelimit.RateLimitConstant.RULE_SELECT_STATEMENT;
|
||||
|
||||
/**
|
||||
* 限流规则 Feign实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class RateLimitClient implements IRateLimitClient {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Override
|
||||
@GetMapping(LIST)
|
||||
public List<RateLimitRule> listEnabledRules() {
|
||||
return jdbcTemplate.query(RULE_SELECT_STATEMENT, new BeanPropertyRowMapper<>(RateLimitRule.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(SAVE_LOG)
|
||||
public int saveLog(@RequestBody RateLimitLogDTO rateLimitLog) {
|
||||
return jdbcTemplate.update(RATE_LIMIT_LOG_INSERT,
|
||||
rateLimitLog.getId(), rateLimitLog.getTenantId(),
|
||||
rateLimitLog.getServiceId(), rateLimitLog.getServerIp(), rateLimitLog.getServerHost(), rateLimitLog.getEnv(),
|
||||
rateLimitLog.getLimitId(), rateLimitLog.getLimitName(), rateLimitLog.getLimitDimension(),
|
||||
rateLimitLog.getLimitCount(), rateLimitLog.getLimitPeriod(), rateLimitLog.getTimeUnit(), rateLimitLog.getLimitKey(),
|
||||
rateLimitLog.getRequestUri(), rateLimitLog.getMethod(), rateLimitLog.getRemoteIp(), rateLimitLog.getUserAgent(), rateLimitLog.getParams(),
|
||||
rateLimitLog.getCreateBy(), rateLimitLog.getCreateTime());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.*;
|
||||
import org.springblade.system.service.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统服务Feign实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class SysClient implements ISysClient {
|
||||
|
||||
private final IDeptService deptService;
|
||||
|
||||
private final IPostService postService;
|
||||
|
||||
private final IRoleService roleService;
|
||||
|
||||
private final IMenuService menuService;
|
||||
|
||||
private final ITenantService tenantService;
|
||||
|
||||
private final ITenantPackageService tenantPackageService;
|
||||
|
||||
private final IParamService paramService;
|
||||
|
||||
private final IRegionService regionService;
|
||||
|
||||
@Override
|
||||
@GetMapping(MENU)
|
||||
public R<Menu> getMenu(Long id) {
|
||||
return R.data(menuService.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(DEPT)
|
||||
public R<Dept> getDept(Long id) {
|
||||
return R.data(deptService.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<String> getDeptIds(String tenantId, String deptNames) {
|
||||
return R.data(deptService.getDeptIds(tenantId, deptNames));
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<String> getDeptIdsByFuzzy(String tenantId, String deptNames) {
|
||||
return R.data(deptService.getDeptIdsByFuzzy(tenantId, deptNames));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(DEPT_NAME)
|
||||
public R<String> getDeptName(Long id) {
|
||||
return R.data(deptService.getById(id).getDeptName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(DEPT_NAMES)
|
||||
public R<List<String>> getDeptNames(String deptIds) {
|
||||
return R.data(deptService.getDeptNames(deptIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(DEPT_CHILD)
|
||||
public R<List<Dept>> getDeptChild(Long deptId) {
|
||||
return R.data(deptService.getDeptChild(deptId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Post> getPost(Long id) {
|
||||
return R.data(postService.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<String> getPostIds(String tenantId, String postNames) {
|
||||
return R.data(postService.getPostIds(tenantId, postNames));
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<String> getPostIdsByFuzzy(String tenantId, String postNames) {
|
||||
return R.data(postService.getPostIdsByFuzzy(tenantId, postNames));
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<String> getPostName(Long id) {
|
||||
return R.data(postService.getById(id).getPostName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<String>> getPostNames(String postIds) {
|
||||
return R.data(postService.getPostNames(postIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(ROLE)
|
||||
public R<Role> getRole(Long id) {
|
||||
return R.data(roleService.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<String> getRoleIds(String tenantId, String roleNames) {
|
||||
return R.data(roleService.getRoleIds(tenantId, roleNames));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(ROLE_NAME)
|
||||
public R<String> getRoleName(Long id) {
|
||||
return R.data(roleService.getById(id).getRoleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(ROLE_ALIAS)
|
||||
public R<String> getRoleAlias(Long id) {
|
||||
return R.data(roleService.getById(id).getRoleAlias());
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(ROLE_NAMES)
|
||||
public R<List<String>> getRoleNames(String roleIds) {
|
||||
return R.data(roleService.getRoleNames(roleIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(ROLE_ALIASES)
|
||||
public R<List<String>> getRoleAliases(String roleIds) {
|
||||
return R.data(roleService.getRoleAliases(roleIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(TENANT)
|
||||
public R<Tenant> getTenant(Long id) {
|
||||
return R.data(tenantService.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(TENANT_ID)
|
||||
public R<Tenant> getTenant(String tenantId) {
|
||||
return R.data(tenantService.getByTenantId(tenantId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(TENANT_PACKAGE)
|
||||
public R<TenantPackage> getTenantPackage(String tenantId) {
|
||||
Tenant tenant = tenantService.getByTenantId(tenantId);
|
||||
return R.data(tenantPackageService.getById(tenant.getPackageId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(PARAM)
|
||||
public R<Param> getParam(Long id) {
|
||||
return R.data(paramService.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(PARAM_VALUE)
|
||||
public R<String> getParamValue(String paramKey) {
|
||||
return R.data(paramService.getValue(paramKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(REGION)
|
||||
public R<Region> getRegion(String code) {
|
||||
return R.data(regionService.getById(code));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.User;
|
||||
import org.springblade.system.pojo.entity.UserInfo;
|
||||
import org.springblade.system.pojo.entity.UserOauth;
|
||||
import org.springblade.system.pojo.enums.UserType;
|
||||
import org.springblade.system.service.IUserService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
|
||||
/**
|
||||
* 用户服务Feign实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class UserClient implements IUserClient {
|
||||
|
||||
private final IUserService service;
|
||||
|
||||
@Override
|
||||
@GetMapping(USER_BY_ID)
|
||||
public R<User> userInfoById(Long userId) {
|
||||
return R.data(service.getById(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(USER_BY_ACCOUNT)
|
||||
public R<User> userByAccount(String tenantId, String account) {
|
||||
return R.data(service.userByAccount(tenantId, account));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(USER_INFO_BY_ID)
|
||||
public R<UserInfo> userInfo(Long userId) {
|
||||
return R.data(service.userInfo(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(USER_INFO_BY_ID_TYPE)
|
||||
public R<UserInfo> userInfo(Long userId, String userType) {
|
||||
return R.data(service.userInfo(userId, UserType.of(userType)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(USER_INFO_BY_TENANT_ID_ACCOUNT)
|
||||
public R<UserInfo> userInfo(String tenantId, String account) {
|
||||
return R.data(service.userInfo(tenantId, account));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(USER_INFO_BY_TENANT_ID_ACCOUNT_TYPE)
|
||||
public R<UserInfo> userInfo(String tenantId, String account, String userType) {
|
||||
return R.data(service.userInfo(tenantId, account, UserType.of(userType)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(USER_INFO_BY_TENANT_ID_PHONE_TYPE)
|
||||
public R<UserInfo> userInfoByPhone(String tenantId, String phone, String userType) {
|
||||
return R.data(service.userInfoByPhone(tenantId, phone, UserType.of(userType)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(USER_AUTH_INFO)
|
||||
public R<UserInfo> userAuthInfo(@RequestBody UserOauth userOauth) {
|
||||
return R.data(service.userInfo(userOauth));
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(SAVE_USER)
|
||||
public R<Boolean> saveUser(@RequestBody User user) {
|
||||
return R.data(service.submit(user));
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(REGISTER_USER)
|
||||
public R<String> registerUser(User user) {
|
||||
boolean temp = service.registerUser(user);
|
||||
return temp ? R.data(String.valueOf(user.getId())) : R.fail("注册失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(REMOVE_USER)
|
||||
public R<Boolean> removeUser(String tenantIds) {
|
||||
return R.data(service.remove(Wrappers.<User>query().lambda().in(User::getTenantId, Func.toStrList(tenantIds))));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.pojo.entity.User;
|
||||
import org.springblade.system.service.IUserSearchService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户查询服务Feign实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class UserSearchClient implements IUserSearchClient {
|
||||
|
||||
private final IUserSearchService service;
|
||||
|
||||
@Override
|
||||
@GetMapping(LIST_BY_USER)
|
||||
public R<List<User>> listByUser(String userId) {
|
||||
return R.data(service.listByUser(Func.toLongList(userId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(LIST_BY_DEPT)
|
||||
public R<List<User>> listByDept(String deptId) {
|
||||
return R.data(service.listByDept(Func.toLongList(deptId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(LIST_BY_POST)
|
||||
public R<List<User>> listByPost(String postId) {
|
||||
return R.data(service.listByPost(Func.toLongList(postId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(LIST_BY_ROLE)
|
||||
public R<List<User>> listByRole(String roleId) {
|
||||
return R.data(service.listByRole(Func.toLongList(roleId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(LIST_LEADER)
|
||||
public R<List<User>> listLeader(String tenantId, String realName) {
|
||||
return R.data(service.listLeader(tenantId, realName));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping(GET_LEADER)
|
||||
public R<List<User>> getLeader(String userId) {
|
||||
return R.data(service.getLeader(Func.toLongList(userId)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.system.pojo.entity.ApiKeyLog;
|
||||
|
||||
/**
|
||||
* 令牌调用日志 Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface ApiKeyLogMapper extends BaseMapper<ApiKeyLog> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.ApiKeyLogMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="logResultMap" type="org.springblade.system.pojo.entity.ApiKeyLog">
|
||||
<result column="id" property="id"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="service_id" property="serviceId"/>
|
||||
<result column="server_ip" property="serverIp"/>
|
||||
<result column="server_host" property="serverHost"/>
|
||||
<result column="env" property="env"/>
|
||||
<result column="api_key_id" property="apiKeyId"/>
|
||||
<result column="request_uri" property="requestUri"/>
|
||||
<result column="method" property="method"/>
|
||||
<result column="remote_ip" property="remoteIp"/>
|
||||
<result column="user_agent" property="userAgent"/>
|
||||
<result column="params" property="params"/>
|
||||
<result column="time" property="time"/>
|
||||
<result column="create_by" property="createBy"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.system.pojo.entity.ApiKey;
|
||||
import org.springblade.system.pojo.vo.ApiKeyVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 令牌权限 Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface ApiKeyMapper extends BaseMapper<ApiKey> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页
|
||||
* @param apiKey 实体
|
||||
* @return List<ApiKeyVO>
|
||||
*/
|
||||
List<ApiKeyVO> selectApiKeyPage(IPage<ApiKeyVO> page, ApiKeyVO apiKey);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.ApiKeyMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="apiKeyResultMap" type="org.springblade.system.pojo.entity.ApiKey">
|
||||
<id column="api_key" property="apiKey"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="expire_time" property="expireTime"/>
|
||||
<result column="ext_params" property="extParams"/>
|
||||
<result column="api_path" property="apiPath"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- VO查询映射结果 -->
|
||||
<resultMap id="apiKeyVOResultMap" type="org.springblade.system.pojo.vo.ApiKeyVO">
|
||||
<id column="api_key" property="apiKey"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="expire_time" property="expireTime"/>
|
||||
<result column="ext_params" property="extParams"/>
|
||||
<result column="api_path" property="apiPath"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="user_name" property="userName"/>
|
||||
<result column="account" property="account"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectApiKeyPage" resultMap="apiKeyVOResultMap">
|
||||
SELECT
|
||||
k.*,
|
||||
u.name AS user_name,
|
||||
u.account AS account
|
||||
FROM
|
||||
blade_api_key k
|
||||
LEFT JOIN blade_user u ON k.user_id = u.id
|
||||
WHERE
|
||||
k.is_deleted = 0 AND k.tenant_id = #{apiKey.tenantId}
|
||||
<if test="apiKey.name != null and apiKey.name != ''">
|
||||
AND k.name LIKE CONCAT('%', #{apiKey.name}, '%')
|
||||
</if>
|
||||
<if test="apiKey.userId != null">
|
||||
AND k.user_id = #{apiKey.userId}
|
||||
</if>
|
||||
<if test="apiKey.status != null">
|
||||
AND k.status = #{apiKey.status}
|
||||
</if>
|
||||
ORDER BY k.create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.system.pojo.entity.ApiScope;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public interface ApiScopeMapper extends BaseMapper<ApiScope> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.ApiScopeMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.system.pojo.entity.AuthClient;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface AuthClientMapper extends BaseMapper<AuthClient> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.AuthClientMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="clientResultMap" type="org.springblade.system.pojo.entity.AuthClient">
|
||||
<result column="id" property="id"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="client_id" property="clientId"/>
|
||||
<result column="client_secret" property="clientSecret"/>
|
||||
<result column="resources_ids" property="resourceIds"/>
|
||||
<result column="scope" property="scope"/>
|
||||
<result column="authorized_grant_types" property="authorizedGrantTypes"/>
|
||||
<result column="web_server_redirect_uri" property="webServerRedirectUri"/>
|
||||
<result column="authorities" property="authorities"/>
|
||||
<result column="access_token_validity" property="accessTokenValidity"/>
|
||||
<result column="refresh_token_validity" property="refreshTokenValidity"/>
|
||||
<result column="additional_information" property="additionalInformation"/>
|
||||
<result column="autoapprove" property="autoapprove"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.system.pojo.entity.AuthLock;
|
||||
|
||||
/**
|
||||
* 认证锁定记录 Mapper 接口
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public interface AuthLockMapper extends BaseMapper<AuthLock> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.AuthLockMapper">
|
||||
|
||||
<resultMap id="authLockResultMap" type="org.springblade.system.pojo.entity.AuthLock">
|
||||
<result column="id" property="id"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="lock_type" property="lockType"/>
|
||||
<result column="lock_status" property="lockStatus"/>
|
||||
<result column="lock_target" property="lockTarget"/>
|
||||
<result column="remote_ip" property="remoteIp"/>
|
||||
<result column="user_agent" property="userAgent"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="lock_begin_time" property="lockBeginTime"/>
|
||||
<result column="lock_end_time" property="lockEndTime"/>
|
||||
<result column="lock_reason" property="lockReason"/>
|
||||
<result column="unlock_reason" property="unlockReason"/>
|
||||
<result column="fail_count" property="failCount"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.system.pojo.entity.AuthLog;
|
||||
|
||||
/**
|
||||
* 认证日志 Mapper 接口
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public interface AuthLogMapper extends BaseMapper<AuthLog> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.AuthLogMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="authLogResultMap" type="org.springblade.system.pojo.entity.AuthLog">
|
||||
<id column="id" property="id"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="service_id" property="serviceId"/>
|
||||
<result column="server_ip" property="serverIp"/>
|
||||
<result column="server_host" property="serverHost"/>
|
||||
<result column="env" property="env"/>
|
||||
<result column="account" property="account"/>
|
||||
<result column="real_name" property="realName"/>
|
||||
<result column="grant_type" property="grantType"/>
|
||||
<result column="remote_ip" property="remoteIp"/>
|
||||
<result column="user_agent" property="userAgent"/>
|
||||
<result column="login_time" property="loginTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.system.pojo.entity.DataScope;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public interface DataScopeMapper extends BaseMapper<DataScope> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.DataScopeMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.system.pojo.entity.Dept;
|
||||
import org.springblade.system.pojo.vo.DeptVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* DeptMapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface DeptMapper extends BaseMapper<Dept> {
|
||||
|
||||
/**
|
||||
* 懒加载部门列表
|
||||
*
|
||||
* @param tenantId
|
||||
* @param parentId
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
List<DeptVO> lazyList(String tenantId, Long parentId, Map<String, Object> param);
|
||||
|
||||
/**
|
||||
* 获取树形节点
|
||||
*
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
List<DeptVO> tree(String tenantId);
|
||||
|
||||
/**
|
||||
* 懒加载获取树形节点
|
||||
*
|
||||
* @param tenantId
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
List<DeptVO> lazyTree(String tenantId, Long parentId);
|
||||
|
||||
/**
|
||||
* 获取部门名
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<String> getDeptNames(Long[] ids);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.DeptMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="deptResultMap" type="org.springblade.system.pojo.entity.Dept">
|
||||
<id column="id" property="id"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="dept_name" property="deptName"/>
|
||||
<result column="full_name" property="fullName"/>
|
||||
<result column="ancestors" property="ancestors"/>
|
||||
<result column="dept_category" property="deptCategory"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="deptVOResultMap" type="org.springblade.system.pojo.vo.DeptVO">
|
||||
<id column="id" property="id"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="dept_name" property="deptName"/>
|
||||
<result column="full_name" property="fullName"/>
|
||||
<result column="ancestors" property="ancestors"/>
|
||||
<result column="dept_category" property="deptCategory"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="has_children" property="hasChildren"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
|
||||
<id column="id" property="id"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="title" property="title"/>
|
||||
<result column="value" property="value"/>
|
||||
<result column="key" property="key"/>
|
||||
<result column="has_children" property="hasChildren"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="lazyList" resultMap="deptVOResultMap">
|
||||
SELECT
|
||||
dept.* ,
|
||||
(
|
||||
SELECT
|
||||
CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
|
||||
FROM
|
||||
blade_dept
|
||||
WHERE
|
||||
parent_id = dept.id and is_deleted = 0
|
||||
) AS "has_children"
|
||||
FROM
|
||||
blade_dept dept
|
||||
WHERE dept.is_deleted = 0
|
||||
<if test="param1!=null and param1!=''">
|
||||
and dept.tenant_id = #{param1}
|
||||
</if>
|
||||
<if test="param2!=null">
|
||||
and dept.parent_id = #{param2}
|
||||
</if>
|
||||
<if test="param3.deptName!=null and param3.deptName!=''">
|
||||
and dept.dept_name like concat(concat('%', #{param3.deptName}),'%')
|
||||
</if>
|
||||
<if test="param3.fullName!=null and param3.fullName!=''">
|
||||
and dept.full_name like concat(concat('%', #{param3.fullName}),'%')
|
||||
</if>
|
||||
ORDER BY dept.sort
|
||||
</select>
|
||||
|
||||
<select id="tree" resultMap="treeNodeResultMap">
|
||||
select id, parent_id, dept_name as title, id as "value", id as "key" from blade_dept where is_deleted = 0
|
||||
<if test="_parameter!=null and _parameter!=''">
|
||||
and tenant_id = #{_parameter}
|
||||
</if>
|
||||
ORDER BY sort
|
||||
</select>
|
||||
|
||||
<select id="lazyTree" resultMap="treeNodeResultMap" >
|
||||
SELECT
|
||||
dept.id,
|
||||
dept.parent_id,
|
||||
dept.dept_name AS title,
|
||||
dept.id AS "value",
|
||||
dept.id AS "key",
|
||||
(
|
||||
SELECT
|
||||
CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
|
||||
FROM
|
||||
blade_dept
|
||||
WHERE
|
||||
parent_id = dept.id and is_deleted = 0
|
||||
) AS "has_children"
|
||||
FROM
|
||||
blade_dept dept
|
||||
WHERE
|
||||
dept.parent_id = #{param2} AND dept.is_deleted = 0
|
||||
<if test="param1!=null and param1!=''">
|
||||
and dept.tenant_id = #{param1}
|
||||
</if>
|
||||
ORDER BY dept.sort
|
||||
</select>
|
||||
|
||||
<select id="getDeptNames" resultType="java.lang.String">
|
||||
SELECT
|
||||
dept_name
|
||||
FROM
|
||||
blade_dept
|
||||
WHERE
|
||||
id IN
|
||||
<foreach collection="array" item="ids" index="index" open="(" close=")" separator=",">
|
||||
#{ids}
|
||||
</foreach>
|
||||
and is_deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.core.tenant.annotation.TenantIgnore;
|
||||
import org.springblade.system.pojo.entity.DictBiz;
|
||||
import org.springblade.system.pojo.vo.DictBizVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface DictBizMapper extends BaseMapper<DictBiz> {
|
||||
|
||||
/**
|
||||
* 获取字典表对应中文
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param code 字典编号
|
||||
* @param dictKey 字典序号
|
||||
* @return
|
||||
*/
|
||||
@TenantIgnore
|
||||
String getValue(String tenantId, String code, String dictKey);
|
||||
|
||||
/**
|
||||
* 获取字典表
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param code 字典编号
|
||||
* @return
|
||||
*/
|
||||
@TenantIgnore
|
||||
List<DictBiz> getList(String tenantId, String code);
|
||||
|
||||
/**
|
||||
* 获取树形节点
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DictBizVO> tree();
|
||||
|
||||
/**
|
||||
* 获取树形节点
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DictBizVO> parentTree();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.DictBizMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="dictResultMap" type="org.springblade.system.pojo.entity.DictBiz">
|
||||
<id column="id" property="id"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="code" property="code"/>
|
||||
<result column="dict_key" property="dictKey"/>
|
||||
<result column="dict_value" property="dictValue"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
|
||||
<id column="id" property="id"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="title" property="title"/>
|
||||
<result column="value" property="value"/>
|
||||
<result column="key" property="key"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getValue" resultType="java.lang.String">
|
||||
select
|
||||
dict_value
|
||||
from blade_dict_biz where tenant_id = #{param1} and code = #{param2} and dict_key = #{param3} and is_deleted = 0
|
||||
</select>
|
||||
|
||||
<!-- oracle 版本 -->
|
||||
<!--<select id="getValue" resultType="java.lang.String">
|
||||
select
|
||||
dict_value
|
||||
from blade_dict_biz where code = #{param1, jdbcType=VARCHAR} and dict_key = #{param2} and dict_key >= 0 rownum 1
|
||||
</select>-->
|
||||
|
||||
<select id="getList" resultMap="dictResultMap">
|
||||
select id, tenant_id, parent_id, code, dict_key, dict_value, sort, remark from blade_dict_biz where tenant_id = #{param1} and code = #{param2} and parent_id > 0 and is_sealed = 0 and is_deleted = 0 order by sort
|
||||
</select>
|
||||
|
||||
<select id="tree" resultMap="treeNodeResultMap">
|
||||
select id, parent_id, dict_value as title, id as "value", id as "key" from blade_dict_biz where is_deleted = 0 order by sort
|
||||
</select>
|
||||
|
||||
<select id="parentTree" resultMap="treeNodeResultMap">
|
||||
select id, parent_id, dict_value as title, id as "value", id as "key" from blade_dict_biz where is_deleted = 0 and parent_id = 0 order by sort
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.system.pojo.entity.Dict;
|
||||
import org.springblade.system.pojo.vo.DictVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface DictMapper extends BaseMapper<Dict> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page
|
||||
* @param dict
|
||||
* @return
|
||||
*/
|
||||
List<DictVO> selectDictPage(IPage page, DictVO dict);
|
||||
|
||||
/**
|
||||
* 获取字典表对应中文
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @param dictKey 字典序号
|
||||
* @return
|
||||
*/
|
||||
String getValue(String code, String dictKey);
|
||||
|
||||
/**
|
||||
* 获取字典表
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @return
|
||||
*/
|
||||
List<Dict> getList(String code);
|
||||
|
||||
/**
|
||||
* 获取树形节点
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DictVO> tree();
|
||||
|
||||
/**
|
||||
* 获取树形节点
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DictVO> parentTree();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.DictMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="dictResultMap" type="org.springblade.system.pojo.entity.Dict">
|
||||
<id column="id" property="id"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="code" property="code"/>
|
||||
<result column="dict_key" property="dictKey"/>
|
||||
<result column="dict_value" property="dictValue"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
|
||||
<id column="id" property="id"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="title" property="title"/>
|
||||
<result column="value" property="value"/>
|
||||
<result column="key" property="key"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectDictPage" resultMap="dictResultMap">
|
||||
select * from blade_dict where is_deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="getValue" resultType="java.lang.String">
|
||||
select
|
||||
dict_value
|
||||
from blade_dict where code = #{param1} and dict_key = #{param2} and is_deleted = 0
|
||||
</select>
|
||||
|
||||
<!-- oracle 版本 -->
|
||||
<!--<select id="getValue" resultType="java.lang.String">
|
||||
select
|
||||
dict_value
|
||||
from blade_dict where code = #{param1, jdbcType=VARCHAR} and dict_key = #{param2} and dict_key >= 0 rownum 1
|
||||
</select>-->
|
||||
|
||||
<select id="getList" resultMap="dictResultMap">
|
||||
select id, parent_id, code, dict_key, dict_value, sort, remark from blade_dict where code = #{param1} and parent_id > 0 and is_sealed = 0 and is_deleted = 0 order by sort
|
||||
</select>
|
||||
|
||||
<select id="tree" resultMap="treeNodeResultMap">
|
||||
select id, parent_id, dict_value as title, id as "value", id as "key" from blade_dict where is_deleted = 0 order by sort
|
||||
</select>
|
||||
|
||||
<select id="parentTree" resultMap="treeNodeResultMap">
|
||||
select id, parent_id, dict_value as title, id as "value", id as "key" from blade_dict where is_deleted = 0 and parent_id = 0 order by sort
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,192 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.core.tool.node.TreeNode;
|
||||
import org.springblade.system.pojo.dto.MenuDTO;
|
||||
import org.springblade.system.pojo.entity.Menu;
|
||||
import org.springblade.system.pojo.vo.MenuVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* MenuMapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface MenuMapper extends BaseMapper<Menu> {
|
||||
|
||||
/**
|
||||
* 懒加载列表
|
||||
*
|
||||
* @param parentId
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
List<MenuVO> lazyList(Long parentId, Map<String, Object> param);
|
||||
|
||||
/**
|
||||
* 懒加载菜单列表
|
||||
*
|
||||
* @param parentId
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
List<MenuVO> lazyMenuList(Long parentId, Map<String, Object> param);
|
||||
|
||||
/**
|
||||
* 树形结构
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TreeNode> tree();
|
||||
|
||||
/**
|
||||
* 授权树形结构
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TreeNode> grantTree();
|
||||
|
||||
/**
|
||||
* 授权树形结构
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
List<TreeNode> grantTreeByRole(List<Long> roleId);
|
||||
|
||||
/**
|
||||
* 顶部菜单树形结构
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TreeNode> grantTopTree();
|
||||
|
||||
/**
|
||||
* 顶部菜单树形结构
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
List<TreeNode> grantTopTreeByRole(List<Long> roleId);
|
||||
|
||||
/**
|
||||
* 数据权限授权树形结构
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TreeNode> grantDataScopeTree();
|
||||
|
||||
/**
|
||||
* 接口权限授权树形结构
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TreeNode> grantApiScopeTree();
|
||||
|
||||
/**
|
||||
* 数据权限授权树形结构
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
List<TreeNode> grantDataScopeTreeByRole(List<Long> roleId);
|
||||
|
||||
/**
|
||||
* 接口权限授权树形结构
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
List<TreeNode> grantApiScopeTreeByRole(List<Long> roleId);
|
||||
|
||||
/**
|
||||
* 所有菜单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Menu> allMenu();
|
||||
|
||||
/**
|
||||
* 权限配置菜单
|
||||
*
|
||||
* @param roleId
|
||||
* @param topMenuId
|
||||
* @return
|
||||
*/
|
||||
List<Menu> roleMenu(List<Long> roleId, Long topMenuId);
|
||||
|
||||
/**
|
||||
* 权限配置菜单
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
List<Menu> roleMenuByRoleId(List<Long> roleId);
|
||||
|
||||
/**
|
||||
* 权限配置菜单
|
||||
*
|
||||
* @param topMenuId
|
||||
* @return
|
||||
*/
|
||||
List<Menu> roleMenuByTopMenuId(Long topMenuId);
|
||||
|
||||
/**
|
||||
* 菜单树形结构
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
List<Menu> routes(List<Long> roleId);
|
||||
|
||||
/**
|
||||
* 按钮树形结构
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Menu> allButtons();
|
||||
|
||||
/**
|
||||
* 按钮树形结构
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
List<Menu> buttons(List<Long> roleId);
|
||||
|
||||
/**
|
||||
* 获取配置的角色权限
|
||||
*
|
||||
* @param roleIds
|
||||
* @return
|
||||
*/
|
||||
List<MenuDTO> authRoutes(List<Long> roleIds);
|
||||
}
|
||||
@@ -0,0 +1,478 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.MenuMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="menuResultMap" type="org.springblade.system.pojo.entity.Menu">
|
||||
<id column="id" property="id"/>
|
||||
<result column="code" property="code"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="alias" property="alias"/>
|
||||
<result column="path" property="path"/>
|
||||
<result column="source" property="source"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="category" property="category"/>
|
||||
<result column="action" property="action"/>
|
||||
<result column="is_open" property="isOpen"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="menuVOResultMap" type="org.springblade.system.pojo.vo.MenuVO">
|
||||
<id column="id" property="id"/>
|
||||
<result column="code" property="code"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="alias" property="alias"/>
|
||||
<result column="path" property="path"/>
|
||||
<result column="source" property="source"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="category" property="category"/>
|
||||
<result column="action" property="action"/>
|
||||
<result column="is_open" property="isOpen"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="has_children" property="hasChildren"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
|
||||
<id column="id" property="id"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="title" property="title"/>
|
||||
<result column="value" property="value"/>
|
||||
<result column="key" property="key"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="lazyList" resultMap="menuVOResultMap">
|
||||
SELECT
|
||||
menu.*,
|
||||
(
|
||||
SELECT
|
||||
CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END
|
||||
FROM
|
||||
blade_menu
|
||||
WHERE
|
||||
parent_id = menu.id AND is_deleted = 0
|
||||
) AS "has_children"
|
||||
FROM
|
||||
blade_menu menu
|
||||
WHERE menu.is_deleted = 0
|
||||
<if test="param1!=null">
|
||||
and menu.parent_id = #{param1}
|
||||
</if>
|
||||
<if test="param2.name!=null and param2.name!=''">
|
||||
and menu.name like concat(concat('%', #{param2.name}),'%')
|
||||
</if>
|
||||
<if test="param2.code!=null and param2.code!=''">
|
||||
and menu.code like concat(concat('%', #{param2.code}),'%')
|
||||
</if>
|
||||
<if test="param2.alias!=null and param2.alias!=''">
|
||||
and menu.alias like concat(concat('%', #{param2.alias}),'%')
|
||||
</if>
|
||||
ORDER BY menu.sort
|
||||
</select>
|
||||
|
||||
<select id="lazyMenuList" resultMap="menuVOResultMap">
|
||||
SELECT
|
||||
menu.*,
|
||||
(
|
||||
SELECT
|
||||
CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END
|
||||
FROM
|
||||
blade_menu
|
||||
WHERE
|
||||
parent_id = menu.id AND is_deleted = 0 AND category = 1
|
||||
) AS "has_children"
|
||||
FROM
|
||||
blade_menu menu
|
||||
WHERE menu.is_deleted = 0 AND menu.category = 1
|
||||
<if test="param1!=null">
|
||||
and menu.parent_id = #{param1}
|
||||
</if>
|
||||
<if test="param2.name!=null and param2.name!=''">
|
||||
and menu.name like concat(concat('%', #{param2.name}),'%')
|
||||
</if>
|
||||
<if test="param2.code!=null and param2.code!=''">
|
||||
and menu.code like concat(concat('%', #{param2.code}),'%')
|
||||
</if>
|
||||
<if test="param2.alias!=null and param2.alias!=''">
|
||||
and menu.alias like concat(concat('%', #{param2.alias}),'%')
|
||||
</if>
|
||||
ORDER BY menu.sort
|
||||
</select>
|
||||
|
||||
<select id="tree" resultMap="treeNodeResultMap">
|
||||
select id, parent_id, name as title, id as "value", id as "key" from blade_menu where is_deleted = 0 and category = 1
|
||||
</select>
|
||||
|
||||
<select id="allMenu" resultMap="menuResultMap">
|
||||
select * from blade_menu where is_deleted = 0 and category = 1
|
||||
</select>
|
||||
|
||||
<select id="roleMenu" resultMap="menuResultMap">
|
||||
select * from blade_menu where is_deleted = 0 and id IN
|
||||
( SELECT menu_id FROM blade_role_menu WHERE role_id IN
|
||||
<foreach collection="param1" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
<if test="param2!=null and param2>0">
|
||||
AND id IN
|
||||
(
|
||||
SELECT menu_id FROM blade_top_menu_setting WHERE top_menu_id = #{param2}
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="roleMenuByRoleId" resultMap="menuResultMap">
|
||||
select * from blade_menu where is_deleted = 0 and id IN
|
||||
( SELECT menu_id FROM blade_role_menu WHERE role_id IN
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="roleMenuByTopMenuId" resultMap="menuResultMap">
|
||||
select * from blade_menu where is_deleted = 0 and id IN
|
||||
(
|
||||
SELECT menu_id FROM blade_top_menu_setting WHERE top_menu_id = #{param1}
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="routes" resultMap="menuResultMap">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
blade_menu
|
||||
WHERE
|
||||
is_deleted = 0 and category = 1
|
||||
and id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach> )
|
||||
</select>
|
||||
|
||||
<select id="allButtons" resultMap="menuResultMap">
|
||||
SELECT
|
||||
id,
|
||||
parent_id,
|
||||
CODE,
|
||||
NAME,
|
||||
alias,
|
||||
path,
|
||||
source,
|
||||
action,
|
||||
sort
|
||||
FROM
|
||||
blade_menu
|
||||
WHERE
|
||||
(
|
||||
category = 2 OR id IN ( SELECT parent_id FROM blade_menu WHERE is_deleted = 0 AND category = 2 )
|
||||
)
|
||||
AND is_deleted = 0
|
||||
ORDER BY sort
|
||||
</select>
|
||||
|
||||
<select id="buttons" resultMap="menuResultMap">
|
||||
SELECT * FROM (
|
||||
SELECT
|
||||
id,
|
||||
parent_id,
|
||||
code,
|
||||
name,
|
||||
alias,
|
||||
path,
|
||||
source,
|
||||
action,
|
||||
sort
|
||||
FROM
|
||||
blade_menu
|
||||
WHERE
|
||||
is_deleted = 0 and id IN (
|
||||
SELECT parent_id FROM blade_menu
|
||||
WHERE ( category = 2 AND id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
) ) )
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
id,
|
||||
parent_id,
|
||||
code,
|
||||
name,
|
||||
alias,
|
||||
path,
|
||||
source,
|
||||
action,
|
||||
sort
|
||||
FROM
|
||||
blade_menu
|
||||
WHERE
|
||||
is_deleted = 0 and category = 2 AND id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>)
|
||||
) menu ORDER BY sort
|
||||
</select>
|
||||
|
||||
<select id="grantTree" resultMap="treeNodeResultMap">
|
||||
select id, parent_id, name as title, id as "value", id as "key" from blade_menu where is_deleted = 0 order by sort
|
||||
</select>
|
||||
|
||||
<select id="grantTreeByRole" resultMap="treeNodeResultMap">
|
||||
select id, parent_id, name as title, id as "value", id as "key" from blade_menu where is_deleted = 0
|
||||
and id in ( select menu_id from blade_role_menu where role_id in
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach> )
|
||||
or id in (
|
||||
select parent_id from blade_menu where is_deleted = 0
|
||||
and id in ( select menu_id from blade_role_menu where role_id in
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach> )
|
||||
)
|
||||
order by sort
|
||||
</select>
|
||||
|
||||
<select id="grantTopTree" resultMap="treeNodeResultMap">
|
||||
select id, parent_id, name as title, id as "value", id as "key" from blade_menu where category = 1 and is_deleted = 0 order by sort
|
||||
</select>
|
||||
|
||||
<select id="grantTopTreeByRole" resultMap="treeNodeResultMap">
|
||||
select id, parent_id, name as title, id as "value", id as "key" from blade_menu where category = 1 and is_deleted = 0
|
||||
and id in ( select menu_id from blade_role_menu where role_id in
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach> )
|
||||
or id in (
|
||||
select parent_id from blade_menu where is_deleted = 0
|
||||
and id in ( select menu_id from blade_role_menu where role_id in
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach> )
|
||||
)
|
||||
order by sort
|
||||
</select>
|
||||
|
||||
<select id="grantDataScopeTree" resultMap="treeNodeResultMap">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
id,
|
||||
parent_id,
|
||||
NAME AS title,
|
||||
id AS "value",
|
||||
id AS "key"
|
||||
FROM
|
||||
blade_menu
|
||||
WHERE
|
||||
category = 1
|
||||
AND is_deleted = 0
|
||||
AND id IN ( SELECT menu_id FROM blade_scope_data WHERE is_deleted = 0 AND menu_id IS NOT NULL )
|
||||
) menu
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
id,
|
||||
menu_id AS parent_id,
|
||||
scope_name AS title,
|
||||
id AS "value",
|
||||
id AS "key"
|
||||
FROM
|
||||
blade_scope_data
|
||||
WHERE
|
||||
is_deleted = 0
|
||||
AND menu_id IS NOT NULL
|
||||
</select>
|
||||
|
||||
<select id="grantApiScopeTree" resultMap="treeNodeResultMap">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
id,
|
||||
parent_id,
|
||||
NAME AS title,
|
||||
id AS "value",
|
||||
id AS "key"
|
||||
FROM
|
||||
blade_menu
|
||||
WHERE
|
||||
category = 1
|
||||
AND is_deleted = 0
|
||||
AND id IN ( SELECT menu_id FROM blade_scope_api WHERE is_deleted = 0 AND menu_id IS NOT NULL )
|
||||
) menu
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
id,
|
||||
menu_id AS parent_id,
|
||||
scope_name AS title,
|
||||
id AS "value",
|
||||
id AS "key"
|
||||
FROM
|
||||
blade_scope_api
|
||||
WHERE
|
||||
is_deleted = 0
|
||||
AND menu_id IS NOT NULL
|
||||
</select>
|
||||
|
||||
<select id="grantDataScopeTreeByRole" resultMap="treeNodeResultMap">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
id,
|
||||
parent_id,
|
||||
NAME AS title,
|
||||
id AS "value",
|
||||
id AS "key"
|
||||
FROM
|
||||
blade_menu
|
||||
WHERE
|
||||
category = 1
|
||||
AND is_deleted = 0
|
||||
AND id IN ( SELECT menu_id FROM blade_scope_data WHERE is_deleted = 0 AND menu_id IS NOT NULL )
|
||||
AND (
|
||||
id IN (
|
||||
select menu_id from blade_role_menu where role_id in
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
OR id IN (
|
||||
select parent_id from blade_menu where is_deleted = 0
|
||||
and id in ( select menu_id from blade_role_menu where role_id in
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach> )
|
||||
)
|
||||
)
|
||||
) menu
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
id,
|
||||
menu_id AS parent_id,
|
||||
scope_name AS title,
|
||||
id AS "value",
|
||||
id AS "key"
|
||||
FROM
|
||||
blade_scope_data
|
||||
WHERE
|
||||
is_deleted = 0
|
||||
AND (
|
||||
menu_id IN (
|
||||
select menu_id from blade_role_menu where role_id in
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
OR menu_id IN (
|
||||
select parent_id from blade_menu where is_deleted = 0
|
||||
and id in ( select menu_id from blade_role_menu where role_id in
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach> )
|
||||
)
|
||||
)
|
||||
AND menu_id IS NOT NULL
|
||||
</select>
|
||||
|
||||
<select id="grantApiScopeTreeByRole" resultMap="treeNodeResultMap">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
id,
|
||||
parent_id,
|
||||
NAME AS title,
|
||||
id AS "value",
|
||||
id AS "key"
|
||||
FROM
|
||||
blade_menu
|
||||
WHERE
|
||||
category = 1
|
||||
AND is_deleted = 0
|
||||
AND id IN ( SELECT menu_id FROM blade_scope_api WHERE is_deleted = 0 AND menu_id IS NOT NULL )
|
||||
AND (
|
||||
id IN (
|
||||
select menu_id from blade_role_menu where role_id in
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
OR id IN (
|
||||
select parent_id from blade_menu where is_deleted = 0
|
||||
and id in (
|
||||
select menu_id from blade_role_menu where role_id in
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach> )
|
||||
)
|
||||
)
|
||||
) menu
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
id,
|
||||
menu_id AS parent_id,
|
||||
scope_name AS title,
|
||||
id AS "value",
|
||||
id AS "key"
|
||||
FROM
|
||||
blade_scope_api
|
||||
WHERE
|
||||
is_deleted = 0
|
||||
AND
|
||||
(
|
||||
menu_id IN (
|
||||
select menu_id from blade_role_menu where role_id in
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
OR menu_id IN (
|
||||
select parent_id from blade_menu where is_deleted = 0
|
||||
and id in ( select menu_id from blade_role_menu where role_id in
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach> )
|
||||
)
|
||||
)
|
||||
AND menu_id IS NOT NULL
|
||||
</select>
|
||||
|
||||
<select id="authRoutes" resultType="org.springblade.system.pojo.dto.MenuDTO">
|
||||
SELECT
|
||||
GROUP_CONCAT(r.role_alias) as alias,
|
||||
m.path
|
||||
FROM
|
||||
blade_role_menu rm
|
||||
LEFT JOIN blade_menu m ON rm.menu_id = m.id
|
||||
LEFT JOIN blade_role r ON rm.role_id = r.id
|
||||
WHERE
|
||||
rm.role_id IN
|
||||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
AND m.path IS NOT NULL and m.is_deleted = 0
|
||||
GROUP BY m.path
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.system.pojo.entity.Param;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface ParamMapper extends BaseMapper<Param> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.ParamMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="paramResultMap" type="org.springblade.system.pojo.entity.Param">
|
||||
<result column="id" property="id"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="param_name" property="paramName"/>
|
||||
<result column="param_key" property="paramKey"/>
|
||||
<result column="param_value" property="paramValue"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.system.pojo.entity.Post;
|
||||
import org.springblade.system.pojo.vo.PostVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 岗位表 Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface PostMapper extends BaseMapper<Post> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page
|
||||
* @param post
|
||||
* @return
|
||||
*/
|
||||
List<PostVO> selectPostPage(IPage page, PostVO post);
|
||||
|
||||
/**
|
||||
* 获取岗位名
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<String> getPostNames(Long[] ids);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.PostMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="postResultMap" type="org.springblade.system.pojo.entity.Post">
|
||||
<result column="id" property="id"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_dept" property="createDept"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="category" property="category"/>
|
||||
<result column="post_code" property="postCode"/>
|
||||
<result column="post_name" property="postName"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectPostPage" resultMap="postResultMap">
|
||||
select * from blade_post where is_deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="getPostNames" resultType="java.lang.String">
|
||||
SELECT
|
||||
post_name
|
||||
FROM
|
||||
blade_post
|
||||
WHERE
|
||||
id IN
|
||||
<foreach collection="array" item="ids" index="index" open="(" close=")" separator=",">
|
||||
#{ids}
|
||||
</foreach>
|
||||
and is_deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.system.pojo.entity.RateLimitLog;
|
||||
|
||||
/**
|
||||
* 限流触发日志 Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface RateLimitLogMapper extends BaseMapper<RateLimitLog> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.system.pojo.entity.RateLimit;
|
||||
|
||||
/**
|
||||
* 限流规则 Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface RateLimitMapper extends BaseMapper<RateLimit> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springblade.system.pojo.entity.RecordData;
|
||||
|
||||
/**
|
||||
* 数据审计表 Mapper 接口
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public interface RecordDataMapper extends BaseMapper<RecordData> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.RecordDataMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="recordDataResultMap" type="org.springblade.system.pojo.entity.RecordData">
|
||||
<result column="service_id" property="serviceId"/>
|
||||
<result column="server_host" property="serverHost"/>
|
||||
<result column="server_ip" property="serverIp"/>
|
||||
<result column="env" property="env"/>
|
||||
<result column="level" property="recordLevel"/>
|
||||
<result column="method" property="method"/>
|
||||
<result column="request_uri" property="requestUri"/>
|
||||
<result column="user_agent" property="userAgent"/>
|
||||
<result column="remote_ip" property="remoteIp"/>
|
||||
<result column="operation" property="operation"/>
|
||||
<result column="table_name" property="tableName"/>
|
||||
<result column="old_data" property="oldData"/>
|
||||
<result column="new_data" property="newData"/>
|
||||
<result column="record_message" property="recordMessage"/>
|
||||
<result column="record_result" property="recordResult"/>
|
||||
<result column="record_cost" property="recordCost"/>
|
||||
<result column="record_time" property="recordTime"/>
|
||||
<result column="record_user" property="recordUser"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springblade.system.pojo.entity.Region;
|
||||
import org.springblade.system.excel.RegionExcel;
|
||||
import org.springblade.system.pojo.vo.RegionVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 行政区划表 Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface RegionMapper extends BaseMapper<Region> {
|
||||
|
||||
/**
|
||||
* 懒加载列表
|
||||
*
|
||||
* @param parentCode
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
List<RegionVO> lazyList(String parentCode, Map<String, Object> param);
|
||||
|
||||
/**
|
||||
* 懒加载列表
|
||||
*
|
||||
* @param parentCode
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
List<RegionVO> lazyTree(String parentCode, Map<String, Object> param);
|
||||
|
||||
/**
|
||||
* 导出区划数据
|
||||
*
|
||||
* @param queryWrapper
|
||||
* @return
|
||||
*/
|
||||
List<RegionExcel> exportRegion(@Param("ew") Wrapper<Region> queryWrapper);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?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">
|
||||
<mapper namespace="org.springblade.system.mapper.RegionMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="regionResultMap" type="org.springblade.system.pojo.entity.Region">
|
||||
<id column="code" property="code"/>
|
||||
<result column="parent_code" property="parentCode"/>
|
||||
<result column="ancestors" property="ancestors"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="province_code" property="provinceCode"/>
|
||||
<result column="province_name" property="provinceName"/>
|
||||
<result column="city_code" property="cityCode"/>
|
||||
<result column="city_name" property="cityName"/>
|
||||
<result column="district_code" property="districtCode"/>
|
||||
<result column="district_name" property="districtName"/>
|
||||
<result column="town_code" property="townCode"/>
|
||||
<result column="town_name" property="townName"/>
|
||||
<result column="village_code" property="villageCode"/>
|
||||
<result column="village_name" property="villageName"/>
|
||||
<result column="level" property="regionLevel"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="regionVOResultMap" type="org.springblade.system.pojo.vo.RegionVO">
|
||||
<id column="code" property="code"/>
|
||||
<result column="parent_code" property="parentCode"/>
|
||||
<result column="ancestors" property="ancestors"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="province_code" property="provinceCode"/>
|
||||
<result column="province_name" property="provinceName"/>
|
||||
<result column="city_code" property="cityCode"/>
|
||||
<result column="city_name" property="cityName"/>
|
||||
<result column="district_code" property="districtCode"/>
|
||||
<result column="district_name" property="districtName"/>
|
||||
<result column="town_code" property="townCode"/>
|
||||
<result column="town_name" property="townName"/>
|
||||
<result column="village_code" property="villageCode"/>
|
||||
<result column="village_name" property="villageName"/>
|
||||
<result column="level" property="regionLevel"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="id" property="id"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="has_children" property="hasChildren"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
|
||||
<id column="id" property="id"/>
|
||||
<result column="parent_id" property="parentId"/>
|
||||
<result column="title" property="title"/>
|
||||
<result column="value" property="value"/>
|
||||
<result column="key" property="key"/>
|
||||
<result column="has_children" property="hasChildren"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="lazyList" resultMap="regionVOResultMap">
|
||||
SELECT
|
||||
region.*,
|
||||
( SELECT CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END FROM blade_region WHERE parent_code = region.code ) AS "has_children"
|
||||
FROM
|
||||
blade_region region
|
||||
<where>
|
||||
<if test="param1!=null">
|
||||
and region.parent_code = #{param1}
|
||||
</if>
|
||||
<if test="param2.code!=null and param2.code!=''">
|
||||
and region.code like concat(concat('%', #{param2.code}),'%')
|
||||
</if>
|
||||
<if test="param2.name!=null and param2.name!=''">
|
||||
and region.name like concat(concat('%', #{param2.name}),'%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="lazyTree" resultMap="treeNodeResultMap">
|
||||
SELECT
|
||||
region.code AS "id",
|
||||
region.parent_code AS "parent_id",
|
||||
region.name AS "title",
|
||||
region.code AS "value",
|
||||
region.code AS "key",
|
||||
( SELECT CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END FROM blade_region WHERE parent_code = region.code ) AS "has_children"
|
||||
FROM
|
||||
blade_region region
|
||||
<where>
|
||||
<if test="param1!=null">
|
||||
and region.parent_code = #{param1}
|
||||
</if>
|
||||
<if test="param2.code!=null and param2.code!=''">
|
||||
and region.code like concat(concat('%', #{param2.code}),'%')
|
||||
</if>
|
||||
<if test="param2.name!=null and param2.name!=''">
|
||||
and region.name like concat(concat('%', #{param2.name}),'%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY region.code
|
||||
</select>
|
||||
|
||||
<select id="exportRegion" resultType="org.springblade.system.excel.RegionExcel">
|
||||
SELECT * FROM blade_region ${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.system.pojo.entity.Role;
|
||||
import org.springblade.system.pojo.vo.RoleVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface RoleMapper extends BaseMapper<Role> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page
|
||||
* @param role
|
||||
* @return
|
||||
*/
|
||||
List<RoleVO> selectRolePage(IPage page, RoleVO role);
|
||||
|
||||
/**
|
||||
* 获取树形节点
|
||||
*
|
||||
* @param tenantId
|
||||
* @param excludeRole
|
||||
* @return
|
||||
*/
|
||||
List<RoleVO> tree(String tenantId, String excludeRole);
|
||||
|
||||
/**
|
||||
* 获取角色名
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<String> getRoleNames(Long[] ids);
|
||||
|
||||
/**
|
||||
* 获取角色名
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<String> getRoleAliases(Long[] ids);
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user