Commit e68a7ec9 authored by 李丛阳's avatar 李丛阳

zip

parent 9706c239
...@@ -93,11 +93,6 @@ ...@@ -93,11 +93,6 @@
<artifactId>spring-boot-starter-aop</artifactId> <artifactId>spring-boot-starter-aop</artifactId>
</dependency> </dependency>
<!--spring boot redis starter-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!--spring boot freemarker starter--> <!--spring boot freemarker starter-->
<dependency> <dependency>
...@@ -297,6 +292,14 @@ ...@@ -297,6 +292,14 @@
<version>3.15</version> <version>3.15</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.apache.ant/ant -->
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.9.0</version>
<!-- 1.10 需要jdk1.8-->
</dependency>
<!-- SerializationUtils 序列化 --> <!-- SerializationUtils 序列化 -->
<dependency> <dependency>
<groupId>com.dyuproject.protostuff</groupId> <groupId>com.dyuproject.protostuff</groupId>
......
...@@ -14,18 +14,18 @@ import org.rcisoft.core.exception.ServiceException; ...@@ -14,18 +14,18 @@ import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.model.SelectModel; import org.rcisoft.core.model.SelectModel;
import org.rcisoft.core.result.Result; import org.rcisoft.core.result.Result;
import org.rcisoft.core.result.ResultCode;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -40,6 +40,7 @@ public class BClassController extends PaginationController<BClass> { ...@@ -40,6 +40,7 @@ public class BClassController extends PaginationController<BClass> {
@Autowired @Autowired
private Global global; private Global global;
@ApiOperation(value="添加/编辑班级", notes="businessId为空时是添加方法,不为空时是修改方法") @ApiOperation(value="添加/编辑班级", notes="businessId为空时是添加方法,不为空时是修改方法")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"), @ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "code", value = "班级编号", required = true, dataType = "varchar"), @ApiImplicitParam(name = "code", value = "班级编号", required = true, dataType = "varchar"),
......
...@@ -33,4 +33,6 @@ public class BCodeLxc { ...@@ -33,4 +33,6 @@ public class BCodeLxc {
/*workingDir*/ /*workingDir*/
private String workingDir; private String workingDir;
} }
package org.rcisoft.business.bcode.model;
import lombok.Data;
/**
* Created by lcy on 18/1/9.
*/
@Data
public class BPortsLxc {
/**
* 已开端口集合
*/
private String[] ports;
}
...@@ -12,6 +12,7 @@ import org.rcisoft.core.util.FreemarkerUtil; ...@@ -12,6 +12,7 @@ import org.rcisoft.core.util.FreemarkerUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -39,7 +40,14 @@ public class BCodeLxcServiceImpl implements BCodeLxcService { ...@@ -39,7 +40,14 @@ public class BCodeLxcServiceImpl implements BCodeLxcService {
param.put("lxcName",lxc.getUserId()); param.put("lxcName",lxc.getUserId());
param.put("lxcPort",22); param.put("lxcPort",22);
param.put("lxcPath",lxc.getWorkingDir()); param.put("lxcPath",lxc.getWorkingDir());
result = freemarkerUtil.generatorFileFromModel("","",param); //rcRedisServiceImpl.getBytes("lxcPorts");
/* config path*/
String destPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator +
global.getLxcDockerfilePath() + File.separator + lxc.getUserId() ;
result = freemarkerUtil.generatorFileFromModel(this.getModelProject(lxc.getCode()),destPath
,param);
if(!result.isSuccess())
return;
/*2.docker-compose 起容器*/ /*2.docker-compose 起容器*/
result = LxcCommand.startOrDownLxc(""); result = LxcCommand.startOrDownLxc("");
if(!result.isSuccess()) if(!result.isSuccess())
...@@ -47,9 +55,26 @@ public class BCodeLxcServiceImpl implements BCodeLxcService { ...@@ -47,9 +55,26 @@ public class BCodeLxcServiceImpl implements BCodeLxcService {
/*3.redis 放置状态*/ /*3.redis 放置状态*/
rcRedisServiceImpl.setBytes(global.getLxcPrefix() + lxc.getUserId(), rcRedisServiceImpl.setBytes(global.getLxcPrefix() + lxc.getUserId(),
SerializationUtils.serializer(lxc)); SerializationUtils.serializer(lxc));
/*4.定时关闭 */
/*5.端口放进去 */
//SerializationUtils.deserializer(bytes, BCodeLxc.class); //SerializationUtils.deserializer(bytes, BCodeLxc.class);
} }
/**
* 或许模型
* @param code
* @return
*/
private String getModelProject(String code) {
if(global.getJavaProject().equals(code))
return "java";
else if(global.getHtmlProject().equals(code))
return "html";
else
return "";
}
@Override @Override
......
...@@ -248,4 +248,8 @@ public class Global { ...@@ -248,4 +248,8 @@ public class Global {
@Value("${lxc.lxc_ports") @Value("${lxc.lxc_ports")
private String lxcPorts; private String lxcPorts;
@Value("${lxc.lxc_dockerfilePath")
private String lxcDockerfilePath;
} }
package org.rcisoft.core.util;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Zip;
import org.apache.tools.ant.types.FileSet;
import java.io.File;
import java.io.Serializable;
/**
* Created by lcy on 17/7/6.
*
* 压缩
*/
public class ZipCompress implements Serializable {
private static final long serialVersionUID = -2522528934048955246L;
public ZipCompress() {
}
/**
* 执行压缩操作
* @param srcPathName 需要被压缩的文件/文件夹
*/
public static void compressExe(String srcPathName,String dest) {
File srcdir = new File(srcPathName);
if (!srcdir.exists()){
throw new RuntimeException(srcPathName + "不存在!");
}
File zipFile = new File(dest);
Project prj = new Project();
Zip zip = new Zip();
zip.setProject(prj);
zip.setDestFile(zipFile);
FileSet fileSet = new FileSet();
fileSet.setProject(prj);
fileSet.setDir(srcdir);
//fileSet.setIncludes("**/*.java"); //包括哪些文件或文件夹 eg:zip.setIncludes("*.java");
fileSet.setExcludes(".DS_Store"); //排除哪些文件或文件夹
zip.addFileset(fileSet);
zip.execute();
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ZipCompress book = new ZipCompress();
try{
book.compressExe(
"/working/virtualDirectory/projectFiles/family/upload/codegenerate/0d76004eccb54b03ab9a07de145f520e/20170706224325/",
"/working/ZipTestCompressing.zip");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
...@@ -11,7 +11,7 @@ server: ...@@ -11,7 +11,7 @@ server:
# org.springframework.web: DEBUG # org.springframework.web: DEBUG
druid: druid:
url: jdbc:mysql://edu2_mysql:3306/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true url: jdbc:mysql://edu2_mysql:3306/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false
username: root username: root
password: 123456 password: 123456
initial-size: 1 initial-size: 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment