Commit 23c5ec19 authored by 李丛阳's avatar 李丛阳

merge

parents 7c91e9f9 653cf840
...@@ -65,7 +65,7 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -65,7 +65,7 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiImplicitParam(name = "classHour", value = "课时", required = false, dataType = "varchar"), @ApiImplicitParam(name = "classHour", value = "课时", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "experimentType", value = "实验类型,1:java单文件 2:java工程 3:html单文件 4:html工程", required = false, dataType = "varchar"), @ApiImplicitParam(name = "experimentType", value = "实验类型,1:java单文件 2:java工程 3:html单文件 4:html工程", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "lessonOrSl", value = "课程或开课;0:开课 1:课程", required = true, dataType = "varchar"), @ApiImplicitParam(name = "lessonOrSl", value = "课程或开课;0:开课 1:课程", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "isTest", value = "1:实验 2:视频 3:PPT 4:pdf 5:资料", required = false, dataType = "varchar"), @ApiImplicitParam(name = "isTest", value = "1:实验 2:视频 3:PPT 4:pdf 5:资料 6试题", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "lessonId", value = "课程ID(课程ID和开课ID只能存在一个)", required = false, dataType = "varchar")}) @ApiImplicitParam(name = "lessonId", value = "课程ID(课程ID和开课ID只能存在一个)", required = false, dataType = "varchar")})
@PreAuthorize("hasAnyRole('ROLE_1001','ROLE_1002')") @PreAuthorize("hasAnyRole('ROLE_1001','ROLE_1002')")
@PostMapping(value = "/add") @PostMapping(value = "/add")
......
...@@ -13,10 +13,10 @@ import org.rcisoft.core.exception.ServiceException; ...@@ -13,10 +13,10 @@ import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result; import org.rcisoft.core.result.Result;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.CompileUtil;
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.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -143,11 +143,12 @@ public class BCodeController extends PaginationController { ...@@ -143,11 +143,12 @@ public class BCodeController extends PaginationController {
@ApiImplicitParam(name = "content", value = "内容(修改文件内容时使用该参数)", required = false, dataType = "varchar"), @ApiImplicitParam(name = "content", value = "内容(修改文件内容时使用该参数)", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "slId", value = "开课Id", required = true, dataType = "varchar"), @ApiImplicitParam(name = "slId", value = "开课Id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "chapId", value = "章节Id", required = true, dataType = "varchar"), @ApiImplicitParam(name = "chapId", value = "章节Id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "fileType", value = "1新增文件夹,2新增文件,3修改文件名,4删除文件,5修改文件内容", required = true, dataType = "varchar")}) @ApiImplicitParam(name = "fileType", value = "1新增文件夹,2新增文件,3修改文件名,4删除文件,5修改文件内容, 6读取文件内容", required = true, dataType = "varchar")})
@ApiOperation(value="单文件或工程各种操作", notes="单文件或工程各种操作") @ApiOperation(value="单文件或工程各种操作", notes="单文件或工程各种操作")
@GetMapping(value = "/createOrUpdateFiles") @GetMapping(value = "/createOrUpdateFiles")
public Result createOrUpdateFiles(String filePath, String newFilePath, String content, String slId, String chapId, String fileType) throws Exception{ public Result createOrUpdateFiles(String filePath, String newFilePath, String content, String slId, String chapId, String fileType) throws Exception{
String codePath = ""; String codePath = "";
String javaCode = "";
codePath = global.getCOURSE_PROJECT_LOCATION(); codePath = global.getCOURSE_PROJECT_LOCATION();
String serverPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator String serverPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ global.getCOURSE_LOCATION() + File.separator + global.getCOURSE_LOCATION() + File.separator
...@@ -162,17 +163,31 @@ public class BCodeController extends PaginationController { ...@@ -162,17 +163,31 @@ public class BCodeController extends PaginationController {
}else if(fileType.equals("2")&&!file.exists()){//新增文件 }else if(fileType.equals("2")&&!file.exists()){//新增文件
file.createNewFile(); file.createNewFile();
}else if(fileType.equals("3")&&file.exists()){//修改文件名 }else if(fileType.equals("3")&&file.exists()){//修改文件名
File newFile = new File(newFilePath); File newFile = new File(serverPath+newFilePath);
file.renameTo(newFile); file.renameTo(newFile);
}else if(fileType.equals("4")&&file.exists()){//删除文件 }else if(fileType.equals("4")&&file.exists()){//删除文件
file.delete(); this.deleteFile(file);
}else if(fileType.equals("5")&&file.exists()){//修改文件内容 }else if(fileType.equals("5")&&file.exists()){//修改文件内容
FileUtils.write(file,content,"UTF-8"); FileUtils.write(file,content,"UTF-8");
}else if(fileType.equals("6")&&file.exists()){//读取文件内容
javaCode = FileUtils.readFileToString(file);
} }
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
""); javaCode);
}
private void deleteFile(File file) {
if (file.isFile()) {//判断是否是文件
file.delete();//删除文件
} else if (file.isDirectory()) {//否则如果它是一个目录
File[] files = file.listFiles();//声明目录下所有的文件 files[];
for (int i = 0;i < files.length;i ++) {//遍历目录下所有的文件
this.deleteFile(files[i]);//把每个文件用这个方法进行迭代
}
file.delete();//删除文件夹
}
} }
...@@ -187,4 +202,28 @@ public class BCodeController extends PaginationController { ...@@ -187,4 +202,28 @@ public class BCodeController extends PaginationController {
bCodeServiceImpl.queryAllStudentCode(slId,chapterId)); bCodeServiceImpl.queryAllStudentCode(slId,chapterId));
} }
@ApiImplicitParams({@ApiImplicitParam(name = "content", value = "代码", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "studentCode", value = "学号", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "fileName", value = "class名", required = true, dataType = "varchar")})
@ApiOperation(value="编译代码", notes="编译代码")
@GetMapping(value = "/compileCode")
public Result compileCode(String content, String studentCode, String fileName){
String fileUrl = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ global.getTEMP_LOCATION() + File.separator
+ global.getSTUDENT_CODE_LOCATION() + File.separator
+ studentCode + File.separator;
String executeResult = "";
try {
executeResult = CompileUtil.executeJavaCode(content, fileName, fileUrl);
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
executeResult);
} catch (Exception e) {
throw new ServiceException(ResultServiceEnums.COMPILING_CODE);
}
}
} }
...@@ -33,5 +33,5 @@ public interface BCodeService { ...@@ -33,5 +33,5 @@ public interface BCodeService {
String exportFiles(String slId, String studentId, String type, String slCode); String exportFiles(String slId, String studentId, String type, String slCode);
List<List<BCodeFile>> queryAllStudentCode(String slId, String chapterId); List<BCodeFile> queryAllStudentCode(String slId, String chapterId);
} }
...@@ -17,7 +17,6 @@ import org.rcisoft.business.bstudent.entity.BStudentDto; ...@@ -17,7 +17,6 @@ import org.rcisoft.business.bstudent.entity.BStudentDto;
import org.rcisoft.common.component.Global; import org.rcisoft.common.component.Global;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.result.CommandResult; import org.rcisoft.core.result.CommandResult;
import org.rcisoft.core.result.ResultExceptionEnum;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.service.RcRedisService; import org.rcisoft.core.service.RcRedisService;
import org.rcisoft.core.service.SerializationUtils; import org.rcisoft.core.service.SerializationUtils;
...@@ -76,13 +75,13 @@ public class BCodeServiceImpl implements BCodeService { ...@@ -76,13 +75,13 @@ public class BCodeServiceImpl implements BCodeService {
return this.readSimpleFile(slId,chapId,CodeType.SIM_JAVA,userInfo,studentCode); return this.readSimpleFile(slId,chapId,CodeType.SIM_JAVA,userInfo,studentCode);
/*java 工程*/ /*java 工程*/
if(examType.equals(global.getJavaProject())) if(examType.equals(global.getJavaProject()))
return this.readProjectFile(slId,chapId,userInfo,studentCode,global.getJavaProject()); return this.readProjectFile(slId,chapId,userInfo,studentCode);
/*html 单文件*/ /*html 单文件*/
if(examType.equals(global.getHtmlSimple())) if(examType.equals(global.getHtmlSimple()))
return this.readSimpleFile(slId,chapId,CodeType.SIM_HTML,userInfo,studentCode); return this.readSimpleFile(slId,chapId,CodeType.SIM_HTML,userInfo,studentCode);
/*html 工程*/ /*html 工程*/
if(examType.equals(global.getHtmlProject())) if(examType.equals(global.getHtmlProject()))
return this.readProjectFile(slId,chapId,userInfo,studentCode,global.getHtmlProject()); return this.readProjectFile(slId,chapId,userInfo,studentCode);
return null; return null;
} }
...@@ -439,8 +438,7 @@ public class BCodeServiceImpl implements BCodeService { ...@@ -439,8 +438,7 @@ public class BCodeServiceImpl implements BCodeService {
@Override @Override
public List<List<BCodeFile>> queryAllStudentCode(String slId, String chapterId){ public List<BCodeFile> queryAllStudentCode(String slId, String chapterId){
List<List<BCodeFile>> list = new ArrayList<>();
String codePath = ""; String codePath = "";
String suffixName = ""; String suffixName = "";
BCodeFile codeFile = null; BCodeFile codeFile = null;
...@@ -475,20 +473,18 @@ public class BCodeServiceImpl implements BCodeService { ...@@ -475,20 +473,18 @@ public class BCodeServiceImpl implements BCodeService {
String content = FileUtils.readFileToString(file); String content = FileUtils.readFileToString(file);
codeFile = new BCodeFile("0", content, new Date(file.lastModified()), file.getName(), IdGen.uuid(), "0", "", studentName,null); codeFile = new BCodeFile("0", content, new Date(file.lastModified()), file.getName(), IdGen.uuid(), "0", "", studentName,null);
students.add(codeFile); students.add(codeFile);
list.add(students);
}else if(file.isDirectory()){//工程的处理 }else if(file.isDirectory()){//工程的处理
List<BCodeFile> codeFiles = new ArrayList<>(); List<BCodeFile> codeFiles = new ArrayList<>();
BCodeFile simpleCodeFile = null; BCodeFile simpleCodeFile = null;
boolean isFile = true; boolean isFile = true;
simpleCodeFile = new BCodeFile("0", "", null, file.getName(),IdGen.uuid(),"0",""); simpleCodeFile = new BCodeFile("0", "", null, file.getName(),IdGen.uuid(),"0","");
getFileList(file,codeFiles,simpleCodeFile,isFile,studentName); getFileList(file,codeFiles,simpleCodeFile,isFile,studentName);
list.add(codeFiles);
} }
} }
}catch (Exception e){ }catch (Exception e){
} }
} }
return list; return students;
} }
} }
...@@ -40,7 +40,7 @@ public interface BDirectionRepository extends BaseMapper<BDirection> { ...@@ -40,7 +40,7 @@ public interface BDirectionRepository extends BaseMapper<BDirection> {
@ResultMap(value = "BaseResultMap") @ResultMap(value = "BaseResultMap")
List<BDirection> queryDirectionsList(); List<BDirection> queryDirectionsList();
@Insert("insert into b_lesson_direction (business_id,direction_id,sl_id) values (#{businessId},#{directionId},#{slId})") @Insert("insert into b_lesson_direction (business_id,direction_id,sl_id,lession_id) values (#{businessId},#{directionId},#{slId},#{lessionId})")
int insertBLessonDirection(BLessonDirection bDirection); int insertBLessonDirection(BLessonDirection bDirection);
} }
...@@ -47,9 +47,11 @@ public class BLesson extends IdEntity<BLesson> { ...@@ -47,9 +47,11 @@ public class BLesson extends IdEntity<BLesson> {
this.code = code; this.code = code;
} }
public BLesson(String code, String lessonName) { public BLesson(String code, String lessonName, String classHour, String credits) {
this.code = code; this.code = code;
this.lessonName = lessonName; this.lessonName = lessonName;
this.classHour = classHour;
this.credits = credits;
} }
@Override @Override
......
...@@ -2,6 +2,8 @@ package org.rcisoft.business.blesson.service.impl; ...@@ -2,6 +2,8 @@ package org.rcisoft.business.blesson.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.rcisoft.business.bdirection.dao.BDirectionRepository;
import org.rcisoft.business.bdirection.entity.BDirection;
import org.rcisoft.business.blesson.dao.BLessonRepository; import org.rcisoft.business.blesson.dao.BLessonRepository;
import org.rcisoft.business.blesson.entity.BLesson; import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.entity.BLessonDirection; import org.rcisoft.business.blesson.entity.BLessonDirection;
...@@ -40,6 +42,8 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -40,6 +42,8 @@ public class BLessonServiceImpl implements BLessonService {
private BSlRepository bSlRepository; private BSlRepository bSlRepository;
@Autowired @Autowired
private Global global; private Global global;
@Autowired
private BDirectionRepository bDirectionRepository;
@Override @Override
...@@ -101,8 +105,9 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -101,8 +105,9 @@ public class BLessonServiceImpl implements BLessonService {
ArrayList<BLesson> lessons = new ArrayList<BLesson>(); ArrayList<BLesson> lessons = new ArrayList<BLesson>();
ArrayList<String> repeatCode = new ArrayList<String>(); ArrayList<String> repeatCode = new ArrayList<String>();
List<String> errorCode = new ArrayList<>(); List<String> errorCode = new ArrayList<>();
ArrayList<String> direction = new ArrayList<String>();
String[] headers = {"课程编号","课程名称"}; String[] headers = {"课程编号","课程名称","课程方向","课时","学分"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers); //获取excel数据 ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers); //获取excel数据
...@@ -124,12 +129,24 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -124,12 +129,24 @@ public class BLessonServiceImpl implements BLessonService {
repeatCode.add(value[0]); repeatCode.add(value[0]);
continue; continue;
} }
bLesson= new BLesson(value[0],value[1]); BDirection b_direction = bDirectionRepository.selectOne(new BDirection(value[2]));
if (b_direction == null) {
if (!direction.contains(value[2]))
direction.add(value[2]);
continue;
}
bLesson= new BLesson(value[0],value[1],value[3],value[4]);
bLesson.setDefaultUrl(global.getDEFAULT_COURSE_LOCATION()); bLesson.setDefaultUrl(global.getDEFAULT_COURSE_LOCATION());
UserUtil.setCurrentPersistOperation(bLesson); UserUtil.setCurrentPersistOperation(bLesson);
if(!lessons.contains(bLesson)){ if(!lessons.contains(bLesson)){
lessons.add(bLesson); lessons.add(bLesson);
BLessonDirection bDirection = new BLessonDirection();
bDirection.setDirectionId(b_direction.getBusinessId());
bDirection.setBusinessId(IdGen.uuid());
bDirection.setLessionId(bLesson.getBusinessId());
bDirectionRepository.insertBLessonDirection(bDirection);
} }
} }
...@@ -152,6 +169,9 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -152,6 +169,9 @@ public class BLessonServiceImpl implements BLessonService {
if(errorCode.size()>0){ if(errorCode.size()>0){
result+="以下课程编号超过15位:"+ JSON.toJSONString(errorCode)+"。"; result+="以下课程编号超过15位:"+ JSON.toJSONString(errorCode)+"。";
} }
if(direction.size()>0){
result+="以下课程方向编号不存在:"+ JSON.toJSONString(direction)+"。";
}
if (lessons.size()<1){ if (lessons.size()<1){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST.getCode(),result); throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST.getCode(),result);
} }
......
...@@ -103,7 +103,7 @@ public class BRSlStudentServiceImpl implements BRSlStudentService { ...@@ -103,7 +103,7 @@ public class BRSlStudentServiceImpl implements BRSlStudentService {
if(value[0]==null||value[0].equals("")||value[1]==null||value[1].equals("")){ if(value[0]==null||value[0].equals("")||value[1]==null||value[1].equals("")){
continue; continue;
} }
if((bSl = bSlRepository.selectOne(new BSl(value[0])))==null) { if((bSl = bSlRepository.selectOne(new BSl(value[0],"0","1")))==null) {
if(!slCode.contains(value[0])) if(!slCode.contains(value[0]))
slCode.add(value[0]); slCode.add(value[0]);
continue; continue;
......
...@@ -124,7 +124,7 @@ public interface BSlRepository extends BaseMapper<BSl> { ...@@ -124,7 +124,7 @@ public interface BSlRepository extends BaseMapper<BSl> {
"AND t3.del_flag = 0\n" + "AND t3.del_flag = 0\n" +
"AND t3.flag = 1\n"+ "AND t3.flag = 1\n"+
"AND t2.audit_status != '4' "+ "AND t2.audit_status != '4' "+
"<if test=\"lessonName !=null and lessonName !=''\">AND t3.lesson_name like CONCAT('%',#{lessonName},'%') </if>" + "<if test=\"lessonName !=null and lessonName !=''\">AND (t3.lesson_name like CONCAT('%',#{lessonName},'%') or t2.`code` like CONCAT('%',#{lessonName},'%') ) </if>" +
"<if test=\"auditStatus !=null and auditStatus !=''\">AND t2.audit_status = #{auditStatus} </if>" + "<if test=\"auditStatus !=null and auditStatus !=''\">AND t2.audit_status = #{auditStatus} </if>" +
" <if test=\"termCode !=null and termCode !=''\">AND t2.term_code like CONCAT('%',#{termCode},'%') </if></script>") " <if test=\"termCode !=null and termCode !=''\">AND t2.term_code like CONCAT('%',#{termCode},'%') </if></script>")
List<SlDTO> selectTeacherSLByCode(@Param("teacherCode") String teacherCode, List<SlDTO> selectTeacherSLByCode(@Param("teacherCode") String teacherCode,
...@@ -146,7 +146,8 @@ public interface BSlRepository extends BaseMapper<BSl> { ...@@ -146,7 +146,8 @@ public interface BSlRepository extends BaseMapper<BSl> {
"(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','2','%' )) AS video,\n" + "(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','2','%' )) AS video,\n" +
"(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','3','%' )) AS ppt,\n" + "(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','3','%' )) AS ppt,\n" +
"(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','4','%' )) AS pdf,\n" + "(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','4','%' )) AS pdf,\n" +
"(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','5','%' )) AS file\n" + "(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','5','%' )) AS file,\n" +
"(select count(*) from b_chapter bc where bc.sl_id=t1.business_id and bc.is_test like CONCAT('%','6','%' )) AS questions\n" +
"FROM\n" + "FROM\n" +
"b_sl t1\n" + "b_sl t1\n" +
"LEFT JOIN b_lesson_direction t7 ON t1.business_id = t7.sl_id\n" + "LEFT JOIN b_lesson_direction t7 ON t1.business_id = t7.sl_id\n" +
......
...@@ -29,4 +29,5 @@ public class SlDetailDTO { ...@@ -29,4 +29,5 @@ public class SlDetailDTO {
private String directionCode; private String directionCode;
private String termName; private String termName;
private String auditStatus; private String auditStatus;
private String questions;
} }
...@@ -30,8 +30,10 @@ public class BSl extends IdEntity<BSl> { ...@@ -30,8 +30,10 @@ public class BSl extends IdEntity<BSl> {
this.termCode = termCode; this.termCode = termCode;
} }
public BSl(String code) { public BSl(String code, String delFlag, String flag) {
this.code = code; this.code = code;
this.delFlag = delFlag;
this.flag = flag;
} }
private String code;//课序号 private String code;//课序号
......
...@@ -117,7 +117,7 @@ public class BSlServiceImpl implements BSlService { ...@@ -117,7 +117,7 @@ public class BSlServiceImpl implements BSlService {
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA); throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
model.setSlCoverUrl(bLesson.getDefaultUrl()); model.setSlCoverUrl(bLesson.getDefaultUrl());
if(bSlRepository.selectOne(new BSl(model.getCode()))!=null) if(bSlRepository.selectOne(new BSl(model.getCode(),"0","1"))!=null)
throw new ServiceException(ResultServiceEnums.SL_EXISTS); throw new ServiceException(ResultServiceEnums.SL_EXISTS);
//3. 封装git lab //3. 封装git lab
/*User user = userRepository.selectOne(new User(model.getTeacherCode())); /*User user = userRepository.selectOne(new User(model.getTeacherCode()));
...@@ -170,7 +170,7 @@ public class BSlServiceImpl implements BSlService { ...@@ -170,7 +170,7 @@ public class BSlServiceImpl implements BSlService {
if(value.length>=4) { if(value.length>=4) {
//1. 检查数据正确性 //1. 检查数据正确性
BSl bSl = null; BSl bSl = null;
BSl b = new BSl(value[0]); BSl b = new BSl(value[0],"0","1");
BSl bSl1 = new BSl(); BSl bSl1 = new BSl();
bSl1.setTermCode(value[3]); bSl1.setTermCode(value[3]);
bSl1.setTeacherCode(value[2]); bSl1.setTeacherCode(value[2]);
...@@ -186,7 +186,7 @@ public class BSlServiceImpl implements BSlService { ...@@ -186,7 +186,7 @@ public class BSlServiceImpl implements BSlService {
continue; continue;
} }
// //
if ((bTeacherRepository.selectOne(new BTeacher(value[2]))) == null) { if ((bTeacherRepository.selectOne(new BTeacher(value[2],"0","1"))) == null) {
if (!teacherCode.contains(value[2])) if (!teacherCode.contains(value[2]))
teacherCode.add(value[2]); teacherCode.add(value[2]);
continue; continue;
......
...@@ -108,7 +108,7 @@ public class BSlApplyServiceImpl implements BSlApplyService { ...@@ -108,7 +108,7 @@ public class BSlApplyServiceImpl implements BSlApplyService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public void agreeApply(ApplyDTO applyDTO,String token) throws UnsupportedEncodingException { public void agreeApply(ApplyDTO applyDTO,String token) throws UnsupportedEncodingException {
if(bSlRepository.selectOne(new BSl(applyDTO.getSlCode()))!=null) if(bSlRepository.selectOne(new BSl(applyDTO.getSlCode(),"0","1"))!=null)
throw new ServiceException(ResultServiceEnums.SL_EXISTS); throw new ServiceException(ResultServiceEnums.SL_EXISTS);
if(bLessonRepository.selectOne(new BLesson(applyDTO.getCourseCode()))!=null) if(bLessonRepository.selectOne(new BLesson(applyDTO.getCourseCode()))!=null)
throw new ServiceException(ResultServiceEnums.LESSON_EXISTS); throw new ServiceException(ResultServiceEnums.LESSON_EXISTS);
......
...@@ -157,6 +157,8 @@ public class BStudentServiceImpl implements BStudentService { ...@@ -157,6 +157,8 @@ public class BStudentServiceImpl implements BStudentService {
//判断2:MySQL数据库中是否存在该用户; //判断2:MySQL数据库中是否存在该用户;
SysUser user1 =new SysUser(); SysUser user1 =new SysUser();
user1.setLoginName(value[0]); user1.setLoginName(value[0]);
user1.setDelFlag("0");
user1.setFlag("1");
if (sysUserMapper.selectOne(user1) != null) { if (sysUserMapper.selectOne(user1) != null) {
//该用户已存在,记入codeRepeat中 //该用户已存在,记入codeRepeat中
valuesRepeat.add(value[0]); valuesRepeat.add(value[0]);
...@@ -254,9 +256,10 @@ public class BStudentServiceImpl implements BStudentService { ...@@ -254,9 +256,10 @@ public class BStudentServiceImpl implements BStudentService {
} }
BStudent bStudent = new BStudent(); BStudent bStudent = new BStudent();
bStudent.setBusinessId(id); bStudent.setBusinessId(id);
UserUtil.setCurrentMergeOperation(bStudent);
BStudent student = bStudentRepository.selectOne(bStudent); BStudent student = bStudentRepository.selectOne(bStudent);
sysUserMapper.deleteByCode(student.getCode()); sysUserMapper.deleteByCode(student.getCode());
bStudent.setDeleted();
UserUtil.setCurrentMergeOperation(bStudent);
int line = bStudentRepository.logicalDelete(bStudent); int line = bStudentRepository.logicalDelete(bStudent);
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS); return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
} }
......
...@@ -22,8 +22,10 @@ public class BTeacher extends IdEntity<BTeacher> { ...@@ -22,8 +22,10 @@ public class BTeacher extends IdEntity<BTeacher> {
private static final long serialVersionUID = -4023201651225813372L; private static final long serialVersionUID = -4023201651225813372L;
public BTeacher(String code) { public BTeacher(String code, String delFlag, String flag) {
this.code = code; this.code = code;
this.delFlag = delFlag;
this.flag = flag;
} }
...@@ -53,5 +55,9 @@ public class BTeacher extends IdEntity<BTeacher> { ...@@ -53,5 +55,9 @@ public class BTeacher extends IdEntity<BTeacher> {
@Transient @Transient
private String headPic; private String headPic;
public BTeacher(String code) {
this.code = code;
}
} }
...@@ -108,6 +108,8 @@ public class BTeacherServiceImpl implements BTeacherService { ...@@ -108,6 +108,8 @@ public class BTeacherServiceImpl implements BTeacherService {
//判断2:MySQL数据库中是否存在该用户; //判断2:MySQL数据库中是否存在该用户;
SysUser user1 =new SysUser(); SysUser user1 =new SysUser();
user1.setLoginName(value[0]); user1.setLoginName(value[0]);
user1.setDelFlag("0");
user1.setFlag("1");
if (sysUserMapper.selectOne(user1) != null) { if (sysUserMapper.selectOne(user1) != null) {
//该用户已存在,记入codeRepeat中 //该用户已存在,记入codeRepeat中
valuesRepeat.add(value[0]); valuesRepeat.add(value[0]);
......
...@@ -46,12 +46,12 @@ public class TQuestionController extends PaginationController<TQuestion> { ...@@ -46,12 +46,12 @@ public class TQuestionController extends PaginationController<TQuestion> {
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")}) //@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping @PostMapping
@PreAuthorize("hasRole('ROLE_1002')") @PreAuthorize("hasRole('ROLE_1002')")
public Result add(@Valid TQuestion tQuestion, List<Map<String,Object>> questionOptions) { public Result add(TQuestion tQuestion, List<Map<String,Object>> questionOptions) {
PersistModel data = tQuestionServiceImpl.save(tQuestion,questionOptions); PersistModel data = tQuestionServiceImpl.save(tQuestion,questionOptions);
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
tQuestion); tQuestion);
} }
@ApiOperation(value = "新增选项",notes = "新增加一个选项") @ApiOperation(value = "新增选项",notes = "新增加一个选项")
...@@ -82,10 +82,10 @@ public class TQuestionController extends PaginationController<TQuestion> { ...@@ -82,10 +82,10 @@ public class TQuestionController extends PaginationController<TQuestion> {
@ApiOperation(value="删除题目", notes="根据ID删除一个题") @ApiOperation(value="删除题目", notes="根据ID删除一个题")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "businessId", required = true, dataType = "varchar")}) @ApiImplicitParam(name = "id", value = "businessId", required = true, dataType = "varchar")
@PostMapping("/remove") @PostMapping("/remove")
@PreAuthorize("hasRole('ROLE_1002')") @PreAuthorize("hasRole('ROLE_1002')")
public Result delete(@PathVariable String id) { public Result delete(String id) {
return Result.builder(new PersistModel(tQuestionServiceImpl.remove(id,getToken())), return Result.builder(new PersistModel(tQuestionServiceImpl.remove(id,getToken())),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
......
...@@ -30,12 +30,6 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> { ...@@ -30,12 +30,6 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> {
List<TQuestion> queryTQuestionsByPagination(TQuestion tQuestion); List<TQuestion> queryTQuestionsByPagination(TQuestion tQuestion);
@Insert("<script>INSERT INTO t_question_options (business_id,qid,alias,desc) VALUES " +
"(#{businessId},#{qid},#{alias},#{slId})</script>")
void insertQuestionOptions(TQuestionOptions model);
@Select("<script>select * " @Select("<script>select * "
+"from t_question tq" +"from t_question tq"
+"left join t_question_options tqo on tqo.qid = tq.business_id" +"left join t_question_options tqo on tqo.qid = tq.business_id"
...@@ -50,9 +44,9 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> { ...@@ -50,9 +44,9 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> {
int deleteByIds(String idInfoList); int deleteByIds(String idInfoList);
@Insert("<script>INSERT INTO t_question_options " + @Insert("<script>INSERT INTO t_question_options " +
"(business_id,qid,desc,alias)VALUES " + "(business_id,qid,describe,alias)VALUES " +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" + "<foreach collection=\"list\" item=\"item\" separator=\",\">" +
"( #{item.businessId},#{item.qid},#{item.desc},#{item.alias})" + "( #{item.businessId},#{item.qid},#{item.describe},#{item.alias})" +
"</foreach></script>") "</foreach></script>")
int insertOptionsList(List<TQuestionOptions> optionList); int insertOptionsList(List<TQuestionOptions> optionList);
} }
......
...@@ -26,7 +26,7 @@ public class TQuestionOptions extends IdEntity<TQuestionOptions> { ...@@ -26,7 +26,7 @@ public class TQuestionOptions extends IdEntity<TQuestionOptions> {
private String alias; private String alias;
private String desc; private String describe;
} }
......
...@@ -56,7 +56,7 @@ public class TQuestionServiceImpl implements TQuestionService { ...@@ -56,7 +56,7 @@ public class TQuestionServiceImpl implements TQuestionService {
tQuestionOptions.setCommonBusinessId(); tQuestionOptions.setCommonBusinessId();
tQuestionOptions.setQid(tQuestion.getQid()); tQuestionOptions.setQid(tQuestion.getQid());
tQuestionOptions.setAlias(String.valueOf(map.get("alias"))); tQuestionOptions.setAlias(String.valueOf(map.get("alias")));
tQuestionOptions.setDesc(String.valueOf(map.get("desc"))); tQuestionOptions.setDescribe(String.valueOf(map.get("describe")));
optionList.add(tQuestionOptions); optionList.add(tQuestionOptions);
} }
......
...@@ -131,6 +131,8 @@ public enum ResultServiceEnums { ...@@ -131,6 +131,8 @@ public enum ResultServiceEnums {
NO_STUDENT_HOMEWORK(72,"暂无学生提交作业"), NO_STUDENT_HOMEWORK(72,"暂无学生提交作业"),
DOWNLOAD_ERROR(73,"下载失败"), DOWNLOAD_ERROR(73,"下载失败"),
COMPILING_CODE (74,"运行失败,请重试")
; ;
private Integer code; private Integer code;
......
package org.rcisoft.core.util;
import java.io.*;
public class CompileUtil {
/**
* @param code 代码
* @param fileName 文件名
* @param fileUrl 文件所在目录
* @return
*/
public static String executeJavaCode(String code,String fileName,String fileUrl) throws Exception {
writeCodeToFile(code,fileName,fileUrl);
File file = new File(fileUrl+fileName+".java");
while(!file.exists()) {
Thread.sleep(10);
}
File dir = new File(fileUrl);
String os = System.getProperty("os.name");
String command1,command2;
if (os.toLowerCase().startsWith("win")) {
command1 = "c:\\Windows\\System32\\cmd.exe /c javac -encoding utf-8 "+fileName+".java";
command2 = "c:\\Windows\\System32\\cmd.exe /c java "+fileName;
} else {
command1 = "javac -encoding utf-8 "+fileName+".java";
command2 = "java "+fileName;
}
Runtime r1 = Runtime.getRuntime();
Process p1 = null;
Boolean comResult1 =true;
String result="";
try {
p1 = r1.exec(command1, null, dir);
InputStreamReader ir = new InputStreamReader(p1.getInputStream(),"GBK");
LineNumberReader input = new LineNumberReader(ir);
StringBuilder sb = new StringBuilder();
boolean firstLine = true;
String line;
while ((line = input.readLine()) != null) {
comResult1 = false;
if(!firstLine){
sb.append(System.getProperty("line.separator"));
}else{
firstLine = false;
}
sb.append(line);
}
input.close();
ir.close();
// result = new String(sb.toString().getBytes("iso8859-1"),"utf-8");
result = sb.toString();
/*if(input.readLine()!=null) {
comResult1 = false;
}*/
} catch (IOException e) {
e.printStackTrace();
}
if(!comResult1) {
return result;
}
String classUrl = fileUrl+fileName+".class";
File classFile = new File(classUrl);
while(!classFile.exists()) {
Thread.sleep(10);
if(!comResult1) {
break;
}
}
Runtime r2 = Runtime.getRuntime();
Process p2 = null;
try {
p2 = r2.exec(command2, null, dir);
InputStreamReader ir = new InputStreamReader(p2.getInputStream(),"GBK");
LineNumberReader input = new LineNumberReader(ir);
StringBuilder sb = new StringBuilder();
boolean firstLine = true;
String line;
while ((line = input.readLine()) != null) {
if(!firstLine){
sb.append(System.getProperty("line.separator"));
}else{
firstLine = false;
}
sb.append(line);
}
input.close();
ir.close();
// result = new String(sb.toString().getBytes("iso8859-1"),"utf-8");
result = sb.toString();
//file.delete();
} catch (IOException e) {
e.printStackTrace();
result = "error";
}
p2.waitFor();
p2.destroy();
return result;
}
public static void writeCodeToFile(String code,String fileName,String fileUrl) throws Exception{
File file = new File(fileUrl+fileName+".java");
if(!file.getParentFile().exists()){
file.getParentFile().mkdirs();
}
Writer out = new FileWriter(file);
out.write(code);
out.close();
}
}
This diff is collapsed.
...@@ -17,7 +17,7 @@ import static javafx.scene.input.KeyCode.V; ...@@ -17,7 +17,7 @@ import static javafx.scene.input.KeyCode.V;
public interface SysUserMapper extends BaseMapper<SysUser> { public interface SysUserMapper extends BaseMapper<SysUser> {
@Select("<script>select * from s_user where login_name = #{username}</script>") @Select("<script>select * from s_user where login_name = #{username} and del_flag = 0 and flag = 1</script>")
@ResultMap(value = "BaseResultMap") @ResultMap(value = "BaseResultMap")
List<SysUser> queryUserByName(String username); List<SysUser> queryUserByName(String username);
...@@ -56,6 +56,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> { ...@@ -56,6 +56,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
@Select("<script>select password from s_user where business_id = #{userId} </script>") @Select("<script>select password from s_user where business_id = #{userId} </script>")
String queryPasswordById(String userId); String queryPasswordById(String userId);
@Update("update s_user set password = #{password} where login_name = #{userCode}") @Update("update s_user set password = #{password} where login_name = #{userCode} and del_flag = 0 and flag = 1")
int resetPassword( @Param("userCode") String userCode, @Param("password") String password); int resetPassword( @Param("userCode") String userCode, @Param("password") String password);
} }
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