正在显示
12 个修改的文件
包含
388 行增加
和
224 行删除
| @@ -105,6 +105,7 @@ public class BusServerController { | @@ -105,6 +105,7 @@ public class BusServerController { | ||
| 105 | * | 105 | * |
| 106 | * @param busServer {@link BusServer} | 106 | * @param busServer {@link BusServer} |
| 107 | * @return {@link ResultJson} | 107 | * @return {@link ResultJson} |
| 108 | + * @throws Exception | ||
| 108 | */ | 109 | */ |
| 109 | @PostMapping("/insert") | 110 | @PostMapping("/insert") |
| 110 | public ResultJson insertBusServer(@RequestBody BusServer busServer) | 111 | public ResultJson insertBusServer(@RequestBody BusServer busServer) |
| @@ -5,12 +5,13 @@ import com.sunyo.wlpt.message.bus.service.domain.VirtualHost; | @@ -5,12 +5,13 @@ import com.sunyo.wlpt.message.bus.service.domain.VirtualHost; | ||
| 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.VirtualHostService; | 6 | import com.sunyo.wlpt.message.bus.service.service.VirtualHostService; |
| 7 | import com.sunyo.wlpt.message.bus.service.utils.IdUtils; | 7 | import com.sunyo.wlpt.message.bus.service.utils.IdUtils; |
| 8 | +import lombok.extern.slf4j.Slf4j; | ||
| 8 | import org.springframework.web.bind.annotation.*; | 9 | import org.springframework.web.bind.annotation.*; |
| 9 | 10 | ||
| 10 | import javax.annotation.Resource; | 11 | import javax.annotation.Resource; |
| 11 | import java.io.IOException; | 12 | import java.io.IOException; |
| 13 | +import java.net.URISyntaxException; | ||
| 12 | import java.util.List; | 14 | import java.util.List; |
| 13 | -import java.util.concurrent.TimeoutException; | ||
| 14 | 15 | ||
| 15 | import static com.sunyo.wlpt.message.bus.service.common.Constant.EXIST_HOST_INFO; | 16 | import static com.sunyo.wlpt.message.bus.service.common.Constant.EXIST_HOST_INFO; |
| 16 | 17 | ||
| @@ -19,6 +20,7 @@ import static com.sunyo.wlpt.message.bus.service.common.Constant.EXIST_HOST_INFO | @@ -19,6 +20,7 @@ import static com.sunyo.wlpt.message.bus.service.common.Constant.EXIST_HOST_INFO | ||
| 19 | * Description:关于MQ虚拟主机信息的控制器 | 20 | * Description:关于MQ虚拟主机信息的控制器 |
| 20 | * 时间:2020/7/1 14:28 | 21 | * 时间:2020/7/1 14:28 |
| 21 | */ | 22 | */ |
| 23 | +@Slf4j | ||
| 22 | @CrossOrigin | 24 | @CrossOrigin |
| 23 | @RequestMapping("bus/host") | 25 | @RequestMapping("bus/host") |
| 24 | @RestController | 26 | @RestController |
| @@ -41,7 +43,8 @@ public class VirtualHostController { | @@ -41,7 +43,8 @@ public class VirtualHostController { | ||
| 41 | @RequestParam(value = "virtualHostName", required = false) String virtualHostName, | 43 | @RequestParam(value = "virtualHostName", required = false) String virtualHostName, |
| 42 | @RequestParam(value = "serverId", required = false) String serverId, | 44 | @RequestParam(value = "serverId", required = false) String serverId, |
| 43 | @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, | 45 | @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, |
| 44 | - @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { | 46 | + @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) |
| 47 | + { | ||
| 45 | // 获取查询参数 | 48 | // 获取查询参数 |
| 46 | VirtualHost virtualHost = VirtualHost.builder().virtualHostName(virtualHostName).serverId(serverId).build(); | 49 | VirtualHost virtualHost = VirtualHost.builder().virtualHostName(virtualHostName).serverId(serverId).build(); |
| 47 | // 分页查询 | 50 | // 分页查询 |
| @@ -58,11 +61,15 @@ public class VirtualHostController { | @@ -58,11 +61,15 @@ public class VirtualHostController { | ||
| 58 | * @return {@link ResultJson} | 61 | * @return {@link ResultJson} |
| 59 | */ | 62 | */ |
| 60 | @DeleteMapping("/delete") | 63 | @DeleteMapping("/delete") |
| 61 | - public ResultJson deleteVirtualHost(@RequestBody VirtualHost virtualHost) throws IOException, TimeoutException | 64 | + public ResultJson deleteVirtualHost(@RequestBody VirtualHost virtualHost) |
| 62 | { | 65 | { |
| 63 | - return virtualHostService.deleteByPrimaryKey(virtualHost.getId()) > 0 | ||
| 64 | - ? new ResultJson<>("200", "删除虚拟主机信息,成功") | ||
| 65 | - : new ResultJson<>("500", "删除虚拟主机信息,失败"); | 66 | + try { |
| 67 | + return virtualHostService.deleteByPrimaryKey(virtualHost.getId()) > 0 | ||
| 68 | + ? new ResultJson<>("200", "删除虚拟主机信息,成功") | ||
| 69 | + : new ResultJson<>("500", "删除虚拟主机信息,失败"); | ||
| 70 | + } catch (IOException | URISyntaxException e) { | ||
| 71 | + return new ResultJson<>("500", "服务器异常,删除虚拟主机信息,失败"); | ||
| 72 | + } | ||
| 66 | } | 73 | } |
| 67 | 74 | ||
| 68 | /** | 75 | /** |
| @@ -72,11 +79,15 @@ public class VirtualHostController { | @@ -72,11 +79,15 @@ public class VirtualHostController { | ||
| 72 | * @return {@link ResultJson} | 79 | * @return {@link ResultJson} |
| 73 | */ | 80 | */ |
| 74 | @GetMapping("/batchRemove") | 81 | @GetMapping("/batchRemove") |
| 75 | - public ResultJson batchRemoveVirtualHost(String ids) throws IOException, TimeoutException | 82 | + public ResultJson batchRemoveVirtualHost(String ids) |
| 76 | { | 83 | { |
| 77 | - return virtualHostService.deleteByPrimaryKey(ids) > 0 | ||
| 78 | - ? new ResultJson<>("200", "批量删除虚拟主机,成功") | ||
| 79 | - : new ResultJson<>("500", "批量删除虚拟主机,失败"); | 84 | + try { |
| 85 | + return virtualHostService.deleteByPrimaryKey(ids) > 0 | ||
| 86 | + ? new ResultJson<>("200", "批量删除虚拟主机,成功") | ||
| 87 | + : new ResultJson<>("500", "批量删除虚拟主机,失败"); | ||
| 88 | + } catch (IOException | URISyntaxException e) { | ||
| 89 | + return new ResultJson<>("500", "服务器异常,批量删除虚拟主机信息,失败"); | ||
| 90 | + } | ||
| 80 | } | 91 | } |
| 81 | 92 | ||
| 82 | /** | 93 | /** |
| @@ -86,7 +97,8 @@ public class VirtualHostController { | @@ -86,7 +97,8 @@ public class VirtualHostController { | ||
| 86 | * @return {@link ResultJson} | 97 | * @return {@link ResultJson} |
| 87 | */ | 98 | */ |
| 88 | @PutMapping("/update") | 99 | @PutMapping("/update") |
| 89 | - public ResultJson updateVirtualHost(@RequestBody VirtualHost virtualHost) { | 100 | + public ResultJson updateVirtualHost(@RequestBody VirtualHost virtualHost) |
| 101 | + { | ||
| 90 | //先验证,修改好的核心信息(虚拟主机名称)是否已存在 | 102 | //先验证,修改好的核心信息(虚拟主机名称)是否已存在 |
| 91 | String message = validateVirtualHost(virtualHost); | 103 | String message = validateVirtualHost(virtualHost); |
| 92 | return message == null | 104 | return message == null |
| @@ -103,16 +115,21 @@ public class VirtualHostController { | @@ -103,16 +115,21 @@ public class VirtualHostController { | ||
| 103 | * @return {@link ResultJson} | 115 | * @return {@link ResultJson} |
| 104 | */ | 116 | */ |
| 105 | @PostMapping("/insert") | 117 | @PostMapping("/insert") |
| 106 | - public ResultJson insertVirtualHost(@RequestBody VirtualHost virtualHost) { | ||
| 107 | - //先验证,增加的虚拟主机的核心信息(虚拟主机名称)是否已存在 | ||
| 108 | - String message = validateVirtualHost(virtualHost); | ||
| 109 | - // 设置id | ||
| 110 | - virtualHost.setId(IdUtils.generateId()); | ||
| 111 | - return message == null | ||
| 112 | - ? virtualHostService.insertSelective(virtualHost) > 0 | ||
| 113 | - ? new ResultJson<>("200", "新增虚拟主机信息,成功") | ||
| 114 | - : new ResultJson<>("500", "新增虚拟主机信息,失败") | ||
| 115 | - : new ResultJson<>("400", message); | 118 | + public ResultJson insertVirtualHost(@RequestBody VirtualHost virtualHost) |
| 119 | + { | ||
| 120 | + | ||
| 121 | + try { | ||
| 122 | + //先验证,增加的虚拟主机的核心信息(虚拟主机名称)是否已存在 | ||
| 123 | + String message = validateVirtualHost(virtualHost); | ||
| 124 | + virtualHost.setId(IdUtils.generateId()); | ||
| 125 | + return message == null | ||
| 126 | + ? virtualHostService.insertSelective(virtualHost) > 0 | ||
| 127 | + ? new ResultJson<>("200", "新增虚拟主机信息,成功") | ||
| 128 | + : new ResultJson<>("500", "新增虚拟主机信息,失败") | ||
| 129 | + : new ResultJson<>("400", message); | ||
| 130 | + } catch (IOException | URISyntaxException e) { | ||
| 131 | + return new ResultJson<>("500", "新增虚拟主机信息失败,请检查服务器配置是否正确!"); | ||
| 132 | + } | ||
| 116 | } | 133 | } |
| 117 | 134 | ||
| 118 | /** | 135 | /** |
| @@ -121,7 +138,8 @@ public class VirtualHostController { | @@ -121,7 +138,8 @@ public class VirtualHostController { | ||
| 121 | * @param virtualHost {@link VirtualHost} | 138 | * @param virtualHost {@link VirtualHost} |
| 122 | * @return 通过,无返回消息 | 139 | * @return 通过,无返回消息 |
| 123 | */ | 140 | */ |
| 124 | - private String validateVirtualHost(VirtualHost virtualHost) { | 141 | + private String validateVirtualHost(VirtualHost virtualHost) |
| 142 | + { | ||
| 125 | if ("".equals(virtualHost.getVirtualHostName()) || virtualHost.getVirtualHostName() == null) { | 143 | if ("".equals(virtualHost.getVirtualHostName()) || virtualHost.getVirtualHostName() == null) { |
| 126 | return "该虚拟主机信息中,没有虚拟主机名称"; | 144 | return "该虚拟主机信息中,没有虚拟主机名称"; |
| 127 | } | 145 | } |
| @@ -13,7 +13,7 @@ import java.util.List; | @@ -13,7 +13,7 @@ import java.util.List; | ||
| 13 | /** | 13 | /** |
| 14 | * @author 子诚 | 14 | * @author 子诚 |
| 15 | * Description:MQ服务器静态信息表 | 15 | * Description:MQ服务器静态信息表 |
| 16 | - * 时间:2020/7/1 10:02 | 16 | + * 时间:2020/8/12 14:07 |
| 17 | */ | 17 | */ |
| 18 | @Data | 18 | @Data |
| 19 | @Builder | 19 | @Builder |
| @@ -21,7 +21,7 @@ import java.util.List; | @@ -21,7 +21,7 @@ import java.util.List; | ||
| 21 | @NoArgsConstructor | 21 | @NoArgsConstructor |
| 22 | public class BusServer implements Serializable { | 22 | public class BusServer implements Serializable { |
| 23 | 23 | ||
| 24 | - private static final long serialVersionUID = 1L; | 24 | + private static final long serialVersionUID = -5662106932282473768L; |
| 25 | 25 | ||
| 26 | /** | 26 | /** |
| 27 | * 服务器ID | 27 | * 服务器ID |
| @@ -44,6 +44,21 @@ public class BusServer implements Serializable { | @@ -44,6 +44,21 @@ public class BusServer implements Serializable { | ||
| 44 | private Integer serverPort; | 44 | private Integer serverPort; |
| 45 | 45 | ||
| 46 | /** | 46 | /** |
| 47 | + * 客户端的端口号 | ||
| 48 | + */ | ||
| 49 | + private Integer clientPort; | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 备用字段,超级用户的用户名 | ||
| 53 | + */ | ||
| 54 | + private String superUsername; | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 备用字段,超级用户的密码 | ||
| 58 | + */ | ||
| 59 | + private String superPassword; | ||
| 60 | + | ||
| 61 | + /** | ||
| 47 | * 服务器相关描述 | 62 | * 服务器相关描述 |
| 48 | */ | 63 | */ |
| 49 | private String description; | 64 | private String description; |
| @@ -75,13 +90,4 @@ public class BusServer implements Serializable { | @@ -75,13 +90,4 @@ public class BusServer implements Serializable { | ||
| 75 | */ | 90 | */ |
| 76 | private String aliasName; | 91 | private String aliasName; |
| 77 | 92 | ||
| 78 | - /** | ||
| 79 | - * 定义有参构造器 | ||
| 80 | - * 封装 BusController 的查询参数 | ||
| 81 | - * | ||
| 82 | - * @param serverName 服务器名称 | ||
| 83 | - */ | ||
| 84 | - public BusServer(String serverName) { | ||
| 85 | - this.serverName = serverName; | ||
| 86 | - } | ||
| 87 | -} | 93 | +} |
| @@ -108,4 +108,8 @@ public class XmlData implements Serializable { | @@ -108,4 +108,8 @@ public class XmlData implements Serializable { | ||
| 108 | private String serverIp; | 108 | private String serverIp; |
| 109 | 109 | ||
| 110 | private Integer serverPort; | 110 | private Integer serverPort; |
| 111 | + | ||
| 112 | + private String superUsername; | ||
| 113 | + | ||
| 114 | + private String superPassword; | ||
| 111 | } | 115 | } |
| 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.BusServer; | 3 | import com.sunyo.wlpt.message.bus.service.domain.BusServer; |
| 4 | -import org.apache.ibatis.annotations.Mapper; | ||
| 5 | -import org.apache.ibatis.annotations.Param; | ||
| 6 | - | ||
| 7 | -import java.util.List; | 4 | +import org.apache.ibatis.annotations.Mapper;import org.apache.ibatis.annotations.Param;import java.util.List; |
| 8 | 5 | ||
| 9 | /** | 6 | /** |
| 10 | * @author 子诚 | 7 | * @author 子诚 |
| 11 | * Description: | 8 | * Description: |
| 12 | - * 时间:2020/7/1 10:02 | 9 | + * 时间:2020/8/12 14:07 |
| 13 | */ | 10 | */ |
| 14 | @Mapper | 11 | @Mapper |
| 15 | public interface BusServerMapper { | 12 | public interface BusServerMapper { |
| 16 | - | ||
| 17 | /** | 13 | /** |
| 18 | - * 删除,根据主键 | 14 | + * delete by primary key |
| 19 | * | 15 | * |
| 20 | * @param id primaryKey | 16 | * @param id primaryKey |
| 21 | * @return deleteCount | 17 | * @return deleteCount |
| @@ -23,7 +19,7 @@ public interface BusServerMapper { | @@ -23,7 +19,7 @@ public interface BusServerMapper { | ||
| 23 | int deleteByPrimaryKey(String id); | 19 | int deleteByPrimaryKey(String id); |
| 24 | 20 | ||
| 25 | /** | 21 | /** |
| 26 | - * 新增 | 22 | + * insert record to table |
| 27 | * | 23 | * |
| 28 | * @param record the record | 24 | * @param record the record |
| 29 | * @return insert count | 25 | * @return insert count |
| @@ -31,7 +27,7 @@ public interface BusServerMapper { | @@ -31,7 +27,7 @@ public interface BusServerMapper { | ||
| 31 | int insert(BusServer record); | 27 | int insert(BusServer record); |
| 32 | 28 | ||
| 33 | /** | 29 | /** |
| 34 | - * 新增,选择性 | 30 | + * insert record to table selective |
| 35 | * | 31 | * |
| 36 | * @param record the record | 32 | * @param record the record |
| 37 | * @return insert count | 33 | * @return insert count |
| @@ -39,7 +35,7 @@ public interface BusServerMapper { | @@ -39,7 +35,7 @@ public interface BusServerMapper { | ||
| 39 | int insertSelective(BusServer record); | 35 | int insertSelective(BusServer record); |
| 40 | 36 | ||
| 41 | /** | 37 | /** |
| 42 | - * 查询,根据主键 | 38 | + * select by primary key |
| 43 | * | 39 | * |
| 44 | * @param id primary key | 40 | * @param id primary key |
| 45 | * @return object by primary key | 41 | * @return object by primary key |
| @@ -47,36 +43,36 @@ public interface BusServerMapper { | @@ -47,36 +43,36 @@ public interface BusServerMapper { | ||
| 47 | BusServer selectByPrimaryKey(String id); | 43 | BusServer selectByPrimaryKey(String id); |
| 48 | 44 | ||
| 49 | /** | 45 | /** |
| 50 | - * 查询,根据服务器名称 | 46 | + * update record selective |
| 51 | * | 47 | * |
| 52 | - * @param serverName 服务器名称 | ||
| 53 | - * @return | 48 | + * @param record the updated record |
| 49 | + * @return update count | ||
| 54 | */ | 50 | */ |
| 55 | - BusServer selectByServerName(String serverName); | 51 | + int updateByPrimaryKeySelective(BusServer record); |
| 56 | 52 | ||
| 57 | /** | 53 | /** |
| 58 | - * 查询服务器列表,选择性 | 54 | + * update record |
| 59 | * | 55 | * |
| 60 | - * @param busServer 服务器以及参数 | ||
| 61 | - * @return 服务器列表 | 56 | + * @param record the updated record |
| 57 | + * @return update count | ||
| 62 | */ | 58 | */ |
| 63 | - List<BusServer> selectBusServerList(BusServer busServer); | 59 | + int updateByPrimaryKey(BusServer record); |
| 64 | 60 | ||
| 65 | /** | 61 | /** |
| 66 | - * 更新,选择性,根据主键 | 62 | + * 查询,根据服务器名称 |
| 67 | * | 63 | * |
| 68 | - * @param record the updated record | ||
| 69 | - * @return update count | 64 | + * @param serverName 服务器名称 |
| 65 | + * @return | ||
| 70 | */ | 66 | */ |
| 71 | - int updateByPrimaryKeySelective(BusServer record); | 67 | + BusServer selectByServerName(String serverName); |
| 72 | 68 | ||
| 73 | /** | 69 | /** |
| 74 | - * 更新,根据主键 | 70 | + * 查询服务器列表,选择性 |
| 75 | * | 71 | * |
| 76 | - * @param record the updated record | ||
| 77 | - * @return update count | 72 | + * @param busServer 服务器以及参数 |
| 73 | + * @return 服务器列表 | ||
| 78 | */ | 74 | */ |
| 79 | - int updateByPrimaryKey(BusServer record); | 75 | + List<BusServer> selectBusServerList(BusServer busServer); |
| 80 | 76 | ||
| 81 | /** | 77 | /** |
| 82 | * 先校验该服务器名称是否存在 | 78 | * 先校验该服务器名称是否存在 |
| @@ -124,4 +120,4 @@ public interface BusServerMapper { | @@ -124,4 +120,4 @@ public interface BusServerMapper { | ||
| 124 | * @return List<BusServer> | 120 | * @return List<BusServer> |
| 125 | */ | 121 | */ |
| 126 | List<BusServer> selectServerExist(@Param("serverName") String serverName); | 122 | List<BusServer> selectServerExist(@Param("serverName") String serverName); |
| 127 | -} | 123 | +} |
| @@ -35,6 +35,7 @@ public interface BusServerService { | @@ -35,6 +35,7 @@ public interface BusServerService { | ||
| 35 | * | 35 | * |
| 36 | * @param record the record | 36 | * @param record the record |
| 37 | * @return insert count | 37 | * @return insert count |
| 38 | + * @throws Exception | ||
| 38 | */ | 39 | */ |
| 39 | int insertSelective(BusServer record); | 40 | int insertSelective(BusServer record); |
| 40 | 41 | ||
| @@ -127,3 +128,4 @@ public interface BusServerService { | @@ -127,3 +128,4 @@ public interface BusServerService { | ||
| 127 | */ | 128 | */ |
| 128 | List<BusServer> selectServerExist(String serverName); | 129 | List<BusServer> selectServerExist(String serverName); |
| 129 | } | 130 | } |
| 131 | + |
| @@ -4,8 +4,8 @@ import com.github.pagehelper.PageInfo; | @@ -4,8 +4,8 @@ import com.github.pagehelper.PageInfo; | ||
| 4 | import com.sunyo.wlpt.message.bus.service.domain.VirtualHost; | 4 | import com.sunyo.wlpt.message.bus.service.domain.VirtualHost; |
| 5 | 5 | ||
| 6 | import java.io.IOException; | 6 | import java.io.IOException; |
| 7 | +import java.net.URISyntaxException; | ||
| 7 | import java.util.List; | 8 | import java.util.List; |
| 8 | -import java.util.concurrent.TimeoutException; | ||
| 9 | 9 | ||
| 10 | /** | 10 | /** |
| 11 | * @author 子诚 | 11 | * @author 子诚 |
| @@ -20,7 +20,7 @@ public interface VirtualHostService { | @@ -20,7 +20,7 @@ public interface VirtualHostService { | ||
| 20 | * @param id primaryKey | 20 | * @param id primaryKey |
| 21 | * @return deleteCount | 21 | * @return deleteCount |
| 22 | */ | 22 | */ |
| 23 | - int deleteByPrimaryKey(String id) throws IOException, TimeoutException; | 23 | + int deleteByPrimaryKey(String id) throws IOException, URISyntaxException; |
| 24 | 24 | ||
| 25 | /** | 25 | /** |
| 26 | * 新增 | 26 | * 新增 |
| @@ -36,7 +36,7 @@ public interface VirtualHostService { | @@ -36,7 +36,7 @@ public interface VirtualHostService { | ||
| 36 | * @param record the record | 36 | * @param record the record |
| 37 | * @return insert count | 37 | * @return insert count |
| 38 | */ | 38 | */ |
| 39 | - int insertSelective(VirtualHost record); | 39 | + int insertSelective(VirtualHost record) throws IOException, URISyntaxException; |
| 40 | 40 | ||
| 41 | /** | 41 | /** |
| 42 | * 查询,根据主键 | 42 | * 查询,根据主键 |
| @@ -6,6 +6,7 @@ import com.sunyo.wlpt.message.bus.service.domain.*; | @@ -6,6 +6,7 @@ import com.sunyo.wlpt.message.bus.service.domain.*; | ||
| 6 | import com.sunyo.wlpt.message.bus.service.mapper.BusServerMapper; | 6 | import com.sunyo.wlpt.message.bus.service.mapper.BusServerMapper; |
| 7 | import com.sunyo.wlpt.message.bus.service.rabbit.utils.RabbitUtils; | 7 | import com.sunyo.wlpt.message.bus.service.rabbit.utils.RabbitUtils; |
| 8 | import com.sunyo.wlpt.message.bus.service.service.*; | 8 | import com.sunyo.wlpt.message.bus.service.service.*; |
| 9 | +import com.sunyo.wlpt.message.bus.service.utils.EncryptionUtils; | ||
| 9 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| 10 | import org.springframework.transaction.annotation.Propagation; | 11 | import org.springframework.transaction.annotation.Propagation; |
| 11 | import org.springframework.transaction.annotation.Transactional; | 12 | import org.springframework.transaction.annotation.Transactional; |
| @@ -100,9 +101,12 @@ public class BusServerServiceImpl implements BusServerService { | @@ -100,9 +101,12 @@ public class BusServerServiceImpl implements BusServerService { | ||
| 100 | } | 101 | } |
| 101 | 102 | ||
| 102 | @Override | 103 | @Override |
| 103 | - public int insertSelective(BusServer record) | 104 | + public int insertSelective(BusServer server) |
| 104 | { | 105 | { |
| 105 | - return busServerMapper.insertSelective(record); | 106 | + // 超级用户的密码,设计规则(超级用户名+.+超级用户密码) |
| 107 | + String key = server.getSuperUsername() + "." + server.getSuperPassword(); | ||
| 108 | + server.setSuperPassword(EncryptionUtils.encryptBase64(key)); | ||
| 109 | + return busServerMapper.insertSelective(server); | ||
| 106 | } | 110 | } |
| 107 | 111 | ||
| 108 | @Override | 112 | @Override |
| @@ -194,3 +198,4 @@ public class BusServerServiceImpl implements BusServerService { | @@ -194,3 +198,4 @@ public class BusServerServiceImpl implements BusServerService { | ||
| 194 | } | 198 | } |
| 195 | } | 199 | } |
| 196 | } | 200 | } |
| 201 | + |
| @@ -4,9 +4,10 @@ import com.github.pagehelper.PageHelper; | @@ -4,9 +4,10 @@ import com.github.pagehelper.PageHelper; | ||
| 4 | import com.github.pagehelper.PageInfo; | 4 | import com.github.pagehelper.PageInfo; |
| 5 | import com.sunyo.wlpt.message.bus.service.domain.BusExchange; | 5 | import com.sunyo.wlpt.message.bus.service.domain.BusExchange; |
| 6 | import com.sunyo.wlpt.message.bus.service.domain.BusQueue; | 6 | import com.sunyo.wlpt.message.bus.service.domain.BusQueue; |
| 7 | -import com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding; | 7 | +import com.sunyo.wlpt.message.bus.service.domain.BusServer; |
| 8 | import com.sunyo.wlpt.message.bus.service.domain.VirtualHost; | 8 | import com.sunyo.wlpt.message.bus.service.domain.VirtualHost; |
| 9 | import com.sunyo.wlpt.message.bus.service.mapper.VirtualHostMapper; | 9 | import com.sunyo.wlpt.message.bus.service.mapper.VirtualHostMapper; |
| 10 | +import com.sunyo.wlpt.message.bus.service.rabbit.utils.ClientUtils; | ||
| 10 | import com.sunyo.wlpt.message.bus.service.rabbit.utils.RabbitUtils; | 11 | import com.sunyo.wlpt.message.bus.service.rabbit.utils.RabbitUtils; |
| 11 | import com.sunyo.wlpt.message.bus.service.service.*; | 12 | import com.sunyo.wlpt.message.bus.service.service.*; |
| 12 | import org.springframework.stereotype.Service; | 13 | import org.springframework.stereotype.Service; |
| @@ -15,8 +16,8 @@ import org.springframework.transaction.annotation.Transactional; | @@ -15,8 +16,8 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 15 | 16 | ||
| 16 | import javax.annotation.Resource; | 17 | import javax.annotation.Resource; |
| 17 | import java.io.IOException; | 18 | import java.io.IOException; |
| 19 | +import java.net.URISyntaxException; | ||
| 18 | import java.util.List; | 20 | import java.util.List; |
| 19 | -import java.util.concurrent.TimeoutException; | ||
| 20 | 21 | ||
| 21 | /** | 22 | /** |
| 22 | * @author 子诚 | 23 | * @author 子诚 |
| @@ -30,6 +31,9 @@ public class VirtualHostServiceImpl implements VirtualHostService { | @@ -30,6 +31,9 @@ public class VirtualHostServiceImpl implements VirtualHostService { | ||
| 30 | private VirtualHostMapper virtualHostMapper; | 31 | private VirtualHostMapper virtualHostMapper; |
| 31 | 32 | ||
| 32 | @Resource | 33 | @Resource |
| 34 | + private BusServerService busServerService; | ||
| 35 | + | ||
| 36 | + @Resource | ||
| 33 | private RabbitUtils rabbitUtils; | 37 | private RabbitUtils rabbitUtils; |
| 34 | 38 | ||
| 35 | @Resource | 39 | @Resource |
| @@ -46,7 +50,7 @@ public class VirtualHostServiceImpl implements VirtualHostService { | @@ -46,7 +50,7 @@ public class VirtualHostServiceImpl implements VirtualHostService { | ||
| 46 | 50 | ||
| 47 | @Override | 51 | @Override |
| 48 | @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) | 52 | @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) |
| 49 | - public int deleteByPrimaryKey(String id) throws IOException, TimeoutException | 53 | + public int deleteByPrimaryKey(String id) throws IOException, URISyntaxException |
| 50 | { | 54 | { |
| 51 | // 判断删除的个数,需被删除的个数是否一致 | 55 | // 判断删除的个数,需被删除的个数是否一致 |
| 52 | int index = 0; | 56 | int index = 0; |
| @@ -83,10 +87,18 @@ public class VirtualHostServiceImpl implements VirtualHostService { | @@ -83,10 +87,18 @@ public class VirtualHostServiceImpl implements VirtualHostService { | ||
| 83 | return virtualHostMapper.insert(record); | 87 | return virtualHostMapper.insert(record); |
| 84 | } | 88 | } |
| 85 | 89 | ||
| 90 | + /** | ||
| 91 | + * 创建虚拟主机于MQ服务器 | ||
| 92 | + * <p> | ||
| 93 | + * 存储于数据库 | ||
| 94 | + */ | ||
| 86 | @Override | 95 | @Override |
| 87 | - public int insertSelective(VirtualHost record) | 96 | + public int insertSelective(VirtualHost vHost) throws IOException, URISyntaxException |
| 88 | { | 97 | { |
| 89 | - return virtualHostMapper.insertSelective(record); | 98 | + BusServer busServer = busServerService.selectByPrimaryKey(vHost.getServerId()); |
| 99 | + int num = virtualHostMapper.insertSelective(vHost); | ||
| 100 | + ClientUtils.createVirtualHost(busServer, vHost); | ||
| 101 | + return num; | ||
| 90 | } | 102 | } |
| 91 | 103 | ||
| 92 | @Override | 104 | @Override |
| @@ -152,23 +164,20 @@ public class VirtualHostServiceImpl implements VirtualHostService { | @@ -152,23 +164,20 @@ public class VirtualHostServiceImpl implements VirtualHostService { | ||
| 152 | return virtualHostMapper.deleteByServerId(serverId); | 164 | return virtualHostMapper.deleteByServerId(serverId); |
| 153 | } | 165 | } |
| 154 | 166 | ||
| 155 | - public void virtualHostCascadeDelete(VirtualHost virtualHost) throws IOException, TimeoutException | 167 | + /** |
| 168 | + * 先删除MQ服务器上的虚拟主机,再删除数据库表中的所有相关字段 | ||
| 169 | + */ | ||
| 170 | + public void virtualHostCascadeDelete(VirtualHost virtualHost) throws IOException, URISyntaxException | ||
| 156 | { | 171 | { |
| 172 | + BusServer busServer = busServerService.selectByPrimaryKey(virtualHost.getServerId()); | ||
| 173 | + ClientUtils.deleteVirtualHost(busServer, virtualHost.getVirtualHostName()); | ||
| 174 | + | ||
| 157 | String virtualHostId = virtualHost.getId(); | 175 | String virtualHostId = virtualHost.getId(); |
| 158 | - List<UserMessageBinding> bindings = userMessageBindingService.selectByVirtualHostId(virtualHostId); | ||
| 159 | // 1.1、删除数据库中的绑定关系 | 176 | // 1.1、删除数据库中的绑定关系 |
| 160 | userMessageBindingService.deleteByVirtualHostId(virtualHostId); | 177 | userMessageBindingService.deleteByVirtualHostId(virtualHostId); |
| 161 | - for (UserMessageBinding userMessageBinding : bindings) { | ||
| 162 | - // 1.2、解除MQ服务器上的绑定关系 | ||
| 163 | - rabbitUtils.toRemoveBinding(userMessageBinding); | ||
| 164 | - } | ||
| 165 | List<BusQueue> queues = busQueueService.selectByVirtualHostId(virtualHostId); | 178 | List<BusQueue> queues = busQueueService.selectByVirtualHostId(virtualHostId); |
| 166 | // 2.1、删除数据库中对应的队列 | 179 | // 2.1、删除数据库中对应的队列 |
| 167 | busQueueService.deleteByVirtualHostId(virtualHostId); | 180 | busQueueService.deleteByVirtualHostId(virtualHostId); |
| 168 | - for (BusQueue queue : queues) { | ||
| 169 | - // 2.2、删除MQ服务器上的队列 | ||
| 170 | - rabbitUtils.toRemoveQueue(queue); | ||
| 171 | - } | ||
| 172 | List<BusExchange> exchanges = busExchangeService.selectByVirtualHostId(virtualHostId); | 181 | List<BusExchange> exchanges = busExchangeService.selectByVirtualHostId(virtualHostId); |
| 173 | // 3.1 根据虚拟主机id,删除交换机 | 182 | // 3.1 根据虚拟主机id,删除交换机 |
| 174 | busExchangeService.deleteByVirtualHostId(virtualHostId); | 183 | busExchangeService.deleteByVirtualHostId(virtualHostId); |
| @@ -176,8 +185,6 @@ public class VirtualHostServiceImpl implements VirtualHostService { | @@ -176,8 +185,6 @@ public class VirtualHostServiceImpl implements VirtualHostService { | ||
| 176 | String exchangeId = busExchange.getId(); | 185 | String exchangeId = busExchange.getId(); |
| 177 | // 4.1、删除数据库中对应的路由键 | 186 | // 4.1、删除数据库中对应的路由键 |
| 178 | routingKeyService.deleteByExchangeId(exchangeId); | 187 | routingKeyService.deleteByExchangeId(exchangeId); |
| 179 | - // 3.2 在MQ服务器上删除该交换机 | ||
| 180 | - rabbitUtils.toRemoveExchange(busExchange); | ||
| 181 | } | 188 | } |
| 182 | } | 189 | } |
| 183 | } | 190 | } |
| 1 | +package com.sunyo.wlpt.message.bus.service.utils; | ||
| 2 | + | ||
| 3 | +import org.springframework.util.DigestUtils; | ||
| 4 | +import sun.misc.BASE64Decoder; | ||
| 5 | +import sun.misc.BASE64Encoder; | ||
| 6 | + | ||
| 7 | +import java.io.IOException; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * @author 子诚 | ||
| 11 | + * Description:各种常用的加密与解密 | ||
| 12 | + * 时间:2020/8/12 15:22 | ||
| 13 | + */ | ||
| 14 | +public class EncryptionUtils { | ||
| 15 | + /** | ||
| 16 | + * Base64加密,重载 | ||
| 17 | + * | ||
| 18 | + * @param key 需要Base64加密的属性 | ||
| 19 | + * @return | ||
| 20 | + */ | ||
| 21 | + public static String encryptBase64(byte[] key) | ||
| 22 | + { | ||
| 23 | + return (new BASE64Encoder()).encodeBuffer(key); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * Base64加密,重载 | ||
| 28 | + * | ||
| 29 | + * @param key 需要Base64加密的属性 | ||
| 30 | + * @return | ||
| 31 | + */ | ||
| 32 | + public static String encryptBase64(String key) | ||
| 33 | + { | ||
| 34 | + byte[] newKey = key.getBytes(); | ||
| 35 | + return (new BASE64Encoder()).encodeBuffer(newKey); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * Base64解密,重载 | ||
| 40 | + * | ||
| 41 | + * @param key 需要Base64解密的属性 | ||
| 42 | + * @return | ||
| 43 | + * @throws IOException | ||
| 44 | + */ | ||
| 45 | + public static byte[] decryptBase(String key) throws IOException | ||
| 46 | + { | ||
| 47 | + return (new BASE64Decoder()).decodeBuffer(key); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * Base64解密,重载 | ||
| 52 | + * | ||
| 53 | + * @param key 需要Base64解密的属性 | ||
| 54 | + * @return | ||
| 55 | + * @throws Exception | ||
| 56 | + */ | ||
| 57 | + public static String decryptBase64(String key) throws IOException | ||
| 58 | + { | ||
| 59 | + byte[] bytes = (new BASE64Decoder()).decodeBuffer(key); | ||
| 60 | + if (bytes == null) { | ||
| 61 | + return null; | ||
| 62 | + } | ||
| 63 | + String str = new String(bytes); | ||
| 64 | + return str; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * MD5加密 | ||
| 69 | + * | ||
| 70 | + * @param key 需要MD5加密的属性 | ||
| 71 | + * @return | ||
| 72 | + */ | ||
| 73 | + private static String encryptionKey(String key) | ||
| 74 | + { | ||
| 75 | + return DigestUtils.md5DigestAsHex(key.getBytes()); | ||
| 76 | + } | ||
| 77 | +} |
| @@ -147,6 +147,11 @@ public class XmlUtils { | @@ -147,6 +147,11 @@ public class XmlUtils { | ||
| 147 | xmlData.setServerPort(serverList.get(0).getServerPort()); | 147 | xmlData.setServerPort(serverList.get(0).getServerPort()); |
| 148 | // 获取服务器port | 148 | // 获取服务器port |
| 149 | xmlData.setServerIp(serverList.get(0).getServerIp()); | 149 | xmlData.setServerIp(serverList.get(0).getServerIp()); |
| 150 | + // 获取超级用户名称 | ||
| 151 | + xmlData.setSuperUsername(serverList.get(0).getSuperUsername()); | ||
| 152 | + // 获取超级用户密码 | ||
| 153 | + xmlData.setSuperPassword(serverList.get(0).getSuperPassword()); | ||
| 154 | + | ||
| 150 | ResultJson<XmlData> result = new ResultJson<>("200", "通过格式与数据校验", xmlData); | 155 | ResultJson<XmlData> result = new ResultJson<>("200", "通过格式与数据校验", xmlData); |
| 151 | 156 | ||
| 152 | return result; | 157 | return result; |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | <mapper namespace="com.sunyo.wlpt.message.bus.service.mapper.BusServerMapper"> | 3 | <mapper namespace="com.sunyo.wlpt.message.bus.service.mapper.BusServerMapper"> |
| 4 | - <cache-ref namespace="com.sunyo.wlpt.message.bus.service.mapper.VirtualHostMapper"/> | ||
| 5 | <resultMap id="BaseResultMap" type="com.sunyo.wlpt.message.bus.service.domain.BusServer"> | 4 | <resultMap id="BaseResultMap" type="com.sunyo.wlpt.message.bus.service.domain.BusServer"> |
| 6 | <!--@mbg.generated--> | 5 | <!--@mbg.generated--> |
| 7 | <!--@Table bus_server--> | 6 | <!--@Table bus_server--> |
| 8 | <id column="id" jdbcType="VARCHAR" property="id"/> | 7 | <id column="id" jdbcType="VARCHAR" property="id"/> |
| 9 | - <result column="server_name" jdbcType="VARCHAR" property="serverName"/> | ||
| 10 | - <result column="server_name" jdbcType="VARCHAR" property="aliasName"/> | ||
| 11 | - <result column="server_ip" jdbcType="VARCHAR" property="serverIp"/> | ||
| 12 | - <result column="server_port" jdbcType="INTEGER" property="serverPort"/> | ||
| 13 | - <result column="description" jdbcType="VARCHAR" property="description"/> | ||
| 14 | - <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/> | ||
| 15 | - <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/> | 8 | + <result column="server_name" jdbcType="VARCHAR" property="serverName"/> |
| 9 | + <result column="server_name" jdbcType="VARCHAR" property="aliasName"/> | ||
| 10 | + <result column="server_ip" jdbcType="VARCHAR" property="serverIp"/> | ||
| 11 | + <result column="server_port" jdbcType="INTEGER" property="serverPort"/> | ||
| 12 | + <result column="client_port" jdbcType="INTEGER" property="clientPort"/> | ||
| 13 | + <result column="super_username" jdbcType="VARCHAR" property="superUsername"/> | ||
| 14 | + <result column="super_password" jdbcType="VARCHAR" property="superPassword"/> | ||
| 15 | + <result column="description" jdbcType="VARCHAR" property="description"/> | ||
| 16 | + <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/> | ||
| 17 | + <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/> | ||
| 16 | </resultMap> | 18 | </resultMap> |
| 19 | + <sql id="Base_Column_List"> | ||
| 20 | + <!--@mbg.generated--> | ||
| 21 | + id, `server_name`, server_ip, server_port, client_port, super_username, super_password, | ||
| 22 | + description, gmt_create, gmt_modified | ||
| 23 | + </sql> | ||
| 24 | + <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> | ||
| 25 | + <!--@mbg.generated--> | ||
| 26 | + select | ||
| 27 | + <include refid="Base_Column_List"/> | ||
| 28 | + from bus_server | ||
| 29 | + where id = #{id,jdbcType=VARCHAR} | ||
| 30 | + </select> | ||
| 31 | + <delete id="deleteByPrimaryKey" parameterType="java.lang.String"> | ||
| 32 | + <!--@mbg.generated--> | ||
| 33 | + delete | ||
| 34 | + from bus_server | ||
| 35 | + where id = #{id,jdbcType=VARCHAR} | ||
| 36 | + </delete> | ||
| 37 | + <insert id="insert" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"> | ||
| 38 | + <!--@mbg.generated--> | ||
| 39 | + insert into bus_server (id, `server_name`, server_ip, | ||
| 40 | + server_port, client_port, super_username, | ||
| 41 | + super_password, description, gmt_create, | ||
| 42 | + gmt_modified) | ||
| 43 | + values (#{id,jdbcType=VARCHAR}, #{serverName,jdbcType=VARCHAR}, #{serverIp,jdbcType=VARCHAR}, | ||
| 44 | + #{serverPort,jdbcType=INTEGER}, #{clientPort,jdbcType=INTEGER}, #{superUsername,jdbcType=VARCHAR}, | ||
| 45 | + #{superPassword,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{gmtCreate,jdbcType=TIMESTAMP}, | ||
| 46 | + #{gmtModified,jdbcType=TIMESTAMP}) | ||
| 47 | + </insert> | ||
| 48 | + <insert id="insertSelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"> | ||
| 49 | + <!--@mbg.generated--> | ||
| 50 | + insert into bus_server | ||
| 51 | + <trim prefix="(" suffix=")" suffixOverrides=","> | ||
| 52 | + <if test="id != null"> | ||
| 53 | + id, | ||
| 54 | + </if> | ||
| 55 | + <if test="serverName != null"> | ||
| 56 | + `server_name`, | ||
| 57 | + </if> | ||
| 58 | + <if test="serverIp != null"> | ||
| 59 | + server_ip, | ||
| 60 | + </if> | ||
| 61 | + <if test="serverPort != null"> | ||
| 62 | + server_port, | ||
| 63 | + </if> | ||
| 64 | + <if test="clientPort != null"> | ||
| 65 | + client_port, | ||
| 66 | + </if> | ||
| 67 | + <if test="superUsername != null"> | ||
| 68 | + super_username, | ||
| 69 | + </if> | ||
| 70 | + <if test="superPassword != null"> | ||
| 71 | + super_password, | ||
| 72 | + </if> | ||
| 73 | + <if test="description != null"> | ||
| 74 | + description, | ||
| 75 | + </if> | ||
| 76 | + <if test="gmtCreate != null"> | ||
| 77 | + gmt_create, | ||
| 78 | + </if> | ||
| 79 | + <if test="gmtModified != null"> | ||
| 80 | + gmt_modified, | ||
| 81 | + </if> | ||
| 82 | + </trim> | ||
| 83 | + <trim prefix="values (" suffix=")" suffixOverrides=","> | ||
| 84 | + <if test="id != null"> | ||
| 85 | + #{id,jdbcType=VARCHAR}, | ||
| 86 | + </if> | ||
| 87 | + <if test="serverName != null"> | ||
| 88 | + #{serverName,jdbcType=VARCHAR}, | ||
| 89 | + </if> | ||
| 90 | + <if test="serverIp != null"> | ||
| 91 | + #{serverIp,jdbcType=VARCHAR}, | ||
| 92 | + </if> | ||
| 93 | + <if test="serverPort != null"> | ||
| 94 | + #{serverPort,jdbcType=INTEGER}, | ||
| 95 | + </if> | ||
| 96 | + <if test="clientPort != null"> | ||
| 97 | + #{clientPort,jdbcType=INTEGER}, | ||
| 98 | + </if> | ||
| 99 | + <if test="superUsername != null"> | ||
| 100 | + #{superUsername,jdbcType=VARCHAR}, | ||
| 101 | + </if> | ||
| 102 | + <if test="superPassword != null"> | ||
| 103 | + #{superPassword,jdbcType=VARCHAR}, | ||
| 104 | + </if> | ||
| 105 | + <if test="description != null"> | ||
| 106 | + #{description,jdbcType=VARCHAR}, | ||
| 107 | + </if> | ||
| 108 | + <if test="gmtCreate != null"> | ||
| 109 | + #{gmtCreate,jdbcType=TIMESTAMP}, | ||
| 110 | + </if> | ||
| 111 | + <if test="gmtModified != null"> | ||
| 112 | + #{gmtModified,jdbcType=TIMESTAMP}, | ||
| 113 | + </if> | ||
| 114 | + </trim> | ||
| 115 | + </insert> | ||
| 116 | + <update id="updateByPrimaryKeySelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"> | ||
| 117 | + <!--@mbg.generated--> | ||
| 118 | + update bus_server | ||
| 119 | + <set> | ||
| 120 | + <if test="serverName != null"> | ||
| 121 | + `server_name` = #{serverName,jdbcType=VARCHAR}, | ||
| 122 | + </if> | ||
| 123 | + <if test="serverIp != null"> | ||
| 124 | + server_ip = #{serverIp,jdbcType=VARCHAR}, | ||
| 125 | + </if> | ||
| 126 | + <if test="serverPort != null"> | ||
| 127 | + server_port = #{serverPort,jdbcType=INTEGER}, | ||
| 128 | + </if> | ||
| 129 | + <if test="clientPort != null"> | ||
| 130 | + client_port = #{clientPort,jdbcType=INTEGER}, | ||
| 131 | + </if> | ||
| 132 | + <if test="superUsername != null"> | ||
| 133 | + super_username = #{superUsername,jdbcType=VARCHAR}, | ||
| 134 | + </if> | ||
| 135 | + <if test="superPassword != null"> | ||
| 136 | + super_password = #{superPassword,jdbcType=VARCHAR}, | ||
| 137 | + </if> | ||
| 138 | + <if test="description != null"> | ||
| 139 | + description = #{description,jdbcType=VARCHAR}, | ||
| 140 | + </if> | ||
| 141 | + <if test="gmtCreate != null"> | ||
| 142 | + gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, | ||
| 143 | + </if> | ||
| 144 | + <if test="gmtModified != null"> | ||
| 145 | + gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, | ||
| 146 | + </if> | ||
| 147 | + </set> | ||
| 148 | + where id = #{id,jdbcType=VARCHAR} | ||
| 149 | + </update> | ||
| 150 | + <update id="updateByPrimaryKey" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"> | ||
| 151 | + <!--@mbg.generated--> | ||
| 152 | + update bus_server | ||
| 153 | + set `server_name` = #{serverName,jdbcType=VARCHAR}, | ||
| 154 | + server_ip = #{serverIp,jdbcType=VARCHAR}, | ||
| 155 | + server_port = #{serverPort,jdbcType=INTEGER}, | ||
| 156 | + client_port = #{clientPort,jdbcType=INTEGER}, | ||
| 157 | + super_username = #{superUsername,jdbcType=VARCHAR}, | ||
| 158 | + super_password = #{superPassword,jdbcType=VARCHAR}, | ||
| 159 | + description = #{description,jdbcType=VARCHAR}, | ||
| 160 | + gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, | ||
| 161 | + gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} | ||
| 162 | + where id = #{id,jdbcType=VARCHAR} | ||
| 163 | + </update> | ||
| 164 | + <cache-ref namespace="com.sunyo.wlpt.message.bus.service.mapper.VirtualHostMapper"/> | ||
| 17 | <!-- 该Mapper映射关系的作用,是服务器与虚拟主机的1:n的关系映射 --> | 165 | <!-- 该Mapper映射关系的作用,是服务器与虚拟主机的1:n的关系映射 --> |
| 18 | - <resultMap id="ServerAndVirtualHostMap" type="com.sunyo.wlpt.message.bus.service.domain.BusServer" | ||
| 19 | - extends="BaseResultMap"> | ||
| 20 | - <collection property="aliasList" ofType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost"> | 166 | + <resultMap extends="BaseResultMap" id="ServerAndVirtualHostMap" |
| 167 | + type="com.sunyo.wlpt.message.bus.service.domain.BusServer"> | ||
| 168 | + <collection ofType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost" property="aliasList"> | ||
| 21 | <id column="vid" jdbcType="VARCHAR" property="id"/> | 169 | <id column="vid" jdbcType="VARCHAR" property="id"/> |
| 22 | <result column="virtual_host_name" jdbcType="VARCHAR" property="virtualHostName"/> | 170 | <result column="virtual_host_name" jdbcType="VARCHAR" property="virtualHostName"/> |
| 23 | <result column="virtual_host_name" jdbcType="VARCHAR" property="aliasName"/> | 171 | <result column="virtual_host_name" jdbcType="VARCHAR" property="aliasName"/> |
| 172 | + <result column="server_id" jdbcType="VARCHAR" property="serverId"/> | ||
| 24 | </collection> | 173 | </collection> |
| 25 | </resultMap> | 174 | </resultMap> |
| 26 | - <!-- 该Mapper映射关系的作用,服务器:虚拟主机—>1:n ; 虚拟主机:交换机—>1:n 的关系映射 --> | ||
| 27 | - <resultMap id="ServerAndHostAndExchangeMap" type="com.sunyo.wlpt.message.bus.service.domain.BusServer" | ||
| 28 | - extends="BaseResultMap"> | ||
| 29 | - <collection property="aliasList" ofType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost"> | 175 | + <!-- 该Mapper映射关系的作用,服务器:虚拟主机—>1:n ; 虚拟主机:交换机—>1:n 的关系映射 --> |
| 176 | + <resultMap extends="BaseResultMap" id="ServerAndHostAndExchangeMap" | ||
| 177 | + type="com.sunyo.wlpt.message.bus.service.domain.BusServer"> | ||
| 178 | + <collection ofType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost" property="aliasList"> | ||
| 30 | <id column="vid" jdbcType="VARCHAR" property="id"/> | 179 | <id column="vid" jdbcType="VARCHAR" property="id"/> |
| 31 | <result column="virtual_host_name" jdbcType="VARCHAR" property="virtualHostName"/> | 180 | <result column="virtual_host_name" jdbcType="VARCHAR" property="virtualHostName"/> |
| 32 | <result column="virtual_host_name" jdbcType="VARCHAR" property="aliasName"/> | 181 | <result column="virtual_host_name" jdbcType="VARCHAR" property="aliasName"/> |
| 33 | - <collection property="aliasList" ofType="com.sunyo.wlpt.message.bus.service.domain.BusExchange"> | 182 | + <collection ofType="com.sunyo.wlpt.message.bus.service.domain.BusExchange" property="aliasList"> |
| 34 | <id column="eid" jdbcType="VARCHAR" property="id"/> | 183 | <id column="eid" jdbcType="VARCHAR" property="id"/> |
| 35 | <result column="exchange_name" jdbcType="VARCHAR" property="exchangeName"/> | 184 | <result column="exchange_name" jdbcType="VARCHAR" property="exchangeName"/> |
| 36 | <result column="exchange_name" jdbcType="VARCHAR" property="aliasName"/> | 185 | <result column="exchange_name" jdbcType="VARCHAR" property="aliasName"/> |
| @@ -38,28 +187,6 @@ | @@ -38,28 +187,6 @@ | ||
| 38 | </collection> | 187 | </collection> |
| 39 | </resultMap> | 188 | </resultMap> |
| 40 | 189 | ||
| 41 | - | ||
| 42 | - <sql id="Base_Column_List"> | ||
| 43 | - <!--@mbg.generated--> | ||
| 44 | - id, `server_name`, server_ip, server_port, description, gmt_create, gmt_modified | ||
| 45 | - </sql> | ||
| 46 | - | ||
| 47 | - <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> | ||
| 48 | - <!--@mbg.generated--> | ||
| 49 | - select | ||
| 50 | - <include refid="Base_Column_List"/> | ||
| 51 | - from bus_server | ||
| 52 | - where id = #{id,jdbcType=VARCHAR} | ||
| 53 | - </select> | ||
| 54 | - | ||
| 55 | - <select id="selectByServerName" parameterType="java.lang.String" resultMap="BaseResultMap"> | ||
| 56 | - <!--@mbg.generated--> | ||
| 57 | - select | ||
| 58 | - <include refid="Base_Column_List"/> | ||
| 59 | - from bus_server | ||
| 60 | - where server_name = #{serverName,jdbcType=VARCHAR} | ||
| 61 | - </select> | ||
| 62 | - | ||
| 63 | <!-- 获取服务器列表,可能要级联或者懒加载 --> | 190 | <!-- 获取服务器列表,可能要级联或者懒加载 --> |
| 64 | <select id="getServerList" resultMap="BaseResultMap"> | 191 | <select id="getServerList" resultMap="BaseResultMap"> |
| 65 | select | 192 | select |
| @@ -72,7 +199,8 @@ | @@ -72,7 +199,8 @@ | ||
| 72 | select s.id, | 199 | select s.id, |
| 73 | s.server_name, | 200 | s.server_name, |
| 74 | v.id as vid, | 201 | v.id as vid, |
| 75 | - v.virtual_host_name | 202 | + v.virtual_host_name, |
| 203 | + v.server_id | ||
| 76 | from bus_server as s, | 204 | from bus_server as s, |
| 77 | virtual_host as v | 205 | virtual_host as v |
| 78 | where s.id = v.server_id | 206 | where s.id = v.server_id |
| @@ -92,11 +220,19 @@ | @@ -92,11 +220,19 @@ | ||
| 92 | where s.id = v.server_id | 220 | where s.id = v.server_id |
| 93 | and v.id = e.virtual_host_id | 221 | and v.id = e.virtual_host_id |
| 94 | </select> | 222 | </select> |
| 223 | + | ||
| 95 | <!-- 获取服务器列表,分页 --> | 224 | <!-- 获取服务器列表,分页 --> |
| 96 | <select id="selectBusServerList" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer" | 225 | <select id="selectBusServerList" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer" |
| 97 | resultMap="BaseResultMap"> | 226 | resultMap="BaseResultMap"> |
| 98 | - select | ||
| 99 | - <include refid="Base_Column_List"/> | 227 | + select id, |
| 228 | + `server_name`, | ||
| 229 | + server_ip, | ||
| 230 | + server_port, | ||
| 231 | + client_port, | ||
| 232 | + super_username, | ||
| 233 | + description, | ||
| 234 | + gmt_create, | ||
| 235 | + gmt_modified | ||
| 100 | from bus_server | 236 | from bus_server |
| 101 | <where> | 237 | <where> |
| 102 | <!-- 服务器名称 --> | 238 | <!-- 服务器名称 --> |
| @@ -119,6 +255,7 @@ | @@ -119,6 +255,7 @@ | ||
| 119 | </if> | 255 | </if> |
| 120 | </where> | 256 | </where> |
| 121 | </select> | 257 | </select> |
| 258 | + | ||
| 122 | <!-- 再校验服务器信息(服务器的ip,服务器的port)是否同时存在 --> | 259 | <!-- 再校验服务器信息(服务器的ip,服务器的port)是否同时存在 --> |
| 123 | <select id="validateBusServer" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer" | 260 | <select id="validateBusServer" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer" |
| 124 | resultMap="BaseResultMap"> | 261 | resultMap="BaseResultMap"> |
| @@ -137,107 +274,13 @@ | @@ -137,107 +274,13 @@ | ||
| 137 | </where> | 274 | </where> |
| 138 | </select> | 275 | </select> |
| 139 | 276 | ||
| 140 | - <delete id="deleteByPrimaryKey" parameterType="java.lang.String"> | 277 | + <select id="selectByServerName" parameterType="java.lang.String" resultMap="BaseResultMap"> |
| 141 | <!--@mbg.generated--> | 278 | <!--@mbg.generated--> |
| 142 | - delete | 279 | + select |
| 280 | + <include refid="Base_Column_List"/> | ||
| 143 | from bus_server | 281 | from bus_server |
| 144 | - where id = #{id,jdbcType=VARCHAR} | ||
| 145 | - </delete> | ||
| 146 | - <insert id="insert" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"> | ||
| 147 | - <!--@mbg.generated--> | ||
| 148 | - insert into bus_server (id, `server_name`, server_ip, | ||
| 149 | - server_port, description, gmt_create, | ||
| 150 | - gmt_modified) | ||
| 151 | - values (#{id,jdbcType=VARCHAR}, #{serverName,jdbcType=VARCHAR}, #{serverIp,jdbcType=VARCHAR}, | ||
| 152 | - #{serverPort,jdbcType=INTEGER}, #{description,jdbcType=VARCHAR}, #{gmtCreate,jdbcType=TIMESTAMP}, | ||
| 153 | - #{gmtModified,jdbcType=TIMESTAMP}) | ||
| 154 | - </insert> | ||
| 155 | - <insert id="insertSelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"> | ||
| 156 | - <!--@mbg.generated--> | ||
| 157 | - insert into bus_server | ||
| 158 | - <trim prefix="(" suffix=")" suffixOverrides=","> | ||
| 159 | - <if test="id != null"> | ||
| 160 | - id, | ||
| 161 | - </if> | ||
| 162 | - <if test="serverName != null"> | ||
| 163 | - `server_name`, | ||
| 164 | - </if> | ||
| 165 | - <if test="serverIp != null"> | ||
| 166 | - server_ip, | ||
| 167 | - </if> | ||
| 168 | - <if test="serverPort != null"> | ||
| 169 | - server_port, | ||
| 170 | - </if> | ||
| 171 | - <if test="description != null"> | ||
| 172 | - description, | ||
| 173 | - </if> | ||
| 174 | - <if test="gmtCreate != null"> | ||
| 175 | - gmt_create, | ||
| 176 | - </if> | ||
| 177 | - <if test="gmtModified != null"> | ||
| 178 | - gmt_modified, | ||
| 179 | - </if> | ||
| 180 | - </trim> | ||
| 181 | - <trim prefix="values (" suffix=")" suffixOverrides=","> | ||
| 182 | - <if test="id != null"> | ||
| 183 | - #{id,jdbcType=VARCHAR}, | ||
| 184 | - </if> | ||
| 185 | - <if test="serverName != null"> | ||
| 186 | - #{serverName,jdbcType=VARCHAR}, | ||
| 187 | - </if> | ||
| 188 | - <if test="serverIp != null"> | ||
| 189 | - #{serverIp,jdbcType=VARCHAR}, | ||
| 190 | - </if> | ||
| 191 | - <if test="serverPort != null"> | ||
| 192 | - #{serverPort,jdbcType=INTEGER}, | ||
| 193 | - </if> | ||
| 194 | - <if test="description != null"> | ||
| 195 | - #{description,jdbcType=VARCHAR}, | ||
| 196 | - </if> | ||
| 197 | - <if test="gmtCreate != null"> | ||
| 198 | - #{gmtCreate,jdbcType=TIMESTAMP}, | ||
| 199 | - </if> | ||
| 200 | - <if test="gmtModified != null"> | ||
| 201 | - #{gmtModified,jdbcType=TIMESTAMP}, | ||
| 202 | - </if> | ||
| 203 | - </trim> | ||
| 204 | - </insert> | ||
| 205 | - <update id="updateByPrimaryKeySelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"> | ||
| 206 | - <!--@mbg.generated--> | ||
| 207 | - update bus_server | ||
| 208 | - <set> | ||
| 209 | - <if test="serverName != null"> | ||
| 210 | - `server_name` = #{serverName,jdbcType=VARCHAR}, | ||
| 211 | - </if> | ||
| 212 | - <if test="serverIp != null"> | ||
| 213 | - server_ip = #{serverIp,jdbcType=VARCHAR}, | ||
| 214 | - </if> | ||
| 215 | - <if test="serverPort != null"> | ||
| 216 | - server_port = #{serverPort,jdbcType=INTEGER}, | ||
| 217 | - </if> | ||
| 218 | - <if test="description != null"> | ||
| 219 | - description = #{description,jdbcType=VARCHAR}, | ||
| 220 | - </if> | ||
| 221 | - <if test="gmtCreate != null"> | ||
| 222 | - gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, | ||
| 223 | - </if> | ||
| 224 | - <if test="gmtModified != null"> | ||
| 225 | - gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, | ||
| 226 | - </if> | ||
| 227 | - </set> | ||
| 228 | - where id = #{id,jdbcType=VARCHAR} | ||
| 229 | - </update> | ||
| 230 | - <update id="updateByPrimaryKey" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"> | ||
| 231 | - <!--@mbg.generated--> | ||
| 232 | - update bus_server | ||
| 233 | - set `server_name` = #{serverName,jdbcType=VARCHAR}, | ||
| 234 | - server_ip = #{serverIp,jdbcType=VARCHAR}, | ||
| 235 | - server_port = #{serverPort,jdbcType=INTEGER}, | ||
| 236 | - description = #{description,jdbcType=VARCHAR}, | ||
| 237 | - gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, | ||
| 238 | - gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} | ||
| 239 | - where id = #{id,jdbcType=VARCHAR} | ||
| 240 | - </update> | 282 | + where server_name = #{serverName,jdbcType=VARCHAR} |
| 283 | + </select> | ||
| 241 | 284 | ||
| 242 | <select id="selectServerExist" parameterType="java.lang.String" resultMap="BaseResultMap"> | 285 | <select id="selectServerExist" parameterType="java.lang.String" resultMap="BaseResultMap"> |
| 243 | <!--@mbg.generated--> | 286 | <!--@mbg.generated--> |
| @@ -246,4 +289,4 @@ | @@ -246,4 +289,4 @@ | ||
| 246 | from bus_server | 289 | from bus_server |
| 247 | where server_name = #{serverName,jdbcType=VARCHAR} | 290 | where server_name = #{serverName,jdbcType=VARCHAR} |
| 248 | </select> | 291 | </select> |
| 249 | -</mapper> | 292 | +</mapper> |
-
请 注册 或 登录 后发表评论