Compare commits

...

4 Commits

Author SHA1 Message Date
weishao 3cc4b5fde6 删除guacamole 2023-03-28 15:40:54 +08:00
weishao 12746fbc8f 删除guacamole 2023-03-28 15:03:19 +08:00
weishao 7ea4504050 Merge branch 'master' into dev_local_v8 2023-03-28 15:00:20 +08:00
weishao 92fa7efdb1 删除swagger 2023-03-14 18:57:54 +08:00
14 changed files with 13 additions and 725 deletions

53
pom.xml
View File

@ -15,7 +15,6 @@
<description>browser(websocket) -> webssh(ssh) -> pod</description>
<properties>
<swagger2.version>2.6.1</swagger2.version>
<java.version>1.8</java.version>
<jsch.version>0.1.54</jsch.version>
<fastjson.version>1.2.20</fastjson.version>
@ -62,19 +61,6 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger2.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
<dependency>
<groupId>com.jcraft</groupId>
@ -100,51 +86,12 @@
<version>${commons-io.version}</version>
</dependency>
<!-- Main Guacamole library -->
<dependency>
<groupId>org.apache.guacamole</groupId>
<artifactId>guacamole-common</artifactId>
<version>1.4.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.48</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>

View File

@ -1,11 +1,9 @@
package net.educoder.bridge;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@MapperScan("net.educoder.bridge.dao")
@SpringBootApplication()
public class WebsshApplication {

View File

@ -1,62 +0,0 @@
package net.educoder.bridge.common.model;
import lombok.Data;
import java.time.LocalDateTime;
/**
* windows实例信息
*/
@Data
public class WindowsInfo {
private Long id;
private String uniqId;
private String instanceId;
private String userID;
private String templateName;
private String port;
private String vncPort;
private String forwardTableId;
private String forwardEntryId;
private String vncForwardEntryId;
private LocalDateTime autoReleaseTime;
private LocalDateTime createTime;
private LocalDateTime updateTime;
private Integer status;
public WindowsInfo() {
}
public WindowsInfo(String uniqId, String instanceId, String userID, String templateName, String port, String vncPort,
LocalDateTime autoReleaseTime, String forwardTableId, String forwardEntryId, String vncForwardEntryId) {
this.uniqId = uniqId;
this.instanceId = instanceId;
this.userID = userID;
this.templateName = templateName;
this.port = port;
this.vncPort = vncPort;
this.autoReleaseTime = autoReleaseTime;
this.forwardTableId = forwardTableId;
this.forwardEntryId = forwardEntryId;
this.vncForwardEntryId = vncForwardEntryId;
this.createTime = LocalDateTime.now();
this.updateTime = LocalDateTime.now();
this.status = 0;
}
}

View File

@ -1,25 +0,0 @@
package net.educoder.bridge.dao;
import net.educoder.bridge.common.model.WindowsInfo;
import java.util.List;
public interface WindowsInfoMapper {
int deleteByUniqId(String uniqId);
int insertSelective(WindowsInfo record);
WindowsInfo selectByUniqId(String uniqId);
List<WindowsInfo> selectByTpiId(String tpiId);
List<WindowsInfo> selectByUserId(String userID);
int updateByUniqIdSelective(WindowsInfo windowsInfo);
List<String> selectUniqIdByAutoReleaseTime(WindowsInfo windowsInfo);
List<WindowsInfo> selectNotForwardEntryHost();
}

View File

@ -1,23 +1,6 @@
package net.educoder.bridge.git.controller;
import java.io.File;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.educoder.bridge.common.constant.ApiResultCsts;
import net.educoder.bridge.common.model.ApiResult;
import net.educoder.bridge.common.utils.Base64Util;
@ -27,6 +10,14 @@ import net.educoder.bridge.git.model.GitResetRequestParam;
import net.educoder.bridge.git.model.OjRequestParam;
import net.educoder.bridge.git.service.GitService;
import net.educoder.bridge.git.util.CompileUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.File;
/**
* git
@ -132,7 +123,7 @@ public class GitGontroller {
* 删除私密版本库
*/
@RequestMapping(path = "/deleteSecret", method = { RequestMethod.POST })
public ApiResult<?> deleteSecret(@ApiParam(name = "secretRepospace", required = true, value = "私密版本库路径") @RequestParam String secretRepospace) {
public ApiResult<?> deleteSecret( @RequestParam String secretRepospace) {
logger.info("[start]deleteSecret: secretRepospace: {}", secretRepospace);
ApiResult<?> result = new ApiResult<>();
@ -146,7 +137,6 @@ public class GitGontroller {
* tpm版本库已更新同步
*/
@RequestMapping(path = "/resetTpmRepository", method = RequestMethod.POST)
@ApiOperation(value = "tpm版本库已更新同步操作", httpMethod = "POST", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ApiResult<?> reset(@RequestBody GitResetRequestParam param) {
logger.info("[start]tpm版本库已更新同步到tpi版本库 {}", param);
@ -179,7 +169,7 @@ public class GitGontroller {
* 删除私密版本库
*/
@RequestMapping(path = "/clearWorkspace", method = { RequestMethod.POST })
public ApiResult<?> clearWorkspace(@ApiParam(name = "tpiWorkspace", required = true, value = "实训工作空间") @RequestParam String tpiWorkspace) {
public ApiResult<?> clearWorkspace( @RequestParam String tpiWorkspace) {
logger.info("[start]clearWorkspace: tpiWorkspace: {}", tpiWorkspace);
ApiResult<?> result = new ApiResult<>();
@ -237,9 +227,9 @@ public class GitGontroller {
* 导入jupyter tpm文件
*/
@RequestMapping(path = "/updateJupyterTpm", method = { RequestMethod.POST })
public ApiResult<?> updateJupyterTpm(@ApiParam(name = "tpiID", required = true, value = "tpiID") @RequestParam String tpiID,
@ApiParam(name = "content", required = true, value = "文件内容") @RequestParam String content,
@ApiParam(name = "tpiWorkspace", required = true, value = "工作空间") @RequestParam String tpiWorkspace) {
public ApiResult<?> updateJupyterTpm( @RequestParam String tpiID,
@RequestParam String content,
@RequestParam String tpiWorkspace) {
logger.info("[start]updateJupyterTpm tpiID: {}, content: {}, tpiWorkspace", tpiID, content, tpiWorkspace);
ApiResult<?> result = new ApiResult<>();
gitService.updateJupyterTpm(tpiID, content, tpiWorkspace);

View File

@ -1,42 +1,29 @@
package net.educoder.bridge.git.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* git信息
*/
@ApiModel(value = "gitPullRequestParam", description = "git pull接口传参")
public class GitPullRequestParam {
@ApiModelProperty(name = "tpiId", required = true, value = "实训实例的ID")
private String tpiId;
@ApiModelProperty(name = "tpiGitURL", required = true, value = "git项目地址")
private String tpiGitURL;
@ApiModelProperty(name = "tpiWorkspace", required = true, value = "实训工作空间")
private String tpiWorkspace;
@ApiModelProperty(name = "tpiRepoName", required = true, value = "实训项目名")
private String tpiRepoName;
@ApiModelProperty(name = "tpiProtectspace", required = true, value = "实训保护空间")
private String tpiProtectspace;
@ApiModelProperty(name = "tpmScript", required = false, value = "实训评测脚本")
private String tpmScript;
@ApiModelProperty(name = "secretDir", required = false, value = "私密版本库路径")
private String secretDir;
@ApiModelProperty(name = "secretGitUrl", required = false, value = "私密版本库项目地址")
private String secretGitUrl;
@ApiModelProperty(name = "contentModified", required = false, value = "文件是否修改的标志")
private Integer contentModified;
@ApiModelProperty(name = "file", required = false, value = "需要传文件的实训,给出文件存放路径(一个目录)及文件类型")
private String file;
public String getTpiId() {

View File

@ -1,30 +1,20 @@
package net.educoder.bridge.git.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* git信息
*/
@ApiModel(value = "gitResetRequestParam", description = "git reset接口传参")
public class GitResetRequestParam {
@ApiModelProperty(name = "tpiId", required = true, value = "实训实例的ID")
private String tpiId;
@ApiModelProperty(name = "tpiGitURL", required = true, value = "tpi git项目地址")
private String tpiGitURL;
@ApiModelProperty(name = "tpmGitURL", required = true, value = "tpm git项目地址")
private String tpmGitURL;
@ApiModelProperty(name = "tpiWorkspace", required = true, value = "实训工作空间")
private String tpiWorkspace;
@ApiModelProperty(name = "tpiRepoName", required = true, value = "实训项目名")
private String tpiRepoName;
@ApiModelProperty(name = "tpiRepoPath", required = true, value = "实训项目名")
private String tpiRepoPath;
public String getTpiId() {

View File

@ -1,27 +1,18 @@
package net.educoder.bridge.git.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* git信息
*/
@ApiModel(value = "ojRequestParam", description = "oj接口传参")
public class OjRequestParam {
@ApiModelProperty(name = "tpiID", required = true, value = "实训实例的ID")
private String tpiID;
@ApiModelProperty(name = "codeFileName", required = false, value = "代码文件名")
private String codeFileName;
@ApiModelProperty(name = "codeFileContent", required = false, value = "代码文件内容")
private String codeFileContent;
@ApiModelProperty(name = "tpiWorkspace", required = false, value = "工作空间")
private String tpiWorkspace;
@ApiModelProperty(name = "codeFilePath", required = true, value = "代码文件路径")
private String codeFilePath;
public String getTpiID() {

View File

@ -1,8 +1,6 @@
package net.educoder.bridge.webssh.config;
import net.educoder.bridge.webssh.handler.GuacamoleWebSocketTunnelHandler;
import net.educoder.bridge.webssh.handler.RunOnlyHandler;
import net.educoder.bridge.webssh.handler.EducoderGuacamoleWebSocketTunnelHandler;
import net.educoder.bridge.webssh.handler.WebsshHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
@ -21,15 +19,10 @@ public class WebSocketConfig implements WebSocketConfigurer {
@Resource
RunOnlyHandler runOnlyHandler;
@Resource
EducoderGuacamoleWebSocketTunnelHandler EducoderGuacamoleWebSocketTunnelHandler;
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(websshHandler, "/ws").setAllowedOrigins("*");
registry.addHandler(runOnlyHandler, "/log").setAllowedOrigins("*");
registry.addHandler(EducoderGuacamoleWebSocketTunnelHandler,"/tunnel").setAllowedOrigins("*");
}

View File

@ -1,114 +0,0 @@
package net.educoder.bridge.webssh.handler;
import net.educoder.bridge.common.model.WindowsInfo;
import net.educoder.bridge.dao.WindowsInfoMapper;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.net.GuacamoleSocket;
import org.apache.guacamole.net.GuacamoleTunnel;
import org.apache.guacamole.net.InetGuacamoleSocket;
import org.apache.guacamole.net.SimpleGuacamoleTunnel;
import org.apache.guacamole.protocol.ConfiguredGuacamoleSocket;
import org.apache.guacamole.protocol.GuacamoleConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;
import javax.annotation.Resource;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
/**
* rdp协议连接
* @author 悟空
*/
@Component
public class EducoderGuacamoleWebSocketTunnelHandler extends GuacamoleWebSocketTunnelHandler {
@Resource
private WindowsInfoMapper windowsInfoMapper;
private static final String DEFAULT_POSITION = "1";
@Value("${guacamole.server.ip}")
private String guacamoleServer;
@Value("${guacamole.server.port}")
private int guacamoleServerPort;
/**
* Logger for this class.
*/
private final Logger logger = LoggerFactory.getLogger(EducoderGuacamoleWebSocketTunnelHandler.class);
/**
* 通过tpiId及position生成uniqId默认postion为1
*/
public String generateUniqId(String tpiId) {
return generateUniqId(tpiId, DEFAULT_POSITION);
}
public String generateUniqId(String tpiId, String position) {
return tpiId + "-" + NumberUtils.toInt(position, 1);
}
@Override
GuacamoleTunnel createTunnel(WebSocketSession session) throws GuacamoleException {
Properties properties = new Properties();
try {
properties.load(new ByteArrayInputStream(session.getUri().getQuery().replace('&','\n').getBytes()));
} catch (IOException e) {
e.printStackTrace();
}
String tpiID = properties.getProperty("tpiID");
//生成唯一键
String uniqId = generateUniqId(tpiID);
WindowsInfo windowsInfo = getWindowsInfo(uniqId);
// Create our configuration
GuacamoleConfiguration config = new GuacamoleConfiguration();
config.setProtocol("rdp");
config.setParameter("hostname", "39.105.62.120");
config.setParameter("port", windowsInfo.getVncPort());
config.setParameter("username", "Administrator");
config.setParameter("password", "Edu_123123");
config.setParameter("security", "nla");
config.setParameter("ignore-cert", "true");
config.setParameter("width",properties.getProperty("width"));
config.setParameter("height",properties.getProperty("height"));
// Connect to guacd - everything is hard-coded here.
GuacamoleSocket socket = null;
try{
socket = new ConfiguredGuacamoleSocket(new InetGuacamoleSocket(guacamoleServer, guacamoleServerPort),
config);
}catch (Exception e){
e.printStackTrace();
}
// Return a new tunnel which uses the connected socket
return new SimpleGuacamoleTunnel(socket);
}
public WindowsInfo getWindowsInfo(String uniqId) {
return windowsInfoMapper.selectByUniqId(uniqId);
}
@Override
public List<String> getSubProtocols() {
return Collections.singletonList("guacamole");
}
}

View File

@ -1,185 +0,0 @@
package net.educoder.bridge.webssh.handler;
import org.apache.guacamole.GuacamoleClientException;
import org.apache.guacamole.GuacamoleConnectionClosedException;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.io.GuacamoleReader;
import org.apache.guacamole.io.GuacamoleWriter;
import org.apache.guacamole.net.GuacamoleTunnel;
import org.apache.guacamole.protocol.GuacamoleStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.socket.*;
public abstract class GuacamoleWebSocketTunnelHandler implements WebSocketHandler, SubProtocolCapable {
/**
* The default, minimum buffer size for instructions.
*/
private static final int BUFFER_SIZE = 8192;
/**
* Logger for this class.
*/
private final Logger logger = LoggerFactory.getLogger(GuacamoleWebSocketTunnelHandler.class);
/**
* The underlying GuacamoleTunnel. WebSocket reads/writes will be handled as
* reads/writes to this tunnel.
*/
private GuacamoleTunnel tunnel;
/**
* Returns a new tunnel for the given session. How this tunnel is created or
* retrieved is implementation-dependent.
*
* @param session
* The session associated with the active WebSocket connection.
* @return A connected tunnel, or null if no such tunnel exists.
* @throws GuacamoleException
* If an error occurs while retrieving the tunnel, or if access
* to the tunnel is denied.
*/
abstract GuacamoleTunnel createTunnel(WebSocketSession session) throws GuacamoleException;
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
logger.debug("afterConnectionEstablished");
try {
// Get tunnel
tunnel = createTunnel(session);
if (tunnel == null) {
String message = Integer.toString(GuacamoleStatus.RESOURCE_NOT_FOUND.getGuacamoleStatusCode());
afterConnectionClosed(session,
new CloseStatus(GuacamoleStatus.RESOURCE_NOT_FOUND.getWebSocketCode(), message));
return;
}
} catch (GuacamoleException e) {
logger.error("Creation of WebSocket tunnel to guacd failed: {}", e.getMessage());
logger.debug("Error connecting WebSocket tunnel.", e);
String message = Integer.toString(e.getStatus().getGuacamoleStatusCode());
afterConnectionClosed(session, new CloseStatus(e.getStatus().getWebSocketCode(), message));
return;
}
Thread readThread = new Thread() {
@Override
public void run() {
StringBuilder buffer = new StringBuilder(BUFFER_SIZE);
GuacamoleReader reader = tunnel.acquireReader();
char[] readMessage;
try {
try {
// Attempt to read
while ((readMessage = reader.read()) != null) {
// Buffer message
buffer.append(readMessage);
// Flush if we expect to wait or buffer is getting
// full
if (!reader.available() || buffer.length() >= BUFFER_SIZE) {
session.sendMessage(new TextMessage(buffer));
buffer.setLength(0);
}
}
// No more data
String message = Integer.toString(GuacamoleStatus.SUCCESS.getGuacamoleStatusCode());
afterConnectionClosed(session,
new CloseStatus(GuacamoleStatus.SUCCESS.getWebSocketCode(), message));
}
// Catch any thrown guacamole exception and attempt
// to pass within the WebSocket connection, logging
// each error appropriately.
catch (GuacamoleClientException e) {
logger.info("WebSocket connection terminated: {}", e.getMessage());
logger.debug("WebSocket connection terminated due to client error.", e);
String message = Integer.toString(e.getStatus().getGuacamoleStatusCode());
afterConnectionClosed(session, new CloseStatus(e.getStatus().getWebSocketCode(), message));
} catch (GuacamoleConnectionClosedException e) {
logger.debug("Connection to guacd closed.", e);
String message = Integer.toString(GuacamoleStatus.SUCCESS.getGuacamoleStatusCode());
afterConnectionClosed(session,
new CloseStatus(GuacamoleStatus.SUCCESS.getWebSocketCode(), message));
} catch (GuacamoleException e) {
logger.error("Connection to guacd terminated abnormally: {}", e.getMessage());
logger.debug("Internal error during connection to guacd.", e);
String message = Integer.toString(e.getStatus().getGuacamoleStatusCode());
afterConnectionClosed(session, new CloseStatus(e.getStatus().getWebSocketCode(), message));
}
} catch (Exception e) {
logger.debug("I/O error prevents further reads.", e);
}
}
};
readThread.start();
}
@Override
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
logger.debug("handleMessage");
// Ignore inbound messages if there is no associated tunnel
if (tunnel == null) {
return;
}
GuacamoleWriter writer = tunnel.acquireWriter();
try {
// Write received message
writer.write(message.getPayload().toString().toCharArray());
} catch (GuacamoleConnectionClosedException e) {
logger.debug("Connection to guacd closed.", e);
} catch (GuacamoleException e) {
logger.debug("WebSocket tunnel write failed.", e);
}
tunnel.releaseWriter();
}
@Override
public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
logger.debug("handleTransportError");
}
/**
* Sends the given status on the given WebSocket connection and closes the
* connection.
*
* @param session
* The outbound WebSocket connection to close.
* @param closeStatus
* The status to send.
*/
@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
logger.debug("afterConnectionClosed");
session.close(closeStatus);
try {
if (tunnel != null) {
tunnel.close();
}
} catch (GuacamoleException e) {
logger.debug("Unable to close WebSocket tunnel.", e);
}
}
@Override
public boolean supportsPartialMessages() {
return false;
}
}

View File

@ -22,33 +22,3 @@ git.repoDir=/data/repositories
spring.redis.host=127.0.0.1
spring.redis.port=6379
#guacamole
guacamole.server.ip=121.40.224.66
guacamole.server.port=54482
# mysql
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://rm-bp13v5020p7828r5rso.mysql.rds.aliyuncs.com:3306/testbridge?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
spring.datasource.username=testeducoder
spring.datasource.password=TEST@123
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.initialSize=200
spring.datasource.maxActive=400
spring.datasource.minIdle=200
spring.datasource.validationQuery=select 1
spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
spring.datasource.testWhileIdle=true
#mybatis.config-location=classpath:mybatis-config.xml
mybatis.type-aliases-package=net.educoder.bridge.**.model
mybatis.mapper-locations=classpath:mapper/*.xml
#mapper
mapper.mappers=tk.mybatis.springboot.util.MyMapper
mapper.not-empty=false
mapper.identity=MYSQL
#showSql
#logging.level.com.example.demo.dao=debug

View File

@ -39,7 +39,6 @@
<!-- 屏蔽框架输出 -->
<logger name="org.slf4j" level="ERROR" />
<logger name="org.springframework" level="ERROR" />
<logger name="io.swagger" level="ERROR" />
<logger name="ch.qos.logback" level="OFF" />
<logger name="springfox.documentation" level="ERROR" />
<logger name="com.spotify.docker.client" level="ERROR" />

View File

@ -1,191 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="net.educoder.bridge.dao.WindowsInfoMapper" >
<resultMap id="BaseResultMap" type="net.educoder.bridge.common.model.WindowsInfo" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="uniq_id" property="uniqId" jdbcType="VARCHAR" />
<result column="instance_id" property="instanceId" jdbcType="VARCHAR" />
<result column="user_id" property="userID" jdbcType="VARCHAR" />
<result column="port" property="port" jdbcType="VARCHAR" />
<result column="vnc_port" property="vncPort" jdbcType="VARCHAR" />
<result column="template_name" property="templateName" jdbcType="VARCHAR" />
<result column="auto_release_time" property="autoReleaseTime" jdbcType="TIMESTAMP" />
<result column="forward_table_id" property="forwardTableId" jdbcType="VARCHAR" />
<result column="forward_entry_id" property="forwardEntryId" jdbcType="VARCHAR" />
<result column="vnc_forward_entry_id" property="vncForwardEntryId" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="status" property="status" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, uniq_id, instance_id, user_id, port, vnc_port, template_name, auto_release_time, forward_table_id, forward_entry_id, vnc_forward_entry_id, status
</sql>
<select id="selectByUniqId" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from windows_info
where uniq_id = #{uniqId,jdbcType=VARCHAR} and status = 0 limit 1
</select>
<select id="selectByUserId" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from windows_info
where user_id = #{userID,jdbcType=VARCHAR}
and status = 0
</select>
<select id="selectByTpiId" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from windows_info
where uniq_id like concat( #{tpiId,jdbcType=VARCHAR} , '%') and status = 0
</select>
<select id="selectUniqIdByAutoReleaseTime" resultType="java.lang.String" parameterType="net.educoder.bridge.common.model.WindowsInfo">
SELECT uniq_id FROM windows_info
where status = 0
<if test="autoReleaseTime != null">
and auto_release_time &lt; #{autoReleaseTime,jdbcType=TIMESTAMP}
</if>
</select>
<select id="selectNotForwardEntryHost" resultMap="BaseResultMap" >
SELECT
<include refid="Base_Column_List" />
FROM windows_info
WHERE (forward_entry_id IS NULL OR (vnc_port IS NOT NULL AND vnc_forward_entry_id IS NULL)) and status = 0
</select>
<delete id="deleteByUniqId" parameterType="java.lang.String" >
update windows_info set status = -1
where uniq_id = #{uniqId,jdbcType=VARCHAR}
</delete>
<insert id="insertSelective" useGeneratedKeys="true" keyProperty="id"
parameterType="net.educoder.bridge.common.model.WindowsInfo" >
insert into windows_info
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="uniqId != null" >
uniq_id,
</if>
<if test="instanceId != null" >
instance_id,
</if>
<if test="userID != null" >
user_id,
</if>
<if test="port != null" >
port,
</if>
<if test="vncPort != null" >
vnc_port,
</if>
<if test="templateName != null" >
template_name,
</if>
<if test="autoReleaseTime != null" >
auto_release_time,
</if>
<if test="forwardTableId != null" >
forward_table_id,
</if>
<if test="forwardEntryId != null" >
forward_entry_id,
</if>
<if test="vncForwardEntryId != null" >
vnc_forward_entry_id,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="uniqId != null" >
#{uniqId,jdbcType=VARCHAR},
</if>
<if test="instanceId != null" >
#{instanceId,jdbcType=VARCHAR},
</if>
<if test="userID != null" >
#{userID,jdbcType=VARCHAR},
</if>
<if test="port != null" >
#{port,jdbcType=VARCHAR},
</if>
<if test="vncPort != null" >
#{vncPort,jdbcType=VARCHAR},
</if>
<if test="templateName != null" >
#{templateName,jdbcType=VARCHAR},
</if>
<if test="autoReleaseTime != null" >
#{autoReleaseTime,jdbcType=TIMESTAMP},
</if>
<if test="forwardTableId != null" >
#{forwardTableId,jdbcType=VARCHAR},
</if>
<if test="forwardEntryId != null" >
#{forwardEntryId,jdbcType=VARCHAR},
</if>
<if test="vncForwardEntryId != null" >
#{vncForwardEntryId,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByUniqIdSelective" parameterType="net.educoder.bridge.common.model.WindowsInfo" >
update windows_info
<set >
<if test="instanceId != null" >
instance_id = #{instanceId,jdbcType=VARCHAR},
</if>
<if test="userID != null" >
user_id = #{userID,jdbcType=VARCHAR},
</if>
<if test="port != null" >
port = #{port,jdbcType=INTEGER},
</if>
<if test="vncPort != null" >
vnc_port = #{vncPort,jdbcType=INTEGER},
</if>
<if test="templateName != null" >
template_name = #{templateName,jdbcType=VARCHAR},
</if>
<if test="autoReleaseTime != null" >
auto_release_time = #{autoReleaseTime,jdbcType=TIMESTAMP},
</if>
<if test="forwardTableId != null" >
forward_table_id = #{forwardTableId,jdbcType=VARCHAR},
</if>
<if test="forwardEntryId != null" >
forward_entry_id = #{forwardEntryId,jdbcType=VARCHAR},
</if>
<if test="vncForwardEntryId != null" >
vnc_forward_entry_id = #{vncForwardEntryId,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where uniq_id = #{uniqId,jdbcType=VARCHAR}
</update>
</mapper>