New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-cloud-plus</artifactId> |
| | | <version>${revision}</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <modules> |
| | | <module>ruoyi-system</module> |
| | | <module>ruoyi-gen</module> |
| | | <module>ruoyi-job</module> |
| | | <module>ruoyi-resource</module> |
| | | </modules> |
| | | |
| | | <artifactId>ruoyi-modules</artifactId> |
| | | <packaging>pom</packaging> |
| | | |
| | | <description> |
| | | ruoyi-modules业务模块 |
| | | </description> |
| | | |
| | | <dependencies> |
| | | <!-- 自定义负载均衡(多团队开发使用) --> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>org.dromara</groupId>--> |
| | | <!-- <artifactId>ruoyi-common-loadbalancer</artifactId>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <!-- ELK 日志收集 --> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>org.dromara</groupId>--> |
| | | <!-- <artifactId>ruoyi-common-logstash</artifactId>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <!-- skywalking 日志收集 --> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>org.dromara</groupId>--> |
| | | <!-- <artifactId>ruoyi-common-skylog</artifactId>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <!-- prometheus 监控 --> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>org.dromara</groupId>--> |
| | | <!-- <artifactId>ruoyi-common-prometheus</artifactId>--> |
| | | <!-- </dependency>--> |
| | | |
| | | </dependencies> |
| | | |
| | | </project> |
New file |
| | |
| | | #FROM findepi/graalvm:java17-native |
| | | FROM openjdk:17.0.2-oraclelinux8 |
| | | |
| | | MAINTAINER Lion Li |
| | | |
| | | RUN mkdir -p /ruoyi/gen/logs |
| | | |
| | | WORKDIR /ruoyi/gen |
| | | |
| | | ENV SERVER_PORT=9202 LANG=C.UTF-8 LC_ALL=C.UTF-8 JAVA_OPTS="" |
| | | |
| | | EXPOSE ${SERVER_PORT} |
| | | |
| | | ADD ./target/ruoyi-gen.jar ./app.jar |
| | | |
| | | ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${SERVER_PORT} -jar app.jar ${JAVA_OPTS} |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-modules</artifactId> |
| | | <version>${revision}</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>ruoyi-gen</artifactId> |
| | | |
| | | <description> |
| | | ruoyi-gen代码生成 |
| | | </description> |
| | | |
| | | <dependencies> |
| | | |
| | | <!-- SpringCloud Alibaba Nacos --> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- SpringCloud Alibaba Nacos Config --> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- Apache Velocity --> |
| | | <dependency> |
| | | <groupId>org.apache.velocity</groupId> |
| | | <artifactId>velocity-engine-core</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- RuoYi Common Log --> |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-log</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-doc</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-web</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-mybatis</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-dubbo</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-tenant</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-security</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <finalName>${project.artifactId}</finalName> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <version>${spring-boot.version}</version> |
| | | <executions> |
| | | <execution> |
| | | <goals> |
| | | <goal>repackage</goal> |
| | | </goals> |
| | | </execution> |
| | | </executions> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
New file |
| | |
| | | package org.dromara.gen; |
| | | |
| | | import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup; |
| | | |
| | | /** |
| | | * 代码生成 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @EnableDubbo |
| | | @SpringBootApplication |
| | | public class RuoYiGenApplication { |
| | | public static void main(String[] args) { |
| | | SpringApplication application = new SpringApplication(RuoYiGenApplication.class); |
| | | application.setApplicationStartup(new BufferingApplicationStartup(2048)); |
| | | application.run(args); |
| | | System.out.println("(♥◠‿◠)ノ゙ 代码生成模块启动成功 ლ(´ڡ`ლ)゙ "); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.gen.config; |
| | | |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 代码生成相关配置 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | @ConfigurationProperties(prefix = "gen") |
| | | public class GenConfig { |
| | | /** |
| | | * 作者 |
| | | */ |
| | | public static String author; |
| | | |
| | | /** |
| | | * 生成包路径 |
| | | */ |
| | | public static String packageName; |
| | | |
| | | /** |
| | | * 自动去除表前缀,默认是false |
| | | */ |
| | | public static boolean autoRemovePre; |
| | | |
| | | /** |
| | | * 表前缀(类名不会包含表前缀) |
| | | */ |
| | | public static String tablePrefix; |
| | | |
| | | public static String getAuthor() { |
| | | return author; |
| | | } |
| | | |
| | | public void setAuthor(String author) { |
| | | GenConfig.author = author; |
| | | } |
| | | |
| | | public static String getPackageName() { |
| | | return packageName; |
| | | } |
| | | |
| | | public void setPackageName(String packageName) { |
| | | GenConfig.packageName = packageName; |
| | | } |
| | | |
| | | public static boolean getAutoRemovePre() { |
| | | return autoRemovePre; |
| | | } |
| | | |
| | | public void setAutoRemovePre(boolean autoRemovePre) { |
| | | GenConfig.autoRemovePre = autoRemovePre; |
| | | } |
| | | |
| | | public static String getTablePrefix() { |
| | | return tablePrefix; |
| | | } |
| | | |
| | | public void setTablePrefix(String tablePrefix) { |
| | | GenConfig.tablePrefix = tablePrefix; |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.gen.constant; |
| | | |
| | | /** |
| | | * 代码生成通用常量 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface GenConstants { |
| | | /** |
| | | * 单表(增删改查) |
| | | */ |
| | | String TPL_CRUD = "crud"; |
| | | |
| | | /** |
| | | * 树表(增删改查) |
| | | */ |
| | | String TPL_TREE = "tree"; |
| | | |
| | | /** |
| | | * 树编码字段 |
| | | */ |
| | | String TREE_CODE = "treeCode"; |
| | | |
| | | /** |
| | | * 树父编码字段 |
| | | */ |
| | | String TREE_PARENT_CODE = "treeParentCode"; |
| | | |
| | | /** |
| | | * 树名称字段 |
| | | */ |
| | | String TREE_NAME = "treeName"; |
| | | |
| | | /** |
| | | * 上级菜单ID字段 |
| | | */ |
| | | String PARENT_MENU_ID = "parentMenuId"; |
| | | |
| | | /** |
| | | * 上级菜单名称字段 |
| | | */ |
| | | String PARENT_MENU_NAME = "parentMenuName"; |
| | | |
| | | /** |
| | | * 数据库字符串类型 |
| | | */ |
| | | String[] COLUMNTYPE_STR = {"char", "varchar", "enum", "set", "nchar", "nvarchar", "varchar2", "nvarchar2"}; |
| | | |
| | | /** |
| | | * 数据库文本类型 |
| | | */ |
| | | String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext", "binary", "varbinary", "blob", |
| | | "ntext", "image", "bytea"}; |
| | | |
| | | /** |
| | | * 数据库时间类型 |
| | | */ |
| | | String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp", "year", "interval", |
| | | "smalldatetime", "datetime2", "datetimeoffset"}; |
| | | |
| | | /** |
| | | * 数据库数字类型 |
| | | */ |
| | | String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer", |
| | | "bit", "bigint", "float", "double", "decimal", "numeric", "real", "double precision", |
| | | "smallserial", "serial", "bigserial", "money", "smallmoney"}; |
| | | |
| | | /** |
| | | * BO对象 不需要添加字段 |
| | | */ |
| | | String[] COLUMNNAME_NOT_ADD = {"create_dept", "create_by", "create_time", "del_flag", "update_by", |
| | | "update_time", "version", "tenant_id"}; |
| | | |
| | | /** |
| | | * BO对象 不需要编辑字段 |
| | | */ |
| | | String[] COLUMNNAME_NOT_EDIT = {"create_dept", "create_by", "create_time", "del_flag", "update_by", |
| | | "update_time", "version", "tenant_id"}; |
| | | |
| | | /** |
| | | * VO对象 不需要返回字段 |
| | | */ |
| | | String[] COLUMNNAME_NOT_LIST = {"create_dept", "create_by", "create_time", "del_flag", "update_by", |
| | | "update_time", "version", "tenant_id"}; |
| | | |
| | | /** |
| | | * BO对象 不需要查询字段 |
| | | */ |
| | | String[] COLUMNNAME_NOT_QUERY = {"id", "create_dept", "create_by", "create_time", "del_flag", "update_by", |
| | | "update_time", "remark", "version", "tenant_id"}; |
| | | |
| | | /** |
| | | * Entity基类字段 |
| | | */ |
| | | String[] BASE_ENTITY = {"createDept", "createBy", "createTime", "updateBy", "updateTime", "tenantId"}; |
| | | |
| | | /** |
| | | * 文本框 |
| | | */ |
| | | String HTML_INPUT = "input"; |
| | | |
| | | /** |
| | | * 文本域 |
| | | */ |
| | | String HTML_TEXTAREA = "textarea"; |
| | | |
| | | /** |
| | | * 下拉框 |
| | | */ |
| | | String HTML_SELECT = "select"; |
| | | |
| | | /** |
| | | * 单选框 |
| | | */ |
| | | String HTML_RADIO = "radio"; |
| | | |
| | | /** |
| | | * 复选框 |
| | | */ |
| | | String HTML_CHECKBOX = "checkbox"; |
| | | |
| | | /** |
| | | * 日期控件 |
| | | */ |
| | | String HTML_DATETIME = "datetime"; |
| | | |
| | | /** |
| | | * 图片上传控件 |
| | | */ |
| | | String HTML_IMAGE_UPLOAD = "imageUpload"; |
| | | |
| | | /** |
| | | * 文件上传控件 |
| | | */ |
| | | String HTML_FILE_UPLOAD = "fileUpload"; |
| | | |
| | | /** |
| | | * 富文本控件 |
| | | */ |
| | | String HTML_EDITOR = "editor"; |
| | | |
| | | /** |
| | | * 字符串类型 |
| | | */ |
| | | String TYPE_STRING = "String"; |
| | | |
| | | /** |
| | | * 整型 |
| | | */ |
| | | String TYPE_INTEGER = "Integer"; |
| | | |
| | | /** |
| | | * 长整型 |
| | | */ |
| | | String TYPE_LONG = "Long"; |
| | | |
| | | /** |
| | | * 浮点型 |
| | | */ |
| | | String TYPE_DOUBLE = "Double"; |
| | | |
| | | /** |
| | | * 高精度计算类型 |
| | | */ |
| | | String TYPE_BIGDECIMAL = "BigDecimal"; |
| | | |
| | | /** |
| | | * 时间类型 |
| | | */ |
| | | String TYPE_DATE = "Date"; |
| | | |
| | | /** |
| | | * 模糊查询 |
| | | */ |
| | | String QUERY_LIKE = "LIKE"; |
| | | |
| | | /** |
| | | * 相等查询 |
| | | */ |
| | | String QUERY_EQ = "EQ"; |
| | | |
| | | /** |
| | | * 需要 |
| | | */ |
| | | String REQUIRE = "1"; |
| | | } |
New file |
| | |
| | | package org.dromara.gen.controller; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.io.IoUtil; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.mybatis.helper.DataBaseHelper; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.gen.domain.GenTable; |
| | | import org.dromara.gen.domain.GenTableColumn; |
| | | import org.dromara.gen.service.IGenTableService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 代码生成 操作处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/gen") |
| | | public class GenController extends BaseController { |
| | | |
| | | private final IGenTableService genTableService; |
| | | |
| | | /** |
| | | * 查询代码生成列表 |
| | | */ |
| | | @SaCheckPermission("tool:gen:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<GenTable> genList(GenTable genTable, PageQuery pageQuery) { |
| | | return genTableService.selectPageGenTableList(genTable, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 修改代码生成业务 |
| | | * |
| | | * @param tableId 表ID |
| | | */ |
| | | @SaCheckPermission("tool:gen:query") |
| | | @GetMapping(value = "/{tableId}") |
| | | public R<Map<String, Object>> getInfo(@PathVariable Long tableId) { |
| | | GenTable table = genTableService.selectGenTableById(tableId); |
| | | List<GenTable> tables = genTableService.selectGenTableAll(); |
| | | List<GenTableColumn> list = genTableService.selectGenTableColumnListByTableId(tableId); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("info", table); |
| | | map.put("rows", list); |
| | | map.put("tables", tables); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | /** |
| | | * 查询数据库列表 |
| | | */ |
| | | @SaCheckPermission("tool:gen:list") |
| | | @GetMapping("/db/list") |
| | | public TableDataInfo<GenTable> dataList(GenTable genTable, PageQuery pageQuery) { |
| | | return genTableService.selectPageDbTableList(genTable, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 查询数据表字段列表 |
| | | * |
| | | * @param tableId 表ID |
| | | */ |
| | | @SaCheckPermission("tool:gen:list") |
| | | @GetMapping(value = "/column/{tableId}") |
| | | public TableDataInfo<GenTableColumn> columnList(@PathVariable("tableId") Long tableId) { |
| | | TableDataInfo<GenTableColumn> dataInfo = new TableDataInfo<>(); |
| | | List<GenTableColumn> list = genTableService.selectGenTableColumnListByTableId(tableId); |
| | | dataInfo.setRows(list); |
| | | dataInfo.setTotal(list.size()); |
| | | return dataInfo; |
| | | } |
| | | |
| | | /** |
| | | * 导入表结构(保存) |
| | | * |
| | | * @param tables 表名串 |
| | | */ |
| | | @SaCheckPermission("tool:gen:import") |
| | | @Log(title = "代码生成", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importTable") |
| | | public R<Void> importTableSave(String tables, String dataName) { |
| | | String[] tableNames = Convert.toStrArray(tables); |
| | | // 查询表信息 |
| | | List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames, dataName); |
| | | genTableService.importGenTable(tableList, dataName); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存代码生成业务 |
| | | */ |
| | | @SaCheckPermission("tool:gen:edit") |
| | | @Log(title = "代码生成", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public R<Void> editSave(@Validated @RequestBody GenTable genTable) { |
| | | genTableService.validateEdit(genTable); |
| | | genTableService.updateGenTable(genTable); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除代码生成 |
| | | * |
| | | * @param tableIds 表ID串 |
| | | */ |
| | | @SaCheckPermission("tool:gen:remove") |
| | | @Log(title = "代码生成", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{tableIds}") |
| | | public R<Void> remove(@PathVariable Long[] tableIds) { |
| | | genTableService.deleteGenTableByIds(tableIds); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 预览代码 |
| | | * |
| | | * @param tableId 表ID |
| | | */ |
| | | @SaCheckPermission("tool:gen:preview") |
| | | @GetMapping("/preview/{tableId}") |
| | | public R<Map<String, String>> preview(@PathVariable("tableId") Long tableId) throws IOException { |
| | | Map<String, String> dataMap = genTableService.previewCode(tableId); |
| | | return R.ok(dataMap); |
| | | } |
| | | |
| | | /** |
| | | * 生成代码(下载方式) |
| | | * |
| | | * @param tableId 表ID |
| | | */ |
| | | @SaCheckPermission("tool:gen:code") |
| | | @Log(title = "代码生成", businessType = BusinessType.GENCODE) |
| | | @GetMapping("/download/{tableId}") |
| | | public void download(HttpServletResponse response, @PathVariable("tableId") Long tableId) throws IOException { |
| | | byte[] data = genTableService.downloadCode(tableId); |
| | | genCode(response, data); |
| | | } |
| | | |
| | | /** |
| | | * 生成代码(自定义路径) |
| | | * |
| | | * @param tableId 表ID |
| | | */ |
| | | @SaCheckPermission("tool:gen:code") |
| | | @Log(title = "代码生成", businessType = BusinessType.GENCODE) |
| | | @GetMapping("/genCode/{tableId}") |
| | | public R<Void> genCode(@PathVariable("tableId") Long tableId) { |
| | | genTableService.generatorCode(tableId); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 同步数据库 |
| | | * |
| | | * @param tableId 表ID |
| | | */ |
| | | @SaCheckPermission("tool:gen:edit") |
| | | @Log(title = "代码生成", businessType = BusinessType.UPDATE) |
| | | @GetMapping("/synchDb/{tableId}") |
| | | public R<Void> synchDb(@PathVariable("tableId") Long tableId) { |
| | | genTableService.synchDb(tableId); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 批量生成代码 |
| | | * |
| | | * @param tableIdStr 表ID串 |
| | | */ |
| | | @SaCheckPermission("tool:gen:code") |
| | | @Log(title = "代码生成", businessType = BusinessType.GENCODE) |
| | | @GetMapping("/batchGenCode") |
| | | public void batchGenCode(HttpServletResponse response, String tableIdStr) throws IOException { |
| | | String[] tableIds = Convert.toStrArray(tableIdStr); |
| | | byte[] data = genTableService.downloadCode(tableIds); |
| | | genCode(response, data); |
| | | } |
| | | |
| | | /** |
| | | * 生成zip文件 |
| | | */ |
| | | private void genCode(HttpServletResponse response, byte[] data) throws IOException { |
| | | response.reset(); |
| | | response.addHeader("Access-Control-Allow-Origin", "*"); |
| | | response.addHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
| | | response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\""); |
| | | response.addHeader("Content-Length", "" + data.length); |
| | | response.setContentType("application/octet-stream; charset=UTF-8"); |
| | | IoUtil.write(response.getOutputStream(), false, data); |
| | | } |
| | | |
| | | /** |
| | | * 查询数据源名称列表 |
| | | */ |
| | | @SaCheckPermission("tool:gen:list") |
| | | @GetMapping(value = "/getDataNames") |
| | | public R<Object> getCurrentDataSourceNameList(){ |
| | | return R.ok(DataBaseHelper.getDataSourceNameList()); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.gen.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldStrategy; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import jakarta.validation.Valid; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.gen.constant.GenConstants; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 业务表 gen_table |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("gen_table") |
| | | public class GenTable extends BaseEntity { |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @TableId(value = "table_id") |
| | | private Long tableId; |
| | | |
| | | /** |
| | | * 数据源名称 |
| | | */ |
| | | @NotBlank(message = "数据源名称不能为空") |
| | | private String dataName; |
| | | |
| | | /** |
| | | * 表名称 |
| | | */ |
| | | @NotBlank(message = "表名称不能为空") |
| | | private String tableName; |
| | | |
| | | /** |
| | | * 表描述 |
| | | */ |
| | | @NotBlank(message = "表描述不能为空") |
| | | private String tableComment; |
| | | |
| | | /** |
| | | * 关联父表的表名 |
| | | */ |
| | | private String subTableName; |
| | | |
| | | /** |
| | | * 本表关联父表的外键名 |
| | | */ |
| | | private String subTableFkName; |
| | | |
| | | /** |
| | | * 实体类名称(首字母大写) |
| | | */ |
| | | @NotBlank(message = "实体类名称不能为空") |
| | | private String className; |
| | | |
| | | /** |
| | | * 使用的模板(crud单表操作 tree树表操作 sub主子表操作) |
| | | */ |
| | | private String tplCategory; |
| | | |
| | | /** |
| | | * 生成包路径 |
| | | */ |
| | | @NotBlank(message = "生成包路径不能为空") |
| | | private String packageName; |
| | | |
| | | /** |
| | | * 生成模块名 |
| | | */ |
| | | @NotBlank(message = "生成模块名不能为空") |
| | | private String moduleName; |
| | | |
| | | /** |
| | | * 生成业务名 |
| | | */ |
| | | @NotBlank(message = "生成业务名不能为空") |
| | | private String businessName; |
| | | |
| | | /** |
| | | * 生成功能名 |
| | | */ |
| | | @NotBlank(message = "生成功能名不能为空") |
| | | private String functionName; |
| | | |
| | | /** |
| | | * 生成作者 |
| | | */ |
| | | @NotBlank(message = "作者不能为空") |
| | | private String functionAuthor; |
| | | |
| | | /** |
| | | * 生成代码方式(0zip压缩包 1自定义路径) |
| | | */ |
| | | private String genType; |
| | | |
| | | /** |
| | | * 生成路径(不填默认项目路径) |
| | | */ |
| | | @TableField(updateStrategy = FieldStrategy.NOT_EMPTY) |
| | | private String genPath; |
| | | |
| | | /** |
| | | * 主键信息 |
| | | */ |
| | | @TableField(exist = false) |
| | | private GenTableColumn pkColumn; |
| | | |
| | | /** |
| | | * 表列信息 |
| | | */ |
| | | @Valid |
| | | @TableField(exist = false) |
| | | private List<GenTableColumn> columns; |
| | | |
| | | /** |
| | | * 其它生成选项 |
| | | */ |
| | | private String options; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 树编码字段 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String treeCode; |
| | | |
| | | /** |
| | | * 树父编码字段 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String treeParentCode; |
| | | |
| | | /** |
| | | * 树名称字段 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String treeName; |
| | | |
| | | /* |
| | | * 菜单id列表 |
| | | */ |
| | | @TableField(exist = false) |
| | | private List<Long> menuIds; |
| | | |
| | | /** |
| | | * 上级菜单ID字段 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String parentMenuId; |
| | | |
| | | /** |
| | | * 上级菜单名称字段 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String parentMenuName; |
| | | |
| | | public boolean isTree() { |
| | | return isTree(this.tplCategory); |
| | | } |
| | | |
| | | public static boolean isTree(String tplCategory) { |
| | | return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory); |
| | | } |
| | | |
| | | public boolean isCrud() { |
| | | return isCrud(this.tplCategory); |
| | | } |
| | | |
| | | public static boolean isCrud(String tplCategory) { |
| | | return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory); |
| | | } |
| | | |
| | | public boolean isSuperColumn(String javaField) { |
| | | return isSuperColumn(this.tplCategory, javaField); |
| | | } |
| | | |
| | | public static boolean isSuperColumn(String tplCategory, String javaField) { |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.gen.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldStrategy; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.apache.ibatis.type.JdbcType; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * 代码生成业务字段表 gen_table_column |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("gen_table_column") |
| | | public class GenTableColumn extends BaseEntity { |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @TableId(value = "column_id") |
| | | private Long columnId; |
| | | |
| | | /** |
| | | * 归属表编号 |
| | | */ |
| | | private Long tableId; |
| | | |
| | | /** |
| | | * 列名称 |
| | | */ |
| | | private String columnName; |
| | | |
| | | /** |
| | | * 列描述 |
| | | */ |
| | | @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
| | | private String columnComment; |
| | | |
| | | /** |
| | | * 列类型 |
| | | */ |
| | | private String columnType; |
| | | |
| | | /** |
| | | * JAVA类型 |
| | | */ |
| | | private String javaType; |
| | | |
| | | /** |
| | | * JAVA字段名 |
| | | */ |
| | | @NotBlank(message = "Java属性不能为空") |
| | | private String javaField; |
| | | |
| | | /** |
| | | * 是否主键(1是) |
| | | */ |
| | | @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
| | | private String isPk; |
| | | |
| | | /** |
| | | * 是否自增(1是) |
| | | */ |
| | | @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
| | | private String isIncrement; |
| | | |
| | | /** |
| | | * 是否必填(1是) |
| | | */ |
| | | @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
| | | private String isRequired; |
| | | |
| | | /** |
| | | * 是否为插入字段(1是) |
| | | */ |
| | | @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
| | | private String isInsert; |
| | | |
| | | /** |
| | | * 是否编辑字段(1是) |
| | | */ |
| | | @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
| | | private String isEdit; |
| | | |
| | | /** |
| | | * 是否列表字段(1是) |
| | | */ |
| | | @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
| | | private String isList; |
| | | |
| | | /** |
| | | * 是否查询字段(1是) |
| | | */ |
| | | @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) |
| | | private String isQuery; |
| | | |
| | | /** |
| | | * 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) |
| | | */ |
| | | private String queryType; |
| | | |
| | | /** |
| | | * 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件) |
| | | */ |
| | | private String htmlType; |
| | | |
| | | /** |
| | | * 字典类型 |
| | | */ |
| | | private String dictType; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | private Integer sort; |
| | | |
| | | public String getCapJavaField() { |
| | | return StringUtils.capitalize(javaField); |
| | | } |
| | | |
| | | public boolean isPk() { |
| | | return isPk(this.isPk); |
| | | } |
| | | |
| | | public boolean isPk(String isPk) { |
| | | return isPk != null && StringUtils.equals("1", isPk); |
| | | } |
| | | |
| | | public boolean isIncrement() { |
| | | return isIncrement(this.isIncrement); |
| | | } |
| | | |
| | | public boolean isIncrement(String isIncrement) { |
| | | return isIncrement != null && StringUtils.equals("1", isIncrement); |
| | | } |
| | | |
| | | public boolean isRequired() { |
| | | return isRequired(this.isRequired); |
| | | } |
| | | |
| | | public boolean isRequired(String isRequired) { |
| | | return isRequired != null && StringUtils.equals("1", isRequired); |
| | | } |
| | | |
| | | public boolean isInsert() { |
| | | return isInsert(this.isInsert); |
| | | } |
| | | |
| | | public boolean isInsert(String isInsert) { |
| | | return isInsert != null && StringUtils.equals("1", isInsert); |
| | | } |
| | | |
| | | public boolean isEdit() { |
| | | return isInsert(this.isEdit); |
| | | } |
| | | |
| | | public boolean isEdit(String isEdit) { |
| | | return isEdit != null && StringUtils.equals("1", isEdit); |
| | | } |
| | | |
| | | public boolean isList() { |
| | | return isList(this.isList); |
| | | } |
| | | |
| | | public boolean isList(String isList) { |
| | | return isList != null && StringUtils.equals("1", isList); |
| | | } |
| | | |
| | | public boolean isQuery() { |
| | | return isQuery(this.isQuery); |
| | | } |
| | | |
| | | public boolean isQuery(String isQuery) { |
| | | return isQuery != null && StringUtils.equals("1", isQuery); |
| | | } |
| | | |
| | | public boolean isSuperColumn() { |
| | | return isSuperColumn(this.javaField); |
| | | } |
| | | |
| | | public static boolean isSuperColumn(String javaField) { |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, |
| | | // BaseEntity |
| | | "createBy", "createTime", "updateBy", "updateTime", |
| | | // TreeEntity |
| | | "parentName", "parentId"); |
| | | } |
| | | |
| | | public boolean isUsableColumn() { |
| | | return isUsableColumn(javaField); |
| | | } |
| | | |
| | | public static boolean isUsableColumn(String javaField) { |
| | | // isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单 |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark"); |
| | | } |
| | | |
| | | public String readConverterExp() { |
| | | String remarks = StringUtils.substringBetween(this.columnComment, "(", ")"); |
| | | StringBuffer sb = new StringBuffer(); |
| | | if (StringUtils.isNotEmpty(remarks)) { |
| | | for (String value : remarks.split(" ")) { |
| | | if (StringUtils.isNotEmpty(value)) { |
| | | Object startStr = value.subSequence(0, 1); |
| | | String endStr = value.substring(1); |
| | | sb.append(StringUtils.EMPTY).append(startStr).append("=").append(endStr).append(StringUtils.SEPARATOR); |
| | | } |
| | | } |
| | | return sb.deleteCharAt(sb.length() - 1).toString(); |
| | | } else { |
| | | return this.columnComment; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.gen.mapper; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.gen.domain.GenTableColumn; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 业务字段 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @InterceptorIgnore(dataPermission = "true", tenantLine = "true") |
| | | public interface GenTableColumnMapper extends BaseMapperPlus<GenTableColumn, GenTableColumn> { |
| | | /** |
| | | * 根据表名称查询列信息 |
| | | * |
| | | * @param tableName 表名称 |
| | | * @param dataName 数据源名称 |
| | | * @return 列信息 |
| | | */ |
| | | @DS("#dataName") |
| | | List<GenTableColumn> selectDbTableColumnsByName(@Param("tableName") String tableName, String dataName); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.gen.mapper; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.gen.domain.GenTable; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 业务 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @InterceptorIgnore(dataPermission = "true", tenantLine = "true") |
| | | public interface GenTableMapper extends BaseMapperPlus<GenTable, GenTable> { |
| | | |
| | | /** |
| | | * 查询据库列表 |
| | | * |
| | | * @param genTable 查询条件 |
| | | * @return 数据库表集合 |
| | | */ |
| | | Page<GenTable> selectPageDbTableList(@Param("page") Page<GenTable> page, @Param("genTable") GenTable genTable); |
| | | |
| | | /** |
| | | * 查询据库列表 |
| | | * |
| | | * @param tableNames 表名称组 |
| | | * @return 数据库表集合 |
| | | */ |
| | | List<GenTable> selectDbTableListByNames(String[] tableNames); |
| | | |
| | | /** |
| | | * 查询所有表信息 |
| | | * |
| | | * @return 表信息集合 |
| | | */ |
| | | List<GenTable> selectGenTableAll(); |
| | | |
| | | /** |
| | | * 查询表ID业务信息 |
| | | * |
| | | * @param id 业务ID |
| | | * @return 业务信息 |
| | | */ |
| | | GenTable selectGenTableById(Long id); |
| | | |
| | | /** |
| | | * 查询表名称业务信息 |
| | | * |
| | | * @param tableName 表名称 |
| | | * @return 业务信息 |
| | | */ |
| | | GenTable selectGenTableByName(String tableName); |
| | | |
| | | @DS("") |
| | | List<String> selectTableNameList(String dataName); |
| | | } |
New file |
| | |
| | | package org.dromara.gen.service; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.lang.Dict; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.velocity.Template; |
| | | import org.apache.velocity.VelocityContext; |
| | | import org.apache.velocity.app.Velocity; |
| | | import org.dromara.common.core.constant.Constants; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.StreamUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.core.utils.file.FileUtils; |
| | | import org.dromara.common.json.utils.JsonUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.satoken.utils.LoginHelper; |
| | | import org.dromara.gen.constant.GenConstants; |
| | | import org.dromara.gen.domain.GenTable; |
| | | import org.dromara.gen.domain.GenTableColumn; |
| | | import org.dromara.gen.mapper.GenTableColumnMapper; |
| | | import org.dromara.gen.mapper.GenTableMapper; |
| | | import org.dromara.gen.util.GenUtils; |
| | | import org.dromara.gen.util.VelocityInitializer; |
| | | import org.dromara.gen.util.VelocityUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.StringWriter; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.*; |
| | | import java.util.zip.ZipEntry; |
| | | import java.util.zip.ZipOutputStream; |
| | | |
| | | /** |
| | | * 业务 服务层实现 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class GenTableServiceImpl implements IGenTableService { |
| | | |
| | | private final GenTableMapper baseMapper; |
| | | private final GenTableColumnMapper genTableColumnMapper; |
| | | private final IdentifierGenerator identifierGenerator; |
| | | |
| | | /** |
| | | * 查询业务字段列表 |
| | | * |
| | | * @param tableId 业务字段编号 |
| | | * @return 业务字段集合 |
| | | */ |
| | | @Override |
| | | public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) { |
| | | return genTableColumnMapper.selectList(new LambdaQueryWrapper<GenTableColumn>() |
| | | .eq(GenTableColumn::getTableId, tableId) |
| | | .orderByAsc(GenTableColumn::getSort)); |
| | | } |
| | | |
| | | /** |
| | | * 查询业务信息 |
| | | * |
| | | * @param id 业务ID |
| | | * @return 业务信息 |
| | | */ |
| | | @Override |
| | | public GenTable selectGenTableById(Long id) { |
| | | GenTable genTable = baseMapper.selectGenTableById(id); |
| | | setTableFromOptions(genTable); |
| | | return genTable; |
| | | } |
| | | |
| | | @Override |
| | | public TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery) { |
| | | Page<GenTable> page = baseMapper.selectPage(pageQuery.build(), this.buildGenTableQueryWrapper(genTable)); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | private QueryWrapper<GenTable> buildGenTableQueryWrapper(GenTable genTable) { |
| | | Map<String, Object> params = genTable.getParams(); |
| | | QueryWrapper<GenTable> wrapper = Wrappers.query(); |
| | | wrapper |
| | | .eq(StringUtils.isNotEmpty(genTable.getDataName()),"data_name", genTable.getDataName()) |
| | | .like(StringUtils.isNotBlank(genTable.getTableName()), "lower(table_name)", StringUtils.lowerCase(genTable.getTableName())) |
| | | .like(StringUtils.isNotBlank(genTable.getTableComment()), "lower(table_comment)", StringUtils.lowerCase(genTable.getTableComment())) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | "create_time", params.get("beginTime"), params.get("endTime")); |
| | | return wrapper; |
| | | } |
| | | |
| | | @DS("#genTable.dataName") |
| | | @Override |
| | | public TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery) { |
| | | genTable.getParams().put("genTableNames",baseMapper.selectTableNameList(genTable.getDataName())); |
| | | Page<GenTable> page = baseMapper.selectPageDbTableList(pageQuery.build(), genTable); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | | * 查询据库列表 |
| | | * |
| | | * @param tableNames 表名称组 |
| | | * @param dataName 数据源名称 |
| | | * @return 数据库表集合 |
| | | */ |
| | | @DS("#dataName") |
| | | @Override |
| | | public List<GenTable> selectDbTableListByNames(String[] tableNames, String dataName) { |
| | | return baseMapper.selectDbTableListByNames(tableNames); |
| | | } |
| | | |
| | | /** |
| | | * 查询所有表信息 |
| | | * |
| | | * @return 表信息集合 |
| | | */ |
| | | @Override |
| | | public List<GenTable> selectGenTableAll() { |
| | | return baseMapper.selectGenTableAll(); |
| | | } |
| | | |
| | | /** |
| | | * 修改业务 |
| | | * |
| | | * @param genTable 业务信息 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void updateGenTable(GenTable genTable) { |
| | | String options = JsonUtils.toJsonString(genTable.getParams()); |
| | | genTable.setOptions(options); |
| | | int row = baseMapper.updateById(genTable); |
| | | if (row > 0) { |
| | | for (GenTableColumn cenTableColumn : genTable.getColumns()) { |
| | | genTableColumnMapper.updateById(cenTableColumn); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除业务对象 |
| | | * |
| | | * @param tableIds 需要删除的数据ID |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void deleteGenTableByIds(Long[] tableIds) { |
| | | List<Long> ids = Arrays.asList(tableIds); |
| | | baseMapper.deleteBatchIds(ids); |
| | | genTableColumnMapper.delete(new LambdaQueryWrapper<GenTableColumn>().in(GenTableColumn::getTableId, ids)); |
| | | } |
| | | |
| | | /** |
| | | * 导入表结构 |
| | | * |
| | | * @param tableList 导入表列表 |
| | | * @param dataName 数据源名称 |
| | | */ |
| | | @DSTransactional |
| | | @Override |
| | | public void importGenTable(List<GenTable> tableList, String dataName) { |
| | | Long operId = LoginHelper.getUserId(); |
| | | try { |
| | | for (GenTable table : tableList) { |
| | | String tableName = table.getTableName(); |
| | | GenUtils.initTable(table, operId); |
| | | table.setDataName(dataName); |
| | | int row = baseMapper.insert(table); |
| | | if (row > 0) { |
| | | // 保存列信息 |
| | | List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName, dataName); |
| | | List<GenTableColumn> saveColumns = new ArrayList<>(); |
| | | for (GenTableColumn column : genTableColumns) { |
| | | GenUtils.initColumnField(column, table); |
| | | saveColumns.add(column); |
| | | } |
| | | if (CollUtil.isNotEmpty(saveColumns)) { |
| | | genTableColumnMapper.insertBatch(saveColumns); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | throw new ServiceException("导入失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 预览代码 |
| | | * |
| | | * @param tableId 表编号 |
| | | * @return 预览数据列表 |
| | | */ |
| | | @Override |
| | | public Map<String, String> previewCode(Long tableId) { |
| | | Map<String, String> dataMap = new LinkedHashMap<>(); |
| | | // 查询表信息 |
| | | GenTable table = baseMapper.selectGenTableById(tableId); |
| | | List<Long> menuIds = new ArrayList<>(); |
| | | for (int i = 0; i < 6; i++) { |
| | | menuIds.add(identifierGenerator.nextId(null).longValue()); |
| | | } |
| | | table.setMenuIds(menuIds); |
| | | // 设置主键列信息 |
| | | setPkColumn(table); |
| | | VelocityInitializer.initVelocity(); |
| | | |
| | | VelocityContext context = VelocityUtils.prepareContext(table); |
| | | |
| | | // 获取模板列表 |
| | | List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); |
| | | for (String template : templates) { |
| | | // 渲染模板 |
| | | StringWriter sw = new StringWriter(); |
| | | Template tpl = Velocity.getTemplate(template, Constants.UTF8); |
| | | tpl.merge(context, sw); |
| | | dataMap.put(template, sw.toString()); |
| | | } |
| | | return dataMap; |
| | | } |
| | | |
| | | /** |
| | | * 生成代码(下载方式) |
| | | * |
| | | * @param tableId 表名称 |
| | | * @return 数据 |
| | | */ |
| | | @Override |
| | | public byte[] downloadCode(Long tableId) { |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | ZipOutputStream zip = new ZipOutputStream(outputStream); |
| | | generatorCode(tableId, zip); |
| | | IoUtil.close(zip); |
| | | return outputStream.toByteArray(); |
| | | } |
| | | |
| | | /** |
| | | * 生成代码(自定义路径) |
| | | * |
| | | * @param tableId 表名称 |
| | | */ |
| | | @Override |
| | | public void generatorCode(Long tableId) { |
| | | // 查询表信息 |
| | | GenTable table = baseMapper.selectGenTableById(tableId); |
| | | // 设置主键列信息 |
| | | setPkColumn(table); |
| | | |
| | | VelocityInitializer.initVelocity(); |
| | | |
| | | VelocityContext context = VelocityUtils.prepareContext(table); |
| | | |
| | | // 获取模板列表 |
| | | List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); |
| | | for (String template : templates) { |
| | | if (!StringUtils.containsAny(template, "sql.vm", "api.ts.vm", "types.ts.vm", "index.vue.vm", "index-tree.vue.vm")) { |
| | | // 渲染模板 |
| | | StringWriter sw = new StringWriter(); |
| | | Template tpl = Velocity.getTemplate(template, Constants.UTF8); |
| | | tpl.merge(context, sw); |
| | | try { |
| | | String path = getGenPath(table, template); |
| | | FileUtils.writeUtf8String(sw.toString(), path); |
| | | } catch (Exception e) { |
| | | throw new ServiceException("渲染模板失败,表名:" + table.getTableName()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 同步数据库 |
| | | * |
| | | * @param tableId 表名称 |
| | | */ |
| | | @DSTransactional |
| | | @Override |
| | | public void synchDb(Long tableId) { |
| | | GenTable table = baseMapper.selectGenTableById(tableId); |
| | | List<GenTableColumn> tableColumns = table.getColumns(); |
| | | Map<String, GenTableColumn> tableColumnMap = StreamUtils.toIdentityMap(tableColumns, GenTableColumn::getColumnName); |
| | | |
| | | List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(table.getTableName(), table.getDataName()); |
| | | if (CollUtil.isEmpty(dbTableColumns)) { |
| | | throw new ServiceException("同步数据失败,原表结构不存在"); |
| | | } |
| | | List<String> dbTableColumnNames = StreamUtils.toList(dbTableColumns, GenTableColumn::getColumnName); |
| | | |
| | | List<GenTableColumn> saveColumns = new ArrayList<>(); |
| | | dbTableColumns.forEach(column -> { |
| | | GenUtils.initColumnField(column, table); |
| | | if (tableColumnMap.containsKey(column.getColumnName())) { |
| | | GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName()); |
| | | column.setColumnId(prevColumn.getColumnId()); |
| | | if (column.isList()) { |
| | | // 如果是列表,继续保留查询方式/字典类型选项 |
| | | column.setDictType(prevColumn.getDictType()); |
| | | column.setQueryType(prevColumn.getQueryType()); |
| | | } |
| | | if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk() |
| | | && (column.isInsert() || column.isEdit()) |
| | | && ((column.isUsableColumn()) || (!column.isSuperColumn()))) { |
| | | // 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项 |
| | | column.setIsRequired(prevColumn.getIsRequired()); |
| | | column.setHtmlType(prevColumn.getHtmlType()); |
| | | } |
| | | } |
| | | saveColumns.add(column); |
| | | }); |
| | | if (CollUtil.isNotEmpty(saveColumns)) { |
| | | genTableColumnMapper.insertOrUpdateBatch(saveColumns); |
| | | } |
| | | List<GenTableColumn> delColumns = StreamUtils.filter(tableColumns, column -> !dbTableColumnNames.contains(column.getColumnName())); |
| | | if (CollUtil.isNotEmpty(delColumns)) { |
| | | List<Long> ids = StreamUtils.toList(delColumns, GenTableColumn::getColumnId); |
| | | if (CollUtil.isNotEmpty(ids)) { |
| | | genTableColumnMapper.deleteBatchIds(ids); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 批量生成代码(下载方式) |
| | | * |
| | | * @param tableIds 表ID数组 |
| | | * @return 数据 |
| | | */ |
| | | @Override |
| | | public byte[] downloadCode(String[] tableIds) { |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | ZipOutputStream zip = new ZipOutputStream(outputStream); |
| | | for (String tableId : tableIds) { |
| | | generatorCode(Long.parseLong(tableId), zip); |
| | | } |
| | | IoUtil.close(zip); |
| | | return outputStream.toByteArray(); |
| | | } |
| | | |
| | | /** |
| | | * 查询表信息并生成代码 |
| | | */ |
| | | private void generatorCode(Long tableId, ZipOutputStream zip) { |
| | | // 查询表信息 |
| | | GenTable table = baseMapper.selectGenTableById(tableId); |
| | | List<Long> menuIds = new ArrayList<>(); |
| | | for (int i = 0; i < 6; i++) { |
| | | menuIds.add(identifierGenerator.nextId(null).longValue()); |
| | | } |
| | | table.setMenuIds(menuIds); |
| | | // 设置主键列信息 |
| | | setPkColumn(table); |
| | | |
| | | VelocityInitializer.initVelocity(); |
| | | |
| | | VelocityContext context = VelocityUtils.prepareContext(table); |
| | | |
| | | // 获取模板列表 |
| | | List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); |
| | | for (String template : templates) { |
| | | // 渲染模板 |
| | | StringWriter sw = new StringWriter(); |
| | | Template tpl = Velocity.getTemplate(template, Constants.UTF8); |
| | | tpl.merge(context, sw); |
| | | try { |
| | | // 添加到zip |
| | | zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); |
| | | IoUtil.write(zip, StandardCharsets.UTF_8, false, sw.toString()); |
| | | IoUtil.close(sw); |
| | | zip.flush(); |
| | | zip.closeEntry(); |
| | | } catch (IOException e) { |
| | | log.error("渲染模板失败,表名:" + table.getTableName(), e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改保存参数校验 |
| | | * |
| | | * @param genTable 业务信息 |
| | | */ |
| | | @Override |
| | | public void validateEdit(GenTable genTable) { |
| | | if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) { |
| | | String options = JsonUtils.toJsonString(genTable.getParams()); |
| | | Dict paramsObj = JsonUtils.parseMap(options); |
| | | if (StringUtils.isEmpty(paramsObj.getStr(GenConstants.TREE_CODE))) { |
| | | throw new ServiceException("树编码字段不能为空"); |
| | | } else if (StringUtils.isEmpty(paramsObj.getStr(GenConstants.TREE_PARENT_CODE))) { |
| | | throw new ServiceException("树父编码字段不能为空"); |
| | | } else if (StringUtils.isEmpty(paramsObj.getStr(GenConstants.TREE_NAME))) { |
| | | throw new ServiceException("树名称字段不能为空"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置主键列信息 |
| | | * |
| | | * @param table 业务表信息 |
| | | */ |
| | | public void setPkColumn(GenTable table) { |
| | | for (GenTableColumn column : table.getColumns()) { |
| | | if (column.isPk()) { |
| | | table.setPkColumn(column); |
| | | break; |
| | | } |
| | | } |
| | | if (ObjectUtil.isNull(table.getPkColumn())) { |
| | | table.setPkColumn(table.getColumns().get(0)); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 设置代码生成其他选项值 |
| | | * |
| | | * @param genTable 设置后的生成对象 |
| | | */ |
| | | public void setTableFromOptions(GenTable genTable) { |
| | | Dict paramsObj = JsonUtils.parseMap(genTable.getOptions()); |
| | | if (ObjectUtil.isNotNull(paramsObj)) { |
| | | String treeCode = paramsObj.getStr(GenConstants.TREE_CODE); |
| | | String treeParentCode = paramsObj.getStr(GenConstants.TREE_PARENT_CODE); |
| | | String treeName = paramsObj.getStr(GenConstants.TREE_NAME); |
| | | String parentMenuId = paramsObj.getStr(GenConstants.PARENT_MENU_ID); |
| | | String parentMenuName = paramsObj.getStr(GenConstants.PARENT_MENU_NAME); |
| | | |
| | | genTable.setTreeCode(treeCode); |
| | | genTable.setTreeParentCode(treeParentCode); |
| | | genTable.setTreeName(treeName); |
| | | genTable.setParentMenuId(parentMenuId); |
| | | genTable.setParentMenuName(parentMenuName); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取代码生成地址 |
| | | * |
| | | * @param table 业务表信息 |
| | | * @param template 模板文件路径 |
| | | * @return 生成地址 |
| | | */ |
| | | public static String getGenPath(GenTable table, String template) { |
| | | String genPath = table.getGenPath(); |
| | | if (StringUtils.equals(genPath, "/")) { |
| | | return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table); |
| | | } |
| | | return genPath + File.separator + VelocityUtils.getFileName(template, table); |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | package org.dromara.gen.service; |
| | | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.gen.domain.GenTable; |
| | | import org.dromara.gen.domain.GenTableColumn; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 业务 服务层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface IGenTableService { |
| | | |
| | | /** |
| | | * 查询业务字段列表 |
| | | * |
| | | * @param tableId 业务字段编号 |
| | | * @return 业务字段集合 |
| | | */ |
| | | List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId); |
| | | |
| | | /** |
| | | * 查询业务列表 |
| | | * |
| | | * @param genTable 业务信息 |
| | | * @return 业务集合 |
| | | */ |
| | | TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 查询据库列表 |
| | | * |
| | | * @param genTable 业务信息 |
| | | * @return 数据库表集合 |
| | | */ |
| | | TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 查询据库列表 |
| | | * |
| | | * @param tableNames 表名称组 |
| | | * @param dataName 数据源名称 |
| | | * @return 数据库表集合 |
| | | */ |
| | | List<GenTable> selectDbTableListByNames(String[] tableNames, String dataName); |
| | | |
| | | /** |
| | | * 查询所有表信息 |
| | | * |
| | | * @return 表信息集合 |
| | | */ |
| | | List<GenTable> selectGenTableAll(); |
| | | |
| | | /** |
| | | * 查询业务信息 |
| | | * |
| | | * @param id 业务ID |
| | | * @return 业务信息 |
| | | */ |
| | | GenTable selectGenTableById(Long id); |
| | | |
| | | /** |
| | | * 修改业务 |
| | | * |
| | | * @param genTable 业务信息 |
| | | */ |
| | | void updateGenTable(GenTable genTable); |
| | | |
| | | /** |
| | | * 删除业务信息 |
| | | * |
| | | * @param tableIds 需要删除的表数据ID |
| | | */ |
| | | void deleteGenTableByIds(Long[] tableIds); |
| | | |
| | | /** |
| | | * 导入表结构 |
| | | * |
| | | * @param tableList 导入表列表 |
| | | * @param dataName 数据源名称 |
| | | */ |
| | | void importGenTable(List<GenTable> tableList, String dataName); |
| | | |
| | | /** |
| | | * 预览代码 |
| | | * |
| | | * @param tableId 表编号 |
| | | * @return 预览数据列表 |
| | | */ |
| | | Map<String, String> previewCode(Long tableId); |
| | | |
| | | /** |
| | | * 生成代码(下载方式) |
| | | * |
| | | * @param tableId 表名称 |
| | | * @return 数据 |
| | | */ |
| | | byte[] downloadCode(Long tableId); |
| | | |
| | | /** |
| | | * 生成代码(自定义路径) |
| | | * |
| | | * @param tableId 表名称 |
| | | */ |
| | | void generatorCode(Long tableId); |
| | | |
| | | /** |
| | | * 同步数据库 |
| | | * |
| | | * @param tableId 表名称 |
| | | */ |
| | | void synchDb(Long tableId); |
| | | |
| | | /** |
| | | * 批量生成代码(下载方式) |
| | | * |
| | | * @param tableIds 表ID数组 |
| | | * @return 数据 |
| | | */ |
| | | byte[] downloadCode(String[] tableIds); |
| | | |
| | | /** |
| | | * 修改保存参数校验 |
| | | * |
| | | * @param genTable 业务信息 |
| | | */ |
| | | void validateEdit(GenTable genTable); |
| | | } |
New file |
| | |
| | | package org.dromara.gen.util; |
| | | |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | import org.apache.commons.lang3.RegExUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.gen.config.GenConfig; |
| | | import org.dromara.gen.constant.GenConstants; |
| | | import org.dromara.gen.domain.GenTable; |
| | | import org.dromara.gen.domain.GenTableColumn; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * 代码生成器 工具类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class GenUtils { |
| | | |
| | | /** |
| | | * 初始化表信息 |
| | | */ |
| | | public static void initTable(GenTable genTable, Long operId) { |
| | | genTable.setClassName(convertClassName(genTable.getTableName())); |
| | | genTable.setPackageName(GenConfig.getPackageName()); |
| | | genTable.setModuleName(getModuleName(GenConfig.getPackageName())); |
| | | genTable.setBusinessName(getBusinessName(genTable.getTableName())); |
| | | genTable.setFunctionName(replaceText(genTable.getTableComment())); |
| | | genTable.setFunctionAuthor(GenConfig.getAuthor()); |
| | | genTable.setCreateBy(operId); |
| | | } |
| | | |
| | | /** |
| | | * 初始化列属性字段 |
| | | */ |
| | | public static void initColumnField(GenTableColumn column, GenTable table) { |
| | | String dataType = getDbType(column.getColumnType()); |
| | | String columnName = column.getColumnName(); |
| | | column.setTableId(table.getTableId()); |
| | | column.setCreateBy(table.getCreateBy()); |
| | | // 设置java字段名 |
| | | column.setJavaField(StringUtils.toCamelCase(columnName)); |
| | | // 设置默认类型 |
| | | column.setJavaType(GenConstants.TYPE_STRING); |
| | | column.setQueryType(GenConstants.QUERY_EQ); |
| | | |
| | | if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) { |
| | | // 字符串长度超过500设置为文本域 |
| | | Integer columnLength = getColumnLength(column.getColumnType()); |
| | | String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT; |
| | | column.setHtmlType(htmlType); |
| | | } else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) { |
| | | column.setJavaType(GenConstants.TYPE_DATE); |
| | | column.setHtmlType(GenConstants.HTML_DATETIME); |
| | | } else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) { |
| | | column.setHtmlType(GenConstants.HTML_INPUT); |
| | | |
| | | // 如果是浮点型 统一用BigDecimal |
| | | String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), StringUtils.SEPARATOR); |
| | | if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) { |
| | | column.setJavaType(GenConstants.TYPE_BIGDECIMAL); |
| | | } |
| | | // 如果是整形 |
| | | else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) { |
| | | column.setJavaType(GenConstants.TYPE_INTEGER); |
| | | } |
| | | // 长整形 |
| | | else { |
| | | column.setJavaType(GenConstants.TYPE_LONG); |
| | | } |
| | | } |
| | | |
| | | // BO对象 默认插入勾选 |
| | | if (!arraysContains(GenConstants.COLUMNNAME_NOT_ADD, columnName) && !column.isPk()) { |
| | | column.setIsInsert(GenConstants.REQUIRE); |
| | | } |
| | | // BO对象 默认编辑勾选 |
| | | if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName)) { |
| | | column.setIsEdit(GenConstants.REQUIRE); |
| | | } |
| | | // BO对象 默认是否必填勾选 |
| | | if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName)) { |
| | | column.setIsRequired(GenConstants.REQUIRE); |
| | | } |
| | | // VO对象 默认返回勾选 |
| | | if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName)) { |
| | | column.setIsList(GenConstants.REQUIRE); |
| | | } |
| | | // BO对象 默认查询勾选 |
| | | if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) { |
| | | column.setIsQuery(GenConstants.REQUIRE); |
| | | } |
| | | |
| | | // 查询字段类型 |
| | | if (StringUtils.endsWithIgnoreCase(columnName, "name")) { |
| | | column.setQueryType(GenConstants.QUERY_LIKE); |
| | | } |
| | | // 状态字段设置单选框 |
| | | if (StringUtils.endsWithIgnoreCase(columnName, "status")) { |
| | | column.setHtmlType(GenConstants.HTML_RADIO); |
| | | } |
| | | // 类型&性别字段设置下拉框 |
| | | else if (StringUtils.endsWithIgnoreCase(columnName, "type") |
| | | || StringUtils.endsWithIgnoreCase(columnName, "sex")) { |
| | | column.setHtmlType(GenConstants.HTML_SELECT); |
| | | } |
| | | // 图片字段设置图片上传控件 |
| | | else if (StringUtils.endsWithIgnoreCase(columnName, "image")) { |
| | | column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD); |
| | | } |
| | | // 文件字段设置文件上传控件 |
| | | else if (StringUtils.endsWithIgnoreCase(columnName, "file")) { |
| | | column.setHtmlType(GenConstants.HTML_FILE_UPLOAD); |
| | | } |
| | | // 内容字段设置富文本控件 |
| | | else if (StringUtils.endsWithIgnoreCase(columnName, "content")) { |
| | | column.setHtmlType(GenConstants.HTML_EDITOR); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 校验数组是否包含指定值 |
| | | * |
| | | * @param arr 数组 |
| | | * @param targetValue 值 |
| | | * @return 是否包含 |
| | | */ |
| | | public static boolean arraysContains(String[] arr, String targetValue) { |
| | | return Arrays.asList(arr).contains(targetValue); |
| | | } |
| | | |
| | | /** |
| | | * 获取模块名 |
| | | * |
| | | * @param packageName 包名 |
| | | * @return 模块名 |
| | | */ |
| | | public static String getModuleName(String packageName) { |
| | | int lastIndex = packageName.lastIndexOf("."); |
| | | int nameLength = packageName.length(); |
| | | return StringUtils.substring(packageName, lastIndex + 1, nameLength); |
| | | } |
| | | |
| | | /** |
| | | * 获取业务名 |
| | | * |
| | | * @param tableName 表名 |
| | | * @return 业务名 |
| | | */ |
| | | public static String getBusinessName(String tableName) { |
| | | int firstIndex = tableName.indexOf("_"); |
| | | int nameLength = tableName.length(); |
| | | String businessName = StringUtils.substring(tableName, firstIndex + 1, nameLength); |
| | | businessName = StringUtils.toCamelCase(businessName); |
| | | return businessName; |
| | | } |
| | | |
| | | /** |
| | | * 表名转换成Java类名 |
| | | * |
| | | * @param tableName 表名称 |
| | | * @return 类名 |
| | | */ |
| | | public static String convertClassName(String tableName) { |
| | | boolean autoRemovePre = GenConfig.getAutoRemovePre(); |
| | | String tablePrefix = GenConfig.getTablePrefix(); |
| | | if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) { |
| | | String[] searchList = StringUtils.split(tablePrefix, StringUtils.SEPARATOR); |
| | | tableName = replaceFirst(tableName, searchList); |
| | | } |
| | | return StringUtils.convertToCamelCase(tableName); |
| | | } |
| | | |
| | | /** |
| | | * 批量替换前缀 |
| | | * |
| | | * @param replacementm 替换值 |
| | | * @param searchList 替换列表 |
| | | */ |
| | | public static String replaceFirst(String replacementm, String[] searchList) { |
| | | String text = replacementm; |
| | | for (String searchString : searchList) { |
| | | if (replacementm.startsWith(searchString)) { |
| | | text = replacementm.replaceFirst(searchString, StringUtils.EMPTY); |
| | | break; |
| | | } |
| | | } |
| | | return text; |
| | | } |
| | | |
| | | /** |
| | | * 关键字替换 |
| | | * |
| | | * @param text 需要被替换的名字 |
| | | * @return 替换后的名字 |
| | | */ |
| | | public static String replaceText(String text) { |
| | | return RegExUtils.replaceAll(text, "(?:表|若依)", ""); |
| | | } |
| | | |
| | | /** |
| | | * 获取数据库类型字段 |
| | | * |
| | | * @param columnType 列类型 |
| | | * @return 截取后的列类型 |
| | | */ |
| | | public static String getDbType(String columnType) { |
| | | if (StringUtils.indexOf(columnType, "(") > 0) { |
| | | return StringUtils.substringBefore(columnType, "("); |
| | | } else { |
| | | return columnType; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取字段长度 |
| | | * |
| | | * @param columnType 列类型 |
| | | * @return 截取后的列类型 |
| | | */ |
| | | public static Integer getColumnLength(String columnType) { |
| | | if (StringUtils.indexOf(columnType, "(") > 0) { |
| | | String length = StringUtils.substringBetween(columnType, "(", ")"); |
| | | return Integer.valueOf(length); |
| | | } else { |
| | | return 0; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.gen.util; |
| | | |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | import org.apache.velocity.app.Velocity; |
| | | import org.dromara.common.core.constant.Constants; |
| | | |
| | | import java.util.Properties; |
| | | |
| | | /** |
| | | * VelocityEngine工厂 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class VelocityInitializer { |
| | | |
| | | /** |
| | | * 初始化vm方法 |
| | | */ |
| | | public static void initVelocity() { |
| | | Properties p = new Properties(); |
| | | try { |
| | | // 加载classpath目录下的vm文件 |
| | | p.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); |
| | | // 定义字符集 |
| | | p.setProperty(Velocity.INPUT_ENCODING, Constants.UTF8); |
| | | // 初始化Velocity引擎,指定配置Properties |
| | | Velocity.init(p); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.gen.util; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.lang.Dict; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | import org.apache.velocity.VelocityContext; |
| | | import org.dromara.common.core.utils.DateUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.json.utils.JsonUtils; |
| | | import org.dromara.common.mybatis.helper.DataBaseHelper; |
| | | import org.dromara.gen.constant.GenConstants; |
| | | import org.dromara.gen.domain.GenTable; |
| | | import org.dromara.gen.domain.GenTableColumn; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 模板处理工具类 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class VelocityUtils { |
| | | |
| | | /** |
| | | * 项目空间路径 |
| | | */ |
| | | private static final String PROJECT_PATH = "main/java"; |
| | | |
| | | /** |
| | | * mybatis空间路径 |
| | | */ |
| | | private static final String MYBATIS_PATH = "main/resources/mapper"; |
| | | |
| | | /** |
| | | * 默认上级菜单,系统工具 |
| | | */ |
| | | private static final String DEFAULT_PARENT_MENU_ID = "3"; |
| | | |
| | | /** |
| | | * 设置模板变量信息 |
| | | * |
| | | * @return 模板列表 |
| | | */ |
| | | public static VelocityContext prepareContext(GenTable genTable) { |
| | | String moduleName = genTable.getModuleName(); |
| | | String businessName = genTable.getBusinessName(); |
| | | String packageName = genTable.getPackageName(); |
| | | String tplCategory = genTable.getTplCategory(); |
| | | String functionName = genTable.getFunctionName(); |
| | | |
| | | VelocityContext velocityContext = new VelocityContext(); |
| | | velocityContext.put("tplCategory", genTable.getTplCategory()); |
| | | velocityContext.put("tableName", genTable.getTableName()); |
| | | velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】"); |
| | | velocityContext.put("ClassName", genTable.getClassName()); |
| | | velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName())); |
| | | velocityContext.put("moduleName", genTable.getModuleName()); |
| | | velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName())); |
| | | velocityContext.put("businessName", genTable.getBusinessName()); |
| | | velocityContext.put("basePackage", getPackagePrefix(packageName)); |
| | | velocityContext.put("packageName", packageName); |
| | | velocityContext.put("author", genTable.getFunctionAuthor()); |
| | | velocityContext.put("datetime", DateUtils.getDate()); |
| | | velocityContext.put("pkColumn", genTable.getPkColumn()); |
| | | velocityContext.put("importList", getImportList(genTable)); |
| | | velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName)); |
| | | velocityContext.put("columns", genTable.getColumns()); |
| | | velocityContext.put("table", genTable); |
| | | velocityContext.put("dicts", getDicts(genTable)); |
| | | setMenuVelocityContext(velocityContext, genTable); |
| | | if (GenConstants.TPL_TREE.equals(tplCategory)) { |
| | | setTreeVelocityContext(velocityContext, genTable); |
| | | } |
| | | return velocityContext; |
| | | } |
| | | |
| | | public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) { |
| | | String options = genTable.getOptions(); |
| | | Dict paramsObj = JsonUtils.parseMap(options); |
| | | String parentMenuId = getParentMenuId(paramsObj); |
| | | context.put("parentMenuId", parentMenuId); |
| | | } |
| | | |
| | | public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) { |
| | | String options = genTable.getOptions(); |
| | | Dict paramsObj = JsonUtils.parseMap(options); |
| | | String treeCode = getTreecode(paramsObj); |
| | | String treeParentCode = getTreeParentCode(paramsObj); |
| | | String treeName = getTreeName(paramsObj); |
| | | |
| | | context.put("treeCode", treeCode); |
| | | context.put("treeParentCode", treeParentCode); |
| | | context.put("treeName", treeName); |
| | | context.put("expandColumn", getExpandColumn(genTable)); |
| | | if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) { |
| | | context.put("tree_parent_code", paramsObj.get(GenConstants.TREE_PARENT_CODE)); |
| | | } |
| | | if (paramsObj.containsKey(GenConstants.TREE_NAME)) { |
| | | context.put("tree_name", paramsObj.get(GenConstants.TREE_NAME)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取模板信息 |
| | | * |
| | | * @return 模板列表 |
| | | */ |
| | | public static List<String> getTemplateList(String tplCategory) { |
| | | List<String> templates = new ArrayList<>(); |
| | | templates.add("vm/java/domain.java.vm"); |
| | | templates.add("vm/java/vo.java.vm"); |
| | | templates.add("vm/java/bo.java.vm"); |
| | | templates.add("vm/java/mapper.java.vm"); |
| | | templates.add("vm/java/service.java.vm"); |
| | | templates.add("vm/java/serviceImpl.java.vm"); |
| | | templates.add("vm/java/controller.java.vm"); |
| | | templates.add("vm/xml/mapper.xml.vm"); |
| | | if (DataBaseHelper.isOracle()) { |
| | | templates.add("vm/sql/oracle/sql.vm"); |
| | | } else if (DataBaseHelper.isPostgerSql()) { |
| | | templates.add("vm/sql/postgres/sql.vm"); |
| | | } else { |
| | | templates.add("vm/sql/sql.vm"); |
| | | } |
| | | templates.add("vm/ts/api.ts.vm"); |
| | | templates.add("vm/ts/types.ts.vm"); |
| | | if (GenConstants.TPL_CRUD.equals(tplCategory)) { |
| | | templates.add("vm/vue/index.vue.vm"); |
| | | } else if (GenConstants.TPL_TREE.equals(tplCategory)) { |
| | | templates.add("vm/vue/index-tree.vue.vm"); |
| | | } |
| | | return templates; |
| | | } |
| | | |
| | | /** |
| | | * 获取文件名 |
| | | */ |
| | | public static String getFileName(String template, GenTable genTable) { |
| | | // 文件名称 |
| | | String fileName = ""; |
| | | // 包路径 |
| | | String packageName = genTable.getPackageName(); |
| | | // 模块名 |
| | | String moduleName = genTable.getModuleName(); |
| | | // 大写类名 |
| | | String className = genTable.getClassName(); |
| | | // 业务名称 |
| | | String businessName = genTable.getBusinessName(); |
| | | |
| | | String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/"); |
| | | String mybatisPath = MYBATIS_PATH + "/" + moduleName; |
| | | String vuePath = "vue"; |
| | | |
| | | if (template.contains("domain.java.vm")) { |
| | | fileName = StringUtils.format("{}/domain/{}.java", javaPath, className); |
| | | } |
| | | if (template.contains("vo.java.vm")) { |
| | | fileName = StringUtils.format("{}/domain/vo/{}Vo.java", javaPath, className); |
| | | } |
| | | if (template.contains("bo.java.vm")) { |
| | | fileName = StringUtils.format("{}/domain/bo/{}Bo.java", javaPath, className); |
| | | } |
| | | if (template.contains("mapper.java.vm")) { |
| | | fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className); |
| | | } else if (template.contains("service.java.vm")) { |
| | | fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className); |
| | | } else if (template.contains("serviceImpl.java.vm")) { |
| | | fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className); |
| | | } else if (template.contains("controller.java.vm")) { |
| | | fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className); |
| | | } else if (template.contains("mapper.xml.vm")) { |
| | | fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className); |
| | | } else if (template.contains("sql.vm")) { |
| | | fileName = businessName + "Menu.sql"; |
| | | } else if (template.contains("api.ts.vm")) { |
| | | fileName = StringUtils.format("{}/api/{}/{}/index.ts", vuePath, moduleName, businessName); |
| | | } else if (template.contains("types.ts.vm")) { |
| | | fileName = StringUtils.format("{}/api/{}/{}/types.ts", vuePath, moduleName, businessName); |
| | | } else if (template.contains("index.vue.vm")) { |
| | | fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); |
| | | } else if (template.contains("index-tree.vue.vm")) { |
| | | fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); |
| | | } |
| | | return fileName; |
| | | } |
| | | |
| | | /** |
| | | * 获取包前缀 |
| | | * |
| | | * @param packageName 包名称 |
| | | * @return 包前缀名称 |
| | | */ |
| | | public static String getPackagePrefix(String packageName) { |
| | | int lastIndex = packageName.lastIndexOf("."); |
| | | return StringUtils.substring(packageName, 0, lastIndex); |
| | | } |
| | | |
| | | /** |
| | | * 根据列类型获取导入包 |
| | | * |
| | | * @param genTable 业务表对象 |
| | | * @return 返回需要导入的包列表 |
| | | */ |
| | | public static HashSet<String> getImportList(GenTable genTable) { |
| | | List<GenTableColumn> columns = genTable.getColumns(); |
| | | HashSet<String> importList = new HashSet<>(); |
| | | for (GenTableColumn column : columns) { |
| | | if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) { |
| | | importList.add("java.util.Date"); |
| | | importList.add("com.fasterxml.jackson.annotation.JsonFormat"); |
| | | } else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) { |
| | | importList.add("java.math.BigDecimal"); |
| | | } |
| | | } |
| | | return importList; |
| | | } |
| | | |
| | | /** |
| | | * 根据列类型获取字典组 |
| | | * |
| | | * @param genTable 业务表对象 |
| | | * @return 返回字典组 |
| | | */ |
| | | public static String getDicts(GenTable genTable) { |
| | | List<GenTableColumn> columns = genTable.getColumns(); |
| | | Set<String> dicts = new HashSet<>(); |
| | | addDicts(dicts, columns); |
| | | return StringUtils.join(dicts, ", "); |
| | | } |
| | | |
| | | /** |
| | | * 添加字典列表 |
| | | * |
| | | * @param dicts 字典列表 |
| | | * @param columns 列集合 |
| | | */ |
| | | public static void addDicts(Set<String> dicts, List<GenTableColumn> columns) { |
| | | for (GenTableColumn column : columns) { |
| | | if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny( |
| | | column.getHtmlType(), |
| | | new String[] { GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX })) { |
| | | dicts.add("'" + column.getDictType() + "'"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取权限前缀 |
| | | * |
| | | * @param moduleName 模块名称 |
| | | * @param businessName 业务名称 |
| | | * @return 返回权限前缀 |
| | | */ |
| | | public static String getPermissionPrefix(String moduleName, String businessName) { |
| | | return StringUtils.format("{}:{}", moduleName, businessName); |
| | | } |
| | | |
| | | /** |
| | | * 获取上级菜单ID字段 |
| | | * |
| | | * @param paramsObj 生成其他选项 |
| | | * @return 上级菜单ID字段 |
| | | */ |
| | | public static String getParentMenuId(Dict paramsObj) { |
| | | if (CollUtil.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID) |
| | | && StringUtils.isNotEmpty(paramsObj.getStr(GenConstants.PARENT_MENU_ID))) { |
| | | return paramsObj.getStr(GenConstants.PARENT_MENU_ID); |
| | | } |
| | | return DEFAULT_PARENT_MENU_ID; |
| | | } |
| | | |
| | | /** |
| | | * 获取树编码 |
| | | * |
| | | * @param paramsObj 生成其他选项 |
| | | * @return 树编码 |
| | | */ |
| | | public static String getTreecode(Map<String, Object> paramsObj) { |
| | | if (CollUtil.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_CODE)) { |
| | | return StringUtils.toCamelCase(Convert.toStr(paramsObj.get(GenConstants.TREE_CODE))); |
| | | } |
| | | return StringUtils.EMPTY; |
| | | } |
| | | |
| | | /** |
| | | * 获取树父编码 |
| | | * |
| | | * @param paramsObj 生成其他选项 |
| | | * @return 树父编码 |
| | | */ |
| | | public static String getTreeParentCode(Dict paramsObj) { |
| | | if (CollUtil.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) { |
| | | return StringUtils.toCamelCase(paramsObj.getStr(GenConstants.TREE_PARENT_CODE)); |
| | | } |
| | | return StringUtils.EMPTY; |
| | | } |
| | | |
| | | /** |
| | | * 获取树名称 |
| | | * |
| | | * @param paramsObj 生成其他选项 |
| | | * @return 树名称 |
| | | */ |
| | | public static String getTreeName(Dict paramsObj) { |
| | | if (CollUtil.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_NAME)) { |
| | | return StringUtils.toCamelCase(paramsObj.getStr(GenConstants.TREE_NAME)); |
| | | } |
| | | return StringUtils.EMPTY; |
| | | } |
| | | |
| | | /** |
| | | * 获取需要在哪一列上面显示展开按钮 |
| | | * |
| | | * @param genTable 业务表对象 |
| | | * @return 展开按钮列序号 |
| | | */ |
| | | public static int getExpandColumn(GenTable genTable) { |
| | | String options = genTable.getOptions(); |
| | | Dict paramsObj = JsonUtils.parseMap(options); |
| | | String treeName = paramsObj.getStr(GenConstants.TREE_NAME); |
| | | int num = 0; |
| | | for (GenTableColumn column : genTable.getColumns()) { |
| | | if (column.isList()) { |
| | | num++; |
| | | String columnName = column.getColumnName(); |
| | | if (columnName.equals(treeName)) { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return num; |
| | | } |
| | | } |
New file |
| | |
| | | # Tomcat |
| | | server: |
| | | port: 9202 |
| | | |
| | | # Spring |
| | | spring: |
| | | application: |
| | | # 应用名称 |
| | | name: ruoyi-gen |
| | | profiles: |
| | | # 环境配置 |
| | | active: @profiles.active@ |
| | | |
| | | --- # nacos 配置 |
| | | spring: |
| | | cloud: |
| | | nacos: |
| | | # nacos 服务地址 |
| | | server-addr: @nacos.server@ |
| | | discovery: |
| | | # 注册组 |
| | | group: @nacos.discovery.group@ |
| | | namespace: ${spring.profiles.active} |
| | | config: |
| | | # 配置组 |
| | | group: @nacos.config.group@ |
| | | namespace: ${spring.profiles.active} |
| | | config: |
| | | import: |
| | | - optional:nacos:application-common.yml |
| | | - optional:nacos:datasource.yml |
| | | - optional:nacos:${spring.application.name}.yml |
New file |
| | |
| | | Spring Boot Version: ${spring-boot.version} |
| | | Spring Application Name: ${spring.application.name} |
| | | _ |
| | | (_) |
| | | _ __ _ _ ___ _ _ _ ______ __ _ ___ _ __ |
| | | | '__|| | | | / _ \ | | | || ||______| / _` | / _ \| '_ \ |
| | | | | | |_| || (_) || |_| || | | (_| || __/| | | | |
| | | |_| \__,_| \___/ \__, ||_| \__, | \___||_| |_| |
| | | __/ | __/ | |
| | | |___/ |___/ |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <configuration scan="true" scanPeriod="60 seconds" debug="false"> |
| | | <!-- 日志存放路径 --> |
| | | <property name="log.path" value="logs/${project.artifactId}"/> |
| | | <!-- 日志输出格式 --> |
| | | <property name="console.log.pattern" |
| | | value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/> |
| | | |
| | | <!-- 控制台输出 --> |
| | | <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> |
| | | <encoder> |
| | | <pattern>${console.log.pattern}</pattern> |
| | | <charset>utf-8</charset> |
| | | </encoder> |
| | | </appender> |
| | | |
| | | <include resource="logback-common.xml" /> |
| | | |
| | | <include resource="logback-logstash.xml" /> |
| | | |
| | | <!--系统操作日志--> |
| | | <root level="info"> |
| | | <appender-ref ref="console"/> |
| | | </root> |
| | | </configuration> |
New file |
| | |
| | | <?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.dromara.gen.mapper.GenTableColumnMapper"> |
| | | |
| | | <resultMap type="org.dromara.gen.domain.GenTableColumn" id="GenTableColumnResult"> |
| | | </resultMap> |
| | | |
| | | <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult"> |
| | | <if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isMySql()"> |
| | | select column_name, |
| | | (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else '0' end) as is_required, |
| | | (case when column_key = 'PRI' then '1' else '0' end) as is_pk, |
| | | ordinal_position as sort, |
| | | column_comment, |
| | | (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, |
| | | column_type |
| | | from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName}) |
| | | order by ordinal_position |
| | | </if> |
| | | <if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isOracle()"> |
| | | select lower(temp.column_name) as column_name, |
| | | (case when (temp.nullable = 'N' and temp.constraint_type != 'P') then '1' else '0' end) as is_required, |
| | | (case when temp.constraint_type = 'P' then '1' else '0' end) as is_pk, |
| | | temp.column_id as sort, |
| | | temp.comments as column_comment, |
| | | (case when temp.constraint_type = 'P' then '1' else '0' end) as is_increment, |
| | | lower(temp.data_type) as column_type |
| | | from ( |
| | | select col.column_id, col.column_name,col.nullable, col.data_type, colc.comments, uc.constraint_type, row_number() |
| | | over (partition by col.column_name order by uc.constraint_type desc) as row_flg |
| | | from user_tab_columns col |
| | | left join user_col_comments colc on colc.table_name = col.table_name and colc.column_name = col.column_name |
| | | left join user_cons_columns ucc on ucc.table_name = col.table_name and ucc.column_name = col.column_name |
| | | left join user_constraints uc on uc.constraint_name = ucc.constraint_name |
| | | where col.table_name = upper(#{tableName}) |
| | | ) temp |
| | | WHERE temp.row_flg = 1 |
| | | ORDER BY temp.column_id |
| | | </if> |
| | | <if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isPostgerSql()"> |
| | | SELECT column_name, is_required, is_pk, sort, column_comment, is_increment, column_type |
| | | FROM ( |
| | | SELECT c.relname AS table_name, |
| | | a.attname AS column_name, |
| | | d.description AS column_comment, |
| | | CASE WHEN a.attnotnull AND con.conname IS NULL THEN 1 ELSE 0 |
| | | END AS is_required, |
| | | CASE WHEN con.conname IS NOT NULL THEN 1 ELSE 0 |
| | | END AS is_pk, |
| | | a.attnum AS sort, |
| | | CASE WHEN "position"(pg_get_expr(ad.adbin, ad.adrelid), |
| | | ((c.relname::text || '_'::text) || a.attname::text) || '_seq'::text) > 0 THEN 1 ELSE 0 |
| | | END AS is_increment, |
| | | btrim( |
| | | CASE WHEN t.typelem <![CDATA[ <> ]]> 0::oid AND t.typlen = '-1'::integer THEN 'ARRAY'::text ELSE |
| | | CASE WHEN t.typtype = 'd'::"char" THEN format_type(t.typbasetype, NULL::integer) |
| | | ELSE format_type(a.atttypid, NULL::integer) END |
| | | END, '"'::text |
| | | ) AS column_type |
| | | FROM pg_attribute a |
| | | JOIN (pg_class c JOIN pg_namespace n ON c.relnamespace = n.oid) ON a.attrelid = c.oid |
| | | LEFT JOIN pg_description d ON d.objoid = c.oid AND a.attnum = d.objsubid |
| | | LEFT JOIN pg_constraint con ON con.conrelid = c.oid AND (a.attnum = ANY (con.conkey)) |
| | | LEFT JOIN pg_attrdef ad ON a.attrelid = ad.adrelid AND a.attnum = ad.adnum |
| | | LEFT JOIN pg_type t ON a.atttypid = t.oid |
| | | WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"])) |
| | | AND a.attnum > 0 |
| | | AND n.nspname = 'public'::name |
| | | ORDER BY c.relname, a.attnum |
| | | ) temp |
| | | WHERE table_name = (#{tableName}) |
| | | AND column_type <![CDATA[ <> ]]> '-' |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?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.dromara.gen.mapper.GenTableMapper"> |
| | | |
| | | <!-- 多结构嵌套自动映射需带上每个实体的主键id 否则映射会失败 --> |
| | | <resultMap type="org.dromara.gen.domain.GenTable" id="GenTableResult"> |
| | | <id property="tableId" column="table_id" /> |
| | | <collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" /> |
| | | </resultMap> |
| | | |
| | | <resultMap type="org.dromara.gen.domain.GenTableColumn" id="GenTableColumnResult"> |
| | | <id property="columnId" column="column_id"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectPageDbTableList" resultMap="GenTableResult"> |
| | | <if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isMySql()"> |
| | | select table_name, table_comment, create_time, update_time |
| | | from information_schema.tables |
| | | where table_schema = (select database()) |
| | | AND table_name NOT LIKE 'xxl_job_%' AND table_name NOT LIKE 'gen_%' |
| | | <if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0"> |
| | | AND table_name NOT IN |
| | | <foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | <if test="genTable.tableName != null and genTable.tableName != ''"> |
| | | AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%')) |
| | | </if> |
| | | <if test="genTable.tableComment != null and genTable.tableComment != ''"> |
| | | AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%')) |
| | | </if> |
| | | order by create_time desc |
| | | </if> |
| | | <if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isOracle()"> |
| | | select lower(dt.table_name) as table_name, dtc.comments as table_comment, uo.created as create_time, uo.last_ddl_time as update_time |
| | | from user_tables dt, user_tab_comments dtc, user_objects uo |
| | | where dt.table_name = dtc.table_name |
| | | and dt.table_name = uo.object_name |
| | | and uo.object_type = 'TABLE' |
| | | AND dt.table_name NOT LIKE 'XXL_JOB_%' AND dt.table_name NOT LIKE 'GEN_%' |
| | | <if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0"> |
| | | AND lower(dt.table_name) NOT IN |
| | | <foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | <if test="genTable.tableName != null and genTable.tableName != ''"> |
| | | AND lower(dt.table_name) like lower(concat(concat('%', #{genTable.tableName}), '%')) |
| | | </if> |
| | | <if test="genTable.tableComment != null and genTable.tableComment != ''"> |
| | | AND lower(dtc.comments) like lower(concat(concat('%', #{genTable.tableComment}), '%')) |
| | | </if> |
| | | order by create_time desc |
| | | </if> |
| | | <if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isPostgerSql()"> |
| | | select table_name, table_comment, create_time, update_time |
| | | from ( |
| | | SELECT c.relname AS table_name, |
| | | obj_description(c.oid) AS table_comment, |
| | | CURRENT_TIMESTAMP AS create_time, |
| | | CURRENT_TIMESTAMP AS update_time |
| | | FROM pg_class c |
| | | LEFT JOIN pg_namespace n ON n.oid = c.relnamespace |
| | | WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"])) |
| | | AND c.relname != 'spatial_%'::text |
| | | AND n.nspname = 'public'::name |
| | | AND n.nspname <![CDATA[ <> ]]> ''::name |
| | | ) list_table |
| | | where table_name NOT LIKE 'xxl_job_%' AND table_name NOT LIKE 'gen_%' |
| | | <if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0"> |
| | | AND table_name NOT IN |
| | | <foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | <if test="genTable.tableName != null and genTable.tableName != ''"> |
| | | AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%')) |
| | | </if> |
| | | <if test="genTable.tableComment != null and genTable.tableComment != ''"> |
| | | AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%')) |
| | | </if> |
| | | order by create_time desc |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="selectDbTableListByNames" resultMap="GenTableResult"> |
| | | <if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isMySql()"> |
| | | select table_name, table_comment, create_time, update_time from information_schema.tables |
| | | where table_name NOT LIKE 'xxl_job_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database()) |
| | | and table_name in |
| | | <foreach collection="array" item="name" open="(" separator="," close=")"> |
| | | #{name} |
| | | </foreach> |
| | | </if> |
| | | <if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isOracle()"> |
| | | select lower(dt.table_name) as table_name, dtc.comments as table_comment, uo.created as create_time, uo.last_ddl_time as update_time |
| | | from user_tables dt, user_tab_comments dtc, user_objects uo |
| | | where dt.table_name = dtc.table_name |
| | | and dt.table_name = uo.object_name |
| | | and uo.object_type = 'TABLE' |
| | | AND dt.table_name NOT LIKE 'XXL_JOB_%' AND dt.table_name NOT LIKE 'GEN_%' |
| | | and lower(dt.table_name) in |
| | | <foreach collection="array" item="name" open="(" separator="," close=")"> |
| | | #{name} |
| | | </foreach> |
| | | </if> |
| | | <if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isPostgerSql()"> |
| | | select table_name, table_comment, create_time, update_time |
| | | from ( |
| | | SELECT c.relname AS table_name, |
| | | obj_description(c.oid) AS table_comment, |
| | | CURRENT_TIMESTAMP AS create_time, |
| | | CURRENT_TIMESTAMP AS update_time |
| | | FROM pg_class c |
| | | LEFT JOIN pg_namespace n ON n.oid = c.relnamespace |
| | | WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"])) |
| | | AND c.relname != 'spatial_%'::text |
| | | AND n.nspname = 'public'::name |
| | | AND n.nspname <![CDATA[ <> ]]> ''::name |
| | | ) list_table |
| | | where table_name NOT LIKE 'xxl_job_%' and table_name NOT LIKE 'gen_%' |
| | | and table_name in |
| | | <foreach collection="array" item="name" open="(" separator="," close=")"> |
| | | #{name} |
| | | </foreach> |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="selectTableByName" parameterType="String" resultMap="GenTableResult"> |
| | | <if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isMySql()"> |
| | | select table_name, table_comment, create_time, update_time from information_schema.tables |
| | | where table_name NOT LIKE 'xxl_job_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database()) |
| | | and table_name = #{tableName} |
| | | </if> |
| | | <if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isOracle()"> |
| | | select lower(dt.table_name) as table_name, dtc.comments as table_comment, uo.created as create_time, uo.last_ddl_time as update_time |
| | | from user_tables dt, user_tab_comments dtc, user_objects uo |
| | | where dt.table_name = dtc.table_name |
| | | and dt.table_name = uo.object_name |
| | | and uo.object_type = 'TABLE' |
| | | AND dt.table_name NOT LIKE 'XXL_JOB_%' AND dt.table_name NOT LIKE 'GEN_%' |
| | | AND dt.table_name NOT IN (select table_name from gen_table) |
| | | and lower(dt.table_name) = #{tableName} |
| | | </if> |
| | | <if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isPostgerSql()"> |
| | | select table_name, table_comment, create_time, update_time |
| | | from ( |
| | | SELECT c.relname AS table_name, |
| | | obj_description(c.oid) AS table_comment, |
| | | CURRENT_TIMESTAMP AS create_time, |
| | | CURRENT_TIMESTAMP AS update_time |
| | | FROM pg_class c |
| | | LEFT JOIN pg_namespace n ON n.oid = c.relnamespace |
| | | WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"])) |
| | | AND c.relname != 'spatial_%'::text |
| | | AND n.nspname = 'public'::name |
| | | AND n.nspname <![CDATA[ <> ]]> ''::name |
| | | ) list_table |
| | | where table_name NOT LIKE 'xxl_job_%' and table_name NOT LIKE 'gen_%' |
| | | and table_name = #{tableName} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult"> |
| | | SELECT t.table_id, t.data_name, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, |
| | | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort |
| | | FROM gen_table t |
| | | LEFT JOIN gen_table_column c ON t.table_id = c.table_id |
| | | where t.table_id = #{tableId} order by c.sort |
| | | </select> |
| | | |
| | | <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult"> |
| | | SELECT t.table_id, t.data_name, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, |
| | | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort |
| | | FROM gen_table t |
| | | LEFT JOIN gen_table_column c ON t.table_id = c.table_id |
| | | where t.table_name = #{tableName} order by c.sort |
| | | </select> |
| | | |
| | | <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult"> |
| | | SELECT t.table_id, t.data_name, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark, |
| | | c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort |
| | | FROM gen_table t |
| | | LEFT JOIN gen_table_column c ON t.table_id = c.table_id |
| | | order by c.sort |
| | | </select> |
| | | |
| | | <select id="selectTableNameList" resultType="java.lang.String"> |
| | | select table_name from gen_table where data_name = #{dataName,jdbcType=VARCHAR} |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | java包使用 `.` 分割 resource 目录使用 `/` 分割 |
| | | <br> |
| | | 此文件目的 防止文件夹粘连找不到 `xml` 文件 |
New file |
| | |
| | | # p6spy 性能分析插件配置文件 |
| | | modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory |
| | | # 自定义日志打印 |
| | | logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger |
| | | #日志输出到控制台 |
| | | appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger |
| | | # 使用日志系统记录 sql |
| | | #appender=com.p6spy.engine.spy.appender.Slf4JLogger |
| | | # 设置 p6spy driver 代理 |
| | | #deregisterdrivers=true |
| | | # 取消JDBC URL前缀 |
| | | useprefix=true |
| | | # 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset. |
| | | excludecategories=info,debug,result,commit,resultset |
| | | # 日期格式 |
| | | dateformat=yyyy-MM-dd HH:mm:ss |
| | | # SQL语句打印时间格式 |
| | | databaseDialectTimestampFormat=yyyy-MM-dd HH:mm:ss |
| | | # 实际驱动可多个 |
| | | #driverlist=org.h2.Driver |
| | | # 是否开启慢SQL记录 |
| | | outagedetection=true |
| | | # 慢SQL记录标准 2 秒 |
| | | outagedetectioninterval=2 |
| | | # 是否过滤 Log |
| | | filter=true |
| | | # 过滤 Log 时所排除的 sql 关键字,以逗号分隔 |
| | | exclude=SELECT 1 |
New file |
| | |
| | | package ${packageName}.domain.bo; |
| | | |
| | | import ${packageName}.domain.${ClassName}; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import jakarta.validation.constraints.*; |
| | | #foreach ($import in $importList) |
| | | import ${import}; |
| | | #end |
| | | |
| | | /** |
| | | * ${functionName}业务对象 ${tableName} |
| | | * |
| | | * @author ${author} |
| | | * @date ${datetime} |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = ${ClassName}.class, reverseConvertGenerate = false) |
| | | public class ${ClassName}Bo extends BaseEntity { |
| | | |
| | | #foreach ($column in $columns) |
| | | #if(!$table.isSuperColumn($column.javaField) && ($column.query || $column.insert || $column.edit)) |
| | | /** |
| | | * $column.columnComment |
| | | */ |
| | | #if($column.insert && $column.edit) |
| | | #set($Group="AddGroup.class, EditGroup.class") |
| | | #elseif($column.insert) |
| | | #set($Group="AddGroup.class") |
| | | #elseif($column.edit) |
| | | #set($Group="EditGroup.class") |
| | | #end |
| | | #if($column.required) |
| | | #if($column.javaType == 'String') |
| | | @NotBlank(message = "$column.columnComment不能为空", groups = { $Group }) |
| | | #else |
| | | @NotNull(message = "$column.columnComment不能为空", groups = { $Group }) |
| | | #end |
| | | #end |
| | | private $column.javaType $column.javaField; |
| | | |
| | | #end |
| | | #end |
| | | |
| | | } |
New file |
| | |
| | | package ${packageName}.controller; |
| | | |
| | | import java.util.List; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.*; |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.dromara.common.idempotent.annotation.RepeatSubmit; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import ${packageName}.domain.vo.${ClassName}Vo; |
| | | import ${packageName}.domain.bo.${ClassName}Bo; |
| | | import ${packageName}.service.I${ClassName}Service; |
| | | #if($table.crud || $table.sub) |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | #elseif($table.tree) |
| | | #end |
| | | |
| | | /** |
| | | * ${functionName} |
| | | * 前端访问路由地址为:/${moduleName}/${businessName} |
| | | * |
| | | * @author ${author} |
| | | * @date ${datetime} |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/${businessName}") |
| | | public class ${ClassName}Controller extends BaseController { |
| | | |
| | | private final I${ClassName}Service ${className}Service; |
| | | |
| | | /** |
| | | * 查询${functionName}列表 |
| | | */ |
| | | @SaCheckPermission("${permissionPrefix}:list") |
| | | @GetMapping("/list") |
| | | #if($table.crud || $table.sub) |
| | | public TableDataInfo<${ClassName}Vo> list(${ClassName}Bo bo, PageQuery pageQuery) { |
| | | return ${className}Service.queryPageList(bo, pageQuery); |
| | | } |
| | | #elseif($table.tree) |
| | | public R<List<${ClassName}Vo>> list(${ClassName}Bo bo) { |
| | | List<${ClassName}Vo> list = ${className}Service.queryList(bo); |
| | | return R.ok(list); |
| | | } |
| | | #end |
| | | |
| | | /** |
| | | * 导出${functionName}列表 |
| | | */ |
| | | @SaCheckPermission("${permissionPrefix}:export") |
| | | @Log(title = "${functionName}", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(${ClassName}Bo bo, HttpServletResponse response) { |
| | | List<${ClassName}Vo> list = ${className}Service.queryList(bo); |
| | | ExcelUtil.exportExcel(list, "${functionName}", ${ClassName}Vo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 获取${functionName}详细信息 |
| | | * |
| | | * @param ${pkColumn.javaField} 主键 |
| | | */ |
| | | @SaCheckPermission("${permissionPrefix}:query") |
| | | @GetMapping("/{${pkColumn.javaField}}") |
| | | public R<${ClassName}Vo> getInfo(@NotNull(message = "主键不能为空") |
| | | @PathVariable ${pkColumn.javaType} ${pkColumn.javaField}) { |
| | | return R.ok(${className}Service.queryById(${pkColumn.javaField})); |
| | | } |
| | | |
| | | /** |
| | | * 新增${functionName} |
| | | */ |
| | | @SaCheckPermission("${permissionPrefix}:add") |
| | | @Log(title = "${functionName}", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit() |
| | | @PostMapping() |
| | | public R<Void> add(@Validated(AddGroup.class) @RequestBody ${ClassName}Bo bo) { |
| | | return toAjax(${className}Service.insertByBo(bo)); |
| | | } |
| | | |
| | | /** |
| | | * 修改${functionName} |
| | | */ |
| | | @SaCheckPermission("${permissionPrefix}:edit") |
| | | @Log(title = "${functionName}", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit() |
| | | @PutMapping() |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody ${ClassName}Bo bo) { |
| | | return toAjax(${className}Service.updateByBo(bo)); |
| | | } |
| | | |
| | | /** |
| | | * 删除${functionName} |
| | | * |
| | | * @param ${pkColumn.javaField}s 主键串 |
| | | */ |
| | | @SaCheckPermission("${permissionPrefix}:remove") |
| | | @Log(title = "${functionName}", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{${pkColumn.javaField}s}") |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) { |
| | | return toAjax(${className}Service.deleteWithValidByIds(List.of(${pkColumn.javaField}s), true)); |
| | | } |
| | | } |
New file |
| | |
| | | package ${packageName}.domain; |
| | | |
| | | #foreach ($column in $columns) |
| | | #if($column.javaField=='tenantId') |
| | | #set($IsTenant=1) |
| | | #end |
| | | #end |
| | | #if($IsTenant==1) |
| | | import org.dromara.common.tenant.core.TenantEntity; |
| | | #else |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | #end |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | #foreach ($import in $importList) |
| | | import ${import}; |
| | | #end |
| | | |
| | | import java.io.Serial; |
| | | |
| | | /** |
| | | * ${functionName}对象 ${tableName} |
| | | * |
| | | * @author ${author} |
| | | * @date ${datetime} |
| | | */ |
| | | #if($IsTenant==1) |
| | | #set($Entity="TenantEntity") |
| | | #else |
| | | #set($Entity="BaseEntity") |
| | | #end |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("${tableName}") |
| | | public class ${ClassName} extends ${Entity} { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | #foreach ($column in $columns) |
| | | #if(!$table.isSuperColumn($column.javaField)) |
| | | /** |
| | | * $column.columnComment |
| | | */ |
| | | #if($column.javaField=='delFlag') |
| | | @TableLogic |
| | | #end |
| | | #if($column.javaField=='version') |
| | | @Version |
| | | #end |
| | | #if($column.isPk==1) |
| | | @TableId(value = "$column.columnName") |
| | | #end |
| | | private $column.javaType $column.javaField; |
| | | |
| | | #end |
| | | #end |
| | | |
| | | } |
New file |
| | |
| | | package ${packageName}.mapper; |
| | | |
| | | import ${packageName}.domain.${ClassName}; |
| | | import ${packageName}.domain.vo.${ClassName}Vo; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | |
| | | /** |
| | | * ${functionName}Mapper接口 |
| | | * |
| | | * @author ${author} |
| | | * @date ${datetime} |
| | | */ |
| | | public interface ${ClassName}Mapper extends BaseMapperPlus<${ClassName}, ${ClassName}Vo> { |
| | | |
| | | } |
New file |
| | |
| | | package ${packageName}.service; |
| | | |
| | | import ${packageName}.domain.${ClassName}; |
| | | import ${packageName}.domain.vo.${ClassName}Vo; |
| | | import ${packageName}.domain.bo.${ClassName}Bo; |
| | | #if($table.crud || $table.sub) |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | #end |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ${functionName}Service接口 |
| | | * |
| | | * @author ${author} |
| | | * @date ${datetime} |
| | | */ |
| | | public interface I${ClassName}Service { |
| | | |
| | | /** |
| | | * 查询${functionName} |
| | | */ |
| | | ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}); |
| | | |
| | | #if($table.crud || $table.sub) |
| | | /** |
| | | * 查询${functionName}列表 |
| | | */ |
| | | TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery); |
| | | #end |
| | | |
| | | /** |
| | | * 查询${functionName}列表 |
| | | */ |
| | | List<${ClassName}Vo> queryList(${ClassName}Bo bo); |
| | | |
| | | /** |
| | | * 新增${functionName} |
| | | */ |
| | | Boolean insertByBo(${ClassName}Bo bo); |
| | | |
| | | /** |
| | | * 修改${functionName} |
| | | */ |
| | | Boolean updateByBo(${ClassName}Bo bo); |
| | | |
| | | /** |
| | | * 校验并批量删除${functionName}信息 |
| | | */ |
| | | Boolean deleteWithValidByIds(Collection<${pkColumn.javaType}> ids, Boolean isValid); |
| | | } |
New file |
| | |
| | | package ${packageName}.service.impl; |
| | | |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | #if($table.crud || $table.sub) |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | #end |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import ${packageName}.domain.bo.${ClassName}Bo; |
| | | import ${packageName}.domain.vo.${ClassName}Vo; |
| | | import ${packageName}.domain.${ClassName}; |
| | | import ${packageName}.mapper.${ClassName}Mapper; |
| | | import ${packageName}.service.I${ClassName}Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Collection; |
| | | |
| | | /** |
| | | * ${functionName}Service业务层处理 |
| | | * |
| | | * @author ${author} |
| | | * @date ${datetime} |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class ${ClassName}ServiceImpl implements I${ClassName}Service { |
| | | |
| | | private final ${ClassName}Mapper baseMapper; |
| | | |
| | | /** |
| | | * 查询${functionName} |
| | | */ |
| | | @Override |
| | | public ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}){ |
| | | return baseMapper.selectVoById(${pkColumn.javaField}); |
| | | } |
| | | |
| | | #if($table.crud || $table.sub) |
| | | /** |
| | | * 查询${functionName}列表 |
| | | */ |
| | | @Override |
| | | public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<${ClassName}> lqw = buildQueryWrapper(bo); |
| | | Page<${ClassName}Vo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | #end |
| | | |
| | | /** |
| | | * 查询${functionName}列表 |
| | | */ |
| | | @Override |
| | | public List<${ClassName}Vo> queryList(${ClassName}Bo bo) { |
| | | LambdaQueryWrapper<${ClassName}> lqw = buildQueryWrapper(bo); |
| | | return baseMapper.selectVoList(lqw); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName}Bo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery(); |
| | | #foreach($column in $columns) |
| | | #if($column.query) |
| | | #set($queryType=$column.queryType) |
| | | #set($javaField=$column.javaField) |
| | | #set($javaType=$column.javaType) |
| | | #set($columnName=$column.columnName) |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | #set($mpMethod=$column.queryType.toLowerCase()) |
| | | #if($queryType != 'BETWEEN') |
| | | #if($javaType == 'String') |
| | | #set($condition='StringUtils.isNotBlank(bo.get'+$AttrName+'())') |
| | | #else |
| | | #set($condition='bo.get'+$AttrName+'() != null') |
| | | #end |
| | | lqw.$mpMethod($condition, ${ClassName}::get$AttrName, bo.get$AttrName()); |
| | | #else |
| | | lqw.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null, |
| | | ${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName")); |
| | | #end |
| | | #end |
| | | #end |
| | | return lqw; |
| | | } |
| | | |
| | | /** |
| | | * 新增${functionName} |
| | | */ |
| | | @Override |
| | | public Boolean insertByBo(${ClassName}Bo bo) { |
| | | ${ClassName} add = MapstructUtils.convert(bo, ${ClassName}.class); |
| | | validEntityBeforeSave(add); |
| | | boolean flag = baseMapper.insert(add) > 0; |
| | | #set($pk=$pkColumn.javaField.substring(0,1).toUpperCase() + ${pkColumn.javaField.substring(1)}) |
| | | if (flag) { |
| | | bo.set$pk(add.get$pk()); |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * 修改${functionName} |
| | | */ |
| | | @Override |
| | | public Boolean updateByBo(${ClassName}Bo bo) { |
| | | ${ClassName} update = MapstructUtils.convert(bo, ${ClassName}.class); |
| | | validEntityBeforeSave(update); |
| | | return baseMapper.updateById(update) > 0; |
| | | } |
| | | |
| | | /** |
| | | * 保存前的数据校验 |
| | | */ |
| | | private void validEntityBeforeSave(${ClassName} entity){ |
| | | //TODO 做一些数据校验,如唯一约束 |
| | | } |
| | | |
| | | /** |
| | | * 批量删除${functionName} |
| | | */ |
| | | @Override |
| | | public Boolean deleteWithValidByIds(Collection<${pkColumn.javaType}> ids, Boolean isValid) { |
| | | if(isValid){ |
| | | //TODO 做一些业务上的校验,判断是否需要校验 |
| | | } |
| | | return baseMapper.deleteBatchIds(ids) > 0; |
| | | } |
| | | } |
New file |
| | |
| | | package ${packageName}.domain.vo; |
| | | |
| | | #foreach ($import in $importList) |
| | | import ${import}; |
| | | #end |
| | | import ${packageName}.domain.${ClassName}; |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | |
| | | |
| | | /** |
| | | * ${functionName}视图对象 ${tableName} |
| | | * |
| | | * @author ${author} |
| | | * @date ${datetime} |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | @AutoMapper(target = ${ClassName}.class) |
| | | public class ${ClassName}Vo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | #foreach ($column in $columns) |
| | | #if($column.list) |
| | | /** |
| | | * $column.columnComment |
| | | */ |
| | | #set($parentheseIndex=$column.columnComment.indexOf("(")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #if(${column.dictType} && ${column.dictType} != '') |
| | | @ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "${column.dictType}") |
| | | #elseif($parentheseIndex != -1) |
| | | @ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(readConverterExp = "$column.readConverterExp()") |
| | | #else |
| | | @ExcelProperty(value = "${comment}") |
| | | #end |
| | | private $column.javaType $column.javaField; |
| | | |
| | | #end |
| | | #end |
| | | |
| | | } |
New file |
| | |
| | | -- 菜单 SQL |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[0]}, '${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 103, 1, sysdate, null, null, '${functionName}菜单'); |
| | | |
| | | -- 按钮 SQL |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[1]}, '${functionName}查询', ${table.menuIds[0]}, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 103, 1, sysdate, null, null, ''); |
| | | |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[2]}, '${functionName}新增', ${table.menuIds[0]}, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 103, 1, sysdate, null, null, ''); |
| | | |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[3]}, '${functionName}修改', ${table.menuIds[0]}, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 103, 1, sysdate, null, null, ''); |
| | | |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[4]}, '${functionName}删除', ${table.menuIds[0]}, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 103, 1, sysdate, null, null, ''); |
| | | |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[5]}, '${functionName}导出', ${table.menuIds[0]}, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 103, 1, sysdate, null, null, ''); |
New file |
| | |
| | | -- 菜单 SQL |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[0]}, '${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 103, 1, now(), null, null, '${functionName}菜单'); |
| | | |
| | | -- 按钮 SQL |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[1]}, '${functionName}查询', ${table.menuIds[0]}, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 103, 1, now(), null, null, ''); |
| | | |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[2]}, '${functionName}新增', ${table.menuIds[0]}, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 103, 1, now(), null, null, ''); |
| | | |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[3]}, '${functionName}修改', ${table.menuIds[0]}, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 103, 1, now(), null, null, ''); |
| | | |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[4]}, '${functionName}删除', ${table.menuIds[0]}, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 103, 1, now(), null, null, ''); |
| | | |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[5]}, '${functionName}导出', ${table.menuIds[0]}, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 103, 1, now(), null, null, ''); |
| | | |
New file |
| | |
| | | -- 菜单 SQL |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[0]}, '${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 103, 1, sysdate(), null, null, '${functionName}菜单'); |
| | | |
| | | -- 按钮 SQL |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[1]}, '${functionName}查询', ${table.menuIds[0]}, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 103, 1, sysdate(), null, null, ''); |
| | | |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[2]}, '${functionName}新增', ${table.menuIds[0]}, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 103, 1, sysdate(), null, null, ''); |
| | | |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[3]}, '${functionName}修改', ${table.menuIds[0]}, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 103, 1, sysdate(), null, null, ''); |
| | | |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[4]}, '${functionName}删除', ${table.menuIds[0]}, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 103, 1, sysdate(), null, null, ''); |
| | | |
| | | insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) |
| | | values(${table.menuIds[5]}, '${functionName}导出', ${table.menuIds[0]}, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 103, 1, sysdate(), null, null, ''); |
New file |
| | |
| | | import request from '@/utils/request'; |
| | | import { AxiosPromise } from 'axios'; |
| | | import { ${BusinessName}VO, ${BusinessName}Form, ${BusinessName}Query } from '@/api/${moduleName}/${businessName}/types'; |
| | | |
| | | /** |
| | | * 查询${functionName}列表 |
| | | * @param query |
| | | * @returns {*} |
| | | */ |
| | | |
| | | export const list${BusinessName} = (query?: ${BusinessName}Query): AxiosPromise<${BusinessName}VO[]> => { |
| | | return request({ |
| | | url: '/${moduleName}/${businessName}/list', |
| | | method: 'get', |
| | | params: query |
| | | }); |
| | | }; |
| | | |
| | | /** |
| | | * 查询${functionName}详细 |
| | | * @param ${pkColumn.javaField} |
| | | */ |
| | | export const get${BusinessName} = (${pkColumn.javaField}: string | number): AxiosPromise<${BusinessName}VO> => { |
| | | return request({ |
| | | url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, |
| | | method: 'get' |
| | | }); |
| | | }; |
| | | |
| | | /** |
| | | * 新增${functionName} |
| | | * @param data |
| | | */ |
| | | export const add${BusinessName} = (data: ${BusinessName}Form) => { |
| | | return request({ |
| | | url: '/${moduleName}/${businessName}', |
| | | method: 'post', |
| | | data: data |
| | | }); |
| | | }; |
| | | |
| | | /** |
| | | * 修改${functionName} |
| | | * @param data |
| | | */ |
| | | export const update${BusinessName} = (data: ${BusinessName}Form) => { |
| | | return request({ |
| | | url: '/${moduleName}/${businessName}', |
| | | method: 'put', |
| | | data: data |
| | | }); |
| | | }; |
| | | |
| | | /** |
| | | * 删除${functionName} |
| | | * @param ${pkColumn.javaField} |
| | | */ |
| | | export const del${BusinessName} = (${pkColumn.javaField}: string | number | Array<string | number>) => { |
| | | return request({ |
| | | url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, |
| | | method: 'delete' |
| | | }); |
| | | }; |
New file |
| | |
| | | export interface ${BusinessName}VO { |
| | | #foreach ($column in $columns) |
| | | #if($column.insert || $column.edit) |
| | | /** |
| | | * $column.columnComment |
| | | */ |
| | | $column.javaField:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number; |
| | | #elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number; |
| | | #elseif($column.javaType == 'Boolean') boolean; |
| | | #else string; |
| | | #end |
| | | #end |
| | | #end |
| | | #if ($table.tree) |
| | | /** |
| | | * 子对象 |
| | | */ |
| | | children: ${BusinessName}VO[]; |
| | | #end |
| | | } |
| | | |
| | | export interface ${BusinessName}Form extends BaseEntity { |
| | | #foreach ($column in $columns) |
| | | #if($column.insert || $column.edit) |
| | | /** |
| | | * $column.columnComment |
| | | */ |
| | | $column.javaField?:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number; |
| | | #elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number; |
| | | #elseif($column.javaType == 'Boolean') boolean; |
| | | #else string; |
| | | #end |
| | | #end |
| | | #end |
| | | } |
| | | |
| | | export interface ${BusinessName}Query #if(!${treeCode})extends PageQuery #end{ |
| | | #foreach ($column in $columns) |
| | | #if($column.query) |
| | | /** |
| | | * $column.columnComment |
| | | */ |
| | | $column.javaField?:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number; |
| | | #elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number; |
| | | #elseif($column.javaType == 'Boolean') boolean; |
| | | #else string; |
| | | #end |
| | | #end |
| | | #end |
| | | } |
New file |
| | |
| | | <template> |
| | | <div class="p-2"> |
| | | <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> |
| | | <div class="search" v-show="showSearch"> |
| | | <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px"> |
| | | #foreach($column in $columns) |
| | | #if($column.query) |
| | | #set($dictType=$column.dictType) |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("(")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #if($column.htmlType == "input" || $column.htmlType == "textarea") |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-input v-model="queryParams.${column.javaField}" placeholder="请输入${comment}" clearable style="width: 240px" @keyup.enter="handleQuery" /> |
| | | </el-form-item> |
| | | #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> |
| | | <el-option |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> |
| | | <el-option label="请选择字典生成" value="" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-date-picker clearable |
| | | v-model="queryParams.${column.javaField}" |
| | | type="date" |
| | | value-format="YYYY-MM-DD" |
| | | placeholder="选择${comment}" |
| | | /> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | <el-form-item label="${comment}" style="width: 308px"> |
| | | <el-date-picker |
| | | v-model="dateRange${AttrName}" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]" |
| | | /> |
| | | </el-form-item> |
| | | #end |
| | | #end |
| | | #end |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | </transition> |
| | | |
| | | <el-card shadow="never"> |
| | | <template #header> |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button type="primary" plain icon="Plus" @click="handleAdd()" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="info" plain icon="Sort" @click="handleToggleExpandAll">展开/折叠</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | </template> |
| | | <el-table |
| | | v-loading="loading" |
| | | :data="${businessName}List" |
| | | row-key="${treeCode}" |
| | | :default-expand-all="isExpandAll" |
| | | :tree-props="{children: 'children', hasChildren: 'hasChildren'}" |
| | | ref="${businessName}TableRef" |
| | | > |
| | | #foreach($column in $columns) |
| | | #set($javaField=$column.javaField) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("(")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #if($column.pk) |
| | | #elseif($column.list && $column.htmlType == "datetime") |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | #elseif($column.list && $column.htmlType == "imageUpload") |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}" width="100"> |
| | | <template #default="scope"> |
| | | <image-preview :src="scope.row.${javaField}" :width="50" :height="50"/> |
| | | </template> |
| | | </el-table-column> |
| | | #elseif($column.list && $column.dictType && "" != $column.dictType) |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}"> |
| | | <template #default="scope"> |
| | | #if($column.htmlType == "checkbox") |
| | | <dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/> |
| | | #else |
| | | <dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/> |
| | | #end |
| | | </template> |
| | | </el-table-column> |
| | | #elseif($column.list && "" != $javaField) |
| | | #if(${foreach.index} == 1) |
| | | <el-table-column label="${comment}" prop="${javaField}" /> |
| | | #else |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}" /> |
| | | #end |
| | | #end |
| | | #end |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-tooltip content="修改" placement="top"> |
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']" /> |
| | | </el-tooltip> |
| | | <el-tooltip content="新增" placement="top"> |
| | | <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${moduleName}:${businessName}:add']" /> |
| | | </el-tooltip> |
| | | <el-tooltip content="删除" placement="top"> |
| | | <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']" /> |
| | | </el-tooltip> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-card> |
| | | <!-- 添加或修改${functionName}对话框 --> |
| | | <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body> |
| | | <el-form ref="${businessName}FormRef" :model="form" :rules="rules" label-width="80px"> |
| | | #foreach($column in $columns) |
| | | #set($field=$column.javaField) |
| | | #if(($column.insert || $column.edit) && !$column.pk) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("(")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #set($dictType=$column.dictType) |
| | | #if("" != $treeParentCode && $column.javaField == $treeParentCode) |
| | | <el-form-item label="${comment}" prop="${treeParentCode}"> |
| | | <el-tree-select |
| | | v-model="form.${treeParentCode}" |
| | | :data="${businessName}Options" |
| | | :props="{ value: '${treeCode}', label: '${treeName}', children: 'children' }" |
| | | value-key="${treeCode}" |
| | | placeholder="请选择${comment}" |
| | | check-strictly |
| | | /> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "input") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-input v-model="form.${field}" placeholder="请输入${comment}" /> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "imageUpload") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <image-upload v-model="form.${field}"/> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "fileUpload") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <file-upload v-model="form.${field}"/> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "editor") |
| | | <el-form-item label="${comment}"> |
| | | <editor v-model="form.${field}" :min-height="192"/> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "select" && "" != $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-select v-model="form.${field}" placeholder="请选择${comment}"> |
| | | <el-option |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | #if($column.javaType == "Integer" || $column.javaType == "Long") |
| | | :value="parseInt(dict.value)" |
| | | #else |
| | | :value="dict.value" |
| | | #end |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "select" && $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-select v-model="form.${field}" placeholder="请选择${comment}"> |
| | | <el-option label="请选择字典生成" value="" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "checkbox" && "" != $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-checkbox-group v-model="form.${field}"> |
| | | <el-checkbox |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | :label="dict.value"> |
| | | {{dict.label}} |
| | | </el-checkbox> |
| | | </el-checkbox-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "checkbox" && $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-checkbox-group v-model="form.${field}"> |
| | | <el-checkbox>请选择字典生成</el-checkbox> |
| | | </el-checkbox-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "radio" && "" != $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-radio-group v-model="form.${field}"> |
| | | <el-radio |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | #if($column.javaType == "Integer" || $column.javaType == "Long") |
| | | :label="parseInt(dict.value)" |
| | | #else |
| | | :label="dict.value" |
| | | #end |
| | | >{{dict.label}}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "radio" && $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-radio-group v-model="form.${field}"> |
| | | <el-radio label="1">请选择字典生成</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "datetime") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-date-picker clearable |
| | | v-model="form.${field}" |
| | | type="datetime" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | placeholder="选择${comment}" |
| | | /> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "textarea") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" /> |
| | | </el-form-item> |
| | | #end |
| | | #end |
| | | #end |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="${BusinessName}" lang="ts"> |
| | | import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; |
| | | import { ${BusinessName}VO, ${BusinessName}Query, ${BusinessName}Form } from '@/api/${moduleName}/${businessName}/types'; |
| | | |
| | | type ${BusinessName}Option = { |
| | | ${treeCode}: number; |
| | | ${treeName}: string; |
| | | children?: ${BusinessName}Option[]; |
| | | } |
| | | |
| | | const { proxy } = getCurrentInstance() as ComponentInternalInstance;; |
| | | |
| | | #if(${dicts} != '') |
| | | #set($dictsNoSymbol=$dicts.replace("'", "")) |
| | | const { ${dictsNoSymbol} } = toRefs<any>(proxy?.useDict(${dicts})); |
| | | #end |
| | | |
| | | const ${businessName}List = ref<${BusinessName}VO[]>([]); |
| | | const ${businessName}Options = ref<${BusinessName}Option[]>([]); |
| | | const buttonLoading = ref(false); |
| | | const showSearch = ref(true); |
| | | const isExpandAll = ref(true); |
| | | const loading = ref(false); |
| | | |
| | | const queryFormRef = ref<ElFormInstance>(); |
| | | const ${businessName}FormRef = ref<ElFormInstance>(); |
| | | const ${businessName}TableRef = ref<ElTableInstance>() |
| | | |
| | | const dialog = reactive<DialogOption>({ |
| | | visible: false, |
| | | title: '' |
| | | }); |
| | | |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | const dateRange${AttrName} = ref<[DateModelType, DateModelType]>(['', '']); |
| | | #end |
| | | #end |
| | | |
| | | const initFormData: ${BusinessName}Form = { |
| | | #foreach ($column in $columns) |
| | | #if($column.insert || $column.edit) |
| | | #if($column.htmlType == "checkbox") |
| | | $column.javaField: []#if($foreach.count != $columns.size()),#end |
| | | #else |
| | | $column.javaField: undefined#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | #end |
| | | } |
| | | |
| | | const data = reactive<PageData<${BusinessName}Form, ${BusinessName}Query>>({ |
| | | form: {...initFormData}, |
| | | queryParams: { |
| | | #foreach ($column in $columns) |
| | | #if($column.query) |
| | | #if($column.htmlType != "datetime" || $column.queryType != "BETWEEN") |
| | | $column.javaField: undefined, |
| | | #end |
| | | #end |
| | | #end |
| | | params: { |
| | | #foreach ($column in $columns) |
| | | #if($column.query) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | $column.javaField: undefined#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | #end |
| | | } |
| | | }, |
| | | rules: { |
| | | #foreach ($column in $columns) |
| | | #if($column.insert || $column.edit) |
| | | #if($column.required) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("(")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | $column.javaField: [ |
| | | { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } |
| | | ]#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | #end |
| | | } |
| | | }); |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | |
| | | /** 查询${functionName}列表 */ |
| | | const getList = async () => { |
| | | loading.value = true; |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | queryParams.value.params = {}; |
| | | #break |
| | | #end |
| | | #end |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | proxy?.addDateRange(queryParams.value, dateRange${AttrName}.value, '${AttrName}'); |
| | | #end |
| | | #end |
| | | const res = await list${BusinessName}(queryParams.value); |
| | | const data = proxy?.handleTree<${BusinessName}VO>(res.data, "${treeCode}", "${treeParentCode}"); |
| | | if (data) { |
| | | ${businessName}List.value = data; |
| | | loading.value = false; |
| | | } |
| | | } |
| | | |
| | | /** 查询${functionName}下拉树结构 */ |
| | | const getTreeselect = async () => { |
| | | const res = await list${BusinessName}(); |
| | | ${businessName}Options.value = []; |
| | | const data: ${BusinessName}Option = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] }; |
| | | data.children = proxy?.handleTree<${BusinessName}Option>(res.data, "${treeCode}", "${treeParentCode}"); |
| | | ${businessName}Options.value.push(data); |
| | | } |
| | | |
| | | // 取消按钮 |
| | | const cancel = () => { |
| | | reset(); |
| | | dialog.visible = false; |
| | | } |
| | | |
| | | // 表单重置 |
| | | const reset = () => { |
| | | form.value = {...initFormData} |
| | | ${businessName}FormRef.value?.resetFields(); |
| | | } |
| | | |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | | getList(); |
| | | } |
| | | |
| | | /** 重置按钮操作 */ |
| | | const resetQuery = () => { |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | dateRange${AttrName}.value = ['', '']; |
| | | #end |
| | | #end |
| | | queryFormRef.value?.resetFields(); |
| | | handleQuery(); |
| | | } |
| | | |
| | | /** 新增按钮操作 */ |
| | | const handleAdd = (row?: ${BusinessName}VO) => { |
| | | dialog.visible = true; |
| | | dialog.title = "添加${functionName}"; |
| | | nextTick(() => { |
| | | reset(); |
| | | getTreeselect(); |
| | | if (row != null && row.${treeCode}) { |
| | | form.value.${treeParentCode} = row.${treeParentCode}; |
| | | } else { |
| | | form.value.${treeParentCode} = 0; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** 展开/折叠操作 */ |
| | | const handleToggleExpandAll = () => { |
| | | isExpandAll.value = !isExpandAll.value; |
| | | toggleExpandAll(${businessName}List.value, isExpandAll.value) |
| | | } |
| | | |
| | | /** 展开/折叠操作 */ |
| | | const toggleExpandAll = (data: ${BusinessName}VO[], status: boolean) => { |
| | | data.forEach((item) => { |
| | | ${businessName}TableRef.value?.toggleRowExpansion(item, status) |
| | | if (item.children && item.children.length > 0) toggleExpandAll(item.children, status) |
| | | }) |
| | | } |
| | | |
| | | /** 修改按钮操作 */ |
| | | const handleUpdate = (row: ${BusinessName}VO) => { |
| | | loading.value = true; |
| | | dialog.visible = true; |
| | | dialog.title = "修改${functionName}"; |
| | | nextTick(async () => { |
| | | reset(); |
| | | await getTreeselect(); |
| | | if (row != null) { |
| | | form.value.${treeParentCode} = row.${treeCode}; |
| | | } |
| | | const res = await get${BusinessName}(row.${pkColumn.javaField}); |
| | | loading.value = false; |
| | | Object.assign(form.value, res.data); |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "checkbox") |
| | | form.value.$column.javaField = form.value.${column.javaField}.split(","); |
| | | #end |
| | | #end |
| | | }); |
| | | } |
| | | |
| | | /** 提交按钮 */ |
| | | const submitForm = () => { |
| | | ${businessName}FormRef.value?.validate(async (valid: boolean) => { |
| | | if (valid) { |
| | | buttonLoading.value = true; |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "checkbox") |
| | | form.value.$column.javaField = form.value.${column.javaField}.join(","); |
| | | #end |
| | | #end |
| | | if (form.value.${pkColumn.javaField}) { |
| | | await update${BusinessName}(form.value).finally(() => buttonLoading.value = false); |
| | | } else { |
| | | await add${BusinessName}(form.value).finally(() => buttonLoading.value = false); |
| | | } |
| | | proxy?.#[[$modal]]#.msgSuccess("操作成功"); |
| | | dialog.visible = false; |
| | | getList(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** 删除按钮操作 */ |
| | | const handleDelete = async (row: ${BusinessName}VO) => { |
| | | await proxy?.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?'); |
| | | loading.value = true; |
| | | await del${BusinessName}(row.${pkColumn.javaField}).finally(() => loading.value = false); |
| | | await getList(); |
| | | proxy?.#[[$modal]]#.msgSuccess("删除成功"); |
| | | } |
| | | |
| | | onMounted(() => { |
| | | getList(); |
| | | }); |
| | | </script> |
New file |
| | |
| | | <template> |
| | | <div class="p-2"> |
| | | <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> |
| | | <div class="search" v-show="showSearch"> |
| | | <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px"> |
| | | #foreach($column in $columns) |
| | | #if($column.query) |
| | | #set($dictType=$column.dictType) |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("(")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #if($column.htmlType == "input" || $column.htmlType == "textarea") |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-input v-model="queryParams.${column.javaField}" placeholder="请输入${comment}" clearable style="width: 240px" @keyup.enter="handleQuery" /> |
| | | </el-form-item> |
| | | #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> |
| | | <el-option |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> |
| | | <el-option label="请选择字典生成" value="" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") |
| | | <el-form-item label="${comment}" prop="${column.javaField}"> |
| | | <el-date-picker clearable |
| | | v-model="queryParams.${column.javaField}" |
| | | type="date" |
| | | value-format="YYYY-MM-DD" |
| | | placeholder="请选择${comment}" |
| | | /> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | <el-form-item label="${comment}" style="width: 308px"> |
| | | <el-date-picker |
| | | v-model="dateRange${AttrName}" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]" |
| | | /> |
| | | </el-form-item> |
| | | #end |
| | | #end |
| | | #end |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | </transition> |
| | | |
| | | <el-card shadow="never"> |
| | | <template #header> |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['${moduleName}:${businessName}:export']">导出</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | </template> |
| | | |
| | | <el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | #foreach($column in $columns) |
| | | #set($javaField=$column.javaField) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("(")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #if($column.pk) |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}" v-if="${column.list}" /> |
| | | #elseif($column.list && $column.htmlType == "datetime") |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | #elseif($column.list && $column.htmlType == "imageUpload") |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}" width="100"> |
| | | <template #default="scope"> |
| | | <image-preview :src="scope.row.${javaField}" :width="50" :height="50"/> |
| | | </template> |
| | | </el-table-column> |
| | | #elseif($column.list && $column.dictType && "" != $column.dictType) |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}"> |
| | | <template #default="scope"> |
| | | #if($column.htmlType == "checkbox") |
| | | <dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/> |
| | | #else |
| | | <dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/> |
| | | #end |
| | | </template> |
| | | </el-table-column> |
| | | #elseif($column.list && "" != $javaField) |
| | | <el-table-column label="${comment}" align="center" prop="${javaField}" /> |
| | | #end |
| | | #end |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-tooltip content="修改" placement="top"> |
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']"></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="删除" placement="top"> |
| | | <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']"></el-button> |
| | | </el-tooltip> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total>0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </el-card> |
| | | <!-- 添加或修改${functionName}对话框 --> |
| | | <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body> |
| | | <el-form ref="${businessName}FormRef" :model="form" :rules="rules" label-width="80px"> |
| | | #foreach($column in $columns) |
| | | #set($field=$column.javaField) |
| | | #if(($column.insert || $column.edit) && !$column.pk) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("(")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | #set($dictType=$column.dictType) |
| | | #if($column.htmlType == "input") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-input v-model="form.${field}" placeholder="请输入${comment}" /> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "imageUpload") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <image-upload v-model="form.${field}"/> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "fileUpload") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <file-upload v-model="form.${field}"/> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "editor") |
| | | <el-form-item label="${comment}"> |
| | | <editor v-model="form.${field}" :min-height="192"/> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "select" && "" != $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-select v-model="form.${field}" placeholder="请选择${comment}"> |
| | | <el-option |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | #if($column.javaType == "Integer" || $column.javaType == "Long") |
| | | :value="parseInt(dict.value)" |
| | | #else |
| | | :value="dict.value" |
| | | #end |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "select" && $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-select v-model="form.${field}" placeholder="请选择${comment}"> |
| | | <el-option label="请选择字典生成" value="" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "checkbox" && "" != $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-checkbox-group v-model="form.${field}"> |
| | | <el-checkbox |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | :label="dict.value"> |
| | | {{dict.label}} |
| | | </el-checkbox> |
| | | </el-checkbox-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "checkbox" && $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-checkbox-group v-model="form.${field}"> |
| | | <el-checkbox>请选择字典生成</el-checkbox> |
| | | </el-checkbox-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "radio" && "" != $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-radio-group v-model="form.${field}"> |
| | | <el-radio |
| | | v-for="dict in ${dictType}" |
| | | :key="dict.value" |
| | | #if($column.javaType == "Integer" || $column.javaType == "Long") |
| | | :label="parseInt(dict.value)" |
| | | #else |
| | | :label="dict.value" |
| | | #end |
| | | >{{dict.label}}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "radio" && $dictType) |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-radio-group v-model="form.${field}"> |
| | | <el-radio label="1">请选择字典生成</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "datetime") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-date-picker clearable |
| | | v-model="form.${field}" |
| | | type="datetime" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | placeholder="请选择${comment}"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | #elseif($column.htmlType == "textarea") |
| | | <el-form-item label="${comment}" prop="${field}"> |
| | | <el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" /> |
| | | </el-form-item> |
| | | #end |
| | | #end |
| | | #end |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="${BusinessName}" lang="ts"> |
| | | import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from '@/api/${moduleName}/${businessName}'; |
| | | import { ${BusinessName}VO, ${BusinessName}Query, ${BusinessName}Form } from '@/api/${moduleName}/${businessName}/types'; |
| | | |
| | | const { proxy } = getCurrentInstance() as ComponentInternalInstance; |
| | | #if(${dicts} != '') |
| | | #set($dictsNoSymbol=$dicts.replace("'", "")) |
| | | const { ${dictsNoSymbol} } = toRefs<any>(proxy?.useDict(${dicts})); |
| | | #end |
| | | |
| | | const ${businessName}List = ref<${BusinessName}VO[]>([]); |
| | | const buttonLoading = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const ids = ref<Array<string | number>>([]); |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const total = ref(0); |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | const dateRange${AttrName} = ref<[DateModelType, DateModelType]>(['', '']); |
| | | #end |
| | | #end |
| | | |
| | | const queryFormRef = ref<ElFormInstance>(); |
| | | const ${businessName}FormRef = ref<ElFormInstance>(); |
| | | |
| | | const dialog = reactive<DialogOption>({ |
| | | visible: false, |
| | | title: '' |
| | | }); |
| | | |
| | | const initFormData: ${BusinessName}Form = { |
| | | #foreach ($column in $columns) |
| | | #if($column.insert || $column.edit) |
| | | #if($column.htmlType == "checkbox") |
| | | $column.javaField: []#if($foreach.count != $columns.size()),#end |
| | | #else |
| | | $column.javaField: undefined#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | #end |
| | | } |
| | | const data = reactive<PageData<${BusinessName}Form, ${BusinessName}Query>>({ |
| | | form: {...initFormData}, |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | #foreach ($column in $columns) |
| | | #if($column.query) |
| | | #if($column.htmlType != "datetime" || $column.queryType != "BETWEEN") |
| | | $column.javaField: undefined, |
| | | #end |
| | | #end |
| | | #end |
| | | params: { |
| | | #foreach ($column in $columns) |
| | | #if($column.query) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | $column.javaField: undefined#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | #end |
| | | } |
| | | }, |
| | | rules: { |
| | | #foreach ($column in $columns) |
| | | #if($column.insert || $column.edit) |
| | | #if($column.required) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("(")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | $column.javaField: [ |
| | | { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } |
| | | ]#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | #end |
| | | } |
| | | }); |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | |
| | | /** 查询${functionName}列表 */ |
| | | const getList = async () => { |
| | | loading.value = true; |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | queryParams.value.params = {}; |
| | | #break |
| | | #end |
| | | #end |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | proxy?.addDateRange(queryParams.value, dateRange${AttrName}.value, '${AttrName}'); |
| | | #end |
| | | #end |
| | | const res = await list${BusinessName}(queryParams.value); |
| | | ${businessName}List.value = res.rows; |
| | | total.value = res.total; |
| | | loading.value = false; |
| | | } |
| | | |
| | | /** 取消按钮 */ |
| | | const cancel = () => { |
| | | reset(); |
| | | dialog.visible = false; |
| | | } |
| | | |
| | | /** 表单重置 */ |
| | | const reset = () => { |
| | | form.value = {...initFormData}; |
| | | ${businessName}FormRef.value?.resetFields(); |
| | | } |
| | | |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | } |
| | | |
| | | /** 重置按钮操作 */ |
| | | const resetQuery = () => { |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | dateRange${AttrName}.value = ['', '']; |
| | | #end |
| | | #end |
| | | queryFormRef.value?.resetFields(); |
| | | handleQuery(); |
| | | } |
| | | |
| | | /** 多选框选中数据 */ |
| | | const handleSelectionChange = (selection: ${BusinessName}VO[]) => { |
| | | ids.value = selection.map(item => item.${pkColumn.javaField}); |
| | | single.value = selection.length != 1; |
| | | multiple.value = !selection.length; |
| | | } |
| | | |
| | | /** 新增按钮操作 */ |
| | | const handleAdd = () => { |
| | | dialog.visible = true; |
| | | dialog.title = "添加${functionName}"; |
| | | nextTick(() => { |
| | | reset(); |
| | | }); |
| | | } |
| | | |
| | | /** 修改按钮操作 */ |
| | | const handleUpdate = (row?: ${BusinessName}VO) => { |
| | | loading.value = true |
| | | dialog.visible = true; |
| | | dialog.title = "修改${functionName}"; |
| | | nextTick(async () => { |
| | | reset(); |
| | | const _${pkColumn.javaField} = row?.${pkColumn.javaField} || ids.value[0] |
| | | const res = await get${BusinessName}(_${pkColumn.javaField}); |
| | | loading.value = false; |
| | | Object.assign(form.value, res.data); |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "checkbox") |
| | | form.value.$column.javaField = form.value.${column.javaField}.split(","); |
| | | #end |
| | | #end |
| | | }); |
| | | } |
| | | |
| | | /** 提交按钮 */ |
| | | const submitForm = () => { |
| | | ${businessName}FormRef.value?.validate(async (valid: boolean) => { |
| | | if (valid) { |
| | | buttonLoading.value = true; |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "checkbox") |
| | | form.value.$column.javaField = form.value.${column.javaField}.join(","); |
| | | #end |
| | | #end |
| | | if (form.value.${pkColumn.javaField}) { |
| | | await update${BusinessName}(form.value).finally(() => buttonLoading.value = false); |
| | | } else { |
| | | await add${BusinessName}(form.value).finally(() => buttonLoading.value = false); |
| | | } |
| | | proxy?.#[[$modal]]#.msgSuccess("修改成功"); |
| | | dialog.visible = false; |
| | | await getList(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** 删除按钮操作 */ |
| | | const handleDelete = async (row?: ${BusinessName}VO) => { |
| | | const _${pkColumn.javaField}s = row?.${pkColumn.javaField} || ids.value; |
| | | await proxy?.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').finally(() => loading.value = false); |
| | | await del${BusinessName}(_${pkColumn.javaField}s); |
| | | proxy?.#[[$modal]]#.msgSuccess("删除成功"); |
| | | await getList(); |
| | | } |
| | | |
| | | /** 导出按钮操作 */ |
| | | const handleExport = () => { |
| | | proxy?.download('${moduleName}/${businessName}/export', { |
| | | ...queryParams.value |
| | | }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`) |
| | | } |
| | | |
| | | onMounted(() => { |
| | | getList(); |
| | | }); |
| | | </script> |
New file |
| | |
| | | <?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="${packageName}.mapper.${ClassName}Mapper"> |
| | | |
| | | </mapper> |
New file |
| | |
| | | #FROM findepi/graalvm:java17-native |
| | | FROM openjdk:17.0.2-oraclelinux8 |
| | | |
| | | MAINTAINER Lion Li |
| | | |
| | | RUN mkdir -p /ruoyi/job/logs \ |
| | | /ruoyi/job/temp \ |
| | | /ruoyi/skywalking/agent |
| | | |
| | | WORKDIR /ruoyi/job |
| | | |
| | | ENV SERVER_PORT=9203 LANG=C.UTF-8 LC_ALL=C.UTF-8 JAVA_OPTS="" |
| | | |
| | | EXPOSE ${SERVER_PORT} |
| | | |
| | | ADD ./target/ruoyi-job.jar ./app.jar |
| | | |
| | | ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${SERVER_PORT} \ |
| | | #-Dskywalking.agent.service_name=ruoyi-job \ |
| | | #-javaagent:/ruoyi/skywalking/agent/skywalking-agent.jar \ |
| | | -jar app.jar \ |
| | | -XX:+HeapDumpOnOutOfMemoryError -Xlog:gc*,:time,tags,level -XX:+UseZGC ${JAVA_OPTS} |
| | | |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-modules</artifactId> |
| | | <version>${revision}</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>ruoyi-job</artifactId> |
| | | |
| | | <description> |
| | | ruoyi-job 任务调度模块 |
| | | </description> |
| | | |
| | | <dependencies> |
| | | |
| | | <!-- SpringCloud Alibaba Nacos --> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- SpringCloud Alibaba Nacos Config --> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- RuoYi Common Log --> |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-log</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-dict</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-web</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-dubbo</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-mybatis</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-job</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-tenant</artifactId> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-mybatis</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-security</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- RuoYi Api System --> |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-api-system</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <finalName>${project.artifactId}</finalName> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <version>${spring-boot.version}</version> |
| | | <executions> |
| | | <execution> |
| | | <goals> |
| | | <goal>repackage</goal> |
| | | </goals> |
| | | </execution> |
| | | </executions> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
New file |
| | |
| | | package org.dromara.job; |
| | | |
| | | import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup; |
| | | |
| | | /** |
| | | * 任务调度模块 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @EnableDubbo |
| | | @SpringBootApplication |
| | | public class RuoYiJobApplication { |
| | | |
| | | public static void main(String[] args) { |
| | | SpringApplication application = new SpringApplication(RuoYiJobApplication.class); |
| | | application.setApplicationStartup(new BufferingApplicationStartup(2048)); |
| | | application.run(args); |
| | | System.out.println("(♥◠‿◠)ノ゙ 任务调度模块启动成功 ლ(´ڡ`ლ)゙ "); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.job.processors; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | import tech.powerjob.common.utils.NetUtils; |
| | | import tech.powerjob.worker.core.processor.ProcessResult; |
| | | import tech.powerjob.worker.core.processor.TaskContext; |
| | | import tech.powerjob.worker.core.processor.TaskResult; |
| | | import tech.powerjob.worker.core.processor.sdk.BroadcastProcessor; |
| | | import tech.powerjob.worker.log.OmsLogger; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 广播处理器 示例 |
| | | * |
| | | * @author tjq |
| | | * @since 2020/4/17 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class BroadcastProcessorDemo implements BroadcastProcessor { |
| | | |
| | | @Override |
| | | public ProcessResult preProcess(TaskContext context) { |
| | | System.out.println("===== BroadcastProcessorDemo#preProcess ======"); |
| | | context.getOmsLogger().info("BroadcastProcessorDemo#preProcess, current host: {}", NetUtils.getLocalHost()); |
| | | if ("rootFailed".equals(context.getJobParams())) { |
| | | return new ProcessResult(false, "console need failed"); |
| | | } else { |
| | | return new ProcessResult(true); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ProcessResult process(TaskContext taskContext) throws Exception { |
| | | OmsLogger logger = taskContext.getOmsLogger(); |
| | | System.out.println("===== BroadcastProcessorDemo#process ======"); |
| | | logger.info("BroadcastProcessorDemo#process, current host: {}", NetUtils.getLocalHost()); |
| | | long sleepTime = 1000; |
| | | try { |
| | | sleepTime = Long.parseLong(taskContext.getJobParams()); |
| | | } catch (Exception e) { |
| | | logger.warn("[BroadcastProcessor] parse sleep time failed!", e); |
| | | } |
| | | Thread.sleep(Math.max(sleepTime, 1000)); |
| | | return new ProcessResult(true); |
| | | } |
| | | |
| | | @Override |
| | | public ProcessResult postProcess(TaskContext context, List<TaskResult> taskResults) { |
| | | System.out.println("===== BroadcastProcessorDemo#postProcess ======"); |
| | | context.getOmsLogger().info("BroadcastProcessorDemo#postProcess, current host: {}, taskResult: {}", NetUtils.getLocalHost(), taskResults); |
| | | return new ProcessResult(true, "success"); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.job.processors; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.springframework.stereotype.Component; |
| | | import tech.powerjob.official.processors.util.CommonUtils; |
| | | import tech.powerjob.worker.core.processor.ProcessResult; |
| | | import tech.powerjob.worker.core.processor.TaskContext; |
| | | import tech.powerjob.worker.core.processor.sdk.BasicProcessor; |
| | | import tech.powerjob.worker.log.OmsLogger; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Optional; |
| | | |
| | | /** |
| | | * LogTestProcessor |
| | | * |
| | | * @author tjq |
| | | * @since 2022/9/18 |
| | | */ |
| | | @Component |
| | | public class LogTestProcessor implements BasicProcessor { |
| | | |
| | | @Override |
| | | public ProcessResult process(TaskContext context) throws Exception { |
| | | |
| | | final OmsLogger omsLogger = context.getOmsLogger(); |
| | | final String parseParams = CommonUtils.parseParams(context); |
| | | final JSONObject config = Optional.ofNullable(JSONObject.parseObject(parseParams)).orElse(new JSONObject()); |
| | | |
| | | final long loopTimes = Optional.ofNullable(config.getLong("loopTimes")).orElse(1000L); |
| | | |
| | | for (int i = 0; i < loopTimes; i++) { |
| | | omsLogger.debug("[DEBUG] one DEBUG log in {}", new Date()); |
| | | omsLogger.info("[INFO] one INFO log in {}", new Date()); |
| | | omsLogger.warn("[WARN] one WARN log in {}", new Date()); |
| | | omsLogger.error("[ERROR] one ERROR log in {}", new Date()); |
| | | } |
| | | |
| | | return new ProcessResult(true); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.job.processors; |
| | | |
| | | import com.google.common.collect.Lists; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | import lombok.NoArgsConstructor; |
| | | import org.dromara.common.json.utils.JsonUtils; |
| | | import org.springframework.stereotype.Component; |
| | | import tech.powerjob.worker.core.processor.ProcessResult; |
| | | import tech.powerjob.worker.core.processor.TaskContext; |
| | | import tech.powerjob.worker.core.processor.sdk.MapProcessor; |
| | | |
| | | import java.util.List; |
| | | import java.util.concurrent.ThreadLocalRandom; |
| | | |
| | | /** |
| | | * Map处理器 示例 |
| | | * |
| | | * @author tjq |
| | | * @since 2020/4/18 |
| | | */ |
| | | @Component |
| | | public class MapProcessorDemo implements MapProcessor { |
| | | |
| | | |
| | | /** |
| | | * 每一批发送任务大小 |
| | | */ |
| | | private static final int BATCH_SIZE = 100; |
| | | /** |
| | | * 发送的批次 |
| | | */ |
| | | private static final int BATCH_NUM = 5; |
| | | |
| | | @Override |
| | | public ProcessResult process(TaskContext context) throws Exception { |
| | | |
| | | log.info("============== MapProcessorDemo#process =============="); |
| | | log.info("isRootTask:{}", isRootTask()); |
| | | log.info("taskContext:{}", JsonUtils.toJsonString(context)); |
| | | |
| | | if (isRootTask()) { |
| | | log.info("==== MAP ===="); |
| | | List<SubTask> subTasks = Lists.newLinkedList(); |
| | | for (int j = 0; j < BATCH_NUM; j++) { |
| | | SubTask subTask = new SubTask(); |
| | | subTask.siteId = j; |
| | | subTask.itemIds = Lists.newLinkedList(); |
| | | subTasks.add(subTask); |
| | | for (int i = 0; i < BATCH_SIZE; i++) { |
| | | subTask.itemIds.add(i + j * 100); |
| | | } |
| | | } |
| | | map(subTasks, "MAP_TEST_TASK"); |
| | | return new ProcessResult(true, "map successfully"); |
| | | } else { |
| | | |
| | | log.info("==== PROCESS ===="); |
| | | SubTask subTask = (SubTask) context.getSubTask(); |
| | | for (Integer itemId : subTask.getItemIds()) { |
| | | if (Thread.interrupted()) { |
| | | // 任务被中断 |
| | | log.info("job has been stop! so stop to process subTask: {} => {}", subTask.getSiteId(), itemId); |
| | | break; |
| | | } |
| | | log.info("processing subTask: {} => {}", subTask.getSiteId(), itemId); |
| | | int max = Integer.MAX_VALUE >> 7; |
| | | for (int i = 0; ; i++) { |
| | | // 模拟耗时操作 |
| | | if (i > max) { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | // 测试在 Map 任务中追加上下文 |
| | | context.getWorkflowContext().appendData2WfContext("Yasuo", "A sword's poor company for a long road."); |
| | | boolean b = ThreadLocalRandom.current().nextBoolean(); |
| | | if (context.getCurrentRetryTimes() >= 1) { |
| | | // 重试的话一定会成功 |
| | | b = true; |
| | | } |
| | | return new ProcessResult(b, "RESULT:" + b); |
| | | } |
| | | } |
| | | |
| | | @Getter |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public static class SubTask { |
| | | private Integer siteId; |
| | | private List<Integer> itemIds; |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.job.processors; |
| | | |
| | | import cn.hutool.core.lang.Dict; |
| | | import com.google.common.collect.Lists; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.ToString; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.dromara.common.json.utils.JsonUtils; |
| | | import org.springframework.stereotype.Component; |
| | | import tech.powerjob.worker.core.processor.ProcessResult; |
| | | import tech.powerjob.worker.core.processor.TaskContext; |
| | | import tech.powerjob.worker.core.processor.TaskResult; |
| | | import tech.powerjob.worker.core.processor.sdk.MapReduceProcessor; |
| | | import tech.powerjob.worker.log.OmsLogger; |
| | | |
| | | import java.util.List; |
| | | import java.util.concurrent.ThreadLocalRandom; |
| | | |
| | | /** |
| | | * MapReduce 处理器示例 |
| | | * 控制台参数:{"batchSize": 100, "batchNum": 2} |
| | | * |
| | | * @author tjq |
| | | * @since 2020/4/17 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class MapReduceProcessorDemo implements MapReduceProcessor { |
| | | |
| | | @Override |
| | | public ProcessResult process(TaskContext context) throws Exception { |
| | | |
| | | OmsLogger omsLogger = context.getOmsLogger(); |
| | | |
| | | log.info("============== TestMapReduceProcessor#process =============="); |
| | | log.info("isRootTask:{}", isRootTask()); |
| | | log.info("taskContext:{}", JsonUtils.toJsonString(context)); |
| | | |
| | | // 根据控制台参数获取MR批次及子任务大小 |
| | | final Dict jobParams = JsonUtils.parseMap(context.getJobParams()); |
| | | |
| | | Integer batchSize = (Integer) jobParams.getOrDefault("batchSize", 100); |
| | | Integer batchNum = (Integer) jobParams.getOrDefault("batchNum", 10); |
| | | |
| | | if (isRootTask()) { |
| | | log.info("==== MAP ===="); |
| | | omsLogger.info("[DemoMRProcessor] start root task~"); |
| | | List<TestSubTask> subTasks = Lists.newLinkedList(); |
| | | for (int j = 0; j < batchNum; j++) { |
| | | for (int i = 0; i < batchSize; i++) { |
| | | int x = j * batchSize + i; |
| | | subTasks.add(new TestSubTask("name" + x, x)); |
| | | } |
| | | map(subTasks, "MAP_TEST_TASK"); |
| | | subTasks.clear(); |
| | | } |
| | | omsLogger.info("[DemoMRProcessor] map success~"); |
| | | return new ProcessResult(true, "MAP_SUCCESS"); |
| | | } else { |
| | | log.info("==== NORMAL_PROCESS ===="); |
| | | omsLogger.info("[DemoMRProcessor] process subTask: {}.", JsonUtils.toJsonString(context.getSubTask())); |
| | | log.info("subTask: {}", JsonUtils.toJsonString(context.getSubTask())); |
| | | Thread.sleep(1000); |
| | | if (context.getCurrentRetryTimes() == 0) { |
| | | return new ProcessResult(false, "FIRST_FAILED"); |
| | | } else { |
| | | return new ProcessResult(true, "PROCESS_SUCCESS"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ProcessResult reduce(TaskContext context, List<TaskResult> taskResults) { |
| | | log.info("================ MapReduceProcessorDemo#reduce ================"); |
| | | log.info("TaskContext: {}", JsonUtils.toJsonString(context)); |
| | | log.info("List<TaskResult>: {}", JsonUtils.toJsonString(taskResults)); |
| | | context.getOmsLogger().info("MapReduce job finished, result is {}.", taskResults); |
| | | |
| | | boolean success = ThreadLocalRandom.current().nextBoolean(); |
| | | return new ProcessResult(success, context + ": " + success); |
| | | } |
| | | |
| | | @Getter |
| | | @ToString |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public static class TestSubTask { |
| | | private String name; |
| | | private int age; |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.job.processors; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | import tech.powerjob.worker.core.processor.ProcessResult; |
| | | import tech.powerjob.worker.core.processor.TaskContext; |
| | | import tech.powerjob.worker.core.processor.sdk.BasicProcessor; |
| | | import tech.powerjob.worker.log.OmsLogger; |
| | | |
| | | import java.util.Optional; |
| | | |
| | | /** |
| | | * @author Echo009 |
| | | * @since 2022/4/27 |
| | | */ |
| | | @Component |
| | | public class SimpleProcessor implements BasicProcessor { |
| | | |
| | | @Override |
| | | public ProcessResult process(TaskContext context) throws Exception { |
| | | |
| | | OmsLogger logger = context.getOmsLogger(); |
| | | |
| | | String jobParams = Optional.ofNullable(context.getJobParams()).orElse("S"); |
| | | logger.info("Current context:{}", context.getWorkflowContext()); |
| | | logger.info("Current job params:{}", jobParams); |
| | | |
| | | // 测试中文问题 #581 |
| | | if (jobParams.contains("CN")) { |
| | | return new ProcessResult(true, "任务成功啦!!!"); |
| | | } |
| | | |
| | | return jobParams.contains("F") ? new ProcessResult(false) : new ProcessResult(true, "yeah!"); |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.job.processors; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Component; |
| | | import tech.powerjob.worker.core.processor.ProcessResult; |
| | | import tech.powerjob.worker.core.processor.TaskContext; |
| | | import tech.powerjob.worker.core.processor.sdk.BasicProcessor; |
| | | import tech.powerjob.worker.log.OmsLogger; |
| | | |
| | | import java.util.Collections; |
| | | |
| | | /** |
| | | * 单机处理器 示例 |
| | | * |
| | | * @author tjq |
| | | * @since 2020/4/17 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class StandaloneProcessorDemo implements BasicProcessor { |
| | | |
| | | @Override |
| | | public ProcessResult process(TaskContext context) throws Exception { |
| | | OmsLogger omsLogger = context.getOmsLogger(); |
| | | omsLogger.info("StandaloneProcessorDemo start process,context is {}.", context); |
| | | omsLogger.info("Notice! If you want this job process failed, your jobParams need to be 'failed'"); |
| | | omsLogger.info("Let's test the exception~"); |
| | | // 测试异常日志 |
| | | try { |
| | | Collections.emptyList().add("277"); |
| | | } catch (Exception e) { |
| | | omsLogger.error("oh~it seems that we have an exception~", e); |
| | | } |
| | | log.info("================ StandaloneProcessorDemo#process ================"); |
| | | log.info("jobParam:{}", context.getJobParams()); |
| | | log.info("instanceParams:{}", context.getInstanceParams()); |
| | | String param; |
| | | // 解析参数,非处于工作流中时,优先取实例参数(允许动态[instanceParams]覆盖静态参数[jobParams]) |
| | | if (context.getWorkflowContext() == null) { |
| | | param = StringUtils.isBlank(context.getInstanceParams()) ? context.getJobParams() : context.getInstanceParams(); |
| | | } else { |
| | | param = context.getJobParams(); |
| | | } |
| | | // 根据参数判断是否成功 |
| | | boolean success = !"failed".equals(param); |
| | | omsLogger.info("StandaloneProcessorDemo finished process,success: {}", success); |
| | | omsLogger.info("anyway, we finished the job successfully~Congratulations!"); |
| | | return new ProcessResult(success, context + ": " + success); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.job.processors; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | import tech.powerjob.worker.core.processor.ProcessResult; |
| | | import tech.powerjob.worker.core.processor.TaskContext; |
| | | import tech.powerjob.worker.core.processor.sdk.BasicProcessor; |
| | | |
| | | /** |
| | | * 测试超时任务(可中断) |
| | | * |
| | | * @author tjq |
| | | * @since 2020/4/20 |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class TimeoutProcessor implements BasicProcessor { |
| | | @Override |
| | | public ProcessResult process(TaskContext context) throws Exception { |
| | | long sleepTime = Long.parseLong(context.getJobParams()); |
| | | log.info("TaskInstance({}) will sleep {} ms", context.getInstanceId(), sleepTime); |
| | | Thread.sleep(Long.parseLong(context.getJobParams())); |
| | | return new ProcessResult(true, "impossible~~~~QAQ~"); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.job.workflow; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | import tech.powerjob.worker.core.processor.ProcessResult; |
| | | import tech.powerjob.worker.core.processor.TaskContext; |
| | | import tech.powerjob.worker.core.processor.sdk.BasicProcessor; |
| | | import tech.powerjob.worker.log.OmsLogger; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 工作流测试 |
| | | * |
| | | * @author tjq |
| | | * @since 2020/6/2 |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class WorkflowStandaloneProcessor implements BasicProcessor { |
| | | |
| | | @Override |
| | | public ProcessResult process(TaskContext context) throws Exception { |
| | | OmsLogger logger = context.getOmsLogger(); |
| | | logger.info("current jobParams: {}", context.getJobParams()); |
| | | logger.info("current context: {}", context.getWorkflowContext()); |
| | | log.info("jobParams:{}", context.getJobParams()); |
| | | log.info("currentContext:{}", JSON.toJSONString(context)); |
| | | |
| | | // 尝试获取上游任务 |
| | | Map<String, String> workflowContext = context.getWorkflowContext().fetchWorkflowContext(); |
| | | log.info("工作流上下文数据:{}", workflowContext); |
| | | return new ProcessResult(true, context.getJobId() + " process successfully."); |
| | | } |
| | | } |
New file |
| | |
| | | # Tomcat |
| | | server: |
| | | port: 9203 |
| | | |
| | | # Spring |
| | | spring: |
| | | application: |
| | | # 应用名称 |
| | | name: ruoyi-job |
| | | profiles: |
| | | # 环境配置 |
| | | active: @profiles.active@ |
| | | |
| | | --- # nacos 配置 |
| | | spring: |
| | | cloud: |
| | | nacos: |
| | | # nacos 服务地址 |
| | | server-addr: @nacos.server@ |
| | | discovery: |
| | | # 注册组 |
| | | group: @nacos.discovery.group@ |
| | | namespace: ${spring.profiles.active} |
| | | config: |
| | | # 配置组 |
| | | group: @nacos.config.group@ |
| | | namespace: ${spring.profiles.active} |
| | | config: |
| | | import: |
| | | - optional:nacos:application-common.yml |
| | | - optional:nacos:datasource.yml |
| | | - optional:nacos:${spring.application.name}.yml |
New file |
| | |
| | | Spring Boot Version: ${spring-boot.version} |
| | | Spring Application Name: ${spring.application.name} |
| | | _ _ _ |
| | | (_) (_) | | |
| | | _ __ _ _ ___ _ _ _ ______ _ ___ | |__ |
| | | | '__| | | |/ _ \| | | | |______| |/ _ \| '_ \ |
| | | | | | |_| | (_) | |_| | | | | (_) | |_) | |
| | | |_| \__,_|\___/ \__, |_| | |\___/|_.__/ |
| | | __/ | _/ | |
| | | |___/ |__/ |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <configuration scan="true" scanPeriod="60 seconds" debug="false"> |
| | | <!-- 日志存放路径 --> |
| | | <property name="log.path" value="logs/${project.artifactId}"/> |
| | | <!-- 日志输出格式 --> |
| | | <property name="console.log.pattern" |
| | | value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/> |
| | | |
| | | <!-- 控制台输出 --> |
| | | <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> |
| | | <encoder> |
| | | <pattern>${console.log.pattern}</pattern> |
| | | <charset>utf-8</charset> |
| | | </encoder> |
| | | </appender> |
| | | |
| | | <include resource="logback-common.xml" /> |
| | | |
| | | <include resource="logback-logstash.xml" /> |
| | | |
| | | <!-- 开启 skywalking 日志收集 --> |
| | | <include resource="logback-skylog.xml" /> |
| | | |
| | | <!--系统操作日志--> |
| | | <root level="info"> |
| | | <appender-ref ref="console"/> |
| | | </root> |
| | | </configuration> |
New file |
| | |
| | | # p6spy 性能分析插件配置文件 |
| | | modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory |
| | | # 自定义日志打印 |
| | | logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger |
| | | #日志输出到控制台 |
| | | appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger |
| | | # 使用日志系统记录 sql |
| | | #appender=com.p6spy.engine.spy.appender.Slf4JLogger |
| | | # 设置 p6spy driver 代理 |
| | | #deregisterdrivers=true |
| | | # 取消JDBC URL前缀 |
| | | useprefix=true |
| | | # 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset. |
| | | excludecategories=info,debug,result,commit,resultset |
| | | # 日期格式 |
| | | dateformat=yyyy-MM-dd HH:mm:ss |
| | | # SQL语句打印时间格式 |
| | | databaseDialectTimestampFormat=yyyy-MM-dd HH:mm:ss |
| | | # 实际驱动可多个 |
| | | #driverlist=org.h2.Driver |
| | | # 是否开启慢SQL记录 |
| | | outagedetection=true |
| | | # 慢SQL记录标准 2 秒 |
| | | outagedetectioninterval=2 |
| | | # 是否过滤 Log |
| | | filter=true |
| | | # 过滤 Log 时所排除的 sql 关键字,以逗号分隔 |
| | | exclude=SELECT 1 |
New file |
| | |
| | | #FROM findepi/graalvm:java17-native |
| | | FROM openjdk:17.0.2-oraclelinux8 |
| | | |
| | | MAINTAINER Lion Li |
| | | |
| | | RUN mkdir -p /ruoyi/resource/logs \ |
| | | /ruoyi/resource/temp \ |
| | | /ruoyi/skywalking/agent |
| | | |
| | | WORKDIR /ruoyi/resource |
| | | |
| | | ENV SERVER_PORT=9204 LANG=C.UTF-8 LC_ALL=C.UTF-8 JAVA_OPTS="" |
| | | |
| | | EXPOSE ${SERVER_PORT} |
| | | |
| | | ADD ./target/ruoyi-resource.jar ./app.jar |
| | | |
| | | ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${SERVER_PORT} \ |
| | | #-Dskywalking.agent.service_name=ruoyi-resource \ |
| | | #-javaagent:/ruoyi/skywalking/agent/skywalking-agent.jar \ |
| | | -jar app.jar \ |
| | | -XX:+HeapDumpOnOutOfMemoryError -Xlog:gc*,:time,tags,level -XX:+UseZGC ${JAVA_OPTS} |
| | | |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-modules</artifactId> |
| | | <version>${revision}</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>ruoyi-resource</artifactId> |
| | | |
| | | <description> |
| | | ruoyi-resource资源服务 |
| | | </description> |
| | | |
| | | <dependencies> |
| | | |
| | | <!-- SpringCloud Alibaba Nacos --> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- SpringCloud Alibaba Nacos Config --> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-sentinel</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-doc</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-dubbo</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-seata</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-web</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-log</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-oss</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-ratelimiter</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-mail</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-sms</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- 短信 用哪个导入哪个依赖 --> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>com.aliyun</groupId>--> |
| | | <!-- <artifactId>dysmsapi20170525</artifactId>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>com.tencentcloudapi</groupId>--> |
| | | <!-- <artifactId>tencentcloud-sdk-java-sms</artifactId>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-mybatis</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-tenant</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-security</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-translation</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-websocket</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- RuoYi Api System --> |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-api-system</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-api-resource</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <finalName>${project.artifactId}</finalName> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <version>${spring-boot.version}</version> |
| | | <executions> |
| | | <execution> |
| | | <goals> |
| | | <goal>repackage</goal> |
| | | </goals> |
| | | </execution> |
| | | </executions> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
New file |
| | |
| | | package org.dromara.resource; |
| | | |
| | | import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
| | | import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup; |
| | | |
| | | /** |
| | | * 资源服务 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @EnableDubbo |
| | | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) |
| | | public class RuoYiResourceApplication { |
| | | public static void main(String[] args) { |
| | | SpringApplication application = new SpringApplication(RuoYiResourceApplication.class); |
| | | application.setApplicationStartup(new BufferingApplicationStartup(2048)); |
| | | application.run(args); |
| | | System.out.println("(♥◠‿◠)ノ゙ 资源服务模块启动成功 ლ(´ڡ`ლ)゙ "); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.resource.controller; |
| | | |
| | | |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.dromara.common.core.constant.Constants; |
| | | import org.dromara.common.core.constant.GlobalConstants; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.ratelimiter.annotation.RateLimiter; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.mail.config.properties.MailProperties; |
| | | import org.dromara.common.mail.utils.MailUtils; |
| | | import org.dromara.common.redis.utils.RedisUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import java.time.Duration; |
| | | |
| | | /** |
| | | * 邮件功能 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/email") |
| | | public class SysEmailController extends BaseController { |
| | | |
| | | private final MailProperties mailProperties; |
| | | |
| | | /** |
| | | * 邮箱验证码 |
| | | * |
| | | * @param email 邮箱 |
| | | */ |
| | | @RateLimiter(key = "#email", time = 60, count = 1) |
| | | @GetMapping("/code") |
| | | public R<Void> emailCode(@NotBlank(message = "{user.email.not.blank}") String email) { |
| | | if (!mailProperties.getEnabled()) { |
| | | return R.fail("当前系统没有开启邮箱功能!"); |
| | | } |
| | | String key = GlobalConstants.CAPTCHA_CODE_KEY + email; |
| | | String code = RandomUtil.randomNumbers(4); |
| | | RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION)); |
| | | try { |
| | | MailUtils.sendText(email, "登录验证码", "您本次验证码为:" + code + ",有效性为" + Constants.CAPTCHA_EXPIRATION + "分钟,请尽快填写。"); |
| | | } catch (Exception e) { |
| | | log.error("验证码短信发送异常 => {}", e.getMessage()); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.controller; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.core.validate.QueryGroup; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.resource.domain.bo.SysOssConfigBo; |
| | | import org.dromara.resource.domain.vo.SysOssConfigVo; |
| | | import org.dromara.resource.service.ISysOssConfigService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * 对象存储配置Controller |
| | | * |
| | | * @author Lion Li |
| | | * @author 孤舟烟雨 |
| | | * @date 2021-08-13 |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/oss/config") |
| | | public class SysOssConfigController extends BaseController { |
| | | |
| | | private final ISysOssConfigService iSysOssConfigService; |
| | | |
| | | /** |
| | | * 查询对象存储配置列表 |
| | | */ |
| | | @SaCheckPermission("system:ossConfig:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysOssConfigVo> list(@Validated(QueryGroup.class) SysOssConfigBo bo, PageQuery pageQuery) { |
| | | return iSysOssConfigService.queryPageList(bo, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 获取对象存储配置详细信息 |
| | | * |
| | | * @param ossConfigId OSS配置ID |
| | | */ |
| | | @SaCheckPermission("system:ossConfig:list") |
| | | @GetMapping("/{ossConfigId}") |
| | | public R<SysOssConfigVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable("ossConfigId") Long ossConfigId) { |
| | | return R.ok(iSysOssConfigService.queryById(ossConfigId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增对象存储配置 |
| | | */ |
| | | @SaCheckPermission("system:ossConfig:add") |
| | | @Log(title = "对象存储配置", businessType = BusinessType.INSERT) |
| | | @PostMapping() |
| | | public R<Void> add(@Validated(AddGroup.class) @RequestBody SysOssConfigBo bo) { |
| | | return toAjax(iSysOssConfigService.insertByBo(bo)); |
| | | } |
| | | |
| | | /** |
| | | * 修改对象存储配置 |
| | | */ |
| | | @SaCheckPermission("system:ossConfig:edit") |
| | | @Log(title = "对象存储配置", businessType = BusinessType.UPDATE) |
| | | @PutMapping() |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysOssConfigBo bo) { |
| | | return toAjax(iSysOssConfigService.updateByBo(bo)); |
| | | } |
| | | |
| | | /** |
| | | * 删除对象存储配置 |
| | | * |
| | | * @param ossConfigIds OSS配置ID串 |
| | | */ |
| | | @SaCheckPermission("system:ossConfig:remove") |
| | | @Log(title = "对象存储配置", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ossConfigIds}") |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ossConfigIds) { |
| | | return toAjax(iSysOssConfigService.deleteWithValidByIds(Arrays.asList(ossConfigIds), true)); |
| | | } |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @SaCheckPermission("system:ossConfig:edit") |
| | | @Log(title = "对象存储状态修改", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public R<Void> changeStatus(@RequestBody SysOssConfigBo bo) { |
| | | return toAjax(iSysOssConfigService.updateOssConfigStatus(bo)); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.resource.controller; |
| | | |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.validate.QueryGroup; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.resource.domain.bo.SysOssBo; |
| | | import org.dromara.resource.domain.vo.SysOssUploadVo; |
| | | import org.dromara.resource.domain.vo.SysOssVo; |
| | | import org.dromara.resource.service.ISysOssService; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 文件上传 控制层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/oss") |
| | | public class SysOssController extends BaseController { |
| | | |
| | | private final ISysOssService iSysOssService; |
| | | |
| | | /** |
| | | * 查询OSS对象存储列表 |
| | | */ |
| | | @SaCheckPermission("system:oss:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysOssVo> list(@Validated(QueryGroup.class) SysOssBo bo, PageQuery pageQuery) { |
| | | return iSysOssService.queryPageList(bo, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 查询OSS对象基于id串 |
| | | * |
| | | * @param ossIds OSS对象ID串 |
| | | */ |
| | | @SaCheckPermission("system:oss:list") |
| | | @GetMapping("/listByIds/{ossIds}") |
| | | public R<List<SysOssVo>> listByIds(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ossIds) { |
| | | List<SysOssVo> list = iSysOssService.listByIds(Arrays.asList(ossIds)); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | /** |
| | | * 上传OSS对象存储 |
| | | * |
| | | * @param file 文件 |
| | | */ |
| | | @SaCheckPermission("system:oss:upload") |
| | | @Log(title = "OSS对象存储", businessType = BusinessType.INSERT) |
| | | @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | public R<SysOssUploadVo> upload(@RequestPart("file") MultipartFile file) { |
| | | if (ObjectUtil.isNull(file)) { |
| | | return R.fail("上传文件不能为空"); |
| | | } |
| | | SysOssVo oss = iSysOssService.upload(file); |
| | | SysOssUploadVo uploadVo = new SysOssUploadVo(); |
| | | uploadVo.setUrl(oss.getUrl()); |
| | | uploadVo.setFileName(oss.getOriginalName()); |
| | | uploadVo.setOssId(oss.getOssId().toString()); |
| | | return R.ok(uploadVo); |
| | | } |
| | | |
| | | /** |
| | | * 下载OSS对象存储 |
| | | * |
| | | * @param ossId OSS对象ID |
| | | */ |
| | | @SaCheckPermission("system:oss:download") |
| | | @GetMapping("/download/{ossId}") |
| | | public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException { |
| | | iSysOssService.download(ossId, response); |
| | | } |
| | | |
| | | /** |
| | | * 删除OSS对象存储 |
| | | * |
| | | * @param ossIds OSS对象ID串 |
| | | */ |
| | | @SaCheckPermission("system:oss:remove") |
| | | @Log(title = "OSS对象存储", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ossIds}") |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ossIds) { |
| | | return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true)); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.controller; |
| | | |
| | | |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.dromara.common.core.constant.Constants; |
| | | import org.dromara.common.core.constant.GlobalConstants; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.ratelimiter.annotation.RateLimiter; |
| | | import org.dromara.common.redis.utils.RedisUtils; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.sms4j.api.SmsBlend; |
| | | import org.dromara.sms4j.api.entity.SmsResponse; |
| | | import org.dromara.sms4j.core.factory.SmsFactory; |
| | | import org.dromara.sms4j.provider.enumerate.SupplierType; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.time.Duration; |
| | | import java.util.LinkedHashMap; |
| | | |
| | | /** |
| | | * 短信功能 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/sms") |
| | | public class SysSmsController extends BaseController { |
| | | |
| | | /** |
| | | * 短信验证码 |
| | | * |
| | | * @param phonenumber 用户手机号 |
| | | */ |
| | | @RateLimiter(key = "#phonenumber", time = 60, count = 1) |
| | | @GetMapping("/code") |
| | | public R<Void> smsCaptcha(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) { |
| | | String key = GlobalConstants.CAPTCHA_CODE_KEY + phonenumber; |
| | | String code = RandomUtil.randomNumbers(4); |
| | | RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION)); |
| | | // 验证码模板id 自行处理 (查数据库或写死均可) |
| | | String templateId = ""; |
| | | LinkedHashMap<String, String> map = new LinkedHashMap<>(1); |
| | | map.put("code", code); |
| | | SmsBlend smsBlend = SmsFactory.createSmsBlend(SupplierType.ALIBABA); |
| | | SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, templateId, map); |
| | | if (!"OK".equals(smsResponse.getCode())) { |
| | | log.error("验证码短信发送异常 => {}", smsResponse); |
| | | return R.fail(smsResponse.getMessage()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.tenant.core.TenantEntity; |
| | | |
| | | /** |
| | | * OSS对象存储对象 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_oss") |
| | | public class SysOss extends TenantEntity { |
| | | |
| | | /** |
| | | * 对象存储主键 |
| | | */ |
| | | @TableId(value = "oss_id") |
| | | private Long ossId; |
| | | |
| | | /** |
| | | * 文件名 |
| | | */ |
| | | private String fileName; |
| | | |
| | | /** |
| | | * 原名 |
| | | */ |
| | | private String originalName; |
| | | |
| | | /** |
| | | * 文件后缀名 |
| | | */ |
| | | private String fileSuffix; |
| | | |
| | | /** |
| | | * URL地址 |
| | | */ |
| | | private String url; |
| | | |
| | | /** |
| | | * 服务商 |
| | | */ |
| | | private String service; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * 对象存储配置对象 sys_oss_config |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_oss_config") |
| | | public class SysOssConfig extends BaseEntity { |
| | | |
| | | /** |
| | | * 主建 |
| | | */ |
| | | @TableId(value = "oss_config_id") |
| | | private Long ossConfigId; |
| | | |
| | | /** |
| | | * 配置key |
| | | */ |
| | | private String configKey; |
| | | |
| | | /** |
| | | * accessKey |
| | | */ |
| | | private String accessKey; |
| | | |
| | | /** |
| | | * 秘钥 |
| | | */ |
| | | private String secretKey; |
| | | |
| | | /** |
| | | * 桶名称 |
| | | */ |
| | | private String bucketName; |
| | | |
| | | /** |
| | | * 前缀 |
| | | */ |
| | | private String prefix; |
| | | |
| | | /** |
| | | * 访问站点 |
| | | */ |
| | | private String endpoint; |
| | | |
| | | /** |
| | | * 自定义域名 |
| | | */ |
| | | private String domain; |
| | | |
| | | |
| | | /** |
| | | * 是否https(0否 1是) |
| | | */ |
| | | private String isHttps; |
| | | |
| | | /** |
| | | * 域 |
| | | */ |
| | | private String region; |
| | | |
| | | /** |
| | | * 是否默认(0=是,1=否) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 扩展字段 |
| | | */ |
| | | private String ext1; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 桶权限类型(0private 1public 2custom) |
| | | */ |
| | | private String accessPolicy; |
| | | } |
New file |
| | |
| | | package org.dromara.resource.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.resource.domain.SysOss; |
| | | |
| | | /** |
| | | * OSS对象存储分页查询对象 sys_oss |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysOss.class, reverseConvertGenerate = false) |
| | | public class SysOssBo extends BaseEntity { |
| | | |
| | | /** |
| | | * ossId |
| | | */ |
| | | private Long ossId; |
| | | |
| | | /** |
| | | * 文件名 |
| | | */ |
| | | private String fileName; |
| | | |
| | | /** |
| | | * 原名 |
| | | */ |
| | | private String originalName; |
| | | |
| | | /** |
| | | * 文件后缀名 |
| | | */ |
| | | private String fileSuffix; |
| | | |
| | | /** |
| | | * URL地址 |
| | | */ |
| | | private String url; |
| | | |
| | | /** |
| | | * 服务商 |
| | | */ |
| | | private String service; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.resource.domain.SysOssConfig; |
| | | |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Size; |
| | | |
| | | /** |
| | | * 对象存储配置业务对象 sys_oss_config |
| | | * |
| | | * @author Lion Li |
| | | * @author 孤舟烟雨 |
| | | * @date 2021-08-13 |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysOssConfig.class, reverseConvertGenerate = false) |
| | | public class SysOssConfigBo extends BaseEntity { |
| | | |
| | | /** |
| | | * 主建 |
| | | */ |
| | | @NotNull(message = "主建不能为空", groups = {EditGroup.class}) |
| | | private Long ossConfigId; |
| | | |
| | | /** |
| | | * 配置key |
| | | */ |
| | | @NotBlank(message = "配置key不能为空", groups = {AddGroup.class, EditGroup.class}) |
| | | @Size(min = 2, max = 100, message = "configKey长度必须介于2和20 之间") |
| | | private String configKey; |
| | | |
| | | /** |
| | | * accessKey |
| | | */ |
| | | @NotBlank(message = "accessKey不能为空", groups = {AddGroup.class, EditGroup.class}) |
| | | @Size(min = 2, max = 100, message = "accessKey长度必须介于2和100 之间") |
| | | private String accessKey; |
| | | |
| | | /** |
| | | * 秘钥 |
| | | */ |
| | | @NotBlank(message = "secretKey不能为空", groups = {AddGroup.class, EditGroup.class}) |
| | | @Size(min = 2, max = 100, message = "secretKey长度必须介于2和100 之间") |
| | | private String secretKey; |
| | | |
| | | /** |
| | | * 桶名称 |
| | | */ |
| | | @NotBlank(message = "桶名称不能为空", groups = {AddGroup.class, EditGroup.class}) |
| | | @Size(min = 2, max = 100, message = "bucketName长度必须介于2和100之间") |
| | | private String bucketName; |
| | | |
| | | /** |
| | | * 前缀 |
| | | */ |
| | | private String prefix; |
| | | |
| | | /** |
| | | * 访问站点 |
| | | */ |
| | | @NotBlank(message = "访问站点不能为空", groups = {AddGroup.class, EditGroup.class}) |
| | | @Size(min = 2, max = 100, message = "endpoint长度必须介于2和100之间") |
| | | private String endpoint; |
| | | |
| | | /** |
| | | * 自定义域名 |
| | | */ |
| | | private String domain; |
| | | |
| | | /** |
| | | * 是否https(Y=是,N=否) |
| | | */ |
| | | private String isHttps; |
| | | |
| | | /** |
| | | * 是否默认(0=是,1=否) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 域 |
| | | */ |
| | | private String region; |
| | | |
| | | /** |
| | | * 扩展字段 |
| | | */ |
| | | private String ext1; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 桶权限类型(0private 1public 2custom) |
| | | */ |
| | | @NotBlank(message = "桶权限类型不能为空", groups = {AddGroup.class, EditGroup.class}) |
| | | private String accessPolicy; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.domain.vo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.resource.domain.SysOssConfig; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | |
| | | |
| | | /** |
| | | * 对象存储配置视图对象 sys_oss_config |
| | | * |
| | | * @author Lion Li |
| | | * @author 孤舟烟雨 |
| | | * @date 2021-08-13 |
| | | */ |
| | | @Data |
| | | @AutoMapper(target = SysOssConfig.class) |
| | | public class SysOssConfigVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主建 |
| | | */ |
| | | private Long ossConfigId; |
| | | |
| | | /** |
| | | * 配置key |
| | | */ |
| | | private String configKey; |
| | | |
| | | /** |
| | | * accessKey |
| | | */ |
| | | private String accessKey; |
| | | |
| | | /** |
| | | * 秘钥 |
| | | */ |
| | | private String secretKey; |
| | | |
| | | /** |
| | | * 桶名称 |
| | | */ |
| | | private String bucketName; |
| | | |
| | | /** |
| | | * 前缀 |
| | | */ |
| | | private String prefix; |
| | | |
| | | /** |
| | | * 访问站点 |
| | | */ |
| | | private String endpoint; |
| | | |
| | | /** |
| | | * 自定义域名 |
| | | */ |
| | | private String domain; |
| | | |
| | | /** |
| | | * 是否https(Y=是,N=否) |
| | | */ |
| | | private String isHttps; |
| | | |
| | | /** |
| | | * 域 |
| | | */ |
| | | private String region; |
| | | |
| | | /** |
| | | * 是否默认(0=是,1=否) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 扩展字段 |
| | | */ |
| | | private String ext1; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 桶权限类型(0private 1public 2custom) |
| | | */ |
| | | private String accessPolicy; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 上传对象信息 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | public class SysOssUploadVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * URL地址 |
| | | */ |
| | | private String url; |
| | | |
| | | /** |
| | | * 文件名 |
| | | */ |
| | | private String fileName; |
| | | |
| | | /** |
| | | * 对象存储主键 |
| | | */ |
| | | private String ossId; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.domain.vo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.common.translation.annotation.Translation; |
| | | import org.dromara.common.translation.constant.TransConstant; |
| | | import org.dromara.resource.domain.SysOss; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * OSS对象存储视图对象 sys_oss |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @AutoMapper(target = SysOss.class) |
| | | public class SysOssVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 对象存储主键 |
| | | */ |
| | | private Long ossId; |
| | | |
| | | /** |
| | | * 文件名 |
| | | */ |
| | | private String fileName; |
| | | |
| | | /** |
| | | * 原名 |
| | | */ |
| | | private String originalName; |
| | | |
| | | /** |
| | | * 文件后缀名 |
| | | */ |
| | | private String fileSuffix; |
| | | |
| | | /** |
| | | * URL地址 |
| | | */ |
| | | private String url; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 上传人 |
| | | */ |
| | | private Long createBy; |
| | | |
| | | /** |
| | | * 上传人名称 |
| | | */ |
| | | @Translation(type = TransConstant.USER_ID_TO_NAME, mapper = "createBy") |
| | | private String createByName; |
| | | |
| | | /** |
| | | * 服务商 |
| | | */ |
| | | private String service; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.dubbo; |
| | | |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.oss.core.OssClient; |
| | | import org.dromara.common.oss.entity.UploadResult; |
| | | import org.dromara.common.oss.factory.OssFactory; |
| | | import org.dromara.resource.api.RemoteFileService; |
| | | import org.dromara.resource.api.domain.RemoteFile; |
| | | import org.dromara.resource.domain.bo.SysOssBo; |
| | | import org.dromara.resource.service.ISysOssService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.config.annotation.DubboService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | /** |
| | | * 文件请求处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | @DubboService |
| | | public class RemoteFileServiceImpl implements RemoteFileService { |
| | | |
| | | private final ISysOssService sysOssService; |
| | | |
| | | /** |
| | | * 文件上传请求 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public RemoteFile upload(String name, String originalFilename, String contentType, byte[] file) throws ServiceException { |
| | | try { |
| | | String suffix = StringUtils.substring(originalFilename, originalFilename.lastIndexOf("."), originalFilename.length()); |
| | | OssClient storage = OssFactory.instance(); |
| | | UploadResult uploadResult = storage.uploadSuffix(file, suffix, contentType); |
| | | // 保存文件信息 |
| | | SysOssBo oss = new SysOssBo(); |
| | | oss.setUrl(uploadResult.getUrl()); |
| | | oss.setFileSuffix(suffix); |
| | | oss.setFileName(uploadResult.getFilename()); |
| | | oss.setOriginalName(originalFilename); |
| | | oss.setService(storage.getConfigKey()); |
| | | sysOssService.insertByBo(oss); |
| | | RemoteFile sysFile = new RemoteFile(); |
| | | sysFile.setOssId(oss.getOssId()); |
| | | sysFile.setName(uploadResult.getFilename()); |
| | | sysFile.setUrl(uploadResult.getUrl()); |
| | | return sysFile; |
| | | } catch (Exception e) { |
| | | log.error("上传文件失败", e); |
| | | throw new ServiceException("上传文件失败"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 通过ossId查询对应的url |
| | | * |
| | | * @param ossIds ossId串逗号分隔 |
| | | * @return url串逗号分隔 |
| | | */ |
| | | @Override |
| | | public String selectUrlByIds(String ossIds) { |
| | | return sysOssService.selectUrlByIds(ossIds); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.dubbo; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.config.annotation.DubboService; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.mail.utils.MailUtils; |
| | | import org.dromara.resource.api.RemoteMailService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 邮件服务 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | @DubboService |
| | | public class RemoteMailServiceImpl implements RemoteMailService { |
| | | |
| | | /** |
| | | * 发送邮件 |
| | | * |
| | | * @param to 接收人 |
| | | * @param subject 标题 |
| | | * @param text 内容 |
| | | */ |
| | | public void send(String to, String subject, String text) throws ServiceException { |
| | | MailUtils.sendText(to, subject, text); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.dubbo; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.config.annotation.DubboService; |
| | | import org.dromara.common.websocket.utils.WebSocketUtils; |
| | | import org.dromara.resource.api.RemoteMessageService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 短信服务 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | @DubboService |
| | | public class RemoteMessageServiceImpl implements RemoteMessageService { |
| | | |
| | | /** |
| | | * 发送消息 |
| | | * |
| | | * @param sessionKey session主键 一般为用户id |
| | | * @param message 消息文本 |
| | | */ |
| | | @Override |
| | | public void sendMessage(Long sessionKey, String message) { |
| | | WebSocketUtils.sendMessage(sessionKey, message); |
| | | } |
| | | |
| | | /** |
| | | * 发布订阅的消息(群发) |
| | | * |
| | | * @param message 消息内容 |
| | | */ |
| | | @Override |
| | | public void publishAll(String message) { |
| | | WebSocketUtils.publishAll(message); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.dubbo; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.config.annotation.DubboService; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.json.utils.JsonUtils; |
| | | import org.dromara.resource.api.RemoteSmsService; |
| | | import org.dromara.resource.api.domain.RemoteSms; |
| | | import org.dromara.sms4j.api.SmsBlend; |
| | | import org.dromara.sms4j.api.entity.SmsResponse; |
| | | import org.dromara.sms4j.core.factory.SmsFactory; |
| | | import org.dromara.sms4j.provider.enumerate.SupplierType; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | |
| | | /** |
| | | * 短信服务 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | @DubboService |
| | | public class RemoteSmsServiceImpl implements RemoteSmsService { |
| | | |
| | | /** |
| | | * 发送短信 |
| | | * |
| | | * @param phones 电话号(多个逗号分割) |
| | | * @param templateId 模板id |
| | | * @param param 模板对应参数 |
| | | */ |
| | | public RemoteSms send(String phones, String templateId, LinkedHashMap<String, String> param) throws ServiceException { |
| | | SmsBlend smsBlend = SmsFactory.createSmsBlend(SupplierType.ALIBABA); |
| | | SmsResponse smsResponse = smsBlend.sendMessage(phones, templateId, param); |
| | | RemoteSms sysSms = new RemoteSms(); |
| | | sysSms.setIsSuccess(smsResponse.isSuccess()); |
| | | sysSms.setMessage(smsResponse.getMessage()); |
| | | sysSms.setResponse(JsonUtils.toJsonString(smsResponse)); |
| | | return sysSms; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.mapper; |
| | | |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.resource.domain.SysOssConfig; |
| | | import org.dromara.resource.domain.vo.SysOssConfigVo; |
| | | |
| | | /** |
| | | * 对象存储配置Mapper接口 |
| | | * |
| | | * @author Lion Li |
| | | * @author 孤舟烟雨 |
| | | * @date 2021-08-13 |
| | | */ |
| | | public interface SysOssConfigMapper extends BaseMapperPlus<SysOssConfig, SysOssConfigVo> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.mapper; |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.resource.domain.SysOss; |
| | | import org.dromara.resource.domain.vo.SysOssVo; |
| | | |
| | | /** |
| | | * 文件上传 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysOssMapper extends BaseMapperPlus<SysOss, SysOssVo> { |
| | | } |
New file |
| | |
| | | package org.dromara.resource.runner; |
| | | |
| | | import org.dromara.resource.service.ISysOssConfigService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.boot.ApplicationArguments; |
| | | import org.springframework.boot.ApplicationRunner; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 初始化 system 模块对应业务数据 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | @Component |
| | | public class ResourceApplicationRunner implements ApplicationRunner { |
| | | |
| | | private final ISysOssConfigService ossConfigService; |
| | | |
| | | @Override |
| | | public void run(ApplicationArguments args) throws Exception { |
| | | ossConfigService.init(); |
| | | log.info("初始化OSS配置成功"); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.service; |
| | | |
| | | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.resource.domain.bo.SysOssConfigBo; |
| | | import org.dromara.resource.domain.vo.SysOssConfigVo; |
| | | |
| | | import java.util.Collection; |
| | | |
| | | /** |
| | | * 对象存储配置Service接口 |
| | | * |
| | | * @author Lion Li |
| | | * @author 孤舟烟雨 |
| | | * @date 2021-08-13 |
| | | */ |
| | | public interface ISysOssConfigService { |
| | | |
| | | /** |
| | | * 初始化OSS配置 |
| | | */ |
| | | void init(); |
| | | |
| | | /** |
| | | * 查询单个 |
| | | */ |
| | | SysOssConfigVo queryById(Long ossConfigId); |
| | | |
| | | /** |
| | | * 查询列表 |
| | | */ |
| | | TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo, PageQuery pageQuery); |
| | | |
| | | |
| | | /** |
| | | * 根据新增业务对象插入对象存储配置 |
| | | * |
| | | * @param bo 对象存储配置新增业务对象 |
| | | * @return |
| | | */ |
| | | Boolean insertByBo(SysOssConfigBo bo); |
| | | |
| | | /** |
| | | * 根据编辑业务对象修改对象存储配置 |
| | | * |
| | | * @param bo 对象存储配置编辑业务对象 |
| | | * @return |
| | | */ |
| | | Boolean updateByBo(SysOssConfigBo bo); |
| | | |
| | | /** |
| | | * 校验并删除数据 |
| | | * |
| | | * @param ids 主键集合 |
| | | * @param isValid 是否校验,true-删除前校验,false-不校验 |
| | | * @return |
| | | */ |
| | | Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
| | | |
| | | /** |
| | | * 启用停用状态 |
| | | */ |
| | | int updateOssConfigStatus(SysOssConfigBo bo); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.service; |
| | | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.resource.domain.bo.SysOssBo; |
| | | import org.dromara.resource.domain.vo.SysOssVo; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 文件上传 服务层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysOssService { |
| | | |
| | | TableDataInfo<SysOssVo> queryPageList(SysOssBo sysOss, PageQuery pageQuery); |
| | | |
| | | List<SysOssVo> listByIds(Collection<Long> ossIds); |
| | | |
| | | String selectUrlByIds(String ossIds); |
| | | |
| | | SysOssVo getById(Long ossId); |
| | | |
| | | SysOssVo upload(MultipartFile file); |
| | | |
| | | SysOssVo upload(File file); |
| | | |
| | | Boolean insertByBo(SysOssBo bo); |
| | | |
| | | void download(Long ossId, HttpServletResponse response) throws IOException; |
| | | |
| | | Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
| | | } |
New file |
| | |
| | | package org.dromara.resource.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.dromara.common.core.constant.CacheNames; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.json.utils.JsonUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.oss.constant.OssConstant; |
| | | import org.dromara.common.redis.utils.CacheUtils; |
| | | import org.dromara.common.redis.utils.RedisUtils; |
| | | import org.dromara.resource.domain.SysOssConfig; |
| | | import org.dromara.resource.domain.bo.SysOssConfigBo; |
| | | import org.dromara.resource.domain.vo.SysOssConfigVo; |
| | | import org.dromara.resource.mapper.SysOssConfigMapper; |
| | | import org.dromara.resource.service.ISysOssConfigService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 对象存储配置Service业务层处理 |
| | | * |
| | | * @author Lion Li |
| | | * @author 孤舟烟雨 |
| | | * @date 2021-08-13 |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysOssConfigServiceImpl implements ISysOssConfigService { |
| | | |
| | | private final SysOssConfigMapper baseMapper; |
| | | |
| | | /** |
| | | * 项目启动时,初始化参数到缓存,加载配置类 |
| | | */ |
| | | @Override |
| | | public void init() { |
| | | List<SysOssConfig> list = baseMapper.selectList(); |
| | | // 加载OSS初始化配置 |
| | | for (SysOssConfig config : list) { |
| | | String configKey = config.getConfigKey(); |
| | | if ("0".equals(config.getStatus())) { |
| | | RedisUtils.setCacheObject(OssConstant.DEFAULT_CONFIG_KEY, configKey); |
| | | } |
| | | CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config)); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public SysOssConfigVo queryById(Long ossConfigId) { |
| | | return baseMapper.selectVoById(ossConfigId); |
| | | } |
| | | |
| | | @Override |
| | | public TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysOssConfig> lqw = buildQueryWrapper(bo); |
| | | Page<SysOssConfigVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | | |
| | | private LambdaQueryWrapper<SysOssConfig> buildQueryWrapper(SysOssConfigBo bo) { |
| | | LambdaQueryWrapper<SysOssConfig> lqw = Wrappers.lambdaQuery(); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getConfigKey()), SysOssConfig::getConfigKey, bo.getConfigKey()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getBucketName()), SysOssConfig::getBucketName, bo.getBucketName()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysOssConfig::getStatus, bo.getStatus()); |
| | | lqw.orderByAsc(SysOssConfig::getOssConfigId); |
| | | return lqw; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean insertByBo(SysOssConfigBo bo) { |
| | | SysOssConfig config = BeanUtil.toBean(bo, SysOssConfig.class); |
| | | validEntityBeforeSave(config); |
| | | boolean flag = baseMapper.insert(config) > 0; |
| | | if (flag) { |
| | | // 从数据库查询完整的数据做缓存 |
| | | config = baseMapper.selectById(config.getOssConfigId()); |
| | | CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config)); |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateByBo(SysOssConfigBo bo) { |
| | | SysOssConfig config = BeanUtil.toBean(bo, SysOssConfig.class); |
| | | validEntityBeforeSave(config); |
| | | LambdaUpdateWrapper<SysOssConfig> luw = new LambdaUpdateWrapper<>(); |
| | | luw.set(ObjectUtil.isNull(config.getPrefix()), SysOssConfig::getPrefix, ""); |
| | | luw.set(ObjectUtil.isNull(config.getRegion()), SysOssConfig::getRegion, ""); |
| | | luw.set(ObjectUtil.isNull(config.getExt1()), SysOssConfig::getExt1, ""); |
| | | luw.set(ObjectUtil.isNull(config.getRemark()), SysOssConfig::getRemark, ""); |
| | | luw.eq(SysOssConfig::getOssConfigId, config.getOssConfigId()); |
| | | boolean flag = baseMapper.update(config, luw) > 0; |
| | | if (flag) { |
| | | // 从数据库查询完整的数据做缓存 |
| | | config = baseMapper.selectById(config.getOssConfigId()); |
| | | CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config)); |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * 保存前的数据校验 |
| | | */ |
| | | private void validEntityBeforeSave(SysOssConfig entity) { |
| | | if (StringUtils.isNotEmpty(entity.getConfigKey()) && !checkConfigKeyUnique(entity)) { |
| | | throw new ServiceException("操作配置'" + entity.getConfigKey() + "'失败, 配置key已存在!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
| | | if (isValid) { |
| | | if (CollUtil.containsAny(ids, OssConstant.SYSTEM_DATA_IDS)) { |
| | | throw new ServiceException("系统内置, 不可删除!"); |
| | | } |
| | | } |
| | | List<SysOssConfig> list = CollUtil.newArrayList(); |
| | | for (Long configId : ids) { |
| | | SysOssConfig config = baseMapper.selectById(configId); |
| | | list.add(config); |
| | | } |
| | | boolean flag = baseMapper.deleteBatchIds(ids) > 0; |
| | | if (flag) { |
| | | list.forEach(sysOssConfig -> |
| | | CacheUtils.evict(CacheNames.SYS_OSS_CONFIG, sysOssConfig.getConfigKey())); |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * 判断configKey是否唯一 |
| | | */ |
| | | private boolean checkConfigKeyUnique(SysOssConfig sysOssConfig) { |
| | | long ossConfigId = ObjectUtil.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId(); |
| | | SysOssConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysOssConfig>() |
| | | .select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey) |
| | | .eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey())); |
| | | if (ObjectUtil.isNotNull(info) && info.getOssConfigId() != ossConfigId) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 启用禁用状态 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int updateOssConfigStatus(SysOssConfigBo bo) { |
| | | SysOssConfig sysOssConfig = BeanUtil.toBean(bo, SysOssConfig.class); |
| | | int row = baseMapper.update(null, new LambdaUpdateWrapper<SysOssConfig>() |
| | | .set(SysOssConfig::getStatus, "1")); |
| | | row += baseMapper.updateById(sysOssConfig); |
| | | if (row > 0) { |
| | | RedisUtils.setCacheObject(OssConstant.DEFAULT_CONFIG_KEY, sysOssConfig.getConfigKey()); |
| | | } |
| | | return row; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.resource.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.CacheNames; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.SpringUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.core.utils.file.FileUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.oss.core.OssClient; |
| | | import org.dromara.common.oss.entity.UploadResult; |
| | | import org.dromara.common.oss.enumd.AccessPolicyType; |
| | | import org.dromara.common.oss.factory.OssFactory; |
| | | import org.dromara.resource.domain.SysOss; |
| | | import org.dromara.resource.domain.bo.SysOssBo; |
| | | import org.dromara.resource.domain.vo.SysOssVo; |
| | | import org.dromara.resource.mapper.SysOssMapper; |
| | | import org.dromara.resource.service.ISysOssService; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 文件上传 服务层实现 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysOssServiceImpl implements ISysOssService { |
| | | |
| | | private final SysOssMapper baseMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysOss> lqw = buildQueryWrapper(bo); |
| | | Page<SysOssVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | List<SysOssVo> filterResult = result.getRecords().stream().map(this::matchingUrl).collect(Collectors.toList()); |
| | | result.setRecords(filterResult); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysOssVo> listByIds(Collection<Long> ossIds) { |
| | | List<SysOssVo> list = new ArrayList<>(); |
| | | for (Long id : ossIds) { |
| | | SysOssVo vo = getById(id); |
| | | if (ObjectUtil.isNotNull(vo)) { |
| | | try { |
| | | list.add(this.matchingUrl(vo)); |
| | | } catch (Exception ignored) { |
| | | // 如果oss异常无法连接则将数据直接返回 |
| | | list.add(vo); |
| | | } } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public String selectUrlByIds(String ossIds) { |
| | | List<String> list = new ArrayList<>(); |
| | | for (Long id : StringUtils.splitTo(ossIds, Convert::toLong)) { |
| | | SysOssVo vo = SpringUtils.getAopProxy(this).getById(id); |
| | | if (ObjectUtil.isNotNull(vo)) { |
| | | try { |
| | | list.add(this.matchingUrl(vo).getUrl()); |
| | | } catch (Exception ignored) { |
| | | // 如果oss异常无法连接则将数据直接返回 |
| | | list.add(vo.getUrl()); |
| | | } |
| | | } |
| | | } |
| | | return String.join(StringUtils.SEPARATOR, list); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<SysOss> buildQueryWrapper(SysOssBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | LambdaQueryWrapper<SysOss> lqw = Wrappers.lambdaQuery(); |
| | | lqw.like(StringUtils.isNotBlank(bo.getFileName()), SysOss::getFileName, bo.getFileName()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getOriginalName()), SysOss::getOriginalName, bo.getOriginalName()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getFileSuffix()), SysOss::getFileSuffix, bo.getFileSuffix()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getUrl()), SysOss::getUrl, bo.getUrl()); |
| | | lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null, |
| | | SysOss::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); |
| | | lqw.eq(ObjectUtil.isNotNull(bo.getCreateBy()), SysOss::getCreateBy, bo.getCreateBy()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getService()), SysOss::getService, bo.getService()); |
| | | lqw.orderByAsc(SysOss::getOssId); |
| | | return lqw; |
| | | } |
| | | |
| | | @Cacheable(cacheNames = CacheNames.SYS_OSS, key = "#ossId") |
| | | @Override |
| | | public SysOssVo getById(Long ossId) { |
| | | return baseMapper.selectVoById(ossId); |
| | | } |
| | | |
| | | @Override |
| | | public void download(Long ossId, HttpServletResponse response) throws IOException { |
| | | SysOssVo sysOss = SpringUtils.getAopProxy(this).getById(ossId); |
| | | if (ObjectUtil.isNull(sysOss)) { |
| | | throw new ServiceException("文件数据不存在!"); |
| | | } |
| | | FileUtils.setAttachmentResponseHeader(response, sysOss.getOriginalName()); |
| | | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8"); |
| | | OssClient storage = OssFactory.instance(sysOss.getService()); |
| | | try(InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) { |
| | | int available = inputStream.available(); |
| | | IoUtil.copy(inputStream, response.getOutputStream(), available); |
| | | response.setContentLength(available); |
| | | } catch (Exception e) { |
| | | throw new ServiceException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public SysOssVo upload(MultipartFile file) { |
| | | String originalfileName = file.getOriginalFilename(); |
| | | String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length()); |
| | | OssClient storage = OssFactory.instance(); |
| | | UploadResult uploadResult; |
| | | try { |
| | | uploadResult = storage.uploadSuffix(file.getBytes(), suffix, file.getContentType()); |
| | | } catch (IOException e) { |
| | | throw new ServiceException(e.getMessage()); |
| | | } |
| | | // 保存文件信息 |
| | | return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult); |
| | | } |
| | | |
| | | @Override |
| | | public SysOssVo upload(File file) { |
| | | String originalfileName = file.getName(); |
| | | String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length()); |
| | | OssClient storage = OssFactory.instance(); |
| | | UploadResult uploadResult = storage.uploadSuffix(file, suffix); |
| | | // 保存文件信息 |
| | | return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult); |
| | | } |
| | | |
| | | private SysOssVo buildResultEntity(String originalfileName, String suffix, String configKey, UploadResult uploadResult) { |
| | | SysOss oss = new SysOss(); |
| | | oss.setUrl(uploadResult.getUrl()); |
| | | oss.setFileSuffix(suffix); |
| | | oss.setFileName(uploadResult.getFilename()); |
| | | oss.setOriginalName(originalfileName); |
| | | oss.setService(configKey); |
| | | baseMapper.insert(oss); |
| | | SysOssVo sysOssVo = MapstructUtils.convert(oss, SysOssVo.class); |
| | | return this.matchingUrl(sysOssVo); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean insertByBo(SysOssBo bo) { |
| | | SysOss oss = BeanUtil.toBean(bo, SysOss.class); |
| | | boolean flag = baseMapper.insert(oss) > 0; |
| | | if (flag) { |
| | | bo.setOssId(oss.getOssId()); |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
| | | if (isValid) { |
| | | // 做一些业务上的校验,判断是否需要校验 |
| | | } |
| | | List<SysOss> list = baseMapper.selectBatchIds(ids); |
| | | for (SysOss sysOss : list) { |
| | | OssClient storage = OssFactory.instance(sysOss.getService()); |
| | | storage.delete(sysOss.getUrl()); |
| | | } |
| | | return baseMapper.deleteBatchIds(ids) > 0; |
| | | } |
| | | |
| | | /** |
| | | * 匹配Url |
| | | * |
| | | * @param oss OSS对象 |
| | | * @return oss 匹配Url的OSS对象 |
| | | */ |
| | | private SysOssVo matchingUrl(SysOssVo oss) { |
| | | OssClient storage = OssFactory.instance(oss.getService()); |
| | | // 仅修改桶类型为 private 的URL,临时URL时长为120s |
| | | if (AccessPolicyType.PRIVATE == storage.getAccessPolicy()) { |
| | | oss.setUrl(storage.getPrivateUrl(oss.getFileName(), 120)); |
| | | } |
| | | return oss; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | # Tomcat |
| | | server: |
| | | port: 9204 |
| | | |
| | | # Spring |
| | | spring: |
| | | application: |
| | | # 应用名称 |
| | | name: ruoyi-resource |
| | | profiles: |
| | | # 环境配置 |
| | | active: @profiles.active@ |
| | | |
| | | --- # nacos 配置 |
| | | spring: |
| | | cloud: |
| | | nacos: |
| | | # nacos 服务地址 |
| | | server-addr: @nacos.server@ |
| | | discovery: |
| | | # 注册组 |
| | | group: @nacos.discovery.group@ |
| | | namespace: ${spring.profiles.active} |
| | | config: |
| | | # 配置组 |
| | | group: @nacos.config.group@ |
| | | namespace: ${spring.profiles.active} |
| | | config: |
| | | import: |
| | | - optional:nacos:application-common.yml |
| | | - optional:nacos:datasource.yml |
| | | - optional:nacos:${spring.application.name}.yml |
New file |
| | |
| | | Spring Boot Version: ${spring-boot.version} |
| | | Spring Application Name: ${spring.application.name} |
| | | _ |
| | | (_) |
| | | _ __ _ _ ___ _ _ _ ______ _ __ ___ ___ ___ _ _ _ __ ___ ___ |
| | | | '__| | | |/ _ \| | | | |______| '__/ _ \/ __|/ _ \| | | | '__/ __/ _ \ |
| | | | | | |_| | (_) | |_| | | | | | __/\__ \ (_) | |_| | | | (_| __/ |
| | | |_| \__,_|\___/ \__, |_| |_| \___||___/\___/ \__,_|_| \___\___| |
| | | __/ | |
| | | |___/ |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <configuration scan="true" scanPeriod="60 seconds" debug="false"> |
| | | <!-- 日志存放路径 --> |
| | | <property name="log.path" value="logs/${project.artifactId}"/> |
| | | <!-- 日志输出格式 --> |
| | | <property name="console.log.pattern" |
| | | value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/> |
| | | |
| | | <!-- 控制台输出 --> |
| | | <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> |
| | | <encoder> |
| | | <pattern>${console.log.pattern}</pattern> |
| | | <charset>utf-8</charset> |
| | | </encoder> |
| | | </appender> |
| | | |
| | | <include resource="logback-common.xml" /> |
| | | |
| | | <include resource="logback-logstash.xml" /> |
| | | |
| | | <!-- 开启 skywalking 日志收集 --> |
| | | <include resource="logback-skylog.xml" /> |
| | | |
| | | <!--系统操作日志--> |
| | | <root level="info"> |
| | | <appender-ref ref="console"/> |
| | | </root> |
| | | </configuration> |
New file |
| | |
| | | java包使用 `.` 分割 resource 目录使用 `/` 分割 |
| | | <br> |
| | | 此文件目的 防止文件夹粘连找不到 `xml` 文件 |
New file |
| | |
| | | <?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.dromara.resource.mapper.SysOssConfigMapper"> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?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.dromara.resource.mapper.SysOssMapper"> |
| | | |
| | | </mapper> |
New file |
| | |
| | | # p6spy 性能分析插件配置文件 |
| | | modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory |
| | | # 自定义日志打印 |
| | | logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger |
| | | #日志输出到控制台 |
| | | appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger |
| | | # 使用日志系统记录 sql |
| | | #appender=com.p6spy.engine.spy.appender.Slf4JLogger |
| | | # 设置 p6spy driver 代理 |
| | | #deregisterdrivers=true |
| | | # 取消JDBC URL前缀 |
| | | useprefix=true |
| | | # 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset. |
| | | excludecategories=info,debug,result,commit,resultset |
| | | # 日期格式 |
| | | dateformat=yyyy-MM-dd HH:mm:ss |
| | | # SQL语句打印时间格式 |
| | | databaseDialectTimestampFormat=yyyy-MM-dd HH:mm:ss |
| | | # 实际驱动可多个 |
| | | #driverlist=org.h2.Driver |
| | | # 是否开启慢SQL记录 |
| | | outagedetection=true |
| | | # 慢SQL记录标准 2 秒 |
| | | outagedetectioninterval=2 |
| | | # 是否过滤 Log |
| | | filter=true |
| | | # 过滤 Log 时所排除的 sql 关键字,以逗号分隔 |
| | | exclude=SELECT 1 |
New file |
| | |
| | | #FROM findepi/graalvm:java17-native |
| | | FROM openjdk:17.0.2-oraclelinux8 |
| | | |
| | | MAINTAINER Lion Li |
| | | |
| | | RUN mkdir -p /ruoyi/system/logs \ |
| | | /ruoyi/system/temp \ |
| | | /ruoyi/skywalking/agent |
| | | |
| | | WORKDIR /ruoyi/system |
| | | |
| | | ENV SERVER_PORT=9201 LANG=C.UTF-8 LC_ALL=C.UTF-8 JAVA_OPTS="" |
| | | |
| | | EXPOSE ${SERVER_PORT} |
| | | |
| | | ADD ./target/ruoyi-system.jar ./app.jar |
| | | |
| | | ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${SERVER_PORT} \ |
| | | #-Dskywalking.agent.service_name=ruoyi-system \ |
| | | #-javaagent:/ruoyi/skywalking/agent/skywalking-agent.jar \ |
| | | -jar app.jar \ |
| | | -XX:+HeapDumpOnOutOfMemoryError -Xlog:gc*,:time,tags,level -XX:+UseZGC ${JAVA_OPTS} |
| | | |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <parent> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-modules</artifactId> |
| | | <version>${revision}</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>ruoyi-system</artifactId> |
| | | |
| | | <description> |
| | | ruoyi-system系统模块 |
| | | </description> |
| | | |
| | | <dependencies> |
| | | |
| | | <!-- SpringCloud Alibaba Nacos --> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- SpringCloud Alibaba Nacos Config --> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-sentinel</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- RuoYi Common Log --> |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-log</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-dict</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-doc</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-web</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-mybatis</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-dubbo</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-seata</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-idempotent</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-tenant</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-security</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-translation</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-sensitive</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-common-encrypt</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- RuoYi Api System --> |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-api-system</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.dromara</groupId> |
| | | <artifactId>ruoyi-api-resource</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <finalName>${project.artifactId}</finalName> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <version>${spring-boot.version}</version> |
| | | <executions> |
| | | <execution> |
| | | <goals> |
| | | <goal>repackage</goal> |
| | | </goals> |
| | | </execution> |
| | | </executions> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | |
| | | </project> |
New file |
| | |
| | | package org.dromara.system; |
| | | |
| | | import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup; |
| | | |
| | | /** |
| | | * 系统模块 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @EnableDubbo |
| | | @SpringBootApplication |
| | | public class RuoYiSystemApplication { |
| | | public static void main(String[] args) { |
| | | SpringApplication application = new SpringApplication(RuoYiSystemApplication.class); |
| | | application.setApplicationStartup(new BufferingApplicationStartup(2048)); |
| | | application.run(args); |
| | | System.out.println("(♥◠‿◠)ノ゙ 系统模块启动成功 ლ(´ڡ`ლ)゙ "); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.monitor; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.system.domain.vo.CacheListInfoVo; |
| | | import org.redisson.spring.data.connection.RedissonConnectionFactory; |
| | | import org.springframework.data.redis.connection.RedisConnection; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 缓存监控 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/cache") |
| | | public class CacheController { |
| | | |
| | | private final RedissonConnectionFactory connectionFactory; |
| | | |
| | | /** |
| | | * 获取缓存监控列表 |
| | | */ |
| | | @SaCheckPermission("monitor:cache:list") |
| | | @GetMapping() |
| | | public R<CacheListInfoVo> getInfo() throws Exception { |
| | | RedisConnection connection = connectionFactory.getConnection(); |
| | | Properties commandStats = connection.commands().info("commandstats"); |
| | | |
| | | List<Map<String, String>> pieList = new ArrayList<>(); |
| | | if (commandStats != null) { |
| | | commandStats.stringPropertyNames().forEach(key -> { |
| | | Map<String, String> data = new HashMap<>(2); |
| | | String property = commandStats.getProperty(key); |
| | | data.put("name", StringUtils.removeStart(key, "cmdstat_")); |
| | | data.put("value", StringUtils.substringBetween(property, "calls=", ",usec")); |
| | | pieList.add(data); |
| | | }); |
| | | } |
| | | |
| | | CacheListInfoVo infoVo = new CacheListInfoVo(); |
| | | infoVo.setInfo(connection.commands().info()); |
| | | infoVo.setDbSize(connection.commands().dbSize()); |
| | | infoVo.setCommandStats(pieList); |
| | | return R.ok(infoVo); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.monitor; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.GlobalConstants; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.redis.utils.RedisUtils; |
| | | import org.dromara.system.domain.bo.SysLogininforBo; |
| | | import org.dromara.system.domain.vo.SysLogininforVo; |
| | | import org.dromara.system.service.ISysLogininforService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 系统访问记录 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/logininfor") |
| | | public class SysLogininforController extends BaseController { |
| | | |
| | | private final ISysLogininforService logininforService; |
| | | |
| | | /** |
| | | * 获取系统访问记录列表 |
| | | */ |
| | | @SaCheckPermission("monitor:logininfor:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysLogininforVo> list(SysLogininforBo logininfor, PageQuery pageQuery) { |
| | | return logininforService.selectPageLogininforList(logininfor, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出系统访问记录列表 |
| | | */ |
| | | @Log(title = "登录日志", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("monitor:logininfor:export") |
| | | @PostMapping("/export") |
| | | public void export(SysLogininforBo logininfor, HttpServletResponse response) { |
| | | List<SysLogininforVo> list = logininforService.selectLogininforList(logininfor); |
| | | ExcelUtil.exportExcel(list, "登录日志", SysLogininforVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除登录日志 |
| | | * @param infoIds 日志ids |
| | | */ |
| | | @SaCheckPermission("monitor:logininfor:remove") |
| | | @Log(title = "登录日志", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{infoIds}") |
| | | public R<Void> remove(@PathVariable Long[] infoIds) { |
| | | return toAjax(logininforService.deleteLogininforByIds(infoIds)); |
| | | } |
| | | |
| | | /** |
| | | * 清理系统访问记录 |
| | | */ |
| | | @SaCheckPermission("monitor:logininfor:remove") |
| | | @Log(title = "登录日志", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/clean") |
| | | public R<Void> clean() { |
| | | logininforService.cleanLogininfor(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @SaCheckPermission("monitor:logininfor:unlock") |
| | | @Log(title = "账户解锁", businessType = BusinessType.OTHER) |
| | | @GetMapping("/unlock/{userName}") |
| | | public R<Void> unlock(@PathVariable("userName") String userName) { |
| | | String loginName = GlobalConstants.PWD_ERR_CNT_KEY + userName; |
| | | if (RedisUtils.hasKey(loginName)) { |
| | | RedisUtils.deleteObject(loginName); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.monitor; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysOperLogBo; |
| | | import org.dromara.system.domain.vo.SysOperLogVo; |
| | | import org.dromara.system.service.ISysOperLogService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 操作日志记录 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/operlog") |
| | | public class SysOperlogController extends BaseController { |
| | | |
| | | private final ISysOperLogService operLogService; |
| | | |
| | | /** |
| | | * 获取操作日志记录列表 |
| | | */ |
| | | @SaCheckPermission("monitor:operlog:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysOperLogVo> list(SysOperLogBo operLog, PageQuery pageQuery) { |
| | | return operLogService.selectPageOperLogList(operLog, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出操作日志记录列表 |
| | | */ |
| | | @Log(title = "操作日志", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("monitor:operlog:export") |
| | | @PostMapping("/export") |
| | | public void export(SysOperLogBo operLog, HttpServletResponse response) { |
| | | List<SysOperLogVo> list = operLogService.selectOperLogList(operLog); |
| | | ExcelUtil.exportExcel(list, "操作日志", SysOperLogVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除操作日志记录 |
| | | * @param operIds 日志ids |
| | | */ |
| | | @Log(title = "操作日志", businessType = BusinessType.DELETE) |
| | | @SaCheckPermission("monitor:operlog:remove") |
| | | @DeleteMapping("/{operIds}") |
| | | public R<Void> remove(@PathVariable Long[] operIds) { |
| | | return toAjax(operLogService.deleteOperLogByIds(operIds)); |
| | | } |
| | | |
| | | /** |
| | | * 清理操作日志记录 |
| | | */ |
| | | @SaCheckPermission("monitor:operlog:remove") |
| | | @Log(title = "操作日志", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/clean") |
| | | public R<Void> clean() { |
| | | operLogService.cleanOperLog(); |
| | | return R.ok(); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.monitor; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.dev33.satoken.exception.NotLoginException; |
| | | import cn.dev33.satoken.stp.StpUtil; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.CacheConstants; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.utils.StreamUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.redis.utils.RedisUtils; |
| | | import org.dromara.system.api.domain.SysUserOnline; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 在线用户监控 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/online") |
| | | public class SysUserOnlineController extends BaseController { |
| | | |
| | | /** |
| | | * 获取在线用户监控列表 |
| | | * |
| | | * @param ipaddr IP地址 |
| | | * @param userName 用户名 |
| | | */ |
| | | @SaCheckPermission("monitor:online:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysUserOnline> list(String ipaddr, String userName) { |
| | | // 获取所有未过期的 token |
| | | List<String> keys = StpUtil.searchTokenValue("", 0, -1, false); |
| | | List<SysUserOnline> userOnlineDTOList = new ArrayList<>(); |
| | | for (String key : keys) { |
| | | String token = StringUtils.substringAfterLast(key, ":"); |
| | | // 如果已经过期则跳过 |
| | | if (StpUtil.stpLogic.getTokenActiveTimeoutByToken(token) < -1) { |
| | | continue; |
| | | } |
| | | userOnlineDTOList.add(RedisUtils.getCacheObject(CacheConstants.ONLINE_TOKEN_KEY + token)); |
| | | } |
| | | if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) { |
| | | userOnlineDTOList = StreamUtils.filter(userOnlineDTOList, userOnline -> |
| | | StringUtils.equals(ipaddr, userOnline.getIpaddr()) && |
| | | StringUtils.equals(userName, userOnline.getUserName()) |
| | | ); |
| | | } else if (StringUtils.isNotEmpty(ipaddr)) { |
| | | userOnlineDTOList = StreamUtils.filter(userOnlineDTOList, userOnline -> |
| | | StringUtils.equals(ipaddr, userOnline.getIpaddr()) |
| | | ); |
| | | } else if (StringUtils.isNotEmpty(userName)) { |
| | | userOnlineDTOList = StreamUtils.filter(userOnlineDTOList, userOnline -> |
| | | StringUtils.equals(userName, userOnline.getUserName()) |
| | | ); |
| | | } |
| | | Collections.reverse(userOnlineDTOList); |
| | | userOnlineDTOList.removeAll(Collections.singleton(null)); |
| | | List<SysUserOnline> userOnlineList = BeanUtil.copyToList(userOnlineDTOList, SysUserOnline.class); |
| | | return TableDataInfo.build(userOnlineList); |
| | | } |
| | | |
| | | /** |
| | | * 强退用户 |
| | | * |
| | | * @param tokenId token值 |
| | | */ |
| | | @SaCheckPermission("monitor:online:forceLogout") |
| | | @Log(title = "在线用户", businessType = BusinessType.FORCE) |
| | | @DeleteMapping("/{tokenId}") |
| | | public R<Void> forceLogout(@PathVariable String tokenId) { |
| | | try { |
| | | StpUtil.kickoutByTokenValue(tokenId); |
| | | } catch (NotLoginException ignored) { |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.common.idempotent.annotation.RepeatSubmit; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.system.domain.bo.SysClientBo; |
| | | import org.dromara.system.domain.vo.SysClientVo; |
| | | import org.dromara.system.service.ISysClientService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 客户端管理 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/client") |
| | | public class SysClientController extends BaseController { |
| | | |
| | | private final ISysClientService sysClientService; |
| | | |
| | | /** |
| | | * 查询客户端管理列表 |
| | | */ |
| | | @SaCheckPermission("system:client:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysClientVo> list(SysClientBo bo, PageQuery pageQuery) { |
| | | return sysClientService.queryPageList(bo, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出客户端管理列表 |
| | | */ |
| | | @SaCheckPermission("system:client:export") |
| | | @Log(title = "客户端管理", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(SysClientBo bo, HttpServletResponse response) { |
| | | List<SysClientVo> list = sysClientService.queryList(bo); |
| | | ExcelUtil.exportExcel(list, "客户端管理", SysClientVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 获取客户端管理详细信息 |
| | | * |
| | | * @param id 主键 |
| | | */ |
| | | @SaCheckPermission("system:client:query") |
| | | @GetMapping("/{id}") |
| | | public R<SysClientVo> getInfo(@NotNull(message = "主键不能为空") |
| | | @PathVariable Long id) { |
| | | return R.ok(sysClientService.queryById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 新增客户端管理 |
| | | */ |
| | | @SaCheckPermission("system:client:add") |
| | | @Log(title = "客户端管理", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit() |
| | | @PostMapping() |
| | | public R<Void> add(@Validated(AddGroup.class) @RequestBody SysClientBo bo) { |
| | | return toAjax(sysClientService.insertByBo(bo)); |
| | | } |
| | | |
| | | /** |
| | | * 修改客户端管理 |
| | | */ |
| | | @SaCheckPermission("system:client:edit") |
| | | @Log(title = "客户端管理", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit() |
| | | @PutMapping() |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysClientBo bo) { |
| | | return toAjax(sysClientService.updateByBo(bo)); |
| | | } |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @SaCheckPermission("system:client:edit") |
| | | @Log(title = "客户端管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public R<Void> changeStatus(@RequestBody SysClientBo bo) { |
| | | return toAjax(sysClientService.updateUserStatus(bo.getId(), bo.getStatus())); |
| | | } |
| | | |
| | | /** |
| | | * 删除客户端管理 |
| | | * |
| | | * @param ids 主键串 |
| | | */ |
| | | @SaCheckPermission("system:client:remove") |
| | | @Log(title = "客户端管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ids) { |
| | | return toAjax(sysClientService.deleteWithValidByIds(List.of(ids), true)); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysConfigBo; |
| | | import org.dromara.system.domain.vo.SysConfigVo; |
| | | import org.dromara.system.service.ISysConfigService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 参数配置 信息操作处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/config") |
| | | public class SysConfigController extends BaseController { |
| | | |
| | | private final ISysConfigService configService; |
| | | |
| | | /** |
| | | * 获取参数配置列表 |
| | | */ |
| | | @SaCheckPermission("system:config:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysConfigVo> list(SysConfigBo config, PageQuery pageQuery) { |
| | | return configService.selectPageConfigList(config, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出参数配置列表 |
| | | */ |
| | | @Log(title = "参数管理", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:config:export") |
| | | @PostMapping("/export") |
| | | public void export(SysConfigBo config, HttpServletResponse response) { |
| | | List<SysConfigVo> list = configService.selectConfigList(config); |
| | | ExcelUtil.exportExcel(list, "参数数据", SysConfigVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 根据参数编号获取详细信息 |
| | | * |
| | | * @param configId 参数ID |
| | | */ |
| | | @SaCheckPermission("system:config:query") |
| | | @GetMapping(value = "/{configId}") |
| | | public R<SysConfigVo> getInfo(@PathVariable Long configId) { |
| | | return R.ok(configService.selectConfigById(configId)); |
| | | } |
| | | |
| | | /** |
| | | * 根据参数键名查询参数值 |
| | | * |
| | | * @param configKey 参数Key |
| | | */ |
| | | @GetMapping(value = "/configKey/{configKey}") |
| | | public R<String> getConfigKey(@PathVariable String configKey) { |
| | | return R.ok("操作成功", configService.selectConfigByKey(configKey)); |
| | | } |
| | | |
| | | /** |
| | | * 新增参数配置 |
| | | */ |
| | | @SaCheckPermission("system:config:add") |
| | | @Log(title = "参数管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public R<Void> add(@Validated @RequestBody SysConfigBo config) { |
| | | if (!configService.checkConfigKeyUnique(config)) { |
| | | return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); |
| | | } |
| | | configService.insertConfig(config); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改参数配置 |
| | | */ |
| | | @SaCheckPermission("system:config:edit") |
| | | @Log(title = "参数管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public R<Void> edit(@Validated @RequestBody SysConfigBo config) { |
| | | if (!configService.checkConfigKeyUnique(config)) { |
| | | return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); |
| | | } |
| | | configService.updateConfig(config); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 根据参数键名修改参数配置 |
| | | */ |
| | | @SaCheckPermission("system:config:edit") |
| | | @Log(title = "参数管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updateByKey") |
| | | public R<Void> updateByKey(@RequestBody SysConfigBo config) { |
| | | configService.updateConfig(config); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除参数配置 |
| | | * |
| | | * @param configIds 参数ID串 |
| | | */ |
| | | @SaCheckPermission("system:config:remove") |
| | | @Log(title = "参数管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{configIds}") |
| | | public R<Void> remove(@PathVariable Long[] configIds) { |
| | | configService.deleteConfigByIds(configIds); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 刷新参数缓存 |
| | | */ |
| | | @SaCheckPermission("system:config:remove") |
| | | @Log(title = "参数管理", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/refreshCache") |
| | | public R<Void> refreshCache() { |
| | | configService.resetConfigCache(); |
| | | return R.ok(); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.hutool.core.convert.Convert; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.system.domain.bo.SysDeptBo; |
| | | import org.dromara.system.domain.vo.SysDeptVo; |
| | | import org.dromara.system.service.ISysDeptService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 部门信息 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/dept") |
| | | public class SysDeptController extends BaseController { |
| | | |
| | | private final ISysDeptService deptService; |
| | | |
| | | /** |
| | | * 获取部门列表 |
| | | */ |
| | | @SaCheckPermission("system:dept:list") |
| | | @GetMapping("/list") |
| | | public R<List<SysDeptVo>> list(SysDeptBo dept) { |
| | | List<SysDeptVo> depts = deptService.selectDeptList(dept); |
| | | return R.ok(depts); |
| | | } |
| | | |
| | | /** |
| | | * 查询部门列表(排除节点) |
| | | * |
| | | * @param deptId 部门ID |
| | | */ |
| | | @SaCheckPermission("system:dept:list") |
| | | @GetMapping("/list/exclude/{deptId}") |
| | | public R<List<SysDeptVo>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) { |
| | | List<SysDeptVo> depts = deptService.selectDeptList(new SysDeptBo()); |
| | | depts.removeIf(d -> d.getDeptId().equals(deptId) |
| | | || StringUtils.splitList(d.getAncestors()).contains(Convert.toStr(deptId))); |
| | | return R.ok(depts); |
| | | } |
| | | |
| | | /** |
| | | * 根据部门编号获取详细信息 |
| | | * |
| | | * @param deptId 部门ID |
| | | */ |
| | | @SaCheckPermission("system:dept:query") |
| | | @GetMapping(value = "/{deptId}") |
| | | public R<SysDeptVo> getInfo(@PathVariable Long deptId) { |
| | | deptService.checkDeptDataScope(deptId); |
| | | return R.ok(deptService.selectDeptById(deptId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增部门 |
| | | */ |
| | | @SaCheckPermission("system:dept:add") |
| | | @Log(title = "部门管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public R<Void> add(@Validated @RequestBody SysDeptBo dept) { |
| | | if (!deptService.checkDeptNameUnique(dept)) { |
| | | return R.fail("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); |
| | | } |
| | | return toAjax(deptService.insertDept(dept)); |
| | | } |
| | | |
| | | /** |
| | | * 修改部门 |
| | | */ |
| | | @SaCheckPermission("system:dept:edit") |
| | | @Log(title = "部门管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public R<Void> edit(@Validated @RequestBody SysDeptBo dept) { |
| | | Long deptId = dept.getDeptId(); |
| | | deptService.checkDeptDataScope(deptId); |
| | | if (!deptService.checkDeptNameUnique(dept)) { |
| | | return R.fail("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); |
| | | } else if (dept.getParentId().equals(deptId)) { |
| | | return R.fail("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); |
| | | } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())) { |
| | | if (deptService.selectNormalChildrenDeptById(deptId) > 0) { |
| | | return R.fail("该部门包含未停用的子部门!"); |
| | | } else if (deptService.checkDeptExistUser(deptId)) { |
| | | return R.fail("该部门下存在已分配用户,不能禁用!"); |
| | | } |
| | | } |
| | | return toAjax(deptService.updateDept(dept)); |
| | | } |
| | | |
| | | /** |
| | | * 删除部门 |
| | | * |
| | | * @param deptId 部门ID |
| | | */ |
| | | @SaCheckPermission("system:dept:remove") |
| | | @Log(title = "部门管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deptId}") |
| | | public R<Void> remove(@PathVariable Long deptId) { |
| | | if (deptService.hasChildByDeptId(deptId)) { |
| | | return R.warn("存在下级部门,不允许删除"); |
| | | } |
| | | if (deptService.checkDeptExistUser(deptId)) { |
| | | return R.warn("部门存在用户,不允许删除"); |
| | | } |
| | | deptService.checkDeptDataScope(deptId); |
| | | return toAjax(deptService.deleteDeptById(deptId)); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysDictDataBo; |
| | | import org.dromara.system.domain.vo.SysDictDataVo; |
| | | import org.dromara.system.service.ISysDictDataService; |
| | | import org.dromara.system.service.ISysDictTypeService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 数据字典信息 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/dict/data") |
| | | public class SysDictDataController extends BaseController { |
| | | |
| | | private final ISysDictDataService dictDataService; |
| | | private final ISysDictTypeService dictTypeService; |
| | | |
| | | /** |
| | | * 查询字典数据列表 |
| | | */ |
| | | @SaCheckPermission("system:dict:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysDictDataVo> list(SysDictDataBo dictData, PageQuery pageQuery) { |
| | | return dictDataService.selectPageDictDataList(dictData, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出字典数据列表 |
| | | */ |
| | | @Log(title = "字典数据", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:dict:export") |
| | | @PostMapping("/export") |
| | | public void export(SysDictDataBo dictData, HttpServletResponse response) { |
| | | List<SysDictDataVo> list = dictDataService.selectDictDataList(dictData); |
| | | ExcelUtil.exportExcel(list, "字典数据", SysDictDataVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 查询字典数据详细 |
| | | * |
| | | * @param dictCode 字典code |
| | | */ |
| | | @SaCheckPermission("system:dict:query") |
| | | @GetMapping(value = "/{dictCode}") |
| | | public R<SysDictDataVo> getInfo(@PathVariable Long dictCode) { |
| | | return R.ok(dictDataService.selectDictDataById(dictCode)); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型查询字典数据信息 |
| | | * |
| | | * @param dictType 字典类型 |
| | | */ |
| | | @GetMapping(value = "/type/{dictType}") |
| | | public R<List<SysDictDataVo>> dictType(@PathVariable String dictType) { |
| | | List<SysDictDataVo> data = dictTypeService.selectDictDataByType(dictType); |
| | | if (ObjectUtil.isNull(data)) { |
| | | data = new ArrayList<>(); |
| | | } |
| | | return R.ok(data); |
| | | } |
| | | |
| | | /** |
| | | * 新增字典类型 |
| | | */ |
| | | @SaCheckPermission("system:dict:add") |
| | | @Log(title = "字典数据", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public R<Void> add(@Validated @RequestBody SysDictDataBo dict) { |
| | | dictDataService.insertDictData(dict); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存字典类型 |
| | | */ |
| | | @SaCheckPermission("system:dict:edit") |
| | | @Log(title = "字典数据", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public R<Void> edit(@Validated @RequestBody SysDictDataBo dict) { |
| | | dictDataService.updateDictData(dict); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除字典类型 |
| | | * |
| | | * @param dictCodes 字典code串 |
| | | */ |
| | | @SaCheckPermission("system:dict:remove") |
| | | @Log(title = "字典类型", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictCodes}") |
| | | public R<Void> remove(@PathVariable Long[] dictCodes) { |
| | | dictDataService.deleteDictDataByIds(dictCodes); |
| | | return R.ok(); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysDictTypeBo; |
| | | import org.dromara.system.domain.vo.SysDictTypeVo; |
| | | import org.dromara.system.service.ISysDictTypeService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 数据字典信息 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/dict/type") |
| | | public class SysDictTypeController extends BaseController { |
| | | |
| | | private final ISysDictTypeService dictTypeService; |
| | | |
| | | /** |
| | | * 查询字典类型列表 |
| | | */ |
| | | @SaCheckPermission("system:dict:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysDictTypeVo> list(SysDictTypeBo dictType, PageQuery pageQuery) { |
| | | return dictTypeService.selectPageDictTypeList(dictType, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出字典类型列表 |
| | | */ |
| | | @Log(title = "字典类型", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:dict:export") |
| | | @PostMapping("/export") |
| | | public void export(SysDictTypeBo dictType, HttpServletResponse response) { |
| | | List<SysDictTypeVo> list = dictTypeService.selectDictTypeList(dictType); |
| | | ExcelUtil.exportExcel(list, "字典类型", SysDictTypeVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 查询字典类型详细 |
| | | * |
| | | * @param dictId 字典ID |
| | | */ |
| | | @SaCheckPermission("system:dict:query") |
| | | @GetMapping(value = "/{dictId}") |
| | | public R<SysDictTypeVo> getInfo(@PathVariable Long dictId) { |
| | | return R.ok(dictTypeService.selectDictTypeById(dictId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增字典类型 |
| | | */ |
| | | @SaCheckPermission("system:dict:add") |
| | | @Log(title = "字典类型", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public R<Void> add(@Validated @RequestBody SysDictTypeBo dict) { |
| | | if (!dictTypeService.checkDictTypeUnique(dict)) { |
| | | return R.fail("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); |
| | | } |
| | | dictTypeService.insertDictType(dict); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改字典类型 |
| | | */ |
| | | @SaCheckPermission("system:dict:edit") |
| | | @Log(title = "字典类型", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public R<Void> edit(@Validated @RequestBody SysDictTypeBo dict) { |
| | | if (!dictTypeService.checkDictTypeUnique(dict)) { |
| | | return R.fail("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); |
| | | } |
| | | dictTypeService.updateDictType(dict); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除字典类型 |
| | | * |
| | | * @param dictIds 字典ID串 |
| | | */ |
| | | @SaCheckPermission("system:dict:remove") |
| | | @Log(title = "字典类型", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictIds}") |
| | | public R<Void> remove(@PathVariable Long[] dictIds) { |
| | | dictTypeService.deleteDictTypeByIds(dictIds); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 刷新字典缓存 |
| | | */ |
| | | @SaCheckPermission("system:dict:remove") |
| | | @Log(title = "字典类型", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/refreshCache") |
| | | public R<Void> refreshCache() { |
| | | dictTypeService.resetDictCache(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典选择框列表 |
| | | */ |
| | | @GetMapping("/optionselect") |
| | | public R<List<SysDictTypeVo>> optionselect() { |
| | | List<SysDictTypeVo> dictTypes = dictTypeService.selectDictTypeAll(); |
| | | return R.ok(dictTypes); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.dev33.satoken.annotation.SaCheckRole; |
| | | import cn.dev33.satoken.annotation.SaMode; |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.TenantConstants; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.satoken.utils.LoginHelper; |
| | | import org.dromara.system.domain.SysMenu; |
| | | import org.dromara.system.domain.bo.SysMenuBo; |
| | | import org.dromara.system.domain.vo.MenuTreeSelectVo; |
| | | import org.dromara.system.domain.vo.RouterVo; |
| | | import org.dromara.system.domain.vo.SysMenuVo; |
| | | import org.dromara.system.service.ISysMenuService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 菜单信息 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/menu") |
| | | public class SysMenuController extends BaseController { |
| | | |
| | | private final ISysMenuService menuService; |
| | | |
| | | /** |
| | | * 获取路由信息 |
| | | * |
| | | * @return 路由信息 |
| | | */ |
| | | @GetMapping("/getRouters") |
| | | public R<List<RouterVo>> getRouters() { |
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(LoginHelper.getUserId()); |
| | | return R.ok(menuService.buildMenus(menus)); |
| | | } |
| | | |
| | | /** |
| | | * 获取菜单列表 |
| | | */ |
| | | @SaCheckRole(value = { |
| | | TenantConstants.SUPER_ADMIN_ROLE_KEY, |
| | | TenantConstants.TENANT_ADMIN_ROLE_KEY |
| | | }, mode = SaMode.OR) |
| | | @SaCheckPermission("system:menu:list") |
| | | @GetMapping("/list") |
| | | public R<List<SysMenuVo>> list(SysMenuBo menu) { |
| | | List<SysMenuVo> menus = menuService.selectMenuList(menu, LoginHelper.getUserId()); |
| | | return R.ok(menus); |
| | | } |
| | | |
| | | /** |
| | | * 根据菜单编号获取详细信息 |
| | | * |
| | | * @param menuId 菜单ID |
| | | */ |
| | | @SaCheckRole(value = { |
| | | TenantConstants.SUPER_ADMIN_ROLE_KEY, |
| | | TenantConstants.TENANT_ADMIN_ROLE_KEY |
| | | }, mode = SaMode.OR) |
| | | @SaCheckPermission("system:menu:query") |
| | | @GetMapping(value = "/{menuId}") |
| | | public R<SysMenuVo> getInfo(@PathVariable Long menuId) { |
| | | return R.ok(menuService.selectMenuById(menuId)); |
| | | } |
| | | |
| | | /** |
| | | * 获取菜单下拉树列表 |
| | | */ |
| | | @SaCheckPermission("system:menu:query") |
| | | @GetMapping("/treeselect") |
| | | public R<List<Tree<Long>>> treeselect(SysMenuBo menu) { |
| | | List<SysMenuVo> menus = menuService.selectMenuList(menu, LoginHelper.getUserId()); |
| | | return R.ok(menuService.buildMenuTreeSelect(menus)); |
| | | } |
| | | |
| | | /** |
| | | * 加载对应角色菜单列表树 |
| | | * |
| | | * @param roleId 角色ID |
| | | */ |
| | | @SaCheckPermission("system:menu:query") |
| | | @GetMapping(value = "/roleMenuTreeselect/{roleId}") |
| | | public R<MenuTreeSelectVo> roleMenuTreeselect(@PathVariable("roleId") Long roleId) { |
| | | List<SysMenuVo> menus = menuService.selectMenuList(LoginHelper.getUserId()); |
| | | MenuTreeSelectVo selectVo = new MenuTreeSelectVo(); |
| | | selectVo.setCheckedKeys(menuService.selectMenuListByRoleId(roleId)); |
| | | selectVo.setMenus(menuService.buildMenuTreeSelect(menus)); |
| | | return R.ok(selectVo); |
| | | } |
| | | |
| | | /** |
| | | * 加载对应租户套餐菜单列表树 |
| | | * |
| | | * @param packageId 租户套餐ID |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:menu:query") |
| | | @GetMapping(value = "/tenantPackageMenuTreeselect/{packageId}") |
| | | public R<MenuTreeSelectVo> tenantPackageMenuTreeselect(@PathVariable("packageId") Long packageId) { |
| | | List<SysMenuVo> menus = menuService.selectMenuList(LoginHelper.getUserId()); |
| | | MenuTreeSelectVo selectVo = new MenuTreeSelectVo(); |
| | | selectVo.setCheckedKeys(menuService.selectMenuListByPackageId(packageId)); |
| | | selectVo.setMenus(menuService.buildMenuTreeSelect(menus)); |
| | | return R.ok(selectVo); |
| | | } |
| | | |
| | | /** |
| | | * 新增菜单 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:menu:add") |
| | | @Log(title = "菜单管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public R<Void> add(@Validated @RequestBody SysMenuBo menu) { |
| | | if (!menuService.checkMenuNameUnique(menu)) { |
| | | return R.fail("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); |
| | | } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) { |
| | | return R.fail("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); |
| | | } |
| | | return toAjax(menuService.insertMenu(menu)); |
| | | } |
| | | |
| | | /** |
| | | * 修改菜单 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:menu:edit") |
| | | @Log(title = "菜单管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public R<Void> edit(@Validated @RequestBody SysMenuBo menu) { |
| | | if (!menuService.checkMenuNameUnique(menu)) { |
| | | return R.fail("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); |
| | | } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) { |
| | | return R.fail("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); |
| | | } else if (menu.getMenuId().equals(menu.getParentId())) { |
| | | return R.fail("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己"); |
| | | } |
| | | return toAjax(menuService.updateMenu(menu)); |
| | | } |
| | | |
| | | /** |
| | | * 删除菜单 |
| | | * |
| | | * @param menuId 菜单ID |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:menu:remove") |
| | | @Log(title = "菜单管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{menuId}") |
| | | public R<Void> remove(@PathVariable("menuId") Long menuId) { |
| | | if (menuService.hasChildByMenuId(menuId)) { |
| | | return R.warn("存在子菜单,不允许删除"); |
| | | } |
| | | if (menuService.checkMenuExistRole(menuId)) { |
| | | return R.warn("菜单已分配,不允许删除"); |
| | | } |
| | | return toAjax(menuService.deleteMenuById(menuId)); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.dubbo.config.annotation.DubboReference; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.service.DictService; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.resource.api.RemoteMessageService; |
| | | import org.dromara.system.domain.bo.SysNoticeBo; |
| | | import org.dromara.system.domain.vo.SysNoticeVo; |
| | | import org.dromara.system.service.ISysNoticeService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * 公告 信息操作处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/notice") |
| | | public class SysNoticeController extends BaseController { |
| | | |
| | | private final ISysNoticeService noticeService; |
| | | private final DictService dictService; |
| | | |
| | | @DubboReference |
| | | private final RemoteMessageService remoteMessageService; |
| | | |
| | | /** |
| | | * 获取通知公告列表 |
| | | */ |
| | | @SaCheckPermission("system:notice:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysNoticeVo> list(SysNoticeBo notice, PageQuery pageQuery) { |
| | | return noticeService.selectPageNoticeList(notice, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 根据通知公告编号获取详细信息 |
| | | * |
| | | * @param noticeId 公告ID |
| | | */ |
| | | @SaCheckPermission("system:notice:query") |
| | | @GetMapping(value = "/{noticeId}") |
| | | public R<SysNoticeVo> getInfo(@PathVariable Long noticeId) { |
| | | return R.ok(noticeService.selectNoticeById(noticeId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增通知公告 |
| | | */ |
| | | @SaCheckPermission("system:notice:add") |
| | | @Log(title = "通知公告", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public R<Void> add(@Validated @RequestBody SysNoticeBo notice) { |
| | | int rows = noticeService.insertNotice(notice); |
| | | if (rows <= 0) { |
| | | return R.fail(); |
| | | } |
| | | String type = dictService.getDictLabel("sys_notice_type", notice.getNoticeType()); |
| | | remoteMessageService.publishAll("[" + type + "] " + notice.getNoticeTitle()); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改通知公告 |
| | | */ |
| | | @SaCheckPermission("system:notice:edit") |
| | | @Log(title = "通知公告", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public R<Void> edit(@Validated @RequestBody SysNoticeBo notice) { |
| | | return toAjax(noticeService.updateNotice(notice)); |
| | | } |
| | | |
| | | /** |
| | | * 删除通知公告 |
| | | * |
| | | * @param noticeIds 公告ID串 |
| | | */ |
| | | @SaCheckPermission("system:notice:remove") |
| | | @Log(title = "通知公告", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{noticeIds}") |
| | | public R<Void> remove(@PathVariable Long[] noticeIds) { |
| | | return toAjax(noticeService.deleteNoticeByIds(noticeIds)); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.system.domain.bo.SysPostBo; |
| | | import org.dromara.system.domain.vo.SysPostVo; |
| | | import org.dromara.system.service.ISysPostService; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 岗位信息操作处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/post") |
| | | public class SysPostController extends BaseController { |
| | | |
| | | private final ISysPostService postService; |
| | | |
| | | /** |
| | | * 获取岗位列表 |
| | | */ |
| | | @SaCheckPermission("system:post:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysPostVo> list(SysPostBo post, PageQuery pageQuery) { |
| | | return postService.selectPagePostList(post, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出岗位列表 |
| | | */ |
| | | @Log(title = "岗位管理", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:post:export") |
| | | @PostMapping("/export") |
| | | public void export(SysPostBo post, HttpServletResponse response) { |
| | | List<SysPostVo> list = postService.selectPostList(post); |
| | | ExcelUtil.exportExcel(list, "岗位数据", SysPostVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 根据岗位编号获取详细信息 |
| | | * |
| | | * @param postId 岗位ID |
| | | */ |
| | | @SaCheckPermission("system:post:query") |
| | | @GetMapping(value = "/{postId}") |
| | | public R<SysPostVo> getInfo(@PathVariable Long postId) { |
| | | return R.ok(postService.selectPostById(postId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增岗位 |
| | | */ |
| | | @SaCheckPermission("system:post:add") |
| | | @Log(title = "岗位管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public R<Void> add(@Validated @RequestBody SysPostBo post) { |
| | | if (!postService.checkPostNameUnique(post)) { |
| | | return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); |
| | | } else if (!postService.checkPostCodeUnique(post)) { |
| | | return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); |
| | | } |
| | | return toAjax(postService.insertPost(post)); |
| | | } |
| | | |
| | | /** |
| | | * 修改岗位 |
| | | */ |
| | | @SaCheckPermission("system:post:edit") |
| | | @Log(title = "岗位管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public R<Void> edit(@Validated @RequestBody SysPostBo post) { |
| | | if (!postService.checkPostNameUnique(post)) { |
| | | return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); |
| | | } else if (!postService.checkPostCodeUnique(post)) { |
| | | return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); |
| | | } else if (UserConstants.POST_DISABLE.equals(post.getStatus()) |
| | | && postService.countUserPostById(post.getPostId()) > 0) { |
| | | return R.fail("该岗位下存在已分配用户,不能禁用!"); |
| | | } |
| | | return toAjax(postService.updatePost(post)); |
| | | } |
| | | |
| | | /** |
| | | * 删除岗位 |
| | | * |
| | | * @param postIds 岗位ID串 |
| | | */ |
| | | @SaCheckPermission("system:post:remove") |
| | | @Log(title = "岗位管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{postIds}") |
| | | public R<Void> remove(@PathVariable Long[] postIds) { |
| | | return toAjax(postService.deletePostByIds(postIds)); |
| | | } |
| | | |
| | | /** |
| | | * 获取岗位选择框列表 |
| | | */ |
| | | @GetMapping("/optionselect") |
| | | public R<List<SysPostVo>> optionselect() { |
| | | SysPostBo postBo = new SysPostBo(); |
| | | postBo.setStatus(UserConstants.POST_NORMAL); |
| | | List<SysPostVo> posts = postService.selectPostList(postBo); |
| | | return R.ok(posts); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.secure.BCrypt; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.io.FileUtil; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.dubbo.config.annotation.DubboReference; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.core.utils.file.MimeTypeUtils; |
| | | import org.dromara.common.encrypt.annotation.ApiEncrypt; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.satoken.utils.LoginHelper; |
| | | import org.dromara.resource.api.RemoteFileService; |
| | | import org.dromara.resource.api.domain.RemoteFile; |
| | | import org.dromara.system.domain.bo.SysUserBo; |
| | | import org.dromara.system.domain.bo.SysUserPasswordBo; |
| | | import org.dromara.system.domain.bo.SysUserProfileBo; |
| | | import org.dromara.system.domain.vo.AvatarVo; |
| | | import org.dromara.system.domain.vo.ProfileVo; |
| | | import org.dromara.system.domain.vo.SysUserVo; |
| | | import org.dromara.system.service.ISysUserService; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * 个人信息 业务处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/user/profile") |
| | | public class SysProfileController extends BaseController { |
| | | |
| | | private final ISysUserService userService; |
| | | |
| | | @DubboReference |
| | | private RemoteFileService remoteFileService; |
| | | |
| | | /** |
| | | * 个人信息 |
| | | */ |
| | | @GetMapping |
| | | public R<ProfileVo> profile() { |
| | | SysUserVo user = userService.selectUserById(LoginHelper.getUserId()); |
| | | ProfileVo profileVo = new ProfileVo(); |
| | | profileVo.setUser(user); |
| | | profileVo.setRoleGroup(userService.selectUserRoleGroup(user.getUserName())); |
| | | profileVo.setPostGroup(userService.selectUserPostGroup(user.getUserName())); |
| | | return R.ok(profileVo); |
| | | } |
| | | |
| | | /** |
| | | * 修改用户 |
| | | */ |
| | | @Log(title = "个人信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public R<Void> updateProfile(@RequestBody SysUserProfileBo profile) { |
| | | SysUserBo user = BeanUtil.toBean(profile, SysUserBo.class); |
| | | String username = LoginHelper.getUsername(); |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { |
| | | return R.fail("修改用户'" + username + "'失败,手机号码已存在"); |
| | | } |
| | | if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) { |
| | | return R.fail("修改用户'" + username + "'失败,邮箱账号已存在"); |
| | | } |
| | | user.setUserId(LoginHelper.getUserId()); |
| | | if (userService.updateUserProfile(user) > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail("修改个人信息异常,请联系管理员"); |
| | | } |
| | | |
| | | /** |
| | | * 重置密码 |
| | | * |
| | | * @param bo 新旧密码 |
| | | */ |
| | | @ApiEncrypt |
| | | @Log(title = "个人信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updatePwd") |
| | | public R<Void> updatePwd(@Validated @RequestBody SysUserPasswordBo bo) { |
| | | SysUserVo user = userService.selectUserById(LoginHelper.getUserId()); |
| | | String password = user.getPassword(); |
| | | if (!BCrypt.checkpw(bo.getOldPassword(), password)) { |
| | | return R.fail("修改密码失败,旧密码错误"); |
| | | } |
| | | if (BCrypt.checkpw(bo.getNewPassword(), password)) { |
| | | return R.fail("新密码不能与旧密码相同"); |
| | | } |
| | | |
| | | if (userService.resetUserPwd(user.getUserId(), BCrypt.hashpw(bo.getNewPassword())) > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail("修改密码异常,请联系管理员"); |
| | | } |
| | | |
| | | /** |
| | | * 头像上传 |
| | | * |
| | | * @param avatarfile 用户头像 |
| | | */ |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | @Log(title = "用户头像", businessType = BusinessType.UPDATE) |
| | | @PostMapping(value = "/avatar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | public R<AvatarVo> avatar(@RequestPart("avatarfile") MultipartFile avatarfile) throws IOException { |
| | | if (!avatarfile.isEmpty()) { |
| | | String extension = FileUtil.extName(avatarfile.getOriginalFilename()); |
| | | if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) { |
| | | return R.fail("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式"); |
| | | } |
| | | RemoteFile oss = remoteFileService.upload(avatarfile.getName(), avatarfile.getOriginalFilename(), avatarfile.getContentType(), avatarfile.getBytes()); |
| | | String avatar = oss.getUrl(); |
| | | if (userService.updateUserAvatar(LoginHelper.getUserId(), oss.getOssId())) { |
| | | AvatarVo avatarVo = new AvatarVo(); |
| | | avatarVo.setImgUrl(avatar); |
| | | return R.ok(avatarVo); |
| | | } |
| | | } |
| | | return R.fail("上传图片异常,请联系管理员"); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.SysUserRole; |
| | | import org.dromara.system.domain.bo.SysDeptBo; |
| | | import org.dromara.system.domain.bo.SysRoleBo; |
| | | import org.dromara.system.domain.bo.SysUserBo; |
| | | import org.dromara.system.domain.vo.DeptTreeSelectVo; |
| | | import org.dromara.system.domain.vo.SysRoleVo; |
| | | import org.dromara.system.domain.vo.SysUserVo; |
| | | import org.dromara.system.service.ISysDeptService; |
| | | import org.dromara.system.service.ISysRoleService; |
| | | import org.dromara.system.service.ISysUserService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色信息 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/role") |
| | | public class SysRoleController extends BaseController { |
| | | |
| | | private final ISysRoleService roleService; |
| | | private final ISysUserService userService; |
| | | private final ISysDeptService deptService; |
| | | |
| | | /** |
| | | * 获取角色信息列表 |
| | | */ |
| | | @SaCheckPermission("system:role:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysRoleVo> list(SysRoleBo role, PageQuery pageQuery) { |
| | | return roleService.selectPageRoleList(role, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出角色信息列表 |
| | | */ |
| | | @Log(title = "角色管理", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:role:export") |
| | | @PostMapping("/export") |
| | | public void export(SysRoleBo role, HttpServletResponse response) { |
| | | List<SysRoleVo> list = roleService.selectRoleList(role); |
| | | ExcelUtil.exportExcel(list, "角色数据", SysRoleVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 根据角色编号获取详细信息 |
| | | * |
| | | * @param roleId 角色ID |
| | | */ |
| | | @SaCheckPermission("system:role:query") |
| | | @GetMapping(value = "/{roleId}") |
| | | public R<SysRoleVo> getInfo(@PathVariable Long roleId) { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return R.ok(roleService.selectRoleById(roleId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增角色 |
| | | */ |
| | | @SaCheckPermission("system:role:add") |
| | | @Log(title = "角色管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public R<Void> add(@Validated @RequestBody SysRoleBo role) { |
| | | roleService.checkRoleAllowed(role); |
| | | if (!roleService.checkRoleNameUnique(role)) { |
| | | return R.fail("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); |
| | | } else if (!roleService.checkRoleKeyUnique(role)) { |
| | | return R.fail("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); |
| | | } |
| | | return toAjax(roleService.insertRole(role)); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 修改保存角色 |
| | | */ |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public R<Void> edit(@Validated @RequestBody SysRoleBo role) { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | | if (!roleService.checkRoleNameUnique(role)) { |
| | | return R.fail("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); |
| | | } else if (!roleService.checkRoleKeyUnique(role)) { |
| | | return R.fail("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); |
| | | } |
| | | |
| | | if (roleService.updateRole(role) > 0) { |
| | | roleService.cleanOnlineUserByRole(role.getRoleId()); |
| | | return R.ok(); |
| | | } |
| | | return R.fail("修改角色'" + role.getRoleName() + "'失败,请联系管理员"); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存数据权限 |
| | | */ |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/dataScope") |
| | | public R<Void> dataScope(@RequestBody SysRoleBo role) { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | | return toAjax(roleService.authDataScope(role)); |
| | | } |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public R<Void> changeStatus(@RequestBody SysRoleBo role) { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | | return toAjax(roleService.updateRoleStatus(role.getRoleId(), role.getStatus())); |
| | | } |
| | | |
| | | /** |
| | | * 删除角色 |
| | | * |
| | | * @param roleIds 角色ID串 |
| | | */ |
| | | @SaCheckPermission("system:role:remove") |
| | | @Log(title = "角色管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{roleIds}") |
| | | public R<Void> remove(@PathVariable Long[] roleIds) { |
| | | return toAjax(roleService.deleteRoleByIds(roleIds)); |
| | | } |
| | | |
| | | /** |
| | | * 获取角色选择框列表 |
| | | */ |
| | | @SaCheckPermission("system:role:query") |
| | | @GetMapping("/optionselect") |
| | | public R<List<SysRoleVo>> optionselect() { |
| | | return R.ok(roleService.selectRoleAll()); |
| | | } |
| | | |
| | | /** |
| | | * 查询已分配用户角色列表 |
| | | */ |
| | | @SaCheckPermission("system:role:list") |
| | | @GetMapping("/authUser/allocatedList") |
| | | public TableDataInfo<SysUserVo> allocatedList(SysUserBo user, PageQuery pageQuery) { |
| | | return userService.selectAllocatedList(user, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 查询未分配用户角色列表 |
| | | */ |
| | | @SaCheckPermission("system:role:list") |
| | | @GetMapping("/authUser/unallocatedList") |
| | | public TableDataInfo<SysUserVo> unallocatedList(SysUserBo user, PageQuery pageQuery) { |
| | | return userService.selectUnallocatedList(user, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 取消授权用户 |
| | | */ |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancel") |
| | | public R<Void> cancelAuthUser(@RequestBody SysUserRole userRole) { |
| | | return toAjax(roleService.deleteAuthUser(userRole)); |
| | | } |
| | | |
| | | /** |
| | | * 批量取消授权用户 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param userIds 用户ID串 |
| | | */ |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancelAll") |
| | | public R<Void> cancelAuthUserAll(Long roleId, Long[] userIds) { |
| | | return toAjax(roleService.deleteAuthUsers(roleId, userIds)); |
| | | } |
| | | |
| | | /** |
| | | * 批量选择用户授权 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param userIds 用户ID串 |
| | | */ |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/selectAll") |
| | | public R<Void> selectAuthUserAll(Long roleId, Long[] userIds) { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return toAjax(roleService.insertAuthUsers(roleId, userIds)); |
| | | } |
| | | |
| | | /** |
| | | * 获取对应角色部门树列表 |
| | | * |
| | | * @param roleId 角色ID |
| | | */ |
| | | @SaCheckPermission("system:role:list") |
| | | @GetMapping(value = "/deptTree/{roleId}") |
| | | public R<DeptTreeSelectVo> roleDeptTreeselect(@PathVariable("roleId") Long roleId) { |
| | | DeptTreeSelectVo selectVo = new DeptTreeSelectVo(); |
| | | selectVo.setCheckedKeys(deptService.selectDeptListByRoleId(roleId)); |
| | | selectVo.setDepts(deptService.selectDeptTreeList(new SysDeptBo())); |
| | | return R.ok(selectVo); |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.satoken.utils.LoginHelper; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.system.domain.vo.SysSocialVo; |
| | | import org.dromara.system.service.ISysSocialService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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 thiszhc |
| | | * @date 2023-06-16 |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/social") |
| | | public class SysSocialController extends BaseController { |
| | | |
| | | private final ISysSocialService socialUserService; |
| | | |
| | | /** |
| | | * 查询社会化关系列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | public R<List<SysSocialVo>> list() { |
| | | return R.ok(socialUserService.queryListByUserId(LoginHelper.getUserId())); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.dev33.satoken.annotation.SaCheckRole; |
| | | import com.baomidou.lock.annotation.Lock4j; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.TenantConstants; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.encrypt.annotation.ApiEncrypt; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.common.idempotent.annotation.RepeatSubmit; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.tenant.helper.TenantHelper; |
| | | import org.dromara.system.domain.bo.SysTenantBo; |
| | | import org.dromara.system.domain.vo.SysTenantVo; |
| | | import org.dromara.system.service.ISysTenantService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 租户管理 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/tenant") |
| | | public class SysTenantController extends BaseController { |
| | | |
| | | private final ISysTenantService tenantService; |
| | | |
| | | /** |
| | | * 查询租户列表 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysTenantVo> list(SysTenantBo bo, PageQuery pageQuery) { |
| | | return tenantService.queryPageList(bo, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出租户列表 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:export") |
| | | @Log(title = "租户", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(SysTenantBo bo, HttpServletResponse response) { |
| | | List<SysTenantVo> list = tenantService.queryList(bo); |
| | | ExcelUtil.exportExcel(list, "租户", SysTenantVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 获取租户详细信息 |
| | | * |
| | | * @param id 主键 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:query") |
| | | @GetMapping("/{id}") |
| | | public R<SysTenantVo> getInfo(@NotNull(message = "主键不能为空") |
| | | @PathVariable Long id) { |
| | | return R.ok(tenantService.queryById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 新增租户 |
| | | */ |
| | | @ApiEncrypt |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:add") |
| | | @Log(title = "租户", businessType = BusinessType.INSERT) |
| | | @Lock4j |
| | | @RepeatSubmit() |
| | | @PostMapping() |
| | | public R<Void> add(@Validated(AddGroup.class) @RequestBody SysTenantBo bo) { |
| | | if (!tenantService.checkCompanyNameUnique(bo)) { |
| | | return R.fail("新增租户'" + bo.getCompanyName() + "'失败,企业名称已存在"); |
| | | } |
| | | return toAjax(TenantHelper.ignore(() -> tenantService.insertByBo(bo))); |
| | | } |
| | | |
| | | /** |
| | | * 修改租户 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:edit") |
| | | @Log(title = "租户", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit() |
| | | @PutMapping() |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysTenantBo bo) { |
| | | tenantService.checkTenantAllowed(bo.getTenantId()); |
| | | if (!tenantService.checkCompanyNameUnique(bo)) { |
| | | return R.fail("修改租户'" + bo.getCompanyName() + "'失败,公司名称已存在"); |
| | | } |
| | | return toAjax(tenantService.updateByBo(bo)); |
| | | } |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:edit") |
| | | @Log(title = "租户", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public R<Void> changeStatus(@RequestBody SysTenantBo bo) { |
| | | tenantService.checkTenantAllowed(bo.getTenantId()); |
| | | return toAjax(tenantService.updateTenantStatus(bo)); |
| | | } |
| | | |
| | | /** |
| | | * 删除租户 |
| | | * |
| | | * @param ids 主键串 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:remove") |
| | | @Log(title = "租户", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ids) { |
| | | return toAjax(tenantService.deleteWithValidByIds(Arrays.asList(ids), true)); |
| | | } |
| | | |
| | | /** |
| | | * 动态切换租户 |
| | | * |
| | | * @param tenantId 租户ID |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @GetMapping("/dynamic/{tenantId}") |
| | | public R<Void> dynamicTenant(@NotBlank(message = "租户ID不能为空") @PathVariable String tenantId) { |
| | | TenantHelper.setDynamic(tenantId); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 清除动态租户 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @GetMapping("/dynamic/clear") |
| | | public R<Void> dynamicClear() { |
| | | TenantHelper.clearDynamic(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 同步租户套餐 |
| | | * |
| | | * @param tenantId 租户id |
| | | * @param packageId 套餐id |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenant:edit") |
| | | @Log(title = "租户", businessType = BusinessType.UPDATE) |
| | | @GetMapping("/syncTenantPackage") |
| | | public R<Void> syncTenantPackage(@NotBlank(message = "租户ID不能为空") String tenantId, |
| | | @NotNull(message = "套餐ID不能为空") Long packageId) { |
| | | return toAjax(TenantHelper.ignore(() -> tenantService.syncTenantPackage(tenantId, packageId))); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.dev33.satoken.annotation.SaCheckRole; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.TenantConstants; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.common.idempotent.annotation.RepeatSubmit; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysTenantPackageBo; |
| | | import org.dromara.system.domain.vo.SysTenantPackageVo; |
| | | import org.dromara.system.service.ISysTenantPackageService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 租户套餐管理 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/tenant/package") |
| | | public class SysTenantPackageController extends BaseController { |
| | | |
| | | private final ISysTenantPackageService tenantPackageService; |
| | | |
| | | /** |
| | | * 查询租户套餐列表 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenantPackage:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysTenantPackageVo> list(SysTenantPackageBo bo, PageQuery pageQuery) { |
| | | return tenantPackageService.queryPageList(bo, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 查询租户套餐下拉选列表 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenantPackage:list") |
| | | @GetMapping("/selectList") |
| | | public R<List<SysTenantPackageVo>> selectList() { |
| | | return R.ok(tenantPackageService.selectList()); |
| | | } |
| | | |
| | | /** |
| | | * 导出租户套餐列表 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenantPackage:export") |
| | | @Log(title = "租户套餐", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(SysTenantPackageBo bo, HttpServletResponse response) { |
| | | List<SysTenantPackageVo> list = tenantPackageService.queryList(bo); |
| | | ExcelUtil.exportExcel(list, "租户套餐", SysTenantPackageVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 获取租户套餐详细信息 |
| | | * |
| | | * @param packageId 主键 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenantPackage:query") |
| | | @GetMapping("/{packageId}") |
| | | public R<SysTenantPackageVo> getInfo(@NotNull(message = "主键不能为空") |
| | | @PathVariable Long packageId) { |
| | | return R.ok(tenantPackageService.queryById(packageId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增租户套餐 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenantPackage:add") |
| | | @Log(title = "租户套餐", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit() |
| | | @PostMapping() |
| | | public R<Void> add(@Validated(AddGroup.class) @RequestBody SysTenantPackageBo bo) { |
| | | return toAjax(tenantPackageService.insertByBo(bo)); |
| | | } |
| | | |
| | | /** |
| | | * 修改租户套餐 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenantPackage:edit") |
| | | @Log(title = "租户套餐", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit() |
| | | @PutMapping() |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysTenantPackageBo bo) { |
| | | return toAjax(tenantPackageService.updateByBo(bo)); |
| | | } |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenantPackage:edit") |
| | | @Log(title = "租户套餐", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public R<Void> changeStatus(@RequestBody SysTenantPackageBo bo) { |
| | | return toAjax(tenantPackageService.updatePackageStatus(bo)); |
| | | } |
| | | |
| | | /** |
| | | * 删除租户套餐 |
| | | * |
| | | * @param packageIds 主键串 |
| | | */ |
| | | @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY) |
| | | @SaCheckPermission("system:tenantPackage:remove") |
| | | @Log(title = "租户套餐", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{packageIds}") |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] packageIds) { |
| | | return toAjax(tenantPackageService.deleteWithValidByIds(Arrays.asList(packageIds), true)); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.dev33.satoken.secure.BCrypt; |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StreamUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.encrypt.annotation.ApiEncrypt; |
| | | import org.dromara.common.excel.core.ExcelResult; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.satoken.utils.LoginHelper; |
| | | import org.dromara.common.tenant.helper.TenantHelper; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.system.api.model.LoginUser; |
| | | import org.dromara.system.domain.bo.SysDeptBo; |
| | | import org.dromara.system.domain.bo.SysPostBo; |
| | | import org.dromara.system.domain.bo.SysRoleBo; |
| | | import org.dromara.system.domain.bo.SysUserBo; |
| | | import org.dromara.system.domain.vo.*; |
| | | import org.dromara.system.listener.SysUserImportListener; |
| | | import org.dromara.system.service.*; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/user") |
| | | public class SysUserController extends BaseController { |
| | | |
| | | private final ISysUserService userService; |
| | | private final ISysRoleService roleService; |
| | | private final ISysPostService postService; |
| | | private final ISysDeptService deptService; |
| | | private final ISysTenantService tenantService; |
| | | |
| | | /** |
| | | * 获取用户列表 |
| | | */ |
| | | @SaCheckPermission("system:user:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysUserVo> list(SysUserBo user, PageQuery pageQuery) { |
| | | return userService.selectPageUserList(user, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出用户列表 |
| | | */ |
| | | @Log(title = "用户管理", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:user:export") |
| | | @PostMapping("/export") |
| | | public void export(SysUserBo user, HttpServletResponse response) { |
| | | List<SysUserVo> list = userService.selectUserList(user); |
| | | List<SysUserExportVo> listVo = MapstructUtils.convert(list, SysUserExportVo.class); |
| | | ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 导入数据 |
| | | * |
| | | * @param file 导入文件 |
| | | * @param updateSupport 是否更新已存在数据 |
| | | */ |
| | | @Log(title = "用户管理", businessType = BusinessType.IMPORT) |
| | | @SaCheckPermission("system:user:import") |
| | | @PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | public R<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception { |
| | | ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener(updateSupport)); |
| | | return R.ok(result.getAnalysis()); |
| | | } |
| | | |
| | | /** |
| | | * 获取导入模板 |
| | | */ |
| | | @PostMapping("/importTemplate") |
| | | public void importTemplate(HttpServletResponse response) { |
| | | ExcelUtil.exportExcel(new ArrayList<>(), "用户数据", SysUserImportVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户信息 |
| | | * |
| | | * @return 用户信息 |
| | | */ |
| | | @GetMapping("/getInfo") |
| | | public R<UserInfoVo> getInfo() { |
| | | UserInfoVo userInfoVo = new UserInfoVo(); |
| | | LoginUser loginUser = LoginHelper.getLoginUser(); |
| | | if (TenantHelper.isEnable() && LoginHelper.isSuperAdmin()) { |
| | | // 超级管理员 如果重新加载用户信息需清除动态租户 |
| | | TenantHelper.clearDynamic(); |
| | | } |
| | | SysUserVo user = userService.selectUserById(loginUser.getUserId()); |
| | | if (ObjectUtil.isNull(user)) { |
| | | return R.fail("没有权限访问用户数据!"); |
| | | } |
| | | userInfoVo.setUser(user); |
| | | userInfoVo.setPermissions(loginUser.getMenuPermission()); |
| | | userInfoVo.setRoles(loginUser.getRolePermission()); |
| | | return R.ok(userInfoVo); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户编号获取详细信息 |
| | | * |
| | | * @param userId 用户ID |
| | | */ |
| | | @SaCheckPermission("system:user:query") |
| | | @GetMapping(value = {"/", "/{userId}"}) |
| | | public R<SysUserInfoVo> getInfo(@PathVariable(value = "userId", required = false) Long userId) { |
| | | userService.checkUserDataScope(userId); |
| | | SysUserInfoVo userInfoVo = new SysUserInfoVo(); |
| | | SysRoleBo roleBo = new SysRoleBo(); |
| | | roleBo.setStatus(UserConstants.ROLE_NORMAL); |
| | | SysPostBo postBo = new SysPostBo(); |
| | | postBo.setStatus(UserConstants.POST_NORMAL); |
| | | List<SysRoleVo> roles = roleService.selectRoleList(roleBo); |
| | | userInfoVo.setRoles(LoginHelper.isSuperAdmin(userId) ? roles : StreamUtils.filter(roles, r -> !r.isSuperAdmin())); |
| | | userInfoVo.setPosts(postService.selectPostList(postBo)); |
| | | if (ObjectUtil.isNotNull(userId)) { |
| | | SysUserVo sysUser = userService.selectUserById(userId); |
| | | userInfoVo.setUser(sysUser); |
| | | userInfoVo.setRoleIds(StreamUtils.toList(sysUser.getRoles(), SysRoleVo::getRoleId)); |
| | | userInfoVo.setPostIds(postService.selectPostListByUserId(userId)); |
| | | } |
| | | return R.ok(userInfoVo); |
| | | } |
| | | |
| | | /** |
| | | * 新增用户 |
| | | */ |
| | | @SaCheckPermission("system:user:add") |
| | | @Log(title = "用户管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public R<Void> add(@Validated @RequestBody SysUserBo user) { |
| | | deptService.checkDeptDataScope(user.getDeptId()); |
| | | if (!userService.checkUserNameUnique(user)) { |
| | | return R.fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { |
| | | return R.fail("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) { |
| | | return R.fail("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | | if (TenantHelper.isEnable()) { |
| | | if (!tenantService.checkAccountBalance(TenantHelper.getTenantId())) { |
| | | return R.fail("当前租户下用户名额不足,请联系管理员"); |
| | | } |
| | | } |
| | | user.setPassword(BCrypt.hashpw(user.getPassword())); |
| | | return toAjax(userService.insertUser(user)); |
| | | } |
| | | |
| | | /** |
| | | * 修改用户 |
| | | */ |
| | | @SaCheckPermission("system:user:edit") |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public R<Void> edit(@Validated @RequestBody SysUserBo user) { |
| | | userService.checkUserAllowed(user.getUserId()); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | deptService.checkDeptDataScope(user.getDeptId()); |
| | | if (!userService.checkUserNameUnique(user)) { |
| | | return R.fail("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { |
| | | return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) { |
| | | return R.fail("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | | return toAjax(userService.updateUser(user)); |
| | | } |
| | | |
| | | /** |
| | | * 删除用户 |
| | | * |
| | | * @param userIds 角色ID串 |
| | | */ |
| | | @SaCheckPermission("system:user:remove") |
| | | @Log(title = "用户管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{userIds}") |
| | | public R<Void> remove(@PathVariable Long[] userIds) { |
| | | if (ArrayUtil.contains(userIds, LoginHelper.getUserId())) { |
| | | return R.fail("当前用户不能删除"); |
| | | } |
| | | return toAjax(userService.deleteUserByIds(userIds)); |
| | | } |
| | | |
| | | /** |
| | | * 重置密码 |
| | | */ |
| | | @ApiEncrypt |
| | | @SaCheckPermission("system:user:resetPwd") |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/resetPwd") |
| | | public R<Void> resetPwd(@RequestBody SysUserBo user) { |
| | | userService.checkUserAllowed(user.getUserId()); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | user.setPassword(BCrypt.hashpw(user.getPassword())); |
| | | return toAjax(userService.resetUserPwd(user.getUserId(), user.getPassword())); |
| | | } |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @SaCheckPermission("system:user:edit") |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public R<Void> changeStatus(@RequestBody SysUserBo user) { |
| | | userService.checkUserAllowed(user.getUserId()); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | return toAjax(userService.updateUserStatus(user.getUserId(), user.getStatus())); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户编号获取授权角色 |
| | | * |
| | | * @param userId 用户ID |
| | | */ |
| | | @SaCheckPermission("system:user:query") |
| | | @GetMapping("/authRole/{userId}") |
| | | public R<SysUserInfoVo> authRole(@PathVariable Long userId) { |
| | | SysUserVo user = userService.selectUserById(userId); |
| | | List<SysRoleVo> roles = roleService.selectRolesByUserId(userId); |
| | | SysUserInfoVo userInfoVo = new SysUserInfoVo(); |
| | | userInfoVo.setUser(user); |
| | | userInfoVo.setRoles(LoginHelper.isSuperAdmin(userId) ? roles : StreamUtils.filter(roles, r -> !r.isSuperAdmin())); |
| | | return R.ok(userInfoVo); |
| | | } |
| | | |
| | | /** |
| | | * 用户授权角色 |
| | | * |
| | | * @param userId 用户Id |
| | | * @param roleIds 角色ID串 |
| | | */ |
| | | @SaCheckPermission("system:user:edit") |
| | | @Log(title = "用户管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authRole") |
| | | public R<Void> insertAuthRole(Long userId, Long[] roleIds) { |
| | | userService.checkUserDataScope(userId); |
| | | userService.insertUserAuth(userId, roleIds); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门树列表 |
| | | */ |
| | | @SaCheckPermission("system:user:list") |
| | | @GetMapping("/deptTree") |
| | | public R<List<Tree<Long>>> deptTree(SysDeptBo dept) { |
| | | return R.ok(deptService.selectDeptTreeList(dept)); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门下的所有用户信息 |
| | | */ |
| | | @SaCheckPermission("system:user:list") |
| | | @GetMapping("/list/dept/{deptId}") |
| | | public R<List<SysUserVo>> listByDept(@PathVariable @NotNull Long deptId) { |
| | | return R.ok(userService.selectUserListByDept(deptId)); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | |
| | | import java.io.Serial; |
| | | |
| | | /** |
| | | * 授权管理对象 sys_client |
| | | * |
| | | * @author Michelle.Chung |
| | | * @date 2023-05-15 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_client") |
| | | public class SysClient extends BaseEntity { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * id |
| | | */ |
| | | @TableId(value = "id") |
| | | private Long id; |
| | | |
| | | /** |
| | | * 客户端id |
| | | */ |
| | | private String clientId; |
| | | |
| | | /** |
| | | * 客户端key |
| | | */ |
| | | private String clientKey; |
| | | |
| | | /** |
| | | * 客户端秘钥 |
| | | */ |
| | | private String clientSecret; |
| | | |
| | | /** |
| | | * 授权类型 |
| | | */ |
| | | private String grantType; |
| | | |
| | | /** |
| | | * 设备类型 |
| | | */ |
| | | private String deviceType; |
| | | |
| | | /** |
| | | * token活跃超时时间 |
| | | */ |
| | | private Long activeTimeout; |
| | | |
| | | /** |
| | | * token固定超时时间 |
| | | */ |
| | | private Long timeout; |
| | | |
| | | /** |
| | | * 状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 删除标志(0代表存在 2代表删除) |
| | | */ |
| | | @TableLogic |
| | | private String delFlag; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.tenant.core.TenantEntity; |
| | | |
| | | /** |
| | | * 参数配置表 sys_config |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_config") |
| | | public class SysConfig extends TenantEntity { |
| | | |
| | | /** |
| | | * 参数主键 |
| | | */ |
| | | @TableId(value = "config_id") |
| | | private Long configId; |
| | | |
| | | /** |
| | | * 参数名称 |
| | | */ |
| | | private String configName; |
| | | |
| | | /** |
| | | * 参数键名 |
| | | */ |
| | | private String configKey; |
| | | |
| | | /** |
| | | * 参数键值 |
| | | */ |
| | | private String configValue; |
| | | |
| | | /** |
| | | * 系统内置(Y是 N否) |
| | | */ |
| | | private String configType; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.tenant.core.TenantEntity; |
| | | |
| | | import java.io.Serial; |
| | | |
| | | |
| | | /** |
| | | * 部门表 sys_dept |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_dept") |
| | | public class SysDept extends TenantEntity { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 部门ID |
| | | */ |
| | | @TableId(value = "dept_id") |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * 父部门ID |
| | | */ |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 部门名称 |
| | | */ |
| | | private String deptName; |
| | | |
| | | /** |
| | | * 显示顺序 |
| | | */ |
| | | private Integer orderNum; |
| | | |
| | | /** |
| | | * 负责人 |
| | | */ |
| | | private Long leader; |
| | | |
| | | /** |
| | | * 联系电话 |
| | | */ |
| | | private String phone; |
| | | |
| | | /** |
| | | * 邮箱 |
| | | */ |
| | | private String email; |
| | | |
| | | /** |
| | | * 部门状态:0正常,1停用 |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 删除标志(0代表存在 2代表删除) |
| | | */ |
| | | @TableLogic |
| | | private String delFlag; |
| | | |
| | | /** |
| | | * 祖级列表 |
| | | */ |
| | | private String ancestors; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.tenant.core.TenantEntity; |
| | | |
| | | /** |
| | | * 字典数据表 sys_dict_data |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_dict_data") |
| | | public class SysDictData extends TenantEntity { |
| | | |
| | | /** |
| | | * 字典编码 |
| | | */ |
| | | @TableId(value = "dict_code") |
| | | private Long dictCode; |
| | | |
| | | /** |
| | | * 字典排序 |
| | | */ |
| | | private Integer dictSort; |
| | | |
| | | /** |
| | | * 字典标签 |
| | | */ |
| | | private String dictLabel; |
| | | |
| | | /** |
| | | * 字典键值 |
| | | */ |
| | | private String dictValue; |
| | | |
| | | /** |
| | | * 字典类型 |
| | | */ |
| | | private String dictType; |
| | | |
| | | /** |
| | | * 样式属性(其他样式扩展) |
| | | */ |
| | | private String cssClass; |
| | | |
| | | /** |
| | | * 表格字典样式 |
| | | */ |
| | | private String listClass; |
| | | |
| | | /** |
| | | * 是否默认(Y是 N否) |
| | | */ |
| | | private String isDefault; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | public boolean getDefault() { |
| | | return UserConstants.YES.equals(this.isDefault); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.tenant.core.TenantEntity; |
| | | |
| | | /** |
| | | * 字典类型表 sys_dict_type |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_dict_type") |
| | | public class SysDictType extends TenantEntity { |
| | | |
| | | /** |
| | | * 字典主键 |
| | | */ |
| | | @TableId(value = "dict_id") |
| | | private Long dictId; |
| | | |
| | | /** |
| | | * 字典名称 |
| | | */ |
| | | private String dictName; |
| | | |
| | | /** |
| | | * 字典类型 |
| | | */ |
| | | private String dictType; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 系统访问记录表 sys_logininfor |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @TableName("sys_logininfor") |
| | | public class SysLogininfor implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @TableId(value = "info_id") |
| | | private Long infoId; |
| | | |
| | | /** |
| | | * 租户编号 |
| | | */ |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 用户账号 |
| | | */ |
| | | private String userName; |
| | | |
| | | /** |
| | | * 客户端 |
| | | */ |
| | | private String clientKey; |
| | | |
| | | /** |
| | | * 设备类型 |
| | | */ |
| | | private String deviceType; |
| | | |
| | | /** |
| | | * 登录状态 0成功 1失败 |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 登录IP地址 |
| | | */ |
| | | private String ipaddr; |
| | | |
| | | /** |
| | | * 登录地点 |
| | | */ |
| | | private String loginLocation; |
| | | |
| | | /** |
| | | * 浏览器类型 |
| | | */ |
| | | private String browser; |
| | | |
| | | /** |
| | | * 操作系统 |
| | | */ |
| | | private String os; |
| | | |
| | | /** |
| | | * 提示消息 |
| | | */ |
| | | private String msg; |
| | | |
| | | /** |
| | | * 访问时间 |
| | | */ |
| | | private Date loginTime; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.core.constant.Constants; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 菜单权限表 sys_menu |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_menu") |
| | | public class SysMenu extends BaseEntity { |
| | | |
| | | /** |
| | | * 菜单ID |
| | | */ |
| | | @TableId(value = "menu_id") |
| | | private Long menuId; |
| | | |
| | | /** |
| | | * 父菜单ID |
| | | */ |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 菜单名称 |
| | | */ |
| | | private String menuName; |
| | | |
| | | /** |
| | | * 显示顺序 |
| | | */ |
| | | private Integer orderNum; |
| | | |
| | | /** |
| | | * 路由地址 |
| | | */ |
| | | private String path; |
| | | |
| | | /** |
| | | * 组件路径 |
| | | */ |
| | | private String component; |
| | | |
| | | /** |
| | | * 路由参数 |
| | | */ |
| | | private String queryParam; |
| | | |
| | | /** |
| | | * 是否为外链(0是 1否) |
| | | */ |
| | | private String isFrame; |
| | | |
| | | /** |
| | | * 是否缓存(0缓存 1不缓存) |
| | | */ |
| | | private String isCache; |
| | | |
| | | /** |
| | | * 类型(M目录 C菜单 F按钮) |
| | | */ |
| | | private String menuType; |
| | | |
| | | /** |
| | | * 显示状态(0显示 1隐藏) |
| | | */ |
| | | private String visible; |
| | | |
| | | /** |
| | | * 菜单状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 权限字符串 |
| | | */ |
| | | private String perms; |
| | | |
| | | /** |
| | | * 菜单图标 |
| | | */ |
| | | private String icon; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 父菜单名称 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String parentName; |
| | | |
| | | /** |
| | | * 子菜单 |
| | | */ |
| | | @TableField(exist = false) |
| | | private List<SysMenu> children = new ArrayList<>(); |
| | | |
| | | /** |
| | | * 获取路由名称 |
| | | */ |
| | | public String getRouteName() { |
| | | String routerName = StringUtils.capitalize(path); |
| | | // 非外链并且是一级目录(类型为目录) |
| | | if (isMenuFrame()) { |
| | | routerName = StringUtils.EMPTY; |
| | | } |
| | | return routerName; |
| | | } |
| | | |
| | | /** |
| | | * 获取路由地址 |
| | | */ |
| | | public String getRouterPath() { |
| | | String routerPath = this.path; |
| | | // 内链打开外网方式 |
| | | if (getParentId() != 0L && isInnerLink()) { |
| | | routerPath = innerLinkReplaceEach(routerPath); |
| | | } |
| | | // 非外链并且是一级目录(类型为目录) |
| | | if (0L == getParentId() && UserConstants.TYPE_DIR.equals(getMenuType()) |
| | | && UserConstants.NO_FRAME.equals(getIsFrame())) { |
| | | routerPath = "/" + this.path; |
| | | } |
| | | // 非外链并且是一级目录(类型为菜单) |
| | | else if (isMenuFrame()) { |
| | | routerPath = "/"; |
| | | } |
| | | return routerPath; |
| | | } |
| | | |
| | | /** |
| | | * 获取组件信息 |
| | | */ |
| | | public String getComponentInfo() { |
| | | String component = UserConstants.LAYOUT; |
| | | if (StringUtils.isNotEmpty(this.component) && !isMenuFrame()) { |
| | | component = this.component; |
| | | } else if (StringUtils.isEmpty(this.component) && getParentId() != 0L && isInnerLink()) { |
| | | component = UserConstants.INNER_LINK; |
| | | } else if (StringUtils.isEmpty(this.component) && isParentView()) { |
| | | component = UserConstants.PARENT_VIEW; |
| | | } |
| | | return component; |
| | | } |
| | | |
| | | /** |
| | | * 是否为菜单内部跳转 |
| | | */ |
| | | public boolean isMenuFrame() { |
| | | return getParentId() == 0L && UserConstants.TYPE_MENU.equals(menuType) && isFrame.equals(UserConstants.NO_FRAME); |
| | | } |
| | | |
| | | /** |
| | | * 是否为内链组件 |
| | | */ |
| | | public boolean isInnerLink() { |
| | | return isFrame.equals(UserConstants.NO_FRAME) && StringUtils.ishttp(path); |
| | | } |
| | | |
| | | /** |
| | | * 是否为parent_view组件 |
| | | */ |
| | | public boolean isParentView() { |
| | | return getParentId() != 0L && UserConstants.TYPE_DIR.equals(menuType); |
| | | } |
| | | |
| | | /** |
| | | * 内链域名特殊字符替换 |
| | | */ |
| | | public static String innerLinkReplaceEach(String path) { |
| | | return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":"}, |
| | | new String[]{"", "", "", "/", "/"}); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.tenant.core.TenantEntity; |
| | | |
| | | |
| | | /** |
| | | * 通知公告表 sys_notice |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_notice") |
| | | public class SysNotice extends TenantEntity { |
| | | |
| | | /** |
| | | * 公告ID |
| | | */ |
| | | @TableId(value = "notice_id") |
| | | private Long noticeId; |
| | | |
| | | /** |
| | | * 公告标题 |
| | | */ |
| | | private String noticeTitle; |
| | | |
| | | /** |
| | | * 公告类型(1通知 2公告) |
| | | */ |
| | | private String noticeType; |
| | | |
| | | /** |
| | | * 公告内容 |
| | | */ |
| | | private String noticeContent; |
| | | |
| | | /** |
| | | * 公告状态(0正常 1关闭) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 操作日志记录表 oper_log |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @TableName("sys_oper_log") |
| | | public class SysOperLog implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 日志主键 |
| | | */ |
| | | @TableId(value = "oper_id") |
| | | private Long operId; |
| | | |
| | | /** |
| | | * 租户编号 |
| | | */ |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 操作模块 |
| | | */ |
| | | private String title; |
| | | |
| | | /** |
| | | * 业务类型(0其它 1新增 2修改 3删除) |
| | | */ |
| | | private Integer businessType; |
| | | |
| | | /** |
| | | * 请求方法 |
| | | */ |
| | | private String method; |
| | | |
| | | /** |
| | | * 请求方式 |
| | | */ |
| | | private String requestMethod; |
| | | |
| | | /** |
| | | * 操作类别(0其它 1后台用户 2手机端用户) |
| | | */ |
| | | private Integer operatorType; |
| | | |
| | | /** |
| | | * 操作人员 |
| | | */ |
| | | private String operName; |
| | | |
| | | /** |
| | | * 部门名称 |
| | | */ |
| | | private String deptName; |
| | | |
| | | /** |
| | | * 请求url |
| | | */ |
| | | private String operUrl; |
| | | |
| | | /** |
| | | * 操作地址 |
| | | */ |
| | | private String operIp; |
| | | |
| | | /** |
| | | * 操作地点 |
| | | */ |
| | | private String operLocation; |
| | | |
| | | /** |
| | | * 请求参数 |
| | | */ |
| | | private String operParam; |
| | | |
| | | /** |
| | | * 返回参数 |
| | | */ |
| | | private String jsonResult; |
| | | |
| | | /** |
| | | * 操作状态(0正常 1异常) |
| | | */ |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 错误消息 |
| | | */ |
| | | private String errorMsg; |
| | | |
| | | /** |
| | | * 操作时间 |
| | | */ |
| | | private Date operTime; |
| | | |
| | | /** |
| | | * 消耗时间 |
| | | */ |
| | | private Long costTime; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import org.dromara.common.tenant.core.TenantEntity; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 岗位表 sys_post |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_post") |
| | | public class SysPost extends TenantEntity { |
| | | |
| | | /** |
| | | * 岗位序号 |
| | | */ |
| | | @TableId(value = "post_id") |
| | | private Long postId; |
| | | |
| | | /** |
| | | * 岗位编码 |
| | | */ |
| | | private String postCode; |
| | | |
| | | /** |
| | | * 岗位名称 |
| | | */ |
| | | private String postName; |
| | | |
| | | /** |
| | | * 岗位排序 |
| | | */ |
| | | private Integer postSort; |
| | | |
| | | /** |
| | | * 状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.NoArgsConstructor; |
| | | import org.dromara.common.tenant.core.TenantEntity; |
| | | |
| | | /** |
| | | * 角色表 sys_role |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_role") |
| | | public class SysRole extends TenantEntity { |
| | | |
| | | /** |
| | | * 角色ID |
| | | */ |
| | | @TableId(value = "role_id") |
| | | private Long roleId; |
| | | |
| | | /** |
| | | * 角色名称 |
| | | */ |
| | | private String roleName; |
| | | |
| | | /** |
| | | * 角色权限 |
| | | */ |
| | | private String roleKey; |
| | | |
| | | /** |
| | | * 角色排序 |
| | | */ |
| | | private Integer roleSort; |
| | | |
| | | /** |
| | | * 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) |
| | | */ |
| | | private String dataScope; |
| | | |
| | | /** |
| | | * 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) |
| | | */ |
| | | private Boolean menuCheckStrictly; |
| | | |
| | | /** |
| | | * 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) |
| | | */ |
| | | private Boolean deptCheckStrictly; |
| | | |
| | | /** |
| | | * 角色状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 删除标志(0代表存在 2代表删除) |
| | | */ |
| | | @TableLogic |
| | | private String delFlag; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | public SysRole(Long roleId) { |
| | | this.roleId = roleId; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 角色和部门关联 sys_role_dept |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @TableName("sys_role_dept") |
| | | public class SysRoleDept { |
| | | |
| | | /** |
| | | * 角色ID |
| | | */ |
| | | @TableId(type = IdType.INPUT) |
| | | private Long roleId; |
| | | |
| | | /** |
| | | * 部门ID |
| | | */ |
| | | private Long deptId; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 角色和菜单关联 sys_role_menu |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @TableName("sys_role_menu") |
| | | public class SysRoleMenu { |
| | | |
| | | /** |
| | | * 角色ID |
| | | */ |
| | | @TableId(type = IdType.INPUT) |
| | | private Long roleId; |
| | | |
| | | /** |
| | | * 菜单ID |
| | | */ |
| | | private Long menuId; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.tenant.core.TenantEntity; |
| | | |
| | | import java.io.Serial; |
| | | |
| | | /** |
| | | * 社会化关系对象 sys_social |
| | | * |
| | | * @author thiszhc |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_social") |
| | | public class SysSocial extends TenantEntity { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id") |
| | | private Long id; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 的唯一ID |
| | | */ |
| | | private String authId; |
| | | |
| | | /** |
| | | * 用户来源 |
| | | */ |
| | | private String source; |
| | | |
| | | /** |
| | | * 用户的授权令牌 |
| | | */ |
| | | private String accessToken; |
| | | |
| | | /** |
| | | * 用户的授权令牌的有效期,部分平台可能没有 |
| | | */ |
| | | private int expireIn; |
| | | |
| | | /** |
| | | * 刷新令牌,部分平台可能没有 |
| | | */ |
| | | private String refreshToken; |
| | | |
| | | /** |
| | | * 用户的 open id |
| | | */ |
| | | private String openId; |
| | | |
| | | /** |
| | | * 授权的第三方账号 |
| | | */ |
| | | private String userName; |
| | | |
| | | /** |
| | | * 授权的第三方昵称 |
| | | */ |
| | | private String nickName; |
| | | |
| | | /** |
| | | * 授权的第三方邮箱 |
| | | */ |
| | | private String email; |
| | | |
| | | /** |
| | | * 授权的第三方头像地址 |
| | | */ |
| | | private String avatar; |
| | | |
| | | /** |
| | | * 平台的授权信息,部分平台可能没有 |
| | | */ |
| | | private String accessCode; |
| | | |
| | | /** |
| | | * 用户的 unionid |
| | | */ |
| | | private String unionId; |
| | | |
| | | /** |
| | | * 授予的权限,部分平台可能没有 |
| | | */ |
| | | private String scope; |
| | | |
| | | /** |
| | | * 个别平台的授权信息,部分平台可能没有 |
| | | */ |
| | | private String tokenType; |
| | | |
| | | /** |
| | | * id token,部分平台可能没有 |
| | | */ |
| | | private String idToken; |
| | | |
| | | /** |
| | | * 小米平台用户的附带属性,部分平台可能没有 |
| | | */ |
| | | private String macAlgorithm; |
| | | |
| | | /** |
| | | * 小米平台用户的附带属性,部分平台可能没有 |
| | | */ |
| | | private String macKey; |
| | | |
| | | /** |
| | | * 用户的授权code,部分平台可能没有 |
| | | */ |
| | | private String code; |
| | | |
| | | /** |
| | | * Twitter平台用户的附带属性,部分平台可能没有 |
| | | */ |
| | | private String oauthToken; |
| | | |
| | | /** |
| | | * Twitter平台用户的附带属性,部分平台可能没有 |
| | | */ |
| | | private String oauthTokenSecret; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | |
| | | import java.io.Serial; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 租户对象 sys_tenant |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_tenant") |
| | | public class SysTenant extends BaseEntity { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * id |
| | | */ |
| | | @TableId(value = "id") |
| | | private Long id; |
| | | |
| | | /** |
| | | * 租户编号 |
| | | */ |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 联系人 |
| | | */ |
| | | private String contactUserName; |
| | | |
| | | /** |
| | | * 联系电话 |
| | | */ |
| | | private String contactPhone; |
| | | |
| | | /** |
| | | * 企业名称 |
| | | */ |
| | | private String companyName; |
| | | |
| | | /** |
| | | * 统一社会信用代码 |
| | | */ |
| | | private String licenseNumber; |
| | | |
| | | /** |
| | | * 地址 |
| | | */ |
| | | private String address; |
| | | |
| | | /** |
| | | * 域名 |
| | | */ |
| | | private String domain; |
| | | |
| | | /** |
| | | * 企业简介 |
| | | */ |
| | | private String intro; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 租户套餐编号 |
| | | */ |
| | | private Long packageId; |
| | | |
| | | /** |
| | | * 过期时间 |
| | | */ |
| | | private Date expireTime; |
| | | |
| | | /** |
| | | * 用户数量(-1不限制) |
| | | */ |
| | | private Long accountCount; |
| | | |
| | | /** |
| | | * 租户状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 删除标志(0代表存在 2代表删除) |
| | | */ |
| | | @TableLogic |
| | | private String delFlag; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | |
| | | import java.io.Serial; |
| | | |
| | | /** |
| | | * 租户套餐对象 sys_tenant_package |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_tenant_package") |
| | | public class SysTenantPackage extends BaseEntity { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 租户套餐id |
| | | */ |
| | | @TableId(value = "package_id") |
| | | private Long packageId; |
| | | /** |
| | | * 套餐名称 |
| | | */ |
| | | private String packageName; |
| | | /** |
| | | * 关联菜单id |
| | | */ |
| | | private String menuIds; |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | /** |
| | | * 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) |
| | | */ |
| | | private Boolean menuCheckStrictly; |
| | | /** |
| | | * 状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | /** |
| | | * 删除标志(0代表存在 2代表删除) |
| | | */ |
| | | @TableLogic |
| | | private String delFlag; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.NoArgsConstructor; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.tenant.core.TenantEntity; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 用户对象 sys_user |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("sys_user") |
| | | public class SysUser extends TenantEntity { |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @TableId(value = "user_id") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 部门ID |
| | | */ |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * 用户账号 |
| | | */ |
| | | private String userName; |
| | | |
| | | /** |
| | | * 用户昵称 |
| | | */ |
| | | private String nickName; |
| | | |
| | | /** |
| | | * 用户类型(sys_user系统用户) |
| | | */ |
| | | private String userType; |
| | | |
| | | /** |
| | | * 用户邮箱 |
| | | */ |
| | | private String email; |
| | | |
| | | /** |
| | | * 手机号码 |
| | | */ |
| | | private String phonenumber; |
| | | |
| | | /** |
| | | * 用户性别 |
| | | */ |
| | | private String sex; |
| | | |
| | | /** |
| | | * 用户头像 |
| | | */ |
| | | private Long avatar; |
| | | |
| | | /** |
| | | * 密码 |
| | | */ |
| | | @TableField( |
| | | insertStrategy = FieldStrategy.NOT_EMPTY, |
| | | updateStrategy = FieldStrategy.NOT_EMPTY, |
| | | whereStrategy = FieldStrategy.NOT_EMPTY |
| | | ) |
| | | private String password; |
| | | |
| | | /** |
| | | * 帐号状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 删除标志(0代表存在 2代表删除) |
| | | */ |
| | | @TableLogic |
| | | private String delFlag; |
| | | |
| | | /** |
| | | * 最后登录IP |
| | | */ |
| | | private String loginIp; |
| | | |
| | | /** |
| | | * 最后登录时间 |
| | | */ |
| | | private Date loginDate; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | |
| | | public SysUser(Long userId) { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public boolean isSuperAdmin() { |
| | | return UserConstants.SUPER_ADMIN_ID.equals(this.userId); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 用户和岗位关联 sys_user_post |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @TableName("sys_user_post") |
| | | public class SysUserPost { |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @TableId(type = IdType.INPUT) |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 岗位ID |
| | | */ |
| | | private Long postId; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 用户和角色关联 sys_user_role |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @TableName("sys_user_role") |
| | | public class SysUserRole { |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @TableId(type = IdType.INPUT) |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 角色ID |
| | | */ |
| | | private Long roleId; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.system.domain.SysClient; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 授权管理业务对象 sys_client |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysClient.class, reverseConvertGenerate = false) |
| | | public class SysClientBo extends BaseEntity { |
| | | |
| | | /** |
| | | * id |
| | | */ |
| | | @NotNull(message = "id不能为空", groups = { EditGroup.class }) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 客户端id |
| | | */ |
| | | private String clientId; |
| | | |
| | | /** |
| | | * 客户端key |
| | | */ |
| | | @NotBlank(message = "客户端key不能为空", groups = { AddGroup.class, EditGroup.class }) |
| | | private String clientKey; |
| | | |
| | | /** |
| | | * 客户端秘钥 |
| | | */ |
| | | @NotBlank(message = "客户端秘钥不能为空", groups = { AddGroup.class, EditGroup.class }) |
| | | private String clientSecret; |
| | | |
| | | /** |
| | | * 授权类型 |
| | | */ |
| | | @NotNull(message = "授权类型不能为空", groups = { AddGroup.class, EditGroup.class }) |
| | | private List<String> grantTypeList; |
| | | |
| | | /** |
| | | * 授权类型 |
| | | */ |
| | | private String grantType; |
| | | |
| | | /** |
| | | * 设备类型 |
| | | */ |
| | | private String deviceType; |
| | | |
| | | /** |
| | | * token活跃超时时间 |
| | | */ |
| | | private Long activeTimeout; |
| | | |
| | | /** |
| | | * token固定超时时间 |
| | | */ |
| | | private Long timeout; |
| | | |
| | | /** |
| | | * 状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.system.domain.SysConfig; |
| | | |
| | | /** |
| | | * 参数配置业务对象 sys_config |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysConfig.class, reverseConvertGenerate = false) |
| | | public class SysConfigBo extends BaseEntity { |
| | | |
| | | /** |
| | | * 参数主键 |
| | | */ |
| | | private Long configId; |
| | | |
| | | /** |
| | | * 参数名称 |
| | | */ |
| | | @NotBlank(message = "参数名称不能为空") |
| | | @Size(min = 0, max = 100, message = "参数名称不能超过{max}个字符") |
| | | private String configName; |
| | | |
| | | /** |
| | | * 参数键名 |
| | | */ |
| | | @NotBlank(message = "参数键名不能为空") |
| | | @Size(min = 0, max = 100, message = "参数键名长度不能超过{max}个字符") |
| | | private String configKey; |
| | | |
| | | /** |
| | | * 参数键值 |
| | | */ |
| | | @NotBlank(message = "参数键值不能为空") |
| | | @Size(min = 0, max = 500, message = "参数键值长度不能超过{max}个字符") |
| | | private String configValue; |
| | | |
| | | /** |
| | | * 系统内置(Y是 N否) |
| | | */ |
| | | private String configType; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import jakarta.validation.constraints.Email; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.system.domain.SysDept; |
| | | |
| | | /** |
| | | * 部门业务对象 sys_dept |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysDept.class, reverseConvertGenerate = false) |
| | | public class SysDeptBo extends BaseEntity { |
| | | |
| | | /** |
| | | * 部门id |
| | | */ |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * 父部门ID |
| | | */ |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 部门名称 |
| | | */ |
| | | @NotBlank(message = "部门名称不能为空") |
| | | @Size(min = 0, max = 30, message = "部门名称长度不能超过{max}个字符") |
| | | private String deptName; |
| | | |
| | | /** |
| | | * 显示顺序 |
| | | */ |
| | | @NotNull(message = "显示顺序不能为空") |
| | | private Integer orderNum; |
| | | |
| | | /** |
| | | * 负责人 |
| | | */ |
| | | private Long leader; |
| | | |
| | | /** |
| | | * 联系电话 |
| | | */ |
| | | @Size(min = 0, max = 11, message = "联系电话长度不能超过{max}个字符") |
| | | private String phone; |
| | | |
| | | /** |
| | | * 邮箱 |
| | | */ |
| | | @Email(message = "邮箱格式不正确") |
| | | @Size(min = 0, max = 50, message = "邮箱长度不能超过{max}个字符") |
| | | private String email; |
| | | |
| | | /** |
| | | * 部门状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.system.domain.SysDictData; |
| | | |
| | | /** |
| | | * 字典数据业务对象 sys_dict_data |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysDictData.class, reverseConvertGenerate = false) |
| | | public class SysDictDataBo extends BaseEntity { |
| | | |
| | | /** |
| | | * 字典编码 |
| | | */ |
| | | private Long dictCode; |
| | | |
| | | /** |
| | | * 字典排序 |
| | | */ |
| | | private Integer dictSort; |
| | | |
| | | /** |
| | | * 字典标签 |
| | | */ |
| | | @NotBlank(message = "字典标签不能为空") |
| | | @Size(min = 0, max = 100, message = "字典标签长度不能超过{max}个字符") |
| | | private String dictLabel; |
| | | |
| | | /** |
| | | * 字典键值 |
| | | */ |
| | | @NotBlank(message = "字典键值不能为空") |
| | | @Size(min = 0, max = 100, message = "字典键值长度不能超过{max}个字符") |
| | | private String dictValue; |
| | | |
| | | /** |
| | | * 字典类型 |
| | | */ |
| | | @NotBlank(message = "字典类型不能为空") |
| | | @Size(min = 0, max = 100, message = "字典类型长度不能超过{max}个字符") |
| | | private String dictType; |
| | | |
| | | /** |
| | | * 样式属性(其他样式扩展) |
| | | */ |
| | | @Size(min = 0, max = 100, message = "样式属性长度不能超过{max}个字符") |
| | | private String cssClass; |
| | | |
| | | /** |
| | | * 表格回显样式 |
| | | */ |
| | | private String listClass; |
| | | |
| | | /** |
| | | * 是否默认(Y是 N否) |
| | | */ |
| | | private String isDefault; |
| | | |
| | | /** |
| | | * 创建部门 |
| | | */ |
| | | private Long createDept; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Pattern; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.system.domain.SysDictType; |
| | | |
| | | /** |
| | | * 字典类型业务对象 sys_dict_type |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysDictType.class, reverseConvertGenerate = false) |
| | | public class SysDictTypeBo extends BaseEntity { |
| | | |
| | | /** |
| | | * 字典主键 |
| | | */ |
| | | private Long dictId; |
| | | |
| | | /** |
| | | * 字典名称 |
| | | */ |
| | | @NotBlank(message = "字典名称不能为空") |
| | | @Size(min = 0, max = 100, message = "字典类型名称长度不能超过{max}个字符") |
| | | private String dictName; |
| | | |
| | | /** |
| | | * 字典类型 |
| | | */ |
| | | @NotBlank(message = "字典类型不能为空") |
| | | @Size(min = 0, max = 100, message = "字典类型类型长度不能超过{max}个字符") |
| | | @Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)") |
| | | private String dictType; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.system.domain.SysLogininfor; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 系统访问记录业务对象 sys_logininfor |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | |
| | | @Data |
| | | @AutoMapper(target = SysLogininfor.class, reverseConvertGenerate = false) |
| | | public class SysLogininforBo { |
| | | |
| | | /** |
| | | * 访问ID |
| | | */ |
| | | private Long infoId; |
| | | |
| | | /** |
| | | * 租户编号 |
| | | */ |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 用户账号 |
| | | */ |
| | | private String userName; |
| | | |
| | | /** |
| | | * 客户端 |
| | | */ |
| | | private String clientKey; |
| | | |
| | | /** |
| | | * 设备类型 |
| | | */ |
| | | private String deviceType; |
| | | |
| | | /** |
| | | * 登录IP地址 |
| | | */ |
| | | private String ipaddr; |
| | | |
| | | /** |
| | | * 登录地点 |
| | | */ |
| | | private String loginLocation; |
| | | |
| | | /** |
| | | * 浏览器类型 |
| | | */ |
| | | private String browser; |
| | | |
| | | /** |
| | | * 操作系统 |
| | | */ |
| | | private String os; |
| | | |
| | | /** |
| | | * 登录状态(0成功 1失败) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 提示消息 |
| | | */ |
| | | private String msg; |
| | | |
| | | /** |
| | | * 访问时间 |
| | | */ |
| | | private Date loginTime; |
| | | |
| | | /** |
| | | * 请求参数 |
| | | */ |
| | | private Map<String, Object> params = new HashMap<>(); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.system.domain.SysMenu; |
| | | |
| | | /** |
| | | * 菜单权限业务对象 sys_menu |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysMenu.class, reverseConvertGenerate = false) |
| | | public class SysMenuBo extends BaseEntity { |
| | | |
| | | /** |
| | | * 菜单ID |
| | | */ |
| | | private Long menuId; |
| | | |
| | | /** |
| | | * 父菜单ID |
| | | */ |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 菜单名称 |
| | | */ |
| | | @NotBlank(message = "菜单名称不能为空") |
| | | @Size(min = 0, max = 50, message = "菜单名称长度不能超过{max}个字符") |
| | | private String menuName; |
| | | |
| | | /** |
| | | * 显示顺序 |
| | | */ |
| | | @NotNull(message = "显示顺序不能为空") |
| | | private Integer orderNum; |
| | | |
| | | /** |
| | | * 路由地址 |
| | | */ |
| | | @Size(min = 0, max = 200, message = "路由地址不能超过{max}个字符") |
| | | private String path; |
| | | |
| | | /** |
| | | * 组件路径 |
| | | */ |
| | | @Size(min = 0, max = 200, message = "组件路径不能超过{max}个字符") |
| | | private String component; |
| | | |
| | | /** |
| | | * 路由参数 |
| | | */ |
| | | private String queryParam; |
| | | |
| | | /** |
| | | * 是否为外链(0是 1否) |
| | | */ |
| | | private String isFrame; |
| | | |
| | | /** |
| | | * 是否缓存(0缓存 1不缓存) |
| | | */ |
| | | private String isCache; |
| | | |
| | | /** |
| | | * 菜单类型(M目录 C菜单 F按钮) |
| | | */ |
| | | @NotBlank(message = "菜单类型不能为空") |
| | | private String menuType; |
| | | |
| | | /** |
| | | * 显示状态(0显示 1隐藏) |
| | | */ |
| | | private String visible; |
| | | |
| | | /** |
| | | * 菜单状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 权限标识 |
| | | */ |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @Size(min = 0, max = 100, message = "权限标识长度不能超过{max}个字符") |
| | | private String perms; |
| | | |
| | | /** |
| | | * 菜单图标 |
| | | */ |
| | | private String icon; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.core.xss.Xss; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.system.domain.SysNotice; |
| | | |
| | | /** |
| | | * 通知公告业务对象 sys_notice |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysNotice.class, reverseConvertGenerate = false) |
| | | public class SysNoticeBo extends BaseEntity { |
| | | |
| | | /** |
| | | * 公告ID |
| | | */ |
| | | private Long noticeId; |
| | | |
| | | /** |
| | | * 公告标题 |
| | | */ |
| | | @Xss(message = "公告标题不能包含脚本字符") |
| | | @NotBlank(message = "公告标题不能为空") |
| | | @Size(min = 0, max = 50, message = "公告标题不能超过{max}个字符") |
| | | private String noticeTitle; |
| | | |
| | | /** |
| | | * 公告类型(1通知 2公告) |
| | | */ |
| | | private String noticeType; |
| | | |
| | | /** |
| | | * 公告内容 |
| | | */ |
| | | private String noticeContent; |
| | | |
| | | /** |
| | | * 公告状态(0正常 1关闭) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 创建人名称 |
| | | */ |
| | | private String createByName; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import io.github.linpeilie.annotations.AutoMappers; |
| | | import lombok.Data; |
| | | import org.dromara.common.log.event.OperLogEvent; |
| | | import org.dromara.system.domain.SysOperLog; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 操作日志记录业务对象 sys_oper_log |
| | | * |
| | | * @author Michelle.Chung |
| | | * @date 2023-02-07 |
| | | */ |
| | | |
| | | @Data |
| | | @AutoMappers({ |
| | | @AutoMapper(target = SysOperLog.class, reverseConvertGenerate = false), |
| | | @AutoMapper(target = OperLogEvent.class) |
| | | }) |
| | | public class SysOperLogBo { |
| | | |
| | | /** |
| | | * 日志主键 |
| | | */ |
| | | private Long operId; |
| | | |
| | | /** |
| | | * 租户编号 |
| | | */ |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 模块标题 |
| | | */ |
| | | private String title; |
| | | |
| | | /** |
| | | * 业务类型(0其它 1新增 2修改 3删除) |
| | | */ |
| | | private Integer businessType; |
| | | |
| | | /** |
| | | * 业务类型数组 |
| | | */ |
| | | private Integer[] businessTypes; |
| | | |
| | | /** |
| | | * 方法名称 |
| | | */ |
| | | private String method; |
| | | |
| | | /** |
| | | * 请求方式 |
| | | */ |
| | | private String requestMethod; |
| | | |
| | | /** |
| | | * 操作类别(0其它 1后台用户 2手机端用户) |
| | | */ |
| | | private Integer operatorType; |
| | | |
| | | /** |
| | | * 操作人员 |
| | | */ |
| | | private String operName; |
| | | |
| | | /** |
| | | * 部门名称 |
| | | */ |
| | | private String deptName; |
| | | |
| | | /** |
| | | * 请求URL |
| | | */ |
| | | private String operUrl; |
| | | |
| | | /** |
| | | * 主机地址 |
| | | */ |
| | | private String operIp; |
| | | |
| | | /** |
| | | * 操作地点 |
| | | */ |
| | | private String operLocation; |
| | | |
| | | /** |
| | | * 请求参数 |
| | | */ |
| | | private String operParam; |
| | | |
| | | /** |
| | | * 返回参数 |
| | | */ |
| | | private String jsonResult; |
| | | |
| | | /** |
| | | * 操作状态(0正常 1异常) |
| | | */ |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 错误消息 |
| | | */ |
| | | private String errorMsg; |
| | | |
| | | /** |
| | | * 操作时间 |
| | | */ |
| | | private Date operTime; |
| | | |
| | | /** |
| | | * 消耗时间 |
| | | */ |
| | | private Long costTime; |
| | | |
| | | /** |
| | | * 请求参数 |
| | | */ |
| | | private Map<String, Object> params = new HashMap<>(); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.system.domain.SysPost; |
| | | |
| | | /** |
| | | * 岗位信息业务对象 sys_post |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysPost.class, reverseConvertGenerate = false) |
| | | public class SysPostBo extends BaseEntity { |
| | | |
| | | /** |
| | | * 岗位ID |
| | | */ |
| | | private Long postId; |
| | | |
| | | /** |
| | | * 岗位编码 |
| | | */ |
| | | @NotBlank(message = "岗位编码不能为空") |
| | | @Size(min = 0, max = 64, message = "岗位编码长度不能超过{max}个字符") |
| | | private String postCode; |
| | | |
| | | /** |
| | | * 岗位名称 |
| | | */ |
| | | @NotBlank(message = "岗位名称不能为空") |
| | | @Size(min = 0, max = 50, message = "岗位名称长度不能超过{max}个字符") |
| | | private String postName; |
| | | |
| | | /** |
| | | * 显示顺序 |
| | | */ |
| | | @NotNull(message = "显示顺序不能为空") |
| | | private Integer postSort; |
| | | |
| | | /** |
| | | * 状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.NoArgsConstructor; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.system.domain.SysRole; |
| | | |
| | | /** |
| | | * 角色信息业务对象 sys_role |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysRole.class, reverseConvertGenerate = false) |
| | | public class SysRoleBo extends BaseEntity { |
| | | |
| | | /** |
| | | * 角色ID |
| | | */ |
| | | private Long roleId; |
| | | |
| | | /** |
| | | * 角色名称 |
| | | */ |
| | | @NotBlank(message = "角色名称不能为空") |
| | | @Size(min = 0, max = 30, message = "角色名称长度不能超过{max}个字符") |
| | | private String roleName; |
| | | |
| | | /** |
| | | * 角色权限字符串 |
| | | */ |
| | | @NotBlank(message = "角色权限字符串不能为空") |
| | | @Size(min = 0, max = 100, message = "权限字符长度不能超过{max}个字符") |
| | | private String roleKey; |
| | | |
| | | /** |
| | | * 显示顺序 |
| | | */ |
| | | @NotNull(message = "显示顺序不能为空") |
| | | private Integer roleSort; |
| | | |
| | | /** |
| | | * 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限) |
| | | */ |
| | | private String dataScope; |
| | | |
| | | /** |
| | | * 菜单树选择项是否关联显示 |
| | | */ |
| | | private Boolean menuCheckStrictly; |
| | | |
| | | /** |
| | | * 部门树选择项是否关联显示 |
| | | */ |
| | | private Boolean deptCheckStrictly; |
| | | |
| | | /** |
| | | * 角色状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 菜单组 |
| | | */ |
| | | private Long[] menuIds; |
| | | |
| | | /** |
| | | * 部门组(数据权限) |
| | | */ |
| | | private Long[] deptIds; |
| | | |
| | | public SysRoleBo(Long roleId) { |
| | | this.roleId = roleId; |
| | | } |
| | | |
| | | public boolean isSuperAdmin() { |
| | | return UserConstants.SUPER_ADMIN_ID.equals(this.roleId); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.NoArgsConstructor; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.tenant.core.TenantEntity; |
| | | import org.dromara.system.domain.SysSocial; |
| | | |
| | | /** |
| | | * 社会化关系业务对象 sys_social |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysSocial.class, reverseConvertGenerate = false) |
| | | public class SysSocialBo extends TenantEntity { |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @NotNull(message = "主键不能为空", groups = { EditGroup.class }) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 的唯一ID |
| | | */ |
| | | @NotBlank(message = "的唯一ID不能为空", groups = { AddGroup.class, EditGroup.class }) |
| | | private String authId; |
| | | |
| | | /** |
| | | * 用户来源 |
| | | */ |
| | | @NotBlank(message = "用户来源不能为空", groups = { AddGroup.class, EditGroup.class }) |
| | | private String source; |
| | | |
| | | /** |
| | | * 用户的授权令牌 |
| | | */ |
| | | @NotBlank(message = "用户的授权令牌不能为空", groups = { AddGroup.class, EditGroup.class }) |
| | | private String accessToken; |
| | | |
| | | /** |
| | | * 用户的授权令牌的有效期,部分平台可能没有 |
| | | */ |
| | | private int expireIn; |
| | | |
| | | /** |
| | | * 刷新令牌,部分平台可能没有 |
| | | */ |
| | | private String refreshToken; |
| | | |
| | | /** |
| | | * 平台唯一id |
| | | */ |
| | | private String openId; |
| | | |
| | | /** |
| | | * 用户的 ID |
| | | */ |
| | | @NotBlank(message = "用户的 ID不能为空", groups = { AddGroup.class, EditGroup.class }) |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 平台的授权信息,部分平台可能没有 |
| | | */ |
| | | private String accessCode; |
| | | |
| | | /** |
| | | * 用户的 unionid |
| | | */ |
| | | private String unionId; |
| | | |
| | | /** |
| | | * 授予的权限,部分平台可能没有 |
| | | */ |
| | | private String scope; |
| | | |
| | | /** |
| | | * 授权的第三方账号 |
| | | */ |
| | | private String userName; |
| | | |
| | | /** |
| | | * 授权的第三方昵称 |
| | | */ |
| | | private String nickName; |
| | | |
| | | /** |
| | | * 授权的第三方邮箱 |
| | | */ |
| | | private String email; |
| | | |
| | | /** |
| | | * 授权的第三方头像地址 |
| | | */ |
| | | private String avatar; |
| | | |
| | | /** |
| | | * 个别平台的授权信息,部分平台可能没有 |
| | | */ |
| | | private String tokenType; |
| | | |
| | | /** |
| | | * id token,部分平台可能没有 |
| | | */ |
| | | private String idToken; |
| | | |
| | | /** |
| | | * 小米平台用户的附带属性,部分平台可能没有 |
| | | */ |
| | | private String macAlgorithm; |
| | | |
| | | /** |
| | | * 小米平台用户的附带属性,部分平台可能没有 |
| | | */ |
| | | private String macKey; |
| | | |
| | | /** |
| | | * 用户的授权code,部分平台可能没有 |
| | | */ |
| | | private String code; |
| | | |
| | | /** |
| | | * Twitter平台用户的附带属性,部分平台可能没有 |
| | | */ |
| | | private String oauthToken; |
| | | |
| | | /** |
| | | * Twitter平台用户的附带属性,部分平台可能没有 |
| | | */ |
| | | private String oauthTokenSecret; |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.system.domain.SysTenant; |
| | | |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 租户业务对象 sys_tenant |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysTenant.class, reverseConvertGenerate = false) |
| | | public class SysTenantBo extends BaseEntity { |
| | | |
| | | /** |
| | | * id |
| | | */ |
| | | @NotNull(message = "id不能为空", groups = { EditGroup.class }) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 租户编号 |
| | | */ |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 联系人 |
| | | */ |
| | | @NotBlank(message = "联系人不能为空", groups = { AddGroup.class, EditGroup.class }) |
| | | private String contactUserName; |
| | | |
| | | /** |
| | | * 联系电话 |
| | | */ |
| | | @NotBlank(message = "联系电话不能为空", groups = { AddGroup.class, EditGroup.class }) |
| | | private String contactPhone; |
| | | |
| | | /** |
| | | * 企业名称 |
| | | */ |
| | | @NotBlank(message = "企业名称不能为空", groups = { AddGroup.class, EditGroup.class }) |
| | | private String companyName; |
| | | |
| | | /** |
| | | * 用户名(创建系统用户) |
| | | */ |
| | | @NotBlank(message = "用户名不能为空", groups = { AddGroup.class }) |
| | | private String username; |
| | | |
| | | /** |
| | | * 密码(创建系统用户) |
| | | */ |
| | | @NotBlank(message = "密码不能为空", groups = { AddGroup.class }) |
| | | private String password; |
| | | |
| | | /** |
| | | * 统一社会信用代码 |
| | | */ |
| | | private String licenseNumber; |
| | | |
| | | /** |
| | | * 地址 |
| | | */ |
| | | private String address; |
| | | |
| | | /** |
| | | * 域名 |
| | | */ |
| | | private String domain; |
| | | |
| | | /** |
| | | * 企业简介 |
| | | */ |
| | | private String intro; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 租户套餐编号 |
| | | */ |
| | | @NotNull(message = "租户套餐不能为空", groups = { AddGroup.class }) |
| | | private Long packageId; |
| | | |
| | | /** |
| | | * 过期时间 |
| | | */ |
| | | private Date expireTime; |
| | | |
| | | /** |
| | | * 用户数量(-1不限制) |
| | | */ |
| | | private Long accountCount; |
| | | |
| | | /** |
| | | * 租户状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import io.github.linpeilie.annotations.AutoMapping; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.system.domain.SysTenantPackage; |
| | | |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * 租户套餐业务对象 sys_tenant_package |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysTenantPackage.class, reverseConvertGenerate = false) |
| | | public class SysTenantPackageBo extends BaseEntity { |
| | | |
| | | /** |
| | | * 租户套餐id |
| | | */ |
| | | @NotNull(message = "租户套餐id不能为空", groups = { EditGroup.class }) |
| | | private Long packageId; |
| | | |
| | | /** |
| | | * 套餐名称 |
| | | */ |
| | | @NotBlank(message = "套餐名称不能为空", groups = { AddGroup.class, EditGroup.class }) |
| | | private String packageName; |
| | | |
| | | /** |
| | | * 关联菜单id |
| | | */ |
| | | @AutoMapping(target = "menuIds", expression = "java(org.dromara.common.core.utils.StringUtils.join(source.getMenuIds(), \",\"))") |
| | | private Long[] menuIds; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 菜单树选择项是否关联显示 |
| | | */ |
| | | private Boolean menuCheckStrictly; |
| | | |
| | | /** |
| | | * 状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import jakarta.validation.constraints.Email; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.NoArgsConstructor; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.core.xss.Xss; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.system.domain.SysUser; |
| | | |
| | | /** |
| | | * 用户信息业务对象 sys_user |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @AutoMapper(target = SysUser.class, reverseConvertGenerate = false) |
| | | public class SysUserBo extends BaseEntity { |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 部门ID |
| | | */ |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * 用户账号 |
| | | */ |
| | | @Xss(message = "用户账号不能包含脚本字符") |
| | | @NotBlank(message = "用户账号不能为空") |
| | | @Size(min = 0, max = 30, message = "用户账号长度不能超过{max}个字符") |
| | | private String userName; |
| | | |
| | | /** |
| | | * 用户昵称 |
| | | */ |
| | | @Xss(message = "用户昵称不能包含脚本字符") |
| | | @NotBlank(message = "用户昵称不能为空") |
| | | @Size(min = 0, max = 30, message = "用户昵称长度不能超过{max}个字符") |
| | | private String nickName; |
| | | |
| | | /** |
| | | * 用户类型(sys_user系统用户) |
| | | */ |
| | | private String userType; |
| | | |
| | | /** |
| | | * 用户邮箱 |
| | | */ |
| | | @Email(message = "邮箱格式不正确") |
| | | @Size(min = 0, max = 50, message = "邮箱长度不能超过{max}个字符") |
| | | private String email; |
| | | |
| | | /** |
| | | * 手机号码 |
| | | */ |
| | | private String phonenumber; |
| | | |
| | | /** |
| | | * 用户性别(0男 1女 2未知) |
| | | */ |
| | | private String sex; |
| | | |
| | | /** |
| | | * 密码 |
| | | */ |
| | | private String password; |
| | | |
| | | /** |
| | | * 帐号状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 角色组 |
| | | */ |
| | | @Size(min = 1, message = "用户角色不能为空") |
| | | private Long[] roleIds; |
| | | |
| | | /** |
| | | * 岗位组 |
| | | */ |
| | | private Long[] postIds; |
| | | |
| | | /** |
| | | * 数据权限 当前角色ID |
| | | */ |
| | | private Long roleId; |
| | | |
| | | public SysUserBo(Long userId) { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public boolean isSuperAdmin() { |
| | | return UserConstants.SUPER_ADMIN_ID.equals(this.userId); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 用户密码修改bo |
| | | */ |
| | | @Data |
| | | public class SysUserPasswordBo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 旧密码 |
| | | */ |
| | | @NotBlank(message = "旧密码不能为空") |
| | | private String oldPassword; |
| | | |
| | | /** |
| | | * 新密码 |
| | | */ |
| | | @NotBlank(message = "新密码不能为空") |
| | | private String newPassword; |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.bo; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.NoArgsConstructor; |
| | | import org.dromara.common.mybatis.core.domain.BaseEntity; |
| | | import org.dromara.common.core.xss.Xss; |
| | | import org.dromara.common.sensitive.annotation.Sensitive; |
| | | import org.dromara.common.sensitive.core.SensitiveStrategy; |
| | | |
| | | import jakarta.validation.constraints.Email; |
| | | import jakarta.validation.constraints.Size; |
| | | |
| | | /** |
| | | * 个人信息业务处理 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SysUserProfileBo extends BaseEntity { |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 用户昵称 |
| | | */ |
| | | @Xss(message = "用户昵称不能包含脚本字符") |
| | | @Size(min = 0, max = 30, message = "用户昵称长度不能超过{max}个字符") |
| | | private String nickName; |
| | | |
| | | /** |
| | | * 用户邮箱 |
| | | */ |
| | | @Sensitive(strategy = SensitiveStrategy.EMAIL) |
| | | @Email(message = "邮箱格式不正确") |
| | | @Size(min = 0, max = 50, message = "邮箱长度不能超过{max}个字符") |
| | | private String email; |
| | | |
| | | /** |
| | | * 手机号码 |
| | | */ |
| | | @Sensitive(strategy = SensitiveStrategy.PHONE) |
| | | private String phonenumber; |
| | | |
| | | /** |
| | | * 用户性别(0男 1女 2未知) |
| | | */ |
| | | private String sex; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.convert; |
| | | |
| | | import io.github.linpeilie.BaseMapper; |
| | | import org.dromara.system.api.domain.vo.RemoteClientVo; |
| | | import org.dromara.system.domain.vo.SysClientVo; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.MappingConstants; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * 客户端数据转换器 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Mapper(componentModel = MappingConstants.ComponentModel.SPRING, unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface SysClientVoConvert extends BaseMapper<SysClientVo, RemoteClientVo> { |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.convert; |
| | | |
| | | import io.github.linpeilie.BaseMapper; |
| | | import org.dromara.system.api.domain.vo.RemoteDictDataVo; |
| | | import org.dromara.system.domain.vo.SysDictDataVo; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.MappingConstants; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * 字典数据转换器 |
| | | * @author zhujie |
| | | */ |
| | | @Mapper(componentModel = MappingConstants.ComponentModel.SPRING, unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface SysDictDataVoConvert extends BaseMapper<SysDictDataVo, RemoteDictDataVo> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.convert; |
| | | |
| | | import io.github.linpeilie.BaseMapper; |
| | | import org.dromara.system.api.domain.bo.RemoteLogininforBo; |
| | | import org.dromara.system.domain.bo.SysLogininforBo; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.MappingConstants; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * 登录日志转换器 |
| | | * @author zhujie |
| | | */ |
| | | @Mapper(componentModel = MappingConstants.ComponentModel.SPRING, unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface SysLogininforBoConvert extends BaseMapper<RemoteLogininforBo, SysLogininforBo> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.convert; |
| | | |
| | | import io.github.linpeilie.BaseMapper; |
| | | import org.dromara.system.api.domain.bo.RemoteOperLogBo; |
| | | import org.dromara.system.domain.bo.SysOperLogBo; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.Mapping; |
| | | import org.mapstruct.MappingConstants; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * 操作日志转换器 |
| | | * @author zhujie |
| | | */ |
| | | @Mapper(componentModel = MappingConstants.ComponentModel.SPRING, unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface SysOperLogBoConvert extends BaseMapper<RemoteOperLogBo, SysOperLogBo> { |
| | | |
| | | /** |
| | | * RemoteOperLogBoToSysOperLogBo |
| | | * @param remoteOperLogBo 待转换对象 |
| | | * @return 转换后对象 |
| | | */ |
| | | @Mapping(target = "businessTypes", ignore = true) |
| | | SysOperLogBo convert(RemoteOperLogBo remoteOperLogBo); |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.convert; |
| | | |
| | | import io.github.linpeilie.BaseMapper; |
| | | import org.dromara.system.api.domain.bo.RemoteSocialBo; |
| | | import org.dromara.system.domain.bo.SysSocialBo; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.MappingConstants; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * 社交数据转换器 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Mapper(componentModel = MappingConstants.ComponentModel.SPRING, unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface SysSocialBoConvert extends BaseMapper<RemoteSocialBo, SysSocialBo> { |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.convert; |
| | | |
| | | import io.github.linpeilie.BaseMapper; |
| | | import org.dromara.system.api.domain.vo.RemoteSocialVo; |
| | | import org.dromara.system.domain.vo.SysSocialVo; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.MappingConstants; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * 社交数据转换器 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Mapper(componentModel = MappingConstants.ComponentModel.SPRING, unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface SysSocialVoConvert extends BaseMapper<SysSocialVo, RemoteSocialVo> { |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.convert; |
| | | |
| | | import io.github.linpeilie.BaseMapper; |
| | | import org.dromara.system.api.domain.vo.RemoteTenantVo; |
| | | import org.dromara.system.domain.vo.SysTenantVo; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.MappingConstants; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * 租户转换器 |
| | | * @author zhujie |
| | | */ |
| | | @Mapper(componentModel = MappingConstants.ComponentModel.SPRING, unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface SysTenantVoConvert extends BaseMapper<SysTenantVo, RemoteTenantVo> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.convert; |
| | | |
| | | import io.github.linpeilie.BaseMapper; |
| | | import org.dromara.system.api.domain.bo.RemoteOperLogBo; |
| | | import org.dromara.system.api.domain.bo.RemoteUserBo; |
| | | import org.dromara.system.domain.bo.SysOperLogBo; |
| | | import org.dromara.system.domain.bo.SysUserBo; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.Mapping; |
| | | import org.mapstruct.MappingConstants; |
| | | import org.mapstruct.ReportingPolicy; |
| | | import org.mapstruct.factory.Mappers; |
| | | |
| | | /** |
| | | * 用户信息转换器 |
| | | * @author zhujie |
| | | */ |
| | | @Mapper(componentModel = MappingConstants.ComponentModel.SPRING, unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface SysUserBoConvert extends BaseMapper<RemoteUserBo, SysUserBo> { |
| | | |
| | | /** |
| | | * RemoteUserBoToSysUserBo |
| | | * @param remoteUserBo 待转换对象 |
| | | * @return 转换后对象 |
| | | */ |
| | | @Mapping(target = "roleIds", ignore = true) |
| | | @Mapping(target = "postIds", ignore = true) |
| | | SysUserBo convert(RemoteUserBo remoteUserBo); |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 用户头像信息 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | public class AvatarVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 头像地址 |
| | | */ |
| | | private String imgUrl; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Properties; |
| | | |
| | | /** |
| | | * 缓存监控列表信息 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | public class CacheListInfoVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private Properties info; |
| | | |
| | | private Long dbSize; |
| | | |
| | | private List<Map<String, String>> commandStats; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色部门列表树信息 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | public class DeptTreeSelectVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 选中部门列表 |
| | | */ |
| | | private List<Long> checkedKeys; |
| | | |
| | | /** |
| | | * 下拉树结构列表 |
| | | */ |
| | | private List<Tree<Long>> depts; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色菜单列表树信息 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | public class MenuTreeSelectVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 选中菜单列表 |
| | | */ |
| | | private List<Long> checkedKeys; |
| | | |
| | | /** |
| | | * 菜单下拉树结构列表 |
| | | */ |
| | | private List<Tree<Long>> menus; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 路由显示信息 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | |
| | | @Data |
| | | public class MetaVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 设置该路由在侧边栏和面包屑中展示的名字 |
| | | */ |
| | | private String title; |
| | | |
| | | /** |
| | | * 设置该路由的图标,对应路径src/assets/icons/svg |
| | | */ |
| | | private String icon; |
| | | |
| | | /** |
| | | * 设置为true,则不会被 <keep-alive>缓存 |
| | | */ |
| | | private boolean noCache; |
| | | |
| | | /** |
| | | * 内链地址(http(s)://开头) |
| | | */ |
| | | private String link; |
| | | |
| | | public MetaVo(String title, String icon) { |
| | | this.title = title; |
| | | this.icon = icon; |
| | | } |
| | | |
| | | public MetaVo(String title, String icon, boolean noCache) { |
| | | this.title = title; |
| | | this.icon = icon; |
| | | this.noCache = noCache; |
| | | } |
| | | |
| | | public MetaVo(String title, String icon, String link) { |
| | | this.title = title; |
| | | this.icon = icon; |
| | | this.link = link; |
| | | } |
| | | |
| | | public MetaVo(String title, String icon, boolean noCache, String link) { |
| | | this.title = title; |
| | | this.icon = icon; |
| | | this.noCache = noCache; |
| | | if (StringUtils.ishttp(link)) { |
| | | this.link = link; |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 用户个人信息 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | public class ProfileVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 用户信息 |
| | | */ |
| | | private SysUserVo user; |
| | | |
| | | /** |
| | | * 用户所属角色组 |
| | | */ |
| | | private String roleGroup; |
| | | |
| | | /** |
| | | * 用户所属岗位组 |
| | | */ |
| | | private String postGroup; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 路由配置信息 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | public class RouterVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 路由名字 |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * 路由地址 |
| | | */ |
| | | private String path; |
| | | |
| | | /** |
| | | * 是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现 |
| | | */ |
| | | private boolean hidden; |
| | | |
| | | /** |
| | | * 重定向地址,当设置 noRedirect 的时候该路由在面包屑导航中不可被点击 |
| | | */ |
| | | private String redirect; |
| | | |
| | | /** |
| | | * 组件地址 |
| | | */ |
| | | private String component; |
| | | |
| | | /** |
| | | * 路由参数:如 {"id": 1, "name": "ry"} |
| | | */ |
| | | private String query; |
| | | |
| | | /** |
| | | * 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面 |
| | | */ |
| | | private Boolean alwaysShow; |
| | | |
| | | /** |
| | | * 其他元素 |
| | | */ |
| | | private MetaVo meta; |
| | | |
| | | /** |
| | | * 子路由 |
| | | */ |
| | | private List<RouterVo> children; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | import org.dromara.system.domain.SysClient; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * 授权管理视图对象 sys_client |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | @AutoMapper(target = SysClient.class) |
| | | public class SysClientVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * id |
| | | */ |
| | | @ExcelProperty(value = "id") |
| | | private Long id; |
| | | |
| | | /** |
| | | * 客户端id |
| | | */ |
| | | @ExcelProperty(value = "客户端id") |
| | | private String clientId; |
| | | |
| | | /** |
| | | * 客户端key |
| | | */ |
| | | @ExcelProperty(value = "客户端key") |
| | | private String clientKey; |
| | | |
| | | /** |
| | | * 客户端秘钥 |
| | | */ |
| | | @ExcelProperty(value = "客户端秘钥") |
| | | private String clientSecret; |
| | | |
| | | /** |
| | | * 授权类型 |
| | | */ |
| | | @ExcelProperty(value = "授权类型") |
| | | private List<String> grantTypeList; |
| | | |
| | | /** |
| | | * 授权类型 |
| | | */ |
| | | private String grantType; |
| | | |
| | | /** |
| | | * 设备类型 |
| | | */ |
| | | private String deviceType; |
| | | |
| | | /** |
| | | * token活跃超时时间 |
| | | */ |
| | | @ExcelProperty(value = "token活跃超时时间") |
| | | private Long activeTimeout; |
| | | |
| | | /** |
| | | * token固定超时时间 |
| | | */ |
| | | @ExcelProperty(value = "token固定超时时间") |
| | | private Long timeout; |
| | | |
| | | /** |
| | | * 状态(0正常 1停用) |
| | | */ |
| | | @ExcelProperty(value = "状态", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(readConverterExp = "0=正常,1=停用") |
| | | private String status; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | import org.dromara.system.domain.SysConfig; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | |
| | | /** |
| | | * 参数配置视图对象 sys_config |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | @AutoMapper(target = SysConfig.class) |
| | | public class SysConfigVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 参数主键 |
| | | */ |
| | | @ExcelProperty(value = "参数主键") |
| | | private Long configId; |
| | | |
| | | /** |
| | | * 参数名称 |
| | | */ |
| | | @ExcelProperty(value = "参数名称") |
| | | private String configName; |
| | | |
| | | /** |
| | | * 参数键名 |
| | | */ |
| | | @ExcelProperty(value = "参数键名") |
| | | private String configKey; |
| | | |
| | | /** |
| | | * 参数键值 |
| | | */ |
| | | @ExcelProperty(value = "参数键值") |
| | | private String configValue; |
| | | |
| | | /** |
| | | * 系统内置(Y是 N否) |
| | | */ |
| | | @ExcelProperty(value = "系统内置", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_yes_no") |
| | | private String configType; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ExcelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @ExcelProperty(value = "创建时间") |
| | | private Date createTime; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | import org.dromara.system.domain.SysDept; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 部门视图对象 sys_dept |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | @AutoMapper(target = SysDept.class) |
| | | public class SysDeptVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 部门id |
| | | */ |
| | | @ExcelProperty(value = "部门id") |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * 父部门id |
| | | */ |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 父部门名称 |
| | | */ |
| | | private String parentName; |
| | | |
| | | /** |
| | | * 祖级列表 |
| | | */ |
| | | private String ancestors; |
| | | |
| | | /** |
| | | * 部门名称 |
| | | */ |
| | | @ExcelProperty(value = "部门名称") |
| | | private String deptName; |
| | | |
| | | /** |
| | | * 显示顺序 |
| | | */ |
| | | private Integer orderNum; |
| | | |
| | | /** |
| | | * 负责人ID |
| | | */ |
| | | private Long leader; |
| | | |
| | | /** |
| | | * 负责人 |
| | | */ |
| | | @ExcelProperty(value = "负责人") |
| | | private String leaderName; |
| | | |
| | | /** |
| | | * 联系电话 |
| | | */ |
| | | @ExcelProperty(value = "联系电话") |
| | | private String phone; |
| | | |
| | | /** |
| | | * 邮箱 |
| | | */ |
| | | @ExcelProperty(value = "邮箱") |
| | | private String email; |
| | | |
| | | /** |
| | | * 部门状态(0正常 1停用) |
| | | */ |
| | | @ExcelProperty(value = "部门状态", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_normal_disable") |
| | | private String status; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @ExcelProperty(value = "创建时间") |
| | | private Date createTime; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | import org.dromara.system.domain.SysDictData; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | |
| | | /** |
| | | * 字典数据视图对象 sys_dict_data |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | @AutoMapper(target = SysDictData.class) |
| | | public class SysDictDataVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 字典编码 |
| | | */ |
| | | @ExcelProperty(value = "字典编码") |
| | | private Long dictCode; |
| | | |
| | | /** |
| | | * 字典排序 |
| | | */ |
| | | @ExcelProperty(value = "字典排序") |
| | | private Integer dictSort; |
| | | |
| | | /** |
| | | * 字典标签 |
| | | */ |
| | | @ExcelProperty(value = "字典标签") |
| | | private String dictLabel; |
| | | |
| | | /** |
| | | * 字典键值 |
| | | */ |
| | | @ExcelProperty(value = "字典键值") |
| | | private String dictValue; |
| | | |
| | | /** |
| | | * 字典类型 |
| | | */ |
| | | @ExcelProperty(value = "字典类型") |
| | | private String dictType; |
| | | |
| | | /** |
| | | * 样式属性(其他样式扩展) |
| | | */ |
| | | private String cssClass; |
| | | |
| | | /** |
| | | * 表格回显样式 |
| | | */ |
| | | private String listClass; |
| | | |
| | | /** |
| | | * 是否默认(Y是 N否) |
| | | */ |
| | | @ExcelProperty(value = "是否默认", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_yes_no") |
| | | private String isDefault; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ExcelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @ExcelProperty(value = "创建时间") |
| | | private Date createTime; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.system.domain.SysDictType; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | |
| | | /** |
| | | * 字典类型视图对象 sys_dict_type |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | @AutoMapper(target = SysDictType.class) |
| | | public class SysDictTypeVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 字典主键 |
| | | */ |
| | | @ExcelProperty(value = "字典主键") |
| | | private Long dictId; |
| | | |
| | | /** |
| | | * 字典名称 |
| | | */ |
| | | @ExcelProperty(value = "字典名称") |
| | | private String dictName; |
| | | |
| | | /** |
| | | * 字典类型 |
| | | */ |
| | | @ExcelProperty(value = "字典类型") |
| | | private String dictType; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ExcelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @ExcelProperty(value = "创建时间") |
| | | private Date createTime; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | import org.dromara.system.domain.SysLogininfor; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 系统访问记录视图对象 sys_logininfor |
| | | * |
| | | * @author Michelle.Chung |
| | | * @date 2023-02-07 |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | @AutoMapper(target = SysLogininfor.class) |
| | | public class SysLogininforVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 访问ID |
| | | */ |
| | | @ExcelProperty(value = "序号") |
| | | private Long infoId; |
| | | |
| | | /** |
| | | * 租户编号 |
| | | */ |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 用户账号 |
| | | */ |
| | | @ExcelProperty(value = "用户账号") |
| | | private String userName; |
| | | |
| | | /** |
| | | * 客户端 |
| | | */ |
| | | @ExcelProperty(value = "客户端") |
| | | private String clientKey; |
| | | |
| | | /** |
| | | * 设备类型 |
| | | */ |
| | | @ExcelProperty(value = "设备类型", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_device_type") |
| | | private String deviceType; |
| | | |
| | | /** |
| | | * 登录状态(0成功 1失败) |
| | | */ |
| | | @ExcelProperty(value = "登录状态", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_common_status") |
| | | private String status; |
| | | |
| | | /** |
| | | * 登录IP地址 |
| | | */ |
| | | @ExcelProperty(value = "登录地址") |
| | | private String ipaddr; |
| | | |
| | | /** |
| | | * 登录地点 |
| | | */ |
| | | @ExcelProperty(value = "登录地点") |
| | | private String loginLocation; |
| | | |
| | | /** |
| | | * 浏览器类型 |
| | | */ |
| | | @ExcelProperty(value = "浏览器") |
| | | private String browser; |
| | | |
| | | /** |
| | | * 操作系统 |
| | | */ |
| | | @ExcelProperty(value = "操作系统") |
| | | private String os; |
| | | |
| | | |
| | | /** |
| | | * 提示消息 |
| | | */ |
| | | @ExcelProperty(value = "提示消息") |
| | | private String msg; |
| | | |
| | | /** |
| | | * 访问时间 |
| | | */ |
| | | @ExcelProperty(value = "访问时间") |
| | | private Date loginTime; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.system.domain.SysMenu; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * 菜单权限视图对象 sys_menu |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @AutoMapper(target = SysMenu.class) |
| | | public class SysMenuVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 菜单ID |
| | | */ |
| | | private Long menuId; |
| | | |
| | | /** |
| | | * 菜单名称 |
| | | */ |
| | | private String menuName; |
| | | |
| | | /** |
| | | * 父菜单ID |
| | | */ |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * 显示顺序 |
| | | */ |
| | | private Integer orderNum; |
| | | |
| | | /** |
| | | * 路由地址 |
| | | */ |
| | | private String path; |
| | | |
| | | /** |
| | | * 组件路径 |
| | | */ |
| | | private String component; |
| | | |
| | | /** |
| | | * 路由参数 |
| | | */ |
| | | private String queryParam; |
| | | |
| | | /** |
| | | * 是否为外链(0是 1否) |
| | | */ |
| | | private String isFrame; |
| | | |
| | | /** |
| | | * 是否缓存(0缓存 1不缓存) |
| | | */ |
| | | private String isCache; |
| | | |
| | | /** |
| | | * 菜单类型(M目录 C菜单 F按钮) |
| | | */ |
| | | private String menuType; |
| | | |
| | | /** |
| | | * 显示状态(0显示 1隐藏) |
| | | */ |
| | | private String visible; |
| | | |
| | | /** |
| | | * 菜单状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 权限标识 |
| | | */ |
| | | private String perms; |
| | | |
| | | /** |
| | | * 菜单图标 |
| | | */ |
| | | private String icon; |
| | | |
| | | /** |
| | | * 创建部门 |
| | | */ |
| | | private Long createDept; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 子菜单 |
| | | */ |
| | | private List<SysMenuVo> children = new ArrayList<>(); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.common.translation.annotation.Translation; |
| | | import org.dromara.common.translation.constant.TransConstant; |
| | | import org.dromara.system.domain.SysNotice; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 通知公告视图对象 sys_notice |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @AutoMapper(target = SysNotice.class) |
| | | public class SysNoticeVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 公告ID |
| | | */ |
| | | private Long noticeId; |
| | | |
| | | /** |
| | | * 公告标题 |
| | | */ |
| | | private String noticeTitle; |
| | | |
| | | /** |
| | | * 公告类型(1通知 2公告) |
| | | */ |
| | | private String noticeType; |
| | | |
| | | /** |
| | | * 公告内容 |
| | | */ |
| | | private String noticeContent; |
| | | |
| | | /** |
| | | * 公告状态(0正常 1关闭) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 创建者 |
| | | */ |
| | | private Long createBy; |
| | | |
| | | /** |
| | | * 创建人名称 |
| | | */ |
| | | @Translation(type = TransConstant.USER_ID_TO_NAME, mapper = "createBy") |
| | | private String createByName; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | import org.dromara.system.domain.SysOperLog; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | |
| | | /** |
| | | * 操作日志记录视图对象 sys_oper_log |
| | | * |
| | | * @author Michelle.Chung |
| | | * @date 2023-02-07 |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | @AutoMapper(target = SysOperLog.class) |
| | | public class SysOperLogVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 日志主键 |
| | | */ |
| | | @ExcelProperty(value = "日志主键") |
| | | private Long operId; |
| | | |
| | | /** |
| | | * 租户编号 |
| | | */ |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 模块标题 |
| | | */ |
| | | @ExcelProperty(value = "操作模块") |
| | | private String title; |
| | | |
| | | /** |
| | | * 业务类型(0其它 1新增 2修改 3删除) |
| | | */ |
| | | @ExcelProperty(value = "业务类型", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_oper_type") |
| | | private Integer businessType; |
| | | |
| | | /** |
| | | * 业务类型数组 |
| | | */ |
| | | private Integer[] businessTypes; |
| | | |
| | | /** |
| | | * 方法名称 |
| | | */ |
| | | @ExcelProperty(value = "请求方法") |
| | | private String method; |
| | | |
| | | /** |
| | | * 请求方式 |
| | | */ |
| | | @ExcelProperty(value = "请求方式") |
| | | private String requestMethod; |
| | | |
| | | /** |
| | | * 操作类别(0其它 1后台用户 2手机端用户) |
| | | */ |
| | | @ExcelProperty(value = "操作类别", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(readConverterExp = "0=其它,1=后台用户,2=手机端用户") |
| | | private Integer operatorType; |
| | | |
| | | /** |
| | | * 操作人员 |
| | | */ |
| | | @ExcelProperty(value = "操作人员") |
| | | private String operName; |
| | | |
| | | /** |
| | | * 部门名称 |
| | | */ |
| | | @ExcelProperty(value = "部门名称") |
| | | private String deptName; |
| | | |
| | | /** |
| | | * 请求URL |
| | | */ |
| | | @ExcelProperty(value = "请求地址") |
| | | private String operUrl; |
| | | |
| | | /** |
| | | * 主机地址 |
| | | */ |
| | | @ExcelProperty(value = "操作地址") |
| | | private String operIp; |
| | | |
| | | /** |
| | | * 操作地点 |
| | | */ |
| | | @ExcelProperty(value = "操作地点") |
| | | private String operLocation; |
| | | |
| | | /** |
| | | * 请求参数 |
| | | */ |
| | | @ExcelProperty(value = "请求参数") |
| | | private String operParam; |
| | | |
| | | /** |
| | | * 返回参数 |
| | | */ |
| | | @ExcelProperty(value = "返回参数") |
| | | private String jsonResult; |
| | | |
| | | /** |
| | | * 操作状态(0正常 1异常) |
| | | */ |
| | | @ExcelProperty(value = "状态", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_common_status") |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 错误消息 |
| | | */ |
| | | @ExcelProperty(value = "错误消息") |
| | | private String errorMsg; |
| | | |
| | | /** |
| | | * 操作时间 |
| | | */ |
| | | @ExcelProperty(value = "操作时间") |
| | | private Date operTime; |
| | | |
| | | /** |
| | | * 消耗时间 |
| | | */ |
| | | @ExcelProperty(value = "消耗时间") |
| | | private Long costTime; |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | import org.dromara.system.domain.SysPost; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 岗位信息视图对象 sys_post |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | @AutoMapper(target = SysPost.class) |
| | | public class SysPostVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 岗位ID |
| | | */ |
| | | @ExcelProperty(value = "岗位序号") |
| | | private Long postId; |
| | | |
| | | /** |
| | | * 岗位编码 |
| | | */ |
| | | @ExcelProperty(value = "岗位编码") |
| | | private String postCode; |
| | | |
| | | /** |
| | | * 岗位名称 |
| | | */ |
| | | @ExcelProperty(value = "岗位名称") |
| | | private String postName; |
| | | |
| | | /** |
| | | * 显示顺序 |
| | | */ |
| | | @ExcelProperty(value = "岗位排序") |
| | | private Integer postSort; |
| | | |
| | | /** |
| | | * 状态(0正常 1停用) |
| | | */ |
| | | @ExcelProperty(value = "状态", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_normal_disable") |
| | | private String status; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ExcelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @ExcelProperty(value = "创建时间") |
| | | private Date createTime; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | import org.dromara.system.domain.SysRole; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 角色信息视图对象 sys_role |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | @AutoMapper(target = SysRole.class) |
| | | public class SysRoleVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 角色ID |
| | | */ |
| | | @ExcelProperty(value = "角色序号") |
| | | private Long roleId; |
| | | |
| | | /** |
| | | * 角色名称 |
| | | */ |
| | | @ExcelProperty(value = "角色名称") |
| | | private String roleName; |
| | | |
| | | /** |
| | | * 角色权限字符串 |
| | | */ |
| | | @ExcelProperty(value = "角色权限") |
| | | private String roleKey; |
| | | |
| | | /** |
| | | * 显示顺序 |
| | | */ |
| | | @ExcelProperty(value = "角色排序") |
| | | private Integer roleSort; |
| | | |
| | | /** |
| | | * 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限) |
| | | */ |
| | | @ExcelProperty(value = "数据范围", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") |
| | | private String dataScope; |
| | | |
| | | /** |
| | | * 菜单树选择项是否关联显示 |
| | | */ |
| | | @ExcelProperty(value = "菜单树选择项是否关联显示") |
| | | private Boolean menuCheckStrictly; |
| | | |
| | | /** |
| | | * 部门树选择项是否关联显示 |
| | | */ |
| | | @ExcelProperty(value = "部门树选择项是否关联显示") |
| | | private Boolean deptCheckStrictly; |
| | | |
| | | /** |
| | | * 角色状态(0正常 1停用) |
| | | */ |
| | | @ExcelProperty(value = "角色状态", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_normal_disable") |
| | | private String status; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ExcelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @ExcelProperty(value = "创建时间") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 用户是否存在此角色标识 默认不存在 |
| | | */ |
| | | private boolean flag = false; |
| | | |
| | | public boolean isSuperAdmin() { |
| | | return UserConstants.SUPER_ADMIN_ID.equals(this.roleId); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.system.domain.SysSocial; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | |
| | | /** |
| | | * 社会化关系视图对象 sys_social |
| | | * |
| | | * @author thiszhc |
| | | */ |
| | | @Data |
| | | @AutoMapper(target = SysSocial.class) |
| | | public class SysSocialVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private Long id; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 的唯一ID |
| | | */ |
| | | private String authId; |
| | | |
| | | /** |
| | | * 用户来源 |
| | | */ |
| | | private String source; |
| | | |
| | | /** |
| | | * 用户的授权令牌 |
| | | */ |
| | | private String accessToken; |
| | | |
| | | /** |
| | | * 用户的授权令牌的有效期,部分平台可能没有 |
| | | */ |
| | | private int expireIn; |
| | | |
| | | /** |
| | | * 刷新令牌,部分平台可能没有 |
| | | */ |
| | | private String refreshToken; |
| | | |
| | | /** |
| | | * 用户的 open id |
| | | */ |
| | | private String openId; |
| | | |
| | | /** |
| | | * 授权的第三方账号 |
| | | */ |
| | | private String userName; |
| | | |
| | | /** |
| | | * 授权的第三方昵称 |
| | | */ |
| | | private String nickName; |
| | | |
| | | /** |
| | | * 授权的第三方邮箱 |
| | | */ |
| | | private String email; |
| | | |
| | | /** |
| | | * 授权的第三方头像地址 |
| | | */ |
| | | private String avatar; |
| | | |
| | | |
| | | /** |
| | | * 平台的授权信息,部分平台可能没有 |
| | | */ |
| | | private String accessCode; |
| | | |
| | | /** |
| | | * 用户的 unionid |
| | | */ |
| | | private String unionId; |
| | | |
| | | /** |
| | | * 授予的权限,部分平台可能没有 |
| | | */ |
| | | private String scope; |
| | | |
| | | /** |
| | | * 个别平台的授权信息,部分平台可能没有 |
| | | */ |
| | | private String tokenType; |
| | | |
| | | /** |
| | | * id token,部分平台可能没有 |
| | | */ |
| | | private String idToken; |
| | | |
| | | /** |
| | | * 小米平台用户的附带属性,部分平台可能没有 |
| | | */ |
| | | private String macAlgorithm; |
| | | |
| | | /** |
| | | * 小米平台用户的附带属性,部分平台可能没有 |
| | | */ |
| | | private String macKey; |
| | | |
| | | /** |
| | | * 用户的授权code,部分平台可能没有 |
| | | */ |
| | | private String code; |
| | | |
| | | /** |
| | | * Twitter平台用户的附带属性,部分平台可能没有 |
| | | */ |
| | | private String oauthToken; |
| | | |
| | | /** |
| | | * Twitter平台用户的附带属性,部分平台可能没有 |
| | | */ |
| | | private String oauthTokenSecret; |
| | | |
| | | /** |
| | | * 显示绑定时间 |
| | | */ |
| | | private Date createTime; |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | import org.dromara.system.domain.SysTenantPackage; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | |
| | | |
| | | /** |
| | | * 租户套餐视图对象 sys_tenant_package |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | @AutoMapper(target = SysTenantPackage.class) |
| | | public class SysTenantPackageVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 租户套餐id |
| | | */ |
| | | @ExcelProperty(value = "租户套餐id") |
| | | private Long packageId; |
| | | |
| | | /** |
| | | * 套餐名称 |
| | | */ |
| | | @ExcelProperty(value = "套餐名称") |
| | | private String packageName; |
| | | |
| | | /** |
| | | * 关联菜单id |
| | | */ |
| | | @ExcelProperty(value = "关联菜单id") |
| | | private String menuIds; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ExcelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 菜单树选择项是否关联显示 |
| | | */ |
| | | @ExcelProperty(value = "菜单树选择项是否关联显示") |
| | | private Boolean menuCheckStrictly; |
| | | |
| | | /** |
| | | * 状态(0正常 1停用) |
| | | */ |
| | | @ExcelProperty(value = "状态", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(readConverterExp = "0=正常,1=停用") |
| | | private String status; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | import org.dromara.system.domain.SysTenant; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | |
| | | /** |
| | | * 租户视图对象 sys_tenant |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | @AutoMapper(target = SysTenant.class) |
| | | public class SysTenantVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * id |
| | | */ |
| | | @ExcelProperty(value = "id") |
| | | private Long id; |
| | | |
| | | /** |
| | | * 租户编号 |
| | | */ |
| | | @ExcelProperty(value = "租户编号") |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 联系人 |
| | | */ |
| | | @ExcelProperty(value = "联系人") |
| | | private String contactUserName; |
| | | |
| | | /** |
| | | * 联系电话 |
| | | */ |
| | | @ExcelProperty(value = "联系电话") |
| | | private String contactPhone; |
| | | |
| | | /** |
| | | * 企业名称 |
| | | */ |
| | | @ExcelProperty(value = "企业名称") |
| | | private String companyName; |
| | | |
| | | /** |
| | | * 统一社会信用代码 |
| | | */ |
| | | @ExcelProperty(value = "统一社会信用代码") |
| | | private String licenseNumber; |
| | | |
| | | /** |
| | | * 地址 |
| | | */ |
| | | @ExcelProperty(value = "地址") |
| | | private String address; |
| | | |
| | | /** |
| | | * 域名 |
| | | */ |
| | | @ExcelProperty(value = "域名") |
| | | private String domain; |
| | | |
| | | /** |
| | | * 企业简介 |
| | | */ |
| | | @ExcelProperty(value = "企业简介") |
| | | private String intro; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ExcelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | /** |
| | | * 租户套餐编号 |
| | | */ |
| | | @ExcelProperty(value = "租户套餐编号") |
| | | private Long packageId; |
| | | |
| | | /** |
| | | * 过期时间 |
| | | */ |
| | | @ExcelProperty(value = "过期时间") |
| | | private Date expireTime; |
| | | |
| | | /** |
| | | * 用户数量(-1不限制) |
| | | */ |
| | | @ExcelProperty(value = "用户数量") |
| | | private Long accountCount; |
| | | |
| | | /** |
| | | * 租户状态(0正常 1停用) |
| | | */ |
| | | @ExcelProperty(value = "租户状态", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(readConverterExp = "0=正常,1=停用") |
| | | private String status; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import io.github.linpeilie.annotations.ReverseAutoMapping; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 用户对象导出VO |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @AutoMapper(target = SysUserVo.class, convertGenerate = false) |
| | | public class SysUserExportVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @ExcelProperty(value = "用户序号") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 用户账号 |
| | | */ |
| | | @ExcelProperty(value = "登录名称") |
| | | private String userName; |
| | | |
| | | /** |
| | | * 用户昵称 |
| | | */ |
| | | @ExcelProperty(value = "用户名称") |
| | | private String nickName; |
| | | |
| | | /** |
| | | * 用户邮箱 |
| | | */ |
| | | @ExcelProperty(value = "用户邮箱") |
| | | private String email; |
| | | |
| | | /** |
| | | * 手机号码 |
| | | */ |
| | | @ExcelProperty(value = "手机号码") |
| | | private String phonenumber; |
| | | |
| | | /** |
| | | * 用户性别 |
| | | */ |
| | | @ExcelProperty(value = "用户性别", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_user_sex") |
| | | private String sex; |
| | | |
| | | /** |
| | | * 帐号状态(0正常 1停用) |
| | | */ |
| | | @ExcelProperty(value = "帐号状态", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_normal_disable") |
| | | private String status; |
| | | |
| | | /** |
| | | * 最后登录IP |
| | | */ |
| | | @ExcelProperty(value = "最后登录IP") |
| | | private String loginIp; |
| | | |
| | | /** |
| | | * 最后登录时间 |
| | | */ |
| | | @ExcelProperty(value = "最后登录时间") |
| | | private Date loginDate; |
| | | |
| | | /** |
| | | * 部门名称 |
| | | */ |
| | | @ReverseAutoMapping(target = "deptName", source = "dept.deptName") |
| | | @ExcelProperty(value = "部门名称") |
| | | private String deptName; |
| | | |
| | | /** |
| | | * 负责人 |
| | | */ |
| | | @ReverseAutoMapping(target = "leaderName", source = "dept.leaderName") |
| | | @ExcelProperty(value = "部门负责人") |
| | | private String leaderName; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | import org.dromara.common.excel.annotation.ExcelDictFormat; |
| | | import org.dromara.common.excel.convert.ExcelDictConvert; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | |
| | | |
| | | /** |
| | | * 用户对象导入VO |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | // @Accessors(chain = true) // 导入不允许使用 会找不到set方法 |
| | | public class SysUserImportVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | @ExcelProperty(value = "用户序号") |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 部门ID |
| | | */ |
| | | @ExcelProperty(value = "部门编号") |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * 用户账号 |
| | | */ |
| | | @ExcelProperty(value = "登录名称") |
| | | private String userName; |
| | | |
| | | /** |
| | | * 用户昵称 |
| | | */ |
| | | @ExcelProperty(value = "用户名称") |
| | | private String nickName; |
| | | |
| | | /** |
| | | * 用户邮箱 |
| | | */ |
| | | @ExcelProperty(value = "用户邮箱") |
| | | private String email; |
| | | |
| | | /** |
| | | * 手机号码 |
| | | */ |
| | | @ExcelProperty(value = "手机号码") |
| | | private String phonenumber; |
| | | |
| | | /** |
| | | * 用户性别 |
| | | */ |
| | | @ExcelProperty(value = "用户性别", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_user_sex") |
| | | private String sex; |
| | | |
| | | /** |
| | | * 帐号状态(0正常 1停用) |
| | | */ |
| | | @ExcelProperty(value = "帐号状态", converter = ExcelDictConvert.class) |
| | | @ExcelDictFormat(dictType = "sys_normal_disable") |
| | | private String status; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户信息 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | public class SysUserInfoVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 用户信息 |
| | | */ |
| | | private SysUserVo user; |
| | | |
| | | /** |
| | | * 角色ID列表 |
| | | */ |
| | | private List<Long> roleIds; |
| | | |
| | | /** |
| | | * 角色列表 |
| | | */ |
| | | private List<SysRoleVo> roles; |
| | | |
| | | /** |
| | | * 岗位ID列表 |
| | | */ |
| | | private List<Long> postIds; |
| | | |
| | | /** |
| | | * 岗位列表 |
| | | */ |
| | | private List<SysPostVo> posts; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | import io.github.linpeilie.annotations.AutoMapper; |
| | | import lombok.Data; |
| | | import org.dromara.common.sensitive.annotation.Sensitive; |
| | | import org.dromara.common.sensitive.core.SensitiveStrategy; |
| | | import org.dromara.common.translation.annotation.Translation; |
| | | import org.dromara.common.translation.constant.TransConstant; |
| | | import org.dromara.system.domain.SysUser; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * 用户信息视图对象 sys_user |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | @AutoMapper(target = SysUser.class) |
| | | public class SysUserVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 租户ID |
| | | */ |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * 部门ID |
| | | */ |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * 用户账号 |
| | | */ |
| | | private String userName; |
| | | |
| | | /** |
| | | * 用户昵称 |
| | | */ |
| | | private String nickName; |
| | | |
| | | /** |
| | | * 用户类型(sys_user系统用户) |
| | | */ |
| | | private String userType; |
| | | |
| | | /** |
| | | * 用户邮箱 |
| | | */ |
| | | @Sensitive(strategy = SensitiveStrategy.EMAIL) |
| | | private String email; |
| | | |
| | | /** |
| | | * 手机号码 |
| | | */ |
| | | @Sensitive(strategy = SensitiveStrategy.PHONE) |
| | | private String phonenumber; |
| | | |
| | | /** |
| | | * 用户性别(0男 1女 2未知) |
| | | */ |
| | | private String sex; |
| | | |
| | | /** |
| | | * 头像地址 |
| | | */ |
| | | @Translation(type = TransConstant.OSS_ID_TO_URL) |
| | | private Long avatar; |
| | | |
| | | /** |
| | | * 密码 |
| | | */ |
| | | @JsonIgnore |
| | | @JsonProperty |
| | | private String password; |
| | | |
| | | /** |
| | | * 帐号状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 最后登录IP |
| | | */ |
| | | private String loginIp; |
| | | |
| | | /** |
| | | * 最后登录时间 |
| | | */ |
| | | private Date loginDate; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 部门对象 |
| | | */ |
| | | private SysDeptVo dept; |
| | | |
| | | /** |
| | | * 角色对象 |
| | | */ |
| | | private List<SysRoleVo> roles; |
| | | |
| | | /** |
| | | * 角色组 |
| | | */ |
| | | private Long[] roleIds; |
| | | |
| | | /** |
| | | * 岗位组 |
| | | */ |
| | | private Long[] postIds; |
| | | |
| | | /** |
| | | * 数据权限 当前角色ID |
| | | */ |
| | | private Long roleId; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * 登录用户信息 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Data |
| | | public class UserInfoVo implements Serializable { |
| | | |
| | | @Serial |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 用户基本信息 |
| | | */ |
| | | private SysUserVo user; |
| | | |
| | | /** |
| | | * 菜单权限 |
| | | */ |
| | | private Set<String> permissions; |
| | | |
| | | /** |
| | | * 角色权限 |
| | | */ |
| | | private Set<String> roles; |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.dubbo; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.dubbo.config.annotation.DubboService; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.system.api.RemoteClientService; |
| | | import org.dromara.system.api.domain.vo.RemoteClientVo; |
| | | import org.dromara.system.domain.vo.SysClientVo; |
| | | import org.dromara.system.service.ISysClientService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 客户端服务 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | @DubboService |
| | | public class RemoteClientServiceImpl implements RemoteClientService { |
| | | |
| | | private final ISysClientService sysClientService; |
| | | |
| | | /** |
| | | * 根据客户端id获取客户端详情 |
| | | */ |
| | | @Override |
| | | public RemoteClientVo queryByClientId(String clientId) { |
| | | SysClientVo vo = sysClientService.queryByClientId(clientId); |
| | | return MapstructUtils.convert(vo, RemoteClientVo.class); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.dubbo; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.dubbo.config.annotation.DubboService; |
| | | import org.dromara.system.api.RemoteConfigService; |
| | | import org.dromara.system.service.ISysConfigService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 配置服务 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | @DubboService |
| | | public class RemoteConfigServiceImpl implements RemoteConfigService { |
| | | |
| | | private final ISysConfigService configService; |
| | | |
| | | /** |
| | | * 获取注册开关 |
| | | */ |
| | | @Override |
| | | public boolean selectRegisterEnabled(String tenantId) { |
| | | return configService.selectRegisterEnabled(tenantId); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.dubbo; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.dubbo.config.annotation.DubboService; |
| | | import org.dromara.common.core.utils.StreamUtils; |
| | | import org.dromara.common.mybatis.helper.DataBaseHelper; |
| | | import org.dromara.system.api.RemoteDataScopeService; |
| | | import org.dromara.system.domain.SysDept; |
| | | import org.dromara.system.domain.SysRoleDept; |
| | | import org.dromara.system.mapper.SysDeptMapper; |
| | | import org.dromara.system.mapper.SysRoleDeptMapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 数据权限 实现 |
| | | * <p> |
| | | * 注意: 此Service内不允许调用标注`数据权限`注解的方法 |
| | | * 例如: deptMapper.selectList 此 selectList 方法标注了`数据权限`注解 会出现循环解析的问题 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | @DubboService |
| | | public class RemoteDataScopeServiceImpl implements RemoteDataScopeService { |
| | | |
| | | private final SysRoleDeptMapper roleDeptMapper; |
| | | private final SysDeptMapper deptMapper; |
| | | |
| | | @Override |
| | | public String getRoleCustom(Long roleId) { |
| | | List<SysRoleDept> list = roleDeptMapper.selectList( |
| | | new LambdaQueryWrapper<SysRoleDept>() |
| | | .select(SysRoleDept::getDeptId) |
| | | .eq(SysRoleDept::getRoleId, roleId)); |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | return StreamUtils.join(list, rd -> Convert.toStr(rd.getDeptId())); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String getDeptAndChild(Long deptId) { |
| | | List<SysDept> deptList = deptMapper.selectList(new LambdaQueryWrapper<SysDept>() |
| | | .select(SysDept::getDeptId) |
| | | .apply(DataBaseHelper.findInSet(deptId, "ancestors"))); |
| | | List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId); |
| | | ids.add(deptId); |
| | | if (CollUtil.isNotEmpty(ids)) { |
| | | return StreamUtils.join(ids, Convert::toStr); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.dubbo; |
| | | |
| | | import org.dromara.system.api.RemoteDeptService; |
| | | import org.dromara.system.service.ISysDeptService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.dubbo.config.annotation.DubboService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 部门服务 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | @DubboService |
| | | public class RemoteDeptServiceImpl implements RemoteDeptService { |
| | | |
| | | private final ISysDeptService sysDeptService; |
| | | |
| | | @Override |
| | | public String selectDeptNameByIds(String deptIds) { |
| | | return sysDeptService.selectDeptNameByIds(deptIds); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.dubbo; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.dubbo.config.annotation.DubboService; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.system.api.RemoteDictService; |
| | | import org.dromara.system.api.domain.vo.RemoteDictDataVo; |
| | | import org.dromara.system.domain.vo.SysDictDataVo; |
| | | import org.dromara.system.service.ISysDictTypeService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典服务 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | @DubboService |
| | | public class RemoteDictServiceImpl implements RemoteDictService { |
| | | |
| | | private final ISysDictTypeService sysDictTypeService; |
| | | |
| | | |
| | | @Override |
| | | public List<RemoteDictDataVo> selectDictDataByType(String dictType) { |
| | | List<SysDictDataVo> list = sysDictTypeService.selectDictDataByType(dictType); |
| | | return MapstructUtils.convert(list, RemoteDictDataVo.class); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.dubbo; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.dubbo.config.annotation.DubboService; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.system.api.RemoteLogService; |
| | | import org.dromara.system.api.domain.bo.RemoteLogininforBo; |
| | | import org.dromara.system.api.domain.bo.RemoteOperLogBo; |
| | | import org.dromara.system.domain.bo.SysLogininforBo; |
| | | import org.dromara.system.domain.bo.SysOperLogBo; |
| | | import org.dromara.system.service.ISysLogininforService; |
| | | import org.dromara.system.service.ISysOperLogService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 操作日志记录 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | @DubboService |
| | | public class RemoteLogServiceImpl implements RemoteLogService { |
| | | |
| | | private final ISysOperLogService operLogService; |
| | | private final ISysLogininforService logininforService; |
| | | |
| | | @Override |
| | | public void saveLog(RemoteOperLogBo remoteOperLogBo) { |
| | | SysOperLogBo sysOperLogBo = MapstructUtils.convert(remoteOperLogBo, SysOperLogBo.class); |
| | | operLogService.insertOperlog(sysOperLogBo); |
| | | } |
| | | |
| | | @Override |
| | | public void saveLogininfor(RemoteLogininforBo remoteLogininforBo) { |
| | | SysLogininforBo sysLogininforBo = MapstructUtils.convert(remoteLogininforBo, SysLogininforBo.class); |
| | | logininforService.insertLogininfor(sysLogininforBo); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.dubbo; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.dubbo.config.annotation.DubboService; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.system.api.RemoteSocialService; |
| | | import org.dromara.system.api.domain.bo.RemoteSocialBo; |
| | | import org.dromara.system.api.domain.vo.RemoteSocialVo; |
| | | import org.dromara.system.domain.bo.SysSocialBo; |
| | | import org.dromara.system.domain.vo.SysSocialVo; |
| | | import org.dromara.system.mapper.SysSocialMapper; |
| | | import org.dromara.system.service.ISysSocialService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 社会化关系服务 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | @DubboService |
| | | public class RemoteSocialServiceImpl implements RemoteSocialService { |
| | | |
| | | private final ISysSocialService sysSocialService; |
| | | private final SysSocialMapper sysSocialMapper; |
| | | |
| | | /** |
| | | * 根据 authId 查询用户信息 |
| | | */ |
| | | @Override |
| | | public List<RemoteSocialVo> selectByAuthId(String authId) { |
| | | List<SysSocialVo> list = sysSocialService.selectByAuthId(authId); |
| | | return MapstructUtils.convert(list, RemoteSocialVo.class); |
| | | } |
| | | |
| | | /** |
| | | * 保存社会化关系 |
| | | */ |
| | | @Override |
| | | public void insertByBo(RemoteSocialBo bo) { |
| | | sysSocialService.insertByBo(MapstructUtils.convert(bo, SysSocialBo.class)); |
| | | } |
| | | |
| | | /** |
| | | * 更新社会化关系 |
| | | */ |
| | | @Override |
| | | public void updateByBo(RemoteSocialBo bo) { |
| | | sysSocialService.updateByBo(MapstructUtils.convert(bo, SysSocialBo.class)); |
| | | } |
| | | |
| | | /** |
| | | * 删除社会化关系 |
| | | */ |
| | | @Override |
| | | public Boolean deleteWithValidById(Long socialId) { |
| | | return sysSocialService.deleteWithValidById(socialId); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.dubbo; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.dubbo.config.annotation.DubboService; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.system.api.RemoteTenantService; |
| | | import org.dromara.system.api.domain.vo.RemoteTenantVo; |
| | | import org.dromara.system.domain.bo.SysTenantBo; |
| | | import org.dromara.system.domain.vo.SysTenantVo; |
| | | import org.dromara.system.service.ISysTenantService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhujie |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | @DubboService |
| | | public class RemoteTenantServiceImpl implements RemoteTenantService { |
| | | |
| | | private final ISysTenantService tenantService; |
| | | |
| | | /** |
| | | * 根据租户id获取租户详情 |
| | | */ |
| | | @Override |
| | | public RemoteTenantVo queryByTenantId(String tenantId) { |
| | | SysTenantVo vo = tenantService.queryByTenantId(tenantId); |
| | | return MapstructUtils.convert(vo, RemoteTenantVo.class); |
| | | } |
| | | |
| | | /** |
| | | * 获取租户列表 |
| | | */ |
| | | @Override |
| | | public List<RemoteTenantVo> queryList() { |
| | | List<SysTenantVo> list = tenantService.queryList(new SysTenantBo()); |
| | | return MapstructUtils.convert(list, RemoteTenantVo.class); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.dubbo; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.dubbo.config.annotation.DubboService; |
| | | import org.dromara.common.core.enums.UserStatus; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.exception.user.UserException; |
| | | import org.dromara.common.core.utils.DateUtils; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.mybatis.helper.DataPermissionHelper; |
| | | import org.dromara.common.tenant.helper.TenantHelper; |
| | | import org.dromara.system.api.RemoteUserService; |
| | | import org.dromara.system.api.domain.bo.RemoteUserBo; |
| | | import org.dromara.system.api.model.LoginUser; |
| | | import org.dromara.system.api.model.RoleDTO; |
| | | import org.dromara.system.api.model.XcxLoginUser; |
| | | import org.dromara.system.domain.SysUser; |
| | | import org.dromara.system.domain.bo.SysUserBo; |
| | | import org.dromara.system.domain.vo.SysUserVo; |
| | | import org.dromara.system.mapper.SysUserMapper; |
| | | import org.dromara.system.service.ISysConfigService; |
| | | import org.dromara.system.service.ISysPermissionService; |
| | | import org.dromara.system.service.ISysUserService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户服务 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | @DubboService |
| | | public class RemoteUserServiceImpl implements RemoteUserService { |
| | | |
| | | private final ISysUserService userService; |
| | | private final ISysPermissionService permissionService; |
| | | private final ISysConfigService configService; |
| | | private final SysUserMapper userMapper; |
| | | |
| | | @Override |
| | | public LoginUser getUserInfo(String username, String tenantId) throws UserException { |
| | | return TenantHelper.dynamic(tenantId, () -> { |
| | | SysUser sysUser = userMapper.selectOne(new LambdaQueryWrapper<SysUser>() |
| | | .select(SysUser::getUserName, SysUser::getStatus) |
| | | .eq(SysUser::getUserName, username)); |
| | | if (ObjectUtil.isNull(sysUser)) { |
| | | throw new UserException("user.not.exists", username); |
| | | } |
| | | if (UserStatus.DISABLE.getCode().equals(sysUser.getStatus())) { |
| | | throw new UserException("user.blocked", username); |
| | | } |
| | | // 框架登录不限制从什么表查询 只要最终构建出 LoginUser 即可 |
| | | // 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了 |
| | | return buildLoginUser(userMapper.selectUserByUserName(username)); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public LoginUser getUserInfo(Long userId, String tenantId) throws UserException { |
| | | return TenantHelper.dynamic(tenantId, () -> { |
| | | SysUser sysUser = userMapper.selectOne(new LambdaQueryWrapper<SysUser>() |
| | | .select(SysUser::getUserName, SysUser::getStatus) |
| | | .eq(SysUser::getUserId, userId)); |
| | | if (ObjectUtil.isNull(sysUser)) { |
| | | throw new UserException("user.not.exists", ""); |
| | | } |
| | | if (UserStatus.DISABLE.getCode().equals(sysUser.getStatus())) { |
| | | throw new UserException("user.blocked", sysUser.getUserName()); |
| | | } |
| | | // 框架登录不限制从什么表查询 只要最终构建出 LoginUser 即可 |
| | | // 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了 |
| | | return buildLoginUser(userMapper.selectUserByUserName(sysUser.getUserName())); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public LoginUser getUserInfoByPhonenumber(String phonenumber, String tenantId) throws UserException { |
| | | return TenantHelper.dynamic(tenantId, () -> { |
| | | SysUser sysUser = userMapper.selectOne(new LambdaQueryWrapper<SysUser>() |
| | | .select(SysUser::getPhonenumber, SysUser::getStatus) |
| | | .eq(SysUser::getPhonenumber, phonenumber)); |
| | | if (ObjectUtil.isNull(sysUser)) { |
| | | throw new UserException("user.not.exists", phonenumber); |
| | | } |
| | | if (UserStatus.DISABLE.getCode().equals(sysUser.getStatus())) { |
| | | throw new UserException("user.blocked", phonenumber); |
| | | } |
| | | // 框架登录不限制从什么表查询 只要最终构建出 LoginUser 即可 |
| | | // 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了 |
| | | return buildLoginUser(userMapper.selectUserByPhonenumber(phonenumber)); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public LoginUser getUserInfoByEmail(String email, String tenantId) throws UserException { |
| | | return TenantHelper.dynamic(tenantId, () -> { |
| | | SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>() |
| | | .select(SysUser::getEmail, SysUser::getStatus) |
| | | .eq(SysUser::getEmail, email)); |
| | | if (ObjectUtil.isNull(user)) { |
| | | throw new UserException("user.not.exists", email); |
| | | } |
| | | if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { |
| | | throw new UserException("user.blocked", email); |
| | | } |
| | | // 框架登录不限制从什么表查询 只要最终构建出 LoginUser 即可 |
| | | // 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了 |
| | | return buildLoginUser(userMapper.selectUserByEmail(email)); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public XcxLoginUser getUserInfoByOpenid(String openid) throws UserException { |
| | | // todo 自行实现 userService.selectUserByOpenid(openid); |
| | | SysUser sysUser = new SysUser(); |
| | | if (ObjectUtil.isNull(sysUser)) { |
| | | // todo 用户不存在 业务逻辑自行实现 |
| | | } |
| | | if (UserStatus.DISABLE.getCode().equals(sysUser.getStatus())) { |
| | | // todo 用户已被停用 业务逻辑自行实现 |
| | | } |
| | | // 框架登录不限制从什么表查询 只要最终构建出 LoginUser 即可 |
| | | // 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了 |
| | | XcxLoginUser loginUser = new XcxLoginUser(); |
| | | loginUser.setUserId(sysUser.getUserId()); |
| | | loginUser.setUsername(sysUser.getUserName()); |
| | | loginUser.setNickname(sysUser.getNickName()); |
| | | loginUser.setUserType(sysUser.getUserType()); |
| | | loginUser.setOpenid(openid); |
| | | return loginUser; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean registerUserInfo(RemoteUserBo remoteUserBo) throws UserException, ServiceException { |
| | | SysUserBo sysUserBo = MapstructUtils.convert(remoteUserBo, SysUserBo.class); |
| | | String username = sysUserBo.getUserName(); |
| | | boolean exist = TenantHelper.dynamic(remoteUserBo.getTenantId(), () -> { |
| | | if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) { |
| | | throw new ServiceException("当前系统没有开启注册功能"); |
| | | } |
| | | return userMapper.exists(new LambdaQueryWrapper<SysUser>() |
| | | .eq(SysUser::getUserName, sysUserBo.getUserName()) |
| | | .ne(ObjectUtil.isNotNull(sysUserBo.getUserId()), SysUser::getUserId, sysUserBo.getUserId())); |
| | | }); |
| | | if (exist) { |
| | | throw new UserException("user.register.save.error", username); |
| | | } |
| | | return userService.registerUser(sysUserBo, remoteUserBo.getTenantId()); |
| | | } |
| | | |
| | | @Override |
| | | public String selectUserNameById(Long userId) { |
| | | return userService.selectUserNameById(userId); |
| | | } |
| | | |
| | | @Override |
| | | public String selectNicknameById(Long userId) { |
| | | return userService.selectNicknameById(userId); |
| | | } |
| | | |
| | | /** |
| | | * 构建登录用户 |
| | | */ |
| | | private LoginUser buildLoginUser(SysUserVo userVo) { |
| | | LoginUser loginUser = new LoginUser(); |
| | | loginUser.setTenantId(userVo.getTenantId()); |
| | | loginUser.setUserId(userVo.getUserId()); |
| | | loginUser.setDeptId(userVo.getDeptId()); |
| | | loginUser.setUsername(userVo.getUserName()); |
| | | loginUser.setNickname(userVo.getNickName()); |
| | | loginUser.setPassword(userVo.getPassword()); |
| | | loginUser.setUserType(userVo.getUserType()); |
| | | loginUser.setMenuPermission(permissionService.getMenuPermission(userVo.getUserId())); |
| | | loginUser.setRolePermission(permissionService.getRolePermission(userVo.getUserId())); |
| | | loginUser.setDeptName(ObjectUtil.isNull(userVo.getDept()) ? "" : userVo.getDept().getDeptName()); |
| | | List<RoleDTO> roles = BeanUtil.copyToList(userVo.getRoles(), RoleDTO.class); |
| | | loginUser.setRoles(roles); |
| | | return loginUser; |
| | | } |
| | | |
| | | /** |
| | | * 更新用户信息 |
| | | * |
| | | * @param userId 用户ID |
| | | * @param ip IP地址 |
| | | */ |
| | | @Override |
| | | public void recordLoginInfo(Long userId, String ip) { |
| | | SysUser sysUser = new SysUser(); |
| | | sysUser.setUserId(userId); |
| | | sysUser.setLoginIp(ip); |
| | | sysUser.setLoginDate(DateUtils.getNowDate()); |
| | | sysUser.setUpdateBy(userId); |
| | | DataPermissionHelper.ignore(() -> userMapper.updateById(sysUser)); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.listener; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.crypto.digest.BCrypt; |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.SpringUtils; |
| | | import org.dromara.common.core.utils.ValidatorUtils; |
| | | import org.dromara.common.excel.core.ExcelListener; |
| | | import org.dromara.common.excel.core.ExcelResult; |
| | | import org.dromara.common.satoken.utils.LoginHelper; |
| | | import org.dromara.system.domain.bo.SysUserBo; |
| | | import org.dromara.system.domain.vo.SysUserImportVo; |
| | | import org.dromara.system.domain.vo.SysUserVo; |
| | | import org.dromara.system.service.ISysConfigService; |
| | | import org.dromara.system.service.ISysUserService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 系统用户自定义导入 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo> implements ExcelListener<SysUserImportVo> { |
| | | |
| | | private final ISysUserService userService; |
| | | |
| | | private final String password; |
| | | |
| | | private final Boolean isUpdateSupport; |
| | | |
| | | private final Long operUserId; |
| | | |
| | | private int successNum = 0; |
| | | private int failureNum = 0; |
| | | private final StringBuilder successMsg = new StringBuilder(); |
| | | private final StringBuilder failureMsg = new StringBuilder(); |
| | | |
| | | public SysUserImportListener(Boolean isUpdateSupport) { |
| | | String initPassword = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.user.initPassword"); |
| | | this.userService = SpringUtils.getBean(ISysUserService.class); |
| | | this.password = BCrypt.hashpw(initPassword); |
| | | this.isUpdateSupport = isUpdateSupport; |
| | | this.operUserId = LoginHelper.getUserId(); |
| | | } |
| | | |
| | | @Override |
| | | public void invoke(SysUserImportVo userVo, AnalysisContext context) { |
| | | SysUserVo sysUser = this.userService.selectUserByUserName(userVo.getUserName()); |
| | | try { |
| | | // 验证是否存在这个用户 |
| | | if (ObjectUtil.isNull(sysUser)) { |
| | | SysUserBo user = BeanUtil.toBean(userVo, SysUserBo.class); |
| | | ValidatorUtils.validate(user); |
| | | user.setPassword(password); |
| | | user.setCreateBy(operUserId); |
| | | userService.insertUser(user); |
| | | successNum++; |
| | | successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功"); |
| | | } else if (isUpdateSupport) { |
| | | Long userId = sysUser.getUserId(); |
| | | SysUserBo user = BeanUtil.toBean(userVo, SysUserBo.class); |
| | | user.setUserId(userId); |
| | | ValidatorUtils.validate(user); |
| | | userService.checkUserAllowed(user.getUserId()); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | user.setUpdateBy(operUserId); |
| | | userService.updateUser(user); |
| | | successNum++; |
| | | successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 更新成功"); |
| | | } else { |
| | | failureNum++; |
| | | failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(sysUser.getUserName()).append(" 已存在"); |
| | | } |
| | | } catch (Exception e) { |
| | | failureNum++; |
| | | String msg = "<br/>" + failureNum + "、账号 " + userVo.getUserName() + " 导入失败:"; |
| | | failureMsg.append(msg).append(e.getMessage()); |
| | | log.error(msg, e); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext context) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public ExcelResult<SysUserImportVo> getExcelResult() { |
| | | return new ExcelResult<SysUserImportVo>() { |
| | | |
| | | @Override |
| | | public String getAnalysis() { |
| | | if (failureNum > 0) { |
| | | failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); |
| | | throw new ServiceException(failureMsg.toString()); |
| | | } else { |
| | | successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); |
| | | } |
| | | return successMsg.toString(); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysUserImportVo> getList() { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getErrorList() { |
| | | return null; |
| | | } |
| | | }; |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysClient; |
| | | import org.dromara.system.domain.vo.SysClientVo; |
| | | |
| | | /** |
| | | * 授权管理Mapper接口 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | public interface SysClientMapper extends BaseMapperPlus<SysClient, SysClientVo> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysConfig; |
| | | import org.dromara.system.domain.vo.SysConfigVo; |
| | | |
| | | /** |
| | | * 参数配置 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysConfigMapper extends BaseMapperPlus<SysConfig, SysConfigVo> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import org.dromara.common.mybatis.annotation.DataColumn; |
| | | import org.dromara.common.mybatis.annotation.DataPermission; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysDept; |
| | | import org.dromara.system.domain.vo.SysDeptVo; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 部门管理 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> { |
| | | |
| | | /** |
| | | * 查询部门管理数据 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | * @return 部门信息集合 |
| | | */ |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "dept_id") |
| | | }) |
| | | List<SysDeptVo> selectDeptList(@Param(Constants.WRAPPER) Wrapper<SysDept> queryWrapper); |
| | | |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "dept_id") |
| | | }) |
| | | SysDeptVo selectDeptById(Long deptId); |
| | | |
| | | /** |
| | | * 根据角色ID查询部门树信息 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param deptCheckStrictly 部门树选择项是否关联显示 |
| | | * @return 选中部门列表 |
| | | */ |
| | | List<Long> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysDictData; |
| | | import org.dromara.system.domain.vo.SysDictDataVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典表 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysDictDataMapper extends BaseMapperPlus<SysDictData, SysDictDataVo> { |
| | | |
| | | default List<SysDictDataVo> selectDictDataByType(String dictType) { |
| | | return selectVoList( |
| | | new LambdaQueryWrapper<SysDictData>() |
| | | .eq(SysDictData::getDictType, dictType) |
| | | .orderByAsc(SysDictData::getDictSort)); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.system.domain.SysDictType; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.vo.SysDictTypeVo; |
| | | |
| | | /** |
| | | * 字典表 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysDictTypeMapper extends BaseMapperPlus<SysDictType, SysDictTypeVo> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysLogininfor; |
| | | import org.dromara.system.domain.vo.SysLogininforVo; |
| | | |
| | | /** |
| | | * 系统访问日志情况信息 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysLogininforMapper extends BaseMapperPlus<SysLogininfor, SysLogininforVo> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.system.domain.SysMenu; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.vo.SysMenuVo; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 菜单表 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysMenuMapper extends BaseMapperPlus<SysMenu, SysMenuVo> { |
| | | |
| | | /** |
| | | * 根据用户所有权限 |
| | | * |
| | | * @return 权限列表 |
| | | */ |
| | | List<String> selectMenuPerms(); |
| | | |
| | | /** |
| | | * 根据用户查询系统菜单列表 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | * @return 菜单列表 |
| | | */ |
| | | List<SysMenu> selectMenuListByUserId(@Param(Constants.WRAPPER) Wrapper<SysMenu> queryWrapper); |
| | | |
| | | /** |
| | | * 根据用户ID查询权限 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 权限列表 |
| | | */ |
| | | List<String> selectMenuPermsByUserId(Long userId); |
| | | |
| | | /** |
| | | * 根据角色ID查询权限 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 权限列表 |
| | | */ |
| | | List<String> selectMenuPermsByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * 根据用户ID查询菜单 |
| | | * |
| | | * @return 菜单列表 |
| | | */ |
| | | default List<SysMenu> selectMenuTreeAll() { |
| | | LambdaQueryWrapper<SysMenu> lqw = new LambdaQueryWrapper<SysMenu>() |
| | | .in(SysMenu::getMenuType, UserConstants.TYPE_DIR, UserConstants.TYPE_MENU) |
| | | .eq(SysMenu::getStatus, UserConstants.MENU_NORMAL) |
| | | .orderByAsc(SysMenu::getParentId) |
| | | .orderByAsc(SysMenu::getOrderNum); |
| | | return this.selectList(lqw); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户ID查询菜单 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 菜单列表 |
| | | */ |
| | | List<SysMenu> selectMenuTreeByUserId(Long userId); |
| | | |
| | | /** |
| | | * 根据角色ID查询菜单树信息 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param menuCheckStrictly 菜单树选择项是否关联显示 |
| | | * @return 选中菜单列表 |
| | | */ |
| | | List<Long> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysNotice; |
| | | import org.dromara.system.domain.vo.SysNoticeVo; |
| | | |
| | | /** |
| | | * 通知公告表 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysNoticeMapper extends BaseMapperPlus<SysNotice, SysNoticeVo> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysOperLog; |
| | | import org.dromara.system.domain.vo.SysOperLogVo; |
| | | |
| | | /** |
| | | * 操作日志 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysOperLogMapper extends BaseMapperPlus<SysOperLog, SysOperLogVo> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysPost; |
| | | import org.dromara.system.domain.vo.SysPostVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 岗位信息 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysPostMapper extends BaseMapperPlus<SysPost, SysPostVo> { |
| | | |
| | | /** |
| | | * 根据用户ID获取岗位选择框列表 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 选中岗位ID列表 |
| | | */ |
| | | List<Long> selectPostListByUserId(Long userId); |
| | | |
| | | /** |
| | | * 查询用户所属岗位组 |
| | | * |
| | | * @param userName 用户名 |
| | | * @return 结果 |
| | | */ |
| | | List<SysPostVo> selectPostsByUserName(String userName); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysRoleDept; |
| | | |
| | | /** |
| | | * 角色与部门关联表 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysRoleDeptMapper extends BaseMapperPlus<SysRoleDept, SysRoleDept> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.dromara.common.mybatis.annotation.DataColumn; |
| | | import org.dromara.common.mybatis.annotation.DataPermission; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysRole; |
| | | import org.dromara.system.domain.vo.SysRoleVo; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色表 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysRoleMapper extends BaseMapperPlus<SysRole, SysRoleVo> { |
| | | |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id"), |
| | | @DataColumn(key = "userName", value = "r.create_by") |
| | | }) |
| | | Page<SysRoleVo> selectPageRoleList(@Param("page") Page<SysRole> page, @Param(Constants.WRAPPER) Wrapper<SysRole> queryWrapper); |
| | | |
| | | /** |
| | | * 根据条件分页查询角色数据 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | * @return 角色数据集合信息 |
| | | */ |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id"), |
| | | @DataColumn(key = "userName", value = "r.create_by") |
| | | }) |
| | | List<SysRoleVo> selectRoleList(@Param(Constants.WRAPPER) Wrapper<SysRole> queryWrapper); |
| | | |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id"), |
| | | @DataColumn(key = "userName", value = "r.create_by") |
| | | }) |
| | | SysRoleVo selectRoleById(Long roleId); |
| | | |
| | | /** |
| | | * 根据用户ID查询角色 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 角色列表 |
| | | */ |
| | | List<SysRoleVo> selectRolePermissionByUserId(Long userId); |
| | | |
| | | |
| | | /** |
| | | * 根据用户ID获取角色选择框列表 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 选中角色ID列表 |
| | | */ |
| | | List<Long> selectRoleListByUserId(Long userId); |
| | | |
| | | /** |
| | | * 根据用户ID查询角色 |
| | | * |
| | | * @param userName 用户名 |
| | | * @return 角色列表 |
| | | */ |
| | | List<SysRoleVo> selectRolesByUserName(String userName); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysRoleMenu; |
| | | |
| | | /** |
| | | * 角色与菜单关联表 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysRoleMenuMapper extends BaseMapperPlus<SysRoleMenu, SysRoleMenu> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysSocial; |
| | | import org.dromara.system.domain.vo.SysSocialVo; |
| | | |
| | | /** |
| | | * 社会化关系Mapper接口 |
| | | * |
| | | * @author thiszhc |
| | | */ |
| | | public interface SysSocialMapper extends BaseMapperPlus<SysSocial, SysSocialVo> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.system.domain.SysTenant; |
| | | import org.dromara.system.domain.vo.SysTenantVo; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | |
| | | /** |
| | | * 租户Mapper接口 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | public interface SysTenantMapper extends BaseMapperPlus<SysTenant, SysTenantVo> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysTenantPackage; |
| | | import org.dromara.system.domain.vo.SysTenantPackageVo; |
| | | |
| | | /** |
| | | * 租户套餐Mapper接口 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | public interface SysTenantPackageMapper extends BaseMapperPlus<SysTenantPackage, SysTenantPackageVo> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.dromara.common.mybatis.annotation.DataColumn; |
| | | import org.dromara.common.mybatis.annotation.DataPermission; |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysUser; |
| | | import org.dromara.system.domain.vo.SysUserVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户表 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> { |
| | | |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id"), |
| | | @DataColumn(key = "userName", value = "u.user_id") |
| | | }) |
| | | Page<SysUserVo> selectPageUserList(@Param("page") Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper); |
| | | |
| | | /** |
| | | * 根据条件分页查询用户列表 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | * @return 用户信息集合信息 |
| | | */ |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id"), |
| | | @DataColumn(key = "userName", value = "u.user_id") |
| | | }) |
| | | List<SysUserVo> selectUserList(@Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper); |
| | | |
| | | /** |
| | | * 根据条件分页查询已配用户角色列表 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | * @return 用户信息集合信息 |
| | | */ |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id"), |
| | | @DataColumn(key = "userName", value = "u.user_id") |
| | | }) |
| | | Page<SysUserVo> selectAllocatedList(@Param("page") Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper); |
| | | |
| | | /** |
| | | * 根据条件分页查询未分配用户角色列表 |
| | | * |
| | | * @param queryWrapper 查询条件 |
| | | * @return 用户信息集合信息 |
| | | */ |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id"), |
| | | @DataColumn(key = "userName", value = "u.user_id") |
| | | }) |
| | | Page<SysUserVo> selectUnallocatedList(@Param("page") Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper); |
| | | |
| | | /** |
| | | * 通过用户名查询用户 |
| | | * |
| | | * @param userName 用户名 |
| | | * @return 用户对象信息 |
| | | */ |
| | | SysUserVo selectUserByUserName(String userName); |
| | | |
| | | /** |
| | | * 通过手机号查询用户 |
| | | * |
| | | * @param phonenumber 手机号 |
| | | * @return 用户对象信息 |
| | | */ |
| | | SysUserVo selectUserByPhonenumber(String phonenumber); |
| | | |
| | | /** |
| | | * 通过邮箱查询用户 |
| | | * |
| | | * @param email 邮箱 |
| | | * @return 用户对象信息 |
| | | */ |
| | | SysUserVo selectUserByEmail(String email); |
| | | |
| | | /** |
| | | * 通过用户ID查询用户 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 用户对象信息 |
| | | */ |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "d.dept_id"), |
| | | @DataColumn(key = "userName", value = "u.user_id") |
| | | }) |
| | | SysUserVo selectUserById(Long userId); |
| | | |
| | | @Override |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "dept_id"), |
| | | @DataColumn(key = "userName", value = "user_id") |
| | | }) |
| | | int update(@Param(Constants.ENTITY) SysUser user, @Param(Constants.WRAPPER) Wrapper<SysUser> updateWrapper); |
| | | |
| | | @Override |
| | | @DataPermission({ |
| | | @DataColumn(key = "deptName", value = "dept_id"), |
| | | @DataColumn(key = "userName", value = "user_id") |
| | | }) |
| | | int updateById(@Param(Constants.ENTITY) SysUser user); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysUserPost; |
| | | |
| | | /** |
| | | * 用户与岗位关联表 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysUserPostMapper extends BaseMapperPlus<SysUserPost, SysUserPost> { |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.mapper; |
| | | |
| | | import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
| | | import org.dromara.system.domain.SysUserRole; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户与角色关联表 数据层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRole, SysUserRole> { |
| | | |
| | | List<Long> selectUserIdsByRoleId(Long roleId); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysClientBo; |
| | | import org.dromara.system.domain.vo.SysClientVo; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 客户端管理Service接口 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | public interface ISysClientService { |
| | | |
| | | /** |
| | | * 查询客户端管理 |
| | | */ |
| | | SysClientVo queryById(Long id); |
| | | |
| | | /** |
| | | * 查询客户端信息基于客户端id |
| | | */ |
| | | SysClientVo queryByClientId(String clientId); |
| | | |
| | | /** |
| | | * 查询客户端管理列表 |
| | | */ |
| | | TableDataInfo<SysClientVo> queryPageList(SysClientBo bo, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 查询客户端管理列表 |
| | | */ |
| | | List<SysClientVo> queryList(SysClientBo bo); |
| | | |
| | | /** |
| | | * 新增客户端管理 |
| | | */ |
| | | Boolean insertByBo(SysClientBo bo); |
| | | |
| | | /** |
| | | * 修改客户端管理 |
| | | */ |
| | | Boolean updateByBo(SysClientBo bo); |
| | | |
| | | /** |
| | | * 修改状态 |
| | | */ |
| | | int updateUserStatus(Long id, String status); |
| | | |
| | | /** |
| | | * 校验并批量删除客户端管理信息 |
| | | */ |
| | | Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysConfigBo; |
| | | import org.dromara.system.domain.vo.SysConfigVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 参数配置 服务层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysConfigService { |
| | | |
| | | |
| | | TableDataInfo<SysConfigVo> selectPageConfigList(SysConfigBo config, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 查询参数配置信息 |
| | | * |
| | | * @param configId 参数配置ID |
| | | * @return 参数配置信息 |
| | | */ |
| | | SysConfigVo selectConfigById(Long configId); |
| | | |
| | | /** |
| | | * 根据键名查询参数配置信息 |
| | | * |
| | | * @param configKey 参数键名 |
| | | * @return 参数键值 |
| | | */ |
| | | String selectConfigByKey(String configKey); |
| | | |
| | | /** |
| | | * 获取注册开关 |
| | | * @param tenantId 租户id |
| | | * @return true开启,false关闭 |
| | | */ |
| | | boolean selectRegisterEnabled(String tenantId); |
| | | |
| | | /** |
| | | * 查询参数配置列表 |
| | | * |
| | | * @param config 参数配置信息 |
| | | * @return 参数配置集合 |
| | | */ |
| | | List<SysConfigVo> selectConfigList(SysConfigBo config); |
| | | |
| | | /** |
| | | * 新增参数配置 |
| | | * |
| | | * @param bo 参数配置信息 |
| | | * @return 结果 |
| | | */ |
| | | String insertConfig(SysConfigBo bo); |
| | | |
| | | /** |
| | | * 修改参数配置 |
| | | * |
| | | * @param bo 参数配置信息 |
| | | * @return 结果 |
| | | */ |
| | | String updateConfig(SysConfigBo bo); |
| | | |
| | | /** |
| | | * 批量删除参数信息 |
| | | * |
| | | * @param configIds 需要删除的参数ID |
| | | */ |
| | | void deleteConfigByIds(Long[] configIds); |
| | | |
| | | /** |
| | | * 重置参数缓存数据 |
| | | */ |
| | | void resetConfigCache(); |
| | | |
| | | /** |
| | | * 校验参数键名是否唯一 |
| | | * |
| | | * @param config 参数信息 |
| | | * @return 结果 |
| | | */ |
| | | boolean checkConfigKeyUnique(SysConfigBo config); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import org.dromara.system.domain.bo.SysDeptBo; |
| | | import org.dromara.system.domain.vo.SysDeptVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 部门管理 服务层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysDeptService { |
| | | /** |
| | | * 查询部门管理数据 |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 部门信息集合 |
| | | */ |
| | | List<SysDeptVo> selectDeptList(SysDeptBo dept); |
| | | |
| | | /** |
| | | * 查询部门树结构信息 |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 部门树信息集合 |
| | | */ |
| | | List<Tree<Long>> selectDeptTreeList(SysDeptBo dept); |
| | | |
| | | /** |
| | | * 构建前端所需要下拉树结构 |
| | | * |
| | | * @param depts 部门列表 |
| | | * @return 下拉树结构列表 |
| | | */ |
| | | List<Tree<Long>> buildDeptTreeSelect(List<SysDeptVo> depts); |
| | | |
| | | /** |
| | | * 根据角色ID查询部门树信息 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 选中部门列表 |
| | | */ |
| | | List<Long> selectDeptListByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * 根据部门ID查询信息 |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 部门信息 |
| | | */ |
| | | SysDeptVo selectDeptById(Long deptId); |
| | | |
| | | /** |
| | | * 通过部门ID查询部门名称 |
| | | * |
| | | * @param deptIds 部门ID串逗号分隔 |
| | | * @return 部门名称串逗号分隔 |
| | | */ |
| | | String selectDeptNameByIds(String deptIds); |
| | | |
| | | /** |
| | | * 根据ID查询所有子部门数(正常状态) |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 子部门数 |
| | | */ |
| | | long selectNormalChildrenDeptById(Long deptId); |
| | | |
| | | /** |
| | | * 是否存在部门子节点 |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | | boolean hasChildByDeptId(Long deptId); |
| | | |
| | | /** |
| | | * 查询部门是否存在用户 |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 true 存在 false 不存在 |
| | | */ |
| | | boolean checkDeptExistUser(Long deptId); |
| | | |
| | | /** |
| | | * 校验部门名称是否唯一 |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 结果 |
| | | */ |
| | | boolean checkDeptNameUnique(SysDeptBo dept); |
| | | |
| | | /** |
| | | * 校验部门是否有数据权限 |
| | | * |
| | | * @param deptId 部门id |
| | | */ |
| | | void checkDeptDataScope(Long deptId); |
| | | |
| | | /** |
| | | * 新增保存部门信息 |
| | | * |
| | | * @param bo 部门信息 |
| | | * @return 结果 |
| | | */ |
| | | int insertDept(SysDeptBo bo); |
| | | |
| | | /** |
| | | * 修改保存部门信息 |
| | | * |
| | | * @param bo 部门信息 |
| | | * @return 结果 |
| | | */ |
| | | int updateDept(SysDeptBo bo); |
| | | |
| | | /** |
| | | * 删除部门管理信息 |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | | int deleteDeptById(Long deptId); |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysDictDataBo; |
| | | import org.dromara.system.domain.vo.SysDictDataVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典 业务层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysDictDataService { |
| | | |
| | | |
| | | TableDataInfo<SysDictDataVo> selectPageDictDataList(SysDictDataBo dictData, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 根据条件分页查询字典数据 |
| | | * |
| | | * @param dictData 字典数据信息 |
| | | * @return 字典数据集合信息 |
| | | */ |
| | | List<SysDictDataVo> selectDictDataList(SysDictDataBo dictData); |
| | | |
| | | /** |
| | | * 根据字典类型和字典键值查询字典数据信息 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @param dictValue 字典键值 |
| | | * @return 字典标签 |
| | | */ |
| | | String selectDictLabel(String dictType, String dictValue); |
| | | |
| | | /** |
| | | * 根据字典数据ID查询信息 |
| | | * |
| | | * @param dictCode 字典数据ID |
| | | * @return 字典数据 |
| | | */ |
| | | SysDictDataVo selectDictDataById(Long dictCode); |
| | | |
| | | /** |
| | | * 批量删除字典数据信息 |
| | | * |
| | | * @param dictCodes 需要删除的字典数据ID |
| | | */ |
| | | void deleteDictDataByIds(Long[] dictCodes); |
| | | |
| | | /** |
| | | * 新增保存字典数据信息 |
| | | * |
| | | * @param bo 字典数据信息 |
| | | * @return 结果 |
| | | */ |
| | | List<SysDictDataVo> insertDictData(SysDictDataBo bo); |
| | | |
| | | /** |
| | | * 修改保存字典数据信息 |
| | | * |
| | | * @param bo 字典数据信息 |
| | | * @return 结果 |
| | | */ |
| | | List<SysDictDataVo> updateDictData(SysDictDataBo bo); |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysDictTypeBo; |
| | | import org.dromara.system.domain.vo.SysDictDataVo; |
| | | import org.dromara.system.domain.vo.SysDictTypeVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典 业务层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysDictTypeService { |
| | | |
| | | |
| | | TableDataInfo<SysDictTypeVo> selectPageDictTypeList(SysDictTypeBo dictType, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 根据条件分页查询字典类型 |
| | | * |
| | | * @param dictType 字典类型信息 |
| | | * @return 字典类型集合信息 |
| | | */ |
| | | List<SysDictTypeVo> selectDictTypeList(SysDictTypeBo dictType); |
| | | |
| | | /** |
| | | * 根据所有字典类型 |
| | | * |
| | | * @return 字典类型集合信息 |
| | | */ |
| | | List<SysDictTypeVo> selectDictTypeAll(); |
| | | |
| | | /** |
| | | * 根据字典类型查询字典数据 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 字典数据集合信息 |
| | | */ |
| | | List<SysDictDataVo> selectDictDataByType(String dictType); |
| | | |
| | | /** |
| | | * 根据字典类型ID查询信息 |
| | | * |
| | | * @param dictId 字典类型ID |
| | | * @return 字典类型 |
| | | */ |
| | | SysDictTypeVo selectDictTypeById(Long dictId); |
| | | |
| | | /** |
| | | * 根据字典类型查询信息 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 字典类型 |
| | | */ |
| | | SysDictTypeVo selectDictTypeByType(String dictType); |
| | | |
| | | /** |
| | | * 批量删除字典信息 |
| | | * |
| | | * @param dictIds 需要删除的字典ID |
| | | */ |
| | | void deleteDictTypeByIds(Long[] dictIds); |
| | | |
| | | /** |
| | | * 重置字典缓存数据 |
| | | */ |
| | | void resetDictCache(); |
| | | |
| | | /** |
| | | * 新增保存字典类型信息 |
| | | * |
| | | * @param bo 字典类型信息 |
| | | * @return 结果 |
| | | */ |
| | | List<SysDictDataVo> insertDictType(SysDictTypeBo bo); |
| | | |
| | | /** |
| | | * 修改保存字典类型信息 |
| | | * |
| | | * @param bo 字典类型信息 |
| | | * @return 结果 |
| | | */ |
| | | List<SysDictDataVo> updateDictType(SysDictTypeBo bo); |
| | | |
| | | /** |
| | | * 校验字典类型称是否唯一 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 结果 |
| | | */ |
| | | boolean checkDictTypeUnique(SysDictTypeBo dictType); |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysLogininforBo; |
| | | import org.dromara.system.domain.vo.SysLogininforVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 系统访问日志情况信息 服务层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysLogininforService { |
| | | |
| | | |
| | | TableDataInfo<SysLogininforVo> selectPageLogininforList(SysLogininforBo logininfor, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 新增系统登录日志 |
| | | * |
| | | * @param bo 访问日志对象 |
| | | */ |
| | | void insertLogininfor(SysLogininforBo bo); |
| | | |
| | | /** |
| | | * 查询系统登录日志集合 |
| | | * |
| | | * @param logininfor 访问日志对象 |
| | | * @return 登录记录集合 |
| | | */ |
| | | List<SysLogininforVo> selectLogininforList(SysLogininforBo logininfor); |
| | | |
| | | /** |
| | | * 批量删除系统登录日志 |
| | | * |
| | | * @param infoIds 需要删除的登录日志ID |
| | | * @return 结果 |
| | | */ |
| | | int deleteLogininforByIds(Long[] infoIds); |
| | | |
| | | /** |
| | | * 清空系统登录日志 |
| | | */ |
| | | void cleanLogininfor(); |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import org.dromara.system.domain.SysMenu; |
| | | import org.dromara.system.domain.bo.SysMenuBo; |
| | | import org.dromara.system.domain.vo.RouterVo; |
| | | import org.dromara.system.domain.vo.SysMenuVo; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * 菜单 业务层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysMenuService { |
| | | |
| | | /** |
| | | * 根据用户查询系统菜单列表 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 菜单列表 |
| | | */ |
| | | List<SysMenuVo> selectMenuList(Long userId); |
| | | |
| | | /** |
| | | * 根据用户查询系统菜单列表 |
| | | * |
| | | * @param menu 菜单信息 |
| | | * @param userId 用户ID |
| | | * @return 菜单列表 |
| | | */ |
| | | List<SysMenuVo> selectMenuList(SysMenuBo menu, Long userId); |
| | | |
| | | /** |
| | | * 根据用户ID查询权限 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 权限列表 |
| | | */ |
| | | Set<String> selectMenuPermsByUserId(Long userId); |
| | | |
| | | /** |
| | | * 根据角色ID查询权限 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 权限列表 |
| | | */ |
| | | Set<String> selectMenuPermsByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * 根据用户ID查询菜单树信息 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 菜单列表 |
| | | */ |
| | | List<SysMenu> selectMenuTreeByUserId(Long userId); |
| | | |
| | | /** |
| | | * 根据角色ID查询菜单树信息 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 选中菜单列表 |
| | | */ |
| | | List<Long> selectMenuListByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * 根据租户套餐ID查询菜单树信息 |
| | | * |
| | | * @param packageId 租户套餐ID |
| | | * @return 选中菜单列表 |
| | | */ |
| | | List<Long> selectMenuListByPackageId(Long packageId); |
| | | |
| | | /** |
| | | * 构建前端路由所需要的菜单 |
| | | * |
| | | * @param menus 菜单列表 |
| | | * @return 路由列表 |
| | | */ |
| | | List<RouterVo> buildMenus(List<SysMenu> menus); |
| | | |
| | | /** |
| | | * 构建前端所需要下拉树结构 |
| | | * |
| | | * @param menus 菜单列表 |
| | | * @return 下拉树结构列表 |
| | | */ |
| | | List<Tree<Long>> buildMenuTreeSelect(List<SysMenuVo> menus); |
| | | |
| | | /** |
| | | * 根据菜单ID查询信息 |
| | | * |
| | | * @param menuId 菜单ID |
| | | * @return 菜单信息 |
| | | */ |
| | | SysMenuVo selectMenuById(Long menuId); |
| | | |
| | | /** |
| | | * 是否存在菜单子节点 |
| | | * |
| | | * @param menuId 菜单ID |
| | | * @return 结果 true 存在 false 不存在 |
| | | */ |
| | | boolean hasChildByMenuId(Long menuId); |
| | | |
| | | /** |
| | | * 查询菜单是否存在角色 |
| | | * |
| | | * @param menuId 菜单ID |
| | | * @return 结果 true 存在 false 不存在 |
| | | */ |
| | | boolean checkMenuExistRole(Long menuId); |
| | | |
| | | /** |
| | | * 新增保存菜单信息 |
| | | * |
| | | * @param bo 菜单信息 |
| | | * @return 结果 |
| | | */ |
| | | int insertMenu(SysMenuBo bo); |
| | | |
| | | /** |
| | | * 修改保存菜单信息 |
| | | * |
| | | * @param bo 菜单信息 |
| | | * @return 结果 |
| | | */ |
| | | int updateMenu(SysMenuBo bo); |
| | | |
| | | /** |
| | | * 删除菜单管理信息 |
| | | * |
| | | * @param menuId 菜单ID |
| | | * @return 结果 |
| | | */ |
| | | int deleteMenuById(Long menuId); |
| | | |
| | | /** |
| | | * 校验菜单名称是否唯一 |
| | | * |
| | | * @param menu 菜单信息 |
| | | * @return 结果 |
| | | */ |
| | | boolean checkMenuNameUnique(SysMenuBo menu); |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysNoticeBo; |
| | | import org.dromara.system.domain.vo.SysNoticeVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 公告 服务层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysNoticeService { |
| | | |
| | | |
| | | TableDataInfo<SysNoticeVo> selectPageNoticeList(SysNoticeBo notice, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 查询公告信息 |
| | | * |
| | | * @param noticeId 公告ID |
| | | * @return 公告信息 |
| | | */ |
| | | SysNoticeVo selectNoticeById(Long noticeId); |
| | | |
| | | /** |
| | | * 查询公告列表 |
| | | * |
| | | * @param notice 公告信息 |
| | | * @return 公告集合 |
| | | */ |
| | | List<SysNoticeVo> selectNoticeList(SysNoticeBo notice); |
| | | |
| | | /** |
| | | * 新增公告 |
| | | * |
| | | * @param bo 公告信息 |
| | | * @return 结果 |
| | | */ |
| | | int insertNotice(SysNoticeBo bo); |
| | | |
| | | /** |
| | | * 修改公告 |
| | | * |
| | | * @param bo 公告信息 |
| | | * @return 结果 |
| | | */ |
| | | int updateNotice(SysNoticeBo bo); |
| | | |
| | | /** |
| | | * 删除公告信息 |
| | | * |
| | | * @param noticeId 公告ID |
| | | * @return 结果 |
| | | */ |
| | | int deleteNoticeById(Long noticeId); |
| | | |
| | | /** |
| | | * 批量删除公告信息 |
| | | * |
| | | * @param noticeIds 需要删除的公告ID |
| | | * @return 结果 |
| | | */ |
| | | int deleteNoticeByIds(Long[] noticeIds); |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysOperLogBo; |
| | | import org.dromara.system.domain.vo.SysOperLogVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 操作日志 服务层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysOperLogService { |
| | | |
| | | TableDataInfo<SysOperLogVo> selectPageOperLogList(SysOperLogBo operLog, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 新增操作日志 |
| | | * |
| | | * @param bo 操作日志对象 |
| | | */ |
| | | void insertOperlog(SysOperLogBo bo); |
| | | |
| | | /** |
| | | * 查询系统操作日志集合 |
| | | * |
| | | * @param operLog 操作日志对象 |
| | | * @return 操作日志集合 |
| | | */ |
| | | List<SysOperLogVo> selectOperLogList(SysOperLogBo operLog); |
| | | |
| | | /** |
| | | * 批量删除系统操作日志 |
| | | * |
| | | * @param operIds 需要删除的操作日志ID |
| | | * @return 结果 |
| | | */ |
| | | int deleteOperLogByIds(Long[] operIds); |
| | | |
| | | /** |
| | | * 查询操作日志详细 |
| | | * |
| | | * @param operId 操作ID |
| | | * @return 操作日志对象 |
| | | */ |
| | | SysOperLogVo selectOperLogById(Long operId); |
| | | |
| | | /** |
| | | * 清空操作日志 |
| | | */ |
| | | void cleanOperLog(); |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * 用户权限处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysPermissionService { |
| | | |
| | | /** |
| | | * 获取角色数据权限 |
| | | * |
| | | * @param userId 用户id |
| | | * @return 角色权限信息 |
| | | */ |
| | | Set<String> getRolePermission(Long userId); |
| | | |
| | | /** |
| | | * 获取菜单数据权限 |
| | | * |
| | | * @param userId 用户id |
| | | * @return 菜单权限信息 |
| | | */ |
| | | Set<String> getMenuPermission(Long userId); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysPostBo; |
| | | import org.dromara.system.domain.vo.SysPostVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 岗位信息 服务层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysPostService { |
| | | |
| | | |
| | | TableDataInfo<SysPostVo> selectPagePostList(SysPostBo post, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 查询岗位信息集合 |
| | | * |
| | | * @param post 岗位信息 |
| | | * @return 岗位列表 |
| | | */ |
| | | List<SysPostVo> selectPostList(SysPostBo post); |
| | | |
| | | /** |
| | | * 查询所有岗位 |
| | | * |
| | | * @return 岗位列表 |
| | | */ |
| | | List<SysPostVo> selectPostAll(); |
| | | |
| | | /** |
| | | * 通过岗位ID查询岗位信息 |
| | | * |
| | | * @param postId 岗位ID |
| | | * @return 角色对象信息 |
| | | */ |
| | | SysPostVo selectPostById(Long postId); |
| | | |
| | | /** |
| | | * 根据用户ID获取岗位选择框列表 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 选中岗位ID列表 |
| | | */ |
| | | List<Long> selectPostListByUserId(Long userId); |
| | | |
| | | /** |
| | | * 校验岗位名称 |
| | | * |
| | | * @param post 岗位信息 |
| | | * @return 结果 |
| | | */ |
| | | boolean checkPostNameUnique(SysPostBo post); |
| | | |
| | | /** |
| | | * 校验岗位编码 |
| | | * |
| | | * @param post 岗位信息 |
| | | * @return 结果 |
| | | */ |
| | | boolean checkPostCodeUnique(SysPostBo post); |
| | | |
| | | /** |
| | | * 通过岗位ID查询岗位使用数量 |
| | | * |
| | | * @param postId 岗位ID |
| | | * @return 结果 |
| | | */ |
| | | long countUserPostById(Long postId); |
| | | |
| | | /** |
| | | * 删除岗位信息 |
| | | * |
| | | * @param postId 岗位ID |
| | | * @return 结果 |
| | | */ |
| | | int deletePostById(Long postId); |
| | | |
| | | /** |
| | | * 批量删除岗位信息 |
| | | * |
| | | * @param postIds 需要删除的岗位ID |
| | | * @return 结果 |
| | | */ |
| | | int deletePostByIds(Long[] postIds); |
| | | |
| | | /** |
| | | * 新增保存岗位信息 |
| | | * |
| | | * @param bo 岗位信息 |
| | | * @return 结果 |
| | | */ |
| | | int insertPost(SysPostBo bo); |
| | | |
| | | /** |
| | | * 修改保存岗位信息 |
| | | * |
| | | * @param bo 岗位信息 |
| | | * @return 结果 |
| | | */ |
| | | int updatePost(SysPostBo bo); |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.SysUserRole; |
| | | import org.dromara.system.domain.bo.SysRoleBo; |
| | | import org.dromara.system.domain.vo.SysRoleVo; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * 角色业务层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysRoleService { |
| | | |
| | | |
| | | TableDataInfo<SysRoleVo> selectPageRoleList(SysRoleBo role, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 根据条件分页查询角色数据 |
| | | * |
| | | * @param role 角色信息 |
| | | * @return 角色数据集合信息 |
| | | */ |
| | | List<SysRoleVo> selectRoleList(SysRoleBo role); |
| | | |
| | | /** |
| | | * 根据用户ID查询角色列表 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 角色列表 |
| | | */ |
| | | List<SysRoleVo> selectRolesByUserId(Long userId); |
| | | |
| | | /** |
| | | * 根据用户ID查询角色权限 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 权限列表 |
| | | */ |
| | | Set<String> selectRolePermissionByUserId(Long userId); |
| | | |
| | | /** |
| | | * 查询所有角色 |
| | | * |
| | | * @return 角色列表 |
| | | */ |
| | | List<SysRoleVo> selectRoleAll(); |
| | | |
| | | /** |
| | | * 根据用户ID获取角色选择框列表 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 选中角色ID列表 |
| | | */ |
| | | List<Long> selectRoleListByUserId(Long userId); |
| | | |
| | | /** |
| | | * 通过角色ID查询角色 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 角色对象信息 |
| | | */ |
| | | SysRoleVo selectRoleById(Long roleId); |
| | | |
| | | /** |
| | | * 校验角色名称是否唯一 |
| | | * |
| | | * @param role 角色信息 |
| | | * @return 结果 |
| | | */ |
| | | boolean checkRoleNameUnique(SysRoleBo role); |
| | | |
| | | /** |
| | | * 校验角色权限是否唯一 |
| | | * |
| | | * @param role 角色信息 |
| | | * @return 结果 |
| | | */ |
| | | boolean checkRoleKeyUnique(SysRoleBo role); |
| | | |
| | | /** |
| | | * 校验角色是否允许操作 |
| | | * |
| | | * @param role 角色信息 |
| | | */ |
| | | void checkRoleAllowed(SysRoleBo role); |
| | | |
| | | /** |
| | | * 校验角色是否有数据权限 |
| | | * |
| | | * @param roleId 角色id |
| | | */ |
| | | void checkRoleDataScope(Long roleId); |
| | | |
| | | /** |
| | | * 通过角色ID查询角色使用数量 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 结果 |
| | | */ |
| | | long countUserRoleByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * 新增保存角色信息 |
| | | * |
| | | * @param bo 角色信息 |
| | | * @return 结果 |
| | | */ |
| | | int insertRole(SysRoleBo bo); |
| | | |
| | | /** |
| | | * 修改保存角色信息 |
| | | * |
| | | * @param bo 角色信息 |
| | | * @return 结果 |
| | | */ |
| | | int updateRole(SysRoleBo bo); |
| | | |
| | | /** |
| | | * 修改角色状态 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param status 角色状态 |
| | | * @return 结果 |
| | | */ |
| | | int updateRoleStatus(Long roleId, String status); |
| | | |
| | | /** |
| | | * 修改数据权限信息 |
| | | * |
| | | * @param bo 角色信息 |
| | | * @return 结果 |
| | | */ |
| | | int authDataScope(SysRoleBo bo); |
| | | |
| | | /** |
| | | * 通过角色ID删除角色 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 结果 |
| | | */ |
| | | int deleteRoleById(Long roleId); |
| | | |
| | | /** |
| | | * 批量删除角色信息 |
| | | * |
| | | * @param roleIds 需要删除的角色ID |
| | | * @return 结果 |
| | | */ |
| | | int deleteRoleByIds(Long[] roleIds); |
| | | |
| | | /** |
| | | * 取消授权用户角色 |
| | | * |
| | | * @param userRole 用户和角色关联信息 |
| | | * @return 结果 |
| | | */ |
| | | int deleteAuthUser(SysUserRole userRole); |
| | | |
| | | /** |
| | | * 批量取消授权用户角色 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param userIds 需要取消授权的用户数据ID |
| | | * @return 结果 |
| | | */ |
| | | int deleteAuthUsers(Long roleId, Long[] userIds); |
| | | |
| | | /** |
| | | * 批量选择授权用户角色 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param userIds 需要删除的用户数据ID |
| | | * @return 结果 |
| | | */ |
| | | int insertAuthUsers(Long roleId, Long[] userIds); |
| | | |
| | | void cleanOnlineUserByRole(Long roleId); |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import org.dromara.system.domain.bo.SysSocialBo; |
| | | import org.dromara.system.domain.vo.SysSocialVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 社会化关系Service接口 |
| | | * |
| | | * @author thiszhc |
| | | */ |
| | | public interface ISysSocialService { |
| | | |
| | | |
| | | /** |
| | | * 查询社会化关系 |
| | | */ |
| | | SysSocialVo queryById(String id); |
| | | |
| | | /** |
| | | * 查询社会化关系列表 |
| | | */ |
| | | List<SysSocialVo> queryList(); |
| | | |
| | | /** |
| | | * 查询社会化关系列表 |
| | | */ |
| | | List<SysSocialVo> queryListByUserId(Long userId); |
| | | |
| | | /** |
| | | * 新增授权关系 |
| | | */ |
| | | Boolean insertByBo(SysSocialBo bo); |
| | | |
| | | /** |
| | | * 更新社会化关系 |
| | | */ |
| | | |
| | | Boolean updateByBo(SysSocialBo bo); |
| | | |
| | | /** |
| | | * 删除社会化关系信息 |
| | | */ |
| | | Boolean deleteWithValidById(Long id); |
| | | |
| | | |
| | | /** |
| | | * 根据 authId 查询 SysSocial 表和 SysUser 表,返回 SysSocialAuthResult 映射的对象 |
| | | * @param authId 认证ID |
| | | * @return SysSocial |
| | | */ |
| | | List<SysSocialVo> selectByAuthId(String authId); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import org.dromara.system.domain.vo.SysTenantPackageVo; |
| | | import org.dromara.system.domain.bo.SysTenantPackageBo; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 租户套餐Service接口 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | public interface ISysTenantPackageService { |
| | | |
| | | /** |
| | | * 查询租户套餐 |
| | | */ |
| | | SysTenantPackageVo queryById(Long packageId); |
| | | |
| | | /** |
| | | * 查询租户套餐列表 |
| | | */ |
| | | TableDataInfo<SysTenantPackageVo> queryPageList(SysTenantPackageBo bo, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 查询租户套餐已启用列表 |
| | | */ |
| | | List<SysTenantPackageVo> selectList(); |
| | | |
| | | /** |
| | | * 查询租户套餐列表 |
| | | */ |
| | | List<SysTenantPackageVo> queryList(SysTenantPackageBo bo); |
| | | |
| | | /** |
| | | * 新增租户套餐 |
| | | */ |
| | | Boolean insertByBo(SysTenantPackageBo bo); |
| | | |
| | | /** |
| | | * 修改租户套餐 |
| | | */ |
| | | Boolean updateByBo(SysTenantPackageBo bo); |
| | | |
| | | /** |
| | | * 修改套餐状态 |
| | | */ |
| | | int updatePackageStatus(SysTenantPackageBo bo); |
| | | |
| | | /** |
| | | * 校验并批量删除租户套餐信息 |
| | | */ |
| | | Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import org.dromara.system.domain.vo.SysTenantVo; |
| | | import org.dromara.system.domain.bo.SysTenantBo; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 租户Service接口 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | public interface ISysTenantService { |
| | | |
| | | /** |
| | | * 查询租户 |
| | | */ |
| | | SysTenantVo queryById(Long id); |
| | | |
| | | /** |
| | | * 基于租户ID查询租户 |
| | | */ |
| | | SysTenantVo queryByTenantId(String tenantId); |
| | | |
| | | /** |
| | | * 查询租户列表 |
| | | */ |
| | | TableDataInfo<SysTenantVo> queryPageList(SysTenantBo bo, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 查询租户列表 |
| | | */ |
| | | List<SysTenantVo> queryList(SysTenantBo bo); |
| | | |
| | | /** |
| | | * 新增租户 |
| | | */ |
| | | Boolean insertByBo(SysTenantBo bo); |
| | | |
| | | /** |
| | | * 修改租户 |
| | | */ |
| | | Boolean updateByBo(SysTenantBo bo); |
| | | |
| | | /** |
| | | * 修改租户状态 |
| | | */ |
| | | int updateTenantStatus(SysTenantBo bo); |
| | | |
| | | /** |
| | | * 校验租户是否允许操作 |
| | | */ |
| | | void checkTenantAllowed(String tenantId); |
| | | |
| | | /** |
| | | * 校验并批量删除租户信息 |
| | | */ |
| | | Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
| | | |
| | | /** |
| | | * 校验企业名称是否唯一 |
| | | */ |
| | | boolean checkCompanyNameUnique(SysTenantBo bo); |
| | | |
| | | /** |
| | | * 校验账号余额 |
| | | */ |
| | | boolean checkAccountBalance(String tenantId); |
| | | |
| | | /** |
| | | * 校验有效期 |
| | | */ |
| | | boolean checkExpireTime(String tenantId); |
| | | |
| | | /** |
| | | * 同步租户套餐 |
| | | */ |
| | | Boolean syncTenantPackage(String tenantId, Long packageId); |
| | | } |
New file |
| | |
| | | package org.dromara.system.service; |
| | | |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.bo.SysUserBo; |
| | | import org.dromara.system.domain.vo.SysUserVo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户 业务层 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | public interface ISysUserService { |
| | | |
| | | |
| | | TableDataInfo<SysUserVo> selectPageUserList(SysUserBo user, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 根据条件分页查询用户列表 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 用户信息集合信息 |
| | | */ |
| | | List<SysUserVo> selectUserList(SysUserBo user); |
| | | |
| | | /** |
| | | * 根据条件分页查询已分配用户角色列表 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 用户信息集合信息 |
| | | */ |
| | | TableDataInfo<SysUserVo> selectAllocatedList(SysUserBo user, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 根据条件分页查询未分配用户角色列表 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 用户信息集合信息 |
| | | */ |
| | | TableDataInfo<SysUserVo> selectUnallocatedList(SysUserBo user, PageQuery pageQuery); |
| | | |
| | | /** |
| | | * 通过用户名查询用户 |
| | | * |
| | | * @param userName 用户名 |
| | | * @return 用户对象信息 |
| | | */ |
| | | SysUserVo selectUserByUserName(String userName); |
| | | |
| | | /** |
| | | * 通过手机号查询用户 |
| | | * |
| | | * @param phonenumber 手机号 |
| | | * @return 用户对象信息 |
| | | */ |
| | | SysUserVo selectUserByPhonenumber(String phonenumber); |
| | | |
| | | /** |
| | | * 通过用户ID查询用户 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 用户对象信息 |
| | | */ |
| | | SysUserVo selectUserById(Long userId); |
| | | |
| | | /** |
| | | * 根据用户ID查询用户所属角色组 |
| | | * |
| | | * @param userName 用户名 |
| | | * @return 结果 |
| | | */ |
| | | String selectUserRoleGroup(String userName); |
| | | |
| | | /** |
| | | * 根据用户ID查询用户所属岗位组 |
| | | * |
| | | * @param userName 用户名 |
| | | * @return 结果 |
| | | */ |
| | | String selectUserPostGroup(String userName); |
| | | |
| | | /** |
| | | * 校验用户名称是否唯一 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 结果 |
| | | */ |
| | | boolean checkUserNameUnique(SysUserBo user); |
| | | |
| | | /** |
| | | * 校验手机号码是否唯一 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 结果 |
| | | */ |
| | | boolean checkPhoneUnique(SysUserBo user); |
| | | |
| | | /** |
| | | * 校验email是否唯一 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 结果 |
| | | */ |
| | | boolean checkEmailUnique(SysUserBo user); |
| | | |
| | | /** |
| | | * 校验用户是否允许操作 |
| | | * |
| | | * @param userId 用户ID |
| | | */ |
| | | void checkUserAllowed(Long userId); |
| | | |
| | | /** |
| | | * 校验用户是否有数据权限 |
| | | * |
| | | * @param userId 用户id |
| | | */ |
| | | void checkUserDataScope(Long userId); |
| | | |
| | | /** |
| | | * 新增用户信息 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 结果 |
| | | */ |
| | | int insertUser(SysUserBo user); |
| | | |
| | | /** |
| | | * 注册用户信息 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 结果 |
| | | */ |
| | | boolean registerUser(SysUserBo user, String tenantId); |
| | | |
| | | /** |
| | | * 修改用户信息 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 结果 |
| | | */ |
| | | int updateUser(SysUserBo user); |
| | | |
| | | /** |
| | | * 用户授权角色 |
| | | * |
| | | * @param userId 用户ID |
| | | * @param roleIds 角色组 |
| | | */ |
| | | void insertUserAuth(Long userId, Long[] roleIds); |
| | | |
| | | /** |
| | | * 修改用户状态 |
| | | * |
| | | * @param userId 用户ID |
| | | * @param status 帐号状态 |
| | | * @return 结果 |
| | | */ |
| | | int updateUserStatus(Long userId, String status); |
| | | |
| | | /** |
| | | * 修改用户基本信息 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 结果 |
| | | */ |
| | | int updateUserProfile(SysUserBo user); |
| | | |
| | | /** |
| | | * 修改用户头像 |
| | | * |
| | | * @param userId 用户ID |
| | | * @param avatar 头像地址 |
| | | * @return 结果 |
| | | */ |
| | | boolean updateUserAvatar(Long userId, Long avatar); |
| | | |
| | | /** |
| | | * 重置用户密码 |
| | | * |
| | | * @param userId 用户ID |
| | | * @param password 密码 |
| | | * @return 结果 |
| | | */ |
| | | int resetUserPwd(Long userId, String password); |
| | | |
| | | /** |
| | | * 通过用户ID删除用户 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 结果 |
| | | */ |
| | | int deleteUserById(Long userId); |
| | | |
| | | /** |
| | | * 批量删除用户信息 |
| | | * |
| | | * @param userIds 需要删除的用户ID |
| | | * @return 结果 |
| | | */ |
| | | int deleteUserByIds(Long[] userIds); |
| | | |
| | | /** |
| | | * 通过用户ID查询用户账户 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 用户账户 |
| | | */ |
| | | String selectUserNameById(Long userId); |
| | | |
| | | /** |
| | | * 通过用户ID查询用户账户 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 用户账户 |
| | | */ |
| | | String selectNicknameById(Long userId); |
| | | |
| | | /** |
| | | * 通过部门id查询当前部门所有用户 |
| | | * |
| | | * @param deptId |
| | | * @return |
| | | */ |
| | | List<SysUserVo> selectUserListByDept(Long deptId); |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.SysClient; |
| | | import org.dromara.system.domain.bo.SysClientBo; |
| | | import org.dromara.system.domain.vo.SysClientVo; |
| | | import org.dromara.system.mapper.SysClientMapper; |
| | | import org.dromara.system.service.ISysClientService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 客户端管理Service业务层处理 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysClientServiceImpl implements ISysClientService { |
| | | |
| | | private final SysClientMapper baseMapper; |
| | | |
| | | /** |
| | | * 查询客户端管理 |
| | | */ |
| | | @Override |
| | | public SysClientVo queryById(Long id) { |
| | | SysClientVo vo = baseMapper.selectVoById(id); |
| | | vo.setGrantTypeList(List.of(vo.getGrantType().split(","))); |
| | | return vo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询客户端管理 |
| | | */ |
| | | @Override |
| | | public SysClientVo queryByClientId(String clientId) { |
| | | return baseMapper.selectVoOne(new LambdaQueryWrapper<SysClient>().eq(SysClient::getClientId, clientId)); |
| | | } |
| | | |
| | | /** |
| | | * 查询客户端管理列表 |
| | | */ |
| | | @Override |
| | | public TableDataInfo<SysClientVo> queryPageList(SysClientBo bo, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysClient> lqw = buildQueryWrapper(bo); |
| | | Page<SysClientVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | result.getRecords().forEach(r -> r.setGrantTypeList(List.of(r.getGrantType().split(",")))); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | | /** |
| | | * 查询客户端管理列表 |
| | | */ |
| | | @Override |
| | | public List<SysClientVo> queryList(SysClientBo bo) { |
| | | LambdaQueryWrapper<SysClient> lqw = buildQueryWrapper(bo); |
| | | return baseMapper.selectVoList(lqw); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<SysClient> buildQueryWrapper(SysClientBo bo) { |
| | | LambdaQueryWrapper<SysClient> lqw = Wrappers.lambdaQuery(); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getClientId()), SysClient::getClientId, bo.getClientId()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getClientKey()), SysClient::getClientKey, bo.getClientKey()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getClientSecret()), SysClient::getClientSecret, bo.getClientSecret()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysClient::getStatus, bo.getStatus()); |
| | | lqw.orderByAsc(SysClient::getId); |
| | | return lqw; |
| | | } |
| | | |
| | | /** |
| | | * 新增客户端管理 |
| | | */ |
| | | @Override |
| | | public Boolean insertByBo(SysClientBo bo) { |
| | | SysClient add = MapstructUtils.convert(bo, SysClient.class); |
| | | validEntityBeforeSave(add); |
| | | add.setGrantType(String.join(",", bo.getGrantTypeList())); |
| | | // 生成clientid |
| | | String clientKey = bo.getClientKey(); |
| | | String clientSecret = bo.getClientSecret(); |
| | | add.setClientId(SecureUtil.md5(clientKey + clientSecret)); |
| | | boolean flag = baseMapper.insert(add) > 0; |
| | | if (flag) { |
| | | bo.setId(add.getId()); |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * 修改客户端管理 |
| | | */ |
| | | @Override |
| | | public Boolean updateByBo(SysClientBo bo) { |
| | | SysClient update = MapstructUtils.convert(bo, SysClient.class); |
| | | validEntityBeforeSave(update); |
| | | update.setGrantType(String.join(",", bo.getGrantTypeList())); |
| | | return baseMapper.updateById(update) > 0; |
| | | } |
| | | |
| | | /** |
| | | * 修改状态 |
| | | */ |
| | | @Override |
| | | public int updateUserStatus(Long id, String status) { |
| | | return baseMapper.update(null, |
| | | new LambdaUpdateWrapper<SysClient>() |
| | | .set(SysClient::getStatus, status) |
| | | .eq(SysClient::getId, id)); |
| | | } |
| | | |
| | | /** |
| | | * 保存前的数据校验 |
| | | */ |
| | | private void validEntityBeforeSave(SysClient entity) { |
| | | //TODO 做一些数据校验,如唯一约束 |
| | | } |
| | | |
| | | /** |
| | | * 批量删除客户端管理 |
| | | */ |
| | | @Override |
| | | public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
| | | if (isValid) { |
| | | //TODO 做一些业务上的校验,判断是否需要校验 |
| | | } |
| | | return baseMapper.deleteBatchIds(ids) > 0; |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.CacheNames; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.redis.utils.CacheUtils; |
| | | import org.dromara.common.tenant.helper.TenantHelper; |
| | | import org.dromara.system.domain.SysConfig; |
| | | import org.dromara.system.domain.bo.SysConfigBo; |
| | | import org.dromara.system.domain.vo.SysConfigVo; |
| | | import org.dromara.system.mapper.SysConfigMapper; |
| | | import org.dromara.system.service.ISysConfigService; |
| | | import org.springframework.cache.annotation.CachePut; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 参数配置 服务层实现 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysConfigServiceImpl implements ISysConfigService { |
| | | |
| | | private final SysConfigMapper baseMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysConfigVo> selectPageConfigList(SysConfigBo config, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysConfig> lqw = buildQueryWrapper(config); |
| | | Page<SysConfigVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | | * 查询参数配置信息 |
| | | * |
| | | * @param configId 参数配置ID |
| | | * @return 参数配置信息 |
| | | */ |
| | | @Override |
| | | @DS("master") |
| | | public SysConfigVo selectConfigById(Long configId) { |
| | | return baseMapper.selectVoById(configId); |
| | | } |
| | | |
| | | /** |
| | | * 根据键名查询参数配置信息 |
| | | * |
| | | * @param configKey 参数key |
| | | * @return 参数键值 |
| | | */ |
| | | @Cacheable(cacheNames = CacheNames.SYS_CONFIG, key = "#configKey") |
| | | @Override |
| | | public String selectConfigByKey(String configKey) { |
| | | SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>() |
| | | .eq(SysConfig::getConfigKey, configKey)); |
| | | if (ObjectUtil.isNotNull(retConfig)) { |
| | | return retConfig.getConfigValue(); |
| | | } |
| | | return StringUtils.EMPTY; |
| | | } |
| | | |
| | | /** |
| | | * 获取注册开关 |
| | | * @param tenantId 租户id |
| | | * @return true开启,false关闭 |
| | | */ |
| | | @Override |
| | | public boolean selectRegisterEnabled(String tenantId) { |
| | | SysConfig retConfig = TenantHelper.dynamic(tenantId, () -> { |
| | | return baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>() |
| | | .eq(SysConfig::getConfigKey, "sys.account.registerUser")); |
| | | }); |
| | | if (ObjectUtil.isNull(retConfig)) { |
| | | return false; |
| | | } |
| | | return Convert.toBool(retConfig.getConfigValue()); |
| | | } |
| | | |
| | | /** |
| | | * 查询参数配置列表 |
| | | * |
| | | * @param config 参数配置信息 |
| | | * @return 参数配置集合 |
| | | */ |
| | | @Override |
| | | public List<SysConfigVo> selectConfigList(SysConfigBo config) { |
| | | LambdaQueryWrapper<SysConfig> lqw = buildQueryWrapper(config); |
| | | return baseMapper.selectVoList(lqw); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<SysConfig> buildQueryWrapper(SysConfigBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | LambdaQueryWrapper<SysConfig> lqw = Wrappers.lambdaQuery(); |
| | | lqw.like(StringUtils.isNotBlank(bo.getConfigName()), SysConfig::getConfigName, bo.getConfigName()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getConfigType()), SysConfig::getConfigType, bo.getConfigType()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getConfigKey()), SysConfig::getConfigKey, bo.getConfigKey()); |
| | | lqw.between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysConfig::getCreateTime, params.get("beginTime"), params.get("endTime")); |
| | | lqw.orderByAsc(SysConfig::getConfigId); |
| | | return lqw; |
| | | } |
| | | |
| | | /** |
| | | * 新增参数配置 |
| | | * |
| | | * @param bo 参数配置信息 |
| | | * @return 结果 |
| | | */ |
| | | @CachePut(cacheNames = CacheNames.SYS_CONFIG, key = "#bo.configKey") |
| | | @Override |
| | | public String insertConfig(SysConfigBo bo) { |
| | | SysConfig config = MapstructUtils.convert(bo, SysConfig.class); |
| | | int row = baseMapper.insert(config); |
| | | if (row > 0) { |
| | | return config.getConfigValue(); |
| | | } |
| | | throw new ServiceException("操作失败"); |
| | | } |
| | | |
| | | /** |
| | | * 修改参数配置 |
| | | * |
| | | * @param bo 参数配置信息 |
| | | * @return 结果 |
| | | */ |
| | | @CachePut(cacheNames = CacheNames.SYS_CONFIG, key = "#bo.configKey") |
| | | @Override |
| | | public String updateConfig(SysConfigBo bo) { |
| | | int row = 0; |
| | | SysConfig config = MapstructUtils.convert(bo, SysConfig.class); |
| | | if (config.getConfigId() != null) { |
| | | SysConfig temp = baseMapper.selectById(config.getConfigId()); |
| | | if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey())) { |
| | | CacheUtils.evict(CacheNames.SYS_CONFIG, temp.getConfigKey()); |
| | | } |
| | | row = baseMapper.updateById(config); |
| | | } else { |
| | | row = baseMapper.update(config, new LambdaQueryWrapper<SysConfig>() |
| | | .eq(SysConfig::getConfigKey, config.getConfigKey())); |
| | | } |
| | | if (row > 0) { |
| | | return config.getConfigValue(); |
| | | } |
| | | throw new ServiceException("操作失败"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除参数信息 |
| | | * |
| | | * @param configIds 需要删除的参数ID |
| | | */ |
| | | @Override |
| | | public void deleteConfigByIds(Long[] configIds) { |
| | | for (Long configId : configIds) { |
| | | SysConfig config = baseMapper.selectById(configId); |
| | | if (StringUtils.equals(UserConstants.YES, config.getConfigType())) { |
| | | throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey())); |
| | | } |
| | | CacheUtils.evict(CacheNames.SYS_CONFIG, config.getConfigKey()); |
| | | } |
| | | baseMapper.deleteBatchIds(Arrays.asList(configIds)); |
| | | } |
| | | |
| | | /** |
| | | * 重置参数缓存数据 |
| | | */ |
| | | @Override |
| | | public void resetConfigCache() { |
| | | CacheUtils.clear(CacheNames.SYS_CONFIG); |
| | | } |
| | | |
| | | /** |
| | | * 校验参数键名是否唯一 |
| | | * |
| | | * @param config 参数配置信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean checkConfigKeyUnique(SysConfigBo config) { |
| | | long configId = ObjectUtil.isNull(config.getConfigId()) ? -1L : config.getConfigId(); |
| | | SysConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getConfigKey, config.getConfigKey())); |
| | | if (ObjectUtil.isNotNull(info) && info.getConfigId() != configId) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.CacheNames; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.SpringUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.core.utils.TreeBuildUtils; |
| | | import org.dromara.common.mybatis.helper.DataBaseHelper; |
| | | import org.dromara.common.redis.utils.CacheUtils; |
| | | import org.dromara.common.satoken.utils.LoginHelper; |
| | | import org.dromara.system.domain.SysDept; |
| | | import org.dromara.system.domain.SysRole; |
| | | import org.dromara.system.domain.SysUser; |
| | | import org.dromara.system.domain.bo.SysDeptBo; |
| | | import org.dromara.system.domain.vo.SysDeptVo; |
| | | import org.dromara.system.mapper.SysDeptMapper; |
| | | import org.dromara.system.mapper.SysRoleMapper; |
| | | import org.dromara.system.mapper.SysUserMapper; |
| | | import org.dromara.system.service.ISysDeptService; |
| | | import org.springframework.cache.annotation.CacheEvict; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 部门管理 服务实现 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysDeptServiceImpl implements ISysDeptService{ |
| | | |
| | | private final SysDeptMapper baseMapper; |
| | | private final SysRoleMapper roleMapper; |
| | | private final SysUserMapper userMapper; |
| | | |
| | | /** |
| | | * 查询部门管理数据 |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 部门信息集合 |
| | | */ |
| | | @Override |
| | | public List<SysDeptVo> selectDeptList(SysDeptBo dept) { |
| | | LambdaQueryWrapper<SysDept> lqw = buildQueryWrapper(dept); |
| | | return baseMapper.selectDeptList(lqw); |
| | | } |
| | | |
| | | /** |
| | | * 查询部门树结构信息 |
| | | * |
| | | * @param bo 部门信息 |
| | | * @return 部门树信息集合 |
| | | */ |
| | | @Override |
| | | public List<Tree<Long>> selectDeptTreeList(SysDeptBo bo) { |
| | | // 只查询未禁用部门 |
| | | bo.setStatus(UserConstants.DEPT_NORMAL); |
| | | LambdaQueryWrapper<SysDept> lqw = buildQueryWrapper(bo); |
| | | List<SysDeptVo> depts = baseMapper.selectDeptList(lqw); |
| | | return buildDeptTreeSelect(depts); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<SysDept> buildQueryWrapper(SysDeptBo bo) { |
| | | LambdaQueryWrapper<SysDept> lqw = Wrappers.lambdaQuery(); |
| | | lqw.eq(SysDept::getDelFlag, "0"); |
| | | lqw.eq(ObjectUtil.isNotNull(bo.getDeptId()), SysDept::getDeptId, bo.getDeptId()); |
| | | lqw.eq(ObjectUtil.isNotNull(bo.getParentId()), SysDept::getParentId, bo.getParentId()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getDeptName()), SysDept::getDeptName, bo.getDeptName()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysDept::getStatus, bo.getStatus()); |
| | | lqw.orderByAsc(SysDept::getParentId); |
| | | lqw.orderByAsc(SysDept::getOrderNum); |
| | | lqw.orderByAsc(SysDept::getDeptId); |
| | | return lqw; |
| | | } |
| | | |
| | | /** |
| | | * 构建前端所需要下拉树结构 |
| | | * |
| | | * @param depts 部门列表 |
| | | * @return 下拉树结构列表 |
| | | */ |
| | | @Override |
| | | public List<Tree<Long>> buildDeptTreeSelect(List<SysDeptVo> depts) { |
| | | if (CollUtil.isEmpty(depts)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | return TreeBuildUtils.build(depts, (dept, tree) -> |
| | | tree.setId(dept.getDeptId()) |
| | | .setParentId(dept.getParentId()) |
| | | .setName(dept.getDeptName()) |
| | | .setWeight(dept.getOrderNum())); |
| | | } |
| | | |
| | | /** |
| | | * 根据角色ID查询部门树信息 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 选中部门列表 |
| | | */ |
| | | @Override |
| | | public List<Long> selectDeptListByRoleId(Long roleId) { |
| | | SysRole role = roleMapper.selectById(roleId); |
| | | return baseMapper.selectDeptListByRoleId(roleId, role.getDeptCheckStrictly()); |
| | | } |
| | | |
| | | /** |
| | | * 根据部门ID查询信息 |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 部门信息 |
| | | */ |
| | | @Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId") |
| | | @Override |
| | | public SysDeptVo selectDeptById(Long deptId) { |
| | | SysDeptVo dept = baseMapper.selectVoById(deptId); |
| | | if (ObjectUtil.isNull(dept)) { |
| | | return null; |
| | | } |
| | | SysDeptVo parentDept = baseMapper.selectVoOne(new LambdaQueryWrapper<SysDept>() |
| | | .select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId())); |
| | | dept.setParentName(ObjectUtil.isNotNull(parentDept) ? parentDept.getDeptName() : null); |
| | | return dept; |
| | | } |
| | | |
| | | /** |
| | | * 通过部门ID查询部门名称 |
| | | * |
| | | * @param deptIds 部门ID串逗号分隔 |
| | | * @return 部门名称串逗号分隔 |
| | | */ |
| | | public String selectDeptNameByIds(String deptIds) { |
| | | List<String> list = new ArrayList<>(); |
| | | for (Long id : StringUtils.splitTo(deptIds, Convert::toLong)) { |
| | | SysDeptVo vo = SpringUtils.getAopProxy(this).selectDeptById(id); |
| | | if (ObjectUtil.isNotNull(vo)) { |
| | | list.add(vo.getDeptName()); |
| | | } |
| | | } |
| | | return String.join(StringUtils.SEPARATOR, list); |
| | | } |
| | | |
| | | /** |
| | | * 根据ID查询所有子部门数(正常状态) |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 子部门数 |
| | | */ |
| | | @Override |
| | | public long selectNormalChildrenDeptById(Long deptId) { |
| | | return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>() |
| | | .eq(SysDept::getStatus, UserConstants.DEPT_NORMAL) |
| | | .apply(DataBaseHelper.findInSet(deptId, "ancestors"))); |
| | | } |
| | | |
| | | /** |
| | | * 是否存在子节点 |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean hasChildByDeptId(Long deptId) { |
| | | return baseMapper.exists(new LambdaQueryWrapper<SysDept>() |
| | | .eq(SysDept::getParentId, deptId)); |
| | | } |
| | | |
| | | /** |
| | | * 查询部门是否存在用户 |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 true 存在 false 不存在 |
| | | */ |
| | | @Override |
| | | public boolean checkDeptExistUser(Long deptId) { |
| | | return userMapper.exists(new LambdaQueryWrapper<SysUser>() |
| | | .eq(SysUser::getDeptId, deptId)); |
| | | } |
| | | |
| | | /** |
| | | * 校验部门名称是否唯一 |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean checkDeptNameUnique(SysDeptBo dept) { |
| | | boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDept>() |
| | | .eq(SysDept::getDeptName, dept.getDeptName()) |
| | | .eq(SysDept::getParentId, dept.getParentId()) |
| | | .ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId())); |
| | | return !exist; |
| | | } |
| | | |
| | | /** |
| | | * 校验部门是否有数据权限 |
| | | * |
| | | * @param deptId 部门id |
| | | */ |
| | | @Override |
| | | public void checkDeptDataScope(Long deptId) { |
| | | if (ObjectUtil.isNull(deptId)) { |
| | | return; |
| | | } |
| | | if (LoginHelper.isSuperAdmin()) { |
| | | return; |
| | | } |
| | | SysDeptVo dept = baseMapper.selectDeptById(deptId); |
| | | if (ObjectUtil.isNull(dept)) { |
| | | throw new ServiceException("没有权限访问部门数据!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 新增保存部门信息 |
| | | * |
| | | * @param bo 部门信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertDept(SysDeptBo bo) { |
| | | SysDept info = baseMapper.selectById(bo.getParentId()); |
| | | // 如果父节点不为正常状态,则不允许新增子节点 |
| | | if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { |
| | | throw new ServiceException("部门停用,不允许新增"); |
| | | } |
| | | SysDept dept = MapstructUtils.convert(bo, SysDept.class); |
| | | dept.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + dept.getParentId()); |
| | | return baseMapper.insert(dept); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存部门信息 |
| | | * |
| | | * @param bo 部门信息 |
| | | * @return 结果 |
| | | */ |
| | | @CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#bo.deptId") |
| | | @Override |
| | | public int updateDept(SysDeptBo bo) { |
| | | SysDept dept = MapstructUtils.convert(bo, SysDept.class); |
| | | SysDept oldDept = baseMapper.selectById(dept.getDeptId()); |
| | | if (!oldDept.getParentId().equals(dept.getParentId())) { |
| | | // 如果是新父部门 则校验是否具有新父部门权限 避免越权 |
| | | this.checkDeptDataScope(dept.getParentId()); |
| | | SysDept newParentDept = baseMapper.selectById(dept.getParentId()); |
| | | if (ObjectUtil.isNotNull(newParentDept) && ObjectUtil.isNotNull(oldDept)) { |
| | | String newAncestors = newParentDept.getAncestors() + StringUtils.SEPARATOR + newParentDept.getDeptId(); |
| | | String oldAncestors = oldDept.getAncestors(); |
| | | dept.setAncestors(newAncestors); |
| | | updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); |
| | | } |
| | | } |
| | | int result = baseMapper.updateById(dept); |
| | | if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) |
| | | && !StringUtils.equals(UserConstants.DEPT_NORMAL, dept.getAncestors())) { |
| | | // 如果该部门是启用状态,则启用该部门的所有上级部门 |
| | | updateParentDeptStatusNormal(dept); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 修改该部门的父级部门状态 |
| | | * |
| | | * @param dept 当前部门 |
| | | */ |
| | | private void updateParentDeptStatusNormal(SysDept dept) { |
| | | String ancestors = dept.getAncestors(); |
| | | Long[] deptIds = Convert.toLongArray(ancestors); |
| | | baseMapper.update(null, new LambdaUpdateWrapper<SysDept>() |
| | | .set(SysDept::getStatus, UserConstants.DEPT_NORMAL) |
| | | .in(SysDept::getDeptId, Arrays.asList(deptIds))); |
| | | } |
| | | |
| | | /** |
| | | * 修改子元素关系 |
| | | * |
| | | * @param deptId 被修改的部门ID |
| | | * @param newAncestors 新的父ID集合 |
| | | * @param oldAncestors 旧的父ID集合 |
| | | */ |
| | | private void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) { |
| | | List<SysDept> children = baseMapper.selectList(new LambdaQueryWrapper<SysDept>() |
| | | .apply(DataBaseHelper.findInSet(deptId, "ancestors"))); |
| | | List<SysDept> list = new ArrayList<>(); |
| | | for (SysDept child : children) { |
| | | SysDept dept = new SysDept(); |
| | | dept.setDeptId(child.getDeptId()); |
| | | dept.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); |
| | | list.add(dept); |
| | | } |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | if (baseMapper.updateBatchById(list)) { |
| | | list.forEach(dept -> CacheUtils.evict(CacheNames.SYS_DEPT, dept.getDeptId())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除部门管理信息 |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | | @CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#deptId") |
| | | @Override |
| | | public int deleteDeptById(Long deptId) { |
| | | return baseMapper.deleteById(deptId); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.CacheNames; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.redis.utils.CacheUtils; |
| | | import org.dromara.system.domain.SysDictData; |
| | | import org.dromara.system.domain.bo.SysDictDataBo; |
| | | import org.dromara.system.domain.vo.SysDictDataVo; |
| | | import org.dromara.system.mapper.SysDictDataMapper; |
| | | import org.dromara.system.service.ISysDictDataService; |
| | | import org.springframework.cache.annotation.CachePut; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典 业务层处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysDictDataServiceImpl implements ISysDictDataService { |
| | | |
| | | private final SysDictDataMapper baseMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysDictDataVo> selectPageDictDataList(SysDictDataBo dictData, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysDictData> lqw = buildQueryWrapper(dictData); |
| | | Page<SysDictDataVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | | * 根据条件分页查询字典数据 |
| | | * |
| | | * @param dictData 字典数据信息 |
| | | * @return 字典数据集合信息 |
| | | */ |
| | | @Override |
| | | public List<SysDictDataVo> selectDictDataList(SysDictDataBo dictData) { |
| | | LambdaQueryWrapper<SysDictData> lqw = buildQueryWrapper(dictData); |
| | | return baseMapper.selectVoList(lqw); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<SysDictData> buildQueryWrapper(SysDictDataBo bo) { |
| | | LambdaQueryWrapper<SysDictData> lqw = Wrappers.lambdaQuery(); |
| | | lqw.eq(bo.getDictSort() != null, SysDictData::getDictSort, bo.getDictSort()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getDictLabel()), SysDictData::getDictLabel, bo.getDictLabel()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getDictType()), SysDictData::getDictType, bo.getDictType()); |
| | | lqw.orderByAsc(SysDictData::getDictSort); |
| | | return lqw; |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型和字典键值查询字典数据信息 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @param dictValue 字典键值 |
| | | * @return 字典标签 |
| | | */ |
| | | @Override |
| | | public String selectDictLabel(String dictType, String dictValue) { |
| | | return baseMapper.selectOne(new LambdaQueryWrapper<SysDictData>() |
| | | .select(SysDictData::getDictLabel) |
| | | .eq(SysDictData::getDictType, dictType) |
| | | .eq(SysDictData::getDictValue, dictValue)) |
| | | .getDictLabel(); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典数据ID查询信息 |
| | | * |
| | | * @param dictCode 字典数据ID |
| | | * @return 字典数据 |
| | | */ |
| | | @Override |
| | | public SysDictDataVo selectDictDataById(Long dictCode) { |
| | | return baseMapper.selectVoById(dictCode); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除字典数据信息 |
| | | * |
| | | * @param dictCodes 需要删除的字典数据ID |
| | | */ |
| | | @Override |
| | | public void deleteDictDataByIds(Long[] dictCodes) { |
| | | for (Long dictCode : dictCodes) { |
| | | SysDictData data = baseMapper.selectById(dictCode); |
| | | baseMapper.deleteById(dictCode); |
| | | CacheUtils.evict(CacheNames.SYS_DICT, data.getDictType()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 新增保存字典数据信息 |
| | | * |
| | | * @param bo 字典数据信息 |
| | | * @return 结果 |
| | | */ |
| | | @CachePut(cacheNames = CacheNames.SYS_DICT, key = "#bo.dictType") |
| | | @Override |
| | | public List<SysDictDataVo> insertDictData(SysDictDataBo bo) { |
| | | SysDictData data = MapstructUtils.convert(bo, SysDictData.class); |
| | | int row = baseMapper.insert(data); |
| | | if (row > 0) { |
| | | return baseMapper.selectDictDataByType(data.getDictType()); |
| | | } |
| | | throw new ServiceException("操作失败"); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存字典数据信息 |
| | | * |
| | | * @param bo 字典数据信息 |
| | | * @return 结果 |
| | | */ |
| | | @CachePut(cacheNames = CacheNames.SYS_DICT, key = "#bo.dictType") |
| | | @Override |
| | | public List<SysDictDataVo> updateDictData(SysDictDataBo bo) { |
| | | SysDictData data = MapstructUtils.convert(bo, SysDictData.class); |
| | | int row = baseMapper.updateById(data); |
| | | if (row > 0) { |
| | | return baseMapper.selectDictDataByType(data.getDictType()); |
| | | } |
| | | throw new ServiceException("操作失败"); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.CacheNames; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.redis.utils.CacheUtils; |
| | | import org.dromara.system.domain.SysDictData; |
| | | import org.dromara.system.domain.SysDictType; |
| | | import org.dromara.system.domain.bo.SysDictTypeBo; |
| | | import org.dromara.system.domain.vo.SysDictDataVo; |
| | | import org.dromara.system.domain.vo.SysDictTypeVo; |
| | | import org.dromara.system.mapper.SysDictDataMapper; |
| | | import org.dromara.system.mapper.SysDictTypeMapper; |
| | | import org.dromara.system.service.ISysDictTypeService; |
| | | import org.springframework.cache.annotation.CachePut; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 字典 业务层处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysDictTypeServiceImpl implements ISysDictTypeService { |
| | | |
| | | private final SysDictTypeMapper baseMapper; |
| | | private final SysDictDataMapper dictDataMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysDictTypeVo> selectPageDictTypeList(SysDictTypeBo dictType, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysDictType> lqw = buildQueryWrapper(dictType); |
| | | Page<SysDictTypeVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | | * 根据条件分页查询字典类型 |
| | | * |
| | | * @param dictType 字典类型信息 |
| | | * @return 字典类型集合信息 |
| | | */ |
| | | @Override |
| | | public List<SysDictTypeVo> selectDictTypeList(SysDictTypeBo dictType) { |
| | | LambdaQueryWrapper<SysDictType> lqw = buildQueryWrapper(dictType); |
| | | return baseMapper.selectVoList(lqw); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<SysDictType> buildQueryWrapper(SysDictTypeBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | LambdaQueryWrapper<SysDictType> lqw = Wrappers.lambdaQuery(); |
| | | lqw.like(StringUtils.isNotBlank(bo.getDictName()), SysDictType::getDictName, bo.getDictName()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getDictType()), SysDictType::getDictType, bo.getDictType()); |
| | | lqw.between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysDictType::getCreateTime, params.get("beginTime"), params.get("endTime")); |
| | | lqw.orderByAsc(SysDictType::getDictId); |
| | | return lqw; |
| | | } |
| | | |
| | | /** |
| | | * 根据所有字典类型 |
| | | * |
| | | * @return 字典类型集合信息 |
| | | */ |
| | | @Override |
| | | public List<SysDictTypeVo> selectDictTypeAll() { |
| | | return baseMapper.selectVoList(); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型查询字典数据 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 字典数据集合信息 |
| | | */ |
| | | @Cacheable(cacheNames = CacheNames.SYS_DICT, key = "#dictType") |
| | | @Override |
| | | public List<SysDictDataVo> selectDictDataByType(String dictType) { |
| | | List<SysDictDataVo> dictDatas = dictDataMapper.selectDictDataByType(dictType); |
| | | if (CollUtil.isNotEmpty(dictDatas)) { |
| | | return dictDatas; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型ID查询信息 |
| | | * |
| | | * @param dictId 字典类型ID |
| | | * @return 字典类型 |
| | | */ |
| | | @Override |
| | | public SysDictTypeVo selectDictTypeById(Long dictId) { |
| | | return baseMapper.selectVoById(dictId); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型查询信息 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 字典类型 |
| | | */ |
| | | @Override |
| | | public SysDictTypeVo selectDictTypeByType(String dictType) { |
| | | return baseMapper.selectVoOne(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除字典类型信息 |
| | | * |
| | | * @param dictIds 需要删除的字典ID |
| | | */ |
| | | @Override |
| | | public void deleteDictTypeByIds(Long[] dictIds) { |
| | | for (Long dictId : dictIds) { |
| | | SysDictType dictType = baseMapper.selectById(dictId); |
| | | if (dictDataMapper.exists(new LambdaQueryWrapper<SysDictData>() |
| | | .eq(SysDictData::getDictType, dictType.getDictType()))) { |
| | | throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName())); |
| | | } |
| | | CacheUtils.evict(CacheNames.SYS_DICT, dictType.getDictType()); |
| | | } |
| | | baseMapper.deleteBatchIds(Arrays.asList(dictIds)); |
| | | } |
| | | |
| | | /** |
| | | * 重置字典缓存数据 |
| | | */ |
| | | @Override |
| | | public void resetDictCache() { |
| | | CacheUtils.clear(CacheNames.SYS_DICT); |
| | | } |
| | | |
| | | /** |
| | | * 新增保存字典类型信息 |
| | | * |
| | | * @param bo 字典类型信息 |
| | | * @return 结果 |
| | | */ |
| | | @CachePut(cacheNames = CacheNames.SYS_DICT, key = "#bo.dictType") |
| | | @Override |
| | | public List<SysDictDataVo> insertDictType(SysDictTypeBo bo) { |
| | | SysDictType dict = MapstructUtils.convert(bo, SysDictType.class); |
| | | int row = baseMapper.insert(dict); |
| | | if (row > 0) { |
| | | // 新增 type 下无 data 数据 返回空防止缓存穿透 |
| | | return new ArrayList<>(); |
| | | } |
| | | throw new ServiceException("操作失败"); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存字典类型信息 |
| | | * |
| | | * @param bo 字典类型信息 |
| | | * @return 结果 |
| | | */ |
| | | @CachePut(cacheNames = CacheNames.SYS_DICT, key = "#bo.dictType") |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public List<SysDictDataVo> updateDictType(SysDictTypeBo bo) { |
| | | SysDictType dict = MapstructUtils.convert(bo, SysDictType.class); |
| | | SysDictType oldDict = baseMapper.selectById(dict.getDictId()); |
| | | dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>() |
| | | .set(SysDictData::getDictType, dict.getDictType()) |
| | | .eq(SysDictData::getDictType, oldDict.getDictType())); |
| | | int row = baseMapper.updateById(dict); |
| | | if (row > 0) { |
| | | CacheUtils.evict(CacheNames.SYS_DICT, oldDict.getDictType()); |
| | | return dictDataMapper.selectDictDataByType(dict.getDictType()); |
| | | } |
| | | throw new ServiceException("操作失败"); |
| | | } |
| | | |
| | | /** |
| | | * 校验字典类型称是否唯一 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean checkDictTypeUnique(SysDictTypeBo dictType) { |
| | | boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDictType>() |
| | | .eq(SysDictType::getDictType, dictType.getDictType()) |
| | | .ne(ObjectUtil.isNotNull(dictType.getDictId()), SysDictType::getDictId, dictType.getDictId())); |
| | | return !exist; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.SysLogininfor; |
| | | import org.dromara.system.domain.bo.SysLogininforBo; |
| | | import org.dromara.system.domain.vo.SysLogininforVo; |
| | | import org.dromara.system.mapper.SysLogininforMapper; |
| | | import org.dromara.system.service.ISysLogininforService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 系统访问日志情况信息 服务层处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Slf4j |
| | | @Service |
| | | public class SysLogininforServiceImpl implements ISysLogininforService { |
| | | |
| | | private final SysLogininforMapper baseMapper; |
| | | |
| | | |
| | | private String getBlock(Object msg) { |
| | | if (msg == null) { |
| | | msg = ""; |
| | | } |
| | | return "[" + msg.toString() + "]"; |
| | | } |
| | | |
| | | @Override |
| | | public TableDataInfo<SysLogininforVo> selectPageLogininforList(SysLogininforBo logininfor, PageQuery pageQuery) { |
| | | Map<String, Object> params = logininfor.getParams(); |
| | | LambdaQueryWrapper<SysLogininfor> lqw = new LambdaQueryWrapper<SysLogininfor>() |
| | | .like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr()) |
| | | .eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus()) |
| | | .like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime")); |
| | | if (StringUtils.isBlank(pageQuery.getOrderByColumn())) { |
| | | pageQuery.setOrderByColumn("info_id"); |
| | | pageQuery.setIsAsc("desc"); |
| | | } |
| | | Page<SysLogininforVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | | * 新增系统登录日志 |
| | | * |
| | | * @param bo 访问日志对象 |
| | | */ |
| | | @Override |
| | | public void insertLogininfor(SysLogininforBo bo) { |
| | | SysLogininfor logininfor = MapstructUtils.convert(bo, SysLogininfor.class); |
| | | logininfor.setLoginTime(new Date()); |
| | | baseMapper.insert(logininfor); |
| | | } |
| | | |
| | | /** |
| | | * 查询系统登录日志集合 |
| | | * |
| | | * @param logininfor 访问日志对象 |
| | | * @return 登录记录集合 |
| | | */ |
| | | @Override |
| | | public List<SysLogininforVo> selectLogininforList(SysLogininforBo logininfor) { |
| | | Map<String, Object> params = logininfor.getParams(); |
| | | return baseMapper.selectVoList(new LambdaQueryWrapper<SysLogininfor>() |
| | | .like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr()) |
| | | .eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus()) |
| | | .like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime")) |
| | | .orderByDesc(SysLogininfor::getInfoId)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除系统登录日志 |
| | | * |
| | | * @param infoIds 需要删除的登录日志ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteLogininforByIds(Long[] infoIds) { |
| | | return baseMapper.deleteBatchIds(Arrays.asList(infoIds)); |
| | | } |
| | | |
| | | /** |
| | | * 清空系统登录日志 |
| | | */ |
| | | @Override |
| | | public void cleanLogininfor() { |
| | | baseMapper.delete(new LambdaQueryWrapper<>()); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StreamUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.core.utils.TreeBuildUtils; |
| | | import org.dromara.common.satoken.utils.LoginHelper; |
| | | import org.dromara.system.domain.SysMenu; |
| | | import org.dromara.system.domain.SysRole; |
| | | import org.dromara.system.domain.SysRoleMenu; |
| | | import org.dromara.system.domain.SysTenantPackage; |
| | | import org.dromara.system.domain.bo.SysMenuBo; |
| | | import org.dromara.system.domain.vo.MetaVo; |
| | | import org.dromara.system.domain.vo.RouterVo; |
| | | import org.dromara.system.domain.vo.SysMenuVo; |
| | | import org.dromara.system.mapper.SysMenuMapper; |
| | | import org.dromara.system.mapper.SysRoleMapper; |
| | | import org.dromara.system.mapper.SysRoleMenuMapper; |
| | | import org.dromara.system.mapper.SysTenantPackageMapper; |
| | | import org.dromara.system.service.ISysMenuService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 菜单 业务层处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysMenuServiceImpl implements ISysMenuService { |
| | | |
| | | private final SysMenuMapper baseMapper; |
| | | private final SysRoleMapper roleMapper; |
| | | private final SysRoleMenuMapper roleMenuMapper; |
| | | private final SysTenantPackageMapper tenantPackageMapper; |
| | | |
| | | /** |
| | | * 根据用户查询系统菜单列表 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 菜单列表 |
| | | */ |
| | | @Override |
| | | public List<SysMenuVo> selectMenuList(Long userId) { |
| | | return selectMenuList(new SysMenuBo(), userId); |
| | | } |
| | | |
| | | /** |
| | | * 查询系统菜单列表 |
| | | * |
| | | * @param menu 菜单信息 |
| | | * @return 菜单列表 |
| | | */ |
| | | @Override |
| | | public List<SysMenuVo> selectMenuList(SysMenuBo menu, Long userId) { |
| | | List<SysMenuVo> menuList; |
| | | // 管理员显示所有菜单信息 |
| | | if (LoginHelper.isSuperAdmin(userId)) { |
| | | menuList = baseMapper.selectVoList(new LambdaQueryWrapper<SysMenu>() |
| | | .like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName()) |
| | | .eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible()) |
| | | .eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus()) |
| | | .orderByAsc(SysMenu::getParentId) |
| | | .orderByAsc(SysMenu::getOrderNum)); |
| | | } else { |
| | | QueryWrapper<SysMenu> wrapper = Wrappers.query(); |
| | | wrapper.eq("sur.user_id", userId) |
| | | .like(StringUtils.isNotBlank(menu.getMenuName()), "m.menu_name", menu.getMenuName()) |
| | | .eq(StringUtils.isNotBlank(menu.getVisible()), "m.visible", menu.getVisible()) |
| | | .eq(StringUtils.isNotBlank(menu.getStatus()), "m.status", menu.getStatus()) |
| | | .orderByAsc("m.parent_id") |
| | | .orderByAsc("m.order_num"); |
| | | List<SysMenu> list = baseMapper.selectMenuListByUserId(wrapper); |
| | | menuList = MapstructUtils.convert(list, SysMenuVo.class); |
| | | } |
| | | return menuList; |
| | | } |
| | | |
| | | /** |
| | | * 根据用户ID查询权限 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 权限列表 |
| | | */ |
| | | @Override |
| | | public Set<String> selectMenuPermsByUserId(Long userId) { |
| | | List<String> perms = baseMapper.selectMenuPermsByUserId(userId); |
| | | Set<String> permsSet = new HashSet<>(); |
| | | for (String perm : perms) { |
| | | if (StringUtils.isNotEmpty(perm)) { |
| | | permsSet.addAll(StringUtils.splitList(perm.trim())); |
| | | } |
| | | } |
| | | return permsSet; |
| | | } |
| | | |
| | | /** |
| | | * 根据角色ID查询权限 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 权限列表 |
| | | */ |
| | | @Override |
| | | public Set<String> selectMenuPermsByRoleId(Long roleId) { |
| | | List<String> perms = baseMapper.selectMenuPermsByRoleId(roleId); |
| | | Set<String> permsSet = new HashSet<>(); |
| | | for (String perm : perms) { |
| | | if (StringUtils.isNotEmpty(perm)) { |
| | | permsSet.addAll(StringUtils.splitList(perm.trim())); |
| | | } |
| | | } |
| | | return permsSet; |
| | | } |
| | | |
| | | /** |
| | | * 根据用户ID查询菜单 |
| | | * |
| | | * @param userId 用户名称 |
| | | * @return 菜单列表 |
| | | */ |
| | | @Override |
| | | public List<SysMenu> selectMenuTreeByUserId(Long userId) { |
| | | List<SysMenu> menus; |
| | | if (LoginHelper.isSuperAdmin(userId)) { |
| | | menus = baseMapper.selectMenuTreeAll(); |
| | | } else { |
| | | menus = baseMapper.selectMenuTreeByUserId(userId); |
| | | } |
| | | return getChildPerms(menus, 0); |
| | | } |
| | | |
| | | /** |
| | | * 根据角色ID查询菜单树信息 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 选中菜单列表 |
| | | */ |
| | | @Override |
| | | public List<Long> selectMenuListByRoleId(Long roleId) { |
| | | SysRole role = roleMapper.selectById(roleId); |
| | | return baseMapper.selectMenuListByRoleId(roleId, role.getMenuCheckStrictly()); |
| | | } |
| | | |
| | | /** |
| | | * 根据租户套餐ID查询菜单树信息 |
| | | * |
| | | * @param packageId 租户套餐ID |
| | | * @return 选中菜单列表 |
| | | */ |
| | | @Override |
| | | public List<Long> selectMenuListByPackageId(Long packageId) { |
| | | SysTenantPackage tenantPackage = tenantPackageMapper.selectById(packageId); |
| | | List<Long> menuIds = StringUtils.splitTo(tenantPackage.getMenuIds(), Convert::toLong); |
| | | if (CollUtil.isEmpty(menuIds)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | List<Long> parentIds = null; |
| | | if (tenantPackage.getMenuCheckStrictly()) { |
| | | parentIds = baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>() |
| | | .select(SysMenu::getParentId) |
| | | .in(SysMenu::getMenuId, menuIds), x -> {return Convert.toLong(x);}); |
| | | } |
| | | return baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>() |
| | | .in(SysMenu::getMenuId, menuIds) |
| | | .notIn(CollUtil.isNotEmpty(parentIds), SysMenu::getMenuId, parentIds), x -> {return Convert.toLong(x);}); |
| | | } |
| | | |
| | | /** |
| | | * 构建前端路由所需要的菜单 |
| | | * |
| | | * @param menus 菜单列表 |
| | | * @return 路由列表 |
| | | */ |
| | | @Override |
| | | public List<RouterVo> buildMenus(List<SysMenu> menus) { |
| | | List<RouterVo> routers = new LinkedList<>(); |
| | | for (SysMenu menu : menus) { |
| | | RouterVo router = new RouterVo(); |
| | | router.setHidden("1".equals(menu.getVisible())); |
| | | router.setName(menu.getRouteName()); |
| | | router.setPath(menu.getRouterPath()); |
| | | router.setComponent(menu.getComponentInfo()); |
| | | router.setQuery(menu.getQueryParam()); |
| | | router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); |
| | | List<SysMenu> cMenus = menu.getChildren(); |
| | | if (CollUtil.isNotEmpty(cMenus) && UserConstants.TYPE_DIR.equals(menu.getMenuType())) { |
| | | router.setAlwaysShow(true); |
| | | router.setRedirect("noRedirect"); |
| | | router.setChildren(buildMenus(cMenus)); |
| | | } else if (menu.isMenuFrame()) { |
| | | router.setMeta(null); |
| | | List<RouterVo> childrenList = new ArrayList<>(); |
| | | RouterVo children = new RouterVo(); |
| | | children.setPath(menu.getPath()); |
| | | children.setComponent(menu.getComponent()); |
| | | children.setName(StringUtils.capitalize(menu.getPath())); |
| | | children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); |
| | | children.setQuery(menu.getQueryParam()); |
| | | childrenList.add(children); |
| | | router.setChildren(childrenList); |
| | | } else if (menu.getParentId().intValue() == 0 && menu.isInnerLink()) { |
| | | router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon())); |
| | | router.setPath("/"); |
| | | List<RouterVo> childrenList = new ArrayList<>(); |
| | | RouterVo children = new RouterVo(); |
| | | String routerPath = SysMenu.innerLinkReplaceEach(menu.getPath()); |
| | | children.setPath(routerPath); |
| | | children.setComponent(UserConstants.INNER_LINK); |
| | | children.setName(StringUtils.capitalize(routerPath)); |
| | | children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath())); |
| | | childrenList.add(children); |
| | | router.setChildren(childrenList); |
| | | } |
| | | routers.add(router); |
| | | } |
| | | return routers; |
| | | } |
| | | |
| | | /** |
| | | * 构建前端所需要下拉树结构 |
| | | * |
| | | * @param menus 菜单列表 |
| | | * @return 下拉树结构列表 |
| | | */ |
| | | @Override |
| | | public List<Tree<Long>> buildMenuTreeSelect(List<SysMenuVo> menus) { |
| | | if (CollUtil.isEmpty(menus)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | return TreeBuildUtils.build(menus, (menu, tree) -> |
| | | tree.setId(menu.getMenuId()) |
| | | .setParentId(menu.getParentId()) |
| | | .setName(menu.getMenuName()) |
| | | .setWeight(menu.getOrderNum())); |
| | | } |
| | | |
| | | /** |
| | | * 根据菜单ID查询信息 |
| | | * |
| | | * @param menuId 菜单ID |
| | | * @return 菜单信息 |
| | | */ |
| | | @Override |
| | | public SysMenuVo selectMenuById(Long menuId) { |
| | | return baseMapper.selectVoById(menuId); |
| | | } |
| | | |
| | | /** |
| | | * 是否存在菜单子节点 |
| | | * |
| | | * @param menuId 菜单ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean hasChildByMenuId(Long menuId) { |
| | | return baseMapper.exists(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId)); |
| | | } |
| | | |
| | | /** |
| | | * 查询菜单使用数量 |
| | | * |
| | | * @param menuId 菜单ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean checkMenuExistRole(Long menuId) { |
| | | return roleMenuMapper.exists(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId, menuId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增保存菜单信息 |
| | | * |
| | | * @param bo 菜单信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertMenu(SysMenuBo bo) { |
| | | SysMenu menu = MapstructUtils.convert(bo, SysMenu.class); |
| | | return baseMapper.insert(menu); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存菜单信息 |
| | | * |
| | | * @param bo 菜单信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateMenu(SysMenuBo bo) { |
| | | SysMenu menu = MapstructUtils.convert(bo, SysMenu.class); |
| | | return baseMapper.updateById(menu); |
| | | } |
| | | |
| | | /** |
| | | * 删除菜单管理信息 |
| | | * |
| | | * @param menuId 菜单ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteMenuById(Long menuId) { |
| | | return baseMapper.deleteById(menuId); |
| | | } |
| | | |
| | | /** |
| | | * 校验菜单名称是否唯一 |
| | | * |
| | | * @param menu 菜单信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean checkMenuNameUnique(SysMenuBo menu) { |
| | | boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysMenu>() |
| | | .eq(SysMenu::getMenuName, menu.getMenuName()) |
| | | .eq(SysMenu::getParentId, menu.getParentId()) |
| | | .ne(ObjectUtil.isNotNull(menu.getMenuId()), SysMenu::getMenuId, menu.getMenuId())); |
| | | return !exist; |
| | | } |
| | | |
| | | /** |
| | | * 根据父节点的ID获取所有子节点 |
| | | * |
| | | * @param list 分类表 |
| | | * @param parentId 传入的父节点ID |
| | | * @return String |
| | | */ |
| | | private List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) { |
| | | List<SysMenu> returnList = new ArrayList<>(); |
| | | for (SysMenu t : list) { |
| | | // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点 |
| | | if (t.getParentId() == parentId) { |
| | | recursionFn(list, t); |
| | | returnList.add(t); |
| | | } |
| | | } |
| | | return returnList; |
| | | } |
| | | |
| | | /** |
| | | * 递归列表 |
| | | */ |
| | | private void recursionFn(List<SysMenu> list, SysMenu t) { |
| | | // 得到子节点列表 |
| | | List<SysMenu> childList = StreamUtils.filter(list, n -> n.getParentId().equals(t.getMenuId())); |
| | | t.setChildren(childList); |
| | | for (SysMenu tChild : childList) { |
| | | // 判断是否有子节点 |
| | | if (list.stream().anyMatch(n -> n.getParentId().equals(tChild.getMenuId()))) { |
| | | recursionFn(list, tChild); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.SysNotice; |
| | | import org.dromara.system.domain.bo.SysNoticeBo; |
| | | import org.dromara.system.domain.vo.SysNoticeVo; |
| | | import org.dromara.system.domain.vo.SysUserVo; |
| | | import org.dromara.system.mapper.SysNoticeMapper; |
| | | import org.dromara.system.mapper.SysUserMapper; |
| | | import org.dromara.system.service.ISysNoticeService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 公告 服务层实现 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysNoticeServiceImpl implements ISysNoticeService { |
| | | |
| | | private final SysNoticeMapper baseMapper; |
| | | private final SysUserMapper userMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysNoticeVo> selectPageNoticeList(SysNoticeBo notice, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysNotice> lqw = buildQueryWrapper(notice); |
| | | Page<SysNoticeVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | | * 查询公告信息 |
| | | * |
| | | * @param noticeId 公告ID |
| | | * @return 公告信息 |
| | | */ |
| | | @Override |
| | | public SysNoticeVo selectNoticeById(Long noticeId) { |
| | | return baseMapper.selectVoById(noticeId); |
| | | } |
| | | |
| | | /** |
| | | * 查询公告列表 |
| | | * |
| | | * @param notice 公告信息 |
| | | * @return 公告集合 |
| | | */ |
| | | @Override |
| | | public List<SysNoticeVo> selectNoticeList(SysNoticeBo notice) { |
| | | LambdaQueryWrapper<SysNotice> lqw = buildQueryWrapper(notice); |
| | | return baseMapper.selectVoList(lqw); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<SysNotice> buildQueryWrapper(SysNoticeBo bo) { |
| | | LambdaQueryWrapper<SysNotice> lqw = Wrappers.lambdaQuery(); |
| | | lqw.like(StringUtils.isNotBlank(bo.getNoticeTitle()), SysNotice::getNoticeTitle, bo.getNoticeTitle()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getNoticeType()), SysNotice::getNoticeType, bo.getNoticeType()); |
| | | if (StringUtils.isNotBlank(bo.getCreateByName())) { |
| | | SysUserVo sysUser = userMapper.selectUserByUserName(bo.getCreateByName()); |
| | | lqw.eq(SysNotice::getCreateBy, ObjectUtil.isNotNull(sysUser) ? sysUser.getUserId() : null); |
| | | } |
| | | lqw.orderByAsc(SysNotice::getNoticeId); |
| | | return lqw; |
| | | } |
| | | |
| | | /** |
| | | * 新增公告 |
| | | * |
| | | * @param bo 公告信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertNotice(SysNoticeBo bo) { |
| | | SysNotice notice = MapstructUtils.convert(bo, SysNotice.class); |
| | | return baseMapper.insert(notice); |
| | | } |
| | | |
| | | /** |
| | | * 修改公告 |
| | | * |
| | | * @param bo 公告信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateNotice(SysNoticeBo bo) { |
| | | SysNotice notice = MapstructUtils.convert(bo, SysNotice.class); |
| | | return baseMapper.updateById(notice); |
| | | } |
| | | |
| | | /** |
| | | * 删除公告对象 |
| | | * |
| | | * @param noticeId 公告ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteNoticeById(Long noticeId) { |
| | | return baseMapper.deleteById(noticeId); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除公告信息 |
| | | * |
| | | * @param noticeIds 需要删除的公告ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteNoticeByIds(Long[] noticeIds) { |
| | | return baseMapper.deleteBatchIds(Arrays.asList(noticeIds)); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.SysOperLog; |
| | | import org.dromara.system.domain.bo.SysOperLogBo; |
| | | import org.dromara.system.domain.vo.SysOperLogVo; |
| | | import org.dromara.system.mapper.SysOperLogMapper; |
| | | import org.dromara.system.service.ISysOperLogService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 操作日志 服务层处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysOperLogServiceImpl implements ISysOperLogService { |
| | | |
| | | private final SysOperLogMapper baseMapper; |
| | | |
| | | |
| | | @Override |
| | | public TableDataInfo<SysOperLogVo> selectPageOperLogList(SysOperLogBo operLog, PageQuery pageQuery) { |
| | | Map<String, Object> params = operLog.getParams(); |
| | | LambdaQueryWrapper<SysOperLog> lqw = new LambdaQueryWrapper<SysOperLog>() |
| | | .like(StringUtils.isNotBlank(operLog.getOperIp()), SysOperLog::getOperIp, operLog.getOperIp()) |
| | | .like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle()) |
| | | .eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0, |
| | | SysOperLog::getBusinessType, operLog.getBusinessType()) |
| | | .func(f -> { |
| | | if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) { |
| | | f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes())); |
| | | } |
| | | }) |
| | | .eq(operLog.getStatus() != null, |
| | | SysOperLog::getStatus, operLog.getStatus()) |
| | | .like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime")); |
| | | if (StringUtils.isBlank(pageQuery.getOrderByColumn())) { |
| | | pageQuery.setOrderByColumn("oper_id"); |
| | | pageQuery.setIsAsc("desc"); |
| | | } |
| | | Page<SysOperLogVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | | * 新增操作日志 |
| | | * |
| | | * @param bo 操作日志对象 |
| | | */ |
| | | @Override |
| | | public void insertOperlog(SysOperLogBo bo) { |
| | | SysOperLog operLog = MapstructUtils.convert(bo, SysOperLog.class); |
| | | operLog.setOperTime(new Date()); |
| | | baseMapper.insert(operLog); |
| | | } |
| | | |
| | | /** |
| | | * 查询系统操作日志集合 |
| | | * |
| | | * @param operLog 操作日志对象 |
| | | * @return 操作日志集合 |
| | | */ |
| | | @Override |
| | | public List<SysOperLogVo> selectOperLogList(SysOperLogBo operLog) { |
| | | Map<String, Object> params = operLog.getParams(); |
| | | return baseMapper.selectVoList(new LambdaQueryWrapper<SysOperLog>() |
| | | .like(StringUtils.isNotBlank(operLog.getOperIp()), SysOperLog::getOperIp, operLog.getOperIp()) |
| | | .like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle()) |
| | | .eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0, |
| | | SysOperLog::getBusinessType, operLog.getBusinessType()) |
| | | .func(f -> { |
| | | if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) { |
| | | f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes())); |
| | | } |
| | | }) |
| | | .eq(operLog.getStatus() != null && operLog.getStatus() > 0, |
| | | SysOperLog::getStatus, operLog.getStatus()) |
| | | .like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime")) |
| | | .orderByDesc(SysOperLog::getOperId)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除系统操作日志 |
| | | * |
| | | * @param operIds 需要删除的操作日志ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteOperLogByIds(Long[] operIds) { |
| | | return baseMapper.deleteBatchIds(Arrays.asList(operIds)); |
| | | } |
| | | |
| | | /** |
| | | * 查询操作日志详细 |
| | | * |
| | | * @param operId 操作ID |
| | | * @return 操作日志对象 |
| | | */ |
| | | @Override |
| | | public SysOperLogVo selectOperLogById(Long operId) { |
| | | return baseMapper.selectVoById(operId); |
| | | } |
| | | |
| | | /** |
| | | * 清空操作日志 |
| | | */ |
| | | @Override |
| | | public void cleanOperLog() { |
| | | baseMapper.delete(new LambdaQueryWrapper<>()); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.TenantConstants; |
| | | import org.dromara.common.satoken.utils.LoginHelper; |
| | | import org.dromara.system.service.ISysMenuService; |
| | | import org.dromara.system.service.ISysPermissionService; |
| | | import org.dromara.system.service.ISysRoleService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * 用户权限处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysPermissionServiceImpl implements ISysPermissionService { |
| | | |
| | | private final ISysRoleService roleService; |
| | | private final ISysMenuService menuService; |
| | | |
| | | /** |
| | | * 获取角色数据权限 |
| | | * |
| | | * @param userId 用户id |
| | | * @return 角色权限信息 |
| | | */ |
| | | @Override |
| | | public Set<String> getRolePermission(Long userId) { |
| | | Set<String> roles = new HashSet<>(); |
| | | // 管理员拥有所有权限 |
| | | if (LoginHelper.isSuperAdmin(userId)) { |
| | | roles.add(TenantConstants.SUPER_ADMIN_ROLE_KEY); |
| | | } else { |
| | | roles.addAll(roleService.selectRolePermissionByUserId(userId)); |
| | | } |
| | | return roles; |
| | | } |
| | | |
| | | /** |
| | | * 获取菜单数据权限 |
| | | * |
| | | * @param userId 用户id |
| | | * @return 菜单权限信息 |
| | | */ |
| | | @Override |
| | | public Set<String> getMenuPermission(Long userId) { |
| | | Set<String> perms = new HashSet<>(); |
| | | // 管理员拥有所有权限 |
| | | if (LoginHelper.isSuperAdmin(userId)) { |
| | | perms.add("*:*:*"); |
| | | } else { |
| | | perms.addAll(menuService.selectMenuPermsByUserId(userId)); |
| | | } |
| | | return perms; |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.SysPost; |
| | | import org.dromara.system.domain.SysUserPost; |
| | | import org.dromara.system.domain.bo.SysPostBo; |
| | | import org.dromara.system.domain.vo.SysPostVo; |
| | | import org.dromara.system.mapper.SysPostMapper; |
| | | import org.dromara.system.mapper.SysUserPostMapper; |
| | | import org.dromara.system.service.ISysPostService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 岗位信息 服务层处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysPostServiceImpl implements ISysPostService { |
| | | |
| | | private final SysPostMapper baseMapper; |
| | | private final SysUserPostMapper userPostMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysPostVo> selectPagePostList(SysPostBo post, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysPost> lqw = buildQueryWrapper(post); |
| | | Page<SysPostVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | | * 查询岗位信息集合 |
| | | * |
| | | * @param post 岗位信息 |
| | | * @return 岗位信息集合 |
| | | */ |
| | | @Override |
| | | public List<SysPostVo> selectPostList(SysPostBo post) { |
| | | LambdaQueryWrapper<SysPost> lqw = buildQueryWrapper(post); |
| | | return baseMapper.selectVoList(lqw); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<SysPost> buildQueryWrapper(SysPostBo bo) { |
| | | LambdaQueryWrapper<SysPost> lqw = Wrappers.lambdaQuery(); |
| | | lqw.like(StringUtils.isNotBlank(bo.getPostCode()), SysPost::getPostCode, bo.getPostCode()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getPostName()), SysPost::getPostName, bo.getPostName()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysPost::getStatus, bo.getStatus()); |
| | | lqw.orderByAsc(SysPost::getPostSort); |
| | | return lqw; |
| | | } |
| | | |
| | | /** |
| | | * 查询所有岗位 |
| | | * |
| | | * @return 岗位列表 |
| | | */ |
| | | @Override |
| | | public List<SysPostVo> selectPostAll() { |
| | | return baseMapper.selectVoList(new QueryWrapper<>()); |
| | | } |
| | | |
| | | /** |
| | | * 通过岗位ID查询岗位信息 |
| | | * |
| | | * @param postId 岗位ID |
| | | * @return 角色对象信息 |
| | | */ |
| | | @Override |
| | | public SysPostVo selectPostById(Long postId) { |
| | | return baseMapper.selectVoById(postId); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户ID获取岗位选择框列表 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 选中岗位ID列表 |
| | | */ |
| | | @Override |
| | | public List<Long> selectPostListByUserId(Long userId) { |
| | | return baseMapper.selectPostListByUserId(userId); |
| | | } |
| | | |
| | | /** |
| | | * 校验岗位名称是否唯一 |
| | | * |
| | | * @param post 岗位信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean checkPostNameUnique(SysPostBo post) { |
| | | boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>() |
| | | .eq(SysPost::getPostName, post.getPostName()) |
| | | .ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId())); |
| | | return !exist; |
| | | } |
| | | |
| | | /** |
| | | * 校验岗位编码是否唯一 |
| | | * |
| | | * @param post 岗位信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean checkPostCodeUnique(SysPostBo post) { |
| | | boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>() |
| | | .eq(SysPost::getPostCode, post.getPostCode()) |
| | | .ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId())); |
| | | return !exist; |
| | | } |
| | | |
| | | /** |
| | | * 通过岗位ID查询岗位使用数量 |
| | | * |
| | | * @param postId 岗位ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public long countUserPostById(Long postId) { |
| | | return userPostMapper.selectCount(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getPostId, postId)); |
| | | } |
| | | |
| | | /** |
| | | * 删除岗位信息 |
| | | * |
| | | * @param postId 岗位ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deletePostById(Long postId) { |
| | | return baseMapper.deleteById(postId); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除岗位信息 |
| | | * |
| | | * @param postIds 需要删除的岗位ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deletePostByIds(Long[] postIds) { |
| | | for (Long postId : postIds) { |
| | | SysPost post = baseMapper.selectById(postId); |
| | | if (countUserPostById(postId) > 0) { |
| | | throw new ServiceException(String.format("%1$s已分配,不能删除!", post.getPostName())); |
| | | } |
| | | } |
| | | return baseMapper.deleteBatchIds(Arrays.asList(postIds)); |
| | | } |
| | | |
| | | /** |
| | | * 新增保存岗位信息 |
| | | * |
| | | * @param bo 岗位信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertPost(SysPostBo bo) { |
| | | SysPost post = MapstructUtils.convert(bo, SysPost.class); |
| | | return baseMapper.insert(post); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存岗位信息 |
| | | * |
| | | * @param bo 岗位信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updatePost(SysPostBo bo) { |
| | | SysPost post = MapstructUtils.convert(bo, SysPost.class); |
| | | return baseMapper.updateById(post); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.dev33.satoken.exception.NotLoginException; |
| | | import cn.dev33.satoken.stp.StpUtil; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.TenantConstants; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StreamUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.satoken.utils.LoginHelper; |
| | | import org.dromara.system.api.model.LoginUser; |
| | | import org.dromara.system.domain.SysRole; |
| | | import org.dromara.system.domain.SysRoleDept; |
| | | import org.dromara.system.domain.SysRoleMenu; |
| | | import org.dromara.system.domain.SysUserRole; |
| | | import org.dromara.system.domain.bo.SysRoleBo; |
| | | import org.dromara.system.domain.vo.SysRoleVo; |
| | | import org.dromara.system.mapper.SysRoleDeptMapper; |
| | | import org.dromara.system.mapper.SysRoleMapper; |
| | | import org.dromara.system.mapper.SysRoleMenuMapper; |
| | | import org.dromara.system.mapper.SysUserRoleMapper; |
| | | import org.dromara.system.service.ISysRoleService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 角色 业务层处理 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysRoleServiceImpl implements ISysRoleService { |
| | | |
| | | private final SysRoleMapper baseMapper; |
| | | private final SysRoleMenuMapper roleMenuMapper; |
| | | private final SysUserRoleMapper userRoleMapper; |
| | | private final SysRoleDeptMapper roleDeptMapper; |
| | | |
| | | @Override |
| | | public TableDataInfo<SysRoleVo> selectPageRoleList(SysRoleBo role, PageQuery pageQuery) { |
| | | Page<SysRoleVo> page = baseMapper.selectPageRoleList(pageQuery.build(), this.buildQueryWrapper(role)); |
| | | return TableDataInfo.build(page); |
| | | } |
| | | |
| | | /** |
| | | * 根据条件分页查询角色数据 |
| | | * |
| | | * @param role 角色信息 |
| | | * @return 角色数据集合信息 |
| | | */ |
| | | @Override |
| | | public List<SysRoleVo> selectRoleList(SysRoleBo role) { |
| | | return baseMapper.selectRoleList(this.buildQueryWrapper(role)); |
| | | } |
| | | |
| | | private Wrapper<SysRole> buildQueryWrapper(SysRoleBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | QueryWrapper<SysRole> wrapper = Wrappers.query(); |
| | | wrapper.eq("r.del_flag", UserConstants.ROLE_NORMAL) |
| | | .eq(ObjectUtil.isNotNull(bo.getRoleId()), "r.role_id", bo.getRoleId()) |
| | | .like(StringUtils.isNotBlank(bo.getRoleName()), "r.role_name", bo.getRoleName()) |
| | | .eq(StringUtils.isNotBlank(bo.getStatus()), "r.status", bo.getStatus()) |
| | | .like(StringUtils.isNotBlank(bo.getRoleKey()), "r.role_key", bo.getRoleKey()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | "r.create_time", params.get("beginTime"), params.get("endTime")) |
| | | .orderByAsc("r.role_sort").orderByAsc("r.create_time");; |
| | | return wrapper; |
| | | } |
| | | |
| | | /** |
| | | * 根据用户ID查询角色 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 角色列表 |
| | | */ |
| | | @Override |
| | | public List<SysRoleVo> selectRolesByUserId(Long userId) { |
| | | List<SysRoleVo> userRoles = baseMapper.selectRolePermissionByUserId(userId); |
| | | List<SysRoleVo> roles = selectRoleAll(); |
| | | for (SysRoleVo role : roles) { |
| | | for (SysRoleVo userRole : userRoles) { |
| | | if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) { |
| | | role.setFlag(true); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return roles; |
| | | } |
| | | |
| | | /** |
| | | * 根据用户ID查询权限 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 权限列表 |
| | | */ |
| | | @Override |
| | | public Set<String> selectRolePermissionByUserId(Long userId) { |
| | | List<SysRoleVo> perms = baseMapper.selectRolePermissionByUserId(userId); |
| | | Set<String> permsSet = new HashSet<>(); |
| | | for (SysRoleVo perm : perms) { |
| | | if (ObjectUtil.isNotNull(perm)) { |
| | | permsSet.addAll(StringUtils.splitList(perm.getRoleKey().trim())); |
| | | } |
| | | } |
| | | return permsSet; |
| | | } |
| | | |
| | | /** |
| | | * 查询所有角色 |
| | | * |
| | | * @return 角色列表 |
| | | */ |
| | | @Override |
| | | public List<SysRoleVo> selectRoleAll() { |
| | | return this.selectRoleList(new SysRoleBo()); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户ID获取角色选择框列表 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 选中角色ID列表 |
| | | */ |
| | | @Override |
| | | public List<Long> selectRoleListByUserId(Long userId) { |
| | | return baseMapper.selectRoleListByUserId(userId); |
| | | } |
| | | |
| | | /** |
| | | * 通过角色ID查询角色 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 角色对象信息 |
| | | */ |
| | | @Override |
| | | public SysRoleVo selectRoleById(Long roleId) { |
| | | return baseMapper.selectRoleById(roleId); |
| | | } |
| | | |
| | | /** |
| | | * 校验角色名称是否唯一 |
| | | * |
| | | * @param role 角色信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean checkRoleNameUnique(SysRoleBo role) { |
| | | boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleName, role.getRoleName()) |
| | | .ne(ObjectUtil.isNotNull(role.getRoleId()), SysRole::getRoleId, role.getRoleId())); |
| | | return !exist; |
| | | } |
| | | |
| | | /** |
| | | * 校验角色权限是否唯一 |
| | | * |
| | | * @param role 角色信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean checkRoleKeyUnique(SysRoleBo role) { |
| | | boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleKey, role.getRoleKey()) |
| | | .ne(ObjectUtil.isNotNull(role.getRoleId()), SysRole::getRoleId, role.getRoleId())); |
| | | return !exist; |
| | | } |
| | | |
| | | /** |
| | | * 校验角色是否允许操作 |
| | | * |
| | | * @param role 角色信息 |
| | | */ |
| | | @Override |
| | | public void checkRoleAllowed(SysRoleBo role) { |
| | | if (ObjectUtil.isNotNull(role.getRoleId()) && LoginHelper.isSuperAdmin(role.getRoleId())) { |
| | | throw new ServiceException("不允许操作超级管理员角色"); |
| | | } |
| | | String[] keys = new String[]{TenantConstants.SUPER_ADMIN_ROLE_KEY, TenantConstants.TENANT_ADMIN_ROLE_KEY}; |
| | | // 新增不允许使用 管理员标识符 |
| | | if (ObjectUtil.isNull(role.getRoleId()) |
| | | && StringUtils.equalsAny(role.getRoleKey(), keys)) { |
| | | throw new ServiceException("不允许使用系统内置管理员角色标识符!"); |
| | | } |
| | | // 修改不允许修改 管理员标识符 |
| | | if (ObjectUtil.isNotNull(role.getRoleId())) { |
| | | SysRole sysRole = baseMapper.selectById(role.getRoleId()); |
| | | // 如果标识符不相等 判断为修改了管理员标识符 |
| | | if (!StringUtils.equals(sysRole.getRoleKey(), role.getRoleKey())) { |
| | | if (StringUtils.equalsAny(sysRole.getRoleKey(), keys)) { |
| | | throw new ServiceException("不允许修改系统内置管理员角色标识符!"); |
| | | } else if (StringUtils.equalsAny(role.getRoleKey(), keys)) { |
| | | throw new ServiceException("不允许使用系统内置管理员角色标识符!"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 校验角色是否有数据权限 |
| | | * |
| | | * @param roleId 角色id |
| | | */ |
| | | @Override |
| | | public void checkRoleDataScope(Long roleId) { |
| | | if (ObjectUtil.isNull(roleId)) { |
| | | return; |
| | | } |
| | | if (LoginHelper.isSuperAdmin()) { |
| | | return; |
| | | } |
| | | List<SysRoleVo> roles = this.selectRoleList(new SysRoleBo(roleId)); |
| | | if (CollUtil.isEmpty(roles)) { |
| | | throw new ServiceException("没有权限访问角色数据!"); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 通过角色ID查询角色使用数量 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public long countUserRoleByRoleId(Long roleId) { |
| | | return userRoleMapper.selectCount(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getRoleId, roleId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增保存角色信息 |
| | | * |
| | | * @param bo 角色信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int insertRole(SysRoleBo bo) { |
| | | SysRole role = MapstructUtils.convert(bo, SysRole.class); |
| | | // 新增角色信息 |
| | | baseMapper.insert(role); |
| | | bo.setRoleId(role.getRoleId()); |
| | | return insertRoleMenu(bo); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存角色信息 |
| | | * |
| | | * @param bo 角色信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int updateRole(SysRoleBo bo) { |
| | | SysRole role = MapstructUtils.convert(bo, SysRole.class); |
| | | // 修改角色信息 |
| | | baseMapper.updateById(role); |
| | | // 删除角色与菜单关联 |
| | | roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, role.getRoleId())); |
| | | return insertRoleMenu(bo); |
| | | } |
| | | |
| | | /** |
| | | * 修改角色状态 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param status 角色状态 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateRoleStatus(Long roleId, String status) { |
| | | if (UserConstants.ROLE_DISABLE.equals(status) && this.countUserRoleByRoleId(roleId) > 0) { |
| | | throw new ServiceException("角色已分配,不能禁用!"); |
| | | } |
| | | return baseMapper.update(null, |
| | | new LambdaUpdateWrapper<SysRole>() |
| | | .set(SysRole::getStatus, status) |
| | | .eq(SysRole::getRoleId, roleId)); |
| | | } |
| | | |
| | | /** |
| | | * 修改数据权限信息 |
| | | * |
| | | * @param bo 角色信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int authDataScope(SysRoleBo bo) { |
| | | SysRole role = MapstructUtils.convert(bo, SysRole.class); |
| | | // 修改角色信息 |
| | | baseMapper.updateById(role); |
| | | // 删除角色与部门关联 |
| | | roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().eq(SysRoleDept::getRoleId, role.getRoleId())); |
| | | // 新增角色和部门信息(数据权限) |
| | | return insertRoleDept(bo); |
| | | } |
| | | |
| | | /** |
| | | * 新增角色菜单信息 |
| | | * |
| | | * @param role 角色对象 |
| | | */ |
| | | private int insertRoleMenu(SysRoleBo role) { |
| | | int rows = 1; |
| | | // 新增用户与角色管理 |
| | | List<SysRoleMenu> list = new ArrayList<SysRoleMenu>(); |
| | | for (Long menuId : role.getMenuIds()) { |
| | | SysRoleMenu rm = new SysRoleMenu(); |
| | | rm.setRoleId(role.getRoleId()); |
| | | rm.setMenuId(menuId); |
| | | list.add(rm); |
| | | } |
| | | if (list.size() > 0) { |
| | | rows = roleMenuMapper.insertBatch(list) ? list.size() : 0; |
| | | } |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * 新增角色部门信息(数据权限) |
| | | * |
| | | * @param role 角色对象 |
| | | */ |
| | | private int insertRoleDept(SysRoleBo role) { |
| | | int rows = 1; |
| | | // 新增角色与部门(数据权限)管理 |
| | | List<SysRoleDept> list = new ArrayList<SysRoleDept>(); |
| | | for (Long deptId : role.getDeptIds()) { |
| | | SysRoleDept rd = new SysRoleDept(); |
| | | rd.setRoleId(role.getRoleId()); |
| | | rd.setDeptId(deptId); |
| | | list.add(rd); |
| | | } |
| | | if (list.size() > 0) { |
| | | rows = roleDeptMapper.insertBatch(list) ? list.size() : 0; |
| | | } |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * 通过角色ID删除角色 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int deleteRoleById(Long roleId) { |
| | | // 删除角色与菜单关联 |
| | | roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, roleId)); |
| | | // 删除角色与部门关联 |
| | | roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().eq(SysRoleDept::getRoleId, roleId)); |
| | | return baseMapper.deleteById(roleId); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除角色信息 |
| | | * |
| | | * @param roleIds 需要删除的角色ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int deleteRoleByIds(Long[] roleIds) { |
| | | for (Long roleId : roleIds) { |
| | | SysRole role = baseMapper.selectById(roleId); |
| | | checkRoleAllowed(BeanUtil.toBean(role, SysRoleBo.class)); |
| | | checkRoleDataScope(roleId); |
| | | if (countUserRoleByRoleId(roleId) > 0) { |
| | | throw new ServiceException(String.format("%1$s已分配,不能删除!", role.getRoleName())); |
| | | } |
| | | } |
| | | List<Long> ids = Arrays.asList(roleIds); |
| | | // 删除角色与菜单关联 |
| | | roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, ids)); |
| | | // 删除角色与部门关联 |
| | | roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().in(SysRoleDept::getRoleId, ids)); |
| | | return baseMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | /** |
| | | * 取消授权用户角色 |
| | | * |
| | | * @param userRole 用户和角色关联信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteAuthUser(SysUserRole userRole) { |
| | | int rows = userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>() |
| | | .eq(SysUserRole::getRoleId, userRole.getRoleId()) |
| | | .eq(SysUserRole::getUserId, userRole.getUserId())); |
| | | if (rows > 0) { |
| | | cleanOnlineUserByRole(userRole.getRoleId()); |
| | | } |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * 批量取消授权用户角色 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param userIds 需要取消授权的用户数据ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteAuthUsers(Long roleId, Long[] userIds) { |
| | | int rows = userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>() |
| | | .eq(SysUserRole::getRoleId, roleId) |
| | | .in(SysUserRole::getUserId, Arrays.asList(userIds))); |
| | | if (rows > 0) { |
| | | cleanOnlineUserByRole(roleId); |
| | | } |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * 批量选择授权用户角色 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param userIds 需要授权的用户数据ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertAuthUsers(Long roleId, Long[] userIds) { |
| | | // 新增用户与角色管理 |
| | | int rows = 1; |
| | | List<SysUserRole> list = StreamUtils.toList(List.of(userIds), userId -> { |
| | | SysUserRole ur = new SysUserRole(); |
| | | ur.setUserId(userId); |
| | | ur.setRoleId(roleId); |
| | | return ur; |
| | | }); |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | rows = userRoleMapper.insertBatch(list) ? list.size() : 0; |
| | | } |
| | | if (rows > 0) { |
| | | cleanOnlineUserByRole(roleId); |
| | | } |
| | | return rows; |
| | | } |
| | | |
| | | @Override |
| | | public void cleanOnlineUserByRole(Long roleId) { |
| | | // 如果角色未绑定用户 直接返回 |
| | | Long num = userRoleMapper.selectCount(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getRoleId, roleId)); |
| | | if (num == 0) { |
| | | return; |
| | | } |
| | | List<String> keys = StpUtil.searchTokenValue("", 0, -1, false); |
| | | if (CollUtil.isEmpty(keys)) { |
| | | return; |
| | | } |
| | | // 角色关联的在线用户量过大会导致redis阻塞卡顿 谨慎操作 |
| | | keys.parallelStream().forEach(key -> { |
| | | String token = StringUtils.substringAfterLast(key, ":"); |
| | | // 如果已经过期则跳过 |
| | | if (StpUtil.stpLogic.getTokenActiveTimeoutByToken(token) < -1) { |
| | | return; |
| | | } |
| | | LoginUser loginUser = LoginHelper.getLoginUser(token); |
| | | if (loginUser.getRoles().stream().anyMatch(r -> r.getRoleId().equals(roleId))) { |
| | | try { |
| | | StpUtil.logoutByTokenValue(token); |
| | | } catch (NotLoginException ignored) { |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.dev33.satoken.stp.StpUtil; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.satoken.utils.LoginHelper; |
| | | import org.dromara.common.sensitive.core.SensitiveService; |
| | | import org.dromara.common.tenant.helper.TenantHelper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 脱敏服务 |
| | | * 默认管理员不过滤 |
| | | * 需自行根据业务重写实现 |
| | | * |
| | | * @author Lion Li |
| | | * @version 3.6.0 |
| | | */ |
| | | @Service |
| | | public class SysSensitiveServiceImpl implements SensitiveService { |
| | | |
| | | /** |
| | | * 是否脱敏 |
| | | */ |
| | | @Override |
| | | public boolean isSensitive(String roleKey, String perms) { |
| | | if (!LoginHelper.isLogin()) { |
| | | return true; |
| | | } |
| | | boolean roleExist = StringUtils.isNotEmpty(roleKey); |
| | | boolean permsExist = StringUtils.isNotEmpty(perms); |
| | | if (roleExist && permsExist) { |
| | | if (StpUtil.hasRole(roleKey) && StpUtil.hasPermission(perms)) { |
| | | return false; |
| | | } |
| | | } else if (roleExist && StpUtil.hasRole(roleKey)) { |
| | | return false; |
| | | } else if (permsExist && StpUtil.hasPermission(perms)) { |
| | | return false; |
| | | } |
| | | |
| | | if (TenantHelper.isEnable()) { |
| | | return !LoginHelper.isSuperAdmin() && !LoginHelper.isTenantAdmin(); |
| | | } |
| | | return !LoginHelper.isSuperAdmin(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.system.domain.SysSocial; |
| | | import org.dromara.system.domain.bo.SysSocialBo; |
| | | import org.dromara.system.domain.vo.SysSocialVo; |
| | | import org.dromara.system.mapper.SysSocialMapper; |
| | | import org.dromara.system.service.ISysSocialService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 社会化关系Service业务层处理 |
| | | * |
| | | * @author thiszhc |
| | | * @date 2023-06-12 |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysSocialServiceImpl implements ISysSocialService { |
| | | |
| | | private final SysSocialMapper baseMapper; |
| | | |
| | | |
| | | /** |
| | | * 查询社会化关系 |
| | | */ |
| | | @Override |
| | | public SysSocialVo queryById(String id) { |
| | | return baseMapper.selectVoById(id); |
| | | } |
| | | |
| | | /** |
| | | * 授权列表 |
| | | */ |
| | | @Override |
| | | public List<SysSocialVo> queryList() { |
| | | return baseMapper.selectVoList(); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysSocialVo> queryListByUserId(Long userId) { |
| | | return baseMapper.selectVoList(new LambdaQueryWrapper<SysSocial>().eq(SysSocial::getUserId, userId)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增社会化关系 |
| | | */ |
| | | @Override |
| | | public Boolean insertByBo(SysSocialBo bo) { |
| | | SysSocial add = MapstructUtils.convert(bo, SysSocial.class); |
| | | validEntityBeforeSave(add); |
| | | boolean flag = baseMapper.insert(add) > 0; |
| | | if (flag) { |
| | | if (add != null) { |
| | | bo.setId(add.getId()); |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * 更新社会化关系 |
| | | */ |
| | | @Override |
| | | public Boolean updateByBo(SysSocialBo bo) { |
| | | SysSocial update = MapstructUtils.convert(bo, SysSocial.class); |
| | | validEntityBeforeSave(update); |
| | | return baseMapper.updateById(update) > 0; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存前的数据校验 |
| | | */ |
| | | private void validEntityBeforeSave(SysSocial entity) { |
| | | //TODO 做一些数据校验,如唯一约束 |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除社会化关系 |
| | | */ |
| | | @Override |
| | | public Boolean deleteWithValidById(Long id) { |
| | | return baseMapper.deleteById(id) > 0; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据 authId 查询用户信息 |
| | | * |
| | | * @param authId 认证id |
| | | * @return 授权信息 |
| | | */ |
| | | @Override |
| | | public List<SysSocialVo> selectByAuthId(String authId) { |
| | | return baseMapper.selectVoList(new LambdaQueryWrapper<SysSocial>().eq(SysSocial::getAuthId, authId)); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.TenantConstants; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.system.domain.SysTenant; |
| | | import org.dromara.system.domain.SysTenantPackage; |
| | | import org.dromara.system.domain.bo.SysTenantPackageBo; |
| | | import org.dromara.system.domain.vo.SysTenantPackageVo; |
| | | import org.dromara.system.mapper.SysTenantMapper; |
| | | import org.dromara.system.mapper.SysTenantPackageMapper; |
| | | import org.dromara.system.service.ISysTenantPackageService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 租户套餐Service业务层处理 |
| | | * |
| | | * @author Michelle.Chung |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class SysTenantPackageServiceImpl implements ISysTenantPackageService { |
| | | |
| | | private final SysTenantPackageMapper baseMapper; |
| | | private final SysTenantMapper tenantMapper; |
| | | |
| | | /** |
| | | * 查询租户套餐 |
| | | */ |
| | | @Override |
| | | public SysTenantPackageVo queryById(Long packageId){ |
| | | return baseMapper.selectVoById(packageId); |
| | | } |
| | | |
| | | /** |
| | | * 查询租户套餐列表 |
| | | */ |
| | | @Override |
| | | public TableDataInfo<SysTenantPackageVo> queryPageList(SysTenantPackageBo bo, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysTenantPackage> lqw = buildQueryWrapper(bo); |
| | | Page<SysTenantPackageVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(result); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysTenantPackageVo> selectList() { |
| | | return baseMapper.selectVoList(new LambdaQueryWrapper<SysTenantPackage>() |
| | | .eq(SysTenantPackage::getStatus, TenantConstants.NORMAL)); |
| | | } |
| | | |
| | | /** |
| | | * 查询租户套餐列表 |
| | | */ |
| | | @Override |
| | | public List<SysTenantPackageVo> queryList(SysTenantPackageBo bo) { |
| | | LambdaQueryWrapper<SysTenantPackage> lqw = buildQueryWrapper(bo); |
| | | return baseMapper.selectVoList(lqw); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<SysTenantPackage> buildQueryWrapper(SysTenantPackageBo bo) { |
| | | LambdaQueryWrapper<SysTenantPackage> lqw = Wrappers.lambdaQuery(); |
| | | lqw.like(StringUtils.isNotBlank(bo.getPackageName()), SysTenantPackage::getPackageName, bo.getPackageName()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysTenantPackage::getStatus, bo.getStatus()); |
| | | lqw.orderByAsc(SysTenantPackage::getPackageId); |
| | | return lqw; |
| | | } |
| | | |
| | | /** |
| | | * 新增租户套餐 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean insertByBo(SysTenantPackageBo bo) { |
| | | SysTenantPackage add = MapstructUtils.convert(bo, SysTenantPackage.class); |
| | | // 保存菜单id |
| | | List<Long> menuIds = Arrays.asList(bo.getMenuIds()); |
| | | if (CollUtil.isNotEmpty(menuIds)) { |
| | | add.setMenuIds(StringUtils.join(menuIds, ", ")); |
| | | } else { |
| | | add.setMenuIds(""); |
| | | } |
| | | boolean flag = baseMapper.insert(add) > 0; |
| | | if (flag) { |
| | | bo.setPackageId(add.getPackageId()); |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * 修改租户套餐 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean updateByBo(SysTenantPackageBo bo) { |
| | | SysTenantPackage update = MapstructUtils.convert(bo, SysTenantPackage.class); |
| | | // 保存菜单id |
| | | List<Long> menuIds = Arrays.asList(bo.getMenuIds()); |
| | | if (CollUtil.isNotEmpty(menuIds)) { |
| | | update.setMenuIds(StringUtils.join(menuIds, ", ")); |
| | | } else { |
| | | update.setMenuIds(""); |
| | | } |
| | | return baseMapper.updateById(update) > 0; |
| | | } |
| | | |
| | | /** |
| | | * 修改套餐状态 |
| | | * |
| | | * @param bo 套餐信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updatePackageStatus(SysTenantPackageBo bo) { |
| | | SysTenantPackage tenantPackage = MapstructUtils.convert(bo, SysTenantPackage.class); |
| | | return baseMapper.updateById(tenantPackage); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除租户套餐 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
| | | if(isValid){ |
| | | boolean exists = tenantMapper.exists(new LambdaQueryWrapper<SysTenant>().in(SysTenant::getPackageId, ids)); |
| | | if (exists) { |
| | | throw new ServiceException("租户套餐已被使用"); |
| | | } |
| | | } |
| | | return baseMapper.deleteBatchIds(ids) > 0; |
| | | } |
| | | } |
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantServiceImpl.java
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java
ruoyi-modules/ruoyi-system/src/main/resources/application.yml
ruoyi-modules/ruoyi-system/src/main/resources/banner.txt
ruoyi-modules/ruoyi-system/src/main/resources/logback-plus.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/package-info.md
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysClientMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDictDataMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysLogininforMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysSocialMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysTenantMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysTenantPackageMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml
ruoyi-modules/ruoyi-system/src/main/resources/spy.properties |