新增三方接口

master
xiaoCJ 8 months ago
parent 921063a630
commit 7b3cb401fc

@ -1,23 +1,20 @@
package com.sztzjy.resource_center.controller.api; package com.sztzjy.resource_center.controller.api;
import com.github.pagehelper.PageHelper; import cn.hutool.core.util.IdUtil;
import com.github.pagehelper.PageInfo;
import com.sztzjy.resource_center.annotation.AnonymousAccess; import com.sztzjy.resource_center.annotation.AnonymousAccess;
import com.sztzjy.resource_center.config.Constant; import com.sztzjy.resource_center.config.Constant;
import com.sztzjy.resource_center.entity.*; import com.sztzjy.resource_center.entity.*;
import com.sztzjy.resource_center.mapper.SysOneCatalogMapper; import com.sztzjy.resource_center.mapper.SysOneCatalogMapper;
import com.sztzjy.resource_center.mapper.SysThreeCatalogMapper; import com.sztzjy.resource_center.mapper.SysThreeCatalogMapper;
import com.sztzjy.resource_center.mapper.SysTwoCatalogMapper; import com.sztzjy.resource_center.mapper.SysTwoCatalogMapper;
import com.sztzjy.resource_center.util.ResultEntity;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
@RestController @RestController
@Api(tags = "课程方面API") @Api(tags = "课程方面API")
@ -33,7 +30,7 @@ public class CourseApi {
@AnonymousAccess @AnonymousAccess
@ApiOperation("查看二级目录") @ApiOperation("查看二级目录")
@PostMapping("getAllTwoCatalogList") @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 sysOneCatalogExample = new SysOneCatalogExample();
sysOneCatalogExample.createCriteria().andOneNameEqualTo(systemOwner); sysOneCatalogExample.createCriteria().andOneNameEqualTo(systemOwner);
SysOneCatalog sysOneCatalog = oneCatalogMapper.selectByExample(sysOneCatalogExample).get(0); SysOneCatalog sysOneCatalog = oneCatalogMapper.selectByExample(sysOneCatalogExample).get(0);
@ -52,7 +49,7 @@ public class CourseApi {
@PostMapping("selectThreeCatalogListByTwoId") @PostMapping("selectThreeCatalogListByTwoId")
@ApiOperation("根据二级目录ID查寻所有三级目录信息") @ApiOperation("根据二级目录ID查寻所有三级目录信息")
@AnonymousAccess @AnonymousAccess
public List<SysThreeCatalog> selectChapterByCourseId(@RequestParam String twoId){ public List<SysThreeCatalog> selectChapterByCourseId(@RequestParam String twoId) {
SysThreeCatalogExample example = new SysThreeCatalogExample(); SysThreeCatalogExample example = new SysThreeCatalogExample();
example.createCriteria().andTwoIdEqualTo(twoId); example.createCriteria().andTwoIdEqualTo(twoId);
example.setOrderByClause("sort asc"); example.setOrderByClause("sort asc");
@ -61,7 +58,83 @@ public class CourseApi {
} }
//增加二级目录 SysTwoCatalog systemOwner //增加二级目录 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 //增加三级目录 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;
}
}
} }

Loading…
Cancel
Save