Commit 4b98f49b authored by YangZhaoJun1's avatar YangZhaoJun1

完善接口

parent 1836d5d1
...@@ -66,12 +66,12 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -66,12 +66,12 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"), @ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "slId", value = "开课id", required = false, dataType = "varchar"), @ApiImplicitParam(name = "slId", value = "开课id", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "chapterName", value = "章节名称", required = true, dataType = "varchar"), @ApiImplicitParam(name = "chapterName", value = "章节名称", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "pid", value = "上一级", required = false, dataType = "varchar"), @ApiImplicitParam(name = "pid", value = "上一级", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "classHour", value = "课时", required = false, dataType = "varchar"), @ApiImplicitParam(name = "classHour", value = "课时", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "isTest", value = "1:实验 2:视频 3:PPT'", required = false, dataType = "varchar"), @ApiImplicitParam(name = "isTest", value = "1:实验 2:视频 3:PPT'", 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 = "lessonId", value = "课程ID(课程ID和开课ID只能存在一个)", required = false, dataType = "varchar")}) @ApiImplicitParam(name = "lessonId", value = "课程ID(课程ID和开课ID只能存在一个)", required = false, dataType = "varchar")})
@PreAuthorize("hasAnyRole('ROLE_1002','ROLE_1002')") @PreAuthorize("hasAnyRole('ROLE_1001','ROLE_1002')")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result add(@Valid BChapter bChapter, public Result add(@Valid BChapter bChapter,
BindingResult bindingResult BindingResult bindingResult
...@@ -91,7 +91,7 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -91,7 +91,7 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiOperation(value="删除章节", notes="根据ID删除一条记录") @ApiOperation(value="删除章节", notes="根据ID删除一条记录")
@ApiImplicitParam(name = "id", value = "businessId", required = true, dataType = "varchar") @ApiImplicitParam(name = "id", value = "businessId", required = true, dataType = "varchar")
@PreAuthorize("hasRole('ROLE_1002')") @PreAuthorize("hasAnyRole('ROLE_1001','ROLE_1002')")
@PostMapping(value = "/remove") @PostMapping(value = "/remove")
public Result remove(String id) { public Result remove(String id) {
PersistModel data = bChapterService.removeBChapter(id,getToken()); PersistModel data = bChapterService.removeBChapter(id,getToken());
......
...@@ -46,13 +46,14 @@ public interface BChapterRepository extends BaseMapper<BChapter> { ...@@ -46,13 +46,14 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
*/ */
@Select("<script>SELECT\n" + @Select("<script>SELECT\n" +
" bc.*,\n" + " bc.*,\n" +
" (SELECT bv.video_url FROM b_video bv WHERE bv.business_id = bcv1.video_id) AS videoUrl,\n" + " bf.video_url AS videoUrl,\n" +
" (SELECT bv.video_url FROM b_video bv WHERE bv.business_id = bcv2.video_id) AS fileUrl,\n" + " bf.file_url AS fileUrl,\n" +
" bf.ppt_url AS pptUrl,\n" +
" bf.pdf_url AS pdfUrl,\n" +
" (SELECT count(*) FROM b_r_student_chapter brs WHERE brs.chapter_id = bc.business_id AND brs.score = - 1) AS studentNum \n" + " (SELECT count(*) FROM b_r_student_chapter brs WHERE brs.chapter_id = bc.business_id AND brs.score = - 1) AS studentNum \n" +
" FROM\n" + " FROM\n" +
" b_chapter bc\n" + " b_chapter bc\n" +
" LEFT JOIN b_r_chapter_video bcv1 ON bcv1.chapter_id = bc.business_id and bcv1.type = '0'\n" + " LEFT JOIN b_file bf ON bf.chapter_id = bc.business_id " +
" LEFT JOIN b_r_chapter_video bcv2 ON bcv2.chapter_id = bc.business_id and bcv2.type = '1'\n" +
" \n" + " \n" +
" WHERE\n" + " WHERE\n" +
" bc.del_flag = 0\n" + " bc.del_flag = 0\n" +
......
...@@ -71,10 +71,23 @@ public class BChapter extends IdEntity<BChapter> { ...@@ -71,10 +71,23 @@ public class BChapter extends IdEntity<BChapter> {
@Transient @Transient
private String videoUrl; private String videoUrl;
@Transient @Transient
private String fileUrl; private String fileUrl;
@Transient
private String pptUrl;
@Transient
private String pdfUrl;
/**
* 课程的父ID(当作map的key存放开课的父ID用)
*/
@Transient
private String lPid;
@Transient
private String sPid;
......
package org.rcisoft.business.bvideo.controller; package org.rcisoft.business.bfile.controller;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.rcisoft.business.bvideo.entity.BVideo; import org.rcisoft.business.bfile.entity.BFile;
import org.rcisoft.business.bvideo.service.BVideoService; import org.rcisoft.business.bfile.service.BFileService;
import org.rcisoft.common.component.Global; import org.rcisoft.common.component.Global;
import org.rcisoft.common.controller.PaginationController; import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.common.model.GridModel; import org.rcisoft.common.model.GridModel;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.core.constant.MessageConstant;
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.ResultCode;
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.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
...@@ -31,9 +29,9 @@ import java.util.List; ...@@ -31,9 +29,9 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/BVideo") @RequestMapping("/BVideo")
public class BVideoController extends PaginationController<BVideo> { public class BFileController extends PaginationController<BFile> {
@Autowired @Autowired
private BVideoService bVideoService; private BFileService bFileService;
@Autowired @Autowired
private Global global; private Global global;
...@@ -46,12 +44,12 @@ public class BVideoController extends PaginationController<BVideo> { ...@@ -46,12 +44,12 @@ public class BVideoController extends PaginationController<BVideo> {
@ApiImplicitParam(name = "remarks", value = "备注", required = false, dataType = "varchar")}) @ApiImplicitParam(name = "remarks", value = "备注", required = false, dataType = "varchar")})
@PreAuthorize("hasRole('ROLE_1002')") @PreAuthorize("hasRole('ROLE_1002')")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result add(BVideo bVideo) { public Result add(BFile bFile) {
PersistModel data = bVideoService.persist(bVideo,getToken()); PersistModel data = bFileService.persist(bFile,getToken());
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
bVideo); bFile);
} }
@ApiOperation(value="逻辑删除", notes="根据ID删除一条记录") @ApiOperation(value="逻辑删除", notes="根据ID删除一条记录")
...@@ -59,7 +57,7 @@ public class BVideoController extends PaginationController<BVideo> { ...@@ -59,7 +57,7 @@ public class BVideoController extends PaginationController<BVideo> {
@PreAuthorize("hasRole('ROLE_1001')") @PreAuthorize("hasRole('ROLE_1001')")
@PostMapping(value = "/remove") @PostMapping(value = "/remove")
public Result remove(String id) { public Result remove(String id) {
PersistModel data = bVideoService.removeBVideo(id,getToken()); PersistModel data = bFileService.removeBVideo(id,getToken());
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
...@@ -73,7 +71,7 @@ public class BVideoController extends PaginationController<BVideo> { ...@@ -73,7 +71,7 @@ public class BVideoController extends PaginationController<BVideo> {
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,
bVideoService.selectOne(businessId)); bFileService.selectOne(businessId));
} }
...@@ -84,9 +82,9 @@ public class BVideoController extends PaginationController<BVideo> { ...@@ -84,9 +82,9 @@ public class BVideoController extends PaginationController<BVideo> {
@ApiImplicitParam(name = "type", value = "'0'为视频,'1'为附件", required = false, dataType = "varchar"), @ApiImplicitParam(name = "type", value = "'0'为视频,'1'为附件", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "remarks", value = "备注", required = false, dataType = "varchar")}) @ApiImplicitParam(name = "remarks", value = "备注", required = false, dataType = "varchar")})
@GetMapping(value = "/queryBVideosByPagination") @GetMapping(value = "/queryBVideosByPagination")
public GridModel queryBVideosByPagination(BVideo param) { public GridModel queryBVideosByPagination(BFile param) {
param.setCreateBy(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID)); param.setCreateBy(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID));
bVideoService.queryBVideosByPagination(getPaginationUtility(),param); bFileService.queryBVideosByPagination(getPaginationUtility(),param);
GridModel gridModel = getGridModelResponse(); GridModel gridModel = getGridModelResponse();
return gridModel; return gridModel;
} }
...@@ -98,12 +96,12 @@ public class BVideoController extends PaginationController<BVideo> { ...@@ -98,12 +96,12 @@ public class BVideoController extends PaginationController<BVideo> {
@ApiImplicitParam(name = "type", value = "'0'为视频,'1'为附件", required = false, dataType = "varchar"), @ApiImplicitParam(name = "type", value = "'0'为视频,'1'为附件", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "remarks", value = "备注", required = false, dataType = "varchar")}) @ApiImplicitParam(name = "remarks", value = "备注", required = false, dataType = "varchar")})
@GetMapping(value = "/queryBVideos") @GetMapping(value = "/queryBVideos")
public Result queryBVideos(BVideo param) { public Result queryBVideos(BFile param) {
param.setCreateBy(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID)); param.setCreateBy(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID));
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,
bVideoService.queryBVideos(param)); bFileService.queryBVideos(param));
} }
...@@ -111,30 +109,14 @@ public class BVideoController extends PaginationController<BVideo> { ...@@ -111,30 +109,14 @@ public class BVideoController extends PaginationController<BVideo> {
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"), @ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "videoName", value = "视频名称", required = false, dataType = "varchar"), @ApiImplicitParam(name = "videoName", value = "视频名称", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "videoUrl", value = "视频地址", required = false, dataType = "varchar"), @ApiImplicitParam(name = "videoUrl", value = "视频地址", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "type", value = "'0'为视频,'1'为附件", required = false, dataType = "varchar"), @ApiImplicitParam(name = "type", value = "'0'为视频,'1'为附件,'2'为ppt,'3'为pdf", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "file", value = "视频文件", required = true, dataType = "MultipartFile")}) @ApiImplicitParam(name = "file", value = "视频文件", required = true, dataType = "MultipartFile")})
@PreAuthorize("hasRole('ROLE_1002')") @PreAuthorize("hasRole('ROLE_1002')")
@PostMapping(value = "/uploadVideo") @PostMapping(value = "/uploadVideo")
public Result uploadVideo(BVideo bVideo, HttpServletRequest request) { public Result uploadVideo(BFile bFile, HttpServletRequest request) {
Result result = new Result();
List<MultipartFile> list = ((MultipartHttpServletRequest)request).getFiles("file"); List<MultipartFile> list = ((MultipartHttpServletRequest)request).getFiles("file");
try{ try{
String pathName; String videoUrl = bFileService.uploadVideoToServer(list, bFile,getToken());
if (bVideo.getType().equals("0")){
pathName = global.getVIDEO_LOCATION();//视频路径
}else{
pathName = global.getFILE_LOCATION();//文件路径
}
String path= global.getBASE_UPLOAD_SERVER_LOCATION()
+ pathName
+ File.separator + bVideo.getLessonId() + File.separator;//根据开课ID区分文件
File outFile=new File(path);
if(!outFile.exists()){//判断保存路径是否存在,不存在新建
outFile.mkdirs();
}
String videoUrl = bVideoService.uploadVideoToServer(list,bVideo,path,getToken());
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(1),
"上传成功", "上传成功",
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
...@@ -161,7 +143,7 @@ public class BVideoController extends PaginationController<BVideo> { ...@@ -161,7 +143,7 @@ public class BVideoController extends PaginationController<BVideo> {
@ApiImplicitParam(name = "chapterId", value = "章节ID", required = true, dataType = "varchar") @ApiImplicitParam(name = "chapterId", value = "章节ID", required = true, dataType = "varchar")
@PostMapping(value = "/downloadFile") @PostMapping(value = "/downloadFile")
public Result downloadFile(String chapterId, HttpServletResponse response){ public Result downloadFile(String chapterId, HttpServletResponse response){
BVideo video = bVideoService.queryFileUrlByChapterId(chapterId); BFile video = bFileService.queryFileUrlByChapterId(chapterId);
BufferedInputStream bis = null; BufferedInputStream bis = null;
BufferedOutputStream bos = null; BufferedOutputStream bos = null;
if(video.getVideoUrl()!=""&&video.getVideoUrl()!=null){ if(video.getVideoUrl()!=""&&video.getVideoUrl()!=null){
......
package org.rcisoft.business.bfile.dao;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.bfile.entity.BFile;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* Created with gaowenfneg on 2017-10-9 14:34:56.
*/
@Repository
public interface BFileRepository extends BaseMapper<BFile> {
/**
* 根据条件查找
* @param param
* @return
*/
@Select("<script>select * from b_file</script>")
@ResultMap(value = "BaseResultMap" )
List<BFile> queryBVideos(Map<String, Object> param);
@Select("<script>SELECT * from b_file " +
"where chapter_id = #{chapterId} </script>")
@ResultMap(value = "BaseResultMap" )
BFile selectInfoByChapterId(String chapterId);
@Select("<script>SELECT * FROM b_file WHERE chapter_id = #{chapterId}</script>")
@ResultMap(value = "BaseResultMap" )
BFile queryFileUrlByChapterId(String chapterId);
@Select("<script>SELECT * FROM b_file WHERE chapter_id = #{chapterId}</script>")
@ResultMap(value = "BaseResultMap" )
BFile queryBVideoByChapterId(String chapterId);
}
package org.rcisoft.business.bvideo.entity; package org.rcisoft.business.bfile.entity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
...@@ -13,11 +13,11 @@ import javax.persistence.Transient; ...@@ -13,11 +13,11 @@ import javax.persistence.Transient;
* Created with gaowenfneg on 2017-10-9 14:34:56. * Created with gaowenfneg on 2017-10-9 14:34:56.
*/ */
@Entity @Entity
@Table(name = "b_video") @Table(name = "b_file")
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class BVideo extends IdEntity<BVideo> { public class BFile extends IdEntity<BFile> {
private static final long serialVersionUID = 5501554322621964535L; private static final long serialVersionUID = 5501554322621964535L;
/*视频名称*/ /*视频名称*/
...@@ -35,10 +35,10 @@ public class BVideo extends IdEntity<BVideo> { ...@@ -35,10 +35,10 @@ public class BVideo extends IdEntity<BVideo> {
private String pdfUrl; private String pdfUrl;
@Transient private String lessonId;//课程ID
private String lessonId;//开课ID
private String slId;//开课ID
@Transient
private String chapterId;//节ID private String chapterId;//节ID
} }
package org.rcisoft.business.bvideo.service; package org.rcisoft.business.bfile.service;
import org.rcisoft.business.bvideo.entity.BVideo; import org.rcisoft.business.bfile.entity.BFile;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -10,13 +10,13 @@ import java.util.List; ...@@ -10,13 +10,13 @@ import java.util.List;
/** /**
* Created by gaowenfneg on 2017-10-9 14:34:56. * Created by gaowenfneg on 2017-10-9 14:34:56.
*/ */
public interface BVideoService{ public interface BFileService {
/** /**
* 根据主键唯一查找 * 根据主键唯一查找
* @param businessId * @param businessId
* @return * @return
*/ */
BVideo selectOne(String businessId); BFile selectOne(String businessId);
/** /**
* 根据条件分页查找 * 根据条件分页查找
...@@ -24,21 +24,21 @@ public interface BVideoService{ ...@@ -24,21 +24,21 @@ public interface BVideoService{
* @param model * @param model
* @return * @return
*/ */
List<BVideo> queryBVideosByPagination(PageUtil pageUtil, BVideo model); List<BFile> queryBVideosByPagination(PageUtil pageUtil, BFile model);
/** /**
* 根据条件查找全部 * 根据条件查找全部
* @param model * @param model
* @return * @return
*/ */
List<BVideo> queryBVideos(BVideo model); List<BFile> queryBVideos(BFile model);
/** /**
* 插入 * 插入
* @param model * @param model
* @return * @return
*/ */
PersistModel persist(BVideo model,String token); PersistModel persist(BFile model, String token);
/** /**
* 逻辑删除 * 逻辑删除
...@@ -47,7 +47,7 @@ public interface BVideoService{ ...@@ -47,7 +47,7 @@ public interface BVideoService{
*/ */
PersistModel removeBVideo(String id, String token); PersistModel removeBVideo(String id, String token);
public String uploadVideoToServer(List<MultipartFile> list, BVideo bVideo, String path,String token); public String uploadVideoToServer(List<MultipartFile> list, BFile bFile, String token);
public BVideo queryFileUrlByChapterId(String chapterId); public BFile queryFileUrlByChapterId(String chapterId);
} }
package org.rcisoft.business.bsl.service.impl; package org.rcisoft.business.bsl.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.rcisoft.business.bchapter.dao.BChapterRepository; import org.rcisoft.business.bchapter.dao.BChapterRepository;
import org.rcisoft.business.bchapter.entity.BChapter; import org.rcisoft.business.bchapter.entity.BChapter;
...@@ -135,6 +136,7 @@ public class BSlServiceImpl implements BSlService { ...@@ -135,6 +136,7 @@ public class BSlServiceImpl implements BSlService {
//添加课程方向信息 //添加课程方向信息
direction.setBusinessId(IdGen.uuid()); direction.setBusinessId(IdGen.uuid());
direction.setSlId(model.getBusinessId()); direction.setSlId(model.getBusinessId());
direction.setDirectionId(model.getDirectionId());
bLessonRepository.insertLessonDirection(direction); bLessonRepository.insertLessonDirection(direction);
if(data!=0&&result!=0){ if(data!=0&&result!=0){
line= data; line= data;
...@@ -151,10 +153,7 @@ public class BSlServiceImpl implements BSlService { ...@@ -151,10 +153,7 @@ public class BSlServiceImpl implements BSlService {
ArrayList<String> repeatCode = new ArrayList<String>(); ArrayList<String> repeatCode = new ArrayList<String>();
ArrayList<String> lessonCode = new ArrayList<String>(); ArrayList<String> lessonCode = new ArrayList<String>();
ArrayList<String> teacherCode = new ArrayList<String>(); ArrayList<String> teacherCode = new ArrayList<String>();
ArrayList<String> gitlab = new ArrayList<String>();
ArrayList<String> termCode = new ArrayList<String>(); ArrayList<String> termCode = new ArrayList<String>();
ArrayList<String> classHour = new ArrayList<String>();
ArrayList<String> credits = new ArrayList<String>();
List<BSl> repeatSl = new ArrayList<>(); List<BSl> repeatSl = new ArrayList<>();
Map map = new HashMap(); Map map = new HashMap();
...@@ -166,7 +165,7 @@ public class BSlServiceImpl implements BSlService { ...@@ -166,7 +165,7 @@ public class BSlServiceImpl implements BSlService {
} }
for(String[] value:values){ //将数据封装到entity for(String[] value:values){ //将数据封装到entity
if(value.length>=4) { if(value.length>=6) {
//1. 检查数据正确性 //1. 检查数据正确性
BSl bSl = null; BSl bSl = null;
BSl b = new BSl(value[0]); BSl b = new BSl(value[0]);
...@@ -176,7 +175,7 @@ public class BSlServiceImpl implements BSlService { ...@@ -176,7 +175,7 @@ public class BSlServiceImpl implements BSlService {
bSl1.setLessonCode(value[1]); bSl1.setLessonCode(value[1]);
bSl1.setClassHour(value[4]); bSl1.setClassHour(value[4]);
bSl1.setCredits(value[5]); bSl1.setCredits(value[5]);
if (value[0] == null || value[0].equals("") || value[1] == null || value[1].equals("")) { if (StringUtils.isAnyEmpty(value[0]) || value[1] == null || value[1].equals("")) {
continue; continue;
} }
if ((bSl = bSlRepository.selectOne(b)) != null) { if ((bSl = bSlRepository.selectOne(b)) != null) {
...@@ -209,18 +208,6 @@ public class BSlServiceImpl implements BSlService { ...@@ -209,18 +208,6 @@ public class BSlServiceImpl implements BSlService {
bSl.setSlCoverUrl(bLessonRepository.queryBLessonByCode(value[1]).getDefaultUrl()); bSl.setSlCoverUrl(bLessonRepository.queryBLessonByCode(value[1]).getDefaultUrl());
UserUtil.setCurrentPersistOperation(bSl); UserUtil.setCurrentPersistOperation(bSl);
//3. 封装git lab
/*User user = userRepository.selectOne(new User(value[2]));
AccountDTO dto = new AccountDTO(user.getGitLabId(),user.getGitLabImpressionToken());
dto.setUsername(user.getGitLabUsername());
if(StringUtils.isEmpty(dto.getId())|| StringUtils.isEmpty(dto.getImpersonationToken())){
gitlab.add(value[2]);
continue;
}
Project project = action.createProject(pName,dto);
bSl.setGitLabProjectId(project.getId());
String pName = global.getGIT_LAB_PROJECT_PREFIX()+value[0];
bSl.setGitLabProjectName(pName);*/
if (!bSls.contains(bSl)) { if (!bSls.contains(bSl)) {
bSls.add(bSl); bSls.add(bSl);
} }
...@@ -256,18 +243,10 @@ public class BSlServiceImpl implements BSlService { ...@@ -256,18 +243,10 @@ public class BSlServiceImpl implements BSlService {
if(termCode.size()>0){ if(termCode.size()>0){
nullResult.append("以下学期编号不存在:").append(JSON.toJSONString(termCode)).append("。 "); nullResult.append("以下学期编号不存在:").append(JSON.toJSONString(termCode)).append("。 ");
} }
if(gitlab.size()>0){
nullResult.append("以下教师的gitlab账户不存在(请重试新增该教师):").append(JSON.toJSONString(gitlab));
}
result+=nullResult; result+=nullResult;
if(bSls.size()<1){ if(bSls.size()<1){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DB_INSERT_ERROR.getCode(),result); throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DB_INSERT_ERROR.getCode(),result);
} }
return new PersistModel(1,result); return new PersistModel(1,result);
} }
......
package org.rcisoft.business.bvideo.dao;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.bvideo.entity.BVideo;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* Created with gaowenfneg on 2017-10-9 14:34:56.
*/
@Repository
public interface BVideoRepository extends BaseMapper<BVideo> {
/**
* 根据条件查找
* @param param
* @return
*/
@Select("<script>select * from b_video</script>")
@ResultMap(value = "BaseResultMap" )
List<BVideo> queryBVideos(Map<String, Object> param);
@Insert("<script>insert into b_r_chapter_video (video_id,chapter_id,type) values (#{businessId},#{chapterId},#{type})</script>")
int insertChapterVideo(BVideo model);
@Select("<script>SELECT\n" +
"\tbv.* from b_video bv\n" +
"\tLEFT JOIN b_r_chapter_video bcv on bcv.video_id = bv.business_id\n" +
"\twhere bcv.chapter_id = #{0} " +
"and bcv.type = #{1}</script>")
@ResultMap(value = "BaseResultMap" )
BVideo selectInfoByChapterId(String chapterId, String type);
@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}\n" +
"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);
}
...@@ -68,6 +68,14 @@ public class Global { ...@@ -68,6 +68,14 @@ public class Global {
@Value("${global.path.file_location}") @Value("${global.path.file_location}")
private String FILE_LOCATION; private String FILE_LOCATION;
/*ppt路径*/
@Value("${global.path.ppt_location}")
private String PPT_LOCATION;
/*pdf路径*/
@Value("${global.path.pdf_location}")
private String PDF_LOCATION;
/*excel模板位置*/ /*excel模板位置*/
@Value("${global.path.excel_template_location}") @Value("${global.path.excel_template_location}")
private String EXCEL_TEMPLATE_LOCATION; private String EXCEL_TEMPLATE_LOCATION;
......
...@@ -107,9 +107,11 @@ global: ...@@ -107,9 +107,11 @@ global:
sl_location: sl sl_location: sl
freemarker_location: /freemarker freemarker_location: /freemarker
image_location: /upload image_location: /upload
video_location: /video video_location: video
temp_location: /temp temp_location: temp
file_location: /file file_location: file
ppt_location: ppt
pdf_location: pdf
excel_template_location: excel-template/ excel_template_location: excel-template/
cource_logo_location: /course/logo cource_logo_location: /course/logo
images_location: /images images_location: /images
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.rcisoft.business.bvideo.dao.BVideoRepository"> <mapper namespace="org.rcisoft.business.bfile.dao.BFileRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.bvideo.entity.BVideo"> <resultMap id="BaseResultMap" type="org.rcisoft.business.bfile.entity.BFile">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/> <id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<result column="del_flag" jdbcType="VARCHAR" property="delFlag"/> <result column="del_flag" jdbcType="VARCHAR" property="delFlag"/>
<result column="flag" jdbcType="VARCHAR" property="flag"/> <result column="flag" jdbcType="VARCHAR" property="flag"/>
...@@ -16,5 +16,8 @@ ...@@ -16,5 +16,8 @@
<result column="ppt_url" jdbcType="VARCHAR" property="pptUrl"/> <result column="ppt_url" jdbcType="VARCHAR" property="pptUrl"/>
<result column="pdf_url" jdbcType="VARCHAR" property="pdfUrl"/> <result column="pdf_url" jdbcType="VARCHAR" property="pdfUrl"/>
<result column="type" jdbcType="VARCHAR" property="type"/> <result column="type" jdbcType="VARCHAR" property="type"/>
<result column="chapter_id" jdbcType="VARCHAR" property="chapterId"/>
<result column="sl_id" jdbcType="VARCHAR" property="slId"/>
<result column="lesson_id" jdbcType="VARCHAR" property="lessonId"/>
</resultMap> </resultMap>
</mapper> </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