From 753db322c77b9bf8c3db31f59a78318da8163644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E5=A4=A7=E5=8F=94?= <494979559@qq.com> Date: Fri, 10 May 2024 14:16:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/core/domain/BaseEntity.java | 1 + .../ruoyi/ss/article/domain/SmArticle.java | 10 +++ .../ss/article/domain/enums/LicenceType.java | 32 +++++++++ .../{article => enums}/SystemClassify.java | 2 +- .../ss/article/service/ISmArticleService.java | 14 ++-- .../service/impl/SmArticleServiceImpl.java | 68 ++++++++++--------- .../service/SmBusinessRecordServiceImpl.java | 4 +- .../com/ruoyi/ss/user/mapper/SmUserMapper.xml | 28 ++++---- .../controller/app/AppArticleController.java | 17 ++++- .../app/AppTransactionBillController.java | 43 +++++------- .../controller/ss/SmArticleController.java | 21 ++++-- .../src/main/resources/application-dev.yml | 24 +++++++ .../src/main/resources/application-test.yml | 30 +++++++- .../src/main/resources/application.yml | 22 ------ 14 files changed, 203 insertions(+), 113 deletions(-) create mode 100644 smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/enums/LicenceType.java rename smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/{article => enums}/SystemClassify.java (86%) diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java index 7832e0f3..5c9d5519 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java @@ -36,6 +36,7 @@ public class BaseEntity implements Serializable /** 更新时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonView(JsonViewProfile.Base.class) private Date updateTime; /** 备注 */ diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/SmArticle.java b/smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/SmArticle.java index f380edb1..58b287ed 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/SmArticle.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/SmArticle.java @@ -1,10 +1,14 @@ package com.ruoyi.ss.article.domain; +import com.fasterxml.jackson.annotation.JsonView; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.core.domain.JsonViewProfile; import com.ruoyi.common.core.domain.entity.SmArticleClassify; import lombok.Data; +import javax.validation.constraints.NotNull; + /** * 文章对象 as_article * @@ -17,14 +21,17 @@ public class SmArticle extends BaseEntity private static final long serialVersionUID = 1L; /** 文章id */ + @JsonView(JsonViewProfile.App.class) private Long articleId; /**分类id */ @Excel(name = "分类id") + @JsonView(JsonViewProfile.App.class) private String classifyId; /** 标题 */ @Excel(name = "标题") + @JsonView(JsonViewProfile.App.class) private String title; /** logo地址 */ @@ -43,12 +50,15 @@ public class SmArticle extends BaseEntity private String isHot; /** 简介 */ + @JsonView(JsonViewProfile.App.class) private String introduction; /** 内容详情 */ + @JsonView(JsonViewProfile.App.class) private String content; /** 作者 */ + @JsonView(JsonViewProfile.App.class) private String author; /** 格式化日期 */ diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/enums/LicenceType.java b/smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/enums/LicenceType.java new file mode 100644 index 00000000..0ba468fa --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/enums/LicenceType.java @@ -0,0 +1,32 @@ +package com.ruoyi.ss.article.domain.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Objects; + +/** + * 协议类型 + * @author wjh + * 2024/5/10 + */ +@Getter +@AllArgsConstructor +public enum LicenceType { + + USER("user", "ss.licence.user.id"), + PRIVACY("privacy", "ss.licence.privacy.id"), + COLLECT("collection", "ss.licence.collection.id"); + + private final String type; // 类型 + private final String key; // 配置键值 + + public static LicenceType parse(String type) { + for (LicenceType value : LicenceType.values()) { + if (Objects.equals(value.getType(), type)) { + return value; + } + } + return null; + } +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/article/SystemClassify.java b/smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/enums/SystemClassify.java similarity index 86% rename from smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/article/SystemClassify.java rename to smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/enums/SystemClassify.java index 04950b37..8b55fa1b 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/article/SystemClassify.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/article/domain/enums/SystemClassify.java @@ -1,4 +1,4 @@ -package com.ruoyi.ss.article.domain.article; +package com.ruoyi.ss.article.domain.enums; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/article/service/ISmArticleService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/article/service/ISmArticleService.java index 7b12b052..2df2c390 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/article/service/ISmArticleService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/article/service/ISmArticleService.java @@ -3,6 +3,7 @@ package com.ruoyi.ss.article.service; import com.ruoyi.ss.article.domain.SmArticle; import com.ruoyi.ss.article.domain.SmArticleQuery; +import com.ruoyi.ss.article.domain.enums.LicenceType; import java.util.List; @@ -70,11 +71,10 @@ public interface ISmArticleService */ public String[] getTagList(Long articleId); -// /** -// * 获取动态分类列表 -// * -// * @param -// * @return 结果 -// */ -// public List selectDynamicClSmsifyList(); + /** + * 根据类型获取协议 + * @param type 协议类型 + */ + SmArticle selectLicenceByType(LicenceType type); + } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/article/service/impl/SmArticleServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/article/service/impl/SmArticleServiceImpl.java index b251625d..2da78b17 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/article/service/impl/SmArticleServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/article/service/impl/SmArticleServiceImpl.java @@ -1,12 +1,17 @@ package com.ruoyi.ss.article.service.impl; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.ss.article.domain.SmArticle; import com.ruoyi.ss.article.domain.SmArticleQuery; +import com.ruoyi.ss.article.domain.enums.LicenceType; import com.ruoyi.ss.article.mapper.SmArticleMapper; import com.ruoyi.ss.article.service.ISmArticleService; import com.ruoyi.system.mapper.SysDictDataMapper; +import com.ruoyi.system.service.ISysConfigService; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -19,13 +24,14 @@ import java.util.List; * @date 2023-12-06 */ @Service +@Slf4j public class SmArticleServiceImpl implements ISmArticleService { @Resource - private SmArticleMapper asArticleMapper; + private SmArticleMapper articleMapper; - @Resource - private SysDictDataMapper dictDataMapper; + @Autowired + private ISysConfigService configService; /** * 查询文章 @@ -36,7 +42,7 @@ public class SmArticleServiceImpl implements ISmArticleService @Override public SmArticle selectSmArticleByArticleId(Long articleId) { - SmArticle smArticle = asArticleMapper.selectSmArticleByArticleId(articleId); + SmArticle smArticle = articleMapper.selectSmArticleByArticleId(articleId); if(ObjectUtils.isNotEmpty(smArticle)){ smArticle.setFormatCreateTime(DateUtils.getYYYY_MM_DD(smArticle.getCreateTime())); } @@ -52,7 +58,7 @@ public class SmArticleServiceImpl implements ISmArticleService @Override public List selectSmArticleList(SmArticleQuery smArticle) { - List smArticles = asArticleMapper.selectSmArticleList(smArticle); + List smArticles = articleMapper.selectSmArticleList(smArticle); for (SmArticle smArticle1 : smArticles) { smArticle.setFormatCreateTime(DateUtils.getYYYY_MM_DD(smArticle1.getCreateTime())); } @@ -69,7 +75,7 @@ public class SmArticleServiceImpl implements ISmArticleService public int insertSmArticle(SmArticle smArticle) { smArticle.setCreateTime(DateUtils.getNowDate()); - return asArticleMapper.insertSmArticle(smArticle); + return articleMapper.insertSmArticle(smArticle); } /** @@ -82,7 +88,7 @@ public class SmArticleServiceImpl implements ISmArticleService public int updateSmArticle(SmArticle smArticle) { smArticle.setUpdateTime(DateUtils.getNowDate()); - return asArticleMapper.updateSmArticle(smArticle); + return articleMapper.updateSmArticle(smArticle); } /** @@ -94,7 +100,7 @@ public class SmArticleServiceImpl implements ISmArticleService @Override public int deleteSmArticleByArticleIds(Long[] articleIds) { - return asArticleMapper.deleteSmArticleByArticleIds(articleIds); + return articleMapper.deleteSmArticleByArticleIds(articleIds); } /** @@ -106,7 +112,7 @@ public class SmArticleServiceImpl implements ISmArticleService @Override public int deleteSmArticleByArticleId(Long articleId) { - return asArticleMapper.deleteSmArticleByArticleId(articleId); + return articleMapper.deleteSmArticleByArticleId(articleId); } /** @@ -117,33 +123,29 @@ public class SmArticleServiceImpl implements ISmArticleService */ @Override public String[] getTagList(Long articleId) { - SmArticle smArticle = asArticleMapper.selectSmArticleByArticleId(articleId); + SmArticle smArticle = articleMapper.selectSmArticleByArticleId(articleId); String tag = smArticle.getTag(); String[] split = tag.split(","); return split; } -// /** -// * 查询动态分类及数量 -// * -// * @param -// * @return 结果 -// */ -// @Override -// public List selectDynamicClassifyList() { -// List classifies = new ArrayList<>(); -// SysDictData dictData = new SysDictData(); -// dictData.setDictType("dynamic_classify"); -// List sysDictData = dictDataMapper.selectDictDataList(dictData); -// for (SysDictData one :sysDictData) { -// DynamicClassify dynamicClassify = new DynamicClassify(); -// String dictValue = one.getDictValue(); -// dynamicClassify.setName(one.getDictLabel()); -// dynamicClassify.setValue(dictValue); -// int classify = asArticleMapper.countDynamicClassify(dictValue); -// dynamicClassify.setNum(classify); -// classifies.add(dynamicClassify); -// } -// return classifies; -// } + /** + * 根据类型获取协议 + * + * @param type 协议类型 + */ + @Override + public SmArticle selectLicenceByType(LicenceType type) { + if (type == null) { + return null; + } + // 查询对应ID + String idStr = configService.selectConfigByKey(type.getKey()); + if (!StringUtils.hasText(idStr)) { + log.warn("key {} not has text, so return null.", type.getKey()); + return null; + } + // 查询ID对应的文章 + return this.selectSmArticleByArticleId(Long.parseLong(idStr)); + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/businessRecord/service/SmBusinessRecordServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/businessRecord/service/SmBusinessRecordServiceImpl.java index ef348edc..b8e32f3d 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/businessRecord/service/SmBusinessRecordServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/businessRecord/service/SmBusinessRecordServiceImpl.java @@ -164,12 +164,12 @@ public class SmBusinessRecordServiceImpl implements ISmBusinessRecordService // 商户总数 SmUserQuery userDto = new SmUserQuery(); - userDto.setDelFlag(UserStatus.OK.getCode()); + userDto.setIsMch(true); brief.setUserCount(userService.selectCount(userDto)); // 租户总数 SmUserQuery tenantDto = new SmUserQuery(); - tenantDto.setDelFlag(UserStatus.OK.getCode()); + tenantDto.setIsMch(false); brief.setTenantCount(userService.selectCount(tenantDto)); // 充值金额总数 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml index a54650c5..0d468b03 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml @@ -80,19 +80,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and date(su.delete_time) = #{deleteDate} and date(su.create_time) = #{createDate} and su.user_id = #{userId} - - and su.user_id in ( - select sdt.tenant_id - from sm_device_tenant sdt - where sdt.device_id = #{tenantDeviceId} - ) - - - and su.user_id in - - #{item} - - + and su.del_flag = '0' + and su.del_flag = #{delFlag} + + and su.user_id in ( + select sdt.tenant_id + from sm_device_tenant sdt + where sdt.device_id = #{tenantDeviceId} + ) + + + and su.user_id in + + #{item} + +