Commit 1836d5d1 authored by YangZhaoJun1's avatar YangZhaoJun1

2.0.1完善接口

parent 290e36ed
......@@ -159,8 +159,6 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiImplicitParam(name = "lessonId", value = "课程ID(课程ID和开课ID只能存在一个)", required = false, dataType = "varchar")})
@GetMapping(value = "/queryBChaptersWithoutAuth")
public Result queryBChapters(BChapter param) {
if (StringUtils.isEmpty(param.getSlId()))
throw new ServiceException(ResultServiceEnums.PARAMER_ERROR);
Map<String, Object> map = new HashedMap();
String userId = UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID);
List<SysRole> role = sysRoleRepository.queryCodeByBusinessId(userId);
......@@ -435,4 +433,30 @@ public class BChapterController extends PaginationController<BChapter> {
MessageConstant.MESSAGE_ALERT_ERROR,
slId);
}
@ApiOperation(value="章节向上调顺序", notes="章节向上调顺序")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "pid", value = "父节点ID", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "sort", value = "当前顺序", required = true, dataType = "Integer")})
@PostMapping(value = "/updateTopChapter")
public Result updateTopChapter(BChapter bChapter){
int data = bChapterService.updateTopChapter(bChapter);
return Result.builder(new PersistModel(data),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bChapter);
}
@ApiOperation(value="章节向下调顺序", notes="章节向下调顺序")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "pid", value = "父节点ID", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "sort", value = "当前顺序", required = true, dataType = "Integer")})
@PostMapping(value = "/updateDownChapter")
public Result updateDownChapter(BChapter bChapter){
int data = bChapterService.updateDownChapter(bChapter);
return Result.builder(new PersistModel(data),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bChapter);
}
}
......@@ -8,6 +8,7 @@ import org.rcisoft.business.bchapter.entity.BChapter;
import org.rcisoft.business.bchapter.vo.StudentChapterScoreVO;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.security.access.method.P;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
......@@ -34,7 +35,7 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
" and lesson_id = #{lessonId}\n" +
"</if>" +
"and lesson_or_sl = #{lessonOrSl} " +
"order by create_date</script>")
"order by sort asc</script>")
@ResultMap(value = "SupperChildListResultMap" )
List<BChapter> queryBChapters(Map<String, Object> param);
......@@ -57,7 +58,7 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
" bc.del_flag = 0\n" +
" AND bc.pid = #{pid}\n" +
" ORDER BY\n" +
" bc.create_date</script>")
" bc.sort asc</script>")
@ResultMap(value = "SupperChildListResultMap" )
List<BChapter> queryBChaptersByPid(String pid);
......@@ -160,12 +161,12 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
"(create_date,create_by,update_date,update_by," +
"del_flag,flag,business_id," +
"sl_id,chapter_name,chapter_level,pid," +
"chapter_url,md_file,is_test,lesson_or_sl)VALUES" +
"chapter_url,md_file,is_test,lesson_or_sl,class_hour,sort)VALUES" +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" +
"(#{item.createDate},#{item.createBy},#{item.updateDate},#{item.updateBy}," +
"#{item.delFlag},#{item.flag},#{item.businessId}," +
"#{item.slId},#{item.chapterName},#{item.chapterLevel},#{item.pid}," +
"#{item.chapterUrl},#{item.mdFile},#{item.isTest},#{item.lessonOrSl})" +
"#{item.chapterUrl},#{item.mdFile},#{item.isTest},#{item.lessonOrSl},#{item.classHour},#{item.sort})" +
"</foreach></script>")
int insertChapterList(List<BChapter> slList);
......@@ -193,5 +194,33 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
@Update("<script>update b_chapter set state = #{state} where sl_id = #{slId}</script>")
int updateAllStateBySlId(@Param("slId") String slId, @Param("state") String state);
@Select("<script>select DISTINCT IFNULL((select max(sort) from b_chapter where pid = #{pid} " +
"<if test=\"SlId !=null and SlId !=''\">AND sl_id = #{SlId} </if>" +
"<if test=\"lessonId !=null and lessonId !=''\">AND lesson_id = #{lessonId} </if>),0)+1 as sort</script>")
int selectMaxSort(@Param("pid") String pid,
@Param("SlId") String SlId,
@Param("lessonId") String lessonId);
@Select("<script>select * from b_chapter where sort &lt; #{sort} " +
"AND pid = #{pid} AND sl_id = #{slId} " +
"ORDER BY sort desc LIMIT 1</script>")
@ResultMap(value = "BaseResultMap" )
BChapter getlessChapter(BChapter bChapter);
@Update("<script>update b_chapter set sort = #{sort} where business_id = #{businessId}</script>")
int updateSortById(@Param("businessId") String businessId, @Param("sort") int sort);
@Select("<script>select * from b_chapter where sort &gt; #{sort} " +
"AND pid = #{pid} AND sl_id = #{slId} " +
"ORDER BY sort asc LIMIT 1</script>")
@ResultMap(value = "BaseResultMap" )
BChapter getBigChapter(BChapter bChapter);
@Select("<script>select * from b_chapter " +
"where del_flag = 0 and flag = 1 " +
"and sl_id = #{slId}</script>")
@ResultMap(value = "BaseResultMap" )
List<BChapter> queryChapterBySlId(String slId);
}
......@@ -57,7 +57,11 @@ public class BChapter extends IdEntity<BChapter> {
/*课程ID*/
private String lessonId;
/*课时*/
private String classHour;
/*章节排序*/
private Integer sort;
@Transient
private List<BChapterRepository> childList;
......
......@@ -97,4 +97,8 @@ public interface BChapterService{
int updateChapterState(BChapter bChapter);
int updateAllChapterState(String slId);
int updateTopChapter(BChapter bChapter);
int updateDownChapter(BChapter bChapter);
}
......@@ -17,6 +17,10 @@ import org.rcisoft.business.brslstudent.dao.BRSlStudentRepository;
import org.rcisoft.business.bsl.dao.BSlRepository;
import org.rcisoft.business.bsl.enums.AuditStatusEnum;
import org.rcisoft.business.bstudent.dao.BStudentRepository;
import org.rcisoft.business.bvideo.dao.BVideoRepository;
import org.rcisoft.business.bvideo.entity.BVideo;
import org.rcisoft.business.bvideo.entity.UrlDto;
import org.rcisoft.common.component.Global;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
......@@ -27,6 +31,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -49,6 +54,10 @@ public class BChapterServiceImpl implements BChapterService {
private BRSlStudentRepository brSlStudentRepository;
@Autowired
private BLessonRepository bLessonRepository;
@Autowired
private BVideoRepository bVideoRepository;
@Autowired
private Global global;
@Override
public BChapter selectOne(String businessId){
......@@ -98,6 +107,8 @@ public class BChapterServiceImpl implements BChapterService {
if(model.getIsTest()==null||model.getIsTest().equals("")){
model.setIsTest("");
}
int sort = bChapterRepository.selectMaxSort(model.getPid(),model.getSlId(),model.getLessonId());
model.setSort(sort);
line = bChapterRepository.insertSelective(model);
}else {
String state = bSlRepository.queryStateById(model.getSlId());
......@@ -184,14 +195,14 @@ public class BChapterServiceImpl implements BChapterService {
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Override
public int addBslFormLesson(String bLseeonId, String lessonCode, String slId) {
public int addBslFormLesson(String bLessonId, String lessonCode, String slId) {
int result = 0;
if(bLseeonId==null){
if(bLessonId==null){
BLesson bLseeon = bLessonRepository.queryBLessonByCode(lessonCode);
bLseeonId = bLseeon.getBusinessId();
bLessonId = bLseeon.getBusinessId();
}
//获取课程的章节列表
List<BChapter> lessonList = bChapterRepository.queryChapterByLessonId(bLseeonId);
List<BChapter> lessonList = bChapterRepository.queryChapterByLessonId(bLessonId);
List<BChapter> chapterList = new ArrayList<>();
//map存放章的ID(key:章名称 value:新的章ID)
Map map = new HashMap();
......@@ -205,6 +216,7 @@ public class BChapterServiceImpl implements BChapterService {
sl_chapter.setIsTest(lessonList.get(i).getIsTest());
sl_chapter.setClassHour(lessonList.get(i).getClassHour());
sl_chapter.setState(StateEnum.CLOSE.getCode());
sl_chapter.setSort(lessonList.get(i).getSort());
sl_chapter.setLessonOrSl("0");
UserUtil.setCurrentPersistOperation(sl_chapter);
if(lessonList.get(i).getPid().equals("-1")){
......@@ -223,12 +235,103 @@ public class BChapterServiceImpl implements BChapterService {
chapterList.get(i).setPid(String.valueOf(map.get(chapterName)));
}
}
String oldPath = global.getBASE_UPLOAD_SERVER_LOCATION()+File.separator
+global.getCOURSE_LOCATION()+File.separator
+global.getLESSON_LOCATION()+File.separator
+bLessonId;
String newPath = global.getBASE_UPLOAD_SERVER_LOCATION()+File.separator
+global.getCOURSE_LOCATION()+File.separator
+global.getSL_LOCATION()+File.separator
+slId;
//copyFileToSl(oldPath,newPath,bLessonId,slId);
if(chapterList.size()>0){
result = bChapterRepository.insertChapterList(chapterList);
}
return result;
}
/**
* 递归方法复制文件夹及子目录
* @param oldPath
* @param newPath
*/
private void copyFileToSl(String oldPath, String newPath, String bLessonId, String slId) {
UrlDto urlDto = new UrlDto();
File oldFile = new File(oldPath);
File[] fs=oldFile.listFiles();
File newFile=new File(newPath);
if(!newFile.exists()){
newFile.mkdirs();
}
for (File f : fs) {
if(f.isFile()){
fileCopy(f.getPath(),newPath+File.separator+f.getName()); //调用文件拷贝的方法
}else if(f.isDirectory()){
copyFileToSl(f.getPath(),newPath+File.separator+f.getName(), bLessonId, slId);
}
}
List<BChapter> leChapters = bChapterRepository.queryChapterByLessonId(bLessonId);
List<BChapter> slChapters = bChapterRepository.queryChapterBySlId(slId);
for (BChapter leBChapter : leChapters){
for(BChapter slChapter : slChapters){
if(leBChapter.getChapterName().equals(slChapter.getChapterName())){
BVideo bVideo = bVideoRepository.queryBVideoByChapterId(leBChapter.getBusinessId());
BVideo newVideo = new BVideo();
newVideo.setBusinessId(bVideo.getBusinessId());
if(bVideo!=null){
if(bVideo.getVideoUrl()!=null&&!bVideo.getVideoUrl().equals("")){
String newUrl = bVideo.getVideoUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setVideoUrl(path);
}
if(bVideo.getFileUrl()!=null&&!bVideo.getFileUrl().equals("")){
String newUrl = bVideo.getVideoUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setFileUrl(path);
}
if(bVideo.getPptUrl()!=null&&!bVideo.getPptUrl().equals("")){
String newUrl = bVideo.getVideoUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setPptUrl(path);
}
if(bVideo.getPdfUrl()!=null&&!bVideo.getPdfUrl().equals("")){
String newUrl = bVideo.getVideoUrl().replace(bLessonId,slId);
String path = newUrl.replace(leBChapter.getBusinessId(),slChapter.getBusinessId());
newVideo.setPdfUrl(path);
}
bVideoRepository.updateByPrimaryKeySelective(newVideo);
}
}
}
}
}
private void fileCopy(String oldPath, String newPath) {
BufferedReader br=null;
PrintStream ps=null;
try {
br=new BufferedReader(new InputStreamReader(new FileInputStream(oldPath)));
ps=new PrintStream(new FileOutputStream(newPath));
String s=null;
while((s=br.readLine())!=null){
ps.println(s);
ps.flush();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
if(br!=null) br.close();
if(ps!=null) ps.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Override
public int updateChapterState(BChapter bChapter) {
......@@ -262,4 +365,34 @@ public class BChapterServiceImpl implements BChapterService {
int result = bChapterRepository.updateAllStateBySlId(slId, state);
return result;
}
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Override
public int updateTopChapter(BChapter bChapter) {
int result = 0;
BChapter lessChapter = bChapterRepository.getlessChapter(bChapter);
int sort = bChapter.getSort();
int lessSort = lessChapter.getSort();
int data = bChapterRepository.updateSortById(bChapter.getBusinessId(),lessSort);
int data2 = bChapterRepository.updateSortById(lessChapter.getBusinessId(),sort);
if(data==data2){
result = 1;
}
return result;
}
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Override
public int updateDownChapter(BChapter bChapter) {
int result = 0;
BChapter bigChapter = bChapterRepository.getBigChapter(bChapter);
int sort = bChapter.getSort();
int bigSort = bigChapter.getSort();
int data = bChapterRepository.updateSortById(bChapter.getBusinessId(),bigSort);
int data2 = bChapterRepository.updateSortById(bigChapter.getBusinessId(),sort);
if(data==data2){
result = 1;
}
return result;
}
}
......@@ -27,7 +27,7 @@ public interface BSlRepository extends BaseMapper<BSl> {
"left join b_lesson_direction bld on bld.sl_id = sl.business_id " +
"left join b_direction bd on bd.business_id = bld.direction_id " +
" <where>" +
" sl.del_flag = '0' and sl.flag = '1'"+
" sl.del_flag = '0' and sl.flag = '1' "+
" <if test=\"isOnline !=NULL and isOnline !=''\">AND sl.is_online like CONCAT('%',#{isOnline},'%')</if>" +
" <if test=\"teacherName !=null and teacherName !=''\">AND u.name like CONCAT('%',#{teacherName},'%')</if>" +
" <if test=\"lessonName !=null and lessonName !=''\">AND lesson.lesson_name like CONCAT('%',#{lessonName},'%')</if>" +
......@@ -58,9 +58,9 @@ public interface BSlRepository extends BaseMapper<BSl> {
* @return
*/
@Insert("<script>INSERT INTO b_sl" +
"(create_date,update_date,del_flag,flag,business_id,code,lesson_code,teacher_code,term_code,sl_cover_url,git_lab_project_id,git_lab_project_name)VALUES" +
"(create_date,update_date,del_flag,flag,business_id,code,lesson_code,teacher_code,term_code,sl_cover_url,git_lab_project_id,git_lab_project_name,class_hour,credits)VALUES" +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" +
"( #{item.createDate},#{item.updateDate},#{item.delFlag},#{item.flag},#{item.businessId},#{item.code},#{item.lessonCode},#{item.teacherCode},#{item.termCode},#{item.slCoverUrl},#{item.gitLabProjectId},#{item.gitLabProjectName})" +
"( #{item.createDate},#{item.updateDate},#{item.delFlag},#{item.flag},#{item.businessId},#{item.code},#{item.lessonCode},#{item.teacherCode},#{item.termCode},#{item.slCoverUrl},#{item.gitLabProjectId},#{item.gitLabProjectName},#{item.classHour},#{item.credits})" +
"</foreach></script>")
int insertList(List<BSl> bSls);
......@@ -244,7 +244,7 @@ public interface BSlRepository extends BaseMapper<BSl> {
@Param("studentCode")String studentCode,
@Param("teacherCode")String teacherCode);
@Update("<script>update b_sl set audit_status=#{code} where business_id=#{code}</script>")
@Update("<script>update b_sl set audit_status=#{code} where business_id=#{slId}</script>")
int updateAuditStatus(@Param("slId") String slId, @Param("code") String code);
@Select("select audit_status from b_sl where business_id = #{slId}")
......
......@@ -46,5 +46,16 @@ public interface BVideoRepository extends BaseMapper<BVideo> {
"AND brc.type = '1'</script>")
@ResultMap(value = "BaseResultMap" )
BVideo queryFileUrlByChapterId(String chapterId);
@Select("<script>SELECT\n" +
"\tbv.*\n" +
"FROM\n" +
"\tb_video bv\n" +
"LEFT JOIN b_r_chapter_video brc ON bv.business_id = brc.video_id\n" +
"WHERE\n" +
"\tbrc.chapter_id = #{chapterId}</script>")
@ResultMap(value = "BaseResultMap" )
BVideo queryBVideoByChapterId(String chapterId);
}
......@@ -19,6 +19,7 @@ import javax.persistence.Transient;
@AllArgsConstructor
public class BVideo extends IdEntity<BVideo> {
private static final long serialVersionUID = 5501554322621964535L;
/*视频名称*/
private String videoName;
......@@ -28,6 +29,12 @@ public class BVideo extends IdEntity<BVideo> {
/*'0'为视频,'1'为附件*/
private String type;
private String fileUrl;
private String pptUrl;
private String pdfUrl;
@Transient
private String lessonId;//开课ID
......
......@@ -36,6 +36,18 @@ public class Global {
@Value("${global.path.base_upload_server_location}")
private String BASE_UPLOAD_SERVER_LOCATION;
/*课程相关文件路径*/
@Value("${global.path.course_location}")
private String COURSE_LOCATION;
/*lesson相关文件路径*/
@Value("${global.path.lesson_location}")
private String LESSON_LOCATION;
/*sl相关文件路径*/
@Value("${global.path.sl_location}")
private String SL_LOCATION;
/*服务器freemarker模板位置*/
@Value("${global.path.freemarker_location}")
private String FREEMARKER_LOCATION;
......
......@@ -44,7 +44,7 @@ public class ExcelUtil {
int firstcolumnnum = hr.getFirstCellNum();
int lastcolumnnum = hr.getLastCellNum();
String[] value = new String[lastcolumnnum];
//boolean hasEmpty = false;
boolean hasEmpty = false;
for (int k = firstcolumnnum; k < lastcolumnnum; k++) {
HSSFCell hc = hr.getCell(k);
if (j==firstrownum + 1) {
......@@ -55,14 +55,14 @@ public class ExcelUtil {
emptyColList.add(k);
}
}
/*else {
else {
if (parseDB(hc).trim().equals("")&&emptyColList.get(k)!=-1) {
//在第j行第k列有空数据,且该列表头不是空的,则舍弃本行数据。
hasEmpty = true;
break;
}
}*/
}
value[k] = parseDB(hc);
//parseDB(hc.getCellType(), hc);
......@@ -73,9 +73,9 @@ public class ExcelUtil {
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_HEADER_ERROR);
}
}else{
//if (!hasEmpty) {
if (!hasEmpty) {
values.add(value);
//}
}
}
}
}
......
......@@ -11,9 +11,9 @@ server:
# org.springframework.web: DEBUG
druid:
url: jdbc:mysql://127.0.0.1:3306/edu_db2?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
url: jdbc:mysql://127.0.0.1:3306/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
username: root
password: 123456
password: root
initial-size: 1
min-idle: 1
max-active: 20
......@@ -102,6 +102,9 @@ global:
max_password: 16
path:
base_upload_server_location: E:\\eduFiles
course_location: course
lesson_location: lesson
sl_location: sl
freemarker_location: /freemarker
image_location: /upload
video_location: /video
......
......@@ -21,6 +21,7 @@
<result column="lesson_id" jdbcType="VARCHAR" property="lessonId"/>
<result column="class_hour" jdbcType="VARCHAR" property="classHour"/>
<result column="state" jdbcType="VARCHAR" property="state"/>
<result column="sort" jdbcType="INTEGER" property="sort"/>
</resultMap>
<resultMap id="SupperChildListResultMap" type="org.rcisoft.business.bchapter.entity.BChapter" extends="BaseResultMap">
......
......@@ -12,6 +12,9 @@
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="video_name" jdbcType="VARCHAR" property="videoName"/>
<result column="video_url" jdbcType="VARCHAR" property="videoUrl"/>
<result column="file_url" jdbcType="VARCHAR" property="fileUrl"/>
<result column="ppt_url" jdbcType="VARCHAR" property="pptUrl"/>
<result column="pdf_url" jdbcType="VARCHAR" property="pdfUrl"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
</resultMap>
</mapper>
\ No newline at end of file
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