Commit 8ccdff94 authored by YangZhaoJun1's avatar YangZhaoJun1

召回被干掉的代码

parent 3eec852f
......@@ -54,8 +54,8 @@ public class BCodeController extends PaginationController {
@ApiImplicitParam(name = "examType", value = "类型 0001:JAVA单文件,0002:JAVA工程,1001:HTML单文件,1002:HTML工程", required = true, dataType = "varchar")})
@GetMapping(value = "/queryOwnExamFiles")
public Result queryOwnExamFiles(@RequestParam("slId") String slId,
@RequestParam("chapId") String chapId,
@RequestParam("examType") String examType){
@RequestParam("chapId") String chapId,
@RequestParam("examType") String examType){
List<BCodeFile> list = bCodeServiceImpl.readExamFiles(slId, chapId, examType,
UserUtil.getUserInfoProp(getToken(), UserUtil.USER_ID),
UserUtil.getUserInfoProp(getToken(), UserUtil.USER_USERNAME));
......@@ -90,7 +90,7 @@ public class BCodeController extends PaginationController {
bCodeServiceImpl.saveOwnExamFiles(slId, chapId, examType, content,
UserUtil.getUserInfoProp(getToken(), UserUtil.USER_ID),
UserUtil.getUserInfoProp(getToken(), UserUtil.USER_USERNAME)
));
));
}
......@@ -101,8 +101,8 @@ public class BCodeController extends PaginationController {
@ApiOperation(value="导出学生代码文件", notes="根据学生Id导出学生代码文件")
@GetMapping(value = "/exportFilesWithoutAuth")
public void exportFilesWithoutAuth(String slId, String studentId, String type, String slCode, HttpServletResponse response)throws Exception{
String fileName = bCodeServiceImpl.exportFiles(slId, studentId, type, slCode);
this.downloadFiles(fileName,response);
String fileName = bCodeServiceImpl.exportFiles(slId, studentId, type, slCode);
this.downloadFiles(fileName,response);
}
......@@ -142,18 +142,13 @@ public class BCodeController extends PaginationController {
@ApiImplicitParam(name = "newFilePath", value = "新文件名(修改文件名时使用该参数)", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "content", value = "内容(修改文件内容时使用该参数)", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "slId", value = "开课Id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "chapId", value = "章节Id", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "fileType", value = "1新增文件夹,2新增文件,3修改文件名,4删除文件,5修改文件内容", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "codeType", value = "1单文件,2工程", required = false, dataType = "varchar")})
@ApiImplicitParam(name = "chapId", value = "章节Id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "fileType", value = "1新增文件夹,2新增文件,3修改文件名,4删除文件,5修改文件内容", required = true, dataType = "varchar")})
@ApiOperation(value="单文件或工程各种操作", notes="单文件或工程各种操作")
@GetMapping(value = "/createOrUpdateFiles")
public Result createOrUpdateFiles(String filePath, String newFilePath, String content, String slId, String chapId, String fileType, String codeType) throws Exception{
public Result createOrUpdateFiles(String filePath, String newFilePath, String content, String slId, String chapId, String fileType) throws Exception{
String codePath = "";
if(codeType.equals("1")){
codePath = global.getCOURSE_CODE_LOCATION();
}else{
codePath = global.getCOURSE_PROJECT_LOCATION();
}
codePath = global.getCOURSE_PROJECT_LOCATION();
String serverPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ global.getCOURSE_LOCATION() + File.separator
+ global.getSL_LOCATION() + File.separator
......@@ -179,4 +174,17 @@ public class BCodeController extends PaginationController {
MessageConstant.MESSAGE_ALERT_ERROR,
"");
}
@ApiImplicitParams({@ApiImplicitParam(name = "slId", value = "开课Id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "chapterId", value = "章节Id", required = true, dataType = "varchar")})
@ApiOperation(value="老师查看所有学生作业", notes="老师查看所有学生作业")
@GetMapping(value = "/queryAllStudentCode")
public Result queryAllStudentCode(String slId, String chapterId){
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bCodeServiceImpl.queryAllStudentCode(slId,chapterId));
}
}
......@@ -29,6 +29,8 @@ public class BCodeFile {
private String pId;
private String isFirstFile;
private String studentName;
/**
* 容器属性
*
......@@ -39,4 +41,13 @@ public class BCodeFile {
*/
private Map lxcParam;
public BCodeFile(String fileType, String content, Date lastModify, String name, String id, String pId, String isFirstFile) {
this.fileType = fileType;
this.content = content;
this.lastModify = lastModify;
this.name = name;
this.id = id;
this.pId = pId;
this.isFirstFile = isFirstFile;
}
}
......@@ -32,4 +32,6 @@ public interface BCodeService {
BCodeFile saveOwnExamFiles(String slId, String chapId, String examType, String content, String userInfoProp, String studentCode);
String exportFiles(String slId, String studentId, String type, String slCode);
List<List<BCodeFile>> queryAllStudentCode(String slId, String chapterId);
}
......@@ -118,18 +118,18 @@ public class BCodeServiceImpl implements BCodeService {
File simpleFile = new File(file);
if(!simpleFile.exists()) {
simpleFile.createNewFile();
codeFile = new BCodeFile("0", "", null, simpleFile.getName(),IdGen.uuid(), "","1",null);
codeFile = new BCodeFile("0", "", null, simpleFile.getName(),IdGen.uuid(), "","1");
codeFileList.add(codeFile);
}else{
String content = FileUtils.readFileToString(simpleFile);
///List<String> fileName = new ArrayList<>();
//fileName.add(simpleFile.getName());
codeFile = new BCodeFile("0", content,new Date(simpleFile.lastModified()), simpleFile.getName(), IdGen.uuid(),"1","",null);
codeFile = new BCodeFile("0", content,new Date(simpleFile.lastModified()), simpleFile.getName(), IdGen.uuid(),"1","");
codeFileList.add(codeFile);
}
}catch (Exception e){
log.debug(file + " is not exist");
codeFile = new BCodeFile("0", "", null, "","", "","0",null);
codeFile = new BCodeFile("0", "", null, "","", "","0");
codeFileList.add(codeFile);
}
......@@ -163,13 +163,13 @@ public class BCodeServiceImpl implements BCodeService {
BCodeFile simpleCodeFile = null;
if(!simplePath.exists()) {
simplePath.mkdirs();
simpleCodeFile = new BCodeFile("0", "", null, simplePath.getName(),IdGen.uuid(),"","0",null);
simpleCodeFile = new BCodeFile("0", "", null, simplePath.getName(),IdGen.uuid(),"","0");
codeFile.add(simpleCodeFile);
}else{
boolean isFile = true;
simpleCodeFile = new BCodeFile("0", "", null, simplePath.getName(),IdGen.uuid(),"0","",null);
codeFile.add(simpleCodeFile);
getFileList(simplePath,codeFile,simpleCodeFile,isFile);
simpleCodeFile = new BCodeFile("0", "", null, simplePath.getName(),IdGen.uuid(),"0","");
//codeFile.add(simpleCodeFile);
getFileList(simplePath,codeFile,simpleCodeFile,isFile,"");
}
/*容器是否已启动*/
byte[] results = rcRedisServiceImpl.getBytes(global.getLxcPrefix() + lxc.getUserId());
......@@ -199,7 +199,7 @@ public class BCodeServiceImpl implements BCodeService {
}catch (Exception e){
log.debug(path + " is not exist");
BCodeFile simpleCodeFile = new BCodeFile("0", "", null,"","","0", "",null);
BCodeFile simpleCodeFile = new BCodeFile("0", "", null,"","","0", "");
}
return codeFile;
......@@ -212,7 +212,7 @@ public class BCodeServiceImpl implements BCodeService {
* @param codeFile
* @throws IOException
*/
private void getFileList(File files,List<BCodeFile> codeFile,BCodeFile parentFile,boolean isFile) throws IOException {
private void getFileList(File files,List<BCodeFile> codeFile,BCodeFile parentFile,boolean isFile,String studentName) throws IOException {
BCodeFile bCodeFile = new BCodeFile();
bCodeFile.setContent("");
......@@ -221,6 +221,7 @@ public class BCodeServiceImpl implements BCodeService {
bCodeFile.setName(files.getName());
bCodeFile.setId(IdGen.uuid());
bCodeFile.setPId(parentFile.getId());
bCodeFile.setStudentName(studentName);
codeFile.add(bCodeFile);
if(files.isFile()){
if(isFile){
......@@ -234,7 +235,7 @@ public class BCodeServiceImpl implements BCodeService {
bCodeFile.setFileType("0");
File[] ffs=files.listFiles();
for (File ff : ffs) {
getFileList(ff, codeFile, bCodeFile, isFile);
getFileList(ff, codeFile, bCodeFile, isFile,studentName);
}
}
......@@ -304,11 +305,11 @@ public class BCodeServiceImpl implements BCodeService {
FileUtils.write(simpleFile,content,"UTF-8");
//List<String> fileName = new ArrayList<>();
//fileName.add(simpleFile.getName());
codeFile = new BCodeFile("0", content,new Date(simpleFile.lastModified()),simpleFile.getName(),IdGen.uuid(),"0", "",null);
codeFile = new BCodeFile("0", content,new Date(simpleFile.lastModified()),simpleFile.getName(),IdGen.uuid(),"0", "");
}catch (Exception e){
log.debug(file + "创建失败");
codeFile = new BCodeFile("0", "", null, "","","0","",null);
codeFile = new BCodeFile("0", "", null, "","","0","");
}
return codeFile;
}
......@@ -400,35 +401,7 @@ public class BCodeServiceImpl implements BCodeService {
return sl.getCode()+ "+" + sl.getLessonName() + ".zip";
}
/*private void exportFileToUser(String zipFile, HttpServletResponse response) {
InputStream bis = null;
try {
File file=new File(zipFile);
bis = new FileInputStream(zipFile);
response.reset();
response.setContentType("bin");
response.addHeader("Content-Disposition", "attachment; filename=\"" + file.getName() + "\"");
byte[] b = new byte[100];
int len;
try {
while ((len = bis.read(b)) > 0)
response.getOutputStream().write(b, 0, len);
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}catch (Exception e){
e.printStackTrace();
}finally {
if (bis != null)
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}*/
private String compressFiles(String compressPath) throws IOException {
String zipFile = "";
......@@ -451,4 +424,59 @@ public class BCodeServiceImpl implements BCodeService {
}
return zipFile;
}
@Override
public List<List<BCodeFile>> queryAllStudentCode(String slId, String chapterId){
List<List<BCodeFile>> list = new ArrayList<>();
String codePath = "";
String suffixName = "";
BCodeFile codeFile = null;
List<BCodeFile> students = new ArrayList<>();
List<BChapter> bChapters = bChapterRepository.queryBchapterStudentById(chapterId);
for(BChapter chapter : bChapters) {
if (chapter.getExperimentType().equals("1")) {//java单文件
codePath = global.getCOURSE_CODE_LOCATION();
suffixName = ".java";
} else if (chapter.getExperimentType().equals("2")) {//java工程
codePath = global.getCOURSE_PROJECT_LOCATION();
} else if (chapter.getExperimentType().equals("3")) {//html单文件
suffixName = ".html";
codePath = global.getCOURSE_CODE_LOCATION();
} else {//html工程
codePath = global.getCOURSE_PROJECT_LOCATION();
}
String path = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ global.getCOURSE_LOCATION() + File.separator
+ global.getSL_LOCATION() + File.separator
+ slId + File.separator
+ chapterId + File.separator
+ codePath + File.separator
+ chapter.getUserId() + File.separator
+ chapter.getStuId()
+ suffixName;
String studentName = chapter.getStuId()+" "+chapter.getStudentName();
try {
File file = new File(path);
if (file.exists()) {
if (file.isFile()) {//单文件的处理
String content = FileUtils.readFileToString(file);
codeFile = new BCodeFile("0", content, new Date(file.lastModified()), file.getName(), IdGen.uuid(), "0", "", studentName,null);
students.add(codeFile);
list.add(students);
}else if(file.isDirectory()){//工程的处理
List<BCodeFile> codeFiles = new ArrayList<>();
BCodeFile simpleCodeFile = null;
boolean isFile = true;
simpleCodeFile = new BCodeFile("0", "", null, file.getName(),IdGen.uuid(),"0","");
getFileList(file,codeFiles,simpleCodeFile,isFile,studentName);
list.add(codeFiles);
}
}
}catch (Exception e){
}
}
return list;
}
}
......@@ -26,6 +26,7 @@ import org.rcisoft.business.tquestion.entity.TQuestion;
import org.rcisoft.business.tquestion.service.TQuestionService;
import java.util.List;
import java.util.Map;
/**
* Created by yangzhaojun on 2018-1-15 19:49:07.
......@@ -42,7 +43,7 @@ public class TQuestionController extends PaginationController<TQuestion> {
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping
@PreAuthorize("hasRole('ROLE_1002')")
public Result add(@Valid TQuestion tQuestion, String[] questionOptions) {
public Result add(@Valid TQuestion tQuestion, List<Map<String,Object>> questionOptions) {
PersistModel data = tQuestionServiceImpl.save(tQuestion,questionOptions);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
......
......@@ -48,5 +48,12 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> {
@Update("<script> update t_question set del_flag = 1 and flag = 0 where FIND_IN_SET(business_id,idInfoList)</script>")
int deleteByIds(String idInfoList);
@Insert("<script>INSERT INTO t_question_options " +
"(business_id,qid,desc,alias)VALUES " +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" +
"( #{item.businessId},#{item.qid},#{item.desc},#{item.alias})" +
"</foreach></script>")
int insertOptionsList(List<TQuestionOptions> optionList);
}
......@@ -21,7 +21,7 @@ import java.util.List;
public class TQuestionOptions extends IdEntity<TQuestionOptions> {
private static final long serialVersionUID = 375966816294919634L;
private String qid;
private String alias;
......
......@@ -5,6 +5,7 @@ import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.aop.PageUtil;
import java.util.List;
import java.util.Map;
/**
* Created by yangzhaojun on 2018-1-15 19:49:07.
......@@ -16,7 +17,7 @@ public interface TQuestionService {
* @param tQuestion
* @return
*/
PersistModel save(TQuestion tQuestion, String[] questionOptions);
PersistModel save(TQuestion tQuestion, List<Map<String,Object>> questionOptions);
/**
* 逻辑删除
......
......@@ -19,10 +19,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import lombok.extern.slf4j.Slf4j;
......@@ -45,20 +42,22 @@ public class TQuestionServiceImpl implements TQuestionService {
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel save(TQuestion tQuestion, String[] questionOptions){
List<String> list = Arrays.asList(questionOptions);
Map map = MapUtils.putAll(new HashMap(), questionOptions);
TQuestionOptions tQuestionOptions = new TQuestionOptions();
//增加操作
public PersistModel save(TQuestion tQuestion, List<Map<String,Object>> questionOptions){
List<TQuestionOptions> optionList = new ArrayList();
//增加主表题干信息
UserUtil.setCurrentPersistOperation(tQuestion);
int line = tQuestionRepository.insertSelective(tQuestion);
//增加选项信息
tQuestionOptions.setQid(tQuestion.getQid());
tQuestionOptions.setAlias(tQuestion.getAlias());
tQuestionOptions.setDesc(tQuestion.getDesc());
tQuestionRepository.insertQuestionOptions(tQuestionOptions);
log.info(UserUtil.getUserInfoProp(tQuestion.getToken(),UserUtil.USER_USERNAME)+"新增了ID为"+
tQuestion.getBusinessId()+"的信息");
for(Map<String,Object> map : questionOptions){
TQuestionOptions tQuestionOptions = new TQuestionOptions();
tQuestionOptions.setCommonBusinessId();
tQuestionOptions.setQid(tQuestion.getQid());
tQuestionOptions.setAlias(String.valueOf(map.get("alias")));
tQuestionOptions.setDesc(String.valueOf(map.get("desc")));
optionList.add(tQuestionOptions);
}
tQuestionRepository.insertOptionsList(optionList);
return new PersistModel(line);
}
......
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