正在显示
7 个修改的文件
包含
110 行增加
和
7 行删除
| 1 | +package com.sunyo.wlpt.message.bus.service.controller; | ||
| 2 | + | ||
| 3 | +import com.github.pagehelper.PageInfo; | ||
| 4 | +import com.sunyo.wlpt.message.bus.service.domain.BusServer; | ||
| 5 | +import com.sunyo.wlpt.message.bus.service.response.ResultJson; | ||
| 6 | +import com.sunyo.wlpt.message.bus.service.service.BusServerService; | ||
| 7 | +import org.springframework.web.bind.annotation.*; | ||
| 8 | + | ||
| 9 | +import javax.annotation.Resource; | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * @author 子诚 | ||
| 14 | + * Description: | ||
| 15 | + * 时间:2020/7/6 14:28 | ||
| 16 | + */ | ||
| 17 | +@CrossOrigin | ||
| 18 | +@RequestMapping("bus/cascade") | ||
| 19 | +@RestController | ||
| 20 | +public class CascadeController { | ||
| 21 | + @Resource | ||
| 22 | + private BusServerService busServerService; | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * @return 查询服务器列表 | ||
| 26 | + */ | ||
| 27 | + @GetMapping("/server") | ||
| 28 | + public ResultJson selectList() { | ||
| 29 | + | ||
| 30 | + ResultJson result = new ResultJson(); | ||
| 31 | + List<BusServer> busServers = busServerService.selectAll(); | ||
| 32 | + int num = busServers.size(); | ||
| 33 | + if (num > 0) { | ||
| 34 | + result.setCode("200"); | ||
| 35 | + result.setData(busServers); | ||
| 36 | + result.setMsg("查询服务器列表,成功"); | ||
| 37 | + } else { | ||
| 38 | + result.setCode("500"); | ||
| 39 | + result.setMsg("查询服务器列表,失败"); | ||
| 40 | + } | ||
| 41 | + return result; | ||
| 42 | + } | ||
| 43 | +} |
| @@ -51,4 +51,6 @@ public class VirtualHost implements Serializable { | @@ -51,4 +51,6 @@ public class VirtualHost implements Serializable { | ||
| 51 | */ | 51 | */ |
| 52 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 52 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| 53 | private Date gmtModified; | 53 | private Date gmtModified; |
| 54 | + | ||
| 55 | + private BusServer busServer; | ||
| 54 | } | 56 | } |
| @@ -76,4 +76,11 @@ public interface BusServerMapper { | @@ -76,4 +76,11 @@ public interface BusServerMapper { | ||
| 76 | * @return List<BusServer> | 76 | * @return List<BusServer> |
| 77 | */ | 77 | */ |
| 78 | List<BusServer> validateBusServer(BusServer busServer); | 78 | List<BusServer> validateBusServer(BusServer busServer); |
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * 查询服务器列表 | ||
| 82 | + * | ||
| 83 | + * @return 服务器列表 | ||
| 84 | + */ | ||
| 85 | + List<BusServer> selectAll(); | ||
| 79 | } | 86 | } |
| @@ -77,4 +77,11 @@ public interface BusServerService { | @@ -77,4 +77,11 @@ public interface BusServerService { | ||
| 77 | * @return List<BusServer> | 77 | * @return List<BusServer> |
| 78 | */ | 78 | */ |
| 79 | List<BusServer> validateBusServer(BusServer busServer); | 79 | List<BusServer> validateBusServer(BusServer busServer); |
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * 查询服务器列表 | ||
| 83 | + * | ||
| 84 | + * @return 服务器列表 | ||
| 85 | + */ | ||
| 86 | + List<BusServer> selectAll(); | ||
| 80 | } | 87 | } |
| @@ -93,4 +93,9 @@ public class BusServerServiceImpl implements BusServerService { | @@ -93,4 +93,9 @@ public class BusServerServiceImpl implements BusServerService { | ||
| 93 | public List<BusServer> validateBusServer(BusServer busServer) { | 93 | public List<BusServer> validateBusServer(BusServer busServer) { |
| 94 | return busServerMapper.validateBusServer(busServer); | 94 | return busServerMapper.validateBusServer(busServer); |
| 95 | } | 95 | } |
| 96 | + | ||
| 97 | + @Override | ||
| 98 | + public List<BusServer> selectAll() { | ||
| 99 | + return busServerMapper.selectAll(); | ||
| 100 | + } | ||
| 96 | } | 101 | } |
| @@ -25,7 +25,16 @@ | @@ -25,7 +25,16 @@ | ||
| 25 | where id = #{id,jdbcType=VARCHAR} | 25 | where id = #{id,jdbcType=VARCHAR} |
| 26 | </select> | 26 | </select> |
| 27 | 27 | ||
| 28 | - <!-- 获取服务器列表 --> | 28 | + <!-- 获取服务器列表,可能要级联或者懒加载 --> |
| 29 | + <select id="selectAll" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer" | ||
| 30 | + resultMap="BaseResultMap"> | ||
| 31 | + select | ||
| 32 | + <include refid="Base_Column_List"/> | ||
| 33 | + from bus_server | ||
| 34 | + </select> | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + <!-- 获取服务器列表,分页 --> | ||
| 29 | <select id="selectBusServerList" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer" | 38 | <select id="selectBusServerList" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer" |
| 30 | resultMap="BaseResultMap"> | 39 | resultMap="BaseResultMap"> |
| 31 | select | 40 | select |
| @@ -11,6 +11,16 @@ | @@ -11,6 +11,16 @@ | ||
| 11 | <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/> | 11 | <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/> |
| 12 | <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/> | 12 | <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/> |
| 13 | </resultMap> | 13 | </resultMap> |
| 14 | + <!-- 该Mapper映射关系的作用,是虚拟主机与 --> | ||
| 15 | + <resultMap id="ServerAndHostMap" extends="BaseResultMap" | ||
| 16 | + type="com.sunyo.wlpt.message.bus.service.domain.VirtualHost"> | ||
| 17 | + <association property="busServer" javaType="com.sunyo.wlpt.message.bus.service.domain.BusServer"> | ||
| 18 | + <id column="id" property="id"></id> | ||
| 19 | + <result column="server_name" property="serverName"></result> | ||
| 20 | + </association> | ||
| 21 | + </resultMap> | ||
| 22 | + | ||
| 23 | + | ||
| 14 | <sql id="Base_Column_List"> | 24 | <sql id="Base_Column_List"> |
| 15 | <!--@mbg.generated--> | 25 | <!--@mbg.generated--> |
| 16 | id, virtual_host_name, server_id, description, gmt_create, gmt_modified | 26 | id, virtual_host_name, server_id, description, gmt_create, gmt_modified |
| @@ -22,24 +32,44 @@ | @@ -22,24 +32,44 @@ | ||
| 22 | from virtual_host | 32 | from virtual_host |
| 23 | where id = #{id,jdbcType=VARCHAR} | 33 | where id = #{id,jdbcType=VARCHAR} |
| 24 | </select> | 34 | </select> |
| 25 | - <!-- 查询虚拟主机列表,选择性 --> | 35 | + |
| 26 | <select id="selectVirtualHostList" parameterType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost" | 36 | <select id="selectVirtualHostList" parameterType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost" |
| 27 | - resultMap="BaseResultMap"> | 37 | + resultMap="ServerAndHostMap"> |
| 28 | select | 38 | select |
| 29 | - <include refid="Base_Column_List"/> | ||
| 30 | - from virtual_host | 39 | + v.id, v.virtual_host_name, v.server_id, v.description, v.gmt_create, v.gmt_modified, s.server_name |
| 40 | + from virtual_host as v,bus_server as s | ||
| 31 | <where> | 41 | <where> |
| 32 | <!-- 所属服务器ID --> | 42 | <!-- 所属服务器ID --> |
| 33 | <if test="serverId != null and serverId !=''"> | 43 | <if test="serverId != null and serverId !=''"> |
| 34 | - server_id = #{serverId,jdbcType=VARCHAR} | 44 | + v.server_id = #{serverId,jdbcType=VARCHAR} |
| 35 | </if> | 45 | </if> |
| 36 | <!-- 虚拟主机名称 --> | 46 | <!-- 虚拟主机名称 --> |
| 37 | <if test="virtualHostName != null and virtualHostName !=''"> | 47 | <if test="virtualHostName != null and virtualHostName !=''"> |
| 38 | - virtual_host_name = #{virtualHostName,jdbcType=VARCHAR} | 48 | + and v.virtual_host_name = #{virtualHostName,jdbcType=VARCHAR} |
| 39 | </if> | 49 | </if> |
| 50 | + and v.server_id=s.id | ||
| 40 | </where> | 51 | </where> |
| 41 | </select> | 52 | </select> |
| 42 | 53 | ||
| 54 | + | ||
| 55 | + <!-- 查询虚拟主机列表,选择性 --> | ||
| 56 | + <!-- <select id="selectVirtualHostList" parameterType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost"--> | ||
| 57 | + <!-- resultMap="BaseResultMap">--> | ||
| 58 | + <!-- select--> | ||
| 59 | + <!-- <include refid="Base_Column_List"/>--> | ||
| 60 | + <!-- from virtual_host--> | ||
| 61 | + <!-- <where>--> | ||
| 62 | + <!-- <!– 所属服务器ID –>--> | ||
| 63 | + <!-- <if test="serverId != null and serverId !=''">--> | ||
| 64 | + <!-- server_id = #{serverId,jdbcType=VARCHAR}--> | ||
| 65 | + <!-- </if>--> | ||
| 66 | + <!-- <!– 虚拟主机名称 –>--> | ||
| 67 | + <!-- <if test="virtualHostName != null and virtualHostName !=''">--> | ||
| 68 | + <!-- and virtual_host_name = #{virtualHostName,jdbcType=VARCHAR}--> | ||
| 69 | + <!-- </if>--> | ||
| 70 | + <!-- </where>--> | ||
| 71 | + <!-- </select>--> | ||
| 72 | + | ||
| 43 | <!-- 校验虚拟主机信息是否存在 --> | 73 | <!-- 校验虚拟主机信息是否存在 --> |
| 44 | <select id="validateVirtualHost" parameterType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost" | 74 | <select id="validateVirtualHost" parameterType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost" |
| 45 | resultMap="BaseResultMap"> | 75 | resultMap="BaseResultMap"> |
-
请 注册 或 登录 后发表评论