From 7672ae5a79c6194339ed431a5c4a9ce8c27f854f Mon Sep 17 00:00:00 2001 From: cjw Date: Fri, 1 Nov 2024 10:55:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/AuthController.java | 3 +- .../web/service/impl/XcxAuthStrategy.java | 17 +++++ .../src/main/resources/application-prod.yml | 53 +++++--------- .../src/main/resources/application.yml | 3 +- .../java/org/dromara/test/AssertUnitTest.java | 45 ------------ .../java/org/dromara/test/DemoUnitTest.java | 70 ------------------ .../java/org/dromara/test/ParamUnitTest.java | 72 ------------------- .../java/org/dromara/test/TagUnitTest.java | 54 -------------- .../controller/wx/WxEvaluationController.java | 28 +++----- .../system/controller/wx/WxMyController.java | 23 ++++-- .../controller/wx/WxScaleController.java | 12 ++-- .../wx/WxScoreRecordController.java | 13 ++-- .../dromara/system/domain/SysScaleOrder.java | 4 +- .../system/domain/SysScalePackage.java | 3 +- .../org/dromara/system/domain/SysTenant.java | 3 +- .../system/domain/SysTenantPackage.java | 11 +-- .../system/domain/bo/ScoreRecordBo.java | 4 +- .../dromara/system/domain/bo/SysScaleBo.java | 8 +-- .../mapper/SysEvaluationRecordMapper.java | 5 -- .../system/service/IEvaluationService.java | 8 +-- .../service/impl/CounselorServiceImpl.java | 20 +++--- .../service/impl/EvaluationServiceImpl.java | 52 ++++++-------- .../system/service/impl/MyServiceImpl.java | 20 ++++-- .../impl/ReservationRefundServiceImpl.java | 2 +- .../service/impl/ScoreRecordServiceImpl.java | 13 ++-- .../impl/SysEvaluationRecordServiceImpl.java | 7 +- .../service/impl/SysOssServiceImpl.java | 2 + .../service/impl/SysScaleServiceImpl.java | 5 ++ .../service/impl/SysTenantServiceImpl.java | 32 +++++---- .../system/SysEvaluationRecordMapper.xml | 7 +- 30 files changed, 187 insertions(+), 412 deletions(-) delete mode 100644 ruoyi-admin/src/test/java/org/dromara/test/AssertUnitTest.java delete mode 100644 ruoyi-admin/src/test/java/org/dromara/test/DemoUnitTest.java delete mode 100644 ruoyi-admin/src/test/java/org/dromara/test/ParamUnitTest.java delete mode 100644 ruoyi-admin/src/test/java/org/dromara/test/TagUnitTest.java diff --git a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java index 83ed732..8439f08 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java @@ -12,6 +12,7 @@ import me.zhyd.oauth.model.AuthResponse; import me.zhyd.oauth.model.AuthUser; import me.zhyd.oauth.request.AuthRequest; import me.zhyd.oauth.utils.AuthStateUtils; +import org.dromara.common.core.constant.TenantConstants; import org.dromara.common.core.constant.UserConstants; import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.model.LoginBody; @@ -134,7 +135,7 @@ public class AuthController { // 校验租户 if (StringUtils.isEmpty(loginBody.getTenantId())) { //没有则默认注册在主租户下; - loginBody.setTenantId("000000"); + loginBody.setTenantId(TenantConstants.DEFAULT_TENANT_ID); } else { loginService.checkTenant(loginBody.getTenantId()); } diff --git a/ruoyi-admin/src/main/java/org/dromara/web/service/impl/XcxAuthStrategy.java b/ruoyi-admin/src/main/java/org/dromara/web/service/impl/XcxAuthStrategy.java index 4e32423..8567bbe 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/service/impl/XcxAuthStrategy.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/service/impl/XcxAuthStrategy.java @@ -12,10 +12,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; +import org.dromara.common.core.constant.TenantConstants; import org.dromara.common.core.domain.model.LoginUser; import org.dromara.common.core.domain.model.XcxLoginBody; import org.dromara.common.core.enums.UserType; import org.dromara.common.core.exception.user.UserException; +import org.dromara.common.core.utils.StringUtils; import org.dromara.common.core.utils.ValidatorUtils; import org.dromara.common.json.utils.JsonUtils; import org.dromara.common.satoken.utils.LoginHelper; @@ -45,9 +47,24 @@ public class XcxAuthStrategy implements IAuthStrategy { @Override public LoginVo login(String body, SysClientVo client) { + String clientKey = client.getClientKey(); + if ("mp-weixin".equals(clientKey)) { + if (!wxMaService.switchover("wx2e09db4124332242")) { + throw new IllegalArgumentException("未找到对应appid=wx2e09db4124332242的配置,请核实!"); + } + } else { + if (!wxMaService.switchover("wx7320557526b9e7ba")) { + throw new IllegalArgumentException("未找到对应appid=wx7320557526b9e7ba的配置,请核实!wx7320557526b9e7ba"); + } + } XcxLoginBody loginBody = JsonUtils.parseObject(body, XcxLoginBody.class); ValidatorUtils.validate(loginBody); String tenantId = loginBody.getTenantId(); + if (StringUtils.isEmpty(tenantId)) { + //没有则默认注册在主租户下; + loginBody.setTenantId(TenantConstants.DEFAULT_TENANT_ID); + tenantId = TenantConstants.DEFAULT_TENANT_ID; + } // code 为 小程序调用 wx.login 授权后获取 String code = loginBody.getCode(); String encryptedData = loginBody.getEncryptedData(); diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml index 22db6ff..45889e8 100644 --- a/ruoyi-admin/src/main/resources/application-prod.yml +++ b/ruoyi-admin/src/main/resources/application-prod.yml @@ -4,7 +4,7 @@ spring.servlet.multipart.location: /ruoyi/server/temp --- # 监控中心配置 spring.boot.admin.client: # 增加客户端开关 - enabled: true + enabled: false url: http://localhost:9090/admin instance: service-host-type: IP @@ -13,7 +13,7 @@ spring.boot.admin.client: --- # snail-job 配置 snail-job: - enabled: true + enabled: false # 需要在 SnailJob 后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务 group: "ruoyi_group" # SnailJob 接入验证令牌 详见 script/sql/snail_job.sql `sj_group_config` 表 @@ -45,35 +45,17 @@ 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 + url: jdbc:mysql://172.25.23.150:16338/mental_tenant?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&allowMultiQueries=true username: root - password: root + password: Mz!@#123 # 从库数据源 slave: lazy: true type: ${spring.datasource.type} driverClassName: com.mysql.cj.jdbc.Driver - 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 + url: jdbc:mysql://172.25.23.150:16338/mental_tenant?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&allowMultiQueries=true username: password: - # oracle: - # type: ${spring.datasource.type} - # driverClassName: oracle.jdbc.OracleDriver - # url: jdbc:oracle:thin:@//localhost:1521/XE - # username: ROOT - # password: root - # postgres: - # type: ${spring.datasource.type} - # driverClassName: org.postgresql.Driver - # url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true - # username: root - # password: root - # sqlserver: - # type: ${spring.datasource.type} - # driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver - # url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true - # username: SA - # password: root hikari: # 最大连接池数量 maxPoolSize: 20 @@ -94,13 +76,13 @@ spring: spring.data: redis: # 地址 - host: localhost + host: 172.25.23.150 # 端口,默认为6379 - port: 6379 + port: 16237 # 数据库索引 database: 0 # redis 密码必须配置 - password: ruoyi123 + password: Mzkj@1234 # 连接超时时间 timeout: 10s # 是否开启ssl @@ -261,16 +243,19 @@ justauth: wx: pay: - appId: #微信公众号或者小程序等的appid - mchId: #微信支付商户号 - mchKey: #微信支付商户密钥 - subAppId: #服务商模式下的子商户公众账号ID - subMchId: #服务商模式下的子商户号 - keyPath: # p12证书的位置,可以指定绝对路径,也可以指定类路径(以classpath:开头) + appId: wx2e09db4124332242 + mchId: 1646701170 + mchKey: Mozhekejiyouxiangongsi6296296296 + keyPath: /usr/local/tenant/certs/apiclient_cert.p12 miniapp: configs: - - appid: #微信小程序的appid - secret: #微信小程序的Secret + - appid: wx2e09db4124332242 + secret: ca069319b37b0909e65367c802c53d29 + token: #微信小程序消息服务器配置的token + aesKey: #微信小程序消息服务器配置的EncodingAESKey + msgDataFormat: JSON + - appid: wx7320557526b9e7ba + secret: 2927739a82d43921fe9a33f48e96a437 token: #微信小程序消息服务器配置的token aesKey: #微信小程序消息服务器配置的EncodingAESKey msgDataFormat: JSON diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 87367e2..fb27915 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -143,6 +143,7 @@ tenant: - sys_oss_config - sys_oss - sys_evaluation_answer + - sys_scale_order - m_counselor - m_counselor_experience - m_counselor_qualification @@ -201,7 +202,7 @@ api-decrypt: springdoc: api-docs: # 是否开启接口文档 - enabled: true + enabled: false # swagger-ui: # # 持久化认证数据 # persistAuthorization: true diff --git a/ruoyi-admin/src/test/java/org/dromara/test/AssertUnitTest.java b/ruoyi-admin/src/test/java/org/dromara/test/AssertUnitTest.java deleted file mode 100644 index dba2323..0000000 --- a/ruoyi-admin/src/test/java/org/dromara/test/AssertUnitTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.dromara.test; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -/** - * 断言单元测试案例 - * - * @author Lion Li - */ -@DisplayName("断言单元测试案例") -public class AssertUnitTest { - - @DisplayName("测试 assertEquals 方法") - @Test - public void testAssertEquals() { - Assertions.assertEquals("666", new String("666")); - Assertions.assertNotEquals("666", new String("666")); - } - - @DisplayName("测试 assertSame 方法") - @Test - public void testAssertSame() { - Object obj = new Object(); - Object obj1 = obj; - Assertions.assertSame(obj, obj1); - Assertions.assertNotSame(obj, obj1); - } - - @DisplayName("测试 assertTrue 方法") - @Test - public void testAssertTrue() { - Assertions.assertTrue(true); - Assertions.assertFalse(true); - } - - @DisplayName("测试 assertNull 方法") - @Test - public void testAssertNull() { - Assertions.assertNull(null); - Assertions.assertNotNull(null); - } - -} diff --git a/ruoyi-admin/src/test/java/org/dromara/test/DemoUnitTest.java b/ruoyi-admin/src/test/java/org/dromara/test/DemoUnitTest.java deleted file mode 100644 index 5b3dfdc..0000000 --- a/ruoyi-admin/src/test/java/org/dromara/test/DemoUnitTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.dromara.test; - -import org.dromara.common.core.config.RuoYiConfig; -import org.junit.jupiter.api.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; - -import java.util.concurrent.TimeUnit; - -/** - * 单元测试案例 - * - * @author Lion Li - */ -@SpringBootTest // 此注解只能在 springboot 主包下使用 需包含 main 方法与 yml 配置文件 -@DisplayName("单元测试案例") -public class DemoUnitTest { - - @Autowired - private RuoYiConfig ruoYiConfig; - - @DisplayName("测试 @SpringBootTest @Test @DisplayName 注解") - @Test - public void testTest() { - System.out.println(ruoYiConfig); - } - - @Disabled - @DisplayName("测试 @Disabled 注解") - @Test - public void testDisabled() { - System.out.println(ruoYiConfig); - } - - @Timeout(value = 2L, unit = TimeUnit.SECONDS) - @DisplayName("测试 @Timeout 注解") - @Test - public void testTimeout() throws InterruptedException { - Thread.sleep(3000); - System.out.println(ruoYiConfig); - } - - - @DisplayName("测试 @RepeatedTest 注解") - @RepeatedTest(3) - public void testRepeatedTest() { - System.out.println(666); - } - - @BeforeAll - public static void testBeforeAll() { - System.out.println("@BeforeAll =================="); - } - - @BeforeEach - public void testBeforeEach() { - System.out.println("@BeforeEach =================="); - } - - @AfterEach - public void testAfterEach() { - System.out.println("@AfterEach =================="); - } - - @AfterAll - public static void testAfterAll() { - System.out.println("@AfterAll =================="); - } - -} diff --git a/ruoyi-admin/src/test/java/org/dromara/test/ParamUnitTest.java b/ruoyi-admin/src/test/java/org/dromara/test/ParamUnitTest.java deleted file mode 100644 index 1db51df..0000000 --- a/ruoyi-admin/src/test/java/org/dromara/test/ParamUnitTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.dromara.test; - -import org.dromara.common.core.enums.UserType; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.EnumSource; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.NullSource; -import org.junit.jupiter.params.provider.ValueSource; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -/** - * 带参数单元测试案例 - * - * @author Lion Li - */ -@DisplayName("带参数单元测试案例") -public class ParamUnitTest { - - @DisplayName("测试 @ValueSource 注解") - @ParameterizedTest - @ValueSource(strings = {"t1", "t2", "t3"}) - public void testValueSource(String str) { - System.out.println(str); - } - - @DisplayName("测试 @NullSource 注解") - @ParameterizedTest - @NullSource - public void testNullSource(String str) { - System.out.println(str); - } - - @DisplayName("测试 @EnumSource 注解") - @ParameterizedTest - @EnumSource(UserType.class) - public void testEnumSource(UserType type) { - System.out.println(type.getUserType()); - } - - @DisplayName("测试 @MethodSource 注解") - @ParameterizedTest - @MethodSource("getParam") - public void testMethodSource(String str) { - System.out.println(str); - } - - public static Stream getParam() { - List list = new ArrayList<>(); - list.add("t1"); - list.add("t2"); - list.add("t3"); - return list.stream(); - } - - @BeforeEach - public void testBeforeEach() { - System.out.println("@BeforeEach =================="); - } - - @AfterEach - public void testAfterEach() { - System.out.println("@AfterEach =================="); - } - - -} diff --git a/ruoyi-admin/src/test/java/org/dromara/test/TagUnitTest.java b/ruoyi-admin/src/test/java/org/dromara/test/TagUnitTest.java deleted file mode 100644 index b50afa6..0000000 --- a/ruoyi-admin/src/test/java/org/dromara/test/TagUnitTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.dromara.test; - -import org.junit.jupiter.api.*; -import org.springframework.boot.test.context.SpringBootTest; - -/** - * 标签单元测试案例 - * - * @author Lion Li - */ -@SpringBootTest -@DisplayName("标签单元测试案例") -public class TagUnitTest { - - @Tag("dev") - @DisplayName("测试 @Tag dev") - @Test - public void testTagDev() { - System.out.println("dev"); - } - - @Tag("prod") - @DisplayName("测试 @Tag prod") - @Test - public void testTagProd() { - System.out.println("prod"); - } - - @Tag("local") - @DisplayName("测试 @Tag local") - @Test - public void testTagLocal() { - System.out.println("local"); - } - - @Tag("exclude") - @DisplayName("测试 @Tag exclude") - @Test - public void testTagExclude() { - System.out.println("exclude"); - } - - @BeforeEach - public void testBeforeEach() { - System.out.println("@BeforeEach =================="); - } - - @AfterEach - public void testAfterEach() { - System.out.println("@AfterEach =================="); - } - - -} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxEvaluationController.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxEvaluationController.java index 048e530..2c35940 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxEvaluationController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxEvaluationController.java @@ -7,13 +7,10 @@ import org.dromara.common.core.validate.AddGroup; import org.dromara.common.idempotent.annotation.RepeatSubmit; import org.dromara.common.log.annotation.Log; import org.dromara.common.log.enums.BusinessType; -import org.dromara.common.mybatis.core.page.PageQuery; -import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.tenant.helper.TenantHelper; import org.dromara.common.web.core.BaseController; import org.dromara.system.domain.bo.SubmitAnswerBo; import org.dromara.system.domain.vo.QuestionAnswerVo; -import org.dromara.system.domain.vo.SysEvaluationRecordVo; -import org.dromara.system.domain.vo.SysScaleVo; import org.dromara.system.service.IEvaluationService; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -39,10 +36,10 @@ public class WxEvaluationController extends BaseController { /** * 查询发布量表 */ - @GetMapping("/publish") - public R> queryPublish() { - return R.ok(evaluationService.queryPublishScale()); - } +// @GetMapping("/publish") +// public R> queryPublish() { +// return R.ok(evaluationService.queryPublishScale()); +// } /** @@ -50,16 +47,9 @@ public class WxEvaluationController extends BaseController { */ @GetMapping("/answer/{id}") public R> queryAnswer(@NotNull(message = "主键不能为空") @PathVariable Long id) { - return R.ok(evaluationService.queryQuestionAnswerListByScaleId(id)); + return R.ok(TenantHelper.ignore(() -> evaluationService.queryQuestionAnswerListByScaleId(id))); } - /** - * 查询量测记录 - */ - @GetMapping("/record") - public TableDataInfo queryRecord(Integer status, PageQuery pageQuery) { - return evaluationService.queryEvaluationRecord(status, pageQuery); - } /** * 新增量测记录 @@ -68,7 +58,7 @@ public class WxEvaluationController extends BaseController { @RepeatSubmit() @PostMapping("/record/create/{scaleId}") public R newRecord(@NotNull(message = "主键不能为空") @PathVariable Long scaleId) { - return toAjax(evaluationService.newRecord(scaleId)); + return toAjax(TenantHelper.ignore(() -> evaluationService.newRecord(scaleId))); } /** @@ -78,7 +68,7 @@ public class WxEvaluationController extends BaseController { @RepeatSubmit() @PostMapping("/record/{id}") public R checkRecord(@NotNull(message = "主键不能为空") @PathVariable Long id) { - return toAjax(evaluationService.checkRecord(id)); + return toAjax(TenantHelper.ignore(() -> evaluationService.checkRecord(id))); } /** @@ -88,6 +78,6 @@ public class WxEvaluationController extends BaseController { @RepeatSubmit() @PostMapping("/record/answer") public R> add(@Validated(AddGroup.class) @RequestBody SubmitAnswerBo bo) { - return R.ok(evaluationService.submitAnswer(bo)); + return R.ok(TenantHelper.ignore(() -> evaluationService.submitAnswer(bo))); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxMyController.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxMyController.java index 1565821..e34980c 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxMyController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxMyController.java @@ -4,12 +4,14 @@ import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.IoUtil; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import org.dromara.common.core.constant.TenantConstants; import org.dromara.common.core.domain.R; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.file.FileUtils; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.satoken.utils.LoginHelper; +import org.dromara.common.tenant.helper.TenantHelper; import org.dromara.common.web.core.BaseController; import org.dromara.system.domain.bo.BaseQueryBo; import org.dromara.system.domain.bo.ReservationOrderBo; @@ -52,7 +54,7 @@ public class WxMyController extends BaseController { */ @GetMapping("/num") public R> getEvaluationTaskNum() { - return R.ok(myService.getMyNum()); + return R.ok(TenantHelper.ignore(() -> myService.getMyNum())); } /** @@ -60,7 +62,7 @@ public class WxMyController extends BaseController { */ @GetMapping("/evaluation/task/pageList") public TableDataInfo taskList(PageQuery pageQuery) { - return myService.queryPersonalTaskPageList(pageQuery); + return TenantHelper.ignore(() -> myService.queryPersonalTaskPageList(pageQuery)); } /** @@ -68,7 +70,8 @@ public class WxMyController extends BaseController { */ @GetMapping("/scale/pageList") public TableDataInfo list(SysScaleBo bo, PageQuery pageQuery) { - return myService.queryScalePageList(bo, pageQuery); + bo.setTenantId(TenantConstants.DEFAULT_TENANT_ID); + return TenantHelper.ignore(() -> myService.queryScalePageList(bo, pageQuery)); } /** @@ -93,14 +96,14 @@ public class WxMyController extends BaseController { */ @GetMapping("/evaluation/personal/pageList") public TableDataInfo personalList(PageQuery pageQuery) { - return myService.queryPersonalEvaluationRecordPageList(pageQuery); + return TenantHelper.ignore(() -> myService.queryPersonalEvaluationRecordPageList(pageQuery)); } /** * 查询我的咨询 */ @GetMapping("/reservation/pageList") - public TableDataInfo reservationList(ReservationOrderBo bo,PageQuery pageQuery) { + public TableDataInfo reservationList(ReservationOrderBo bo, PageQuery pageQuery) { return myService.queryReservationPageList(bo, pageQuery); } @@ -110,7 +113,7 @@ public class WxMyController extends BaseController { @GetMapping("/archive/pageList") public TableDataInfo statisticPageList(PageQuery pageQuery) { Long userId = LoginHelper.getUserId(); - return archiveService.queryStatisticPageList(userId, pageQuery); + return TenantHelper.ignore(() -> archiveService.queryStatisticPageList(userId, pageQuery)); } /** @@ -120,7 +123,13 @@ public class WxMyController extends BaseController { public void export(BaseQueryBo bo, HttpServletResponse response) throws Exception { Long userId = LoginHelper.getUserId(); bo.setUserId(userId); - String filePath = sysEvaluationRecordService.getWordTemplate(bo); + String filePath = TenantHelper.ignore(() -> { + try { + return sysEvaluationRecordService.getWordTemplate(bo); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); File pdf = FileUtil.createTempFile(".pdf", true); String pdfPath = pdf.getPath(); File pdfFile = new File(pdfPath); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxScaleController.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxScaleController.java index 0d28f0e..565c726 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxScaleController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxScaleController.java @@ -2,11 +2,13 @@ package org.dromara.system.controller.wx; import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; +import org.dromara.common.core.constant.TenantConstants; import org.dromara.common.core.domain.R; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.tenant.helper.TenantHelper; import org.dromara.common.web.core.BaseController; import org.dromara.system.domain.bo.SysScaleBo; import org.dromara.system.domain.vo.SysScaleVo; @@ -41,7 +43,8 @@ public class WxScaleController extends BaseController { @GetMapping("/pageList") public TableDataInfo pageList(SysScaleBo bo, PageQuery pageQuery) { bo.setOrderBy("num"); - return sysScaleService.queryPageList(bo, pageQuery); + bo.setTenantId(TenantConstants.DEFAULT_TENANT_ID); + return TenantHelper.ignore(() -> sysScaleService.queryPageList(bo, pageQuery)); } /** @@ -50,7 +53,8 @@ public class WxScaleController extends BaseController { @GetMapping("/typeList") public R> pageListTest(SysScaleBo bo) { bo.setOrderBy("num"); - return R.ok(sysScaleService.queryPageListType(bo)); + bo.setTenantId(TenantConstants.DEFAULT_TENANT_ID); + return R.ok(TenantHelper.ignore(() -> sysScaleService.queryPageListType(bo))); } /** @@ -61,7 +65,7 @@ public class WxScaleController extends BaseController { if (StringUtils.isEmpty(scaleType)) { throw new ServiceException("类型不能为空"); } - return R.ok(sysScaleService.queryWxMapList(scaleType)); + return R.ok(TenantHelper.ignore(() ->sysScaleService.queryWxMapList(scaleType))); } /** @@ -71,6 +75,6 @@ public class WxScaleController extends BaseController { */ @GetMapping("/{scaleId}") public R getInfo(@NotNull(message = "主键不能为空") @PathVariable Long scaleId) { - return R.ok(sysScaleService.queryById4Wx(scaleId)); + return R.ok(TenantHelper.ignore(() ->sysScaleService.queryById4Wx(scaleId))); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxScoreRecordController.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxScoreRecordController.java index 82f5653..e8e45ea 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxScoreRecordController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/wx/WxScoreRecordController.java @@ -1,8 +1,8 @@ package org.dromara.system.controller.wx; -import cn.dev33.satoken.annotation.SaCheckPermission; import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; +import org.dromara.common.core.constant.TenantConstants; import org.dromara.common.core.domain.R; import org.dromara.common.core.validate.AddGroup; import org.dromara.common.idempotent.annotation.RepeatSubmit; @@ -10,6 +10,7 @@ import org.dromara.common.log.annotation.Log; import org.dromara.common.log.enums.BusinessType; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.tenant.helper.TenantHelper; import org.dromara.common.web.core.BaseController; import org.dromara.system.domain.bo.ScoreRecordBo; import org.dromara.system.domain.vo.ScoreRecordVo; @@ -34,10 +35,10 @@ public class WxScoreRecordController extends BaseController { /** * 查询评分列表 */ - @SaCheckPermission("scale:scoreRecord:list") @GetMapping("/list") public TableDataInfo list(ScoreRecordBo bo, PageQuery pageQuery) { - return scoreRecordService.queryPageList(bo, pageQuery); + bo.setTenantId(TenantConstants.DEFAULT_TENANT_ID); + return TenantHelper.ignore(() ->scoreRecordService.queryPageList(bo, pageQuery)); } @@ -46,21 +47,19 @@ public class WxScoreRecordController extends BaseController { * * @param id 主键 */ - @SaCheckPermission("scale:scoreRecord:query") @GetMapping("/{id}") public R getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) { - return R.ok(scoreRecordService.queryById(id)); + return R.ok(TenantHelper.ignore(() ->scoreRecordService.queryById(id))); } /** * 新增评分 */ - @SaCheckPermission("scale:scoreRecord:add") @Log(title = "评分", businessType = BusinessType.INSERT) @RepeatSubmit() @PostMapping() public R add(@Validated(AddGroup.class) @RequestBody ScoreRecordBo bo) { - return toAjax(scoreRecordService.insertByBo(bo)); + return toAjax(TenantHelper.ignore(() ->scoreRecordService.insertByBo(bo))); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysScaleOrder.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysScaleOrder.java index 9ce5970..7b1cc5b 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysScaleOrder.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysScaleOrder.java @@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import lombok.EqualsAndHashCode; -import org.dromara.common.tenant.core.TenantEntity; +import org.dromara.common.mybatis.core.domain.BaseEntity; import java.io.Serial; import java.math.BigDecimal; @@ -18,7 +18,7 @@ import java.math.BigDecimal; @Data @EqualsAndHashCode(callSuper = true) @TableName("sys_scale_order") -public class SysScaleOrder extends TenantEntity { +public class SysScaleOrder extends BaseEntity { @Serial private static final long serialVersionUID = 1L; diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysScalePackage.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysScalePackage.java index c53fcca..35e54af 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysScalePackage.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysScalePackage.java @@ -1,5 +1,6 @@ package org.dromara.system.domain; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; @@ -32,7 +33,7 @@ public class SysScalePackage extends BaseEntity { /** * 量表套餐id */ - @TableId(value = "package_id") + @TableId(value = "package_id", type = IdType.AUTO) private Long packageId; /** diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysTenant.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysTenant.java index 9af3762..de2047a 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysTenant.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysTenant.java @@ -1,5 +1,6 @@ package org.dromara.system.domain; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; @@ -26,7 +27,7 @@ public class SysTenant extends BaseEntity { /** * id */ - @TableId(value = "id") + @TableId(value = "id", type = IdType.AUTO) private Long id; /** diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysTenantPackage.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysTenantPackage.java index f7e423f..1b1b1e8 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysTenantPackage.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysTenantPackage.java @@ -1,12 +1,15 @@ package org.dromara.system.domain; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import lombok.EqualsAndHashCode; -import java.io.Serial; - import org.dromara.common.mybatis.core.domain.BaseEntity; +import java.io.Serial; + /** * 租户套餐对象 sys_tenant_package * @@ -23,7 +26,7 @@ public class SysTenantPackage extends BaseEntity { /** * 租户套餐id */ - @TableId(value = "package_id") + @TableId(value = "package_id", type = IdType.AUTO) private Long packageId; /** * 套餐名称 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/ScoreRecordBo.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/ScoreRecordBo.java index 8ff4ed6..f90a2d7 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/ScoreRecordBo.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/ScoreRecordBo.java @@ -6,7 +6,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import org.dromara.common.core.validate.AddGroup; import org.dromara.common.core.validate.EditGroup; -import org.dromara.common.mybatis.core.domain.BaseEntity; +import org.dromara.common.tenant.core.TenantEntity; import org.dromara.system.domain.ScoreRecord; import java.math.BigDecimal; @@ -20,7 +20,7 @@ import java.math.BigDecimal; @Data @EqualsAndHashCode(callSuper = true) @AutoMapper(target = ScoreRecord.class, reverseConvertGenerate = false) -public class ScoreRecordBo extends BaseEntity { +public class ScoreRecordBo extends TenantEntity { /** * diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysScaleBo.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysScaleBo.java index 4038c13..8c9f76c 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysScaleBo.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysScaleBo.java @@ -10,7 +10,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import org.dromara.common.core.validate.AddGroup; import org.dromara.common.core.validate.EditGroup; -import org.dromara.common.mybatis.core.domain.BaseEntity; +import org.dromara.common.tenant.core.TenantEntity; import org.dromara.system.domain.SysScale; import java.math.BigDecimal; @@ -25,7 +25,7 @@ import java.util.List; @Data @EqualsAndHashCode(callSuper = true) @AutoMapper(target = SysScale.class, reverseConvertGenerate = false) -public class SysScaleBo extends BaseEntity { +public class SysScaleBo extends TenantEntity { /** * 测评id @@ -85,9 +85,9 @@ public class SysScaleBo extends BaseEntity { /** * 封面 */ - @NotNull(message = "封面不能为空", groups = {AddGroup.class, EditGroup.class}) + //@NotNull(message = "封面不能为空", groups = {AddGroup.class, EditGroup.class}) private Long cover; - @NotNull(message = "移动端封面不能为空", groups = {AddGroup.class, EditGroup.class}) + //@NotNull(message = "移动端封面不能为空", groups = {AddGroup.class, EditGroup.class}) private Long appCover; //@NotNull(message = "移动端详情图不能为空", groups = {AddGroup.class, EditGroup.class}) private Long detailAnnex; diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysEvaluationRecordMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysEvaluationRecordMapper.java index 89ff804..91be279 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysEvaluationRecordMapper.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysEvaluationRecordMapper.java @@ -1,8 +1,5 @@ package org.dromara.system.mapper; -import com.baomidou.mybatisplus.core.conditions.Wrapper; -import com.baomidou.mybatisplus.core.toolkit.Constants; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; @@ -25,8 +22,6 @@ public interface SysEvaluationRecordMapper extends BaseMapperPlus selectPublishScaleListByUserAndBatch(@Param("userId") Long userId, @Param("batchNos") String batchNos); - Page selectRecordVoPage(@Param("page") Page page, @Param(Constants.WRAPPER) Wrapper queryWrapper); - List selectEvaluationFactor4Word(Long recordId); List selectUseByBatchNo(Long batchNo); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/IEvaluationService.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/IEvaluationService.java index 9849188..4adbdfd 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/IEvaluationService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/IEvaluationService.java @@ -1,23 +1,17 @@ package org.dromara.system.service; -import org.dromara.common.mybatis.core.page.PageQuery; -import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.system.domain.bo.SubmitAnswerBo; import org.dromara.system.domain.vo.QuestionAnswerVo; -import org.dromara.system.domain.vo.SysEvaluationRecordVo; -import org.dromara.system.domain.vo.SysScaleVo; import java.util.List; import java.util.Map; public interface IEvaluationService { - List queryPublishScale(); +// List queryPublishScale(); List queryQuestionAnswerListByScaleId(Long scaleId); - TableDataInfo queryEvaluationRecord(Integer status, PageQuery pageQuery); - Boolean newRecord(Long recordId); Boolean checkRecord(Long recordId); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/CounselorServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/CounselorServiceImpl.java index e5c1ea3..c885c37 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/CounselorServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/CounselorServiceImpl.java @@ -78,15 +78,17 @@ public class CounselorServiceImpl implements ICounselorService { counselorVo.setPracticeString(betweenYear); ScoreRateVo scoreRateVo = scoreRecordMapper.selectRate(id); - Integer count = scoreRateVo.getCount(); - if (count > 0) { - double v = count * 5 * 5 * 5; - Double total = scoreRateVo.getTotal(); - if (total > 0) { - BigDecimal rate = BigDecimal.valueOf(total).divide(new BigDecimal(v), 2, RoundingMode.HALF_UP) - .multiply(new BigDecimal(100)); - if (rate.compareTo(new BigDecimal(90)) > 0) { - counselorVo.setGoodRate(rate.toString()); + if (scoreRateVo != null) { + Integer count = scoreRateVo.getCount(); + if (count > 0) { + double v = count * 5 * 5 * 5; + Double total = scoreRateVo.getTotal(); + if (total > 0) { + BigDecimal rate = BigDecimal.valueOf(total).divide(new BigDecimal(v), 2, RoundingMode.HALF_UP) + .multiply(new BigDecimal(100)); + if (rate.compareTo(new BigDecimal(90)) > 0) { + counselorVo.setGoodRate(rate.toString()); + } } } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/EvaluationServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/EvaluationServiceImpl.java index 8d2534b..7718fdd 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/EvaluationServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/EvaluationServiceImpl.java @@ -2,16 +2,12 @@ package org.dromara.system.service.impl; import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.domain.model.LoginUser; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.MapstructUtils; -import org.dromara.common.core.utils.StringUtils; -import org.dromara.common.mybatis.core.page.PageQuery; -import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.system.constant.*; import org.dromara.system.domain.*; @@ -65,38 +61,34 @@ public class EvaluationServiceImpl implements IEvaluationService { private final MathContext mathContext = new MathContext(2); - @Override - public List queryPublishScale() { - LoginUser loginUser = getLoginUser(); - Long userId = loginUser.getUserId(); - Long deptId = loginUser.getDeptId(); - - String deptBatchNo = publishMapper.selectUseBatchNoByDeptId(deptId); - String userBatchNo = publishMapper.selectUseBatchNoByUserId(userId); - List batchList = new ArrayList<>(); - List scaleVos = new ArrayList<>(); - if (StringUtils.isNotEmpty(deptBatchNo)) { - batchList.add(deptBatchNo); - } - if (StringUtils.isNotEmpty(userBatchNo)) { - batchList.add(userBatchNo); - } - if (batchList.size() == 0) { - return scaleVos; - } - scaleVos = recordMapper.selectPublishScaleListByUserAndBatch(userId, StrUtil.join(StrUtil.COMMA, batchList)); - return scaleVos; - } +// @Override +// public List queryPublishScale() { +// LoginUser loginUser = getLoginUser(); +// Long userId = loginUser.getUserId(); +// Long deptId = loginUser.getDeptId(); +// +// String deptBatchNo = publishMapper.selectUseBatchNoByDeptId(deptId); +// String userBatchNo = publishMapper.selectUseBatchNoByUserId(userId); +// List batchList = new ArrayList<>(); +// List scaleVos = new ArrayList<>(); +// if (StringUtils.isNotEmpty(deptBatchNo)) { +// batchList.add(deptBatchNo); +// } +// if (StringUtils.isNotEmpty(userBatchNo)) { +// batchList.add(userBatchNo); +// } +// if (batchList.size() == 0) { +// return scaleVos; +// } +// scaleVos = recordMapper.selectPublishScaleListByUserAndBatch(userId, StrUtil.join(StrUtil.COMMA, batchList)); +// return scaleVos; +// } @Override public List queryQuestionAnswerListByScaleId(Long scaleId) { return scaleAnswerService.queryQuestionAnswerListByScaleId(scaleId); } - @Override - public TableDataInfo queryEvaluationRecord(Integer status, PageQuery pageQuery) { - return null; - } @Override public Boolean newRecord(Long scaleId) { diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/MyServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/MyServiceImpl.java index dbc69ab..898d8f0 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/MyServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/MyServiceImpl.java @@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.dromara.common.core.constant.TenantConstants; import org.dromara.common.core.service.OssService; +import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.satoken.utils.LoginHelper; @@ -56,7 +58,8 @@ public class MyServiceImpl implements IMyService { Long recordNum = evaluationRecordMapper.selectCount(new LambdaQueryWrapper() .eq(SysEvaluationRecord::getUserId, userId) .eq(SysEvaluationRecord::getPublishFlag, 0) - .le(SysEvaluationRecord::getStatus, StatusEnum.DISABLED.getValue())); + .eq(SysEvaluationRecord::getTenantId, TenantConstants.DEFAULT_TENANT_ID) + .eq(SysEvaluationRecord::getStatus, StatusEnum.DISABLED.getValue())); list.add(new StatisticNumVo("evaluation", recordNum.intValue())); List scaleList = evaluationRecordMapper.selectEvaluationScaleList(userId); @@ -67,10 +70,12 @@ public class MyServiceImpl implements IMyService { .eq(ReservationOrder::getOrderStatus, 2)); list.add(new StatisticNumVo("intervene", orderNum.intValue())); + String tenantId = LoginHelper.getTenantId(); Long publishNum = evaluationRecordMapper.selectCount(new LambdaQueryWrapper() .eq(SysEvaluationRecord::getUserId, userId) .eq(SysEvaluationRecord::getPublishFlag, 1) - .le(SysEvaluationRecord::getStatus, StatusEnum.DISABLED.getValue())); + .eq(SysEvaluationRecord::getTenantId, tenantId) + .eq(SysEvaluationRecord::getStatus, StatusEnum.DISABLED.getValue())); list.add(new StatisticNumVo("publish", publishNum.intValue())); return list; } @@ -83,6 +88,7 @@ public class MyServiceImpl implements IMyService { //根据flag查询个人或发布 lqw.eq(SysEvaluationRecord::getPublishFlag, 0); lqw.eq(SysEvaluationRecord::getStatus, 0); + lqw.eq(SysEvaluationRecord::getTenantId, TenantConstants.DEFAULT_TENANT_ID); lqw.orderByDesc(SysEvaluationRecord::getCreateTime); return queryEvaluationRecordPageList(lqw, pageQuery); } @@ -94,7 +100,8 @@ public class MyServiceImpl implements IMyService { lqw.eq(SysEvaluationRecord::getUserId, userId); //根据flag查询个人或发布 lqw.eq(SysEvaluationRecord::getPublishFlag, 0); - //lqw.gt(SysEvaluationRecord::getStatus, -1); + lqw.eq(SysEvaluationRecord::getTenantId, TenantConstants.DEFAULT_TENANT_ID); + lqw.ne(SysEvaluationRecord::getStatus, -1); lqw.orderByDesc(SysEvaluationRecord::getCreateTime); return queryEvaluationRecordPageList(lqw, pageQuery); } @@ -115,7 +122,9 @@ public class MyServiceImpl implements IMyService { Long userId = LoginHelper.getUserId(); List list = evaluationRecordMapper.selectEvaluationScaleList(userId); IPage page = scaleMapper.selectVoPage(pageQuery.build(), - new LambdaQueryWrapper().in(SysScale::getScaleId, list)); + new LambdaQueryWrapper() + .eq(StringUtils.isNotBlank(bo.getTenantId()), SysScale::getTenantId, bo.getTenantId()) + .in(SysScale::getScaleId, list)); return TableDataInfo.build(page); } @@ -130,12 +139,13 @@ public class MyServiceImpl implements IMyService { } private TableDataInfo queryEvaluationRecordPageList(LambdaQueryWrapper lqw, PageQuery pageQuery) { - Page result = evaluationRecordMapper.selectRecordVoPage(pageQuery.build(), lqw); + Page result = evaluationRecordMapper.selectVoPage(pageQuery.build(), lqw); List records = result.getRecords(); for (SysEvaluationRecordVo record : records) { SysScale scale = scaleMapper.selectById(record.getScaleId()); String s = ossService.selectUrlByIds(String.valueOf(scale.getAppCover())); record.setAppCoverUrl(s); + record.setScaleName(scale.getScaleName()); } return TableDataInfo.build(result); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/ReservationRefundServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/ReservationRefundServiceImpl.java index e5c79b0..4e2bf04 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/ReservationRefundServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/ReservationRefundServiceImpl.java @@ -194,7 +194,7 @@ public class ReservationRefundServiceImpl implements IReservationRefundService { refund.setStatus(1); refund.setWxRefundId(wxRefundId); refund.setUpdateTime(date); - boolean refundFlag = baseMapper.insert(refund) > 0; + boolean refundFlag = baseMapper.updateById(refund) > 0; return orderFlag && refundFlag; } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/ScoreRecordServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/ScoreRecordServiceImpl.java index cf46fcd..2b92566 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/ScoreRecordServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/ScoreRecordServiceImpl.java @@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; +import org.dromara.common.core.constant.TenantConstants; import org.dromara.common.core.utils.MapstructUtils; +import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.system.domain.ScoreRecord; @@ -36,7 +38,7 @@ public class ScoreRecordServiceImpl implements IScoreRecordService { * @return 评分 */ @Override - public ScoreRecordVo queryById(Long id){ + public ScoreRecordVo queryById(Long id) { return baseMapper.selectVoById(id); } @@ -71,6 +73,7 @@ public class ScoreRecordServiceImpl implements IScoreRecordService { LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); lqw.eq(bo.getBusinessId() != null, ScoreRecord::getBusinessId, bo.getBusinessId()); lqw.eq(bo.getRecordStatus() != null, ScoreRecord::getRecordStatus, bo.getRecordStatus()); + lqw.eq(StringUtils.isNotBlank(bo.getTenantId()), ScoreRecord::getTenantId, bo.getTenantId()); return lqw; } @@ -82,8 +85,8 @@ public class ScoreRecordServiceImpl implements IScoreRecordService { */ @Override public Boolean insertByBo(ScoreRecordBo bo) { + bo.setTenantId(TenantConstants.DEFAULT_TENANT_ID); ScoreRecord add = MapstructUtils.convert(bo, ScoreRecord.class); - validEntityBeforeSave(add); boolean flag = baseMapper.insert(add) > 0; if (flag) { bo.setId(add.getId()); @@ -91,11 +94,5 @@ public class ScoreRecordServiceImpl implements IScoreRecordService { return flag; } - /** - * 保存前的数据校验 - */ - private void validEntityBeforeSave(ScoreRecord entity){ - //TODO 做一些数据校验,如唯一约束 - } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysEvaluationRecordServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysEvaluationRecordServiceImpl.java index b16afd9..d22c995 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysEvaluationRecordServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysEvaluationRecordServiceImpl.java @@ -78,7 +78,12 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi @Override public TableDataInfo queryPageList(SysEvaluationRecordBo bo, PageQuery pageQuery) { LambdaQueryWrapper lqw = buildQueryWrapper(bo); - Page result = baseMapper.selectRecordVoPage(pageQuery.build(), lqw); + Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + List records = result.getRecords(); + for (SysEvaluationRecordVo record : records) { + SysScale scale = scaleMapper.selectById(record.getScaleId()); + record.setScaleName(scale.getScaleName()); + } return TableDataInfo.build(result); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysOssServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysOssServiceImpl.java index d167e8d..e0fd363 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysOssServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysOssServiceImpl.java @@ -29,6 +29,7 @@ import org.dromara.system.domain.vo.SysOssVo; import org.dromara.system.mapper.SysOssMapper; import org.dromara.system.service.ISysOssService; import org.jetbrains.annotations.NotNull; +import org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration; import org.springframework.cache.annotation.Cacheable; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; @@ -51,6 +52,7 @@ import java.util.Map; public class SysOssServiceImpl implements ISysOssService, OssService { private final SysOssMapper baseMapper; + private final DataSourcePoolMetricsAutoConfiguration dataSourcePoolMetricsAutoConfiguration; /** * 查询OSS对象存储列表 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysScaleServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysScaleServiceImpl.java index ffffa1b..e6bf70a 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysScaleServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysScaleServiceImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; +import org.dromara.common.core.constant.TenantConstants; import org.dromara.common.core.service.DictService; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; @@ -23,6 +24,7 @@ import org.dromara.system.mapper.SysEvaluationRecordMapper; import org.dromara.system.mapper.SysScaleMapper; import org.dromara.system.service.ISysScaleService; import org.springframework.stereotype.Service; +import org.springframework.util.StopWatch; import java.math.BigDecimal; import java.util.*; @@ -104,6 +106,7 @@ public class SysScaleServiceImpl implements ISysScaleService { */ @Override public TableDataInfo queryPageList(SysScaleBo bo, PageQuery pageQuery) { + StopWatch watch = new StopWatch(); LambdaQueryWrapper lqw = buildQueryWrapper(bo); if ("num".equals(bo.getOrderBy())) { lqw.orderByDesc(SysScale::getPublishNums); @@ -155,6 +158,7 @@ public class SysScaleServiceImpl implements ISysScaleService { lqw.like(StringUtils.isNotBlank(bo.getScaleName()), SysScale::getScaleName, bo.getScaleName()); lqw.like(StringUtils.isNotBlank(bo.getScaleCode()), SysScale::getScaleCode, bo.getScaleCode()); lqw.eq(bo.getStatus() != null, SysScale::getStatus, bo.getStatus()); + lqw.eq(StringUtils.isNotBlank(bo.getTenantId()), SysScale::getTenantId, bo.getTenantId()); if (CollUtil.isNotEmpty(bo.getScaleType())) { lqw.like(SysScale::getScaleType, bo.getScaleType().get(0)); } @@ -213,6 +217,7 @@ public class SysScaleServiceImpl implements ISysScaleService { for (String s : split) { LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); lqw.like(SysScale::getScaleType, s); + lqw.eq(SysScale::getTenantId, TenantConstants.DEFAULT_TENANT_ID); lqw.orderByDesc(SysScale::getPublishNums); lqw.last("limit 2"); List list = baseMapper.selectVoList(lqw); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantServiceImpl.java index 759e281..d92f004 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysTenantServiceImpl.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.constant.CacheNames; import org.dromara.common.core.constant.Constants; import org.dromara.common.core.constant.TenantConstants; @@ -27,6 +28,7 @@ import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StopWatch; import java.util.*; @@ -35,6 +37,7 @@ import java.util.*; * * @author Michelle.Chung */ +@Slf4j @RequiredArgsConstructor @Service public class SysTenantServiceImpl implements ISysTenantService { @@ -137,7 +140,7 @@ public class SysTenantServiceImpl implements ISysTenantService { // 根据套餐创建角色 Long roleId = createTenantRole(tenantId, bo.getTenantPackageId()); - + createTenantScale(tenantId, bo.getScalePackageId()); // 创建部门: 公司名是部门名称 SysDept dept = new SysDept(); dept.setTenantId(tenantId); @@ -267,25 +270,25 @@ public class SysTenantServiceImpl implements ISysTenantService { if (ObjectUtil.isNull(scalePackage)) { throw new ServiceException("量表套餐不存在"); } - // 获取免费量表id + // 获取新增量表id List scaleIds = StringUtils.splitTo(scalePackage.getScaleIds(), Convert::toLong); - //新增量表 List allScaleList = scaleMapper.selectList(new LambdaQueryWrapper() - .eq(SysScale::getTenantId, TenantConstants.DEFAULT_TENANT_ID)); + .eq(SysScale::getTenantId, TenantConstants.DEFAULT_TENANT_ID) + .in(SysScale::getScaleId, scaleIds)); //处理问题和因子 List allQuestionList = new ArrayList<>(); List allAnswerList = new ArrayList<>(); List allFactorList = new ArrayList<>(); List allRangeList = new ArrayList<>(); + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); for (SysScale sysScale : allScaleList) { Long oldScaleId = sysScale.getScaleId(); Long newScaleId = identifierGenerator.nextId(SysScale.class).longValue(); sysScale.setScaleId(newScaleId); sysScale.setTenantId(tenantId); sysScale.setPublishNums(0); - if (scaleIds.contains(sysScale.getScaleId())) { - sysScale.setFreeFlag(1); - } + sysScale.setFreeFlag(1); Map questionIdMap = new HashMap<>(); //处理问题列表 List questionList = questionMapper.selectList(new LambdaQueryWrapper() @@ -345,11 +348,16 @@ public class SysTenantServiceImpl implements ISysTenantService { } allFactorList.addAll(factorList); } - scaleMapper.insertBatch(allScaleList, 200); - questionMapper.insertBatch(allQuestionList, 200); - answerMapper.insertBatch(allAnswerList, 200); - factorMapper.insertBatch(allFactorList, 200); - rangeMapper.insertBatch(allRangeList, 200); + stopWatch.stop(); + log.info("处理所有量表用时{} 秒", stopWatch.getTotalTimeSeconds()); + stopWatch.start(); + scaleMapper.insertBatch(allScaleList, 500); + questionMapper.insertBatch(allQuestionList, 500); + answerMapper.insertBatch(allAnswerList, 500); + factorMapper.insertBatch(allFactorList, 500); + rangeMapper.insertBatch(allRangeList, 500); + stopWatch.stop(); + log.info("入库所有量表用时{} 秒", stopWatch.getTotalTimeSeconds()); } /** diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysEvaluationRecordMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysEvaluationRecordMapper.xml index c37f61c..73f4081 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysEvaluationRecordMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysEvaluationRecordMapper.xml @@ -20,12 +20,6 @@ and find_in_set(er.batch_no, #{batchNos}) -