diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml index 1c7eae428..8cb29a5de 100644 --- a/ruoyi-admin/src/main/resources/application-prod.yml +++ b/ruoyi-admin/src/main/resources/application-prod.yml @@ -5,7 +5,7 @@ spring.servlet.multipart.location: /ruoyi/server/temp spring.boot.admin.client: # 增加客户端开关 enabled: true - url: http://localhost:9090/admin + url: http://47.121.30.27:9090/admin instance: service-host-type: IP metadata: @@ -22,7 +22,7 @@ snail-job: # SnailJob 接入验证令牌 详见 script/sql/ry_job.sql `sj_group_config`表 token: "SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT" server: - host: 127.0.0.1 + host: 47.121.30.27 port: 17888 # 命名空间UUID 详见 script/sql/ry_job.sql `sj_namespace`表`unique_id`字段 namespace: ${spring.profiles.active} @@ -52,9 +52,9 @@ spring: driverClassName: com.mysql.cj.jdbc.Driver # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562 # rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题) - url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: root + url: jdbc:mysql://47.121.30.27:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + username: ry-vue + password: yP487SnHJa3GWhrj # # 从库数据源 # slave: # lazy: true @@ -101,13 +101,13 @@ spring: spring.data: redis: # 地址 - host: localhost + host: 47.121.30.27 # 端口,默认为6379 port: 6379 # 数据库索引 database: 0 # redis 密码必须配置 - password: ruoyi123 + password: redis_JcKYKa # 连接超时时间 timeout: 10s # 是否开启ssl diff --git a/ruoyi-modules/pom.xml b/ruoyi-modules/pom.xml index daff497a0..3d82542bd 100644 --- a/ruoyi-modules/pom.xml +++ b/ruoyi-modules/pom.xml @@ -10,6 +10,7 @@ 4.0.0 + ruoyi-lx ruoyi-demo ruoyi-generator ruoyi-job diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestBatchController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestBatchController.java index af8c77b3a..f9fadbfdb 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestBatchController.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestBatchController.java @@ -3,8 +3,8 @@ package org.dromara.demo.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.dromara.common.core.domain.R; import org.dromara.common.web.core.BaseController; -import org.dromara.demo.domain.TestDemo; import org.dromara.demo.mapper.TestDemoMapper; +import org.dromara.demo.domain.TestDemo; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PostMapping; diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestDemoController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestDemoController.java index f31c54074..50d3e38c4 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestDemoController.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestDemoController.java @@ -15,11 +15,11 @@ 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.demo.service.ITestDemoService; import org.dromara.demo.domain.TestDemo; import org.dromara.demo.domain.bo.TestDemoBo; import org.dromara.demo.domain.bo.TestDemoImportVo; import org.dromara.demo.domain.vo.TestDemoVo; -import org.dromara.demo.service.ITestDemoService; import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; import org.springframework.validation.annotation.Validated; diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestEncryptController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestEncryptController.java index 2b6886db9..ca36e2a26 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestEncryptController.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestEncryptController.java @@ -1,8 +1,8 @@ package org.dromara.demo.controller; import org.dromara.common.core.domain.R; -import org.dromara.demo.domain.TestDemoEncrypt; import org.dromara.demo.mapper.TestDemoEncryptMapper; +import org.dromara.demo.domain.TestDemoEncrypt; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.validation.annotation.Validated; diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestExcelController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestExcelController.java index 3fd124c78..3b391eabc 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestExcelController.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestExcelController.java @@ -7,9 +7,9 @@ import lombok.Data; import lombok.RequiredArgsConstructor; import org.dromara.common.excel.core.ExcelResult; import org.dromara.common.excel.utils.ExcelUtil; -import org.dromara.demo.domain.vo.ExportDemoVo; import org.dromara.demo.listener.ExportDemoListener; import org.dromara.demo.service.IExportExcelService; +import org.dromara.demo.domain.vo.ExportDemoVo; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestTreeController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestTreeController.java index 5c552055f..2951f88d3 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestTreeController.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestTreeController.java @@ -10,9 +10,9 @@ 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.demo.service.ITestTreeService; import org.dromara.demo.domain.bo.TestTreeBo; import org.dromara.demo.domain.vo.TestTreeVo; -import org.dromara.demo.service.ITestTreeService; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/queue/BoundedQueueController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/queue/BoundedQueueController.java index 30ec27f7f..de2405f2b 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/queue/BoundedQueueController.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/controller/queue/BoundedQueueController.java @@ -1,11 +1,9 @@ package org.dromara.demo.controller.queue; -import cn.dev33.satoken.annotation.SaIgnore; import org.dromara.common.core.domain.R; import org.dromara.common.redis.utils.QueueUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.redisson.api.RBoundedBlockingQueue; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/service/impl/ExportExcelServiceImpl.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/service/impl/ExportExcelServiceImpl.java index 69cf0a8af..edb46f3ed 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/service/impl/ExportExcelServiceImpl.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/service/impl/ExportExcelServiceImpl.java @@ -9,8 +9,8 @@ import org.dromara.common.core.constant.SystemConstants; import org.dromara.common.core.utils.StreamUtils; import org.dromara.common.excel.core.DropDownOptions; import org.dromara.common.excel.utils.ExcelUtil; -import org.dromara.demo.domain.vo.ExportDemoVo; import org.dromara.demo.service.IExportExcelService; +import org.dromara.demo.domain.vo.ExportDemoVo; import org.springframework.stereotype.Service; import java.util.ArrayList; diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/service/impl/TestDemoServiceImpl.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/service/impl/TestDemoServiceImpl.java index ced141ef6..e6bb8e4db 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/service/impl/TestDemoServiceImpl.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/service/impl/TestDemoServiceImpl.java @@ -9,11 +9,11 @@ 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.demo.mapper.TestDemoMapper; +import org.dromara.demo.service.ITestDemoService; import org.dromara.demo.domain.TestDemo; import org.dromara.demo.domain.bo.TestDemoBo; import org.dromara.demo.domain.vo.TestDemoVo; -import org.dromara.demo.mapper.TestDemoMapper; -import org.dromara.demo.service.ITestDemoService; import org.springframework.stereotype.Service; import java.util.Collection; diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/service/impl/TestTreeServiceImpl.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/service/impl/TestTreeServiceImpl.java index e4e548b65..4d58b626f 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/service/impl/TestTreeServiceImpl.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/org/dromara/demo/service/impl/TestTreeServiceImpl.java @@ -4,11 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; +import org.dromara.demo.mapper.TestTreeMapper; +import org.dromara.demo.service.ITestTreeService; import org.dromara.demo.domain.TestTree; import org.dromara.demo.domain.bo.TestTreeBo; import org.dromara.demo.domain.vo.TestTreeVo; -import org.dromara.demo.mapper.TestTreeMapper; -import org.dromara.demo.service.ITestTreeService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/ruoyi-modules/ruoyi-lx/pom.xml b/ruoyi-modules/ruoyi-lx/pom.xml new file mode 100644 index 000000000..b3225c336 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/pom.xml @@ -0,0 +1,108 @@ + + + + org.dromara + ruoyi-modules + ${revision} + + 4.0.0 + + ruoyi-lx + + + 龙翔业务模块 + + + + + + + org.dromara + ruoyi-common-core + + + + org.dromara + ruoyi-common-doc + + + + org.dromara + ruoyi-common-sms + + + + org.dromara + ruoyi-common-mail + + + + org.dromara + ruoyi-common-redis + + + + org.dromara + ruoyi-common-idempotent + + + + org.dromara + ruoyi-common-mybatis + + + + org.dromara + ruoyi-common-log + + + + org.dromara + ruoyi-common-excel + + + + org.dromara + ruoyi-common-security + + + + org.dromara + ruoyi-common-web + + + + org.dromara + ruoyi-common-ratelimiter + + + + org.dromara + ruoyi-common-translation + + + + org.dromara + ruoyi-common-sensitive + + + + org.dromara + ruoyi-common-encrypt + + + + org.dromara + ruoyi-common-tenant + + + + org.dromara + ruoyi-common-websocket + + + + + diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/controller/TestTreeAController.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/controller/TestTreeAController.java new file mode 100644 index 000000000..538b2d1f0 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/controller/TestTreeAController.java @@ -0,0 +1,107 @@ +package org.dromara.lx.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.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.lx.domain.bo.TestTreeBo; +import org.dromara.lx.domain.vo.TestTreeVo; +import org.dromara.lx.service.ITestTreeService; +import lombok.RequiredArgsConstructor; +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; + +/** + * 测试树表Controller + * + * @author Lion Li + * @date 2021-07-26 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/demo/tree1") +public class TestTreeAController extends BaseController { + + private final ITestTreeService testTreeService; + + /** + * 查询测试树表列表 + */ + @SaCheckPermission("demo:tree:list") + @GetMapping("/list") + public R> list(@Validated(QueryGroup.class) TestTreeBo bo) { + List list = testTreeService.queryList(bo); + return R.ok(list); + } + + /** + * 导出测试树表列表 + */ + @SaCheckPermission("demo:tree:export") + @Log(title = "测试树表", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public void export(@Validated TestTreeBo bo, HttpServletResponse response) { + List list = testTreeService.queryList(bo); + ExcelUtil.exportExcel(list, "测试树表", TestTreeVo.class, response); + } + + /** + * 获取测试树表详细信息 + * + * @param id 测试树ID + */ + @SaCheckPermission("demo:tree:query") + @GetMapping("/{id}") + public R getInfo(@NotNull(message = "主键不能为空") + @PathVariable("id") Long id) { + return R.ok(testTreeService.queryById(id)); + } + + /** + * 新增测试树表 + */ + @SaCheckPermission("demo:tree:add") + @Log(title = "测试树表", businessType = BusinessType.INSERT) + @RepeatSubmit + @PostMapping() + public R add(@Validated(AddGroup.class) @RequestBody TestTreeBo bo) { + return toAjax(testTreeService.insertByBo(bo)); + } + + /** + * 修改测试树表 + */ + @SaCheckPermission("demo:tree:edit") + @Log(title = "测试树表", businessType = BusinessType.UPDATE) + @RepeatSubmit + @PutMapping() + public R edit(@Validated(EditGroup.class) @RequestBody TestTreeBo bo) { + return toAjax(testTreeService.updateByBo(bo)); + } + + /** + * 删除测试树表 + * + * @param ids 测试树ID串 + */ + @SaCheckPermission("demo:tree:remove") + @Log(title = "测试树表", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public R remove(@NotEmpty(message = "主键不能为空") + @PathVariable Long[] ids) { + return toAjax(testTreeService.deleteWithValidByIds(Arrays.asList(ids), true)); + } +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/TestDemo.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/TestDemo.java new file mode 100644 index 000000000..df34782c3 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/TestDemo.java @@ -0,0 +1,68 @@ +package org.dromara.lx.domain; + +import com.baomidou.mybatisplus.annotation.*; +import org.dromara.common.tenant.core.TenantEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; + +/** + * 测试单表对象 test_demo + * + * @author Lion Li + * @date 2021-07-26 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("test_demo") +public class TestDemo extends TenantEntity { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id") + private Long id; + + /** + * 部门id + */ + private Long deptId; + + /** + * 用户id + */ + private Long userId; + + /** + * 排序号 + */ + @OrderBy(asc = false, sort = 1) + private Integer orderNum; + + /** + * key键 + */ + private String testKey; + + /** + * 值 + */ + private String value; + + /** + * 版本 + */ + @Version + private Long version; + + /** + * 删除标志 + */ + @TableLogic + private Long delFlag; + +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/TestDemoEncrypt.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/TestDemoEncrypt.java new file mode 100644 index 000000000..53f2ee032 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/TestDemoEncrypt.java @@ -0,0 +1,29 @@ +package org.dromara.lx.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import org.dromara.common.encrypt.annotation.EncryptField; +import org.dromara.common.encrypt.enumd.AlgorithmType; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("test_demo") +public class TestDemoEncrypt extends TestDemo { + + /** + * key键 + */ + // @EncryptField(algorithm=AlgorithmType.SM2, privateKey = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgZSlOvw8FBiH+aFJWLYZP/VRjg9wjfRarTkGBZd/T3N+gCgYIKoEcz1UBgi2hRANCAAR5DGuQwJqkxnbCsP+iPSDoHWIF4RwcR5EsSvT8QPxO1wRkR2IhCkzvRb32x2CUgJFdvoqVqfApFDPZzShqzBwX", publicKey = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEeQxrkMCapMZ2wrD/oj0g6B1iBeEcHEeRLEr0/ED8TtcEZEdiIQpM70W99sdglICRXb6KlanwKRQz2c0oaswcFw==") + @EncryptField(algorithm = AlgorithmType.RSA, privateKey = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBANBBEeueWlXlkkj2+WY5l+IWe42d8b5K28g+G/CFKC/yYAEHtqGlCsBOrb+YBkG9mPzmuYA/n9k0NFIc8E8yY5vZQaroyFBrTTWEzG9RY2f7Y3svVyybs6jpXSUs4xff8abo7wL1Y/wUaeatTViamxYnyTvdTmLm3d+JjRij68rxAgMBAAECgYAB0TnhXraSopwIVRfmboea1b0upl+BUdTJcmci412UjrKr5aE695ZLPkXbFXijVu7HJlyyv94NVUdaMACV7Ku/S2RuNB70M7YJm8rAjHFC3/i2ZeIM60h1Ziy4QKv0XM3pRATlDCDNhC1WUrtQCQSgU8kcp6eUUppruOqDzcY04QJBAPm9+sBP9CwDRgy3e5+V8aZtJkwDstb0lVVV/KY890cydVxiCwvX3fqVnxKMlb+x0YtH0sb9v+71xvK2lGobaRECQQDVePU6r/cCEfpc+nkWF6osAH1f8Mux3rYv2DoBGvaPzV2BGfsLed4neRfCwWNCKvGPCdW+L0xMJg8+RwaoBUPhAkAT5kViqXxFPYWJYd1h2+rDXhMdH3ZSlm6HvDBDdrwlWinr0Iwcx3iSjPV93uHXwm118aUj4fg3LDJMCKxOwBxhAkByrQXfvwOMYygBprRBf/j0plazoWFrbd6lGR0f1uI5IfNnFRPdeFw1DEINZ2Hw+6zEUF44SqRMC+4IYJNc02dBAkBCgy7RvfyV/A7N6kKXxTHauY0v6XwSSvpeKtRJkbIcRWOdIYvaHO9L7cklj3vIEdwjSUp9K4VTBYYlmAz1xh03", publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQQRHrnlpV5ZJI9vlmOZfiFnuNnfG+StvIPhvwhSgv8mABB7ahpQrATq2/mAZBvZj85rmAP5/ZNDRSHPBPMmOb2UGq6MhQa001hMxvUWNn+2N7L1csm7Oo6V0lLOMX3/Gm6O8C9WP8FGnmrU1YmpsWJ8k73U5i5t3fiY0Yo+vK8QIDAQAB") + private String testKey; + + /** + * 值 + */ + // @EncryptField // 什么也不写走默认yml配置 + // @EncryptField(algorithm = AlgorithmType.SM4, password = "10rfylhtccpuyke5") + @EncryptField(algorithm = AlgorithmType.AES, password = "10rfylhtccpuyke5") + private String value; + +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/TestTree.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/TestTree.java new file mode 100644 index 000000000..379d63aa1 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/TestTree.java @@ -0,0 +1,65 @@ +package org.dromara.lx.domain; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.Version; +import org.dromara.common.tenant.core.TenantEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; + +/** + * 测试树表对象 test_tree + * + * @author Lion Li + * @date 2021-07-26 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("test_tree") +public class TestTree extends TenantEntity { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id") + private Long id; + + /** + * 父ID + */ + private Long parentId; + + /** + * 部门id + */ + private Long deptId; + + /** + * 用户id + */ + private Long userId; + + /** + * 树节点名 + */ + private String treeName; + + /** + * 版本 + */ + @Version + private Long version; + + /** + * 删除标志 + */ + @TableLogic + private Long delFlag; + +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/bo/TestDemoBo.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/bo/TestDemoBo.java new file mode 100644 index 000000000..edc9f11e0 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/bo/TestDemoBo.java @@ -0,0 +1,62 @@ +package org.dromara.lx.domain.bo; + +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.lx.domain.TestDemo; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 测试单表业务对象 test_demo + * + * @author Lion Li + * @date 2021-07-26 + */ + +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = TestDemo.class, reverseConvertGenerate = false) +public class TestDemoBo extends BaseEntity { + + /** + * 主键 + */ + @NotNull(message = "主键不能为空", groups = {EditGroup.class}) + private Long id; + + /** + * 部门id + */ + @NotNull(message = "部门id不能为空", groups = {AddGroup.class, EditGroup.class}) + private Long deptId; + + /** + * 用户id + */ + @NotNull(message = "用户id不能为空", groups = {AddGroup.class, EditGroup.class}) + private Long userId; + + /** + * 排序号 + */ + @NotNull(message = "排序号不能为空", groups = {AddGroup.class, EditGroup.class}) + private Integer orderNum; + + /** + * key键 + */ + @NotBlank(message = "key键不能为空", groups = {AddGroup.class, EditGroup.class}) + private String testKey; + + /** + * 值 + */ + @NotBlank(message = "值不能为空", groups = {AddGroup.class, EditGroup.class}) + private String value; + +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/bo/TestDemoImportVo.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/bo/TestDemoImportVo.java new file mode 100644 index 000000000..a72fbf107 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/bo/TestDemoImportVo.java @@ -0,0 +1,53 @@ +package org.dromara.lx.domain.bo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +/** + * 测试单表业务对象 test_demo + * + * @author Lion Li + * @date 2021-07-26 + */ +@Data +public class TestDemoImportVo { + + /** + * 部门id + */ + @NotNull(message = "部门id不能为空") + @ExcelProperty(value = "部门id") + private Long deptId; + + /** + * 用户id + */ + @NotNull(message = "用户id不能为空") + @ExcelProperty(value = "用户id") + private Long userId; + + /** + * 排序号 + */ + @NotNull(message = "排序号不能为空") + @ExcelProperty(value = "排序号") + private Long orderNum; + + /** + * key键 + */ + @NotBlank(message = "key键不能为空") + @ExcelProperty(value = "key键") + private String testKey; + + /** + * 值 + */ + @NotBlank(message = "值不能为空") + @ExcelProperty(value = "值") + private String value; + +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/bo/TestTreeBo.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/bo/TestTreeBo.java new file mode 100644 index 000000000..e674eeb60 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/bo/TestTreeBo.java @@ -0,0 +1,54 @@ +package org.dromara.lx.domain.bo; + +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.lx.domain.TestTree; +import io.github.linpeilie.annotations.AutoMapper; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 测试树表业务对象 test_tree + * + * @author Lion Li + * @date 2021-07-26 + */ + +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = TestTree.class, reverseConvertGenerate = false) +public class TestTreeBo extends BaseEntity { + + /** + * 主键 + */ + @NotNull(message = "主键不能为空", groups = {EditGroup.class}) + private Long id; + + /** + * 父ID + */ + private Long parentId; + + /** + * 部门id + */ + @NotNull(message = "部门id不能为空", groups = {AddGroup.class, EditGroup.class}) + private Long deptId; + + /** + * 用户id + */ + @NotNull(message = "用户id不能为空", groups = {AddGroup.class, EditGroup.class}) + private Long userId; + + /** + * 树节点名 + */ + @NotBlank(message = "树节点名不能为空", groups = {AddGroup.class, EditGroup.class}) + private String treeName; + +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/package-info.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/package-info.java new file mode 100644 index 000000000..13320face --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/package-info.java @@ -0,0 +1 @@ +package org.dromara.lx.domain; diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/vo/ExportDemoVo.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/vo/ExportDemoVo.java new file mode 100644 index 000000000..3e213403f --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/vo/ExportDemoVo.java @@ -0,0 +1,122 @@ +package org.dromara.lx.domain.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.dromara.common.core.enums.UserStatus; +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import org.dromara.common.excel.annotation.ExcelDictFormat; +import org.dromara.common.excel.annotation.ExcelEnumFormat; +import org.dromara.common.excel.convert.ExcelDictConvert; +import org.dromara.common.excel.convert.ExcelEnumConvert; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 带有下拉选的Excel导出 + * + * @author Emil.Zhang + */ +@Data +@ExcelIgnoreUnannotated +@AllArgsConstructor +@NoArgsConstructor +public class ExportDemoVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 用户昵称 + */ + @ExcelProperty(value = "用户名", index = 0) + @NotEmpty(message = "用户名不能为空", groups = AddGroup.class) + private String nickName; + + /** + * 用户类型 + *

+ * 使用ExcelEnumFormat注解需要进行下拉选的部分 + */ + @ExcelProperty(value = "用户类型", index = 1, converter = ExcelEnumConvert.class) + @ExcelEnumFormat(enumClass = UserStatus.class, textField = "info") + @NotEmpty(message = "用户类型不能为空", groups = AddGroup.class) + private String userStatus; + + /** + * 性别 + *

+ * 使用ExcelDictFormat注解需要进行下拉选的部分 + */ + @ExcelProperty(value = "性别", index = 2, converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "sys_user_sex") + @NotEmpty(message = "性别不能为空", groups = AddGroup.class) + private String gender; + + /** + * 手机号 + */ + @ExcelProperty(value = "手机号", index = 3) + @NotEmpty(message = "手机号不能为空", groups = AddGroup.class) + private String phoneNumber; + + /** + * Email + */ + @ExcelProperty(value = "Email", index = 4) + @NotEmpty(message = "Email不能为空", groups = AddGroup.class) + private String email; + + /** + * 省 + *

+ * 级联下拉,仅判断是否选了 + */ + @ExcelProperty(value = "省", index = 5) + @NotNull(message = "省不能为空", groups = AddGroup.class) + private String province; + + /** + * 数据库中的省ID + *

+ * 处理完毕后再判断是否市正确的值 + */ + @NotNull(message = "请勿手动输入", groups = EditGroup.class) + private Integer provinceId; + + /** + * 市 + *

+ * 级联下拉 + */ + @ExcelProperty(value = "市", index = 6) + @NotNull(message = "市不能为空", groups = AddGroup.class) + private String city; + + /** + * 数据库中的市ID + */ + @NotNull(message = "请勿手动输入", groups = EditGroup.class) + private Integer cityId; + + /** + * 县 + *

+ * 级联下拉 + */ + @ExcelProperty(value = "县", index = 7) + @NotNull(message = "县不能为空", groups = AddGroup.class) + private String area; + + /** + * 数据库中的县ID + */ + @NotNull(message = "请勿手动输入", groups = EditGroup.class) + private Integer areaId; +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/vo/TestDemoVo.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/vo/TestDemoVo.java new file mode 100644 index 000000000..81da2b613 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/vo/TestDemoVo.java @@ -0,0 +1,111 @@ +package org.dromara.lx.domain.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import org.dromara.common.excel.annotation.ExcelNotation; +import org.dromara.common.excel.annotation.ExcelRequired; +import org.dromara.common.translation.annotation.Translation; +import org.dromara.common.translation.constant.TransConstant; +import org.dromara.lx.domain.TestDemo; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + + +/** + * 测试单表视图对象 test_demo + * + * @author Lion Li + * @date 2021-07-26 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = TestDemo.class) +public class TestDemoVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @ExcelProperty(value = "主键") + private Long id; + + /** + * 部门id + */ + @ExcelRequired + @ExcelProperty(value = "部门id") + private Long deptId; + + /** + * 用户id + */ + @ExcelRequired + @ExcelProperty(value = "用户id") + private Long userId; + + /** + * 排序号 + */ + @ExcelRequired + @ExcelProperty(value = "排序号") + private Integer orderNum; + + /** + * key键 + */ + @ExcelNotation(value = "测试key") + @ExcelProperty(value = "key键") + private String testKey; + + /** + * 值 + */ + @ExcelNotation(value = "测试value") + @ExcelProperty(value = "值") + private String value; + + /** + * 创建时间 + */ + @ExcelProperty(value = "创建时间") + private Date createTime; + + /** + * 创建人 + */ + @ExcelProperty(value = "创建人") + private Long createBy; + + /** + * 创建人账号 + */ + @Translation(type = TransConstant.USER_ID_TO_NAME, mapper = "createBy") + @ExcelProperty(value = "创建人账号") + private String createByName; + + /** + * 更新时间 + */ + @ExcelProperty(value = "更新时间") + private Date updateTime; + + /** + * 更新人 + */ + @ExcelProperty(value = "更新人") + private Long updateBy; + + /** + * 更新人账号 + */ + @Translation(type = TransConstant.USER_ID_TO_NAME, mapper = "updateBy") + @ExcelProperty(value = "更新人账号") + private String updateByName; + +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/vo/TestTreeVo.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/vo/TestTreeVo.java new file mode 100644 index 000000000..440713b79 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/domain/vo/TestTreeVo.java @@ -0,0 +1,64 @@ +package org.dromara.lx.domain.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import org.dromara.lx.domain.TestTree; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + + +/** + * 测试树表视图对象 test_tree + * + * @author Lion Li + * @date 2021-07-26 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = TestTree.class) +public class TestTreeVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private Long id; + + /** + * 父id + */ + @ExcelProperty(value = "父id") + private Long parentId; + + /** + * 部门id + */ + @ExcelProperty(value = "部门id") + private Long deptId; + + /** + * 用户id + */ + @ExcelProperty(value = "用户id") + private Long userId; + + /** + * 树节点名 + */ + @ExcelProperty(value = "树节点名") + private String treeName; + + /** + * 创建时间 + */ + @ExcelProperty(value = "创建时间") + private Date createTime; + + +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/listener/ExportDemoListener.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/listener/ExportDemoListener.java new file mode 100644 index 000000000..acdaf89e3 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/listener/ExportDemoListener.java @@ -0,0 +1,68 @@ +package org.dromara.lx.listener; + +import cn.hutool.core.util.NumberUtil; +import com.alibaba.excel.context.AnalysisContext; +import org.dromara.common.core.utils.ValidatorUtils; +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import org.dromara.common.excel.core.DefaultExcelListener; +import org.dromara.common.excel.core.DropDownOptions; +import org.dromara.lx.domain.vo.ExportDemoVo; + +import java.util.List; + +/** + * Excel带下拉框的解析处理器 + * + * @author Emil.Zhang + */ +public class ExportDemoListener extends DefaultExcelListener { + + public ExportDemoListener() { + // 显示使用构造函数,否则将导致空指针 + super(true); + } + + @Override + public void invoke(ExportDemoVo data, AnalysisContext context) { + // 先校验必填 + ValidatorUtils.validate(data, AddGroup.class); + + // 处理级联下拉的部分 + String province = data.getProvince(); + String city = data.getCity(); + String area = data.getArea(); + // 本行用户选择的省 + List thisRowSelectedProvinceOption = DropDownOptions.analyzeOptionValue(province); + if (thisRowSelectedProvinceOption.size() == 2) { + String provinceIdStr = thisRowSelectedProvinceOption.get(1); + if (NumberUtil.isNumber(provinceIdStr)) { + // 严格要求数据的话可以在这里做与数据库相关的判断 + // 例如判断省信息是否在数据库中存在等,建议结合RedisCache做缓存10s,减少数据库调用 + data.setProvinceId(Integer.parseInt(provinceIdStr)); + } + } + // 本行用户选择的市 + List thisRowSelectedCityOption = DropDownOptions.analyzeOptionValue(city); + if (thisRowSelectedCityOption.size() == 2) { + String cityIdStr = thisRowSelectedCityOption.get(1); + if (NumberUtil.isNumber(cityIdStr)) { + data.setCityId(Integer.parseInt(cityIdStr)); + } + } + // 本行用户选择的县 + List thisRowSelectedAreaOption = DropDownOptions.analyzeOptionValue(area); + if (thisRowSelectedAreaOption.size() == 2) { + String areaIdStr = thisRowSelectedAreaOption.get(1); + if (NumberUtil.isNumber(areaIdStr)) { + data.setAreaId(Integer.parseInt(areaIdStr)); + } + } + + // 处理完毕以后判断是否符合规则 + ValidatorUtils.validate(data, EditGroup.class); + + // 添加到处理结果中 + getExcelResult().getList().add(data); + } +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/mapper/TestTreeMapper.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/mapper/TestTreeMapper.java new file mode 100644 index 000000000..b00d8c6db --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/mapper/TestTreeMapper.java @@ -0,0 +1,21 @@ +package org.dromara.lx.mapper; + +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.lx.domain.TestTree; +import org.dromara.lx.domain.vo.TestTreeVo; + +/** + * 测试树表Mapper接口 + * + * @author Lion Li + * @date 2021-07-26 + */ +@DataPermission({ + @DataColumn(key = "deptName", value = "dept_id"), + @DataColumn(key = "userName", value = "user_id") +}) +public interface TestTreeMapper extends BaseMapperPlus { + +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/mapper/package-info.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/mapper/package-info.java new file mode 100644 index 000000000..4c80e3a3a --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/mapper/package-info.java @@ -0,0 +1 @@ +package org.dromara.lx.mapper; diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/service/ITestTreeService.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/service/ITestTreeService.java new file mode 100644 index 000000000..2c85fb4cc --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/service/ITestTreeService.java @@ -0,0 +1,52 @@ +package org.dromara.lx.service; + +import org.dromara.lx.domain.bo.TestTreeBo; +import org.dromara.lx.domain.vo.TestTreeVo; + +import java.util.Collection; +import java.util.List; + +/** + * 测试树表Service接口 + * + * @author Lion Li + * @date 2021-07-26 + */ +public interface ITestTreeService { + /** + * 查询单个 + * + * @return + */ + TestTreeVo queryById(Long id); + + /** + * 查询列表 + */ + List queryList(TestTreeBo bo); + + /** + * 根据新增业务对象插入测试树表 + * + * @param bo 测试树表新增业务对象 + * @return + */ + Boolean insertByBo(TestTreeBo bo); + + /** + * 根据编辑业务对象修改测试树表 + * + * @param bo 测试树表编辑业务对象 + * @return + */ + Boolean updateByBo(TestTreeBo bo); + + /** + * 校验并删除数据 + * + * @param ids 主键集合 + * @param isValid 是否校验,true-删除前校验,false-不校验 + * @return + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/service/impl/TestTreeServiceImpl.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/service/impl/TestTreeServiceImpl.java new file mode 100644 index 000000000..a61b034ee --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/service/impl/TestTreeServiceImpl.java @@ -0,0 +1,88 @@ +package org.dromara.lx.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import org.dromara.common.core.utils.MapstructUtils; +import org.dromara.common.core.utils.StringUtils; +import org.dromara.lx.domain.TestTree; +import org.dromara.lx.domain.bo.TestTreeBo; +import org.dromara.lx.domain.vo.TestTreeVo; +import org.dromara.lx.mapper.TestTreeMapper; +import org.dromara.lx.service.ITestTreeService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 测试树表Service业务层处理 + * + * @author Lion Li + * @date 2021-07-26 + */ +// @DS("slave") // 切换从库查询 +@RequiredArgsConstructor +@Service +public class TestTreeServiceImpl implements ITestTreeService { + + private final TestTreeMapper baseMapper; + + @Override + public TestTreeVo queryById(Long id) { + return baseMapper.selectVoById(id); + } + + // @DS("slave") // 切换从库查询 + @Override + public List queryList(TestTreeBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(TestTreeBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.like(StringUtils.isNotBlank(bo.getTreeName()), TestTree::getTreeName, bo.getTreeName()); + lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null, + TestTree::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); + lqw.orderByAsc(TestTree::getId); + return lqw; + } + + @Override + public Boolean insertByBo(TestTreeBo bo) { + TestTree add = MapstructUtils.convert(bo, TestTree.class); + validEntityBeforeSave(add); + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setId(add.getId()); + } + return flag; + } + + @Override + public Boolean updateByBo(TestTreeBo bo) { + TestTree update = MapstructUtils.convert(bo, TestTree.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + * + * @param entity 实体类数据 + */ + private void validEntityBeforeSave(TestTree entity) { + //TODO 做一些数据校验,如唯一约束 + } + + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if (isValid) { + //TODO 做一些业务上的校验,判断是否需要校验 + } + return baseMapper.deleteByIds(ids) > 0; + } +} diff --git a/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/service/package-info.java b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/service/package-info.java new file mode 100644 index 000000000..e37f5db5a --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/java/org/dromara/lx/service/package-info.java @@ -0,0 +1 @@ +package org.dromara.lx.service; diff --git a/ruoyi-modules/ruoyi-lx/src/main/resources/mapper/demo/TestDemoMapper.xml b/ruoyi-modules/ruoyi-lx/src/main/resources/mapper/demo/TestDemoMapper.xml new file mode 100644 index 000000000..6e375d3a1 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/resources/mapper/demo/TestDemoMapper.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/ruoyi-modules/ruoyi-lx/src/main/resources/mapper/demo/TestTreeMapper.xml b/ruoyi-modules/ruoyi-lx/src/main/resources/mapper/demo/TestTreeMapper.xml new file mode 100644 index 000000000..d7975ec52 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/resources/mapper/demo/TestTreeMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/ruoyi-modules/ruoyi-lx/src/main/resources/mapper/package-info.md b/ruoyi-modules/ruoyi-lx/src/main/resources/mapper/package-info.md new file mode 100644 index 000000000..c938b1e50 --- /dev/null +++ b/ruoyi-modules/ruoyi-lx/src/main/resources/mapper/package-info.md @@ -0,0 +1,3 @@ +java包使用 `.` 分割 resource 目录使用 `/` 分割 +
+此文件目的 防止文件夹粘连找不到 `xml` 文件 \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/TestController.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/TestController.java new file mode 100644 index 000000000..f9ca8ce80 --- /dev/null +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/TestController.java @@ -0,0 +1,108 @@ +package org.dromara.workflow.controller; + +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.workflow.common.ConditionalOnEnable; +import org.dromara.workflow.domain.bo.TestLeaveBo; +import org.dromara.workflow.domain.vo.TestLeaveVo; +import org.dromara.workflow.service.ITestLeaveService; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 请假 + * + * @author may + * @date 2023-07-21 + */ +@ConditionalOnEnable +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/workflow/leave") +public class TestController extends BaseController { + + private final ITestLeaveService testLeaveService; + + /** + * 查询请假列表 + */ + @SaCheckPermission("workflow:leave:list") + @GetMapping("/list") + public TableDataInfo list(TestLeaveBo bo, PageQuery pageQuery) { + return testLeaveService.queryPageList(bo, pageQuery); + } + + /** + * 导出请假列表 + */ + @SaCheckPermission("workflow:leave:export") + @Log(title = "请假", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(TestLeaveBo bo, HttpServletResponse response) { + List list = testLeaveService.queryList(bo); + ExcelUtil.exportExcel(list, "请假", TestLeaveVo.class, response); + } + + /** + * 获取请假详细信息 + * + * @param id 主键 + */ + @SaCheckPermission("workflow:leave:query") + @GetMapping("/{id}") + public R getInfo(@NotNull(message = "主键不能为空") + @PathVariable Long id) { + return R.ok(testLeaveService.queryById(id)); + } + + /** + * 新增请假 + */ + @SaCheckPermission("workflow:leave:add") + @Log(title = "请假", businessType = BusinessType.INSERT) + @RepeatSubmit() + @PostMapping() + public R add(@Validated(AddGroup.class) @RequestBody TestLeaveBo bo) { + return R.ok(testLeaveService.insertByBo(bo)); + } + + /** + * 修改请假 + */ + @SaCheckPermission("workflow:leave:edit") + @Log(title = "请假", businessType = BusinessType.UPDATE) + @RepeatSubmit() + @PutMapping() + public R edit(@Validated(EditGroup.class) @RequestBody TestLeaveBo bo) { + return R.ok(testLeaveService.updateByBo(bo)); + } + + /** + * 删除请假 + * + * @param ids 主键串 + */ + @SaCheckPermission("workflow:leave:remove") + @Log(title = "请假", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public R remove(@NotEmpty(message = "主键不能为空") + @PathVariable Long[] ids) { + return toAjax(testLeaveService.deleteWithValidByIds(List.of(ids))); + } +} diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/bo/TestLeaveBo.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/bo/TestLeaveBo.java index a1a4b5968..5933f218f 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/bo/TestLeaveBo.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/bo/TestLeaveBo.java @@ -75,5 +75,10 @@ public class TestLeaveBo extends BaseEntity { */ private String status; + /** + * 部门 + */ + private String dept; + } diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/listener/FinishListener.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/listener/FinishListener.java new file mode 100644 index 000000000..d472c18e1 --- /dev/null +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/listener/FinishListener.java @@ -0,0 +1,23 @@ +package org.dromara.workflow.listener; + +import org.dromara.warm.flow.core.entity.Instance; +import org.dromara.warm.flow.core.listener.Listener; +import org.dromara.warm.flow.core.listener.ListenerVariable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.util.Map; + +@Component +public class FinishListener implements Listener { +// private static final Logger log = LoggerFactory.getLogger(StartListener.class); + + @Override + public void notify(ListenerVariable variable) { +// log.info("完成监听器:{}", variable); + Instance instance = variable.getInstance(); + Map testLeaveMap = variable.getVariable(); +// log.info("完成监听器结束......"); + } +} diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java index 9ecd867ac..641235cd6 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java @@ -19,6 +19,7 @@ import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.core.domain.BaseEntity; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.warm.flow.core.entity.Instance; import org.dromara.workflow.common.ConditionalOnEnable; import org.dromara.workflow.domain.TestLeave; import org.dromara.workflow.domain.bo.TestLeaveBo; @@ -29,6 +30,7 @@ import org.springframework.context.event.EventListener; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -109,6 +111,12 @@ public class TestLeaveServiceImpl implements ITestLeaveService { add.setStatus(BusinessStatusEnum.DRAFT.getStatus()); } boolean flag = baseMapper.insert(add) > 0; + // 流程变量 + Map variable = new HashMap<>(); +// variable.put("testLeave", testLeave); +// variable.put("flag", String.valueOf(testLeave.getDay())); +// flowParams.variable(variable); +// Instance instance = insService.start(id, flowParams); if (flag) { bo.setId(add.getId()); } diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/WorkflowServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/WorkflowServiceImpl.java index f8a20b5b4..3ecc928cc 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/WorkflowServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/WorkflowServiceImpl.java @@ -129,4 +129,6 @@ public class WorkflowServiceImpl implements WorkflowService { public boolean completeTask(CompleteTaskDTO completeTask) { return flwTaskService.completeTask(BeanUtil.toBean(completeTask, CompleteTaskBo.class)); } + + }