SubjectTreeController.java 3.15 KB
package com.meishu.controller;


import com.meishu.common.ResponseData;
import com.meishu.common.ResponseVO;
import com.meishu.common.interceptor.LoginRequired;
import com.meishu.dto.subject.GetSubjectTreeDTO;
import com.meishu.dto.subject.UpdateTreeOrderDTO;
import com.meishu.model.SubjectTreeDO;
import com.meishu.service.SubjectTreeService;
import com.meishu.util.ConstantUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Tuyp
 * @since 2021-04-27
 */
@RestController
@Api(tags = "知识树")
@RequestMapping("/subjectTree")
public class SubjectTreeController {

    @Autowired
    private SubjectTreeService subjectTreeService;

    @PostMapping("updateSubjectTree")
    @ApiOperation("更新知识树子节点  id   treeName:知识点名称  parentId父节点id  treeNode 编号")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO updateSubjectTree(@RequestBody SubjectTreeDO subjectTreeDO){
        return ResponseData.generateCreatedResponse(0,subjectTreeService.updateSubjectTree(subjectTreeDO));
    }

    @PostMapping("addSubjectTree")
    @ApiOperation("添加知识树节点 subjectId 科目id parentId:父节点  treeName:知识点名称 " +
            "treeNode 编号 ")
    @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO addSubjectTree(@RequestBody SubjectTreeDO subjectTreeDO){
        return ResponseData.generateCreatedResponse(0,subjectTreeService.addSubjectTree(subjectTreeDO));
    }

    @PostMapping("deleteSubjectTree")
    @ApiOperation("删除子节点(递归删除) {id}")
    //@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
    public ResponseVO deleteSubjectTree(@RequestBody SubjectTreeDO subjectTreeDO){
        return ResponseData.generateCreatedResponse(0,subjectTreeService.deleteSubjectTree(subjectTreeDO));
    }

    @PostMapping("updateTreeOrder")
    @ApiOperation("知识点排序  {ids[]知识树id  parentId  }")
    public ResponseVO updateTreeOrder(@RequestBody UpdateTreeOrderDTO updateTreeOrderDTO){
        return ResponseData.generateCreatedResponse(0,subjectTreeService.updateTreeOrder(updateTreeOrderDTO));
    }

    @PostMapping("getTreesCnt")
    @ApiOperation("获取知识树+ 题目视频数  subjectId userId")
    public ResponseVO getTreesCnt(@RequestBody GetSubjectTreeDTO getSubjectTreeDTO){
        return ResponseData.generateCreatedResponse(0,subjectTreeService.getTreesCnt(getSubjectTreeDTO));
    }

    @PostMapping("getTreesCheckCnt")
    @ApiOperation("获取知识树+ 视频题目审核数  subjectId userId  shareStatus 2:待审核   1已审核")
    public ResponseVO getTreesCheckCnt(@RequestBody GetSubjectTreeDTO getSubjectTreeDTO){
        return ResponseData.generateCreatedResponse(0,subjectTreeService.getTreesCheckCnt(getSubjectTreeDTO));
    }


}