Commit b6ad33e440c04df411d711dd2754db75f9131ea6

Authored by 张志伟
1 parent 6985174c

:fire: feat(*): 重构

- 重构
fw-hermes-common/src/main/java/cn/fw/hermes/common/utils/StringUtils.java
... ... @@ -25,9 +25,9 @@ public final class StringUtils {
25 25 /**
26 26 * 特殊字符正则表达式
27 27 */
28   - public static final String regEx = "[`~!@#$%^&*()+=|{}':;',\[\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]";
  28 + public static final String REG_EX = "[`~!@#$%^&*()+=|{}':;',\[\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]";
29 29  
30   - public static final String regNo = "^[-\\+]?[\\d]*$";
  30 + public static final String REG_NO = "^[-+]?\\d*$";
31 31  
32 32 private StringUtils() {
33 33 }
... ... @@ -98,7 +98,7 @@ public final class StringUtils {
98 98 * @return
99 99 */
100 100 public static boolean isEmpty(Object obj) {
101   - return obj == null || obj.toString().length() == 0;
  101 + return obj == null || obj.toString().isEmpty();
102 102 }
103 103  
104 104 /**
... ... @@ -111,7 +111,7 @@ public final class StringUtils {
111 111 if (isEmpty(obj)) {
112 112 return false;
113 113 }
114   - Pattern compile = Pattern.compile(regNo);
  114 + Pattern compile = Pattern.compile(REG_NO);
115 115 return compile.matcher(obj.toString()).matches();
116 116 }
117 117  
... ...
fw-hermes-server/src/main/java/cn/fw/hermes/controller/api/v2/AccountV2ServiceImpl.java deleted
1   -package cn.fw.hermes.controller.api.v2;
2   -
3   -import cn.fw.common.web.annotation.ControllerMethod;
4   -import cn.fw.data.base.domain.common.Message;
5   -import cn.fw.hermes.domain.enums.AccountTypeEnum;
6   -import cn.fw.hermes.sdk.v2.enums.AccountType;
7   -import cn.fw.hermes.sdk.v2.para.AccountV2Condition;
8   -import cn.fw.hermes.sdk.v2.service.IAccountV2Service;
9   -import cn.fw.hermes.service.biz.AccountBizService;
10   -import org.springframework.beans.factory.annotation.Autowired;
11   -import org.springframework.validation.annotation.Validated;
12   -import org.springframework.web.bind.annotation.*;
13   -
14   -import static cn.fw.common.businessvalidator.Validator.BV;
15   -import static cn.fw.data.base.domain.common.Message.success;
16   -
17   -/**
18   - * 账号服务
19   - *
20   - * @author : kurisu
21   - * @version : 2.0
22   - * @desc : 账号服务
23   - * @date : 2023-07-20 16:51
24   - */
25   -@Validated
26   -@RestController
27   -@RequestMapping("/api/hermes/account")
28   -public class AccountV2ServiceImpl implements IAccountV2Service {
29   - private final AccountBizService accountBizService;
30   -
31   - @Autowired
32   - public AccountV2ServiceImpl(final AccountBizService accountBizService) {
33   - this.accountBizService = accountBizService;
34   - }
35   -
36   - @Override
37   - @PostMapping("/register")
38   - @ControllerMethod("用户注册")
39   - public Message<Boolean> register(@RequestBody @Validated AccountV2Condition condition) {
40   - Long userId = condition.getUserId();
41   - String userName = condition.getUserName();
42   - AccountType accountType = AccountType.ofValue(condition.getAccountType());
43   - if (AccountType.B_USER.equals(accountType)) {
44   - accountBizService.queryStaffTopic(userId, userName, "");
45   - } else {
46   - accountBizService.queryUserTopic(userId, userName, "");
47   - }
48   - return success(Boolean.TRUE);
49   - }
50   -
51   - @Override
52   - @GetMapping("/getIdentifier")
53   - @ControllerMethod("获取用户标识码")
54   - public Message<String> getIdentifier(@RequestParam("userId") Long userId, @RequestParam(value = "userType", defaultValue = "1", required = false) Integer userType) {
55   - AccountType accountType = AccountType.ofValue(userType);
56   - BV.notNull(accountType, () -> "账户类型不正确");
57   - AccountTypeEnum type = AccountType.B_USER.equals(accountType) ? AccountTypeEnum.B_USER : AccountTypeEnum.C_USER;
58   - String identifier = accountBizService.getUserIdentifier(userId, type);
59   - return success(identifier);
60   - }
61   -
62   - @Override
63   - @GetMapping("/kick-out")
64   - @ControllerMethod("踢下线")
65   - public Message<Void> kick(@RequestParam("userId") Long userId, @RequestParam("userType") Integer userType) {
66   - AccountType accountType = AccountType.ofValue(userType);
67   - BV.notNull(accountType, () -> "账户类型不正确");
68   - accountBizService.kick(userId, AccountType.B_USER.equals(accountType));
69   - return success();
70   - }
71   -}
fw-hermes-server/src/main/java/cn/fw/hermes/controller/api/v2/MessageV2ServiceImpl.java deleted
1   -package cn.fw.hermes.controller.api.v2;
2   -
3   -import cn.fw.common.web.annotation.ControllerMethod;
4   -import cn.fw.data.base.domain.common.Message;
5   -import cn.fw.hermes.sdk.v2.para.AppUpdateMsgCondition;
6   -import cn.fw.hermes.sdk.v2.para.MsgV2Condition;
7   -import cn.fw.hermes.sdk.v2.result.MessageV2Result;
8   -import cn.fw.hermes.sdk.v2.service.IMessageV2Service;
9   -import cn.fw.hermes.service.biz.AppUpdateBizService;
10   -import cn.fw.hermes.service.biz.MessageQueryerService;
11   -import cn.fw.hermes.service.biz.MsgPrepareBizService;
12   -import org.springframework.beans.factory.annotation.Autowired;
13   -import org.springframework.validation.annotation.Validated;
14   -import org.springframework.web.bind.annotation.*;
15   -
16   -import static cn.fw.data.base.domain.common.Message.success;
17   -
18   -/**
19   - * 消息处理服务
20   - *
21   - * @author : kurisu
22   - * @version : 2.0
23   - * @desc : 消息处理服务
24   - * @date : 2023-07-22 15:05
25   - */
26   -@RestController
27   -@Validated
28   -@RequestMapping("/api/hermes/message")
29   -public class MessageV2ServiceImpl implements IMessageV2Service {
30   - private final MessageQueryerService messageQueryerService;
31   - private final MsgPrepareBizService msgPrepareBizService;
32   - private final AppUpdateBizService appUpdateBizService;
33   -
34   - @Autowired
35   - public MessageV2ServiceImpl(final MessageQueryerService messageQueryerService,
36   - final MsgPrepareBizService msgPrepareBizService,
37   - final AppUpdateBizService appUpdateBizService) {
38   - this.messageQueryerService = messageQueryerService;
39   - this.msgPrepareBizService = msgPrepareBizService;
40   - this.appUpdateBizService = appUpdateBizService;
41   - }
42   -
43   - @Override
44   - @PostMapping("/send/async")
45   - @ControllerMethod("异步发送消息")
46   - public Message<Long> asyncSendMsg(@RequestBody @Validated MsgV2Condition condition) {
47   - return success(msgPrepareBizService.asyncSendMsg(condition));
48   - }
49   -
50   - @Override
51   - @PostMapping("/send/sync")
52   - @ControllerMethod("同步发送消息")
53   - public Message<MessageV2Result> sendMsg(@RequestBody @Validated MsgV2Condition condition) {
54   - return success(msgPrepareBizService.sendMsg(condition));
55   - }
56   -
57   - @Override
58   - @GetMapping("/result")
59   - @ControllerMethod("查询消息结果")
60   - public Message<MessageV2Result> queryMsgResult(@RequestParam("messageId") final Long messageId) {
61   - return success(messageQueryerService.queryResultById(messageId));
62   - }
63   -
64   - @Override
65   - @ControllerMethod("发送应用更新消息")
66   - @PostMapping("/send/update_msg")
67   - public Message<Void> sendUpdateMsg(@RequestBody @Validated AppUpdateMsgCondition condition) {
68   - appUpdateBizService.sendUpdateMsg(condition);
69   - return success();
70   - }
71   -}
fw-hermes-server/src/main/java/cn/fw/hermes/config/AutoConfiguration.kt renamed to fw-hermes-server/src/main/kotlin/cn/fw/hermes/config/AutoConfiguration.kt
fw-hermes-server/src/main/java/cn/fw/hermes/config/CustomIdIdentifierGenerator.kt renamed to fw-hermes-server/src/main/kotlin/cn/fw/hermes/config/CustomIdIdentifierGenerator.kt
fw-hermes-server/src/main/java/cn/fw/hermes/config/LaunchConfiguration.kt renamed to fw-hermes-server/src/main/kotlin/cn/fw/hermes/config/LaunchConfiguration.kt
fw-hermes-server/src/main/java/cn/fw/hermes/config/ScheduleConfig.kt renamed to fw-hermes-server/src/main/kotlin/cn/fw/hermes/config/ScheduleConfig.kt
fw-hermes-server/src/main/kotlin/cn/fw/hermes/controller/api/AccountV2ServiceImpl.kt 0 → 100644
  1 +package cn.fw.hermes.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.hermes.domain.enums.AccountTypeEnum
  8 +import cn.fw.hermes.sdk.v2.enums.AccountType
  9 +import cn.fw.hermes.sdk.v2.para.AccountV2Condition
  10 +import cn.fw.hermes.sdk.v2.service.IAccountV2Service
  11 +import cn.fw.hermes.service.biz.AccountBizService
  12 +import org.springframework.validation.annotation.Validated
  13 +import org.springframework.web.bind.annotation.*
  14 +
  15 +/**
  16 + * 账号服务
  17 + *
  18 + * @author : kurisu
  19 + * @version : 2.0
  20 + * @desc : 账号服务
  21 + * @date : 2023-07-20 16:51
  22 + */
  23 +@Validated
  24 +@RestController
  25 +@RequestMapping("/api/hermes/account")
  26 +class AccountV2ServiceImpl(private val accountBizService: AccountBizService) : IAccountV2Service {
  27 + @PostMapping("/register")
  28 + @ControllerMethod("用户注册")
  29 + override fun register(@RequestBody @Validated condition: AccountV2Condition): Message<Boolean> {
  30 + val userId = condition.userId
  31 + val userName = condition.userName
  32 + val accountType = AccountType.ofValue(condition.accountType)
  33 + if (AccountType.B_USER == accountType) {
  34 + accountBizService.queryStaffTopic(userId, userName, "")
  35 + } else {
  36 + accountBizService.queryUserTopic(userId, userName, "")
  37 + }
  38 + return success(true)
  39 + }
  40 +
  41 + @GetMapping("/getIdentifier")
  42 + @ControllerMethod("获取用户标识码")
  43 + override fun getIdentifier(@RequestParam("userId") userId: Long, @RequestParam(value = "userType", defaultValue = "1", required = false) userType: Int): Message<String> {
  44 + val accountType = AccountType.ofValue(userType)
  45 + BV.notNull(accountType) { "账户类型不正确" }
  46 + val type = if (AccountType.B_USER == accountType) AccountTypeEnum.B_USER else AccountTypeEnum.C_USER
  47 + val identifier = accountBizService.getUserIdentifier(userId, type)
  48 + return success(identifier)
  49 + }
  50 +
  51 + @GetMapping("/kick-out")
  52 + @ControllerMethod("踢下线")
  53 + override fun kick(@RequestParam("userId") userId: Long, @RequestParam("userType") userType: Int): Message<Void> {
  54 + val accountType = AccountType.ofValue(userType)
  55 + BV.notNull(accountType) { "账户类型不正确" }
  56 + accountBizService.kick(userId, AccountType.B_USER == accountType)
  57 + return success()
  58 + }
  59 +}
... ...
fw-hermes-server/src/main/kotlin/cn/fw/hermes/controller/api/MessageV2ServiceImpl.kt 0 → 100644
  1 +package cn.fw.hermes.controller.api.v2
  2 +
  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.hermes.sdk.v2.para.AppUpdateMsgCondition
  7 +import cn.fw.hermes.sdk.v2.para.MsgV2Condition
  8 +import cn.fw.hermes.sdk.v2.result.MessageV2Result
  9 +import cn.fw.hermes.sdk.v2.service.IMessageV2Service
  10 +import cn.fw.hermes.service.biz.AppUpdateBizService
  11 +import cn.fw.hermes.service.biz.MessageQueryerService
  12 +import cn.fw.hermes.service.biz.MsgPrepareBizService
  13 +import org.springframework.validation.annotation.Validated
  14 +import org.springframework.web.bind.annotation.*
  15 +
  16 +/**
  17 + * 消息处理服务
  18 + *
  19 + * @author : kurisu
  20 + * @version : 2.0
  21 + * @desc : 消息处理服务
  22 + * @date : 2023-07-22 15:05
  23 + */
  24 +@RestController
  25 +@Validated
  26 +@RequestMapping("/api/hermes/message")
  27 +class MessageV2ServiceImpl(
  28 + private val messageQueryerService: MessageQueryerService,
  29 + private val msgPrepareBizService: MsgPrepareBizService,
  30 + private val appUpdateBizService: AppUpdateBizService
  31 +) : IMessageV2Service {
  32 + @PostMapping("/send/async")
  33 + @ControllerMethod("异步发送消息")
  34 + override fun asyncSendMsg(@RequestBody @Validated condition: MsgV2Condition): Message<Long> {
  35 + return success(msgPrepareBizService.asyncSendMsg(condition))
  36 + }
  37 +
  38 + @PostMapping("/send/sync")
  39 + @ControllerMethod("同步发送消息")
  40 + override fun sendMsg(@RequestBody @Validated condition: MsgV2Condition): Message<MessageV2Result> {
  41 + return success(msgPrepareBizService.sendMsg(condition))
  42 + }
  43 +
  44 + @GetMapping("/result")
  45 + @ControllerMethod("查询消息结果")
  46 + override fun queryMsgResult(@RequestParam("messageId") messageId: Long): Message<MessageV2Result> {
  47 + return success(messageQueryerService.queryResultById(messageId))
  48 + }
  49 +
  50 + @ControllerMethod("发送应用更新消息")
  51 + @PostMapping("/send/update_msg")
  52 + override fun sendUpdateMsg(@RequestBody @Validated condition: AppUpdateMsgCondition): Message<Void> {
  53 + appUpdateBizService.sendUpdateMsg(condition)
  54 + return success()
  55 + }
  56 +}
... ...