feat: 代码生成增加本地保存和创建菜单功能

This commit is contained in:
qiufeng
2024-04-23 14:32:35 +08:00
parent 56d54b1dd9
commit ad95418b5c
54 changed files with 395 additions and 242 deletions
+3 -2
View File
@@ -48,9 +48,10 @@
/tomcat/
/mf-start/mf-start-web/target/
/mf-start/mf-start-openai/target/
# 忽略 .iml 文件
*.iml
/mf-business/mf-nocode/target/
/mf-start/mf-start-nocode/target/
/mf-common/mf-common-bi/target/
/mf-common/mf-common-api/target/
/mf-common/mf-common-sys/target/
# 忽略 .iml 文件
*.iml
+1 -1
View File
@@ -37,7 +37,7 @@ INSERT INTO `config_info` VALUES (1, 'application-dev.yml', 'DEFAULT_GROUP', 'sp
INSERT INTO `config_info` VALUES (2, 'mf-gateway-dev.yml', 'DEFAULT_GROUP', 'spring:\n cloud:\n gateway:\n globalcors:\n cors-configurations:\n \'[/**]\':\n max-age: 3600\n allowed-origin-patterns: \"*\"\n allowed-headers: \"*\"\n allow-credentials: true\n allowed-methods:\n - GET\n - POST\n - DELETE\n - PUT\n - OPTION\n discovery:\n locator:\n lowerCaseServiceId: true\n enabled: true\n routes:\n # 认证中心\n - id: mf-oauth\n uri: lb://mf-oauth\n predicates:\n - Path=/oauth2/**\n filters:\n - CacheFilter\n # 验证码处理\n - CheckCodeFilter\n - StripPrefix=1\n # 测试中心\n - id: mf-test\n uri: lb://mf-test\n predicates:\n - Path=/test/**\n filters:\n - StripPrefix=1\n - id: mf-sys\n uri: lb://mf-sys\n predicates:\n - Path=/sys/**\n filters:\n - StripPrefix=1\n - id: mf-web\n uri: lb://mf-web\n predicates:\n - Path=/web/**\n filters:\n - StripPrefix=1\n - id: mf-storage\n uri: lb://mf-storage\n predicates:\n - Path=/storage/**\n filters:\n - StripPrefix=1\n - id: mf-scheduler\n uri: lb://mf-scheduler\n predicates:\n - Path=/scheduler/**\n filters:\n - StripPrefix=1\n - id: mf-openai\n uri: lb://mf-openai\n predicates:\n - Path=/ai/**\n filters:\n - StripPrefix=1\n - id: mf-nocode\n uri: lb://mf-nocode\n predicates:\n - Path=/nocode/**\n filters:\n - StripPrefix=1\n# 安全配置\nsecurity:\n # 验证码\n captcha:\n enabled: true\n type: math\n # 网关校验直接返回\n gatewayCheckCaptcha:\n # - /oauth2/authorize\n # 网关校验,自己服务返回\n selfCheckCaptcha:\n - /oauth2/authorize?loginType=user_password\n # 防止XSS攻击\n xss:\n enabled: true\n excludeUrls:\n # 不校验白名单\n ignore:\n whites:\n - /oauth2/user/revoke\n - /oauth2/accessToken\n - /oauth2/authorize\n - /oauth2/sendMsg\n - /oauth2/qrCodeLogin/*\n - /oauth2/wx/bind/**\n - /oauth2/static/**\n - /storage/file/*.*\n - /code/**\n - /test/**\n - /*/v3/api-docs\n# swagger configuration\nspringdoc: \n webjars: \n # 设置为空,不要前缀,不配置这个就需要多加一层路径`/webjars`->`http:host:网关ip/webjars/swagger-ui/index.html`\n prefix:', 'ff36cf2372aeb6e03aa79788dbaadf18', '2023-01-11 12:10:11', '2024-04-19 10:53:55', NULL, '0:0:0:0:0:0:0:1', '', '', '', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (3, 'mf-oauth-dev.yml', 'DEFAULT_GROUP', 'swagger:\n title: \'摸鱼认证中心\'\n prefix: /oauth2\n# mybatis配置\nmybatis-plus:\n # 搜索指定包别名\n type-aliases-package: cn.com.mfish.oauth.mapper\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\n mapper-locations: classpath*:cn/com/mfish/**/mapper/**/*Mapper.xml\n global-config:\n # 关闭MP3.0自带的banner\n banner: false\n db-config:\n #主键类型 0:\"数据库ID自增\",1:\"该类型为未设置主键类型\", 2:\"用户输入ID\",3:\"全局唯一ID (数字类型唯一ID)\", 4:\"全局唯一ID UUID\",5:\"字符串全局唯一ID (idWorker 的字符串表示)\";\n #id-type: 0\n # 默认数据库表下划线命名\n table-underline: true\n #逻辑删除 删除前\n logic-not-delete-value: 0\n #逻辑删除 删除后\n logic-delete-value: 1\n configuration:\n # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用\n #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n # 返回类型为Map,显示null对应的字段\n call-setters-on-nulls: true\n map-underscore-to-camel-case: true\n auto-mapping-behavior: full\n jdbc-type-for-null:\nspring: \n thymeleaf:\n cache: false\n datasource:\n druid:\n stat-view-servlet:\n enabled: true\n loginUsername: admin\n loginPassword: 123456\n dynamic:\n druid:\n initial-size: 5\n min-idle: 5\n maxActive: 20\n maxWait: 60000\n timeBetweenEvictionRunsMillis: 60000\n minEvictableIdleTimeMillis: 300000\n validationQuery: SELECT 1 FROM DUAL\n testWhileIdle: true\n testOnBorrow: false\n testOnReturn: false\n poolPreparedStatements: true\n maxPoolPreparedStatementPerConnectionSize: 20\n filters: stat,slf4j\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\n datasource:\n # 主库数据源\n master:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/mf_oauth?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: 123456\n # 从库数据源\n # slave:\n # username: \n # password: \n # url: \n # driver-class-name: \n # seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭\nredisCache:\n expire: 50400\n keyPrefix: sso_cache\nredisSession:\n expire: 50400\n keyPrefix: sso_session\noauth2:\n expire:\n code: 180\n token: 21600\n refreshToken: 604800\n login:\n mutex: false\n user:\n autoCreate: false\n token:\n sm4key: 143be1ae6ee10b048f7e441cec2a9803\nwechat:\n miniapp:\n appId: wx*************e34a3\n secret: a65e*************fa222', '3cd2025470cdd2d7285599956e913e50', '2023-01-11 12:10:11', '2024-04-18 21:12:28', NULL, '0:0:0:0:0:0:0:1', '', '', '', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (4, 'sentinel-mf-gateway', 'DEFAULT_GROUP', '[\n {\n \"resource\": \"mf-oauth\",\n \"count\": 500,\n \"grade\": 1,\n \"limitApp\": \"default\",\n \"strategy\": 0,\n \"controlBehavior\": 0\n },\n {\n \"resource\": \"mf-sys\",\n \"count\": 500,\n \"grade\": 1,\n \"limitApp\": \"default\",\n \"strategy\": 0,\n \"controlBehavior\": 0\n },\n {\n \"resource\": \"mf-storage\",\n \"count\": 100,\n \"grade\": 1,\n \"limitApp\": \"default\",\n \"strategy\": 0,\n \"controlBehavior\": 0\n },\n {\n \"resource\": \"mf-scheduler\",\n \"count\": 100,\n \"grade\": 1,\n \"limitApp\": \"default\",\n \"strategy\": 0,\n \"controlBehavior\": 0\n }\n]', '07a23c3f1d6580115132bd0ba7897504', '2023-01-11 12:10:11', '2024-01-31 23:07:56', NULL, '0:0:0:0:0:0:0:1', '', '', '', '', '', 'text', '', '');
INSERT INTO `config_info` VALUES (6, 'mf-sys-dev.yml', 'DEFAULT_GROUP', 'swagger:\n title: \'摸鱼系统业务中心\'\n prefix: /sys\n# mybatis配置\nmybatis-plus:\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\n mapper-locations: classpath*:cn/com/mfish/sys/mapper/**/*Mapper.xml\n global-config:\n # 关闭MP3.0自带的banner\n banner: false\n db-config:\n #主键类型 0:\"数据库ID自增\",1:\"该类型为未设置主键类型\", 2:\"用户输入ID\",3:\"全局唯一ID (数字类型唯一ID)\", 4:\"全局唯一ID UUID\",5:\"字符串全局唯一ID (idWorker 的字符串表示)\";\n #id-type: 0\n # 默认数据库表下划线命名\n table-underline: true\n #逻辑删除 删除前\n logic-not-delete-value: 0\n #逻辑删除 删除后\n logic-delete-value: 1\n configuration:\n # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用\n #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n # 返回类型为Map,显示null对应的字段\n call-setters-on-nulls: true\n map-underscore-to-camel-case: true\n auto-mapping-behavior: full\n jdbc-type-for-null:\nspring: \n datasource:\n druid:\n stat-view-servlet:\n enabled: true\n loginUsername: admin\n loginPassword: 123456\n dynamic:\n druid:\n initial-size: 5\n min-idle: 5\n maxActive: 20\n maxWait: 60000\n timeBetweenEvictionRunsMillis: 60000\n minEvictableIdleTimeMillis: 300000\n validationQuery: SELECT 1 FROM DUAL\n testWhileIdle: true\n testOnBorrow: false\n testOnReturn: false\n poolPreparedStatements: true\n maxPoolPreparedStatementPerConnectionSize: 20\n filters: stat,slf4j\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\n datasource:\n # 主库数据源\n master:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/mf_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: 123456\n # 从库数据源\n # slave:\n # username: \n # password: \n # url: \n # driver-class-name: \n # seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭\ncode:\n template:\n keys:\n - ${packageName}/controller/${entityName}Controller.java.ftl\n - ${packageName}/entity/${entityName}.java.ftl\n - ${packageName}/mapper/${entityName}Mapper.java.ftl\n - ${packageName}/mapper/xml/${entityName}Mapper.xml.ftl\n - ${packageName}/req/Req${entityName}.java.ftl\n - ${packageName}/service/${entityName}Service.java.ftl\n - ${packageName}/service/impl/${entityName}ServiceImpl.java.ftl\n - mfish-nocode-view/src/views/${apiPrefix}/${entityName#kebab-case}/${entityName#uncap_first}.data.ts.ftl\n - mfish-nocode-view/src/views/${apiPrefix}/${entityName#kebab-case}/${entityName}Modal.vue.ftl\n - mfish-nocode-view/src/views/${apiPrefix}/${entityName#kebab-case}/index.vue.ftl\n - mfish-nocode-view/src/api/${apiPrefix}/model/${entityName}Model.ts.ftl\n - mfish-nocode-view/src/api/${apiPrefix}/${entityName}.ts.ftl\n path: template\n savePath: D:/mfish', '4141703e554e5fbd3f71f6cdf6365a5e', '2023-01-11 12:10:11', '2024-04-18 21:12:39', NULL, '0:0:0:0:0:0:0:1', '', '', '', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (6, 'mf-sys-dev.yml', 'DEFAULT_GROUP', 'swagger:\n title: \'摸鱼系统业务中心\'\n prefix: /sys\n# mybatis配置\nmybatis-plus:\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\n mapper-locations: classpath*:cn/com/mfish/sys/mapper/**/*Mapper.xml\n global-config:\n # 关闭MP3.0自带的banner\n banner: false\n db-config:\n #主键类型 0:\"数据库ID自增\",1:\"该类型为未设置主键类型\", 2:\"用户输入ID\",3:\"全局唯一ID (数字类型唯一ID)\", 4:\"全局唯一ID UUID\",5:\"字符串全局唯一ID (idWorker 的字符串表示)\";\n #id-type: 0\n # 默认数据库表下划线命名\n table-underline: true\n #逻辑删除 删除前\n logic-not-delete-value: 0\n #逻辑删除 删除后\n logic-delete-value: 1\n configuration:\n # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用\n #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n # 返回类型为Map,显示null对应的字段\n call-setters-on-nulls: true\n map-underscore-to-camel-case: true\n auto-mapping-behavior: full\n jdbc-type-for-null:\nspring: \n datasource:\n druid:\n stat-view-servlet:\n enabled: true\n loginUsername: admin\n loginPassword: 123456\n dynamic:\n druid:\n initial-size: 5\n min-idle: 5\n maxActive: 20\n maxWait: 60000\n timeBetweenEvictionRunsMillis: 60000\n minEvictableIdleTimeMillis: 300000\n validationQuery: SELECT 1 FROM DUAL\n testWhileIdle: true\n testOnBorrow: false\n testOnReturn: false\n poolPreparedStatements: true\n maxPoolPreparedStatementPerConnectionSize: 20\n filters: stat,slf4j\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\n datasource:\n # 主库数据源\n master:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/mf_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: 123456\n # 从库数据源\n # slave:\n # username: \n # password: \n # url: \n # driver-class-name: \n # seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭\ncode:\n template:\n keys:\n - src/main/java/${packageName}/controller/${entityName}Controller.java.ftl\n - src/main/java/${packageName}/entity/${entityName}.java.ftl\n - src/main/java/${packageName}/mapper/${entityName}Mapper.java.ftl\n - src/main/java/${packageName}/mapper/xml/${entityName}Mapper.xml.ftl\n - src/main/java/${packageName}/req/Req${entityName}.java.ftl\n - src/main/java/${packageName}/service/${entityName}Service.java.ftl\n - src/main/java/${packageName}/service/impl/${entityName}ServiceImpl.java.ftl\n - mfish-nocode-view/src/views/${apiPrefix}/${entityName#kebab-case}/${entityName#uncap_first}.data.ts.ftl\n - mfish-nocode-view/src/views/${apiPrefix}/${entityName#kebab-case}/${entityName}Modal.vue.ftl\n - mfish-nocode-view/src/views/${apiPrefix}/${entityName#kebab-case}/index.vue.ftl\n - mfish-nocode-view/src/api/${apiPrefix}/model/${entityName}Model.ts.ftl\n - mfish-nocode-view/src/api/${apiPrefix}/${entityName}.ts.ftl\n path: template\n savePath:\n #前端地址\n front: E:/webcode\n #后端地址(需要指定到具体模块路径)\n back: E:/javacode/mfish-nocode-pro/mf-business/mf-sys', '83a9afb77b89ef5ae4c8096218e557af', '2023-01-11 12:10:11', '2024-04-22 22:48:44', NULL, '0:0:0:0:0:0:0:1', '', '', '', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (7, 'mf-storage-dev.yml', 'DEFAULT_GROUP', 'swagger:\n title: \'摸鱼文件管理\'\n prefix: /storage\n# mybatis配置\nmybatis-plus:\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\n mapper-locations: classpath*:cn/com/mfish/storage/mapper/**/*Mapper.xml\n global-config:\n # 关闭MP3.0自带的banner\n banner: false\n db-config:\n #主键类型 0:\"数据库ID自增\",1:\"该类型为未设置主键类型\", 2:\"用户输入ID\",3:\"全局唯一ID (数字类型唯一ID)\", 4:\"全局唯一ID UUID\",5:\"字符串全局唯一ID (idWorker 的字符串表示)\";\n #id-type: 0\n # 默认数据库表下划线命名\n table-underline: true\n #逻辑删除 删除前\n logic-not-delete-value: 0\n #逻辑删除 删除后\n logic-delete-value: 1\n configuration:\n # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用\n #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n # 返回类型为Map,显示null对应的字段\n call-setters-on-nulls: true\n map-underscore-to-camel-case: true\n auto-mapping-behavior: full\n jdbc-type-for-null:\nspring: \n datasource:\n druid:\n stat-view-servlet:\n enabled: true\n loginUsername: admin\n loginPassword: 123456\n dynamic:\n druid:\n initial-size: 5\n min-idle: 5\n maxActive: 20\n maxWait: 60000\n timeBetweenEvictionRunsMillis: 60000\n minEvictableIdleTimeMillis: 300000\n validationQuery: SELECT 1 FROM DUAL\n testWhileIdle: true\n testOnBorrow: false\n testOnReturn: false\n poolPreparedStatements: true\n maxPoolPreparedStatementPerConnectionSize: 20\n filters: stat,slf4j\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\n datasource:\n # 主库数据源\n master:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/mf_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: 123456\n # 从库数据源\n # slave:\n # username: \n # password: \n # url: \n # driver-class-name: \n # seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭\nstorage:\n active: local\n address: http://localhost:8888/storage/file/\n local:\n storagePath: E:/storage\n aliyun:\n endpoint: oss-cn-hangzhou.aliyuncs.com\n accessKeyId: LTAI5***********FsgT\n accessKeySecret: ZtZGF***************JADjS2f\n bucketName: landwise\n qiniu:\n domain: http://cdn.mfish.com.cn\n accessKey: cHlX4*******************cdsexgvP\n secretKey: QPACH*******************1vEa1t4S\n bucket: mfish-nocode', '85f8ec59cc8ba5b307b681d8d95b493f', '2023-01-11 12:10:11', '2024-04-18 21:12:47', NULL, '0:0:0:0:0:0:0:1', '', '', '', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (14, 'mf-monitor-dev.yml', 'DEFAULT_GROUP', 'swagger:\n title: \'摸鱼监控中心\'\nspring: \n security:\n user:\n name: admin\n password: 123456\n boot:\n admin:\n ui:\n title: 摸鱼监控中心', 'a674bfe5ede30ec4b46115021971bc4b', '2023-01-26 15:08:30', '2023-01-27 03:58:53', 'nacos', '0:0:0:0:0:0:0:1', '', '', '', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (15, 'mf-scheduler-dev.yml', 'DEFAULT_GROUP', 'swagger:\n title: \'摸鱼调度中心\'\n prefix: /scheduler\n# mybatis配置\nmybatis-plus:\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\n mapper-locations: classpath*:cn/com/mfish/scheduler/mapper/**/*Mapper.xml\n global-config:\n # 关闭MP3.0自带的banner\n banner: false\n db-config:\n #主键类型 0:\"数据库ID自增\",1:\"该类型为未设置主键类型\", 2:\"用户输入ID\",3:\"全局唯一ID (数字类型唯一ID)\", 4:\"全局唯一ID UUID\",5:\"字符串全局唯一ID (idWorker 的字符串表示)\";\n #id-type: 0\n # 默认数据库表下划线命名\n table-underline: true\n #逻辑删除 删除前\n logic-not-delete-value: 0\n #逻辑删除 删除后\n logic-delete-value: 1\n configuration:\n # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用\n #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n # 返回类型为Map,显示null对应的字段\n call-setters-on-nulls: true\n map-underscore-to-camel-case: true\n auto-mapping-behavior: full\n jdbc-type-for-null:\nspring: \n datasource:\n druid:\n stat-view-servlet:\n enabled: true\n loginUsername: admin\n loginPassword: 123456\n dynamic:\n druid:\n initial-size: 5\n min-idle: 5\n maxActive: 20\n maxWait: 60000\n timeBetweenEvictionRunsMillis: 60000\n minEvictableIdleTimeMillis: 300000\n validationQuery: SELECT 1 FROM DUAL\n testWhileIdle: true\n testOnBorrow: false\n testOnReturn: false\n poolPreparedStatements: true\n maxPoolPreparedStatementPerConnectionSize: 20\n filters: stat,slf4j\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\n datasource:\n # 主库数据源\n master:\n driver-class-name: com.mysql.cj.jdbc.Driver\n url: jdbc:mysql://localhost:3306/mf_scheduler?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\n username: root\n password: 123456\n # 从库数据源\n # slave:\n # username: \n # password: \n # url: \n # driver-class-name: \n # seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭\norg:\n quartz:\n scheduler:\n instanceName: MfishClusteredScheduler\n instanceId: AUTO\n threadPool:\n poolClass: org.quartz.simpl.SimpleThreadPool\n threadCount: 50\n threadPriority: 5\n jobStore:\n jdbcClass: org.quartz.impl.jdbcjobstore.JobStoreTX\n driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate\n useProperties: true\n isClustered: true\n tablePrefix: QRTZ_\n dataSource: mf_scheduler\n clusterCheckinInterval: 20000\n misfireThreshold: 60000\n#rocketmq配置信息\nrocketmq:\n #nameservice服务器地址(多个以英文逗号隔开)\n name-server: 127.0.0.1:9876\n #生产者配置\n producer:\n #组名\n group: mfish-scheduler-group\n sendMessageTimeout: 300000\n #目的地(topic:tag\n #topic\n topic: mfish-scheduler-topic', '9efdb370a89002ab71d530af7282b9cf', '2023-02-03 06:47:14', '2024-04-18 21:13:02', NULL, '0:0:0:0:0:0:0:1', '', '', '', '', '', 'yaml', '', '');
@@ -1,4 +1,4 @@
package cn.com.mfish.oauth.entity;
package cn.com.mfish.common.oauth.api.entity;
import cn.com.mfish.common.core.entity.BaseTreeEntity;
import com.baomidou.mybatisplus.annotation.IdType;
@@ -0,0 +1,31 @@
package cn.com.mfish.common.oauth.api.fallback;
import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.common.oauth.api.entity.SsoMenu;
import cn.com.mfish.common.oauth.api.remote.RemoteMenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
/**
* @description: 菜单远程调用失败处理
* @author: mfish
* @date: 2024/4/22
*/
@Slf4j
public class RemoteMenuFallback implements FallbackFactory<RemoteMenuService> {
@Override
public RemoteMenuService create(Throwable cause) {
log.error("菜单服务调用失败:{}", cause.getMessage());
return new RemoteMenuService() {
@Override
public Result<SsoMenu> add(String origin, SsoMenu ssoMenu) {
return Result.fail("错误:保存菜单失败" + cause.getMessage());
}
@Override
public Result<Boolean> routeExist(String routePath) {
return Result.fail("错误:路由判断失败" + cause.getMessage());
}
};
}
}
@@ -22,20 +22,20 @@ import java.util.List;
public class RemoteOrgFallback implements FallbackFactory<RemoteOrgService> {
@Override
public RemoteOrgService create(Throwable cause) {
log.error("组织服务调用失败:" + cause.getMessage());
log.error("组织服务调用失败:{}", cause.getMessage());
return new RemoteOrgService() {
@Override
public Result<List<SsoOrg>> queryById(String ids) {
public Result<List<SsoOrg>> queryById(String origin, String ids) {
return Result.fail("错误:根据ID获取组织列表失败" + cause.getMessage());
}
@Override
public Result<List<SsoOrg>> queryByFixCode(String code, String direction) {
public Result<List<SsoOrg>> queryByFixCode(String origin, String code, String direction) {
return Result.fail("错误:根据编码获取组织树失败" + cause.getMessage());
}
@Override
public Result<PageResult<UserInfo>> queryUserByCode(String code, String account, String nickname, String phone, ReqPage reqPage) {
public Result<PageResult<UserInfo>> queryUserByCode(String origin, String code, String account, String nickname, String phone, ReqPage reqPage) {
return Result.fail("错误:根据编码获取组织下用户失败" + cause.getMessage());
}
};
@@ -24,7 +24,7 @@ import java.util.Set;
public class RemoteUserFallback implements FallbackFactory<RemoteUserService> {
@Override
public RemoteUserService create(Throwable cause) {
log.error("用户服务调用失败:" + cause.getMessage());
log.error("用户服务调用失败:{}", cause.getMessage());
return new RemoteUserService() {
@Override
public Result<UserInfoVo> getUserInfo(String origin, String token) {
@@ -52,7 +52,7 @@ public class RemoteUserFallback implements FallbackFactory<RemoteUserService> {
}
@Override
public Result<List<SsoOrg>> getOrgs(String userId, String direction) {
public Result<List<SsoOrg>> getOrgs(String origin, String userId, String direction) {
return Result.fail("错误:获取用户组织失败" + cause.getMessage());
}
};
@@ -0,0 +1,23 @@
package cn.com.mfish.common.oauth.api.remote;
import cn.com.mfish.common.core.constants.RPCConstants;
import cn.com.mfish.common.core.constants.ServiceConstants;
import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.common.oauth.api.entity.SsoMenu;
import cn.com.mfish.common.oauth.api.fallback.RemoteMenuFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
/**
* @description: 菜单远程接口
* @author: mfish
* @date: 2024/4/22
*/
@FeignClient(contextId = "remoteMenuService", value = ServiceConstants.OAUTH_SERVICE, fallbackFactory = RemoteMenuFallback.class)
public interface RemoteMenuService {
@PostMapping("/menu")
Result<SsoMenu> add(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @RequestBody SsoMenu ssoMenu);
@GetMapping("/routeExist")
Result<Boolean> routeExist(@RequestParam String routePath);
}
@@ -1,5 +1,6 @@
package cn.com.mfish.common.oauth.api.remote;
import cn.com.mfish.common.core.constants.RPCConstants;
import cn.com.mfish.common.core.constants.ServiceConstants;
import cn.com.mfish.common.core.web.PageResult;
import cn.com.mfish.common.core.web.ReqPage;
@@ -11,6 +12,7 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@@ -24,11 +26,11 @@ import java.util.List;
public interface RemoteOrgService {
@GetMapping("/org/{ids}")
Result<List<SsoOrg>> queryById(@PathVariable("ids") String ids);
Result<List<SsoOrg>> queryById(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("ids") String ids);
@GetMapping("/org/code/{code}")
Result<List<SsoOrg>> queryByFixCode(@PathVariable("code") String code, @RequestParam("direction") String direction);
Result<List<SsoOrg>> queryByFixCode(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("code") String code, @RequestParam("direction") String direction);
@GetMapping("/org/user/{code}")
Result<PageResult<UserInfo>> queryUserByCode(@PathVariable("code") String code, @RequestParam("account") String account, @RequestParam("nickname") String nickname, @RequestParam("phone") String phone, @SpringQueryMap ReqPage reqPage);
Result<PageResult<UserInfo>> queryUserByCode(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("code") String code, @RequestParam("account") String account, @RequestParam("nickname") String nickname, @RequestParam("phone") String phone, @SpringQueryMap ReqPage reqPage);
}
@@ -63,6 +63,7 @@ public interface RemoteUserService {
/**
* 获取当前租户列表
*
* @param origin
* @param userId
* @return
@@ -72,10 +73,11 @@ public interface RemoteUserService {
/**
* 获取用户组织
*
* @param userId
* @param direction
* @return
*/
@GetMapping("/user/orgs/{userId}")
Result<List<SsoOrg>> getOrgs(@PathVariable("userId") String userId, @RequestParam("direction") String direction);
Result<List<SsoOrg>> getOrgs(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("userId") String userId, @RequestParam("direction") String direction);
}
@@ -1,2 +1,3 @@
cn.com.mfish.common.oauth.api.fallback.RemoteUserFallback
cn.com.mfish.common.oauth.api.fallback.RemoteOrgFallback
cn.com.mfish.common.oauth.api.fallback.RemoteOrgFallback
cn.com.mfish.common.oauth.api.fallback.RemoteMenuFallback
@@ -20,12 +20,12 @@ public class RemoteStorageFallBack implements FallbackFactory<RemoteStorageServi
log.error("错误:文件接口调用异常", cause);
return new RemoteStorageService() {
@Override
public Result<StorageInfo> queryByKey(String fileKey) {
public Result<StorageInfo> queryByKey(String origin, String fileKey) {
return Result.fail("错误:根据ID获取组织列表失败" + cause.getMessage());
}
@Override
public Result<Boolean> logicDelete(String id) {
public Result<Boolean> logicDelete(String origin, String id) {
return Result.fail("错误:逻辑删除文件失败" + cause.getMessage());
}
};
@@ -1,5 +1,6 @@
package cn.com.mfish.common.storage.api.remote;
import cn.com.mfish.common.core.constants.RPCConstants;
import cn.com.mfish.common.core.constants.ServiceConstants;
import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.common.storage.api.entity.StorageInfo;
@@ -8,6 +9,7 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
/**
* @description: 远程缓存接口
@@ -17,8 +19,8 @@ import org.springframework.web.bind.annotation.PathVariable;
@FeignClient(contextId = "remoteStorageService", value = ServiceConstants.STORAGE_SERVICE, fallbackFactory = RemoteStorageFallBack.class)
public interface RemoteStorageService {
@GetMapping("/sysFile/{fileKey}")
Result<StorageInfo> queryByKey(@PathVariable("fileKey") String fileKey);
Result<StorageInfo> queryByKey(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("fileKey") String fileKey);
@DeleteMapping("/sysFile/logic/{id}")
Result<Boolean> logicDelete(@PathVariable("id") String id);
Result<Boolean> logicDelete(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("id") String id);
}
@@ -29,7 +29,7 @@ public class RemoteDbConnectFallback implements FallbackFactory<RemoteDbConnectS
log.error("错误:数据库连接调用异常", cause);
return new RemoteDbConnectService() {
@Override
public Result<PageResult<DbConnect>> queryPageList(ReqDbConnect reqDbConnect, ReqPage reqPage) {
public Result<PageResult<DbConnect>> queryPageList(String origin, ReqDbConnect reqDbConnect, ReqPage reqPage) {
return Result.fail("错误:查询数据库连接列表出错");
}
@@ -39,22 +39,22 @@ public class RemoteDbConnectFallback implements FallbackFactory<RemoteDbConnectS
}
@Override
public Result<PageResult<TableInfo>> getTableList(String connectId, String tableName, ReqPage reqPage) {
public Result<PageResult<TableInfo>> getTableList(String origin, String connectId, String tableName, ReqPage reqPage) {
return Result.fail("错误:查询数据库表列表出错");
}
@Override
public Result<PageResult<FieldInfo>> getFieldList(String connectId, String tableName, ReqPage reqPage) {
public Result<PageResult<FieldInfo>> getFieldList(String origin, String connectId, String tableName, ReqPage reqPage) {
return Result.fail("错误:查询表字段列表出错");
}
@Override
public Result<MetaHeaderDataTable> getDataTable(String connectId, String tableName, ReqPage reqPage) {
public Result<MetaHeaderDataTable> getDataTable(String origin, String connectId, String tableName, ReqPage reqPage) {
return Result.fail("错误:查询表数据失败");
}
@Override
public Result<List<MetaDataHeader>> getDataHeaders(String connectId, String tableName, ReqPage reqPage) {
public Result<List<MetaDataHeader>> getDataHeaders(String origin, String connectId, String tableName, ReqPage reqPage) {
return Result.fail("错误:获取表列头失败");
}
};
@@ -18,6 +18,6 @@ public class RemoteDictFallback implements FallbackFactory<RemoteDictService> {
@Override
public RemoteDictService create(Throwable cause) {
log.error("错误:字典调用异常", cause);
return dictCode -> Result.fail("错误:查询字典数据出错");
return (origin, dictCode) -> Result.fail("错误:查询字典数据出错");
}
}
@@ -29,20 +29,20 @@ import java.util.List;
@FeignClient(contextId = "remoteDbConnectService", value = ServiceConstants.SYS_SERVICE, fallbackFactory = RemoteDbConnectFallback.class)
public interface RemoteDbConnectService {
@GetMapping("/dbConnect")
Result<PageResult<DbConnect>> queryPageList(@SpringQueryMap ReqDbConnect reqDbConnect, @SpringQueryMap ReqPage reqPage);
Result<PageResult<DbConnect>> queryPageList(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @SpringQueryMap ReqDbConnect reqDbConnect, @SpringQueryMap ReqPage reqPage);
@GetMapping("/dbConnect/{id}")
Result<DbConnect> queryById(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("id") String id);
@GetMapping("/dbConnect/tables")
Result<PageResult<TableInfo>> getTableList(@RequestParam(name = "connectId") String connectId, @RequestParam(name = "tableName", required = false) String tableName, @SpringQueryMap ReqPage reqPage);
Result<PageResult<TableInfo>> getTableList(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @RequestParam(name = "connectId") String connectId, @RequestParam(name = "tableName", required = false) String tableName, @SpringQueryMap ReqPage reqPage);
@GetMapping("/dbConnect/fields")
Result<PageResult<FieldInfo>> getFieldList(@RequestParam(name = "connectId") String connectId, @RequestParam(name = "tableName", required = false) String tableName, @SpringQueryMap ReqPage reqPage);
Result<PageResult<FieldInfo>> getFieldList(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @RequestParam(name = "connectId") String connectId, @RequestParam(name = "tableName", required = false) String tableName, @SpringQueryMap ReqPage reqPage);
@GetMapping("/dbConnect/data")
Result<MetaHeaderDataTable> getDataTable(@RequestParam(name = "connectId") String connectId, @RequestParam(name = "tableName", required = false) String tableName, @SpringQueryMap ReqPage reqPage);
Result<MetaHeaderDataTable> getDataTable(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @RequestParam(name = "connectId") String connectId, @RequestParam(name = "tableName", required = false) String tableName, @SpringQueryMap ReqPage reqPage);
@GetMapping("/dbConnect/headers")
Result<List<MetaDataHeader>> getDataHeaders(@RequestParam(name = "connectId") String connectId, @RequestParam(name = "tableName", required = false) String tableName, @SpringQueryMap ReqPage reqPage);
Result<List<MetaDataHeader>> getDataHeaders(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @RequestParam(name = "connectId") String connectId, @RequestParam(name = "tableName", required = false) String tableName, @SpringQueryMap ReqPage reqPage);
}
@@ -1,5 +1,6 @@
package cn.com.mfish.sys.api.remote;
import cn.com.mfish.common.core.constants.RPCConstants;
import cn.com.mfish.common.core.constants.ServiceConstants;
import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.sys.api.entity.DictItem;
@@ -7,6 +8,7 @@ import cn.com.mfish.sys.api.fallback.RemoteDictFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import java.util.List;
@@ -18,5 +20,5 @@ import java.util.List;
@FeignClient(contextId = "remoteDictService", value = ServiceConstants.SYS_SERVICE, fallbackFactory = RemoteDictFallback.class)
public interface RemoteDictService {
@GetMapping("/dictItem/{dictCode}")
Result<List<DictItem>> queryByCode(@PathVariable("dictCode") String dictCode);
Result<List<DictItem>> queryByCode(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("dictCode") String dictCode);
}
@@ -7,8 +7,10 @@ import cn.com.mfish.common.core.web.ReqPage;
import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.common.log.annotation.Log;
import cn.com.mfish.common.oauth.annotation.RequiresPermissions;
import cn.com.mfish.common.oauth.api.entity.SsoMenu;
import cn.com.mfish.sys.entity.CodeBuild;
import cn.com.mfish.sys.req.ReqCodeBuild;
import cn.com.mfish.sys.req.ReqMenuCreate;
import cn.com.mfish.sys.service.CodeBuildService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
@@ -70,11 +72,19 @@ public class CodeBuildController {
return codeBuildService.insertCodeBuild(codeBuild);
}
@Log(title = "代码构建-更新", operateType = OperateType.INSERT)
@Operation(summary = "代码构建-更新")
@PutMapping
@RequiresPermissions("sys:codeBuild:insert")
public Result<CodeBuild> update(@RequestBody CodeBuild codeBuild) {
return codeBuildService.updateCodeBuild(codeBuild);
}
@Log(title = "查看代码", operateType = OperateType.QUERY)
@Operation(summary = "查看代码")
@GetMapping("/view/{id}")
@RequiresPermissions("sys:codeBuild:query")
public Result<List<CodeVo>> query(@PathVariable String id) {
public Result<List<CodeVo>> query(@PathVariable Long id) {
return codeBuildService.getCode(id);
}
@@ -82,10 +92,18 @@ public class CodeBuildController {
@Operation(summary = "下载代码")
@GetMapping("/download/{id}")
@RequiresPermissions("sys:codeBuild:query")
public void downloadCode(@PathVariable String id, HttpServletResponse response) throws IOException {
public void downloadCode(@PathVariable Long id, HttpServletResponse response) throws IOException {
codeBuildService.downloadCode(id, response);
}
@Log(title = "保存代码到IDE", operateType = OperateType.QUERY)
@Operation(summary = "保存代码到IDE")
@GetMapping("/saveLocal/{id}")
@RequiresPermissions("sys:codeBuild:query")
public Result<Boolean> saveLocal(@PathVariable Long id) {
return codeBuildService.saveLocal(id);
}
/**
* 通过id删除
*
@@ -96,7 +114,7 @@ public class CodeBuildController {
@Operation(summary = "代码构建-通过id删除")
@DeleteMapping("/{id}")
@RequiresPermissions("sys:codeBuild:delete")
public Result<Boolean> delete(@Parameter(name = "id", description = "唯一性ID") @PathVariable String id) {
public Result<Boolean> delete(@Parameter(name = "id", description = "唯一性ID") @PathVariable Long id) {
if (codeBuildService.removeById(id)) {
return Result.ok(true, "代码构建-删除成功!");
}
@@ -111,9 +129,9 @@ public class CodeBuildController {
*/
@Log(title = "代码构建-批量删除", operateType = OperateType.DELETE)
@Operation(summary = "代码构建-批量删除")
@DeleteMapping("/batch")
@DeleteMapping("/batch/{ids}")
@RequiresPermissions("sys:codeBuild:delete")
public Result<Boolean> deleteBatch(@RequestParam(name = "ids") String ids) {
public Result<Boolean> deleteBatch(@Parameter(name = "ids", description = "唯一性ID") @PathVariable String ids) {
if (this.codeBuildService.removeByIds(Arrays.asList(ids.split(",")))) {
return Result.ok(true, "代码构建-批量删除成功!");
}
@@ -121,16 +139,17 @@ public class CodeBuildController {
}
/**
* 通过id查询
* 创建菜单
*
* @param id 唯一ID
* @return 返回代码构建对象
* @param reqMenuCreate 请求参数
* @return
*/
@Operation(summary = "代码构建-通过id查询")
@GetMapping("/{id}")
@RequiresPermissions("sys:codeBuild:query")
public Result<CodeBuild> queryById(@Parameter(name = "id", description = "唯一性ID") @PathVariable String id) {
CodeBuild codeBuild = codeBuildService.getById(id);
return Result.ok(codeBuild, "代码构建-查询成功!");
@Log(title = "创建菜单", operateType = OperateType.INSERT)
@Operation(summary = "创建菜单", description = "创建菜单")
@PostMapping("/menu")
@RequiresPermissions("sys:codeBuild:insert")
public Result<SsoMenu> createMenu(@RequestBody ReqMenuCreate reqMenuCreate) {
return codeBuildService.createMenu(reqMenuCreate);
}
}
@@ -1,70 +0,0 @@
package cn.com.mfish.sys.controller;
import cn.com.mfish.common.code.common.FreemarkerUtils;
import cn.com.mfish.common.code.req.ReqCode;
import cn.com.mfish.common.code.vo.CodeVo;
import cn.com.mfish.common.core.enums.OperateType;
import cn.com.mfish.common.core.exception.MyRuntimeException;
import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.common.log.annotation.Log;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author: mfish
* @description: 代码生成控制器
* @date: 2022/8/18 16:45
*/
@Tag(name = "代码生成")
@RestController
@RequestMapping("/code")
@Slf4j
public class CodeController {
@Resource
FreemarkerUtils freemarkerUtils;
@Log(title = "获取代码", operateType = OperateType.QUERY)
@Operation(summary = "获取代码")
@PostMapping
public Result<List<CodeVo>> getCode(@RequestBody ReqCode reqCode) {
try {
List<CodeVo> list = freemarkerUtils.getCode(reqCode);
return Result.ok(list, "生成代码成功");
} catch (MyRuntimeException ex) {
return Result.fail(null, ex.getMessage());
}
}
@Log(title = "下载代码", operateType = OperateType.EXPORT)
@Operation(summary = "下载代码")
@PostMapping("/download")
public Result<byte[]> downloadCode(@RequestBody ReqCode reqCode) {
try {
return Result.ok(freemarkerUtils.downloadCode(reqCode));
} catch (MyRuntimeException ex) {
return Result.fail(null, ex.getMessage());
}
}
@Log(title = "代码生成并保存到本地", operateType = OperateType.INSERT)
@Operation(summary = "代码生成并保存到本地")
@PostMapping("/save")
public Result<String> saveCode(@RequestBody ReqCode reqCode) {
try {
if (freemarkerUtils.saveCode(reqCode)) {
return Result.ok("代码生成成功");
}
return Result.fail("错误:代码生成失败");
} catch (MyRuntimeException exception) {
return Result.fail(exception.getMessage());
}
}
}
@@ -11,7 +11,7 @@ import cn.com.mfish.common.dblink.service.DbConnectService;
import cn.com.mfish.common.dblink.service.TableService;
import cn.com.mfish.common.log.annotation.Log;
import cn.com.mfish.common.oauth.annotation.RequiresPermissions;
import cn.com.mfish.common.web.annotation.InnerUser;
import cn.com.mfish.common.core.annotation.InnerUser;
import cn.com.mfish.sys.api.entity.DbConnect;
import cn.com.mfish.sys.api.entity.FieldInfo;
import cn.com.mfish.sys.api.entity.TableInfo;
@@ -26,7 +26,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -168,23 +167,6 @@ public class DbConnectController {
return Result.fail(false, "错误:数据库连接-删除失败!");
}
/**
* 批量删除
*
* @param ids 批量ID
* @return 返回数据库连接-删除结果
*/
@Log(title = "数据库连接-批量删除", operateType = OperateType.DELETE)
@Operation(summary = "数据库连接-批量删除")
@DeleteMapping("/batch")
@RequiresPermissions("sys:database:delete")
public Result<Boolean> deleteBatch(@RequestParam(name = "ids") String ids) {
if (this.dbConnectService.removeByIds(Arrays.asList(ids.split(",")))) {
return Result.ok(true, "数据库连接-批量删除成功!");
}
return Result.fail(false, "错误:数据库连接-批量删除失败!");
}
/**
* 通过id查询
*
@@ -7,7 +7,7 @@ import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.common.log.annotation.Log;
import cn.com.mfish.common.log.service.SysLogService;
import cn.com.mfish.common.oauth.annotation.RequiresPermissions;
import cn.com.mfish.common.web.annotation.InnerUser;
import cn.com.mfish.common.core.annotation.InnerUser;
import cn.com.mfish.sys.api.entity.SysLog;
import cn.com.mfish.sys.req.ReqSysLog;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -41,10 +41,10 @@ public class SysLogController {
* @param reqSysLog 系统日志请求参数
* @return 返回系统日志
*/
@Operation(summary = "系统日志-分页列表查询", description = "系统日志-分页列表查询")
@Operation(summary = "系统日志-分页列表查询", description = "系统日志-分页列表查询")
@GetMapping
@RequiresPermissions("sys:log:query")
public Result<PageResult<SysLog>> queryPageList( ReqSysLog reqSysLog, ReqPage reqPage) {
public Result<PageResult<SysLog>> queryPageList(ReqSysLog reqSysLog, ReqPage reqPage) {
PageHelper.startPage(reqPage.getPageNum(), reqPage.getPageSize());
LambdaQueryWrapper<SysLog> queryWrapper = new LambdaQueryWrapper<SysLog>()
.like(reqSysLog.getTitle() != null, SysLog::getTitle, reqSysLog.getTitle())
@@ -67,7 +67,7 @@ public class SysLogController {
* @param sysLog
* @return
*/
@Operation(summary = "系统日志-添加", description = "系统日志-添加")
@Operation(summary = "系统日志-添加", description = "系统日志-添加")
@PostMapping
@InnerUser
public Result<SysLog> add(@RequestBody SysLog sysLog) {
@@ -81,7 +81,7 @@ public class SysLogController {
* @return
*/
@Log(title = "系统日志-编辑", operateType = OperateType.UPDATE)
@Operation(summary = "系统日志-编辑", description = "系统日志-编辑")
@Operation(summary = "系统日志-编辑", description = "系统日志-编辑")
@PutMapping
public Result<SysLog> edit(@RequestBody SysLog sysLog) {
if (sysLogService.updateById(sysLog)) {
@@ -97,7 +97,7 @@ public class SysLogController {
* @return
*/
@Log(title = "系统日志-通过id删除", operateType = OperateType.DELETE)
@Operation(summary = "系统日志-通过id删除", description = "系统日志-通过id删除")
@Operation(summary = "系统日志-通过id删除", description = "系统日志-通过id删除")
@DeleteMapping("/{id}")
@RequiresPermissions("sys:log:delete")
public Result<Boolean> delete(@Parameter(name = "id", description = "唯一性ID") @PathVariable String id) {
@@ -114,10 +114,10 @@ public class SysLogController {
* @return
*/
@Log(title = "系统日志-批量删除", operateType = OperateType.DELETE)
@Operation(summary = "系统日志-批量删除", description = "系统日志-批量删除")
@DeleteMapping("/batch")
@Operation(summary = "系统日志-批量删除", description = "系统日志-批量删除")
@DeleteMapping("/batch/{ids}")
@RequiresPermissions("sys:log:delete")
public Result<Boolean> deleteBatch(@RequestParam(name = "ids") String ids) {
public Result<Boolean> deleteBatch(@Parameter(name = "ids", description = "唯一性ID") @PathVariable String ids) {
if (this.sysLogService.removeByIds(Arrays.asList(ids.split(",")))) {
return Result.ok(true, "系统日志-批量删除成功!");
}
@@ -130,7 +130,7 @@ public class SysLogController {
* @param id
* @return
*/
@Operation(summary = "系统日志-通过id查询", description = "系统日志-通过id查询")
@Operation(summary = "系统日志-通过id查询", description = "系统日志-通过id查询")
@GetMapping("/{id}")
@RequiresPermissions("sys:log:query")
public Result<SysLog> queryById(@Parameter(name = "id", description = "唯一性ID") @PathVariable String id) {
@@ -0,0 +1,17 @@
package cn.com.mfish.sys.req;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @description: 菜单创建请求
* @author: mfish
* @date: 2024/4/22
*/
@Data
public class ReqMenuCreate {
@Schema(description = "代码生成id")
private Long id;
@Schema(description = "目录ID")
private String parentId;
}
@@ -2,10 +2,12 @@ package cn.com.mfish.sys.service;
import cn.com.mfish.common.code.vo.CodeVo;
import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.common.oauth.api.entity.SsoMenu;
import cn.com.mfish.sys.entity.CodeBuild;
import cn.com.mfish.sys.req.ReqMenuCreate;
import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@@ -18,6 +20,13 @@ import java.util.List;
public interface CodeBuildService extends IService<CodeBuild> {
Result<CodeBuild> insertCodeBuild(CodeBuild codeBuild);
Result<List<CodeVo>> getCode(String id);
void downloadCode(String id, HttpServletResponse response) throws IOException;
Result<CodeBuild> updateCodeBuild(CodeBuild codeBuild);
Result<List<CodeVo>> getCode(Long id);
void downloadCode(Long id, HttpServletResponse response) throws IOException;
Result<Boolean> saveLocal(Long id);
Result<SsoMenu> createMenu(ReqMenuCreate reqMenuCreate);
}
@@ -4,11 +4,16 @@ import cn.com.mfish.common.code.req.ReqCode;
import cn.com.mfish.common.code.req.ReqSearch;
import cn.com.mfish.common.code.vo.CodeVo;
import cn.com.mfish.common.code.common.FreemarkerUtils;
import cn.com.mfish.common.core.constants.RPCConstants;
import cn.com.mfish.common.core.enums.OperateType;
import cn.com.mfish.common.core.exception.MyRuntimeException;
import cn.com.mfish.common.core.utils.StringUtils;
import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.common.oauth.api.entity.SsoMenu;
import cn.com.mfish.common.oauth.api.remote.RemoteMenuService;
import cn.com.mfish.sys.entity.CodeBuild;
import cn.com.mfish.sys.mapper.CodeBuildMapper;
import cn.com.mfish.sys.req.ReqMenuCreate;
import cn.com.mfish.sys.service.CodeBuildService;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -19,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@@ -32,6 +38,8 @@ import java.util.List;
public class CodeBuildServiceImpl extends ServiceImpl<CodeBuildMapper, CodeBuild> implements CodeBuildService {
@Resource
FreemarkerUtils freemarkerUtils;
@Resource
private RemoteMenuService remoteMenuService;
@Override
@Transactional
@@ -41,23 +49,30 @@ public class CodeBuildServiceImpl extends ServiceImpl<CodeBuildMapper, CodeBuild
return result;
}
if (save(codeBuild)) {
ReqCode reqCode = new ReqCode();
BeanUtils.copyProperties(codeBuild, reqCode);
if (!freemarkerUtils.saveCode(reqCode)) {
throw new MyRuntimeException("错误:代码构建-失败");
}
return Result.ok(codeBuild, "代码构建-添加成功!");
}
throw new MyRuntimeException("错误:代码生成失败");
}
@Override
public Result<List<CodeVo>> getCode(String id) {
public Result<CodeBuild> updateCodeBuild(CodeBuild codeBuild) {
Result<CodeBuild> result = validateCodeBuild(codeBuild);
if (!result.isSuccess()) {
return result;
}
if (updateById(codeBuild)) {
return Result.ok(codeBuild, "代码构建-更新成功!");
}
throw new MyRuntimeException("错误:代码生成更新失败");
}
@Override
public Result<List<CodeVo>> getCode(Long id) {
return Result.ok(freemarkerUtils.getCode(buildReqCode(id)), "获取代码成功");
}
@Override
public void downloadCode(String id, HttpServletResponse response) throws IOException {
public void downloadCode(Long id, HttpServletResponse response) throws IOException {
ReqCode reqCode = buildReqCode(id);
response.reset();
byte[] data;
@@ -68,6 +83,14 @@ public class CodeBuildServiceImpl extends ServiceImpl<CodeBuildMapper, CodeBuild
IOUtils.write(data, response.getOutputStream());
}
@Override
public Result<Boolean> saveLocal(Long id) {
if (!freemarkerUtils.saveCode(buildReqCode(id))) {
return Result.fail(false, "错误:代码保存本地失败");
}
return Result.ok(true, "代码保存成功,请重新启动后端");
}
private Result<CodeBuild> validateCodeBuild(CodeBuild codeBuild) {
if (StringUtils.isEmpty(codeBuild.getConnectId()) || StringUtils.isEmpty(codeBuild.getTableName())) {
return Result.fail(codeBuild, "错误:请选择数据库和表");
@@ -81,7 +104,7 @@ public class CodeBuildServiceImpl extends ServiceImpl<CodeBuildMapper, CodeBuild
* @param id 代码唯一id
* @return 请求参数
*/
private ReqCode buildReqCode(String id) {
private ReqCode buildReqCode(Long id) {
CodeBuild codeBuild = baseMapper.selectById(id);
ReqCode reqCode = new ReqCode();
BeanUtils.copyProperties(codeBuild, reqCode);
@@ -90,4 +113,49 @@ public class CodeBuildServiceImpl extends ServiceImpl<CodeBuildMapper, CodeBuild
}
return reqCode;
}
@Override
public Result<SsoMenu> createMenu(ReqMenuCreate reqMenuCreate) {
ReqCode reqCode = buildReqCode(reqMenuCreate.getId());
freemarkerUtils.initReqCode(reqCode);
String routePath = "/" + StringUtils.toKebabCase(reqCode.getEntityName());
if (remoteMenuService.routeExist(routePath).getData()) {
return Result.fail(null, "错误:菜单路由已存在,请勿重复操作");
}
SsoMenu ssoMenu = new SsoMenu();
ssoMenu.setMenuName(reqCode.getTableComment())
.setRoutePath(routePath)
.setComponent("/" + reqCode.getApiPrefix() + routePath + "/index.vue")
.setMenuIcon("ant-design:bars-outlined")
.setMenuSort(999).setMenuType(1).setIsExternal(0).setIsKeepalive(1).setIsVisible(1)
.setParentId(reqMenuCreate.getParentId());
Result<SsoMenu> result = remoteMenuService.add(RPCConstants.INNER, ssoMenu);
if (!result.isSuccess()) {
return result;
}
remoteMenuService.add(RPCConstants.INNER, buildButtonMenu(result.getData().getId(), reqCode, OperateType.QUERY, 1));
remoteMenuService.add(RPCConstants.INNER, buildButtonMenu(result.getData().getId(), reqCode, OperateType.INSERT, 2));
remoteMenuService.add(RPCConstants.INNER, buildButtonMenu(result.getData().getId(), reqCode, OperateType.UPDATE, 3));
remoteMenuService.add(RPCConstants.INNER, buildButtonMenu(result.getData().getId(), reqCode, OperateType.DELETE, 4));
return result;
}
private SsoMenu buildButtonMenu(String id, ReqCode reqCode, OperateType type, int sort) {
SsoMenu menu = new SsoMenu();
menu.setParentId(id)
.setMenuName(type.toString())
.setMenuType(2)
.setMenuSort(sort);
if (type == OperateType.QUERY) {
menu.setPermissions(reqCode.getApiPrefix() + ":" + StringUtils.firstLowerCase(reqCode.getEntityName())
+ ":" + StringUtils.toRootLowerCase(type.name()));
} else {
String lowerCaseEntity = StringUtils.firstLowerCase(reqCode.getEntityName());
menu.setPermissions(reqCode.getApiPrefix() + ":" + lowerCaseEntity
+ ":" + StringUtils.toRootLowerCase(OperateType.QUERY.name()) + "," +
reqCode.getApiPrefix() + ":" + lowerCaseEntity
+ ":" + StringUtils.toRootLowerCase(type.name()));
}
return menu;
}
}
@@ -15,6 +15,7 @@ import cn.com.mfish.sys.api.req.ReqDbConnect;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import java.util.List;
/**
@@ -30,7 +31,7 @@ public class BootDbConnectService implements RemoteDbConnectService {
DbConnectService dbConnectService;
@Override
public Result<PageResult<DbConnect>> queryPageList(ReqDbConnect reqDbConnect, ReqPage reqPage) {
public Result<PageResult<DbConnect>> queryPageList(String origin, ReqDbConnect reqDbConnect, ReqPage reqPage) {
return dbConnectService.queryPageList(reqDbConnect, reqPage);
}
@@ -40,22 +41,22 @@ public class BootDbConnectService implements RemoteDbConnectService {
}
@Override
public Result<PageResult<TableInfo>> getTableList(String connectId, String tableName, ReqPage reqPage) {
public Result<PageResult<TableInfo>> getTableList(String origin, String connectId, String tableName, ReqPage reqPage) {
return Result.ok(new PageResult<>(tableService.getTableList(connectId, tableName, reqPage)), "获取表列表成功");
}
@Override
public Result<PageResult<FieldInfo>> getFieldList(String connectId, String tableName, ReqPage reqPage) {
public Result<PageResult<FieldInfo>> getFieldList(String origin, String connectId, String tableName, ReqPage reqPage) {
return Result.ok(new PageResult<>(tableService.getFieldList(connectId, tableName, reqPage)), "获取字段列表成功");
}
@Override
public Result<MetaHeaderDataTable> getDataTable(String connectId, String tableName, ReqPage reqPage) {
public Result<MetaHeaderDataTable> getDataTable(String origin, String connectId, String tableName, ReqPage reqPage) {
return tableService.getHeaderDataTable(connectId, tableName, reqPage);
}
@Override
public Result<List<MetaDataHeader>> getDataHeaders(String connectId, String tableName, ReqPage reqPage) {
public Result<List<MetaDataHeader>> getDataHeaders(String origin, String connectId, String tableName, ReqPage reqPage) {
return Result.ok(tableService.getDataHeaders(connectId, tableName, reqPage), "获取表列头成功");
}
}
@@ -7,6 +7,7 @@ import cn.com.mfish.sys.api.remote.RemoteDictService;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import java.util.List;
/**
@@ -21,7 +22,7 @@ public class BootDictService implements RemoteDictService {
DictItemService dictItemService;
@Override
public Result<List<DictItem>> queryByCode(String dictCode) {
public Result<List<DictItem>> queryByCode(String origin, String dictCode) {
return dictItemService.queryByCode(dictCode);
}
}
@@ -0,0 +1,29 @@
package cn.com.mfish.common.api;
import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.common.oauth.api.entity.SsoMenu;
import cn.com.mfish.common.oauth.api.remote.RemoteMenuService;
import cn.com.mfish.common.oauth.service.SsoMenuService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
/**
* @description: 菜单远程接口的本地实现
* @author: mfish
* @date: 2024/4/22
*/
@Service("remoteMenuService")
public class BootMenuService implements RemoteMenuService {
@Resource
SsoMenuService ssoMenuService;
@Override
public Result<SsoMenu> add(String origin, SsoMenu ssoMenu) {
return ssoMenuService.insertMenu(ssoMenu);
}
@Override
public Result<Boolean> routeExist(String routePath) {
return ssoMenuService.routeExist(routePath);
}
}
@@ -12,6 +12,7 @@ import cn.com.mfish.common.oauth.service.SsoOrgService;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import java.util.List;
/**
@@ -25,17 +26,17 @@ public class BootOrgService implements RemoteOrgService {
SsoOrgService ssoOrgService;
@Override
public Result<List<SsoOrg>> queryById(String ids) {
public Result<List<SsoOrg>> queryById(String origin, String ids) {
return ssoOrgService.queryByIds(ids);
}
@Override
public Result<List<SsoOrg>> queryByFixCode(String code, String direction) {
public Result<List<SsoOrg>> queryByFixCode(String origin, String code, String direction) {
return Result.ok(ssoOrgService.queryOrgByCode(code, TreeDirection.getDirection(direction)), "组织结构表-查询成功!");
}
@Override
public Result<PageResult<UserInfo>> queryUserByCode(String code, String account, String nickname, String phone, ReqPage reqPage) {
public Result<PageResult<UserInfo>> queryUserByCode(String origin, String code, String account, String nickname, String phone, ReqPage reqPage) {
return Result.ok(ssoOrgService.queryUserByCode(code
, new ReqOrgUser().setAccount(account).setNickname(nickname).setPhone(phone), reqPage)
, "组织下用户查询成功");
@@ -19,12 +19,12 @@ public class BootStorageService implements RemoteStorageService {
StorageService storageService;
@Override
public Result<StorageInfo> queryByKey(String fileKey) {
public Result<StorageInfo> queryByKey(String origin, String fileKey) {
return storageService.queryByKey(fileKey);
}
@Override
public Result<Boolean> logicDelete(String id) {
public Result<Boolean> logicDelete(String origin, String id) {
return storageService.logicDelete(id);
}
}
@@ -13,6 +13,7 @@ import cn.com.mfish.common.oauth.service.SsoUserService;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import java.util.List;
import java.util.Set;
@@ -61,7 +62,7 @@ public class BootUserService implements RemoteUserService {
}
@Override
public Result<List<SsoOrg>> getOrgs(String userId, String direction) {
public Result<List<SsoOrg>> getOrgs(String origin, String userId, String direction) {
return ssoUserService.getOrgs(userId, direction);
}
}
@@ -8,6 +8,7 @@ import cn.com.mfish.common.code.entity.TableExpand;
import cn.com.mfish.common.code.req.ReqCode;
import cn.com.mfish.common.code.req.ReqSearch;
import cn.com.mfish.common.code.vo.CodeVo;
import cn.com.mfish.common.core.constants.RPCConstants;
import cn.com.mfish.common.core.entity.DefaultField;
import cn.com.mfish.common.core.exception.MyRuntimeException;
import cn.com.mfish.common.core.utils.StringUtils;
@@ -30,7 +31,6 @@ import org.springframework.stereotype.Component;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -52,8 +52,10 @@ public class FreemarkerUtils {
FreemarkerProperties freemarkerProperties;
@Resource
RemoteDbConnectService remoteDbConnectService;
@Value("${code.savePath}")
String savePath;
@Value("${code.savePath.front}")
String frontPath;
@Value("${code.savePath.back}")
String backPath;
/**
* 初始化请求参数
@@ -61,7 +63,7 @@ public class FreemarkerUtils {
* @param reqCode
* @return
*/
private void initReqCode(ReqCode reqCode) {
public void initReqCode(ReqCode reqCode) {
if (StringUtils.isEmpty(reqCode.getConnectId())) {
throw new MyRuntimeException("错误:库名不允许为空");
}
@@ -98,7 +100,7 @@ public class FreemarkerUtils {
}
if (StringUtils.isEmpty(reqCode.getTableComment())) {
reqCode.setTableComment(reqCode.getTableName());
Result<PageResult<TableInfo>> result = remoteDbConnectService.getTableList(reqCode.getConnectId(), reqCode.getTableName(), new ReqPage().setPageNum(1).setPageSize(10000));
Result<PageResult<TableInfo>> result = remoteDbConnectService.getTableList(RPCConstants.INNER, reqCode.getConnectId(), reqCode.getTableName(), new ReqPage().setPageNum(1).setPageSize(10000));
if (!result.isSuccess()) {
throw new MyRuntimeException(result.getMsg());
}
@@ -124,7 +126,7 @@ public class FreemarkerUtils {
codeInfo.setPackageName(reqCode.getPackageName());
codeInfo.setEntityName(reqCode.getEntityName());
codeInfo.setApiPrefix(reqCode.getApiPrefix());
Result<PageResult<FieldInfo>> result = remoteDbConnectService.getFieldList(reqCode.getConnectId(), reqCode.getTableName(), new ReqPage().setPageNum(1).setPageSize(10000));
Result<PageResult<FieldInfo>> result = remoteDbConnectService.getFieldList(RPCConstants.INNER, reqCode.getConnectId(), reqCode.getTableName(), new ReqPage().setPageNum(1).setPageSize(10000));
if (!result.isSuccess()) {
throw new MyRuntimeException(result.getMsg());
}
@@ -286,7 +288,10 @@ public class FreemarkerUtils {
*/
public boolean saveCode(ReqCode reqCode) {
List<CodeVo> list = getCode(reqCode);
return saveCode(list);
List<CodeVo> listBack = list.stream().filter((codeVo -> codeVo.getPath().startsWith("src/main/java"))).toList();
List<CodeVo> listFront = list.stream().filter((codeVo -> codeVo.getPath().startsWith("mfish-nocode-view"))).toList();
return saveCode(listBack, backPath) && saveCode(listFront, frontPath);
}
/**
@@ -295,18 +300,16 @@ public class FreemarkerUtils {
* @param list
* @return
*/
public boolean saveCode(List<CodeVo> list) {
public boolean saveCode(List<CodeVo> list, String savePath) {
savePath = savePath.replace("\\", "/");
if (StringUtils.isEmpty(savePath)) {
savePath = "/mfish/";
} else if (!savePath.endsWith("/")) {
savePath += "/";
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd-HH-mm-ss");
String path = savePath + sdf.format(new Date());
for (CodeVo code : list) {
try {
File file = new File(path + "/" + code.getPath(), code.getName());
File file = new File(savePath + "/" + code.getPath(), code.getName());
FileUtils.writeStringToFile(file, code.getCode(), StandardCharsets.UTF_8);
} catch (IOException e) {
log.error("错误:文件保存异常", e);
@@ -60,11 +60,11 @@ export function delete${entityName}(id: <#if tableInfo.idType==''||tableInfo.idT
};
/**
* 批量删除${tableInfo.tableComment}
*
* @param ids 唯一ID多个逗号隔开
* @return
*/
* 批量删除${tableInfo.tableComment}
*
* @param ids 唯一ID多个逗号隔开
* @return
*/
export function deleteBatch${entityName}(ids: string) {
return defHttp.delete<${entityName}>({ url: Api.${entityName} + "/batch/" + ids }, { successMessageMode: "message" });
return defHttp.delete<${entityName}>({ url: Api.${entityName} + "/batch/" + ids }, { successMessageMode: "message" });
};
@@ -9,8 +9,8 @@
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" @click="handleCreate" v-auth="'sys:${entityName?uncap_first}:insert'">新增</a-button>
<a-button type="warning" @click="handleExport" v-auth="'sys:${entityName?uncap_first}:export'">导出</a-button>
<a-button type="error" @click="handleBatchDelete" v-auth="'sys:${entityName?uncap_first}:delete'">批量删除</a-button>
<a-button color="warning" @click="handleExport" v-auth="'sys:${entityName?uncap_first}:export'">导出</a-button>
<a-button color="error" @click="handleBatchDelete" v-auth="'sys:${entityName?uncap_first}:delete'">批量删除</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
@@ -1,4 +1,4 @@
package cn.com.mfish.common.web.annotation;
package cn.com.mfish.common.core.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -131,7 +131,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
}
/**
* 首字母
* 首字母
*
* @param str
* @return
@@ -1,9 +1,13 @@
package cn.com.mfish.common.oauth.aspect;
import cn.com.mfish.common.core.constants.RPCConstants;
import cn.com.mfish.common.core.exception.MyRuntimeException;
import cn.com.mfish.common.core.utils.ServletUtils;
import cn.com.mfish.common.core.utils.StringUtils;
import cn.com.mfish.common.oauth.annotation.RequiresPermissions;
import cn.com.mfish.common.oauth.annotation.RequiresRoles;
import cn.com.mfish.common.oauth.common.OauthUtils;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
@@ -25,6 +29,15 @@ public class AuthorizationAspect {
@Before("@annotation(cn.com.mfish.common.oauth.annotation.RequiresPermissions)" +
"||@annotation(cn.com.mfish.common.oauth.annotation.RequiresRoles)")
public void doBefore(JoinPoint joinPoint) {
HttpServletRequest request = ServletUtils.getRequest();
if (request == null) {
throw new MyRuntimeException("错误:未获取到请求信息");
}
String source = request.getHeader(RPCConstants.REQ_ORIGIN);
//判断如果是内部Feign接口请求不需要验证按钮权限
if (!StringUtils.isEmpty(source) && source.equals(RPCConstants.INNER)) {
return;
}
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
if (method.isAnnotationPresent(RequiresPermissions.class)) {
@@ -1,4 +1,4 @@
package cn.com.mfish.oauth.req;
package cn.com.mfish.common.oauth.req;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -1,8 +1,8 @@
package cn.com.mfish.oauth.service;
package cn.com.mfish.common.oauth.service;
import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.oauth.entity.SsoMenu;
import cn.com.mfish.oauth.req.ReqSsoMenu;
import cn.com.mfish.common.oauth.api.entity.SsoMenu;
import cn.com.mfish.common.oauth.req.ReqSsoMenu;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
@@ -23,4 +23,6 @@ public interface SsoMenuService extends IService<SsoMenu> {
Result<SsoMenu> updateMenu(SsoMenu ssoMenu);
Result<Boolean> deleteMenu(String menuId);
Result<Boolean> routeExist(String routePath);
}
@@ -7,7 +7,7 @@ import cn.com.mfish.common.core.utils.ServletUtils;
import cn.com.mfish.common.core.utils.StringUtils;
import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.common.oauth.validator.TokenValidator;
import cn.com.mfish.common.web.annotation.InnerUser;
import cn.com.mfish.common.core.annotation.InnerUser;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
@@ -1,13 +1,14 @@
package cn.com.mfish.oauth.controller;
import cn.com.mfish.common.core.annotation.InnerUser;
import cn.com.mfish.common.core.enums.OperateType;
import cn.com.mfish.common.core.utils.AuthInfoUtils;
import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.common.log.annotation.Log;
import cn.com.mfish.common.oauth.annotation.RequiresPermissions;
import cn.com.mfish.oauth.entity.SsoMenu;
import cn.com.mfish.oauth.req.ReqSsoMenu;
import cn.com.mfish.oauth.service.SsoMenuService;
import cn.com.mfish.common.oauth.api.entity.SsoMenu;
import cn.com.mfish.common.oauth.req.ReqSsoMenu;
import cn.com.mfish.common.oauth.service.SsoMenuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -37,7 +38,7 @@ public class SsoMenuController {
* @param reqSsoMenu
* @return
*/
@Operation(summary = "菜单表-分页列表查询", description = "菜单表-分页列表查询")
@Operation(summary = "菜单表-分页列表查询", description = "菜单表-分页列表查询")
@GetMapping
@RequiresPermissions("sys:menu:query")
public Result<List<SsoMenu>> queryList(ReqSsoMenu reqSsoMenu) {
@@ -63,7 +64,7 @@ public class SsoMenuController {
* @return
*/
@Log(title = "菜单表-添加", operateType = OperateType.INSERT)
@Operation(summary = "菜单表-添加", description = "菜单表-添加")
@Operation(summary = "菜单表-添加", description = "菜单表-添加")
@PostMapping
@RequiresPermissions("sys:menu:insert")
public Result<SsoMenu> add(@RequestBody SsoMenu ssoMenu) {
@@ -77,7 +78,7 @@ public class SsoMenuController {
* @return
*/
@Log(title = "菜单表-编辑", operateType = OperateType.UPDATE)
@Operation(summary = "菜单表-编辑", description = "菜单表-编辑")
@Operation(summary = "菜单表-编辑", description = "菜单表-编辑")
@PutMapping
@RequiresPermissions("sys:menu:update")
public Result<SsoMenu> edit(@RequestBody SsoMenu ssoMenu) {
@@ -92,7 +93,7 @@ public class SsoMenuController {
* @return
*/
@Log(title = "菜单表-通过id删除", operateType = OperateType.DELETE)
@Operation(summary = "菜单表-通过id删除", description = "菜单表-通过id删除")
@Operation(summary = "菜单表-通过id删除", description = "菜单表-通过id删除")
@DeleteMapping("/{id}")
@RequiresPermissions("sys:menu:delete")
public Result<Boolean> delete(@Parameter(name = "id", description = "唯一性ID") @PathVariable String id) {
@@ -105,11 +106,19 @@ public class SsoMenuController {
* @param id
* @return
*/
@Operation(summary = "菜单表-通过id查询", description = "菜单表-通过id查询")
@Operation(summary = "菜单表-通过id查询", description = "菜单表-通过id查询")
@GetMapping("/{id}")
@RequiresPermissions("sys:menu:query")
public Result<SsoMenu> queryById(@Parameter(name = "id", description = "唯一性ID") @PathVariable String id) {
SsoMenu ssoMenu = ssoMenuService.getById(id);
return Result.ok(ssoMenu, "菜单表-查询成功!");
}
@Operation(summary = "判断路由是否存在")
@GetMapping("/routeExist")
@InnerUser
@Parameter(name = "路由地址", required = true)
public Result<Boolean> routeExist(@RequestParam String routePath) {
return ssoMenuService.routeExist(routePath);
}
}
@@ -23,13 +23,13 @@ import cn.com.mfish.common.oauth.req.ReqSsoUser;
import cn.com.mfish.common.oauth.service.SsoOrgService;
import cn.com.mfish.common.oauth.service.SsoUserService;
import cn.com.mfish.oauth.cache.common.ClearCache;
import cn.com.mfish.oauth.entity.SsoMenu;
import cn.com.mfish.common.oauth.api.entity.SsoMenu;
import cn.com.mfish.oauth.entity.SsoRole;
import cn.com.mfish.oauth.entity.UserOrg;
import cn.com.mfish.oauth.req.ReqSsoMenu;
import cn.com.mfish.common.oauth.req.ReqSsoMenu;
import cn.com.mfish.oauth.req.ReqSsoRole;
import cn.com.mfish.oauth.req.ReqSsoTenant;
import cn.com.mfish.oauth.service.SsoMenuService;
import cn.com.mfish.common.oauth.service.SsoMenuService;
import cn.com.mfish.oauth.service.SsoRoleService;
import cn.com.mfish.oauth.service.SsoTenantService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -19,7 +19,7 @@ import cn.com.mfish.common.oauth.common.OauthUtils;
import cn.com.mfish.common.oauth.entity.*;
import cn.com.mfish.common.oauth.req.ReqSsoUser;
import cn.com.mfish.common.oauth.service.SsoUserService;
import cn.com.mfish.common.web.annotation.InnerUser;
import cn.com.mfish.common.core.annotation.InnerUser;
import cn.com.mfish.oauth.cache.redis.UserTokenCache;
import cn.com.mfish.oauth.req.ReqChangePwd;
import com.github.pagehelper.PageHelper;
@@ -1,7 +1,7 @@
package cn.com.mfish.oauth.mapper;
import cn.com.mfish.oauth.entity.SsoMenu;
import cn.com.mfish.oauth.req.ReqSsoMenu;
import cn.com.mfish.common.oauth.api.entity.SsoMenu;
import cn.com.mfish.common.oauth.req.ReqSsoMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
@@ -1,7 +1,7 @@
<?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="cn.com.mfish.oauth.mapper.SsoMenuMapper">
<insert id="insertMenu" parameterType="cn.com.mfish.oauth.entity.SsoMenu">
<insert id="insertMenu" parameterType="cn.com.mfish.common.oauth.api.entity.SsoMenu">
insert into sso_menu
<trim prefix="(" suffix=")" suffixOverrides=",">
id, parent_id, menu_code, menu_level,
@@ -65,7 +65,7 @@
</if>
</sql>
<!-- 找到当前菜单及所有他的父菜单 -->
<select id="queryMenu" resultType="cn.com.mfish.oauth.entity.SsoMenu">
<select id="queryMenu" resultType="cn.com.mfish.common.oauth.api.entity.SsoMenu">
SELECT m.* FROM sso_menu m
<include refid="menuJoin"/>
<where>
@@ -8,16 +8,17 @@ import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.common.oauth.api.entity.UserRole;
import cn.com.mfish.common.oauth.common.OauthUtils;
import cn.com.mfish.oauth.cache.common.ClearCache;
import cn.com.mfish.oauth.entity.SsoMenu;
import cn.com.mfish.common.oauth.api.entity.SsoMenu;
import cn.com.mfish.oauth.mapper.SsoMenuMapper;
import cn.com.mfish.oauth.req.ReqSsoMenu;
import cn.com.mfish.oauth.service.SsoMenuService;
import cn.com.mfish.common.oauth.req.ReqSsoMenu;
import cn.com.mfish.common.oauth.service.SsoMenuService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@@ -135,6 +136,11 @@ public class SsoMenuServiceImpl extends ServiceImpl<SsoMenuMapper, SsoMenu> impl
return Result.fail("错误:上级菜单选择不正确");
}
}
if (baseMapper.exists(new LambdaQueryWrapper<SsoMenu>()
.eq(SsoMenu::getRoutePath, ssoMenu.getRoutePath())
.ne(!StringUtils.isEmpty(ssoMenu.getId()), SsoMenu::getId, ssoMenu.getId()))) {
return Result.fail("错误:路由地址已存在");
}
return Result.ok("菜单校验成功");
}
@@ -158,6 +164,14 @@ public class SsoMenuServiceImpl extends ServiceImpl<SsoMenuMapper, SsoMenu> impl
return Result.fail("错误:菜单表-删除失败!");
}
@Override
public Result<Boolean> routeExist(String routePath) {
if (baseMapper.exists(new LambdaQueryWrapper<SsoMenu>().eq(SsoMenu::getRoutePath, routePath))) {
return Result.ok(true, "路由地址已存在");
}
return Result.fail(false, "路由地址不存在");
}
/**
* 按钮修改移除缓存中按钮权限
*
@@ -42,7 +42,7 @@ public class JobSubscribeController {
* @param reqJobSubscribe 任务订阅表请求参数
* @return 返回任务订阅表-分页列表
*/
@Operation(summary = "任务订阅表-分页列表查询", description = "任务订阅表-分页列表查询")
@Operation(summary = "任务订阅表-分页列表查询", description = "任务订阅表-分页列表查询")
@GetMapping
public Result<PageResult<JobSubscribe>> queryPageList(ReqJobSubscribe reqJobSubscribe, ReqPage reqPage) {
PageHelper.startPage(reqPage.getPageNum(), reqPage.getPageSize());
@@ -93,7 +93,7 @@ public class JobSubscribeController {
}
@Log(title = "设置订阅状态", operateType = OperateType.UPDATE)
@Operation(summary = "设置订阅状态", description = "设置订阅状态")
@Operation(summary = "设置订阅状态", description = "设置订阅状态")
@PutMapping("/status")
@RequiresPermissions("sys:job:update")
public Result<Boolean> setStatus(@RequestBody JobSubscribe jobSubscribe) throws SchedulerException, ClassNotFoundException {
@@ -117,20 +117,4 @@ public class JobSubscribeController {
return Result.fail(false, "错误:任务订阅表-删除失败!");
}
/**
* 批量删除
*
* @param ids 批量ID
* @return 返回任务订阅表-删除结果
*/
@Log(title = "任务订阅表-批量删除", operateType = OperateType.DELETE)
@Operation(summary = "任务订阅表-批量删除")
@DeleteMapping("/batch")
@RequiresPermissions("sys:job:delete")
public Result<Boolean> deleteBatch(@RequestParam(name = "ids") String ids) {
if (this.jobSubscribeService.removeByIds(Arrays.asList(ids.split(",")))) {
return Result.ok(true, "任务订阅表-批量删除成功!");
}
return Result.fail(false, "错误:任务订阅表-批量删除失败!");
}
}
@@ -1,17 +1,21 @@
code:
template:
keys:
- ${packageName}/controller/${entityName}Controller.java.ftl
- ${packageName}/entity/${entityName}.java.ftl
- ${packageName}/mapper/${entityName}Mapper.java.ftl
- ${packageName}/mapper/xml/${entityName}Mapper.xml.ftl
- ${packageName}/req/Req${entityName}.java.ftl
- ${packageName}/service/${entityName}Service.java.ftl
- ${packageName}/service/impl/${entityName}ServiceImpl.java.ftl
- src/main/java/${packageName}/controller/${entityName}Controller.java.ftl
- src/main/java/${packageName}/entity/${entityName}.java.ftl
- src/main/java/${packageName}/mapper/${entityName}Mapper.java.ftl
- src/main/java/${packageName}/mapper/xml/${entityName}Mapper.xml.ftl
- src/main/java/${packageName}/req/Req${entityName}.java.ftl
- src/main/java/${packageName}/service/${entityName}Service.java.ftl
- src/main/java/${packageName}/service/impl/${entityName}ServiceImpl.java.ftl
- mfish-nocode-view/src/views/${apiPrefix}/${entityName#kebab-case}/${entityName#uncap_first}.data.ts.ftl
- mfish-nocode-view/src/views/${apiPrefix}/${entityName#kebab-case}/${entityName}Modal.vue.ftl
- mfish-nocode-view/src/views/${apiPrefix}/${entityName#kebab-case}/index.vue.ftl
- mfish-nocode-view/src/api/${apiPrefix}/model/${entityName}Model.ts.ftl
- mfish-nocode-view/src/api/${apiPrefix}/${entityName}.ts.ftl
path: template
savePath: D:/mfish
savePath:
#前端地址
front: E:/webcode
#后端地址(需要指定到具体模块路径)
back: E:/javacode/mfish-nocode-pro/mf-business/mf-sys
@@ -1,5 +1,6 @@
package cn.com.mfish.test.sample;
import cn.com.mfish.common.core.constants.RPCConstants;
import cn.com.mfish.common.core.web.PageResult;
import cn.com.mfish.common.core.web.ReqPage;
import cn.com.mfish.common.core.web.Result;
@@ -16,6 +17,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import jakarta.annotation.Resource;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@@ -48,20 +50,20 @@ public class Sample1 {
@Test
public void testController() {
Result<PageResult<DbConnect>> result = remoteDbConnectService.queryPageList(new ReqDbConnect().setDbName("aaa"), new ReqPage());
Result<PageResult<DbConnect>> result = remoteDbConnectService.queryPageList(RPCConstants.INNER, new ReqDbConnect().setDbName("aaa"), new ReqPage());
System.out.println(result);
}
@Test
public void testDict() {
Result<List<DictItem>> result = remoteDictService.queryByCode("sso_grant_type");
Result<List<DictItem>> result = remoteDictService.queryByCode(RPCConstants.INNER, "sso_grant_type");
System.out.println(result.getData());
}
@Test
public void testOrg() {
Result<List<SsoOrg>> result = remoteOrgService.queryByFixCode("mysyb", "all");
Result<List<SsoOrg>> result1 = remoteOrgService.queryById("a453767fa3907e320f458f254a4549ae,bb94731770f981fae7eec5cbb1b32bb3");
Result<List<SsoOrg>> result = remoteOrgService.queryByFixCode(RPCConstants.INNER, "mysyb", "all");
Result<List<SsoOrg>> result1 = remoteOrgService.queryById(RPCConstants.INNER, "a453767fa3907e320f458f254a4549ae,bb94731770f981fae7eec5cbb1b32bb3");
System.out.println(result.getData());
System.out.println(result1.getData());
}