Commit eb5ca491 by xmh

1

1 parent ce3e7046
...@@ -14,13 +14,13 @@ import org.springframework.context.annotation.Configuration; ...@@ -14,13 +14,13 @@ import org.springframework.context.annotation.Configuration;
public class FtpConfiguration { public class FtpConfiguration {
@Value("${ftp.host:127.0.0.1}") @Value("${ftp.host:127.0.0.1}")
private String host;//主机名 private String host;
@Value("${ftp.port:21}") @Value("${ftp.port:21}")
private int port;//端口 private int port;
@Value("${ftp.username:}") @Value("${ftp.username:}")
private String username;//用户名 private String username;
@Value("${ftp.password:}") @Value("${ftp.password:}")
private String password;//密码 private String password;
@Value("${ftp.tempPath:}") @Value("${ftp.tempPath:}")
private String tempPath; private String tempPath;
...@@ -33,7 +33,6 @@ public class FtpConfiguration { ...@@ -33,7 +33,6 @@ public class FtpConfiguration {
ftpPoolConfig.setUsername(username); ftpPoolConfig.setUsername(username);
ftpPoolConfig.setPassword(password); ftpPoolConfig.setPassword(password);
//ftpPoolConfig.setMaxWaitMillis(1000); //ftpPoolConfig.setMaxWaitMillis(1000);
//ftpPoolConfig.setMaxIdle(2);
return ftpPoolConfig; return ftpPoolConfig;
} }
...@@ -48,8 +47,7 @@ public class FtpConfiguration { ...@@ -48,8 +47,7 @@ public class FtpConfiguration {
@Bean("ftpClientPool") @Bean("ftpClientPool")
@ConditionalOnBean(FTPClientFactory.class) @ConditionalOnBean(FTPClientFactory.class)
public FTPClientPool ftpClientPool(FTPClientFactory ftpClientFactory) { public FTPClientPool ftpClientPool(FTPClientFactory ftpClientFactory) {
FTPClientPool ftpClientPool = new FTPClientPool(ftpClientFactory); return new FTPClientPool(ftpClientFactory);
return ftpClientPool;
} }
@Bean("ftpClientHelper") @Bean("ftpClientHelper")
......
...@@ -13,7 +13,7 @@ import lombok.Setter; ...@@ -13,7 +13,7 @@ import lombok.Setter;
@Getter @Getter
@Setter @Setter
public abstract class BaseModel { public abstract class BaseModel {
protected Long empty; protected Long deviceId;
protected Long length; protected Long length;
protected Long firstInt; protected Long firstInt;
protected Long secondInt; protected Long secondInt;
...@@ -27,12 +27,37 @@ public abstract class BaseModel { ...@@ -27,12 +27,37 @@ public abstract class BaseModel {
* *
* @return model * @return model
*/ */
abstract public BaseModel decode(ByteBuf byteBuf); public void decode(ByteBuf byteBuf) {
this.deviceId = byteBuf.readUnsignedInt();
this.length = byteBuf.readUnsignedInt();
this.firstInt = byteBuf.readUnsignedInt();
this.secondInt = byteBuf.readUnsignedInt();
this.data = new byte[(int) (length - 16)];
byteBuf.readBytes(data);
decodeData();
}
;
/** /**
* 将 model 转换为 byteBuf * 将 model 转换为 byteBuf
* *
* @return byteBuf * @return byteBuf
*/ */
abstract public ByteBuf encode(); public void encode(ByteBuf byteBuf) {
encodeData();
byteBuf.writeInt((int) (deviceId & 0xff));
byteBuf.writeInt((int) (length & 0xff));
byteBuf.writeInt((int) (firstInt & 0xff));
byteBuf.writeInt((int) (secondInt & 0xff));
byteBuf.writeBytes(data);
}
;
abstract protected void encodeData();
abstract protected void decodeData();
} }
package com.viontech.model; package com.viontech.model;
import io.netty.buffer.ByteBuf;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.nio.charset.StandardCharsets;
/** /**
* . * .
* *
...@@ -17,14 +18,14 @@ public class LoginData extends BaseModel { ...@@ -17,14 +18,14 @@ public class LoginData extends BaseModel {
private String username; private String username;
private String password; private String password;
@Override @Override
public BaseModel decode(ByteBuf byteBuf) { protected void decodeData() {
return null; this.username = new String(data, 0, 32, StandardCharsets.UTF_8);
this.password = new String(data, 32, 32, StandardCharsets.UTF_8);
} }
@Override @Override
public ByteBuf encode() { protected void encodeData() {
return null;
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!