Commit a8fd14323f6723c3c8e30bd0fc213fdf61f949bf

Authored by 张志伟
1 parent 2a8679ca

:boom: feat(*): 重构消息中心

- 重构消息中心
Showing 24 changed files with 539 additions and 821 deletions
fw-hestia-dao/src/main/java/cn/fw/hestia/dao/MessageHistoryDao.kt
1   -package cn.fw.hestia.dao;
  1 +package cn.fw.hestia.dao
2 2  
3   -import cn.fw.hestia.domain.db.MessageHistory;
4   -import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5   -import org.springframework.stereotype.Repository;
  3 +import cn.fw.hestia.domain.db.MessageHistory
  4 +import com.baomidou.mybatisplus.core.mapper.BaseMapper
  5 +import org.springframework.stereotype.Repository
6 6  
7 7 /**
  8 + * 消息记录
  9 + *
8 10 * @author : kurisu
9   - * @className : DemoDao
10   - * @description :
11   - * @date: 2021-09-23 15:23
  11 + * @version : 1.0
  12 + * @desc : 消息记录
  13 + * @date : 2023-12-18 09:44
12 14 */
13 15 @Repository
14   -public interface MessageHistoryDao extends BaseMapper<MessageHistory> {
15   -}
  16 +interface MessageHistoryDao : BaseMapper<MessageHistory> {
  17 +}
16 18 \ No newline at end of file
... ...
fw-hestia-dao/src/main/java/cn/fw/hestia/dao/SendLogDao.kt
1   -package cn.fw.hestia.dao;
  1 +package cn.fw.hestia.dao
2 2  
3   -import cn.fw.hestia.domain.db.SendLog;
4   -import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5   -import org.springframework.stereotype.Repository;
  3 +import cn.fw.hestia.domain.db.SendLog
  4 +import com.baomidou.mybatisplus.core.mapper.BaseMapper
  5 +import org.springframework.stereotype.Repository
6 6  
7 7 /**
  8 + * 消息发送日志
  9 + *
8 10 * @author : kurisu
9   - * @className : DemoDao
10   - * @description :
11   - * @date: 2021-09-23 15:23
  11 + * @version : 1.0
  12 + * @desc : 消息发送日志
  13 + * @date : 2023-12-18 09:45
12 14 */
13 15 @Repository
14   -public interface SendLogDao extends BaseMapper<SendLog> {
15   -}
  16 +interface SendLogDao : BaseMapper<SendLog> {
  17 +}
16 18 \ No newline at end of file
... ...
fw-hestia-domain/src/main/java/cn/fw/hestia/domain/db/MessageHistory.kt
1   -package cn.fw.hestia.domain.db;
2   -
3   -import cn.fw.hestia.domain.enums.MessageStateEnum;
4   -import com.baomidou.mybatisplus.annotation.*;
5   -import com.baomidou.mybatisplus.extension.activerecord.Model;
6   -import lombok.Data;
7   -import lombok.EqualsAndHashCode;
8   -import lombok.ToString;
9   -
10   -import java.util.Date;
  1 +package cn.fw.hestia.domain.db
11 2  
  3 +import cn.fw.common.annotation.NoArg
  4 +import cn.fw.hestia.domain.enums.MessageStateEnum
  5 +import com.baomidou.mybatisplus.annotation.*
  6 +import com.baomidou.mybatisplus.extension.activerecord.Model
  7 +import java.util.*
12 8  
13 9 /**
  10 + * 消息记录
  11 + *
14 12 * @author : kurisu
15   - * @className : MessageHistory
16   - * @description : 消息记录
17   - * @date: 2021-09-24 16:01
  13 + * @version : 1.0
  14 + * @desc : 消息记录
  15 + * @date : 2023-12-18 09:40
18 16 */
19   -@Data
20   -@ToString(callSuper = true)
21   -@EqualsAndHashCode(callSuper = true)
22   -public class MessageHistory extends Model<MessageHistory> {
23   - @TableId(type = IdType.ASSIGN_ID)
24   - private Long id;
25   - /**
26   - * 会员id
27   - */
28   - private Long memberId;
29   - /**
30   - * 模板code
31   - * 新版对应模板id
32   - */
33   - private String templateCode;
34   - /**
35   - * 消息标题
36   - */
37   - private String title;
38   - /**
39   - * 消息内容
40   - */
41   - private String content;
42   - /**
43   - * 关键词参数 (json字符串)
44   - */
45   - private String keywords;
46   - /**
47   - * 备注
48   - */
49   - private String remark;
50   - /**
51   - * 小程序页面路径
52   - */
53   - private String pagePath;
54   - /**
55   - * 小程序页面路径对应参数(json字符串)
56   - */
57   - private String pageParams;
58   - /**
59   - * 是否已读
60   - */
61   - private Boolean readz;
62   - /**
63   - * 发送时间
64   - */
65   - private Date sendTime;
66   - /**
67   - * 发送次数
68   - */
69   - private Integer frequency;
70   - /**
71   - * 发送状态
72   - */
73   - private MessageStateEnum state;
74   - /**
75   - * 是否有效
76   - */
77   - private Boolean yn;
78   - /**
79   - * 创建时间
80   - */
  17 +@NoArg
  18 +data class MessageHistory(
  19 + @TableId(type = IdType.ASSIGN_ID) var id: Long?,
  20 + var memberId: Long?,
  21 + var templateCode: String?,
  22 + var title: String?,
  23 + var content: String?,
  24 + var keywords: String?,
  25 + var remark: String?,
  26 + var pagePath: String?,
  27 + var pageParams: String?,
  28 + var readz: Boolean?,
  29 + var sendTime: Date?,
  30 + var frequency: Int?,
  31 + var state: MessageStateEnum?,
  32 + var yn: Boolean?,
81 33 @TableField(insertStrategy = FieldStrategy.NOT_NULL, fill = FieldFill.INSERT)
82   - private Date createTime;
83   -}
  34 + var createTime: Date?
  35 +) : Model<MessageHistory>()
... ...
fw-hestia-domain/src/main/java/cn/fw/hestia/domain/db/SendLog.kt
1   -package cn.fw.hestia.domain.db;
  1 +package cn.fw.hestia.domain.db
2 2  
3   -import cn.fw.common.data.entity.BaseEntity;
4   -import lombok.Data;
5   -import lombok.EqualsAndHashCode;
6   -import lombok.ToString;
7   -
8   -import java.util.Date;
  3 +import cn.fw.common.annotation.NoArg
  4 +import cn.fw.common.data.entity.BaseEntity
  5 +import java.util.*
9 6  
10 7 /**
  8 + * 消息发送记录
  9 + *
11 10 * @author : kurisu
12   - * @className : SendLog
13   - * @description : 消息发送记录
14   - * @date: 2021-09-24 16:23
  11 + * @version : 1.0
  12 + * @desc : 消息发送记录
  13 + * @date : 2023-12-18 09:13
15 14 */
16   -@Data
17   -@ToString(callSuper = true)
18   -@EqualsAndHashCode(callSuper = true)
19   -public class SendLog extends BaseEntity<SendLog, Long> {
20   - private Long messageId;
21   - private Date sendTime;
22   - private Boolean succeed;
23   - /**
24   - * 手动触发
25   - */
26   - private Boolean manual;
27   - private String result;
28   -}
  15 +@NoArg
  16 +data class SendLog(
  17 + var messageId: Long?,
  18 + var sendTime: Date?,
  19 + var succeed: Boolean?,
  20 + var manual: Boolean?,
  21 + var result: String?
  22 +) : BaseEntity<SendLog, Long>()
... ...
fw-hestia-domain/src/main/java/cn/fw/hestia/domain/vo/MessageHistoryVO.java
... ... @@ -58,7 +58,7 @@ public class MessageHistoryVO {
58 58 vo.setReadz(history.getReadz());
59 59 vo.setRemark(history.getRemark());
60 60 vo.setMessageTime(history.getCreateTime());
61   - if (history.getPagePath() != null && history.getPagePath().trim().length() > 0) {
  61 + if (history.getPagePath() != null && !history.getPagePath().trim().isEmpty()) {
62 62 String st = history.getPagePath() + "?sceneToken=" + history.getId();
63 63 vo.setPagePath(st);
64 64 }
... ...
fw-hestia-server/src/main/java/cn/fw/hestia/server/Application.kt
1   -package cn.fw.hestia.server;
  1 +package cn.fw.hestia.server
2 2  
3   -import cn.fw.hestia.component.SettingProperty;
4   -import cn.fw.security.auth.client.EnableAuthClient;
5   -import org.mybatis.spring.annotation.MapperScan;
6   -import org.springframework.boot.SpringApplication;
7   -import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
8   -import org.springframework.boot.context.properties.EnableConfigurationProperties;
9   -import org.springframework.cache.annotation.EnableCaching;
10   -import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
11   -import org.springframework.cloud.openfeign.EnableFeignClients;
12   -import org.springframework.context.annotation.ComponentScan;
13   -import org.springframework.context.annotation.Configuration;
14   -import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
15   -import org.springframework.scheduling.annotation.EnableScheduling;
16   -import org.springframework.transaction.annotation.EnableTransactionManagement;
  3 +import cn.fw.hestia.component.SettingProperty
  4 +import cn.fw.security.auth.client.EnableAuthClient
  5 +import org.mybatis.spring.annotation.MapperScan
  6 +import org.springframework.boot.SpringApplication
  7 +import org.springframework.boot.autoconfigure.EnableAutoConfiguration
  8 +import org.springframework.boot.context.properties.EnableConfigurationProperties
  9 +import org.springframework.cache.annotation.EnableCaching
  10 +import org.springframework.cloud.client.discovery.EnableDiscoveryClient
  11 +import org.springframework.cloud.openfeign.EnableFeignClients
  12 +import org.springframework.context.annotation.ComponentScan
  13 +import org.springframework.context.annotation.Configuration
  14 +import org.springframework.data.redis.repository.configuration.EnableRedisRepositories
  15 +import org.springframework.scheduling.annotation.EnableScheduling
  16 +import org.springframework.transaction.annotation.EnableTransactionManagement
17 17  
18 18 /**
19 19 * 启动类
... ... @@ -28,12 +28,14 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
28 28 @EnableAutoConfiguration
29 29 @Configuration
30 30 @EnableRedisRepositories
31   -@EnableConfigurationProperties({SettingProperty.class})
  31 +@EnableConfigurationProperties(
  32 + SettingProperty::class
  33 +)
32 34 @MapperScan("cn.fw.hestia.**.dao")
33   -@ComponentScan({"cn.fw.hestia.*"})
34   -@EnableFeignClients({"cn.fw.**.sdk"})
35   -public class Application {
36   - public static void main(final String[] args) {
37   - SpringApplication.run(Application.class, args);
38   - }
39   -}
  35 +@ComponentScan("cn.fw.hestia.*")
  36 +@EnableFeignClients("cn.fw.**.sdk")
  37 +class Application
  38 +
  39 +fun main(args: Array<String>) {
  40 + SpringApplication.run(Application::class.java, *args)
  41 +}
40 42 \ No newline at end of file
... ...
fw-hestia-server/src/main/java/cn/fw/hestia/server/config/CustomIdIdentifierGenerator.kt
1   -package cn.fw.hestia.server.config;
  1 +package cn.fw.hestia.server.config
2 2  
3   -import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
4   -import com.github.yitter.contract.IdGeneratorOptions;
5   -import com.github.yitter.idgen.YitIdHelper;
6   -import org.springframework.context.annotation.Scope;
7   -import org.springframework.stereotype.Component;
  3 +import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator
  4 +import com.github.yitter.contract.IdGeneratorOptions
  5 +import com.github.yitter.idgen.YitIdHelper
  6 +import org.springframework.context.annotation.Scope
  7 +import org.springframework.stereotype.Component
8 8  
9 9 /**
10 10 * 自定义id生成器
... ... @@ -12,21 +12,22 @@ import org.springframework.stereotype.Component;
12 12 */
13 13 @Component
14 14 @Scope("singleton")
15   -public class CustomIdIdentifierGenerator implements IdentifierGenerator {
16   - static {
17   - //全局初始化设置WorkerId,默认最大2^16-1,可通过调整 WorkerIdBitLength 增加最大值
18   - IdGeneratorOptions options = new IdGeneratorOptions();
19   - options.WorkerId = 1;
20   - options.WorkerIdBitLength = 6;
21   - YitIdHelper.setIdGenerator(options);
22   - System.out.println("------------------初始化IdentifierGenerator------------------------");
23   - }
24   -
25   - @Override
26   - public Long nextId(Object entity) {
  15 +class CustomIdIdentifierGenerator : IdentifierGenerator {
  16 + override fun nextId(entity: Any): Long {
27 17 //可以将当前传入的class全类名来作为bizKey,或者提取参数来生成bizKey进行分布式Id调用生成.
28   - String bizKey = entity.getClass().getName();
  18 + val bizKey = entity.javaClass.name
29 19 //根据bizKey调用分布式ID生成
30   - return YitIdHelper.nextId();
  20 + return YitIdHelper.nextId()
  21 + }
  22 +
  23 + companion object {
  24 + init {
  25 + //全局初始化设置WorkerId,默认最大2^16-1,可通过调整 WorkerIdBitLength 增加最大值
  26 + val options = IdGeneratorOptions()
  27 + options.WorkerId = 1
  28 + options.WorkerIdBitLength = 6
  29 + YitIdHelper.setIdGenerator(options)
  30 + println("------------------初始化IdentifierGenerator------------------------")
  31 + }
31 32 }
32 33 }
33 34 \ No newline at end of file
... ...
fw-hestia-server/src/main/java/cn/fw/hestia/server/config/LocalDateTimeSerializerConfig.java deleted
1   -package cn.fw.hestia.server.config;
2   -
3   -import com.fasterxml.jackson.core.JsonGenerator;
4   -import com.fasterxml.jackson.core.JsonParser;
5   -import com.fasterxml.jackson.databind.DeserializationContext;
6   -import com.fasterxml.jackson.databind.JsonDeserializer;
7   -import com.fasterxml.jackson.databind.JsonSerializer;
8   -import com.fasterxml.jackson.databind.SerializerProvider;
9   -import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
10   -import org.springframework.context.annotation.Bean;
11   -import org.springframework.context.annotation.Configuration;
12   -
13   -import java.io.IOException;
14   -import java.time.Instant;
15   -import java.time.LocalDate;
16   -import java.time.LocalDateTime;
17   -import java.time.ZoneId;
18   -
19   -/**
20   - * @author : kurisu
21   - * @className : LocalDateTimeSerializerConfig
22   - * @description : LocalDateTime序列化和反序列化配置
23   - * @date: 2021-01-19 10:04
24   - */
25   -@Configuration
26   -public class LocalDateTimeSerializerConfig {
27   -
28   -
29   - @Bean
30   - public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
31   - return builder -> {
32   - builder.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer());
33   - builder.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer());
34   - builder.serializerByType(LocalDate.class, new LocalDateSerializer());
35   - builder.deserializerByType(LocalDate.class, new LocalDateDeserializer());
36   - };
37   - }
38   -
39   - /**
40   - * 序列化
41   - */
42   - public static class LocalDateTimeSerializer extends JsonSerializer<LocalDateTime> {
43   - @Override
44   - public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers)
45   - throws IOException {
46   - if (value != null) {
47   - long timestamp = value.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
48   - gen.writeNumber(timestamp);
49   - }
50   - }
51   - }
52   -
53   - /**
54   - * 反序列化
55   - */
56   - public static class LocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {
57   - @Override
58   - public LocalDateTime deserialize(JsonParser p, DeserializationContext deserializationContext)
59   - throws IOException {
60   - long timestamp = p.getValueAsLong();
61   - if (timestamp > 0) {
62   - return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
63   - } else {
64   - return null;
65   - }
66   - }
67   - }
68   -
69   - /**
70   - * 序列化
71   - */
72   - public static class LocalDateSerializer extends JsonSerializer<LocalDate> {
73   - @Override
74   - public void serialize(LocalDate value, JsonGenerator gen, SerializerProvider serializers)
75   - throws IOException {
76   - if (value != null) {
77   - long timestamp = value.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli();
78   - gen.writeNumber(timestamp);
79   - }
80   - }
81   - }
82   -
83   - /**
84   - * 反序列化
85   - */
86   - public static class LocalDateDeserializer extends JsonDeserializer<LocalDate> {
87   - @Override
88   - public LocalDate deserialize(JsonParser p, DeserializationContext deserializationContext)
89   - throws IOException {
90   - long timestamp = p.getValueAsLong();
91   - if (timestamp > 0) {
92   - return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()).toLocalDate();
93   - } else {
94   - return null;
95   - }
96   - }
97   - }
98   -}
99 0 \ No newline at end of file
fw-hestia-server/src/main/java/cn/fw/hestia/server/controller/api/MessageCenterServiceImpl.kt
1   -package cn.fw.hestia.server.controller.api;
2   -
3   -import cn.fw.common.web.annotation.ControllerMethod;
4   -import cn.fw.data.base.domain.common.Message;
5   -import cn.fw.hestia.common.utils.MessageFormatUtil;
6   -import cn.fw.hestia.sdk.api.IMessageCenterService;
7   -import cn.fw.hestia.sdk.params.TemplateMessageParam;
8   -import cn.fw.hestia.sdk.params.ValidList;
9   -import cn.fw.hestia.sdk.result.SendResult;
10   -import cn.fw.hestia.service.buz.MessageCenterBizService;
11   -import lombok.Getter;
12   -import lombok.extern.slf4j.Slf4j;
13   -import org.springframework.beans.factory.annotation.Autowired;
14   -import org.springframework.beans.factory.annotation.Value;
15   -import org.springframework.web.bind.annotation.*;
16   -
17   -import javax.validation.Valid;
18   -import javax.validation.constraints.NotNull;
19   -import java.util.List;
20   -
21   -import static cn.fw.common.businessvalidator.Validator.BV;
22   -import static cn.fw.common.web.util.ResultBuilder.success;
  1 +package cn.fw.hestia.server.controller.api
  2 +
  3 +import cn.fw.common.businessvalidator.Validator.BV
  4 +import cn.fw.common.web.annotation.ControllerMethod
  5 +import cn.fw.common.web.util.ResultBuilder.success
  6 +import cn.fw.data.base.domain.common.Message
  7 +import cn.fw.hestia.common.utils.MessageFormatUtil
  8 +import cn.fw.hestia.sdk.api.IMessageCenterService
  9 +import cn.fw.hestia.sdk.params.TemplateMessageParam
  10 +import cn.fw.hestia.sdk.params.ValidList
  11 +import cn.fw.hestia.sdk.result.SendResult
  12 +import cn.fw.hestia.service.buz.MessageCenterBizService
  13 +import org.springframework.beans.factory.annotation.Value
  14 +import org.springframework.web.bind.annotation.*
  15 +import javax.validation.Valid
  16 +import javax.validation.constraints.NotNull
23 17  
24 18 /**
25 19 * @author : kurisu
... ... @@ -27,41 +21,40 @@ import static cn.fw.common.web.util.ResultBuilder.success;
27 21 * @description :
28 22 * @date: 2021-09-23 15:39
29 23 */
30   -@Slf4j
31 24 @RestController
32 25 @RequestMapping("/api/hestia/mc")
33   -public class MessageCenterServiceImpl implements IMessageCenterService {
34   - private final MessageCenterBizService messageCenterBizService;
35   -
36   - @Value("${task.max-size}")
37   - @Getter
38   - private int maxSize;
39   -
40   - @Autowired
41   - public MessageCenterServiceImpl(final MessageCenterBizService messageCenterBizService) {
42   - this.messageCenterBizService = messageCenterBizService;
43   - }
  26 +class MessageCenterServiceImpl(private val messageCenterBizService: MessageCenterBizService) :
  27 + IMessageCenterService {
  28 + @Value("\${task.max-size}")
  29 + private val maxSize = 0
44 30  
45 31 @PostMapping("/send")
46   - @Override
47 32 @ControllerMethod("发送模板消息")
48   - public Message<SendResult> send(@Valid @RequestBody TemplateMessageParam templateMessageParam) {
49   - return success(messageCenterBizService.saveMessage(templateMessageParam));
  33 + override fun send(@RequestBody templateMessageParam: @Valid TemplateMessageParam): Message<SendResult> {
  34 + return success(
  35 + messageCenterBizService.saveMessage(
  36 + templateMessageParam
  37 + )
  38 + )
50 39 }
51 40  
52 41 @PostMapping("/sendBatch")
53   - @Override
54 42 @ControllerMethod("批量发送模板消息")
55   - public Message<List<SendResult>> sendBatch(@RequestBody @Valid ValidList<TemplateMessageParam> paramList) {
56   - BV.isNotEmpty(paramList, () -> "消息列表不能为空");
57   - BV.isTrue(paramList.size() <= getMaxSize(), () -> MessageFormatUtil.MessageFormatTransfer("最多支持一次性发送{0}条", getMaxSize()));
58   - return success(messageCenterBizService.saveBatchMessage(paramList));
  43 + override fun sendBatch(@RequestBody paramList: @Valid ValidList<TemplateMessageParam>?): Message<List<SendResult>> {
  44 + BV.isNotEmpty(paramList) { "消息列表不能为空" }
  45 + BV.isTrue(
  46 + paramList!!.size <= maxSize
  47 + ) { MessageFormatUtil.MessageFormatTransfer("最多支持一次性发送{0}条", maxSize) }
  48 + return success(
  49 + messageCenterBizService.saveBatchMessage(
  50 + paramList
  51 + )
  52 + )
59 53 }
60 54  
61   - @Override
62 55 @DeleteMapping("/revoke")
63 56 @ControllerMethod("撤回消息")
64   - public Message<Boolean> revokeMessage(@NotNull(message = "Token不能为空") Long sceneToken) {
65   - return success(messageCenterBizService.revokeMessage(sceneToken));
  57 + override fun revokeMessage(sceneToken: @NotNull(message = "Token不能为空") Long?): Message<Boolean> {
  58 + return success(messageCenterBizService.revokeMessage(sceneToken))
66 59 }
67 60 -}
  61 +}
68 62 \ No newline at end of file
... ...
fw-hestia-server/src/main/java/cn/fw/hestia/server/controller/common/CommonController.kt
1   -package cn.fw.hestia.server.controller.common;
  1 +package cn.fw.hestia.server.controller.common
2 2  
3   -import cn.fw.common.web.annotation.ControllerMethod;
4   -import cn.fw.data.base.domain.common.Message;
5   -import cn.fw.hestia.service.buz.MessageCenterBizService;
6   -import cn.fw.security.auth.client.annotation.Authorization;
7   -import cn.fw.security.auth.client.enums.AuthType;
8   -import lombok.extern.slf4j.Slf4j;
9   -import org.springframework.beans.factory.annotation.Autowired;
10   -import org.springframework.validation.annotation.Validated;
11   -import org.springframework.web.bind.annotation.GetMapping;
12   -import org.springframework.web.bind.annotation.RequestMapping;
13   -import org.springframework.web.bind.annotation.RestController;
14   -
15   -import javax.validation.constraints.NotEmpty;
16   -import javax.validation.constraints.NotNull;
17   -
18   -import static cn.fw.common.web.util.ResultBuilder.success;
  3 +import cn.fw.common.web.annotation.ControllerMethod
  4 +import cn.fw.common.web.util.ResultBuilder.success
  5 +import cn.fw.data.base.domain.common.Message
  6 +import cn.fw.hestia.service.buz.MessageCenterBizService
  7 +import cn.fw.security.auth.client.annotation.Authorization
  8 +import cn.fw.security.auth.client.enums.AuthType
  9 +import org.springframework.validation.annotation.Validated
  10 +import org.springframework.web.bind.annotation.GetMapping
  11 +import org.springframework.web.bind.annotation.RequestMapping
  12 +import org.springframework.web.bind.annotation.RestController
  13 +import javax.validation.constraints.NotNull
19 14  
20 15 /**
21 16 * @author : kurisu
... ... @@ -23,28 +18,19 @@ import static cn.fw.common.web.util.ResultBuilder.success;
23 18 * @description :
24 19 * @date: 2021-09-23 15:39
25 20 */
26   -@Slf4j
27 21 @Validated
28 22 @RestController
29 23 @Authorization(AuthType.NONE)
30 24 @RequestMapping("/common/message")
31   -public class CommonController {
32   - private final MessageCenterBizService messageCenterBizService;
33   -
34   - @Autowired
35   - public CommonController(final MessageCenterBizService messageCenterBizService) {
36   - this.messageCenterBizService = messageCenterBizService;
37   - }
38   -
  25 +class CommonController(private val messageCenterBizService: MessageCenterBizService) {
39 26 @GetMapping("/send")
40 27 @ControllerMethod("手动发送消息")
41   - public Message<String> manualSend(@NotNull(message = "sceneToken不能为空") final Long sceneToken) {
42   - return success(messageCenterBizService.manualSend(sceneToken));
  28 + fun manualSend(sceneToken: @NotNull(message = "sceneToken不能为空") Long?): Message<String> {
  29 + return success(messageCenterBizService.manualSend(sceneToken))
43 30 }
44 31  
45   - @GetMapping("/query/code")
46   - @ControllerMethod("查询模板码")
47   - public Message<String> getCode() {
48   - return success(messageCenterBizService.getRdsTemplateCode());
49   - }
50   -}
  32 + @get:ControllerMethod("查询模板码")
  33 + @get:GetMapping("/query/code")
  34 + val code: Message<String>
  35 + get() = success(messageCenterBizService.rdsTemplateCode)
  36 +}
51 37 \ No newline at end of file
... ...
fw-hestia-server/src/main/java/cn/fw/hestia/server/controller/wx/MessageCenterController.kt
1   -package cn.fw.hestia.server.controller.wx;
2   -
3   -import cn.fw.common.page.AppPage;
4   -import cn.fw.common.web.annotation.ControllerMethod;
5   -import cn.fw.common.web.auth.PassportAuthBean;
6   -import cn.fw.common.web.auth.annotation.CurrentUser;
7   -import cn.fw.data.base.domain.common.Message;
8   -import cn.fw.hestia.domain.vo.HistoryQuery;
9   -import cn.fw.hestia.domain.vo.MessageHistoryVO;
10   -import cn.fw.hestia.service.buz.MessageCenterBizService;
11   -import cn.fw.security.auth.client.annotation.Authorization;
12   -import cn.fw.security.auth.client.enums.AuthType;
13   -import lombok.extern.slf4j.Slf4j;
14   -import org.springframework.beans.factory.annotation.Autowired;
15   -import org.springframework.validation.annotation.Validated;
16   -import org.springframework.web.bind.annotation.GetMapping;
17   -import org.springframework.web.bind.annotation.RequestMapping;
18   -import org.springframework.web.bind.annotation.RestController;
19   -
20   -import javax.validation.constraints.NotNull;
21   -import java.util.Map;
22   -
23   -import static cn.fw.common.web.util.ResultBuilder.success;
  1 +package cn.fw.hestia.server.controller.wx
  2 +
  3 +import cn.fw.common.page.AppPage
  4 +import cn.fw.common.web.annotation.ControllerMethod
  5 +import cn.fw.common.web.auth.annotation.CurrentUser
  6 +import cn.fw.common.web.util.ResultBuilder.success
  7 +import cn.fw.data.base.domain.common.Message
  8 +import cn.fw.hestia.domain.vo.HistoryQuery
  9 +import cn.fw.hestia.domain.vo.MessageHistoryVO
  10 +import cn.fw.hestia.service.buz.MessageCenterBizService
  11 +import cn.fw.security.auth.client.annotation.Authorization
  12 +import cn.fw.security.auth.client.enums.AuthType
  13 +import org.springframework.validation.annotation.Validated
  14 +import org.springframework.web.bind.annotation.GetMapping
  15 +import org.springframework.web.bind.annotation.RequestMapping
  16 +import org.springframework.web.bind.annotation.RestController
  17 +import javax.validation.constraints.NotNull
24 18  
25 19 /**
26 20 * @author : kurisu
... ... @@ -28,34 +22,26 @@ import static cn.fw.common.web.util.ResultBuilder.success;
28 22 * @description :
29 23 * @date: 2021-09-23 15:39
30 24 */
31   -@Slf4j
32 25 @Validated
33 26 @RestController
34 27 @Authorization(AuthType.WECHAT)
35 28 @RequestMapping("/wx/message")
36   -public class MessageCenterController {
37   - private final MessageCenterBizService messageCenterBizService;
38   -
39   - @Autowired
40   - public MessageCenterController(final MessageCenterBizService messageCenterBizService) {
41   - this.messageCenterBizService = messageCenterBizService;
42   - }
43   -
  29 +class MessageCenterController(private val messageCenterBizService: MessageCenterBizService) {
44 30 @GetMapping("/unread")
45 31 @ControllerMethod("查询消息未读数")
46   - public Message<Integer> send(@CurrentUser Long userId) {
47   - return success(messageCenterBizService.unreadCount(userId));
  32 + fun send(@CurrentUser userId: Long?): Message<Int> {
  33 + return success(messageCenterBizService.unreadCount(userId))
48 34 }
49 35  
50 36 @GetMapping("/query/pageParams")
51 37 @ControllerMethod("查询小程序页面的参数")
52   - public Message<Map<String, String>> queryPageParams(@NotNull(message = "sceneToken不能为空") final Long sceneToken) {
53   - return success(messageCenterBizService.queryPageParams(sceneToken));
  38 + fun queryPageParams(sceneToken: @NotNull(message = "sceneToken不能为空") Long?): Message<Map<String, String>> {
  39 + return success(messageCenterBizService.queryPageParams(sceneToken))
54 40 }
55 41  
56 42 @GetMapping("/query/history")
57 43 @ControllerMethod("查询消息历史记录")
58   - public Message<AppPage<MessageHistoryVO>> queryHistory(HistoryQuery query) {
59   - return success(messageCenterBizService.queryHistory(query));
  44 + fun queryHistory(query: HistoryQuery): Message<AppPage<MessageHistoryVO>> {
  45 + return success(messageCenterBizService.queryHistory(query))
60 46 }
61 47 -}
  48 +}
62 49 \ No newline at end of file
... ...
fw-hestia-server/src/main/java/cn/fw/hestia/server/converter/Timestamp2DateConverter.java deleted
1   -package cn.fw.hestia.server.converter;
2   -
3   -import org.apache.commons.lang3.StringUtils;
4   -import org.apache.commons.lang3.math.NumberUtils;
5   -import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
6   -import org.springframework.core.convert.converter.Converter;
7   -import org.springframework.lang.Nullable;
8   -import org.springframework.stereotype.Component;
9   -
10   -import java.util.Date;
11   -
12   -/**
13   - * @author : kurisu
14   - * @className : Timestamp2DateConverter
15   - * @description : {@link String} to {@link Date}
16   - * @date: 2021-01-19 10:04
17   - */
18   -@Component
19   -@ConfigurationPropertiesBinding
20   -public class Timestamp2DateConverter implements Converter<String, Date> {
21   - @Override
22   - @Nullable
23   - public Date convert(@Nullable final String value) {
24   - if (StringUtils.isNotBlank(value) && NumberUtils.isDigits(value)) {
25   - return new Date(new Long(value));
26   - }
27   - return null;
28   - }
29   -}
fw-hestia-server/src/main/java/cn/fw/hestia/server/converter/Timestamp2LocalDateConverter.java deleted
1   -package cn.fw.hestia.server.converter;
2   -
3   -import org.apache.commons.lang3.StringUtils;
4   -import org.apache.commons.lang3.math.NumberUtils;
5   -import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
6   -import org.springframework.core.convert.converter.Converter;
7   -import org.springframework.lang.Nullable;
8   -import org.springframework.stereotype.Component;
9   -
10   -import java.time.Instant;
11   -import java.time.LocalDate;
12   -import java.time.ZoneId;
13   -
14   -/**
15   - * @author : kurisu
16   - * @className : Timestamp2LocalDateConverter
17   - * @description : {@link String} to {@link LocalDate}
18   - * @date: 2021-01-19 10:04
19   - */
20   -@Component
21   -@ConfigurationPropertiesBinding
22   -public class Timestamp2LocalDateConverter implements Converter<String, LocalDate> {
23   - @Override
24   - @Nullable
25   - public LocalDate convert(@Nullable final String value) {
26   - if (StringUtils.isNotBlank(value) && NumberUtils.isDigits(value)) {
27   - return Instant.ofEpochMilli(NumberUtils.toLong(value)).atZone(ZoneId.systemDefault()).toLocalDate();
28   - }
29   - return null;
30   - }
31   -}
fw-hestia-server/src/main/java/cn/fw/hestia/server/converter/Timestamp2LocalDateTimeConverter.java deleted
1   -package cn.fw.hestia.server.converter;
2   -
3   -import org.apache.commons.lang3.StringUtils;
4   -import org.apache.commons.lang3.math.NumberUtils;
5   -import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
6   -import org.springframework.core.convert.converter.Converter;
7   -import org.springframework.lang.Nullable;
8   -import org.springframework.stereotype.Component;
9   -
10   -import java.time.Instant;
11   -import java.time.LocalDateTime;
12   -import java.time.ZoneId;
13   -
14   -/**
15   - * @author : kurisu
16   - * @className : Timestamp2LocalDateTimeConverter
17   - * @description : {@link String} to {@link LocalDateTime}
18   - * @date: 2021-01-19 10:04
19   - */
20   -@Component
21   -@ConfigurationPropertiesBinding
22   -public class Timestamp2LocalDateTimeConverter implements Converter<String, LocalDateTime> {
23   - @Override
24   - @Nullable
25   - public LocalDateTime convert(@Nullable final String value) {
26   - if (StringUtils.isNotBlank(value) && NumberUtils.isDigits(value)) {
27   - return Instant.ofEpochMilli(NumberUtils.toLong(value)).atZone(ZoneId.systemDefault()).toLocalDateTime();
28   - }
29   - return null;
30   - }
31   -}
fw-hestia-server/src/main/java/cn/fw/hestia/server/task/SendMessageTask.kt
1   -package cn.fw.hestia.server.task;
  1 +package cn.fw.hestia.server.task
2 2  
3   -import cn.fw.hestia.common.utils.ThreadPoolUtil;
4   -import cn.fw.hestia.domain.db.MessageHistory;
5   -import cn.fw.hestia.domain.enums.MessageStateEnum;
6   -import cn.fw.hestia.service.buz.MessageCenterBizService;
7   -import cn.fw.hestia.service.data.MessageHistoryService;
8   -import com.baomidou.mybatisplus.core.toolkit.Wrappers;
9   -import lombok.Getter;
10   -import org.springframework.beans.factory.annotation.Autowired;
11   -import org.springframework.beans.factory.annotation.Value;
12   -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
13   -import org.springframework.data.redis.core.BoundSetOperations;
14   -import org.springframework.data.redis.core.StringRedisTemplate;
15   -import org.springframework.scheduling.annotation.Scheduled;
16   -import org.springframework.stereotype.Component;
17   -import org.springframework.util.CollectionUtils;
18   -
19   -import java.time.LocalDateTime;
20   -import java.util.Date;
21   -import java.util.List;
22   -import java.util.concurrent.CompletableFuture;
23   -
24   -import static cn.fw.hestia.common.constant.MessageConstant.MAX_FREQUENCY;
  3 +import cn.fw.hestia.common.constant.MessageConstant
  4 +import cn.fw.hestia.common.utils.ThreadPoolUtil
  5 +import cn.fw.hestia.domain.db.MessageHistory
  6 +import cn.fw.hestia.domain.enums.MessageStateEnum
  7 +import cn.fw.hestia.service.buz.MessageCenterBizService
  8 +import cn.fw.hestia.service.data.MessageHistoryService
  9 +import com.baomidou.mybatisplus.core.toolkit.Wrappers
  10 +import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
  11 +import org.springframework.beans.factory.annotation.Value
  12 +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
  13 +import org.springframework.data.redis.core.StringRedisTemplate
  14 +import org.springframework.scheduling.annotation.Scheduled
  15 +import org.springframework.stereotype.Component
  16 +import org.springframework.util.CollectionUtils
  17 +import java.lang.Boolean
  18 +import java.time.LocalDateTime
  19 +import java.util.*
  20 +import java.util.concurrent.CompletableFuture
  21 +import kotlin.Long
  22 +import kotlin.String
  23 +import kotlin.also
  24 +import kotlin.let
25 25  
26 26 /**
27 27 * @author : kurisu
... ... @@ -30,42 +30,33 @@ import static cn.fw.hestia.common.constant.MessageConstant.MAX_FREQUENCY;
30 30 * @date: 2020-08-25 16:57
31 31 */
32 32 @Component
33   -@ConditionalOnProperty(prefix = "task", name = "switch", havingValue = "on")
34   -public class SendMessageTask {
35   - private final MessageCenterBizService messageCenterBizService;
36   - private final MessageHistoryService messageHistoryService;
37   - private final StringRedisTemplate stringRedisTemplate;
38   -
39   - @Getter
40   - @Value("${spring.cache.custom.global-prefix}:data:clear")
41   - private String dataClearKey;
42   -
43   - @Autowired
44   - public SendMessageTask(final MessageCenterBizService messageCenterBizService,
45   - final MessageHistoryService messageHistoryService,
46   - final StringRedisTemplate stringRedisTemplate) {
47   - this.messageCenterBizService = messageCenterBizService;
48   - this.messageHistoryService = messageHistoryService;
49   - this.stringRedisTemplate = stringRedisTemplate;
50   - }
  33 +@ConditionalOnProperty(prefix = "task", name = ["switch"], havingValue = "on")
  34 +class SendMessageTask(
  35 + private val messageCenterBizService: MessageCenterBizService,
  36 + private val messageHistoryService: MessageHistoryService,
  37 + private val stringRedisTemplate: StringRedisTemplate
  38 +) {
  39 + @Value("\${spring.cache.custom.global-prefix}:data:clear")
  40 + private var dataClearKey: String? = null
51 41  
52 42 /**
53 43 * 发送模板消息
54 44 */
55 45 @Scheduled(initialDelay = 1000 * 10, fixedRate = 1000 * 5)
56   - public void sendNotice() {
57   - List<MessageHistory> list = messageHistoryService.list(Wrappers.<MessageHistory>lambdaQuery()
58   - .eq(MessageHistory::getState, MessageStateEnum.MADA)
59   - .eq(MessageHistory::getYn, Boolean.TRUE)
60   - .lt(MessageHistory::getFrequency, MAX_FREQUENCY)
61   - .lt(MessageHistory::getSendTime, new Date())
  46 + fun sendNotice() {
  47 + val list = messageHistoryService.list(
  48 + KtQueryWrapper(MessageHistory::class.java)
  49 + .eq(MessageHistory::state, MessageStateEnum.MADA)
  50 + .eq(MessageHistory::yn, Boolean.TRUE)
  51 + .lt(MessageHistory::frequency, MessageConstant.MAX_FREQUENCY)
  52 + .lt(MessageHistory::sendTime, Date())
62 53 .last("limit 1000")
63   - );
  54 + )
64 55 if (CollectionUtils.isEmpty(list)) {
65   - return;
  56 + return
66 57 }
67   - for (MessageHistory history : list) {
68   - CompletableFuture.runAsync(() -> messageCenterBizService.sendMessage(history));
  58 + for (history in list) {
  59 + CompletableFuture.runAsync { messageCenterBizService.sendMessage(history) }
69 60 }
70 61 }
71 62  
... ... @@ -73,30 +64,36 @@ public class SendMessageTask {
73 64 * 缓存数据
74 65 */
75 66 @Scheduled(initialDelay = 1000 * 10, fixedRate = 1000 * 10)
76   - public void cacheOldData() {
77   - String key = getDataClearKey();
78   - final BoundSetOperations<String, String> setOps = stringRedisTemplate.boundSetOps(key);
79   - List<MessageHistory> list = messageHistoryService.list(Wrappers.<MessageHistory>lambdaQuery()
80   - .lt(MessageHistory::getCreateTime, LocalDateTime.now().minusMonths(6L))
  67 + fun cacheOldData() {
  68 + val key: String = dataClearKey ?: "hestia:global:data:clear"
  69 + val setOps = stringRedisTemplate.boundSetOps(key)
  70 + val list = messageHistoryService.list(
  71 + Wrappers.lambdaQuery<MessageHistory>()
  72 + .lt(MessageHistory::createTime, LocalDateTime.now().minusMonths(6L))
81 73 .last("limit 500")
82   - );
  74 + )
83 75 if (CollectionUtils.isEmpty(list)) {
84   - return;
  76 + return
85 77 }
86   - list.stream().map(MessageHistory::getId).forEach(id -> setOps.add(id.toString()));
  78 + list.stream().map(MessageHistory::id).forEach { id: Long? -> id?.let { setOps.add(it.toString()) } }
87 79 }
88 80  
89 81 /**
90 82 * 清理数据
91 83 */
92 84 @Scheduled(initialDelay = 1000 * 10, fixedRate = 1000 * 15)
93   - public void clearOldData() {
94   - String key = getDataClearKey();
95   - final BoundSetOperations<String, String> setOps = stringRedisTemplate.boundSetOps(key);
96   - String idStr;
97   - while ((idStr = setOps.pop()) != null) {
98   - final Long id = Long.valueOf(idStr);
99   - CompletableFuture.runAsync(() -> messageCenterBizService.clearHistory(id), ThreadPoolUtil.getInstance().getExecutor());
  85 + fun clearOldData() {
  86 + val key: String = dataClearKey ?: "hestia:global:data:clear"
  87 + val setOps = stringRedisTemplate.boundSetOps(key)
  88 + var idStr: String?
  89 + while ((setOps.pop().also { idStr = it }) != null) {
  90 + val id = idStr?.toLong()
  91 + id?.let {
  92 + CompletableFuture.runAsync(
  93 + { messageCenterBizService.clearHistory(it) },
  94 + ThreadPoolUtil.getInstance().executor
  95 + )
  96 + }
100 97 }
101 98 }
102 99 -}
  100 +}
103 101 \ No newline at end of file
... ...
fw-hestia-service/src/main/java/cn/fw/hestia/component/SendMsgProducer.kt
1   -package cn.fw.hestia.component;
  1 +package cn.fw.hestia.component
2 2  
3   -import cn.fw.hestia.sdk.result.MessageSendMq;
4   -import lombok.extern.slf4j.Slf4j;
5   -import org.apache.rocketmq.spring.core.RocketMQTemplate;
6   -import org.springframework.beans.factory.annotation.Autowired;
7   -import org.springframework.stereotype.Component;
8   -import org.springframework.web.bind.annotation.RequestMapping;
  3 +import cn.fw.hestia.sdk.result.MessageSendMq
  4 +import lombok.extern.slf4j.Slf4j
  5 +import org.apache.rocketmq.spring.core.RocketMQTemplate
  6 +import org.slf4j.Logger
  7 +import org.slf4j.LoggerFactory
  8 +import org.springframework.stereotype.Component
  9 +import org.springframework.web.bind.annotation.RequestMapping
9 10  
10 11 /**
11 12 * @author kurisu
12 13 */
13 14 @Slf4j
14 15 @Component
15   -public class SendMsgProducer {
16   - @Autowired
17   - private RocketMQTemplate rocketMQTemplate;
  16 +class SendMsgProducer(private val rocketMQTemplate: RocketMQTemplate) {
  17 + val log: Logger = LoggerFactory.getLogger(this::class.java)
18 18  
19   - @RequestMapping(value = "send")
20   - public void send(MessageSendMq messageSendMq) {
  19 + @RequestMapping(value = ["send"])
  20 + fun send(messageSendMq: MessageSendMq?) {
21 21 try {
22   - log.info("模板消息发送成功mq: body:[{}]", messageSendMq);
23   - rocketMQTemplate.syncSend(MessageSendMq.TOPIC + ":*", messageSendMq);
24   - } catch (Exception e) {
25   - e.printStackTrace();
  22 + log.info("模板消息发送成功mq: body:[{}]", messageSendMq)
  23 + rocketMQTemplate.syncSend(MessageSendMq.TOPIC + ":*", messageSendMq)
  24 + } catch (e: Exception) {
  25 + e.printStackTrace()
26 26 }
27 27 }
28 28 }
29 29 \ No newline at end of file
... ...
fw-hestia-service/src/main/java/cn/fw/hestia/component/SettingProperty.kt
1   -package cn.fw.hestia.component;
  1 +package cn.fw.hestia.component
2 2  
3   -import lombok.Getter;
4   -import lombok.Setter;
5   -import org.springframework.boot.context.properties.ConfigurationProperties;
  3 +import cn.fw.common.annotation.NoArg
  4 +import org.springframework.boot.context.properties.ConfigurationProperties
6 5  
7 6 /**
8 7 * 模板配置信息
... ... @@ -12,20 +11,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
12 11 * @desc : 模板配置信息
13 12 * @date : 2023-07-20 18:03
14 13 */
15   -@Getter
16   -@Setter
  14 +@NoArg
17 15 @ConfigurationProperties(prefix = "mptemplate")
18   -public class SettingProperty {
19   - private String tempId;
20   - private String typeSort1;
21   - private String typeSort2;
22   -
23   - @Override
24   - public String toString() {
25   - return "SettingProperty{" +
26   - "tempId='" + tempId + '\'' +
27   - ", typeSort1='" + typeSort1 + '\'' +
28   - ", typeSort2='" + typeSort2 + '\'' +
29   - '}';
30   - }
31   -}
  16 +data class SettingProperty(var tempId: String?, var typeSort1: String?, var typeSort2: String?)
32 17 \ No newline at end of file
... ...
fw-hestia-service/src/main/java/cn/fw/hestia/service/buz/MessageCenterBizService.kt
1   -package cn.fw.hestia.service.buz;
  1 +package cn.fw.hestia.service.buz
2 2  
3   -import cn.fw.common.data.mybatis.pagination.PageData;
4   -import cn.fw.common.page.AppPage;
5   -import cn.fw.hestia.common.constant.MessageConstant;
6   -import cn.fw.hestia.common.utils.DateUtil;
7   -import cn.fw.hestia.common.utils.StringUtils;
8   -import cn.fw.hestia.component.SendMsgProducer;
9   -import cn.fw.hestia.component.SettingProperty;
10   -import cn.fw.hestia.domain.db.MessageHistory;
11   -import cn.fw.hestia.domain.db.SendLog;
12   -import cn.fw.hestia.domain.enums.MessageStateEnum;
13   -import cn.fw.hestia.domain.vo.HistoryQuery;
14   -import cn.fw.hestia.domain.vo.MessageHistoryVO;
15   -import cn.fw.hestia.rpc.passport.TemplateMessageService;
16   -import cn.fw.hestia.rpc.passport.dto.TMParam;
17   -import cn.fw.hestia.sdk.params.TemplateMessageParam;
18   -import cn.fw.hestia.sdk.result.MessageSendMq;
19   -import cn.fw.hestia.sdk.result.SendResult;
20   -import cn.fw.hestia.service.data.MessageHistoryService;
21   -import cn.fw.hestia.service.data.SendLogService;
22   -import cn.fw.passport.sdk.api.param.WxMpTempMessageData;
23   -import com.alibaba.fastjson.JSON;
24   -import com.alibaba.fastjson.JSONArray;
25   -import com.baomidou.mybatisplus.core.toolkit.Wrappers;
26   -import lombok.Getter;
27   -import lombok.RequiredArgsConstructor;
28   -import lombok.extern.slf4j.Slf4j;
29   -import org.springframework.beans.factory.annotation.Value;
30   -import org.springframework.cache.annotation.Cacheable;
31   -import org.springframework.data.redis.core.BoundSetOperations;
32   -import org.springframework.data.redis.core.StringRedisTemplate;
33   -import org.springframework.stereotype.Service;
34   -import org.springframework.transaction.annotation.Transactional;
35   -import org.springframework.util.CollectionUtils;
36   -
37   -import java.time.LocalDate;
38   -import java.time.LocalDateTime;
39   -import java.util.*;
40   -import java.util.concurrent.TimeUnit;
41   -import java.util.function.Consumer;
42   -import java.util.stream.Collectors;
43   -
44   -import static cn.fw.common.businessvalidator.Validator.BV;
  3 +import cn.fw.common.businessvalidator.Validator
  4 +import cn.fw.common.data.mybatis.pagination.PageData
  5 +import cn.fw.common.page.AppPage
  6 +import cn.fw.hestia.common.constant.MessageConstant
  7 +import cn.fw.hestia.common.utils.DateUtil
  8 +import cn.fw.hestia.common.utils.StringUtils
  9 +import cn.fw.hestia.component.SendMsgProducer
  10 +import cn.fw.hestia.component.SettingProperty
  11 +import cn.fw.hestia.domain.db.MessageHistory
  12 +import cn.fw.hestia.domain.db.SendLog
  13 +import cn.fw.hestia.domain.enums.MessageStateEnum
  14 +import cn.fw.hestia.domain.vo.HistoryQuery
  15 +import cn.fw.hestia.domain.vo.MessageHistoryVO
  16 +import cn.fw.hestia.rpc.passport.dto.TMParam
  17 +import cn.fw.hestia.sdk.params.TemplateMessageParam
  18 +import cn.fw.hestia.sdk.result.MessageSendMq
  19 +import cn.fw.hestia.sdk.result.SendResult
  20 +import cn.fw.hestia.service.data.MessageHistoryService
  21 +import cn.fw.hestia.service.data.SendLogService
  22 +import cn.fw.passport.sdk.api.param.WxMpTempMessageData
  23 +import com.alibaba.fastjson.JSON
  24 +import com.alibaba.fastjson.JSONArray
  25 +import com.baomidou.mybatisplus.core.toolkit.Wrappers
  26 +import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
  27 +import lombok.Getter
  28 +import org.springframework.beans.factory.annotation.Value
  29 +import org.springframework.cache.annotation.Cacheable
  30 +import org.springframework.data.redis.core.StringRedisTemplate
  31 +import org.springframework.stereotype.Service
  32 +import org.springframework.transaction.annotation.Transactional
  33 +import org.springframework.util.CollectionUtils
  34 +import java.time.LocalDate
  35 +import java.time.LocalDateTime
  36 +import java.util.*
  37 +import java.util.concurrent.TimeUnit
  38 +import java.util.function.Consumer
  39 +import java.util.stream.Collectors
45 40  
46 41 /**
47 42 * @author : kurisu
... ... @@ -50,22 +45,23 @@ import static cn.fw.common.businessvalidator.Validator.BV;
50 45 * @date: 2021-09-24 17:10
51 46 */
52 47 @Service
53   -@RequiredArgsConstructor
54   -@Slf4j
55   -public class MessageCenterBizService {
56   - private final MessageHistoryService messageHistoryService;
57   - private final SendLogService sendLogService;
58   - private final TemplateMessageService templateMessageService;
59   - private final SendMsgProducer sendMsgProducer;
60   - private final StringRedisTemplate redisTemplate;
61   - private final SettingProperty settingProperty;
62   -
63   - @Value("${spring.cache.custom.global-prefix}:template:code")
  48 +class MessageCenterBizService(
  49 + private val messageHistoryService: MessageHistoryService,
  50 + private val sendLogService: SendLogService,
  51 + private val sendMsgProducer: SendMsgProducer,
  52 + private val redisTemplate: StringRedisTemplate,
  53 + private val settingProperty: SettingProperty
  54 +) {
  55 + @Value("\${spring.cache.custom.global-prefix}:template:code")
64 56 @Getter
65   - private String keyPrefix;
  57 + private val keyPrefix: String? = null
66 58  
67   - @Value("${spring.cache.custom.global-prefix}:template:send:scene:")
68   - private String sendDataPrefix;
  59 + @Value("\${spring.cache.custom.global-prefix}:template:send:scene:")
  60 + private val sendDataPrefix: String? = null
  61 + get() {
  62 + val today = LocalDate.now().toString()
  63 + return field + today
  64 + }
69 65  
70 66 /**
71 67 * 发送
... ... @@ -73,11 +69,11 @@ public class MessageCenterBizService {
73 69 * @param templateMessageParam
74 70 * @return token
75 71 */
76   - @Transactional(rollbackFor = Exception.class)
77   - public SendResult saveMessage(TemplateMessageParam templateMessageParam) {
78   - MessageHistory messageHistory = createBeans(templateMessageParam);
79   - messageHistoryService.save(messageHistory);
80   - return new SendResult(messageHistory.getId(), messageHistory.getMemberId());
  72 + @Transactional(rollbackFor = [Exception::class])
  73 + fun saveMessage(templateMessageParam: TemplateMessageParam): SendResult {
  74 + val messageHistory = createBeans(templateMessageParam)
  75 + messageHistoryService.save(messageHistory)
  76 + return SendResult(messageHistory.id, messageHistory.memberId)
81 77 }
82 78  
83 79 /**
... ... @@ -86,15 +82,15 @@ public class MessageCenterBizService {
86 82 * @param paramList
87 83 * @return token
88 84 */
89   - @Transactional(rollbackFor = Exception.class)
90   - public List<SendResult> saveBatchMessage(List<TemplateMessageParam> paramList) {
91   - List<MessageHistory> messageHistory = createBeans(paramList);
92   - messageHistoryService.saveBatch(messageHistory);
93   - List<SendResult> list = new ArrayList<>();
94   - for (MessageHistory history : messageHistory) {
95   - list.add(new SendResult(history.getId(), history.getMemberId()));
  85 + @Transactional(rollbackFor = [Exception::class])
  86 + fun saveBatchMessage(paramList: List<TemplateMessageParam>): List<SendResult> {
  87 + val messageHistory = createBeans(paramList)
  88 + messageHistoryService.saveBatch(messageHistory)
  89 + val list: MutableList<SendResult> = ArrayList()
  90 + for ((id, memberId) in messageHistory) {
  91 + list.add(SendResult(id, memberId))
96 92 }
97   - return list;
  93 + return list
98 94 }
99 95  
100 96  
... ... @@ -103,32 +99,32 @@ public class MessageCenterBizService {
103 99 *
104 100 * @param history
105 101 */
106   - @Transactional(rollbackFor = Exception.class)
107   - public void sendMessage(MessageHistory history) {
108   - String key = getSendDataPrefix();
109   - final BoundSetOperations<String, String> setOps = redisTemplate.boundSetOps(key);
110   - final String seanceToken = String.valueOf(history.getId());
111   - if (Boolean.TRUE.equals(setOps.isMember(seanceToken))) {
112   - return;
  102 + @Transactional(rollbackFor = [Exception::class])
  103 + fun sendMessage(history: MessageHistory) {
  104 + val key = sendDataPrefix ?: return
  105 + val setOps = redisTemplate.boundSetOps(key)
  106 + val seanceToken = history.id.toString()
  107 + if (java.lang.Boolean.TRUE == setOps.isMember(seanceToken)) {
  108 + return
113 109 }
114   - String result = saveLog(createTmParam(history), history.getId(), r -> {
115   - r.setManual(Boolean.FALSE);
116   - if (Boolean.TRUE.equals(r.getSucceed())) {
117   - setOps.add(seanceToken);
  110 + val result = saveLog(createTmParam(history), history.id) { r: SendLog ->
  111 + r.manual = java.lang.Boolean.FALSE
  112 + if (java.lang.Boolean.TRUE == r.succeed) {
  113 + setOps.add(seanceToken)
118 114 }
119   - });
120   - boolean succeed = MessageConstant.SUCCEED_STR.equals(result);
121   - final int frequency = history.getFrequency() + 1;
122   - history.setFrequency(frequency);
  115 + }
  116 + val succeed = MessageConstant.SUCCEED_STR == result
  117 + val frequency = history.frequency!! + 1
  118 + history.frequency = frequency
123 119 if (succeed) {
124   - history.setState(MessageStateEnum.SUMI);
  120 + history.state = MessageStateEnum.SUMI
125 121 //发送成功发送mq
126   - sendMsgProducer.send(new MessageSendMq(history.getId(), history.getMemberId(), new Date()));
127   - redisTemplate.expire(key, 24L, TimeUnit.HOURS);
  122 + sendMsgProducer.send(MessageSendMq(history.id, history.memberId, Date()))
  123 + redisTemplate.expire(key, 24L, TimeUnit.HOURS)
128 124 } else {
129   - history.setSendTime(DateUtil.getExpired(history.getSendTime(), 1 << frequency, Calendar.MINUTE));
  125 + history.sendTime = DateUtil.getExpired(history.sendTime, 1 shl frequency, Calendar.MINUTE)
130 126 }
131   - messageHistoryService.updateById(history);
  127 + messageHistoryService.updateById(history)
132 128 }
133 129  
134 130  
... ... @@ -137,12 +133,13 @@ public class MessageCenterBizService {
137 133 *
138 134 * @param id
139 135 */
140   - @Transactional(rollbackFor = Exception.class)
141   - public void clearHistory(Long id) {
142   - sendLogService.remove(Wrappers.<SendLog>lambdaQuery()
143   - .eq(SendLog::getMessageId, id)
144   - );
145   - messageHistoryService.removeById(id);
  136 + @Transactional(rollbackFor = [Exception::class])
  137 + fun clearHistory(id: Long?) {
  138 + sendLogService.remove(
  139 + Wrappers.lambdaQuery<SendLog>()
  140 + .eq(SendLog::messageId, id)
  141 + )
  142 + messageHistoryService.removeById(id)
146 143 }
147 144  
148 145 /**
... ... @@ -151,14 +148,14 @@ public class MessageCenterBizService {
151 148 * @param sceneToken
152 149 * @return
153 150 */
154   - @Transactional(rollbackFor = Exception.class)
155   - public Boolean revokeMessage(Long sceneToken) {
156   - MessageHistory history = messageHistoryService.getById(sceneToken);
  151 + @Transactional(rollbackFor = [Exception::class])
  152 + fun revokeMessage(sceneToken: Long?): Boolean {
  153 + val history = messageHistoryService.getById(sceneToken)
157 154 if (Objects.isNull(history)) {
158   - return Boolean.TRUE;
  155 + return true
159 156 }
160   - history.setYn(Boolean.FALSE);
161   - return messageHistoryService.updateById(history);
  157 + history.yn = false
  158 + return messageHistoryService.updateById(history)
162 159 }
163 160  
164 161 /**
... ... @@ -167,17 +164,18 @@ public class MessageCenterBizService {
167 164 * @param memberId
168 165 * @return
169 166 */
170   - @Cacheable(cacheNames = "UnreadCount", key = "':unread-count:' + #memberId", condition = "#result != 0")
171   - public int unreadCount(Long memberId) {
172   - if (memberId <= 0) {
173   - return 0;
  167 + @Cacheable(cacheNames = ["UnreadCount"], key = "':unread-count:' + #memberId", condition = "#result != 0")
  168 + fun unreadCount(memberId: Long?): Int {
  169 + if (memberId == null || memberId <= 0) {
  170 + return 0
174 171 }
175   - return messageHistoryService.count(Wrappers.<MessageHistory>lambdaQuery()
176   - .eq(MessageHistory::getMemberId, memberId)
177   - .eq(MessageHistory::getReadz, Boolean.FALSE)
178   - .eq(MessageHistory::getYn, Boolean.TRUE)
179   - .ge(MessageHistory::getSendTime, DateUtil.localDateTime2Date(LocalDateTime.now().minusMonths(3L)))
180   - );
  172 + return messageHistoryService.count(
  173 + KtQueryWrapper(MessageHistory::class.java)
  174 + .eq(MessageHistory::memberId, memberId)
  175 + .eq(MessageHistory::readz, false)
  176 + .eq(MessageHistory::yn, false)
  177 + .ge(MessageHistory::sendTime, DateUtil.localDateTime2Date(LocalDateTime.now().minusMonths(3L)))
  178 + )
181 179 }
182 180  
183 181 /**
... ... @@ -186,17 +184,21 @@ public class MessageCenterBizService {
186 184 * @param sceneToken
187 185 * @return
188 186 */
189   - @Transactional(rollbackFor = Exception.class)
190   - @Cacheable(cacheNames = "ExchangePageParam", key = "':Exchange-Page-Param:' + #sceneToken", condition = "#result != null")
191   - public Map<String, String> queryPageParams(Long sceneToken) {
192   - MessageHistory history = messageHistoryService.getById(sceneToken);
193   - BV.notNull(history, () -> "消息不存在或者已经被撤销");
194   - readMessage(history);
195   - String pageParams = history.getPageParams();
  187 + @Transactional(rollbackFor = [Exception::class])
  188 + @Cacheable(
  189 + cacheNames = ["ExchangePageParam"],
  190 + key = "':Exchange-Page-Param:' + #sceneToken",
  191 + condition = "#result != null"
  192 + )
  193 + fun queryPageParams(sceneToken: Long?): Map<String, String> {
  194 + val history = messageHistoryService.getById(sceneToken)
  195 + Validator.BV.notNull(history) { "消息不存在或者已经被撤销" }
  196 + readMessage(history)
  197 + val pageParams = history.pageParams
196 198 if (StringUtils.isEmpty(pageParams)) {
197   - return new HashMap<>(0);
  199 + return HashMap(0)
198 200 }
199   - return JSON.<HashMap<String, String>>parseObject(pageParams, HashMap.class);
  201 + return JSON.parseObject<HashMap<String, String>>(pageParams, HashMap::class.java)
200 202 }
201 203  
202 204 /**
... ... @@ -205,125 +207,125 @@ public class MessageCenterBizService {
205 207 * @param query
206 208 * @return
207 209 */
208   - public AppPage<MessageHistoryVO> queryHistory(HistoryQuery query) {
209   - if (Objects.isNull(query.getMemberId()) || query.getMemberId() <= 0) {
210   - return AppPage.empty(query);
  210 + fun queryHistory(query: HistoryQuery): AppPage<MessageHistoryVO> {
  211 + if (Objects.isNull(query.memberId) || query.memberId <= 0) {
  212 + return AppPage.empty(query)
211 213 }
212   - PageData<MessageHistory> pageData = messageHistoryService.page(new PageData<>(query), Wrappers.<MessageHistory>lambdaQuery()
213   - .eq(MessageHistory::getMemberId, query.getMemberId())
214   - .eq(MessageHistory::getYn, Boolean.TRUE)
215   - .ge(MessageHistory::getSendTime, DateUtil.localDateTime2Date(LocalDate.now().minusMonths(3L).atStartOfDay()))
216   - .orderByDesc(MessageHistory::getCreateTime)
217   - );
218   - AppPage<MessageHistoryVO> page = AppPage.empty(query);
219   - page.setCurrent((int) pageData.getCurrent());
220   - page.setPageSize((int) pageData.getSize());
221   - page.setTotal(pageData.getTotal());
222   - page.setData(new ArrayList<>());
223   - if (!CollectionUtils.isEmpty(pageData.getRecords())) {
224   - List<MessageHistoryVO> voList = pageData.getRecords().stream().map(MessageHistoryVO::with).collect(Collectors.toList());
225   - page.setData(voList);
  214 + val pageData = messageHistoryService.page<PageData<MessageHistory>>(
  215 + PageData(query), KtQueryWrapper(MessageHistory::class.java)
  216 + .eq(MessageHistory::memberId, query.memberId)
  217 + .eq(MessageHistory::yn, true)
  218 + .ge(
  219 + MessageHistory::sendTime,
  220 + DateUtil.localDateTime2Date(LocalDate.now().minusMonths(3L).atStartOfDay())
  221 + )
  222 + .orderByDesc(MessageHistory::createTime)
  223 + )
  224 + val page = AppPage.empty<MessageHistoryVO>(query)
  225 + page.setCurrent(pageData.current.toInt())
  226 + page.setPageSize(pageData.size.toInt())
  227 + page.setTotal(pageData.total)
  228 + page.setData(ArrayList())
  229 + if (!CollectionUtils.isEmpty(pageData.records)) {
  230 + val voList = pageData.records.stream().map { history: MessageHistory? ->
  231 + MessageHistoryVO.with(
  232 + history
  233 + )
  234 + }.collect(Collectors.toList())
  235 + page.setData(voList)
226 236 }
227   - return page;
  237 + return page
228 238 }
229 239  
230 240  
231   - public void readMessage(MessageHistory history) {
232   - if (Boolean.FALSE.equals(history.getReadz())) {
233   - history.setReadz(Boolean.TRUE);
234   - history.setState(MessageStateEnum.SUMI);
235   - messageHistoryService.updateById(history);
  241 + fun readMessage(history: MessageHistory) {
  242 + if (java.lang.Boolean.FALSE == history.readz) {
  243 + history.readz = java.lang.Boolean.TRUE
  244 + history.state = MessageStateEnum.SUMI
  245 + messageHistoryService.updateById(history)
236 246 }
237 247 }
238 248  
239   - public String manualSend(Long id) {
240   - MessageHistory messageHistory = messageHistoryService.getById(id);
241   - String result = saveLog(createTmParam(messageHistory), messageHistory.getId(), r -> r.setManual(Boolean.TRUE));
242   - boolean succeed = MessageConstant.SUCCEED_STR.equals(result);
243   - if (succeed) {
244   - messageHistory.setState(MessageStateEnum.SUMI);
245   - sendMsgProducer.send(new MessageSendMq(messageHistory.getId(), messageHistory.getMemberId(), new Date()));
246   - }
247   - messageHistoryService.updateById(messageHistory);
248   - return result;
  249 + fun manualSend(id: Long?): String {
  250 + val messageHistory: MessageHistory? = messageHistoryService.getById(id)
  251 + return messageHistory?.run {
  252 + val result = saveLog(
  253 + createTmParam(messageHistory), messageHistory.id
  254 + ) { r: SendLog -> r.manual = java.lang.Boolean.TRUE }
  255 + val succeed = MessageConstant.SUCCEED_STR == result
  256 + if (succeed) {
  257 + messageHistory.state = MessageStateEnum.SUMI
  258 + sendMsgProducer.send(MessageSendMq(messageHistory.id, messageHistory.memberId, Date()))
  259 + }
  260 + messageHistoryService.updateById(messageHistory)
  261 + result
  262 + } ?: "消息不存在"
249 263 }
250 264  
251   - public String getRdsTemplateCode() {
252   - return settingProperty.getTempId();
253   - }
  265 + val rdsTemplateCode: String
  266 + get() = settingProperty.tempId ?: "无效code"
254 267  
255   - private String saveLog(TMParam tmParam, Long messageId, Consumer<SendLog> cons) {
256   -// String result = templateMessageService.sendTemplateMessage(tmParam);
257   - String result = MessageConstant.SUCCEED_STR;
258   - SendLog sendLog = new SendLog();
259   - sendLog.setMessageId(messageId);
260   - sendLog.setSendTime(new Date());
261   - sendLog.setSucceed(MessageConstant.SUCCEED_STR.equals(result));
262   - sendLog.setResult(result);
263   - sendLog.setManual(Boolean.FALSE);
264   - cons.accept(sendLog);
265   - sendLogService.save(sendLog);
266   - return result;
  268 + private fun saveLog(tmParam: TMParam, messageId: Long?, cons: Consumer<SendLog>): String {
  269 + val result = MessageConstant.SUCCEED_STR
  270 + val sendLog = SendLog(messageId, Date(), true, java.lang.Boolean.FALSE, result)
  271 + sendLogService.save(sendLog)
  272 + return result
267 273 }
268 274  
269   - private List<MessageHistory> createBeans(List<TemplateMessageParam> paramList) {
270   - List<MessageHistory> list = new ArrayList<>();
271   - for (TemplateMessageParam param : paramList) {
272   - list.add(createBeans(param));
  275 + private fun createBeans(paramList: List<TemplateMessageParam>): List<MessageHistory> {
  276 + val list: MutableList<MessageHistory> = ArrayList()
  277 + for (param in paramList) {
  278 + list.add(createBeans(param))
273 279 }
274   - return list;
  280 + return list
275 281 }
276 282  
277   - private MessageHistory createBeans(TemplateMessageParam param) {
278   - Long memberId = param.getMemberId();
279   - MessageHistory messageHistory = new MessageHistory();
280   - messageHistory.setMemberId(memberId);
281   - messageHistory.setTemplateCode(settingProperty.getTempId());
282   - messageHistory.setTitle(param.getTitle());
283   - StringBuilder content = new StringBuilder(param.getContent());
284   - if (!CollectionUtils.isEmpty(param.getExtraMap())) {
285   - content.append("\n");
286   - for (Map.Entry<String, String> mapEntry : param.getExtraMap().entrySet()) {
  283 + private fun createBeans(param: TemplateMessageParam): MessageHistory {
  284 + val memberId = param.memberId
  285 + val content = StringBuilder(param.content)
  286 + if (!CollectionUtils.isEmpty(param.extraMap)) {
  287 + content.append("\n")
  288 + for ((key, value) in param.extraMap) {
287 289 content.append("\n")
288   - .append(mapEntry.getKey())
289   - .append(":")
290   - .append(mapEntry.getValue());
  290 + .append(key)
  291 + .append(":")
  292 + .append(value)
291 293 }
292 294 }
293   - messageHistory.setContent(content.toString());
294   - messageHistory.setRemark(param.getRemark());
295   - messageHistory.setPagePath(param.getPath());
296   - messageHistory.setReadz(StringUtils.isEmpty(param.getPath()));
297   - messageHistory.setFrequency(0);
298   - messageHistory.setYn(Boolean.TRUE);
299   - messageHistory.setSendTime(new Date());
300   - messageHistory.setState(MessageStateEnum.MADA);
301 295  
302   - List<WxMpTempMessageData> keywords = Arrays.asList(
303   - new WxMpTempMessageData(settingProperty.getTypeSort1(), param.getTitle()),
304   - new WxMpTempMessageData(settingProperty.getTypeSort2(), StringUtils.isEmpty(param.getRemark()) ? "~" : param.getRemark())
305   - );
306   - messageHistory.setKeywords(JSONArray.toJSONString(keywords));
307   - if (!CollectionUtils.isEmpty(param.getParamMap())) {
308   - messageHistory.setPageParams(JSON.toJSONString(param.getParamMap()));
309   - }
310   - return messageHistory;
311   - }
  296 + val keywords = Arrays.asList(
  297 + WxMpTempMessageData(settingProperty.typeSort1, param.title),
  298 + WxMpTempMessageData(settingProperty.typeSort2, if (StringUtils.isEmpty(param.remark)) "~" else param.remark)
  299 + )
312 300  
313   - private TMParam createTmParam(MessageHistory history) {
314   - TMParam tmParam = new TMParam();
315   - tmParam.setSceneToken(history.getId());
316   - tmParam.setTitle(history.getContent());
317   - tmParam.setRemark(history.getRemark());
318   - tmParam.setPath(history.getPagePath());
319   - tmParam.setTemplateCode(history.getTemplateCode());
320   - tmParam.setMemberId(history.getMemberId());
321   - tmParam.setKeywords(history.getKeywords());
322   - return tmParam;
  301 + return MessageHistory(
  302 + id = null,
  303 + memberId = memberId,
  304 + templateCode = settingProperty.tempId,
  305 + title = param.title,
  306 + content = content.toString(),
  307 + keywords = JSONArray.toJSONString(keywords),
  308 + remark = param.remark,
  309 + pagePath = param.path,
  310 + pageParams = if (param.paramMap.isNullOrEmpty()) null else JSON.toJSONString(param.paramMap),
  311 + readz = StringUtils.isEmpty(param.path),
  312 + sendTime = Date(),
  313 + frequency = 0,
  314 + state = MessageStateEnum.MADA,
  315 + yn = true,
  316 + createTime = Date()
  317 + )
323 318 }
324 319  
325   - private String getSendDataPrefix() {
326   - String today = LocalDate.now().toString();
327   - return this.sendDataPrefix + today;
  320 + private fun createTmParam(history: MessageHistory): TMParam {
  321 + val tmParam = TMParam()
  322 + tmParam.setSceneToken(history.id)
  323 + tmParam.setTitle(history.content)
  324 + tmParam.setRemark(history.remark)
  325 + tmParam.setPath(history.pagePath)
  326 + tmParam.setTemplateCode(history.templateCode)
  327 + tmParam.setMemberId(history.memberId)
  328 + tmParam.setKeywords(history.keywords)
  329 + return tmParam
328 330 }
329 331 -}
  332 +}
330 333 \ No newline at end of file
... ...
fw-hestia-service/src/main/java/cn/fw/hestia/service/data/MessageHistoryService.kt
1   -package cn.fw.hestia.service.data;
  1 +package cn.fw.hestia.service.data
2 2  
3   -import cn.fw.hestia.domain.db.MessageHistory;
4   -import com.baomidou.mybatisplus.extension.service.IService;
  3 +import cn.fw.hestia.domain.db.MessageHistory
  4 +import com.baomidou.mybatisplus.extension.service.IService
5 5  
6 6 /**
7 7 * @author : kurisu
... ... @@ -9,5 +9,4 @@ import com.baomidou.mybatisplus.extension.service.IService;
9 9 * @description :
10 10 * @date: 2021-09-23 15:40
11 11 */
12   -public interface MessageHistoryService extends IService<MessageHistory> {
13   -}
  12 +interface MessageHistoryService : IService<MessageHistory>
14 13 \ No newline at end of file
... ...
fw-hestia-service/src/main/java/cn/fw/hestia/service/data/SendLogService.kt
1   -package cn.fw.hestia.service.data;
  1 +package cn.fw.hestia.service.data
2 2  
3   -import cn.fw.hestia.domain.db.SendLog;
4   -import com.baomidou.mybatisplus.extension.service.IService;
  3 +import cn.fw.hestia.domain.db.SendLog
  4 +import com.baomidou.mybatisplus.extension.service.IService
5 5  
6 6 /**
  7 + * 消息发送日志服务
  8 + *
7 9 * @author : kurisu
8   - * @className : SendLogService
9   - * @description :
10   - * @date: 2021-09-23 15:40
  10 + * @version : 1.0
  11 + * @desc : 消息发送日志服务
  12 + * @date : 2023-12-18 09:47
11 13 */
12   -public interface SendLogService extends IService<SendLog> {
13   -}
  14 +interface SendLogService : IService<SendLog> {
  15 +}
14 16 \ No newline at end of file
... ...
fw-hestia-service/src/main/java/cn/fw/hestia/service/data/impl/MessageHistoryServiceImpl.kt
1   -package cn.fw.hestia.service.data.impl;
  1 +package cn.fw.hestia.service.data.impl
2 2  
3   -import cn.fw.hestia.dao.MessageHistoryDao;
4   -import cn.fw.hestia.domain.db.MessageHistory;
5   -import cn.fw.hestia.service.data.MessageHistoryService;
6   -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7   -import org.springframework.stereotype.Service;
  3 +import cn.fw.hestia.dao.MessageHistoryDao
  4 +import cn.fw.hestia.domain.db.MessageHistory
  5 +import cn.fw.hestia.service.data.MessageHistoryService
  6 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
  7 +import org.springframework.stereotype.Service
8 8  
9 9 /**
10 10 * @author : kurisu
... ... @@ -13,5 +13,4 @@ import org.springframework.stereotype.Service;
13 13 * @date: 2021-09-23 15:41
14 14 */
15 15 @Service
16   -public class MessageHistoryServiceImpl extends ServiceImpl<MessageHistoryDao, MessageHistory> implements MessageHistoryService {
17   -}
  16 +class MessageHistoryServiceImpl : ServiceImpl<MessageHistoryDao, MessageHistory>(), MessageHistoryService
18 17 \ No newline at end of file
... ...
fw-hestia-service/src/main/java/cn/fw/hestia/service/data/impl/SendLogServiceImpl.kt
1   -package cn.fw.hestia.service.data.impl;
  1 +package cn.fw.hestia.service.data.impl
2 2  
3   -import cn.fw.hestia.dao.SendLogDao;
4   -import cn.fw.hestia.domain.db.SendLog;
5   -import cn.fw.hestia.service.data.SendLogService;
6   -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7   -import org.springframework.stereotype.Service;
  3 +import cn.fw.hestia.dao.SendLogDao
  4 +import cn.fw.hestia.domain.db.SendLog
  5 +import cn.fw.hestia.service.data.SendLogService
  6 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
  7 +import org.springframework.stereotype.Service
8 8  
9 9 /**
10 10 * @author : kurisu
... ... @@ -13,5 +13,4 @@ import org.springframework.stereotype.Service;
13 13 * @date: 2021-09-23 15:41
14 14 */
15 15 @Service
16   -public class SendLogServiceImpl extends ServiceImpl<SendLogDao, SendLog> implements SendLogService {
17   -}
  16 +class SendLogServiceImpl : ServiceImpl<SendLogDao, SendLog>(), SendLogService
18 17 \ No newline at end of file
... ...
lombok.config 0 → 100644
  1 +config.stopBubbling = true
  2 +lombok.accessors.chain=true
... ...
... ... @@ -152,6 +152,10 @@
152 152 <build>
153 153 <plugins>
154 154 <plugin>
  155 + <groupId>org.jetbrains.kotlin</groupId>
  156 + <artifactId>kotlin-maven-plugin</artifactId>
  157 + </plugin>
  158 + <plugin>
155 159 <groupId>org.apache.maven.plugins</groupId>
156 160 <artifactId>maven-compiler-plugin</artifactId>
157 161 <configuration>
... ...