正在显示
4 个修改的文件
包含
37 行增加
和
59 行删除
@@ -5,7 +5,6 @@ import com.sunyo.wlpt.message.bus.service.domain.BusQueue; | @@ -5,7 +5,6 @@ import com.sunyo.wlpt.message.bus.service.domain.BusQueue; | ||
5 | import com.sunyo.wlpt.message.bus.service.response.ResultJson; | 5 | import com.sunyo.wlpt.message.bus.service.response.ResultJson; |
6 | import com.sunyo.wlpt.message.bus.service.service.BusQueueService; | 6 | import com.sunyo.wlpt.message.bus.service.service.BusQueueService; |
7 | import com.sunyo.wlpt.message.bus.service.service.UserInfoService; | 7 | import com.sunyo.wlpt.message.bus.service.service.UserInfoService; |
8 | -import com.sunyo.wlpt.message.bus.service.utils.IdUtils; | ||
9 | import org.springframework.web.bind.annotation.*; | 8 | import org.springframework.web.bind.annotation.*; |
10 | 9 | ||
11 | import javax.annotation.Resource; | 10 | import javax.annotation.Resource; |
@@ -117,8 +116,7 @@ public class BusQueueController { | @@ -117,8 +116,7 @@ public class BusQueueController { | ||
117 | public ResultJson insertBusQueue(@RequestBody BusQueue busQueue) throws IOException, TimeoutException | 116 | public ResultJson insertBusQueue(@RequestBody BusQueue busQueue) throws IOException, TimeoutException |
118 | { | 117 | { |
119 | String message = validateBusQueue(busQueue); | 118 | String message = validateBusQueue(busQueue); |
120 | - // 设置id | ||
121 | - busQueue.setId(IdUtils.generateId()); | 119 | + |
122 | //验证通过 | 120 | //验证通过 |
123 | return message == null | 121 | return message == null |
124 | ? busQueueService.insertSelective(busQueue) | 122 | ? busQueueService.insertSelective(busQueue) |
1 | package com.sunyo.wlpt.message.bus.service.mapper; | 1 | package com.sunyo.wlpt.message.bus.service.mapper; |
2 | 2 | ||
3 | +import com.sunyo.wlpt.message.bus.service.domain.BusQueue; | ||
3 | import com.sunyo.wlpt.message.bus.service.domain.UserInfo; | 4 | import com.sunyo.wlpt.message.bus.service.domain.UserInfo; |
4 | -import org.apache.ibatis.annotations.Mapper;import org.apache.ibatis.annotations.Param;import java.util.List; | 5 | +import org.apache.ibatis.annotations.Mapper; |
6 | +import org.apache.ibatis.annotations.Param; | ||
7 | + | ||
8 | +import java.util.List; | ||
5 | 9 | ||
6 | /** | 10 | /** |
7 | * @author 子诚 | 11 | * @author 子诚 |
@@ -10,6 +14,7 @@ import org.apache.ibatis.annotations.Mapper;import org.apache.ibatis.annotations | @@ -10,6 +14,7 @@ import org.apache.ibatis.annotations.Mapper;import org.apache.ibatis.annotations | ||
10 | */ | 14 | */ |
11 | @Mapper | 15 | @Mapper |
12 | public interface UserInfoMapper { | 16 | public interface UserInfoMapper { |
17 | + | ||
13 | /** | 18 | /** |
14 | * delete by primary key | 19 | * delete by primary key |
15 | * | 20 | * |
@@ -80,4 +85,28 @@ public interface UserInfoMapper { | @@ -80,4 +85,28 @@ public interface UserInfoMapper { | ||
80 | * @return 用户列表 | 85 | * @return 用户列表 |
81 | */ | 86 | */ |
82 | List<UserInfo> selectUserExist(@Param("username") String username); | 87 | List<UserInfo> selectUserExist(@Param("username") String username); |
88 | + | ||
89 | + /** | ||
90 | + * 分页查询用户信息 | ||
91 | + * | ||
92 | + * @param userInfo 用户信息 {@link UserInfo} | ||
93 | + * @return | ||
94 | + */ | ||
95 | + List<UserInfo> selectUserInfoList(UserInfo userInfo); | ||
96 | + | ||
97 | + /** | ||
98 | + * 校验用户信息 | ||
99 | + * | ||
100 | + * @param userInfo 用户信息 {@link UserInfo} | ||
101 | + * @return | ||
102 | + */ | ||
103 | + List<UserInfo> validateUserInfo(UserInfo userInfo); | ||
104 | + | ||
105 | + /** | ||
106 | + * 根据队列中的用户名,虚拟主机名称和虚拟主机id,查询用户关系 | ||
107 | + * | ||
108 | + * @param busQueue {@link BusQueue} | ||
109 | + * @return | ||
110 | + */ | ||
111 | + List<UserInfo> selectByBusQueue(BusQueue busQueue); | ||
83 | } | 112 | } |
@@ -8,6 +8,7 @@ import com.sunyo.wlpt.message.bus.service.mapper.UserInfoMapper; | @@ -8,6 +8,7 @@ import com.sunyo.wlpt.message.bus.service.mapper.UserInfoMapper; | ||
8 | import com.sunyo.wlpt.message.bus.service.rabbit.utils.RabbitUtils; | 8 | import com.sunyo.wlpt.message.bus.service.rabbit.utils.RabbitUtils; |
9 | import com.sunyo.wlpt.message.bus.service.response.ResultJson; | 9 | import com.sunyo.wlpt.message.bus.service.response.ResultJson; |
10 | import com.sunyo.wlpt.message.bus.service.service.BusQueueService; | 10 | import com.sunyo.wlpt.message.bus.service.service.BusQueueService; |
11 | +import com.sunyo.wlpt.message.bus.service.utils.IdUtils; | ||
11 | import io.netty.util.internal.StringUtil; | 12 | import io.netty.util.internal.StringUtil; |
12 | import org.springframework.context.annotation.Lazy; | 13 | import org.springframework.context.annotation.Lazy; |
13 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
@@ -113,6 +114,11 @@ public class BusQueueServiceImpl implements BusQueueService { | @@ -113,6 +114,11 @@ public class BusQueueServiceImpl implements BusQueueService { | ||
113 | if (userInfoMapper.selectUserExist(record.getUsername()).size() == 0) { | 114 | if (userInfoMapper.selectUserExist(record.getUsername()).size() == 0) { |
114 | return new ResultJson<>("400", "该用户信息,不存在"); | 115 | return new ResultJson<>("400", "该用户信息,不存在"); |
115 | } | 116 | } |
117 | + if (userInfoMapper.selectByBusQueue(record).size() == 0) { | ||
118 | + return new ResultJson<>("400", "该用户关系,不存在"); | ||
119 | + } | ||
120 | + // 设置id | ||
121 | + record.setId(IdUtils.generateId()); | ||
116 | rabbitUtils.toCreateQueue(record); | 122 | rabbitUtils.toCreateQueue(record); |
117 | return busQueueMapper.insertSelective(record) > 0 | 123 | return busQueueMapper.insertSelective(record) > 0 |
118 | ? new ResultJson<>("200", "添加消息队列,成功") | 124 | ? new ResultJson<>("200", "添加消息队列,成功") |
1 | -package com.sunyo.wlpt.message.bus.service.utils; | ||
2 | - | ||
3 | -import java.security.MessageDigest; | ||
4 | - | ||
5 | -/** | ||
6 | - * @author 子诚 | ||
7 | - * Description: | ||
8 | - * 时间:2020/8/7 17:33 | ||
9 | - */ | ||
10 | -public class Md5Utils { | ||
11 | - | ||
12 | - /*** | ||
13 | - * MD5加码 生成32位md5码 | ||
14 | - */ | ||
15 | - public static String string2Md5(String inStr) | ||
16 | - { | ||
17 | - MessageDigest md5 = null; | ||
18 | - try { | ||
19 | - md5 = MessageDigest.getInstance("MD5"); | ||
20 | - } catch (Exception e) { | ||
21 | - System.out.println(e.toString()); | ||
22 | - e.printStackTrace(); | ||
23 | - return ""; | ||
24 | - } | ||
25 | - char[] charArray = inStr.toCharArray(); | ||
26 | - byte[] byteArray = new byte[charArray.length]; | ||
27 | - | ||
28 | - for (int i = 0; i < charArray.length; i++) { | ||
29 | - byteArray[i] = (byte) charArray[i]; | ||
30 | - } | ||
31 | - byte[] md5Bytes = md5.digest(byteArray); | ||
32 | - StringBuffer hexValue = new StringBuffer(); | ||
33 | - for (int i = 0; i < md5Bytes.length; i++) { | ||
34 | - int val = ((int) md5Bytes[i]) & 0xff; | ||
35 | - if (val < 16) { | ||
36 | - hexValue.append("0"); | ||
37 | - } | ||
38 | - hexValue.append(Integer.toHexString(val)); | ||
39 | - } | ||
40 | - return hexValue.toString(); | ||
41 | - } | ||
42 | - | ||
43 | - /** | ||
44 | - * 加密解密算法 执行一次加密,两次解密 | ||
45 | - */ | ||
46 | - public static String convertMD5(String inStr) | ||
47 | - { | ||
48 | - char[] a = inStr.toCharArray(); | ||
49 | - for (int i = 0; i < a.length; i++) { | ||
50 | - a[i] = (char) (a[i] ^ 't'); | ||
51 | - } | ||
52 | - String s = new String(a); | ||
53 | - return s; | ||
54 | - } | ||
55 | -} |
-
请 注册 或 登录 后发表评论