|
|
|
@ -1,23 +1,20 @@
|
|
|
|
|
package com.sztzjy.resource_center.controller.api;
|
|
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import com.sztzjy.resource_center.annotation.AnonymousAccess;
|
|
|
|
|
import com.sztzjy.resource_center.config.Constant;
|
|
|
|
|
import com.sztzjy.resource_center.entity.*;
|
|
|
|
|
import com.sztzjy.resource_center.mapper.SysOneCatalogMapper;
|
|
|
|
|
import com.sztzjy.resource_center.mapper.SysThreeCatalogMapper;
|
|
|
|
|
import com.sztzjy.resource_center.mapper.SysTwoCatalogMapper;
|
|
|
|
|
import com.sztzjy.resource_center.util.ResultEntity;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@Api(tags = "课程方面API")
|
|
|
|
@ -33,7 +30,7 @@ public class CourseApi {
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("查看二级目录")
|
|
|
|
|
@PostMapping("getAllTwoCatalogList")
|
|
|
|
|
public List<SysTwoCatalog> getAllTwoCatalogList(@RequestParam String schoolId,@RequestParam String systemOwner) {
|
|
|
|
|
public List<SysTwoCatalog> getAllTwoCatalogList(@RequestParam String schoolId, @RequestParam String systemOwner) {
|
|
|
|
|
SysOneCatalogExample sysOneCatalogExample = new SysOneCatalogExample();
|
|
|
|
|
sysOneCatalogExample.createCriteria().andOneNameEqualTo(systemOwner);
|
|
|
|
|
SysOneCatalog sysOneCatalog = oneCatalogMapper.selectByExample(sysOneCatalogExample).get(0);
|
|
|
|
@ -52,16 +49,92 @@ public class CourseApi {
|
|
|
|
|
@PostMapping("selectThreeCatalogListByTwoId")
|
|
|
|
|
@ApiOperation("根据二级目录ID查寻所有三级目录信息")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public List<SysThreeCatalog> selectChapterByCourseId(@RequestParam String twoId){
|
|
|
|
|
public List<SysThreeCatalog> selectChapterByCourseId(@RequestParam String twoId) {
|
|
|
|
|
SysThreeCatalogExample example = new SysThreeCatalogExample();
|
|
|
|
|
example.createCriteria().andTwoIdEqualTo(twoId);
|
|
|
|
|
example.setOrderByClause("sort asc");
|
|
|
|
|
List<SysThreeCatalog> sysThreeCatalogs = threeCatalogMapper.selectByExample(example);
|
|
|
|
|
return sysThreeCatalogs;
|
|
|
|
|
return sysThreeCatalogs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//增加二级目录 SysTwoCatalog systemOwner
|
|
|
|
|
//删除二级目录 TwoId schoolId systemOwner
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("添加二级目录")
|
|
|
|
|
@PostMapping("insertSysTwoCatalog")
|
|
|
|
|
public Boolean insertSysTwoCatalog(@RequestBody SysTwoCatalog sysTwoCatalog, @RequestParam String systemOwner) {
|
|
|
|
|
SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner);
|
|
|
|
|
if (sysOneCatalogs == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
String oneName = sysOneCatalogs.getOneName();
|
|
|
|
|
sysTwoCatalog.setTwoId(IdUtil.randomUUID());
|
|
|
|
|
sysTwoCatalog.setOneId(oneName);
|
|
|
|
|
sysTwoCatalog.setCreateTime(new Date());
|
|
|
|
|
sysTwoCatalog.setCreator(sysTwoCatalog.getCreator());
|
|
|
|
|
sysTwoCatalog.setSort(null);
|
|
|
|
|
twoCatalogMapper.insert(sysTwoCatalog);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private SysOneCatalog getSysOneCatalogs(String systemOwner) {
|
|
|
|
|
SysOneCatalogExample example = new SysOneCatalogExample();
|
|
|
|
|
example.createCriteria().andOneNameEqualTo(systemOwner);
|
|
|
|
|
List<SysOneCatalog> sysOneCatalogs = oneCatalogMapper.selectByExample(example);
|
|
|
|
|
return sysOneCatalogs.get(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//增加三级目录 SysThreeCatalog schoolId systemOwner
|
|
|
|
|
//删除三级目录 ThreeId schollId systemOwner
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("添加三级目录")
|
|
|
|
|
@PostMapping("insertSysThreeCatalog")
|
|
|
|
|
public Boolean insertSysThreeCatalog(@RequestBody SysThreeCatalog sysThreeCatalog, @RequestParam String systemOwner) {
|
|
|
|
|
try {
|
|
|
|
|
SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner);
|
|
|
|
|
sysThreeCatalog.setThreeId(IdUtil.randomUUID());
|
|
|
|
|
sysThreeCatalog.setOntId(sysOneCatalogs.getOneId());
|
|
|
|
|
sysThreeCatalog.setCreateTime(new Date());
|
|
|
|
|
threeCatalogMapper.insert(sysThreeCatalog);
|
|
|
|
|
return true;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除二级目录 TwoId
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("删除二级目录")
|
|
|
|
|
@PostMapping("deleteTwoCatalog")
|
|
|
|
|
public Boolean deleteTwoCatalog(@RequestParam String twoId) {
|
|
|
|
|
try {
|
|
|
|
|
SysTwoCatalog sysTwoCatalog = twoCatalogMapper.selectByPrimaryKey(twoId);
|
|
|
|
|
if (sysTwoCatalog.getCreator().equals("管理员")) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
twoCatalogMapper.deleteByPrimaryKey(twoId);
|
|
|
|
|
return true;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//删除三级目录 ThreeId
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("删除三级目录")
|
|
|
|
|
@PostMapping("deleteThreeCatalog")
|
|
|
|
|
public Boolean deleteThreeCatalog(@RequestParam String threeId) {
|
|
|
|
|
try {
|
|
|
|
|
SysThreeCatalog sysThreeCatalog = threeCatalogMapper.selectByPrimaryKey(threeId);
|
|
|
|
|
if (sysThreeCatalog.getCreator().equals("管理员")) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
threeCatalogMapper.deleteByPrimaryKey(threeId);
|
|
|
|
|
return true;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|